Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions apps/docs/content/sdk-features/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,6 @@ These props configure how the editor initializes:
| `bindingUtils` | `TLBindingUtilConstructor[]` | Custom binding utilities |
| `tools` | `TLStateNodeConstructor[]` | Custom tools |
| `onMount` | `TLOnMountHandler` | Callback when editor mounts |
| `cameraOptions` | `Partial<TLCameraOptions>` | Camera constraints and behavior |
| `textOptions` | `TLTextOptions` | Rich text editor configuration |
| `deepLinks` | `true \| TLDeepLinkOptions` | Sync camera state with URL |
| `getShapeVisibility` | `(shape, editor) => 'visible' \| 'hidden' \| 'inherit'` | Conditionally hide shapes |
| `user` | `TLCurrentUser` | Current user information |
| `inferDarkMode` | `boolean` | Infer dark mode from OS preference |
Expand Down
56 changes: 31 additions & 25 deletions apps/docs/content/sdk-features/rich-text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ This configuration disables blockquotes, code blocks, and horizontal rules to ke

### Custom extensions

You can add custom TipTap extensions through the `textOptions` prop on the Tldraw component. This lets you add new formatting options, custom keyboard shortcuts, or specialized behavior:
You can add custom TipTap extensions through the `options` prop on the Tldraw component. This lets you add new formatting options, custom keyboard shortcuts, or specialized behavior:

```tsx
import { Mark, mergeAttributes } from '@tiptap/core'
Expand All @@ -139,16 +139,18 @@ const CustomMark = Mark.create({
},
})

const textOptions = {
tipTapConfig: {
extensions: [StarterKit, CustomMark],
const options = {
text: {
tipTapConfig: {
extensions: [StarterKit, CustomMark],
},
},
}

export default function App() {
return (
<div style={{ position: 'fixed', inset: 0 }}>
<Tldraw textOptions={textOptions} />
<Tldraw options={options} />
</div>
)
}
Expand Down Expand Up @@ -314,20 +316,22 @@ The function accepts an initial font state representing the base font. It walks

### Custom font resolution

You can override font resolution by providing a custom `addFontsFromNode` function through `textOptions`. This lets you use custom fonts or alternative font mapping strategies:
You can override font resolution by providing a custom `addFontsFromNode` function through `options.text`. This lets you use custom fonts or alternative font mapping strategies:

```typescript
const textOptions = {
tipTapConfig: {
extensions: [StarterKit],
},
addFontsFromNode: (node, state, addFont) => {
// Custom font resolution logic
if (node.marks.some((m) => m.type.name === 'bold')) {
state = { ...state, weight: 'bold' }
}
// Call addFont() with required font faces
return state
const options = {
text: {
tipTapConfig: {
extensions: [StarterKit],
},
addFontsFromNode: (node, state, addFont) => {
// Custom font resolution logic
if (node.marks.some((m) => m.type.name === 'bold')) {
state = { ...state, weight: 'bold' }
}
// Call addFont() with required font faces
return state
},
},
}
```
Expand Down Expand Up @@ -402,19 +406,21 @@ The rich text system offers several ways to customize behavior:
| **Custom toolbar** | Replace or extend the rich text toolbar with different formatting controls |
| **Font resolution** | Override font resolution to use custom fonts or alternative loading strategies |

The `textOptions` prop accepts a `tipTapConfig` object that passes through to TipTap's editor configuration, giving you access to all TipTap configuration options:
The `options.text` field accepts a `tipTapConfig` object that passes through to TipTap's editor configuration, giving you access to all TipTap configuration options:

```typescript
const textOptions = {
tipTapConfig: {
extensions: [...],
editorProps: {
attributes: {
class: 'custom-editor',
const options = {
text: {
tipTapConfig: {
extensions: [...],
editorProps: {
attributes: {
class: 'custom-editor',
},
},
},
addFontsFromNode: customFontResolver,
},
addFontsFromNode: customFontResolver,
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/tldraw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@tldraw/editor": "workspace:*",
"@tldraw/store": "workspace:*",
"classnames": "^2.5.1",
"hotkeys-js": "^3.13.9",
"hotkeys-js": "^4.0.2",
"idb": "^7.1.1",
"lz-string": "^1.5.0",
"radix-ui": "^1.4.2"
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19922,10 +19922,10 @@ __metadata:
languageName: node
linkType: hard

"hotkeys-js@npm:^3.13.9":
version: 3.13.9
resolution: "hotkeys-js@npm:3.13.9"
checksum: 10/452bf1763276bca14fad0d61c9374896f69606998dcef685c68729486cc19a59090d7902785e78e75bbf002025f6e3c7ef18dd1c10b9c5bec6b930b2e0b6e4d2
"hotkeys-js@npm:^4.0.2":
version: 4.0.2
resolution: "hotkeys-js@npm:4.0.2"
checksum: 10/76fdcff36899d3bf7abc5d9431fa5d404daccd81159eb8efd112480f403ca328ec471c636893150072228d60683b893450784454624af6fb77b1f0da7b4f377b
languageName: node
linkType: hard

Expand Down Expand Up @@ -29348,7 +29348,7 @@ __metadata:
"@types/react-dom": "npm:^19.2.3"
chokidar-cli: "npm:^3.0.0"
classnames: "npm:^2.5.1"
hotkeys-js: "npm:^3.13.9"
hotkeys-js: "npm:^4.0.2"
idb: "npm:^7.1.1"
lazyrepo: "npm:0.0.0-alpha.27"
lz-string: "npm:^1.5.0"
Expand Down
Loading