platejs 54.0.0-beta.3 → 54.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AIChatRequestContext-DY104TqL.d.ts → AIChatRequestContext-CwCmEMVV.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-Deo6n6Fs.d.ts → BaseSuggestionPlugin-CpVkv7k2.d.ts} +4 -4
- package/dist/{PlateStatic-CJX5bKuv.d.ts → PlateStatic-C7FfXu-Z.d.ts} +3 -3
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/index.d.ts +9 -9
- package/dist/authored/index.d.ts +3 -3
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DAOYWuvC.d.ts → combobox-BhhymlUs.d.ts} +2 -2
- package/dist/{comparison-types-Dt-unJZY-DCddmbSD.d.ts → comparison-types-Bvvxzxq2-08gzpgF6.d.ts} +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-ClHasORr.d.ts → core-Bu--Bog3.d.ts} +65 -26
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/api/core/plate-controller.md +1 -1
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +9 -10
- package/dist/docs/api/react-hooks.md +40 -22
- package/dist/docs/authored-changes.md +4 -2
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/board.md +57 -4
- package/dist/docs/comment.md +2 -2
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/editor.md +50 -4
- package/dist/docs/field.md +138 -20
- package/dist/docs/link.md +1 -1
- package/dist/docs/llms.txt +1 -1
- package/dist/docs/markdown.md +97 -9
- package/dist/docs/media.md +88 -2
- package/dist/docs/plugin-input-rules.md +65 -5
- package/dist/docs/roots.md +16 -10
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/exportDocx.js +18 -13
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewProjection.js +43 -3
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -1
- package/dist/excalidraw/index.d.ts +3 -3
- package/dist/excalidraw/react/index.d.ts +3 -3
- package/dist/facade.js +2 -2
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/callout/index.d.ts +3 -3
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -18
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +38 -18
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -3
- package/dist/features/details/index.d.ts +3 -3
- package/dist/features/details/lib/BaseDetailsPlugin.js +15 -2
- package/dist/features/field/index.d.ts +2 -2
- package/dist/features/field/index.js +4 -2
- package/dist/features/field/lib/BaseFieldPlugin.js +52 -106
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +174 -7
- package/dist/features/find/index.d.ts +3 -3
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/inkGone.internal.js +6 -6
- package/dist/features/ink/lib/inkPlaces.internal.js +8 -9
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/lint/index.d.ts +3 -3
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +200 -2
- package/dist/features/mention/index.d.ts +5 -5
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +50 -7
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +1 -1
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-cg_cWsaN.d.ts → htmlTypes-aE9Qlenu.d.ts} +1 -1
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-C35V_hj0.d.ts → index-BR2S-6Js.d.ts} +3 -3
- package/dist/{index-CLsEe3LY.d.ts → index-BT1-fX5o.d.ts} +3 -3
- package/dist/{index-BZWFoUXt.d.ts → index-BXs4598V.d.ts} +5 -5
- package/dist/{index-C6ql9pKw.d.ts → index-BYAqyTSY.d.ts} +2 -2
- package/dist/{index-CdOLsPaW.d.ts → index-Be_YFFLS.d.ts} +3 -5
- package/dist/{index-CzLwBZpY.d.ts → index-Bf6EwY5O.d.ts} +2 -2
- package/dist/{index-HPYawTae-BCUQLEWF.d.ts → index-BwmXxqbi-COlJb0HZ.d.ts} +1 -1
- package/dist/{index-Cmuluh6f.d.ts → index-C9WSACSv.d.ts} +1 -1
- package/dist/{index-D3-2iM1b.d.ts → index-CGUt4h_4.d.ts} +291 -4
- package/dist/{index-DPWyk3lG-DOYwohXO.d.ts → index-CRmyGzS8-BTrk6JzL.d.ts} +7 -1
- package/dist/{index-baQOK89E.d.ts → index-CTwrWir_.d.ts} +1 -1
- package/dist/{index-CktYvOgk.d.ts → index-CYR4jNU7.d.ts} +4 -4
- package/dist/{index-DQnjqtQa.d.ts → index-CbcYN_S_.d.ts} +122 -21
- package/dist/{index-Do9pj1GK.d.ts → index-CeVE8JR-.d.ts} +47 -6
- package/dist/{index-C1_JIhL4.d.ts → index-DFvzP8N_.d.ts} +4 -4
- package/dist/{index-oIJAZxc2.d.ts → index-DgVsTFYL.d.ts} +3 -3
- package/dist/{index-8WO2vI0U.d.ts → index-DhVOU0pS.d.ts} +34 -29
- package/dist/{index-DKOFvteF.d.ts → index-DhurStYU.d.ts} +1 -1
- package/dist/{index-B5mYEawV.d.ts → index-DlBey0zf.d.ts} +10 -8
- package/dist/{index-C9DiGDVj.d.ts → index-DqKFQcfb.d.ts} +2 -2
- package/dist/{index-C0POz7rg.d.ts → index-DqpzKYwP.d.ts} +3 -3
- package/dist/{index-DpltOCot-A2b3p3Eb.d.ts → index-QuqD4Dyj-DlOIX0sH.d.ts} +75 -27
- package/dist/{index-r7yb77Wy.d.ts → index-dpi2ErEe.d.ts} +5 -3
- package/dist/index.d.ts +4 -4
- package/dist/internal/utils/vscodeClipboard.js +11 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +6 -16
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +73 -14
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +2 -1
- package/dist/markdown/lib/MarkdownPlugin.js +10 -13
- package/dist/markdown/lib/RawHtmlPlugin.js +4 -2
- package/dist/markdown/lib/internal/markdownConversion.js +7 -4
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +40 -1
- package/dist/markdown/lib/internal/markdownTags.js +7 -1
- package/dist/math/index.d.ts +3 -3
- package/dist/math/react/index.d.ts +4 -4
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +2 -2
- package/dist/react/components/EditorContentView.internal.js +26 -16
- package/dist/react/components/Plate.js +13 -20
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardView.internal.js +11 -6
- package/dist/react/features/board/index.d.ts +50 -6
- package/dist/react/features/callout/index.d.ts +3 -3
- package/dist/react/features/combobox/index.d.ts +5 -5
- package/dist/react/features/comments/index.d.ts +6 -6
- package/dist/react/features/date/index.d.ts +4 -4
- package/dist/react/features/details/index.d.ts +4 -4
- package/dist/react/features/field/FieldPlugin.js +5 -4
- package/dist/react/features/field/index.d.ts +19 -16
- package/dist/react/features/footnote/index.d.ts +7 -7
- package/dist/react/features/format-painter/index.d.ts +4 -4
- package/dist/react/features/ink/InkContent.js +13 -0
- package/dist/react/features/ink/index.d.ts +5 -9
- package/dist/react/features/ink/inkPaint.internal.js +4 -1
- package/dist/react/features/ink/inkPlacement.internal.js +2 -1
- package/dist/react/features/layout/index.d.ts +5 -5
- package/dist/react/features/media/index.d.ts +5 -5
- package/dist/react/features/mention/index.d.ts +6 -6
- package/dist/react/features/suggestion/index.d.ts +6 -6
- package/dist/react/features/table/index.d.ts +7 -6
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +5 -5
- package/dist/react/index.d.ts +6 -6
- package/dist/react/internal/plate-context.js +20 -11
- package/dist/react/stores/plate/useEditorSelector.js +22 -9
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/virtualized.d.ts +2 -2
- package/dist/{source-aUwpNnAw.d.ts → source-GMnTi_Vr.d.ts} +3 -3
- package/dist/static/index.d.ts +5 -5
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +2 -2
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +5 -5
- package/package.json +2 -2
|
@@ -351,33 +351,50 @@ The editor follows the `EditorContent` that shows its root inside the
|
|
|
351
351
|
the user last focused or pressed. Until the user has focused or pressed one,
|
|
352
352
|
it follows the first one mounted. Once the one it follows unmounts, it follows
|
|
353
353
|
the one the user focused or pressed before that, or the first one mounted when
|
|
354
|
-
the user has focused or pressed no other. While
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
354
|
+
the user has focused or pressed no other. While every `EditorContent` of the
|
|
355
|
+
root there is hidden, as under an `Activity` or a plugin whose `wrapRoot`
|
|
356
|
+
returns `null`, it follows a hidden one. While none of the root is mounted
|
|
357
|
+
there, it follows the `EditorRoot`, or the `EditorContent` around the hook when
|
|
358
|
+
the hook renders inside one. An `EditorRoot`'s `readOnly` holds for every
|
|
359
|
+
write of the render that sets it. That includes writes through each
|
|
360
|
+
`EditorContent` inside it that sets no `readOnly` and that the render keeps,
|
|
361
|
+
mounts, removes, hides or suspends. An `EditorContent` inside another
|
|
362
|
+
`EditorContent`, or inside an `EditorReadOnlyProvider` that sets `readOnly`,
|
|
363
|
+
takes the lock through its own `readOnly` instead. The lock covers a control's unmount code and a custom
|
|
364
|
+
element's connect. It does not cover the first `attributeChangedCallback` of a
|
|
365
|
+
custom element that React creates in that render with an observed attribute,
|
|
366
|
+
because React runs that callback while it renders. When `readOnly` turns off,
|
|
367
|
+
writes stay refused until React has removed and inserted the nodes of that
|
|
368
|
+
render. A preview takes hold in the `EditorRoot`'s layout effect, and an
|
|
369
|
+
`EditorContent`'s own `readOnly` takes hold in its layout effect in the render
|
|
370
|
+
that mounts it. In such a render, a write from code that runs before that
|
|
371
|
+
layout effect can still land, such as a control's mount or unmount code or an
|
|
372
|
+
earlier layout effect. An `EditorContent` that the render keeps applies its
|
|
373
|
+
own `readOnly` where it sits in the tree. So a class component's
|
|
374
|
+
`getSnapshotBeforeUpdate` placed before it can still write, and a render that
|
|
375
|
+
hides or suspends it applies the lock only once it shows again.
|
|
376
|
+
`setEditorViewing(editor, true)` on the hook's editor and `AuthoredPlugin`'s
|
|
377
|
+
`api.setView` take hold at the call, so call one before that render to refuse
|
|
378
|
+
those writes too. A preview set while the user composes text takes hold when
|
|
379
|
+
the composition ends.
|
|
380
|
+
|
|
381
|
+
The editor never acts in another `EditorRoot`, even while an `EditorContent`
|
|
382
|
+
there holds the caret in the hook's root, and that `EditorRoot`'s lock and
|
|
383
|
+
authored mode never apply to it. So a press in a writable `EditorRoot` writes
|
|
384
|
+
plain text into a root that another `EditorRoot` shows read-only or in
|
|
385
|
+
suggesting mode. A write through it that places the
|
|
386
|
+
caret moves the caret into its own `EditorRoot`. Under an `EditorRoot` that
|
|
387
|
+
shows a preview, its content edits throw and its selection changes go through.
|
|
371
388
|
|
|
372
389
|
While what it follows is read-only, every update through the editor throws,
|
|
373
390
|
and `{ readOnly: false }` does not make the editor writable. An `EditorContent`
|
|
374
391
|
that overrides the `readOnly` of its `EditorRoot` decides for the editor too.
|
|
375
|
-
|
|
392
|
+
The editor also takes the
|
|
376
393
|
[authored view](/docs/api/core/plate-components#authored-view) of what it
|
|
377
394
|
follows, so it records its edits as proposals in suggesting mode.
|
|
378
395
|
|
|
379
|
-
A nested `EditorRoot` is a view of its own
|
|
380
|
-
|
|
396
|
+
A nested `EditorRoot` is a view of its own, and an editor from a hook outside
|
|
397
|
+
it never acts in it.
|
|
381
398
|
|
|
382
399
|
Its `editor.api.dom` calls run in the view it follows, so it can focus the
|
|
383
400
|
view it edits, even after focus moves to the button:
|
|
@@ -388,8 +405,9 @@ const note = useRootEditor("note");
|
|
|
388
405
|
return <button onClick={() => note.api.dom.focus()}>Edit note</button>;
|
|
389
406
|
```
|
|
390
407
|
|
|
391
|
-
While
|
|
392
|
-
|
|
408
|
+
While no `EditorContent` in its `EditorRoot` shows the root, `editable()`
|
|
409
|
+
returns `null` and `focus()` does nothing, even when an `EditorContent` in
|
|
410
|
+
another `EditorRoot` holds the caret. A call given a
|
|
393
411
|
DOM node, an event or pointer coordinates runs in the view of the root that
|
|
394
412
|
holds them, when that view belongs to the same `EditorRoot`, as
|
|
395
413
|
[Views](/docs/api/dom#views) describes.
|
|
@@ -125,9 +125,11 @@ export function SuggestionEditor() {
|
|
|
125
125
|
|
|
126
126
|
The editor must install an authored plugin, either directly or through `SuggestionPlugin`. Changing the `authored` prop updates this view. Rerendering with an equivalent value preserves later mode changes made through the mounted view's portal.
|
|
127
127
|
|
|
128
|
-
For an interactive mode control, set the intent on the mounted view:
|
|
128
|
+
For an interactive mode control, set the intent on the mounted view, which `useEditor()` returns inside `EditorRoot`. The mounted view keeps its own mode, so `setView` on the editor passed to `EditorRoot` does not change what it shows:
|
|
129
129
|
|
|
130
130
|
```tsx
|
|
131
|
+
const editor = useEditor();
|
|
132
|
+
|
|
131
133
|
editor.plugin(AuthoredPlugin).api.setView({ intent: "propose" });
|
|
132
134
|
```
|
|
133
135
|
|
|
@@ -202,7 +204,7 @@ Each `AuthoredChange` has its `id`, `authorId`, `createdAt`, `kind`, current `ra
|
|
|
202
204
|
|
|
203
205
|
Except for a split or join inside a top-level block, no revision covers where a change sits, so an edit before it keeps the revision. Its `ranges` can move while its revision stays the same, so read them again after each document change. A join, split, wrap or unwrap's revision ignores the text and leaves inside the element, so typing inside keeps it. It changes when the element's own fields change, or the order or shapes of the elements inside it. The revision of a split or join inside a top-level block, such as a quote, also covers its index inside that block, because a decision merges its line into the block before it. The index counts blocks, so it does not say which block comes before the line. After the blocks before it change order, or one of them is replaced or changes type, a decision read before still applies and merges the line into the block now before it. A block that lands between the halves of a top-level split or join also keeps the revision, and a decision read before merges the line into that block.
|
|
204
206
|
|
|
205
|
-
A decision names the changes as they were read, and a change whose revision moved since returns `stale`. Accepting a change can need other changes accepted with it, and rejecting one can need its dependants rejected. The result is then `blocked`, `with` names the changes it needs, and nothing applies. The editor never decides a change you did not name. Several decisions in one call decide together:
|
|
207
|
+
A decision names the changes as they were read, and a change whose revision moved since returns `stale`. Accepting a change can need other changes accepted with it, and rejecting one can need its dependants rejected. The result is then `blocked`, `with` names the changes it needs, and nothing applies. The editor never decides a change you did not name. Accepting a line someone typed right after another author's pending join applies without waiting for that join. The line stays where it is stored, and accepting the join later places it after the joined line, as deciding both at once does. Between different authors, the order of decisions can still change where such a line ends. It can also change where a line someone moved in Editing ends when the split that made it is rejected. Several decisions in one call decide together:
|
|
206
208
|
|
|
207
209
|
```tsx
|
|
208
210
|
if (result.status === "blocked") {
|
|
@@ -123,14 +123,16 @@ The plugin shows a placeholder only when every gate passes.
|
|
|
123
123
|
| Focus | Editor is focused and has a selection. |
|
|
124
124
|
| Selection | Selection is collapsed. |
|
|
125
125
|
| Active block | `editor.read.nodes.block()` returns an empty block. |
|
|
126
|
-
| Whole editor | The editor is not in its pristine single-empty-block state. Empty blocks with visible structural state, such as list metadata, still qualify. |
|
|
126
|
+
| Whole editor | The editor is not in its pristine single-empty-block state. Empty blocks with visible structural state, such as list metadata, still qualify, unless the editor's own `placeholder` already shows. |
|
|
127
127
|
| Placeholder map | The block type matches one entry in `placeholders`. |
|
|
128
128
|
| Query | `query({ editor, node, path, ...ctx })` returns `true`. |
|
|
129
129
|
|
|
130
130
|
The default `query` returns `true` for root blocks only. The whole-editor guard
|
|
131
131
|
uses `editor.plugin(ElementStatePlugin).api.isEmpty`, so only `type` and
|
|
132
132
|
compiled element properties declared with `role: "metadata"` are treated as
|
|
133
|
-
pristine metadata.
|
|
133
|
+
pristine metadata. When the editor content has a `placeholder`, that placeholder
|
|
134
|
+
covers any single empty block, a list item included, so the block placeholder
|
|
135
|
+
stays hidden and only one placeholder shows.
|
|
134
136
|
|
|
135
137
|
```tsx
|
|
136
138
|
query: ({ path }) => path.length === 1
|
package/dist/docs/board.md
CHANGED
|
@@ -15,6 +15,7 @@ _Example `board-demo` in the Plate repository: `apps/www/src/registry/examples/b
|
|
|
15
15
|
- Copy, paste and duplicate with fresh shape ids. A copied arrow binds the copied shapes. The copies land on top, with frames still behind the other shapes. They land at the pointer when it is over the board, and step 24px down and right off any shape already at their place.
|
|
16
16
|
- Paste text or a link, and it lands as a selected note at the pointer.
|
|
17
17
|
- Paste an image link or a picture copied from a web page, and it lands as an image shape at the pointer, at the picture's proportions. With [`UploadPlugin`](/docs/upload) installed, picture files that you paste, drop or pick from the toolbar land as image shapes too, and each uploads in its own shape.
|
|
18
|
+
- Export or copy the board, or its selected shapes, as a PNG or an SVG that holds the shapes off screen too.
|
|
18
19
|
- A camera, a tool, a tool lock and a next style for each mounted view, which the document never stores.
|
|
19
20
|
- Tab and Mod with an arrow move between shapes, Shift+Enter reaches the toolbar, and keys zoom, pan and fit. Enter places a note, shape or frame, and connects two shapes with an arrow. A screen reader hears the selected shape, the picked tool, the zoom, each removal and each step of a connect, in words your app passes.
|
|
20
21
|
- Only the shapes near the camera mount, so the work each keystroke does stays the same as the board grows.
|
|
@@ -35,7 +36,7 @@ _Registry item `board`: `npx shadcn@latest add @plate/board`._
|
|
|
35
36
|
- `BoardPageElement`: renders a board that fills its container. `BoardPageKit` installs it in place of `BoardElement`.
|
|
36
37
|
- `BoardNoteElement`, `BoardGeoElement`, `BoardArrowElement`, `BoardFrameElement` and `BoardStrokeElement`: render each shape type.
|
|
37
38
|
- `BoardImageElement`: renders an image shape. `BoardImageKit` installs it apart from `BoardKit`, as [Images](#images) shows.
|
|
38
|
-
- `BoardToolbar`: picks the select, hand, note, shape, arrow, frame, pen or eraser tool, and its shape menu picks a rectangle, ellipse, diamond or triangle for the next shape. The lock button after them turns the tool lock on or off, as Q does, and shows pressed while the lock is on. The Image button after the lock opens a file picker and lands the picked pictures, as [Picture files](#picture-files) describes, and is disabled on a board that takes no picture files. Zoom out and zoom in move one zoom step, the zoom level between them shows the zoom as a percentage and goes back to 100% when clicked, and the fit button brings every shape into view. With a frame selected, an icon button removes the frame and keeps the frame's shapes.
|
|
39
|
+
- `BoardToolbar`: picks the select, hand, note, shape, arrow, frame, pen or eraser tool, and its shape menu picks a rectangle, ellipse, diamond or triangle for the next shape. The lock button after them turns the tool lock on or off, as Q does, and shows pressed while the lock is on. The Image button after the lock opens a file picker and lands the picked pictures, as [Picture files](#picture-files) describes, and is disabled on a board that takes no picture files. The Export menu after the Image button saves or copies the board as a PNG or an SVG, as [Export](#export) describes. Zoom out and zoom in move one zoom step, the zoom level between them shows the zoom as a percentage and goes back to 100% when clicked, and the fit button brings every shape into view. With a frame selected, an icon button removes the frame and keeps the frame's shapes.
|
|
39
40
|
- `BoardStylePanel`: docks at the board's top right and styles the selected shapes, or the next shape while a drawing tool is picked, as [Style panel](#style-panel) shows.
|
|
40
41
|
|
|
41
42
|
### Add kit
|
|
@@ -240,6 +241,55 @@ const editor = createEditor({
|
|
|
240
241
|
|
|
241
242
|
The board takes picture files only in a view that can write, in an editor that installs both `UploadPlugin` and `ImagePlugin`. On any other board, the Image button is disabled and a pasted or dropped file lands no shape. The copied button reads that check as `takesPictureFiles` from `useBoardView`, and lands its files with `upload(files)` from `useBoardActions`.
|
|
242
243
|
|
|
244
|
+
## Export
|
|
245
|
+
|
|
246
|
+
The copied toolbar's Export menu saves the board as `board.png` or `board.svg`. Its Copy as PNG and Copy as SVG items put the same picture on the clipboard. The SVG goes on the clipboard as text, because Firefox and Safari cannot copy an SVG image.
|
|
247
|
+
|
|
248
|
+
- The picture holds the selected shapes and every shape of a selected frame, or the whole board when nothing is selected. Shapes off screen are included.
|
|
249
|
+
- It draws the board's background in the current light or dark theme, without the dot grid.
|
|
250
|
+
- The file holds the fonts its text uses and the board's images, so it looks the same on another computer.
|
|
251
|
+
- The PNG is twice the board's size. A board too large for the browser's canvas draws smaller, and the menu says so.
|
|
252
|
+
- An image that cannot be read draws as a gray box in the PNG and stays a web link in the SVG. A shape type with no static component draws as a gray box. Note content whose plugin `BoardPictureKit` lacks shows as plain text, and a font that cannot be read leaves its text in another font. The menu shows a warning for each.
|
|
253
|
+
- A note's text is HTML inside the SVG. Browsers draw it, but a design tool that opens the SVG shows the shapes without the note text.
|
|
254
|
+
- On an empty board, the menu says there is nothing to export or copy.
|
|
255
|
+
- When the browser refuses a copy, the menu says the board could not be copied. Export as PNG and Export as SVG still save it.
|
|
256
|
+
|
|
257
|
+
When you export, the menu loads `BoardPictureKit` from the copied `board-static.tsx` and passes it to `exportPicture` from `useBoardActions`. A control of your own inside the surface's `toolbar` can do the same:
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
const { exportPicture } = useBoardActions();
|
|
261
|
+
|
|
262
|
+
const picture = await exportPicture({
|
|
263
|
+
format: 'svg',
|
|
264
|
+
kit: import('@/components/editor/board-static').then(
|
|
265
|
+
({ BoardPictureKit }) => BoardPictureKit
|
|
266
|
+
),
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
`picture` is `null` when there is nothing to draw. Otherwise it holds the file's `blob`, its `width` and `height` in pixels, and its `warnings`.
|
|
271
|
+
|
|
272
|
+
To copy the picture, start the clipboard write before you await it. Safari and Firefox refuse a clipboard write that starts too long after the click, and drawing the picture can take longer:
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
const empty = new Error('There is nothing to copy.');
|
|
276
|
+
const picture = exportPicture({
|
|
277
|
+
format: 'png',
|
|
278
|
+
kit: import('@/components/editor/board-static').then(
|
|
279
|
+
({ BoardPictureKit }) => BoardPictureKit
|
|
280
|
+
),
|
|
281
|
+
}).then((drawn) => drawn ?? Promise.reject(empty));
|
|
282
|
+
|
|
283
|
+
await Promise.all([
|
|
284
|
+
picture,
|
|
285
|
+
navigator.clipboard.write([
|
|
286
|
+
new ClipboardItem({ 'image/png': picture.then(({ blob }) => blob) }),
|
|
287
|
+
]),
|
|
288
|
+
]);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
On an empty board, the `await` rejects with `empty` and the clipboard keeps what it held. Any other rejection means the browser refused the copy or the picture could not be drawn.
|
|
292
|
+
|
|
243
293
|
## Manual usage
|
|
244
294
|
|
|
245
295
|
<Steps>
|
|
@@ -632,6 +682,7 @@ Every other peer joins the new room with the new plugins and schema, and without
|
|
|
632
682
|
- A board inside a note, rotation and cropping a picture are not supported, and the copied board draws no caption under a picture.
|
|
633
683
|
- Drawing with the pen needs a pointer. A keyboard resize keeps the proportions of an image shape only, and cannot resize around the center, which Shift and Alt do on a corner drag.
|
|
634
684
|
- No key or pointer gesture moves a bound arrow end off its shape, or resizes several shapes at once. Moving a selected arrow moves its free ends, and each bound end stays on its shape.
|
|
685
|
+
- An export of a selected frame holds the frame's shapes but not an arrow between them, because an arrow never belongs to a frame. Select the arrow too to include it.
|
|
635
686
|
- On a board page, the board is still a block of the document. Delete or Backspace with the board selected removes it with its shapes, and Undo brings it back. With [exit break](/docs/exit-break) installed, Mod+Enter with the caret on the board, where Mod+A can put it, adds a paragraph after the board, out of sight.
|
|
636
687
|
|
|
637
688
|
## Plugins
|
|
@@ -662,9 +713,11 @@ The image shape, `boardImage`: an object block that holds at most one `image` el
|
|
|
662
713
|
| `remove(ids)` | `BaseBoardPlugin` | Removes shapes, each frame with its shapes. An arrow bound to a removed shape keeps a loose end where it drew it. |
|
|
663
714
|
| `removeFrame(id)` | `BaseBoardPlugin` | Removes a frame and keeps its shapes where they are. |
|
|
664
715
|
| `insertCopy(slice, { board, place? })` | `BaseBoardPlugin` | Pastes a copy of the shapes in `slice` into `board`, with fresh ids, and returns the copies' ids. |
|
|
665
|
-
| `shapes(board)`, `shape(id)`, `arrowEnds(id)`, `slice(ids)` | `BaseBoardPlugin` | Read the shapes of a board, one shape by id in any board, where an arrow draws its ends, and the slice a copy of shapes carries. Call them on `tx.plugin(BaseBoardPlugin)
|
|
716
|
+
| `shapes(board)`, `shape(id)`, `arrowEnds(id)`, `strokePath(id)`, `slice(ids)` | `BaseBoardPlugin` | Read the shapes of a board, one shape by id in any board, where an arrow draws its ends, a pen line's outline, and the slice a copy of shapes carries. `strokePath` returns `null` when the id names no pen line. Call them on `tx.plugin(BaseBoardPlugin)` inside an update, or on `editor.read.board` outside one, such as on a server with no mounted board. |
|
|
717
|
+
| `BoardStrokePath` | `platejs/board` | A pen line's outline: an SVG `path` over a box of `width` by `height`, the line's stored size, which you scale to the box `shape(id)` gives. |
|
|
666
718
|
| `BoardSurface`, `BoardShape` | `platejs/board/react` | The board's mounted view and a shape's positioned wrapper, for copied renderers. The surface's required `messages` holds every word the board says, as [Screen readers](#screen-readers) lists. Its `height` sets its view's height and defaults to the board's stored `height`. A shape the eraser will remove shows `data-erasing`, which the copied board fades, and the shape under the picking cursor shows `data-board-cursor`, which the copied board rings. A plain wheel over a toolbar element that can still scroll in the wheel's main direction scrolls that element instead of panning the board. |
|
|
667
719
|
| `data-board-dock` | `platejs/board/react` | Marks an element at the top level of the surface's `toolbar` that sits at the board's `"left"` or `"right"` side. Every other top-level toolbar element counts as a row at the board's top or bottom. `fit` and Shift+1 fit the shapes into the room the toolbar leaves clear. Where that room's width or height cannot hold them at 10 percent, they use the board's whole width or height. Both zoom between 10 and 100 percent, so shapes the board cannot hold at 10 percent run past its edges. |
|
|
668
720
|
| `BoardMessages`, `BoardShapeDescription`, `BoardCorner`, `BoardPickState` | `platejs/board/react` | The type of `messages`, the shape that `messages.shape` describes, the corner a resize moves, and where picking stands when the board says `picking` or `pick`. |
|
|
669
|
-
| `useBoardView(selector)`, `useBoardActions()` | `platejs/board/react` | Inside the surface's `toolbar`, read the view's `tool`, `toolLocked`, `camera` and `nextStyle`, its board's selected shapes as `selectedShapes`, each style a pick would set as `styles`, whether it can write as `writable`, and whether its board takes picture files as `takesPictureFiles`. A camera `zoom` of 1 is 100 percent. Call `setTool`, `setToolLocked`, `setStyle`, `fit`, `zoomIn`, `zoomOut`, `resetZoom`, `removeFrame`, `focus` and `
|
|
670
|
-
| `
|
|
721
|
+
| `useBoardView(selector)`, `useBoardActions()` | `platejs/board/react` | Inside the surface's `toolbar`, read the view's `tool`, `toolLocked`, `camera` and `nextStyle`, its board's selected shapes as `selectedShapes`, each style a pick would set as `styles`, whether it can write as `writable`, and whether its board takes picture files as `takesPictureFiles`. A camera `zoom` of 1 is 100 percent. Call `setTool`, `setToolLocked`, `setStyle`, `fit`, `zoomIn`, `zoomOut`, `resetZoom`, `removeFrame`, `focus`, `upload` and `exportPicture`. From any zoom, `zoomIn` and `zoomOut` go to the next step the `=` or `+` and `-` keys use, and stop at 800 and 10 percent. `resetZoom` zooms to 100 percent, as Shift+0 does. All three work in a read-only view too. `toolLocked` says whether the note, shape, frame and arrow tools stay picked after they add a shape. It is off when the view mounts and is never stored, and `setToolLocked` turns it on or off, as Q does, without changing the tool or the selection. `focus` moves focus back to the board and keeps its selection, such as after a toolbar menu closes. A shape whose text is being edited ends its edit and stays selected. `setStyle` merges into the next style. With the select tool it also writes each style to every selected shape that takes it and to the shape whose text is being edited, as one undo step that keeps the caret. With a drawing tool it styles only the next shape. Each entry of `styles` is `{ mixed: false, value }` when its targets share a value and `{ mixed: true }` when they differ, and a style no target takes has no entry. A read-only view's `setStyle` changes nothing. `upload(files)` lands picture files as image shapes in a row centered on the view, as [Picture files](#picture-files) describes. It changes nothing with an empty list or while `takesPictureFiles` is false. `exportPicture({ format, kit })` draws the selected shapes, or the whole board when nothing is selected, as a `'png'` or `'svg'` picture with the static plugins in `kit`. `kit` can be a promise, such as a dynamic import, as [Export](#export) shows. It reads the selection when it is called and loads its drawing code on the first call. It resolves `null` when there is nothing to draw, and rejects when the surface is not on the page or leaves it before the picture is drawn. Both hooks throw outside a `BoardSurface`. |
|
|
722
|
+
| `BoardPicture`, `BoardPictureOptions`, `BoardPictureWarning` | `platejs/board/react` | What `exportPicture` resolves, what it takes, and each warning in the picture's `warnings`. A warning's `code` is `content-undrawn`, `downscaled`, `font-missing`, `image-unreadable` or `shape-undrawn`, and the last two also name the `shapeId`. |
|
|
723
|
+
| `useArrowPath(element)`, `useStrokePath(element)` | `platejs/board/react` | The drawn path of an arrow or a pen line in a mounted board. `useStrokePath` returns the `BoardStrokePath` that `strokePath(id)` reads, or `undefined` when the element is not a pen line of that board. |
|
package/dist/docs/comment.md
CHANGED
|
@@ -103,7 +103,7 @@ Click “overlapping” to open both conversations. Edit the highlighted text, t
|
|
|
103
103
|
|
|
104
104
|
_Registry item `comment-overlap-demo`: `npx shadcn@latest add @plate/comment-overlap-demo`._
|
|
105
105
|
|
|
106
|
-
Inserting text inside a range expands it; deleting text contracts it. Text inserted at either boundary stays outside. An intentional atomic replacement carries the target to its replacement text. Deleting the target and typing later is a separate edit, so the later text does not inherit the comment. When no range can be shown, `attachment(id)` reports `unavailable`; **All comments** keeps the thread and its original excerpt reachable without a stale block badge. Undo and redo in the live session restore mapped coverage, including backward direction and overlaps.
|
|
106
|
+
Inserting text inside a range expands it; deleting text contracts it. Text inserted at either boundary stays outside. An intentional atomic replacement carries the target to its replacement text. Deleting the target and typing later is a separate edit, so the later text does not inherit the comment. Content that lands between a deleted range's ends can still join it, such as text typed into a paragraph the range emptied, a block moved into that spot, or same-style text the delete joins to the range's first letters. When no range can be shown, `attachment(id)` reports `unavailable`; **All comments** keeps the thread and its original excerpt reachable without a stale block badge. Undo and redo in the live session restore mapped coverage, including backward direction and overlaps.
|
|
107
107
|
|
|
108
108
|
### Save, reload, and retry
|
|
109
109
|
|
|
@@ -212,7 +212,7 @@ await repository.put(revision, { ifMatch: previousRevision });
|
|
|
212
212
|
|
|
213
213
|
In this example, `repository` is your application's storage adapter. It checks the expected revision before it commits.
|
|
214
214
|
|
|
215
|
-
`ranges()` returns `CommentRanges`, a record of plain `Range` values keyed by thread ID. It includes published threads, creates and draft publishes still waiting on `mutate`, drafts whose publish threw, and orphans. Other local drafts,
|
|
215
|
+
`ranges()` returns `CommentRanges`, a record of plain `Range` values keyed by thread ID. It includes published threads, creates and draft publishes still waiting on `mutate`, drafts whose publish threw, and orphans. Other local drafts, ranges that no longer resolve and threads on a suggestion have no entry; a suggestion's thread row keeps the change's ID instead. A thread whose text was deleted reads unavailable but keeps its entry, so text that comes back between its saved points attaches it again. Other content that lands between those points attaches it too. A range matches only the revision it was saved with.
|
|
216
216
|
|
|
217
217
|
A range in a named root, such as the text of a board note, carries that root on both points. A page range carries none:
|
|
218
218
|
|
|
@@ -205,25 +205,37 @@ holds only a weight refuses the parse, and a weight beside another style drops
|
|
|
205
205
|
without a report. Rewrite those spans before parsing, or keep an app plugin that
|
|
206
206
|
declares `fontWeight` with its Markdown mapping.
|
|
207
207
|
|
|
208
|
-
### Saved AI marks
|
|
208
|
+
### Saved AI and raw HTML marks
|
|
209
209
|
|
|
210
210
|
A v53 text leaf with `ai: true` holds AI output that nobody accepted. Plate
|
|
211
211
|
keeps an unaccepted response in a separate draft, so a v54 document has no place
|
|
212
212
|
to put that output back. When no plugin of the target schema declares an `ai`
|
|
213
213
|
text property, `migrateV54` keeps the text as ordinary text and drops the mark
|
|
214
214
|
from every leaf, every root, every media caption and the saved selection's
|
|
215
|
-
marks.
|
|
215
|
+
marks. It leaves an element property that an app's plugin declares, such as
|
|
216
|
+
the app's own `caption`, as the app stored it. Adjacent leaves then merge as
|
|
217
|
+
usual. A leaf whose saved v53 suggestion
|
|
218
|
+
changes `ai` keeps the mark, so `migrateDocument` refuses that document.
|
|
216
219
|
|
|
217
220
|
An app that wants the mark declares its own `ai` text property. `migrateV54`
|
|
218
221
|
then leaves every saved `ai` alone, and the app's schema decides where it loads.
|
|
219
222
|
`migrateDocument` refuses an `ai` under a block whose schema does not allow it,
|
|
220
|
-
|
|
223
|
+
or a value the declaration refuses, such as `true` under a string property, as
|
|
224
|
+
it refuses any other property the schema does not accept. A later step in the
|
|
225
|
+
app's own chain can convert such a value first, unless the document also holds
|
|
226
|
+
a saved v53 suggestion. `migrateV54` checks a document with suggestions
|
|
227
|
+
against the app's final schema before any later step runs.
|
|
221
228
|
|
|
222
229
|
A later step in the app's own chain cannot rename a saved `ai`, because
|
|
223
230
|
`migrateV54` drops it first when the target does not declare it. To keep the
|
|
224
231
|
mark under another name, rename it in a pre-pass before `migrateDocument`, as
|
|
225
232
|
the font-weight pre-pass above does.
|
|
226
233
|
|
|
234
|
+
A v53 text leaf with `rawHtml: true` holds text that Markdown import kept from
|
|
235
|
+
raw HTML. `migrateV54` treats `rawHtml` as it treats `ai`. An editor with
|
|
236
|
+
`RawHtmlPlugin` keeps the mark, and an editor whose plugins declare no
|
|
237
|
+
`rawHtml` drops it.
|
|
238
|
+
|
|
227
239
|
A document that the v53 AI kit saved while a response was streaming also holds
|
|
228
240
|
`aiPreview` on its blocks and an `aiChat` anchor. `migrateDocument` refuses it
|
|
229
241
|
for those keys.
|
package/dist/docs/editor.md
CHANGED
|
@@ -609,9 +609,49 @@ const editor = useCreateEditor({
|
|
|
609
609
|
const elementId = editor.plugin(ElementIdPlugin);
|
|
610
610
|
const key = editor.key(element);
|
|
611
611
|
const id = elementId.read.id(key);
|
|
612
|
-
const entry = id ?
|
|
612
|
+
const entry = id ? editor.read.nodes.byId(id) : null;
|
|
613
613
|
```
|
|
614
614
|
|
|
615
|
+
`editor.read.nodes.byId(id)`, or `tx.nodes.byId(id)` inside an update, returns
|
|
616
|
+
the element's `key`, `node` and `path`, with `root` when the element lives in
|
|
617
|
+
a named root, or `null` when no element holds the ID. A stored ID addresses an
|
|
618
|
+
element; the element's live identity stays its key. Node reads and node
|
|
619
|
+
transforms take an `{ id }` target, such as `nodes.path({ id })` or
|
|
620
|
+
`at: { id }`:
|
|
621
|
+
|
|
622
|
+
```ts
|
|
623
|
+
// A command looks the ID up in the document it runs in.
|
|
624
|
+
editor.update.nodes.move({ at: { id: "intro" }, to: [0] });
|
|
625
|
+
|
|
626
|
+
// A raw update looks the ID up in the stored draft.
|
|
627
|
+
editor.update((tx) => tx.nodes.remove({ at: { id: "intro" } }));
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
`byId` and `at: { id }` need an editor that stores IDs. An editor stores IDs
|
|
631
|
+
when the schema gives every element type a generated, unique string `id`, as
|
|
632
|
+
`ElementIdPlugin`'s default target does, and no content admits undeclared
|
|
633
|
+
element types. In any other editor, both throw.
|
|
634
|
+
|
|
635
|
+
An `{ id }` target acts as the key of the element that holds the ID. Text,
|
|
636
|
+
mark, range and offset targets keep their point or range. A target is an ID
|
|
637
|
+
only as an object, not an array, whose one own key is a string `id`, so a live
|
|
638
|
+
element that carries an `id` stays a node target. When no element holds the
|
|
639
|
+
ID, a write changes nothing and a read returns its empty result.
|
|
640
|
+
|
|
641
|
+
The route decides which document the ID is looked up in:
|
|
642
|
+
|
|
643
|
+
- A command, a plugin update method and every one-shot on `editor.update`, such
|
|
644
|
+
as `editor.update.nodes.wrap`, look it up in the command's document. So do
|
|
645
|
+
the one-shots and plugin update methods of a writable view, in the view's
|
|
646
|
+
root. Over another author's pending suggestions, the ID of a moved element
|
|
647
|
+
reaches the moved copy, and an ID that only a struck original holds changes
|
|
648
|
+
nothing. A path in `to`, `after` or `before`, and a child `position`, still
|
|
649
|
+
names a place in the stored document.
|
|
650
|
+
- A raw `editor.update((tx) => ...)` looks it up in the stored draft, as it
|
|
651
|
+
resolves a path or a key. It reaches the struck original.
|
|
652
|
+
- An editor view answers from its own document. A read on a view while a
|
|
653
|
+
command runs answers from the command's document.
|
|
654
|
+
|
|
615
655
|
The default generator is full-length `nanoid()`. Loads and moves preserve valid
|
|
616
656
|
IDs. Copies, splits, duplicates, and pasted copies receive fresh IDs. No two
|
|
617
657
|
elements store one ID. An insert or update that stores an ID another element
|
|
@@ -622,8 +662,9 @@ optionally installed package boundaries. A suggested Enter stores the new
|
|
|
622
662
|
element's ID when it records, so
|
|
623
663
|
[previews and decisions](/docs/authored-changes#configure-a-view) show that ID.
|
|
624
664
|
|
|
625
|
-
The compiled schema property target decides which elements receive IDs.
|
|
626
|
-
|
|
665
|
+
The compiled schema property target decides which elements receive IDs. When
|
|
666
|
+
only blocks need persisted identity and the application never finds or targets
|
|
667
|
+
an element by ID, narrow the target in the application schema:
|
|
627
668
|
|
|
628
669
|
```ts
|
|
629
670
|
import { ElementIdPlugin, schema, target } from "platejs";
|
|
@@ -640,6 +681,10 @@ const editor = useCreateEditor({
|
|
|
640
681
|
});
|
|
641
682
|
```
|
|
642
683
|
|
|
684
|
+
A block-only target leaves inline elements without IDs, so `nodes.byId` and
|
|
685
|
+
`at: { id }` throw in that editor, even for a block's ID.
|
|
686
|
+
`elementId.read.id(key)` and pen marks from `platejs/ink` keep working.
|
|
687
|
+
|
|
643
688
|
Current-document admission generates IDs only for matching elements and removes
|
|
644
689
|
the plugin-owned `id` from excluded elements. The block target works while no
|
|
645
690
|
element's content admits both a block and an inline element, because the ID is
|
|
@@ -724,7 +769,8 @@ Find the element that holds a unique value with
|
|
|
724
769
|
update. It reads the unique index instead of scanning, in every root, and
|
|
725
770
|
returns the holder's `key`, `path` and `root`, or `null` when no element holds
|
|
726
771
|
the value. Inside an update it also finds an element that took the value
|
|
727
|
-
earlier in that update.
|
|
772
|
+
earlier in that update. In an editor whose elements store IDs,
|
|
773
|
+
`holder("id", value)` throws: find that element with `nodes.byId(id)`.
|
|
728
774
|
|
|
729
775
|
```ts
|
|
730
776
|
const holder = editor.read.unique.holder("anchorId", anchorId);
|