Skip to content

Commit 6c9e855

Browse files
authored
docs: review and update guide pages (Fable) (tldraw#9091)
In order to keep the documentation guides accurate and readable, this PR reviews all 104 guide pages under `apps/docs/content` (getting started, learn tldraw, SDK features, starter kits, and community — not the generated reference docs or release notes) against the current SDK source, and updates pages where needed. Pages that were already accurate and clean are untouched. Every API symbol, code example, internal link, and example link on each page was verified against the packages' source and API reports. Changes fall into three groups: ### Accuracy fixes - Removed or replaced stale APIs: `defineMigrations`, the `CollaboratorCursor` component override (now `CollaboratorCursorOverlayUtil`), `@tldraw/tldraw` package references, deprecated `indicator`/`inputs.currentPagePoint`/`isDragging` accessors, and a nonexistent `editor.getDocumentState()`. - Fixed code examples that wouldn't work as written: missing imports and declarations, `editor.canUndo` without parens, a non-reactive preferences read, wrong argument order in a starter-kit example, invalid wrangler TOML, an `updateAssets` pattern that dropped required props. - Corrected behavior claims: license tracking for hobby licenses, `locale` prop precedence, animation speed direction, camera x/y semantics, image-export error handling, embed sandbox/fallback behavior, edge-scrolling insets, handle angle snapping, and others. - Fixed broken or moved example links (persistence had six), a duplicate starter-kit `order` conflict, and a sentence-case/anchor mismatch. ### New content Four SDK feature pages were TODO stubs and are now full guides written from source: **arrow shape**, **eraser**, **grid**, and **pen mode**. They keep `status: draft` — flip to `published` when you're happy with them. ### Clarity and style Sentence-cased headings and labels, direct openings, short paragraphs, trailing-gerund and hollow-filler cleanup, redundant sections removed, and consistent `[Symbol](?)` API-link usage per the repo writing guides. ### Verification - `yarn check-links` passes (no broken links). - `yarn refresh-content` passes against freshly built package API files: all MDX parses and every `[Symbol](?)` API link resolves. (This required rebuilding `packages/*/api/api.json` locally; one bad API link added during review was caught and removed this way.) ### Policy update tldraw has closed external contributions. The contributing page now states that the source is available to read but contributions are not accepted, the translations page no longer invites translation help (and drops the inaccurate "Lokalise for open source" section), and the community section description no longer calls tldraw an open source project. ### Change type - [x] `other` ### Release notes - Update documentation guides for accuracy, clarity, and style; add full guides for the arrow shape, eraser, grid, and pen mode pages.
1 parent 40cecd6 commit 6c9e855

90 files changed

Lines changed: 979 additions & 554 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/content/community/contributing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ order: 1
88

99
tldraw's source code is available on GitHub at [github.com/tldraw/tldraw](https://github.com/tldraw/tldraw). While you can read the code, we are not accepting external contributions.
1010

11-
The best way to help improve tldraw is to share your feedback. To report a bug or request a feature, [open an issue](https://github.com/tldraw/tldraw/issues) on GitHub or let us know on [Discord](https://discord.tldraw.com/?utm_source=docs&utm_medium=organic&utm_campaign=sociallink). If a code example would help the discussion, fork the repository and link to your branch in the issue.
11+
The best way to help improve tldraw is to share your feedback. To report a bug or request a feature, [open an issue](https://github.com/tldraw/tldraw/issues) on GitHub or let us know on [Discord](https://discord.tldraw.com/?utm_source=docs&utm_medium=organic&utm_campaign=sociallink). If a code example would help the discussion, please fork the repository and link to your branch in the issue.

apps/docs/content/community/license.mdx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ date: 9/13/2023
66
order: 2
77
---
88

9-
This article is about the [tldraw license](/legal/tldraw-license). The tldraw SDK's source code and published packages are provided under the tldraw license.
9+
The tldraw SDK's source code and published packages are provided under the [tldraw license](/legal/tldraw-license).
1010

1111
Under its default terms, the tldraw SDK license permits use **only in development**.
1212

13-
To use the tldraw SDK **in production**, you need either a:
13+
To use the tldraw SDK **in production**, you need one of the following:
1414

15-
- [trial license](#Trial-license) for evaluation;
16-
- [commercial license](#Commercial-license) for commercial projects; or a
17-
- [hobby license](#Hobby-license) for non-commercial projects.
15+
- a [trial license](#Trial-license) for evaluation
16+
- a [commercial license](#Commercial-license) for commercial projects
17+
- a [hobby license](#Hobby-license) for non-commercial projects
1818

19-
The SDK enforces its license using [license keys](#License-keys).
20-
21-
Trial, commercial, and hobby licenses each come with a license key. The SDK will work in production only when provided with a valid and active license key. See the [License Keys](#License-keys) section for more information about license keys.
19+
Trial, commercial, and hobby licenses each come with a license key. The SDK will work in production only when provided with a valid and active license key. See the [License keys](#License-keys) section for more information.
2220

2321
### Trial license
2422

@@ -54,10 +52,10 @@ When using the tldraw SDK under a commercial or hobby license, no information is
5452

5553
When using the tldraw SDK in production under a trial license, the tldraw SDK will ping tldraw's servers with a hash of the license key. This information is primarily for analytics purposes. No user data, canvas contents, or personally-identifiable information (PII) is sent or saved.
5654

57-
## Notes on Open Source
55+
## Notes on open source
5856

59-
While the tldraw SDK is [source available](https://github.com/tldraw/tldraw), it is not permissively licensed. Many of our examples and demos are available under an MIT licenses, and you should feel free to use this code as if it were your own; however any source code or packages licensed by the tldraw SDK would not be [Open Source](https://opensource.org/osd) by any definition.
57+
While the tldraw SDK is [source available](https://github.com/tldraw/tldraw), it is not permissively licensed. Many of our examples and demos are available under the MIT license, and you should feel free to use this code as if it were your own; however, any source code or packages covered by the tldraw SDK license would not be [Open Source](https://opensource.org/osd) by any definition.
6058

61-
If you wish to include tldraw in an open source project, you may do so but the SDK itself must remain under its original license. This means that you and your down-stream users will require their own trial, commercial, or hobby license in order to use the SDK in production. In this case, please also see our [trademark guidelines](https://tldraw.dev/legal/trademark-guidelines) that limit the use of the tldraw name and branding.
59+
If you wish to include tldraw in an open source project, you may do so but the SDK itself must remain under its original license. This means that you and your downstream users will require their own trial, commercial, or hobby license in order to use the SDK in production. In this case, please also see our [trademark guidelines](https://tldraw.dev/legal/trademark-guidelines) that limit the use of the tldraw name and branding.
6260

6361
The tldraw SDK is a product of a company. See [tldraw.dev](https://tldraw.dev/company) for more information about the company and the team.

apps/docs/content/community/translations.mdx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ date: 11/7/2023
66
order: 0
77
---
88

9-
The tldraw user interface (in [@tldraw/ui](/docs/user-interface)) is currently translated into over thirty different languages, with twenty languages at above 70% completion. Where a key's translation is missing in the user's current language language, the default (English) translation will be used instead.
9+
The tldraw [user interface](/docs/user-interface) is translated into more than forty languages. Where a key's translation is missing in the user's current language, the default (English) translation is used instead.
1010

11-
## Contributing translations
11+
We manage our translations through [Lokalise](https://lokalise.com).
1212

13-
We manage our translations through [Lokalise](https://www.lokalise.com), a long-time tldraw sponsor. If you would like to help by translating or reviewing translations, please let us know on [Discord](https://discord.tldraw.com/?utm_source=docs&utm_medium=organic&utm_campaign=sociallink) so that we can add you to the project.
14-
15-
## Lokalise for open source
16-
17-
tldraw is proud to partner with [Lokalise](https://lokalise.com) through their Innovation and Research Plan. This initiative provides our developers with industry-leading localization technology, empowering the next generation of language professionals to master modern, AI-driven workflows.
13+
To learn how the SDK detects and applies languages, see [Internationalization](/sdk-features/internationalization).

apps/docs/content/docs/ai.mdx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ editor.createShape({
7979
For richer AI output, create a custom shape that renders generated content. This approach works well for live HTML previews, interactive prototypes, or any content that needs special rendering:
8080

8181
```tsx
82-
// Abbreviated example—a full ShapeUtil also requires getDefaultProps, getGeometry, and indicator
82+
// Abbreviated example—a full ShapeUtil also requires getDefaultProps, getGeometry, and getIndicatorPath
8383
class PreviewShapeUtil extends ShapeUtil<PreviewShape> {
8484
static override type = 'preview' as const
8585

@@ -149,7 +149,8 @@ The [Agent starter kit](/starter-kits/agent) provides a complete implementation.
149149
The agent exposes a simple API for triggering canvas operations:
150150

151151
```tsx
152-
const agent = useTldrawAgent(editor)
152+
// Inside a component wrapped by TldrawAgentAppProvider
153+
const agent = useAgent()
153154

154155
// Simple prompt
155156
agent.prompt('Draw a flowchart showing user authentication')
@@ -178,8 +179,8 @@ This dual approach—visual screenshots plus structured data—gives the model b
178179
Agents perform operations through typed action schemas. Each action has a defined structure, and the agent system validates, sanitizes, and applies actions to the editor:
179180

180181
```tsx
181-
// Simplified illustration—the actual implementation converts through a SimpleShape
182-
// intermediate format. See CreateActionUtil in the agent starter kit for the full code.
182+
// Simplified illustration—the actual implementation converts through an intermediate
183+
// shape format. See CreateActionUtil in the agent starter kit for the full code.
183184
class CreateActionUtil extends AgentActionUtil<CreateAction> {
184185
override applyAction(action: Streaming<CreateAction>, helpers: AgentHelpers) {
185186
if (!action.complete) return
@@ -213,19 +214,17 @@ const { blob } = await editor.toImage(editor.getCurrentPageShapes(), { format: '
213214

214215
### Structured data
215216

216-
Access shape data directly from the store for text extraction or structured analysis:
217+
Access shape data directly from the store for text extraction or structured analysis. Use [ShapeUtil#getText](?) to extract a shape's text content as a plain string:
217218

218219
```tsx
219220
const shapes = editor.getCurrentPageShapes()
220221

221-
const textContent = shapes
222-
.filter((s) => s.type === 'text' || s.type === 'note' || s.type === 'geo')
223-
.map((s) => ({
224-
id: s.id,
225-
type: s.type,
226-
text: s.props.text,
227-
bounds: editor.getShapePageBounds(s),
228-
}))
222+
const textContent = shapes.map((shape) => ({
223+
id: shape.id,
224+
type: shape.type,
225+
text: editor.getShapeUtil(shape).getText(shape),
226+
bounds: editor.getShapePageBounds(shape),
227+
}))
229228
```
230229

231230
### Combining approaches

apps/docs/content/docs/collaboration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Collaboration involves three concerns:
5353

5454
- **Synchronizing data** — Getting document changes in and out of the [store](/sdk-features/store). See [Persistence](/docs/persistence) for the basics, or [Collaboration](/sdk-features/collaboration) for building custom sync.
5555
- **User presence** — Sharing cursor positions, selections, and viewports with other users. See [Collaboration](/sdk-features/collaboration) for presence APIs and [Cursors](/sdk-features/cursors) for customizing how collaborator cursors appear.
56-
- **Collaboration UI** — The visual elements that show other users on the canvas. See [UI components](/sdk-features/ui-components) for overriding components like `CollaboratorCursor` and `SharePanel`. Collaborator brushes, scribbles, and hints are rendered via the [OverlayUtil](?) system.
56+
- **Collaboration UI** — The visual elements that show other users on the canvas. See [UI components](/sdk-features/ui-components) for overriding components like `SharePanel`. The [OverlayUtil](?) system renders collaborator cursors, brushes, scribbles, and selection indicators—see [Overlay utils](/sdk-features/overlay-utils).
5757

5858
## Related
5959

apps/docs/content/docs/driver.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Every input method returns `this`, so calls can be chained. Call `dispose` when
4343

4444
## Simulating input
4545

46-
Pointer, keyboard, wheel, and pinch events all flow through `editor.dispatch`, so they go through the editor's normal tool state machines—a `pointerDown``pointerMove`...`pointerUp` sequence against the draw tool produces real draw shapes, not an image overlay:
46+
Pointer, keyboard, wheel, and pinch events all flow through `editor.dispatch`, so they go through the editor's normal tool state machines. A `pointerDown``pointerMove``pointerUp` sequence with the draw tool active creates real draw shapes:
4747

4848
```ts
4949
editor.setCurrentTool('draw')
@@ -84,7 +84,7 @@ driver.paste({ x: 400, y: 400 })
8484

8585
## Queries
8686

87-
The driver tracks shapes it has caused to be created via `editor.sideEffects`, making it easy to grab the most recent result of a scripted action:
87+
The driver uses `editor.sideEffects` to track the shapes it creates, so you can grab the most recent result of a scripted action:
8888

8989
```ts
9090
const shape = driver.getLastCreatedShape()

apps/docs/content/docs/handles.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ Handle coordinates are in the shape's local coordinate system, where `(0, 0)` is
4343

4444
There are four handle types:
4545

46-
| Type | Description |
47-
| --------- | --------------------------------------------------------------------------- |
48-
| `vertex` | A primary control point that defines part of the shape's geometry |
49-
| `virtual` | A secondary handle between vertices, often used for adding new points |
50-
| `create` | A handle for extending geometry, like adding a point to the end of a line |
51-
| `clone` | A handle for duplicating the shape, used by notes for quick adjacent copies |
46+
| Type | Description |
47+
| --------- | ----------------------------------------------------------------------------- |
48+
| `vertex` | A primary control point that defines part of the shape's geometry |
49+
| `virtual` | A secondary handle that isn't a vertex, like the arrow's midpoint bend handle |
50+
| `create` | A handle for adding new geometry, like inserting a point into a line segment |
51+
| `clone` | A handle for duplicating the shape, used by notes for quick adjacent copies |
5252

53-
Most custom shapes use `vertex` handles. The `virtual` and `create` types are used by the line shape to let users add points to a path.
53+
Most custom shapes use `vertex` handles. The arrow shape uses a `virtual` handle for its midpoint, and the line shape uses `create` handles to let users add points between vertices.
5454

5555
## Responding to handle drags
5656

57-
When a user drags a handle, tldraw calls `onHandleDrag` with the updated handle position. Return the new shape props:
57+
When a user drags a handle, tldraw calls `onHandleDrag` with the updated handle position. Return the updated shape:
5858

5959
```tsx
6060
import { ShapeUtil, TLHandleDragInfo } from 'tldraw'
@@ -111,7 +111,7 @@ The `snapType` options are:
111111

112112
### Angle snapping
113113

114-
When the user holds Shift while dragging, handles snap to 15-degree angles. By default, this is relative to the shape's position. You can snap relative to another handle by setting `snapReferenceHandleId`:
114+
When the user holds Shift while dragging, handles snap to 15-degree angles. By default, the angle is measured relative to an adjacent vertex handle on the shape. You can use a different reference handle by setting `snapReferenceHandleId`:
115115

116116
```tsx
117117
{

apps/docs/content/docs/indicators.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ keywords:
1212
- custom shapes
1313
---
1414

15-
Indicators are the outlines that appear around shapes when they're selected or hovered. They provide visual feedback about which shapes are active. They also help users understand the bounds of each shape.
15+
Indicators are the outlines that appear around shapes when they're selected or hovered. They show which shapes are active and where each shape's bounds are.
1616

1717
## How indicators work
1818

@@ -112,8 +112,8 @@ In multiplayer sessions, indicators show other users' selections. These appear w
112112

113113
## Related topics
114114

115-
| Topic | Description |
116-
| ------------------------------------------------------- | ------------------------------------------ |
117-
| [Shapes](/docs/shapes) | Creating custom shapes with ShapeUtil |
118-
| [User interface](/docs/user-interface) | Customizing tldraw's UI components |
119-
| [Custom indicators example](/examples/indicators-logic) | Working example of indicator customization |
115+
| Topic | Description |
116+
| ---------------------------------------------------------- | ------------------------------------------ |
117+
| [Shapes](/docs/shapes) | Creating custom shapes with ShapeUtil |
118+
| [User interface](/docs/user-interface) | Customizing tldraw's UI components |
119+
| [Custom indicators example](/examples/ui/indicators-logic) | Working example of indicator customization |

apps/docs/content/docs/mermaid.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ For unsupported types (pie, gantt, class, ER, etc.) pass an `onUnsupportedDiagra
5858

5959
```tsx
6060
await createMermaidDiagram(editor, text, {
61-
onUnsupportedDiagram(svgString) {
62-
editor.putExternalContent({ type: 'svg-text', text: svgString })
61+
async onUnsupportedDiagram(svgString) {
62+
await editor.putExternalContent({ type: 'svg-text', text: svgString })
6363
},
6464
})
6565
```
@@ -135,7 +135,7 @@ The callback receives `diagramKind`, `nodeId`, `kind`, and the full [`MermaidBlu
135135
## Examples
136136

137137
- [Hundreds of mermaid diagrams](/examples/use-cases/hundred-mermaids) — A runnable demo rendering many diagram types at once
138-
- [Customizing mermaid diagrams](/examples/use-cases/custom-shape-mermaids) - Converting mermaid diagram nodes into custom shapes
138+
- [Customizing mermaid diagrams](/examples/use-cases/custom-shape-mermaids) Converting mermaid diagram nodes into custom shapes
139139

140140
## Related
141141

apps/docs/content/docs/shapes.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ You can create your own shapes by defining a shape type and a ShapeUtil class.
3434
Register your shape's props using TypeScript module augmentation:
3535

3636
```ts
37+
import { TLShape } from 'tldraw'
38+
3739
const CARD_TYPE = 'card'
3840

3941
declare module 'tldraw' {
@@ -47,7 +49,7 @@ type CardShape = TLShape<typeof CARD_TYPE>
4749
4850
### Creating a ShapeUtil
4951
50-
Implement the required methods: `getDefaultProps`, `getGeometry`, `component`, and `indicator`:
52+
Implement the required methods: `getDefaultProps`, `getGeometry`, `component`, and `getIndicatorPath`:
5153
5254
```tsx
5355
import { HTMLContainer, Rectangle2d, ShapeUtil } from 'tldraw'

0 commit comments

Comments
 (0)