platejs 54.0.0-beta.3 → 54.0.0-beta.4

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.
Files changed (150) hide show
  1. package/dist/{AIChatRequestContext-DY104TqL.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
  2. package/dist/{BaseSuggestionPlugin-Deo6n6Fs.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +4 -4
  3. package/dist/{PlateStatic-CJX5bKuv.d.ts → PlateStatic-D3Cb-QwH.d.ts} +3 -3
  4. package/dist/ai/index.d.ts +1 -1
  5. package/dist/ai/react/index.d.ts +9 -9
  6. package/dist/authored/index.d.ts +3 -3
  7. package/dist/code-block/codemirror/index.d.ts +1 -1
  8. package/dist/{combobox-DAOYWuvC.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
  9. package/dist/{comparison-types-Dt-unJZY-DCddmbSD.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +1 -1
  10. package/dist/compiler/index.d.ts +2 -2
  11. package/dist/{core-ClHasORr.d.ts → core-BqR-fEDp.d.ts} +65 -26
  12. package/dist/diff/index.d.ts +2 -2
  13. package/dist/docs/api/core/plate-controller.md +1 -1
  14. package/dist/docs/api/core.md +45 -5
  15. package/dist/docs/api/dom.md +4 -7
  16. package/dist/docs/api/react-hooks.md +40 -22
  17. package/dist/docs/authored-changes.md +4 -2
  18. package/dist/docs/block-placeholder.md +4 -2
  19. package/dist/docs/board.md +57 -4
  20. package/dist/docs/comment.md +2 -2
  21. package/dist/docs/document-model.md +15 -3
  22. package/dist/docs/editor.md +50 -4
  23. package/dist/docs/llms.txt +1 -1
  24. package/dist/docs/markdown.md +97 -9
  25. package/dist/docs/plugin-input-rules.md +62 -3
  26. package/dist/docx/export/index.d.ts +3 -3
  27. package/dist/docx/export/lib/exportDocx.js +18 -13
  28. package/dist/docx/export/lib/internal/xml-builder.js +11 -16
  29. package/dist/docx/export/lib/reviewProjection.js +43 -3
  30. package/dist/docx/import/index.d.ts +4 -4
  31. package/dist/docx/paste/index.d.ts +4 -4
  32. package/dist/dom/index.d.ts +1 -1
  33. package/dist/excalidraw/index.d.ts +3 -3
  34. package/dist/excalidraw/react/index.d.ts +3 -3
  35. package/dist/facade.js +2 -2
  36. package/dist/features/board/index.d.ts +1 -1
  37. package/dist/features/callout/index.d.ts +3 -3
  38. package/dist/features/combobox/index.d.ts +2 -2
  39. package/dist/features/comments/BaseCommentsPlugin.js +33 -17
  40. package/dist/features/comments/index.d.ts +1 -1
  41. package/dist/features/date/index.d.ts +3 -3
  42. package/dist/features/details/index.d.ts +3 -3
  43. package/dist/features/details/lib/BaseDetailsPlugin.js +15 -2
  44. package/dist/features/field/index.d.ts +2 -2
  45. package/dist/features/field/index.js +4 -2
  46. package/dist/features/field/lib/BaseFieldPlugin.js +51 -105
  47. package/dist/features/field/lib/applyFieldValues.js +188 -0
  48. package/dist/features/field/lib/fieldRules.internal.js +169 -7
  49. package/dist/features/find/index.d.ts +3 -3
  50. package/dist/features/footnote/index.d.ts +1 -1
  51. package/dist/features/ink/index.d.ts +1 -1
  52. package/dist/features/ink/lib/inkGone.internal.js +6 -6
  53. package/dist/features/ink/lib/inkPlaces.internal.js +8 -9
  54. package/dist/features/layout/index.d.ts +1 -1
  55. package/dist/features/lint/index.d.ts +3 -3
  56. package/dist/features/media/index.d.ts +2 -2
  57. package/dist/features/media/index.js +2 -2
  58. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +200 -2
  59. package/dist/features/mention/index.d.ts +5 -5
  60. package/dist/features/suggestion/index.d.ts +1 -1
  61. package/dist/features/table/index.d.ts +1 -1
  62. package/dist/features/table/lib/BaseTablePlugin.js +50 -7
  63. package/dist/features/toc/index.d.ts +1 -1
  64. package/dist/features/upload/index.d.ts +1 -1
  65. package/dist/history/index.d.ts +2 -2
  66. package/dist/html/index.d.ts +3 -3
  67. package/dist/html/server/index.d.ts +1 -1
  68. package/dist/{htmlTypes-cg_cWsaN.d.ts → htmlTypes-eT2ZGDAj.d.ts} +1 -1
  69. package/dist/hyperscript/index.d.ts +1 -1
  70. package/dist/{index-D3-2iM1b.d.ts → index-B33E1CRJ.d.ts} +291 -4
  71. package/dist/{index-DKOFvteF.d.ts → index-B7moSod7.d.ts} +1 -1
  72. package/dist/{index-C9DiGDVj.d.ts → index-B8-5Sr7I.d.ts} +2 -2
  73. package/dist/{index-CzLwBZpY.d.ts → index-B8QJDAmG.d.ts} +2 -2
  74. package/dist/{index-Cmuluh6f.d.ts → index-BTx5oK7k.d.ts} +1 -1
  75. package/dist/{index-DPWyk3lG-DOYwohXO.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
  76. package/dist/{index-DpltOCot-A2b3p3Eb.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +75 -27
  77. package/dist/{index-C6ql9pKw.d.ts → index-BXwU9QH6.d.ts} +2 -2
  78. package/dist/{index-CLsEe3LY.d.ts → index-BkwR-5hH.d.ts} +3 -3
  79. package/dist/{index-BZWFoUXt.d.ts → index-BsV2McRr.d.ts} +5 -5
  80. package/dist/{index-DQnjqtQa.d.ts → index-C9Fu-P4E.d.ts} +116 -21
  81. package/dist/{index-oIJAZxc2.d.ts → index-Ca48r1ng.d.ts} +3 -3
  82. package/dist/{index-Do9pj1GK.d.ts → index-Cob_iBdu.d.ts} +47 -6
  83. package/dist/{index-C1_JIhL4.d.ts → index-CpY7Xnxw.d.ts} +4 -4
  84. package/dist/{index-baQOK89E.d.ts → index-DNQXzU-X.d.ts} +1 -1
  85. package/dist/{index-8WO2vI0U.d.ts → index-DPowErHa.d.ts} +18 -20
  86. package/dist/{index-B5mYEawV.d.ts → index-DShbzec2.d.ts} +5 -6
  87. package/dist/{index-C35V_hj0.d.ts → index-DYdObeFQ.d.ts} +3 -3
  88. package/dist/{index-HPYawTae-BCUQLEWF.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +1 -1
  89. package/dist/{index-CdOLsPaW.d.ts → index-DwWQVwQt.d.ts} +3 -5
  90. package/dist/{index-r7yb77Wy.d.ts → index-JWgwL5l3.d.ts} +5 -3
  91. package/dist/{index-CktYvOgk.d.ts → index-M781pyx9.d.ts} +4 -4
  92. package/dist/{index-C0POz7rg.d.ts → index-d7io3MzC.d.ts} +3 -3
  93. package/dist/index.d.ts +4 -4
  94. package/dist/lib/plugins/element-id/ElementIdPlugin.js +6 -16
  95. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +73 -14
  96. package/dist/markdown/index.d.ts +2 -2
  97. package/dist/markdown/index.js +2 -1
  98. package/dist/markdown/lib/MarkdownPlugin.js +8 -12
  99. package/dist/markdown/lib/RawHtmlPlugin.js +4 -2
  100. package/dist/markdown/lib/internal/markdownConversion.js +7 -4
  101. package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
  102. package/dist/markdown/lib/internal/markdownRawHtml.js +40 -1
  103. package/dist/markdown/lib/internal/markdownTags.js +7 -1
  104. package/dist/math/index.d.ts +3 -3
  105. package/dist/math/react/index.d.ts +4 -4
  106. package/dist/migrations/index.d.ts +3 -3
  107. package/dist/migrations/migratePlateV54.js +4 -6
  108. package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
  109. package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
  110. package/dist/migrations/v53-manifest.internal.js +4 -0
  111. package/dist/pagination/index.d.ts +1 -1
  112. package/dist/pagination/react/index.d.ts +2 -2
  113. package/dist/react/components/EditorContentView.internal.js +26 -16
  114. package/dist/react/components/Plate.js +13 -20
  115. package/dist/react/features/board/boardExport.internal.js +470 -0
  116. package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
  117. package/dist/react/features/board/boardView.internal.js +11 -6
  118. package/dist/react/features/board/index.d.ts +50 -6
  119. package/dist/react/features/callout/index.d.ts +3 -3
  120. package/dist/react/features/combobox/index.d.ts +5 -5
  121. package/dist/react/features/comments/index.d.ts +6 -6
  122. package/dist/react/features/date/index.d.ts +4 -4
  123. package/dist/react/features/details/index.d.ts +4 -4
  124. package/dist/react/features/field/FieldPlugin.js +5 -4
  125. package/dist/react/features/field/index.d.ts +19 -16
  126. package/dist/react/features/footnote/index.d.ts +7 -7
  127. package/dist/react/features/format-painter/index.d.ts +4 -4
  128. package/dist/react/features/ink/index.d.ts +5 -9
  129. package/dist/react/features/ink/inkPlacement.internal.js +2 -1
  130. package/dist/react/features/layout/index.d.ts +5 -5
  131. package/dist/react/features/media/index.d.ts +5 -5
  132. package/dist/react/features/mention/index.d.ts +6 -6
  133. package/dist/react/features/suggestion/index.d.ts +6 -6
  134. package/dist/react/features/table/index.d.ts +7 -6
  135. package/dist/react/features/table/useTableResize.js +10 -1
  136. package/dist/react/features/toc/index.d.ts +2 -2
  137. package/dist/react/features/upload/index.d.ts +5 -5
  138. package/dist/react/index.d.ts +6 -6
  139. package/dist/react/internal/plate-context.js +20 -11
  140. package/dist/react/stores/plate/useEditorSelector.js +22 -9
  141. package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
  142. package/dist/react/virtualized.d.ts +2 -2
  143. package/dist/{source-aUwpNnAw.d.ts → source-BGohy8vH.d.ts} +3 -3
  144. package/dist/static/index.d.ts +5 -5
  145. package/dist/tabbable/index.d.ts +1 -1
  146. package/dist/tabbable/react/index.d.ts +3 -3
  147. package/dist/testing/index.d.ts +2 -2
  148. package/dist/yjs/index.d.ts +1 -1
  149. package/dist/yjs/react/index.d.ts +5 -5
  150. 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 no `EditorContent` there shows
355
- the root, it follows the `EditorRoot`, or the `EditorContent` around the hook
356
- when the hook renders inside one. While that `EditorRoot` is writable and
357
- shows no `EditorContent` at all, and the caret sits in the hook's root inside
358
- another `EditorRoot` of the same editor, the editor follows the
359
- `EditorContent` that holds the caret instead, for that `EditorContent`'s DOM
360
- and for the read-only state of the `EditorRoot` around it. A read-only `EditorContent` that shares
361
- its `EditorRoot` with a writable one leaves the editor writable. The editor
362
- keeps the authored view of its own `EditorRoot`. A write through it that
363
- places the caret, even where the caret already is, moves the caret into its
364
- own `EditorRoot`, which ends the follow. A caret that moves only because the
365
- content around it changed stays in the followed `EditorContent`. An
366
- `EditorRoot` that shows a preview counts as writable here, so its editor
367
- follows too. The preview refuses the editor's content edits, but a selection
368
- change through the editor still ends the follow, and a review decision still
369
- changes the document. When that `EditorRoot` is read-only, the editor stays
370
- read-only instead.
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
- Outside that follow into another `EditorRoot`, the editor also takes the
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. An editor from a hook outside it
380
- follows it only while it holds the caret, as above.
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 the editor follows its `EditorRoot` because no `EditorContent` shows the
392
- root, its DOM lookups return `null` and `focus()` does nothing. A call given a
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
@@ -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 `upload`. 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. |
670
- | `useArrowPath(element)`, `useStrokePath(element)` | `platejs/board/react` | The drawn path of an arrow or a pen line. |
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. |
@@ -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, unavailable ranges and threads on a suggestion have no entry; a suggestion's thread row keeps the change's ID instead. A range matches only the revision it was saved with.
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. Adjacent leaves then merge as usual.
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
- as it refuses any other undeclared property.
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.
@@ -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 ? elementId.read.entry(id) : undefined;
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. Narrow
626
- the target in the application schema when only blocks need persisted identity:
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);
@@ -1,4 +1,4 @@
1
- # Plate docs for platejs@54.0.0-beta.3
1
+ # Plate docs for platejs@54.0.0-beta.4
2
2
 
3
3
  These pages match the installed `platejs` version. A `/docs/<path>` link in a page is the file `<path>.md` in this folder when the list below names it, and `/docs` is `index.md`. Read the pages your task needs before you write editor code.
4
4
 
@@ -118,7 +118,8 @@ register, after a leading [front matter](#front-matter) block. GFM, math,
118
118
  emoji, and [CJK emphasis](#cjk-emphasis) come from the
119
119
  [remark plugins](#remark-plugins) configured on `MarkdownPlugin`. Registered
120
120
  tags look like HTML, but only registered names are tags and nothing is
121
- evaluated.
121
+ evaluated. Other HTML stays text, which [`RawHtmlPlugin`](#raw-html) writes
122
+ back as HTML when its block passes a check.
122
123
 
123
124
  ### Registered tags
124
125
 
@@ -138,6 +139,90 @@ A tag is registered only while its feature plugin is installed. Element tags
138
139
  use the schema type, so an application that renames a type also renames its
139
140
  tag.
140
141
 
142
+ ### Raw HTML
143
+
144
+ `RawHtmlPlugin` keeps a file's raw HTML through a save. The Markdown kit
145
+ installs it. An editor with its own plugin list adds it beside
146
+ `MarkdownPlugin`:
147
+
148
+ ```ts
149
+ import { BaseParagraphPlugin, createEditor } from 'platejs';
150
+ import { MarkdownPlugin, RawHtmlPlugin } from 'platejs/markdown';
151
+
152
+ const editor = createEditor({
153
+ plugins: [BaseParagraphPlugin, MarkdownPlugin, RawHtmlPlugin],
154
+ });
155
+ ```
156
+
157
+ An app whose own plugin already declares a `rawHtml` mark keeps that plugin and
158
+ leaves `RawHtmlPlugin` out, because two plugins cannot own one mark.
159
+
160
+ The plugin changes the editor's schema fingerprint, so an editor with it
161
+ refuses a document saved under the earlier schema identity. An app that saves
162
+ documents under a named schema increments its `version` and adds a migration
163
+ step, as [Document migrations](/docs/editor#document-migrations) shows. An app
164
+ that saves `{ document, schema }` under the derived identity opens each saved
165
+ document in an editor without the plugin and passes its `read.value()` to the
166
+ new editor.
167
+
168
+ Import gives the `rawHtml` mark to raw HTML that no registered tag claims, such
169
+ as a README's centered header, and to most HTML comments on lines of their own
170
+ in the document, a block quote or a list item. The editor shows that text as
171
+ plain text, and export writes it back as HTML:
172
+
173
+ ```md
174
+ <p align="center">
175
+ <img src="logo.png" width="200" />
176
+ </p>
177
+
178
+ <!-- markdownlint-disable -->
179
+ ```
180
+
181
+ - Import marks only HTML that export can write back. Other raw HTML stays plain
182
+ text without the mark and saves escaped, as it does without the plugin. A
183
+ comment block that fails the check, such as `<!-- a <!-- b -->`, also stays
184
+ plain text, where an editor without the plugin drops it.
185
+ - Export checks each block that holds marked text: its paragraph, heading,
186
+ table cell or HTML block. Marked text in any other block fails the check.
187
+ The check accepts a fixed set of formatting, heading, list, table, media and
188
+ disclosure tags, such as `p`, `div`, `img`, `kbd` and `details`, and
189
+ attributes such as `align`, `alt`, `href`, `src`, `title` and `width`. It
190
+ refuses every other tag and attribute, such as `script`, `class`, `style` and
191
+ event handlers, and a doctype.
192
+ - An `href` or `src` URL passes when it is empty or Plate's URL safety rules
193
+ accept it, and a `cite` or `srcset` URL passes only when those rules accept
194
+ it. The rules refuse script-capable schemes such as `javascript:`. The check
195
+ does not read the Link plugin's `allowedSchemes`, so
196
+ `<a href="smb://server/share">x</a>` writes back as HTML, while the Link
197
+ plugin with its default schemes refuses `[x](smb://server/share)`.
198
+ - When an edit makes a marked block fail the check, export writes that block's
199
+ marked text escaped and reports a lossless `markdown-unsafe-content` warning.
200
+ In rare cases, such as a mapping that copies marked text, export writes all
201
+ marked text in the document escaped. Plate writes a details summary line as
202
+ HTML, so a CommonMark reader still reads escaped text there as HTML, while
203
+ Plate reads it back as the same plain text.
204
+ - An HTML block writes back as HTML in the document, a block quote or a list
205
+ item. Inside a registered block tag's body, such as `<callout>`, raw HTML
206
+ writes back only in pieces that fit on one line. An HTML block there stays
207
+ plain text and saves escaped, and one directly inside `<details>` fails the
208
+ parse with `markdown-schema-invalid`, unless it is a comment. A `<block>`
209
+ wrapper around one HTML block drops on import, and its HTML writes back. A
210
+ footnote definition keeps all of its raw HTML as plain text.
211
+ - A comment drops, as it does without the plugin, when it sits inside a line of
212
+ paragraph or heading text, a table cell, a registered tag's body or a
213
+ footnote definition, or when it is an unindented `<!---->`, the separator
214
+ Plate writes between two blocks.
215
+ - Import also leaves unmarked a comment or HTML block whose indent export
216
+ cannot write back. That covers one indented past its list item's text on the
217
+ line after an empty marker, such as ` <!-- c -->` after `-`, one indented
218
+ after a list, such as one space after `- a`, and one whose indent keeps a tab
219
+ after the indent of its quote or list item. Such a comment drops, and such
220
+ HTML saves escaped.
221
+ - HTML, DOCX and plain-text export write marked text as visible text.
222
+ - Naming `rawHtml` in `MarkdownPlugin`'s `plainMarks` stops import from
223
+ marking, so tags stay plain text and comment blocks drop. Naming it in a
224
+ serialize call's `plainMarks` writes marked text escaped, with no warning.
225
+
141
226
  ### Writer output
142
227
 
143
228
  ```md
@@ -169,7 +254,8 @@ Due <date value="2025-01-01" />, ask [Jane](mention:user_123).
169
254
 
170
255
  - Every string parses. Raw HTML that no mapping accepts stays literal text and
171
256
  reports a lossless `markdown-unsupported-node` warning under every policy.
172
- - HTML comments are dropped with a lossless warning.
257
+ - Without [`RawHtmlPlugin`](#raw-html), an HTML block that holds only closed
258
+ comments drops with a lossless warning.
173
259
  - `<br>`, `<br/>`, and `<br />` become line breaks.
174
260
  - A line holding only a registered block tag is a block, even next to paragraph
175
261
  text. A block tag elsewhere in a paragraph or heading stays text. A table cell
@@ -686,8 +772,9 @@ When the list still holds it, it reads every slice and every block Plate's
686
772
  reader refuses. Unless a mapping decodes the `yaml` or `toml` node it makes,
687
773
  that node is a lossy `markdown-unsupported-node`, which fails the parse under
688
774
  the default policy. A [streaming preview](#streaming-previews) that continues
689
- its previous result also reads a block at the start of each later piece of the
690
- stream, so that preview can differ from a fresh parse of the same text.
775
+ its previous result reads the whole source again while the plugin adds front
776
+ matter syntax, as it does with its default options, so it matches a fresh parse
777
+ of the same text.
691
778
 
692
779
  ### CJK emphasis
693
780
 
@@ -740,7 +827,7 @@ reportWarnings(result.diagnostics);
740
827
  | Code | Severity | Reports |
741
828
  | --- | --- | --- |
742
829
  | `markdown-unsupported-node` | Warning when `lossless` or when the content stays; other `lossy` follows `lossPolicy` | Content no mapping accepts, refused content, or nodes dropped on export (`lossy`), such as a table when no remark plugin, like `remark-gfm`, writes tables. Raw HTML kept as text, HTML comments and removed `<block>` wrappers are `lossless`. A [table cell](#table-cells)'s folded paragraph boundary or collapsed block keeps its content and warns. |
743
- | `markdown-unsafe-content` | Warning when `lossless`; lossy follows `lossPolicy` | A removed link or image destination. |
830
+ | `markdown-unsafe-content` | Warning when `lossless`; lossy follows `lossPolicy` | A removed link or image destination, or marked raw HTML whose block fails the raw HTML check on export. |
744
831
  | `markdown-tag-repair` | Warning | An `unclosed`, `unmatched`, or `misplaced` registered tag. |
745
832
  | `markdown-property-omitted` | Warning | A property or mark Markdown cannot carry on export, such as a paragraph's `textAlign`, or an invalid tag attribute value on import. |
746
833
  | `markdown-limit-exceeded` | Error | Source bytes, node count, or depth above `limits`. |
@@ -768,8 +855,8 @@ parser returns because mdast does not expose a bounded construction hook.
768
855
  | `editor.api.markdown.parseInline(source, options?)` | Closed, rootless inline `ContentSlice`. |
769
856
  | `editor.api.markdown.serialize(options?)` | Current or supplied document using the installed target. |
770
857
 
771
- Import `MarkdownPlugin`, the standalone functions, and their result,
772
- diagnostic, and option types from `platejs/markdown`.
858
+ Import `MarkdownPlugin`, `RawHtmlPlugin`, the standalone functions, and their
859
+ result, diagnostic, and option types from `platejs/markdown`.
773
860
 
774
861
  | Parse option | Use |
775
862
  | --- | --- |
@@ -782,7 +869,7 @@ diagnostic, and option types from `platejs/markdown`.
782
869
  | --- | --- |
783
870
  | `document` | Editor method only: the document to serialize, typed as the editor's value. Defaults to the current value. |
784
871
  | `lossPolicy` | `'reject'` (default) or `'allow'`. |
785
- | `plainMarks` | Mark keys written as plain text without Markdown formatting. |
872
+ | `plainMarks` | Mark keys written as plain text without Markdown formatting. Defaults to `MarkdownPlugin`'s `plainMarks`. |
786
873
  | `preserveEmptyParagraphs` | Keep empty paragraphs. Defaults to `true`. |
787
874
  | `projection` | `'accepted'` or `'proposed'`. Required when the document has pending suggestions. |
788
875
  | `remarkStringifyOptions` | Options passed to `remark-stringify`. |
@@ -791,4 +878,5 @@ diagnostic, and option types from `platejs/markdown`.
791
878
  Standalone functions also require `plugins` and accept `schema`. Installed
792
879
  editor methods omit both because the plugin captures them from the editor.
793
880
  `MarkdownPlugin` state holds `remarkPlugins`, `remarkStringifyOptions`, and
794
- `plainMarks`.
881
+ `plainMarks`. When its `plainMarks` names `rawHtml`, import gives raw HTML no
882
+ mark.