platejs 54.0.0-beta.2 → 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 (255) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
  6. package/dist/ai/index.d.ts +1 -1
  7. package/dist/ai/react/AIChatPlugin.js +113 -78
  8. package/dist/ai/react/CopilotPlugin.js +1 -1
  9. package/dist/ai/react/index.d.ts +23 -16
  10. package/dist/authored/index.d.ts +4 -4
  11. package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
  12. package/dist/code-block/codemirror/index.d.ts +1 -1
  13. package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
  17. package/dist/diff/index.d.ts +2 -2
  18. package/dist/docs/ai.md +4 -3
  19. package/dist/docs/api/core/plate-components.md +0 -19
  20. package/dist/docs/api/core/plate-controller.md +5 -3
  21. package/dist/docs/api/core/plate-plugin.md +3 -0
  22. package/dist/docs/api/core/plate-store.md +3 -3
  23. package/dist/docs/api/core.md +45 -5
  24. package/dist/docs/api/dom.md +11 -4
  25. package/dist/docs/api/editor-transforms.md +2 -1
  26. package/dist/docs/api/react-hooks.md +45 -13
  27. package/dist/docs/authored-changes.md +9 -4
  28. package/dist/docs/basic-blocks.md +42 -29
  29. package/dist/docs/block-placeholder.md +4 -2
  30. package/dist/docs/blockquote.md +5 -3
  31. package/dist/docs/board.md +118 -10
  32. package/dist/docs/code-block.md +47 -0
  33. package/dist/docs/comment.md +2 -2
  34. package/dist/docs/discussion.md +1 -1
  35. package/dist/docs/document-model.md +15 -3
  36. package/dist/docs/docx.md +1 -1
  37. package/dist/docs/dom-coverage.md +5 -0
  38. package/dist/docs/editor.md +50 -4
  39. package/dist/docs/examples/editable-voids.md +2 -3
  40. package/dist/docs/external-text.md +2 -0
  41. package/dist/docs/field.md +370 -0
  42. package/dist/docs/find.md +9 -6
  43. package/dist/docs/form.md +2 -0
  44. package/dist/docs/heading.md +6 -0
  45. package/dist/docs/installation/manual.md +0 -4
  46. package/dist/docs/link.md +3 -3
  47. package/dist/docs/llms.txt +4 -2
  48. package/dist/docs/markdown.md +270 -14
  49. package/dist/docs/plugin-components.md +13 -10
  50. package/dist/docs/plugin-input-rules.md +66 -15
  51. package/dist/docs/prompt-editor.md +205 -0
  52. package/dist/docs/roots.md +8 -6
  53. package/dist/docs/rtl.md +6 -4
  54. package/dist/docs/selection.md +7 -4
  55. package/dist/docs/suggestion.md +1 -1
  56. package/dist/docs/toolbar.md +26 -30
  57. package/dist/docs/upload.md +106 -17
  58. package/dist/docx/export/index.d.ts +3 -3
  59. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  60. package/dist/docx/export/lib/exportDocx.js +46 -17
  61. package/dist/docx/export/lib/internal/xml-builder.js +11 -16
  62. package/dist/docx/export/lib/reviewPart.js +1 -1
  63. package/dist/docx/export/lib/reviewProjection.js +52 -10
  64. package/dist/docx/import/index.d.ts +4 -4
  65. package/dist/docx/paste/index.d.ts +4 -4
  66. package/dist/dom/index.d.ts +1 -6
  67. package/dist/dom/plite-dom.internal.js +2 -2
  68. package/dist/excalidraw/index.d.ts +3 -2
  69. package/dist/excalidraw/react/index.d.ts +3 -2
  70. package/dist/facade.js +2 -2
  71. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  72. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  73. package/dist/features/board/index.d.ts +2 -2
  74. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  75. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  76. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  77. package/dist/features/callout/index.d.ts +3 -2
  78. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  79. package/dist/features/combobox/index.d.ts +2 -2
  80. package/dist/features/comments/BaseCommentsPlugin.js +33 -17
  81. package/dist/features/comments/index.d.ts +1 -1
  82. package/dist/features/date/index.d.ts +3 -2
  83. package/dist/features/details/index.d.ts +3 -2
  84. package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
  85. package/dist/features/field/index.d.ts +2 -0
  86. package/dist/features/field/index.js +4 -0
  87. package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
  88. package/dist/features/field/lib/applyFieldValues.js +188 -0
  89. package/dist/features/field/lib/fieldRules.internal.js +204 -0
  90. package/dist/features/find/index.d.ts +3 -2
  91. package/dist/features/footnote/index.d.ts +1 -1
  92. package/dist/features/ink/index.d.ts +1 -1
  93. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  94. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  95. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  96. package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
  97. package/dist/features/layout/index.d.ts +1 -1
  98. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  99. package/dist/features/lint/index.d.ts +3 -2
  100. package/dist/features/media/index.d.ts +2 -2
  101. package/dist/features/media/index.js +2 -2
  102. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  103. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
  104. package/dist/features/mention/index.d.ts +5 -4
  105. package/dist/features/suggestion/index.d.ts +1 -1
  106. package/dist/features/table/index.d.ts +1 -1
  107. package/dist/features/table/lib/BaseTablePlugin.js +64 -15
  108. package/dist/features/table/lib/internal/selection.js +4 -2
  109. package/dist/features/toc/index.d.ts +1 -1
  110. package/dist/features/upload/index.d.ts +2 -2
  111. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  112. package/dist/history/index.d.ts +2 -2
  113. package/dist/html/index.d.ts +3 -3
  114. package/dist/html/server/index.d.ts +1 -1
  115. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
  116. package/dist/hyperscript/index.d.ts +1 -1
  117. package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
  118. package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
  119. package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
  120. package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
  121. package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
  122. package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
  123. package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
  124. package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
  125. package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
  126. package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
  127. package/dist/index-C9Fu-P4E.d.ts +773 -0
  128. package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
  129. package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
  130. package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
  131. package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
  132. package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
  133. package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
  134. package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
  135. package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
  136. package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
  137. package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
  138. package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
  139. package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
  140. package/dist/index.d.ts +4 -4
  141. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  142. package/dist/internal/plugin/OverridePlugin.js +101 -119
  143. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  144. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  145. package/dist/internal/plugin/resolvePlugin.js +1 -1
  146. package/dist/internal/plugin/resolvePlugins.js +3 -0
  147. package/dist/internal/plugin/uploadDrafts.js +6 -0
  148. package/dist/internal/utils/mergePlugins.js +1 -0
  149. package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
  150. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  151. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  152. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
  153. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  154. package/dist/markdown/index.d.ts +2 -2
  155. package/dist/markdown/index.js +3 -1
  156. package/dist/markdown/lib/MarkdownPlugin.js +14 -11
  157. package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
  158. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  159. package/dist/markdown/lib/internal/markdownConversion.js +776 -74
  160. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  161. package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
  162. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  163. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  164. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  165. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  166. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  167. package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
  168. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  169. package/dist/markdown/lib/internal/markdownTags.js +29 -9
  170. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  171. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  172. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  173. package/dist/math/index.d.ts +3 -2
  174. package/dist/math/react/index.d.ts +4 -3
  175. package/dist/migrations/index.d.ts +3 -3
  176. package/dist/migrations/migratePlateV54.js +4 -6
  177. package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
  178. package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
  179. package/dist/migrations/v53-manifest.internal.js +4 -0
  180. package/dist/pagination/index.d.ts +1 -1
  181. package/dist/pagination/react/index.d.ts +4 -4
  182. package/dist/react/components/EditorContentView.internal.js +42 -23
  183. package/dist/react/components/EditorProvider.js +5 -5
  184. package/dist/react/components/Plate.js +102 -128
  185. package/dist/react/components/PlateContainer.js +40 -32
  186. package/dist/react/components/PlateController.js +28 -16
  187. package/dist/react/components/PlateRoot.internal.js +3 -2
  188. package/dist/react/core.js +4 -4
  189. package/dist/react/features/board/BoardSurface.js +116 -87
  190. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  191. package/dist/react/features/board/boardExport.internal.js +470 -0
  192. package/dist/react/features/board/boardGesture.internal.js +6 -3
  193. package/dist/react/features/board/boardIndex.internal.js +7 -18
  194. package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
  195. package/dist/react/features/board/boardPictures.internal.js +19 -13
  196. package/dist/react/features/board/boardView.internal.js +190 -50
  197. package/dist/react/features/board/boardVoice.internal.js +10 -11
  198. package/dist/react/features/board/index.d.ts +108 -18
  199. package/dist/react/features/callout/index.d.ts +3 -2
  200. package/dist/react/features/combobox/index.d.ts +8 -8
  201. package/dist/react/features/comments/index.d.ts +6 -5
  202. package/dist/react/features/date/index.d.ts +4 -3
  203. package/dist/react/features/details/index.d.ts +4 -3
  204. package/dist/react/features/field/FieldPlugin.js +35 -0
  205. package/dist/react/features/field/index.d.ts +315 -0
  206. package/dist/react/features/field/index.js +2 -0
  207. package/dist/react/features/footnote/index.d.ts +7 -6
  208. package/dist/react/features/format-painter/index.d.ts +4 -3
  209. package/dist/react/features/ink/InkContent.js +313 -0
  210. package/dist/react/features/ink/index.d.ts +57 -33
  211. package/dist/react/features/ink/index.js +2 -2
  212. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  213. package/dist/react/features/ink/inkInput.internal.js +1 -1
  214. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  215. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  216. package/dist/react/features/ink/inkPlacement.internal.js +332 -104
  217. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  218. package/dist/react/features/layout/index.d.ts +5 -4
  219. package/dist/react/features/media/index.d.ts +5 -4
  220. package/dist/react/features/mention/index.d.ts +6 -5
  221. package/dist/react/features/resizable/Resizable.js +4 -6
  222. package/dist/react/features/resizable/index.d.ts +5 -5
  223. package/dist/react/features/suggestion/index.d.ts +6 -5
  224. package/dist/react/features/table/TablePlugin.js +4 -11
  225. package/dist/react/features/table/index.d.ts +10 -8
  226. package/dist/react/features/table/useTableResize.js +10 -1
  227. package/dist/react/features/toc/index.d.ts +2 -2
  228. package/dist/react/features/upload/index.d.ts +11 -6
  229. package/dist/react/index.d.ts +6 -6
  230. package/dist/react/index.js +4 -4
  231. package/dist/react/internal/plate-context.js +434 -188
  232. package/dist/react/plite-react.js +2 -2
  233. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  234. package/dist/react/stores/plate/useEditor.js +32 -14
  235. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  236. package/dist/react/stores/plate/useEditorSelector.js +79 -21
  237. package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
  238. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  239. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  240. package/dist/react/virtualized.d.ts +4 -4
  241. package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
  242. package/dist/static/index.d.ts +18 -18
  243. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  244. package/dist/static/internal/staticPresentation.js +4 -4
  245. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  246. package/dist/tabbable/index.d.ts +1 -1
  247. package/dist/tabbable/react/index.d.ts +3 -3
  248. package/dist/testing/index.d.ts +3 -3
  249. package/dist/yjs/index.d.ts +1 -1
  250. package/dist/yjs/react/index.d.ts +6 -6
  251. package/package.json +20 -2
  252. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  253. package/dist/react/components/EditorSelectionView.js +0 -40
  254. package/dist/react/features/ink/InkLayer.js +0 -218
  255. package/dist/react/internal/createPlateTargetScope.js +0 -62
@@ -13,7 +13,9 @@ _Example `board-demo` in the Plate repository: `apps/www/src/registry/examples/b
13
13
  - Styles stored on each shape: fill, outline color, line style, outline width, opacity and text size, each with a default for its shape type. One pick restyles the selected shapes as one undo step, or the next shape while a drawing tool is picked.
14
14
  - Commands to insert, move, resize, restack and remove shapes. Undo never splits a call, and in Suggesting mode each call is one suggestion.
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
- - 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.
16
+ - Paste text or a link, and it lands as a selected note at the pointer.
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.
17
19
  - A camera, a tool, a tool lock and a next style for each mounted view, which the document never stores.
18
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.
19
21
  - Only the shapes near the camera mount, so the work each keystroke does stays the same as the board grows.
@@ -34,7 +36,7 @@ _Registry item `board`: `npx shadcn@latest add @plate/board`._
34
36
  - `BoardPageElement`: renders a board that fills its container. `BoardPageKit` installs it in place of `BoardElement`.
35
37
  - `BoardNoteElement`, `BoardGeoElement`, `BoardArrowElement`, `BoardFrameElement` and `BoardStrokeElement`: render each shape type.
36
38
  - `BoardImageElement`: renders an image shape. `BoardImageKit` installs it apart from `BoardKit`, as [Images](#images) shows.
37
- - `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. 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.
38
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.
39
41
 
40
42
  ### Add kit
@@ -62,7 +64,7 @@ In this example the board is the page's only block, like a whiteboard app. It fi
62
64
 
63
65
  _Example `board-page-demo` in the Plate repository: `apps/www/src/registry/examples/board-page-demo.tsx`, `apps/www/src/registry/examples/values/board-value.tsx`._
64
66
 
65
- `BoardPageKit` draws the board with `BoardPageElement`, which passes `height="100%"` to `BoardSurface`. That `height` replaces the board's stored `height` in this view and never changes the document, so the board takes the height of the editor around it. Give the editor a height, as the example does with `<Editor className="h-full" variant="none" />` inside a container of set height. Leave out kits that wrap each block or add a paragraph after the last one, such as the drag handles and the trailing block of `EditorKit`. The example installs `ImagePlugin` and `BoardImageKit`, so a pasted picture lands on its board as [Images](#images) describes.
67
+ `BoardPageKit` draws the board with `BoardPageElement`, which passes `height="100%"` to `BoardSurface`. That `height` replaces the board's stored `height` in this view and never changes the document, so the board takes the height of the editor around it. Give the editor a height, as the example does with `<Editor className="h-full" variant="none" />` inside a container of set height. Leave out kits that wrap each block or add a paragraph after the last one, such as the drag handles and the trailing block of `EditorKit`. The example installs `ImagePlugin` and `BoardImageKit`, so a pasted image link or web picture lands on its board as [Images](#images) describes. It installs no `UploadPlugin`, so its board takes no [picture files](#picture-files) and its Image button is disabled.
66
68
 
67
69
  ## Style panel
68
70
 
@@ -134,6 +136,16 @@ function TextSizeRow() {
134
136
  }
135
137
  ```
136
138
 
139
+ ## Pasted text
140
+
141
+ Paste text or a link while the board has focus, such as after a click on its empty space, and a new note holds it. With the caret in the page's text, the page takes the paste at the caret, even while the pointer is over the board.
142
+
143
+ - The note lands centered on the pointer, or on the view's center when the pointer is off the board, at the note tool's 200 by 200 size and in the next style. It lands as one undo step, and the board selects it.
144
+ - The note's text takes the paste as a paste into a note's text does, so the paste plugins your editor installs apply. With `LinkPlugin`, a pasted URL becomes a link.
145
+ - With a shape selected, pasted text still lands as a new note, and the selected shape keeps its text.
146
+ - Blank text, or a paste on a read-only board, lands nothing. An image link lands as an image shape, as [Images](#images) says.
147
+ - While a shape's text is being edited, a paste goes into that text.
148
+
137
149
  ## Images
138
150
 
139
151
  `BoardImageKit` adds the image shape, a box that holds one picture. Its one child is the document's own image element, so `ImagePlugin` keeps the picture's link, alt text, HTML and Markdown. Install the kit in an editor that installs `ImagePlugin`, such as one with the [media kit](/docs/media). The demo at the top of this page gets it from `EditorKit`.
@@ -188,6 +200,96 @@ editor.update((tx) => {
188
200
  });
189
201
  ```
190
202
 
203
+ ### Picture files
204
+
205
+ Install `UploadPlugin` beside `ImagePlugin`, and the board takes picture files. Each file lands in its own image shape, which holds an upload draft until the file finishes uploading and holds the picture after that. [Upload Files](/docs/upload) sets up the plugin, its client and its rules. `EditorKit` holds both plugins, so the demo at the top of this page takes files. That demo keeps each upload in the browser tab.
206
+
207
+ ```tsx
208
+ import { createEditor } from 'platejs/react';
209
+
210
+ import { BoardImageKit, BoardKit } from '@/components/editor/board';
211
+ import { MediaKit } from '@/components/editor/media';
212
+ import { UploadKit } from '@/components/editor/upload';
213
+
214
+ const editor = createEditor({
215
+ plugins: [
216
+ // ...otherPlugins,
217
+ ...MediaKit,
218
+ ...UploadKit,
219
+ ...BoardKit,
220
+ ...BoardImageKit,
221
+ ],
222
+ });
223
+ ```
224
+
225
+ | Gesture | Where the pictures land |
226
+ | --- | --- |
227
+ | Paste copied files while the board has focus | Centered on the pointer, or on the view's center when the pointer is off the board. |
228
+ | Drop files on the board | Centered on the drop point. |
229
+ | Click the toolbar's Image button and pick files | Centered on the view. |
230
+
231
+ - The files of one paste, drop or pick land as image shapes in a row, in file order and 16px apart. They land as one undo step, and the board selects them.
232
+ - The board measures each file before it lands, and sizes its shape as it sizes a pasted link's shape. A file that does not load as a picture lands at 320 by 240.
233
+ - The landing waits for each file to load. It drops the files when another landing starts, when a key or pointer is pressed on the board, when another paste arrives, when focus leaves the board, when the document or the selection changes, or when the view stops being able to write.
234
+ - While a file uploads, its shape draws your upload element. The copied `UploadElement` shows the picture with its progress and a Cancel button. After a failed upload it shows the file's name and "Upload failed. Try again.", and a click on it opens a file picker.
235
+ - Cancel stops the upload and keeps the shape. The shape then shows the upload element's Add an image button. Its file picker takes one file, which uploads in the same shape. Delete removes the shape.
236
+ - One undo removes the shapes of a paste, drop or pick and stops their uploads. An upload that finishes after the undo changes nothing. Redo brings back the pictures of uploads that had finished. For the other shapes it brings back empty drafts, which upload nothing until you pick a file.
237
+ - A file that is not a picture, such as a PDF, lands no shape. `UploadPlugin` passes it to `onError` as `unsupported-file-type`, which the copied `UploadKit` shows as a toast. The pictures beside it still land.
238
+ - `UploadPlugin` checks the pictures of one paste, drop or pick as one batch against its `rules` and `maxFiles`. A batch it refuses lands no shape, and `onError` gets the reason.
239
+ - A picture copied from a web page can carry both its link and its file. The board lands the link, and uploads the file only when the link does not load.
240
+ - While a shape's text is being edited, the board leaves pasted and dropped files to the page. A file pasted into a note's text lands no shape, and `UploadPlugin` reports that it does not fit there.
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`.
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
+
191
293
  ## Manual usage
192
294
 
193
295
  <Steps>
@@ -234,7 +336,7 @@ const editor = createEditor({
234
336
  });
235
337
  ```
236
338
 
237
- For pictures, also install `ImagePlugin` and `BoardImagePlugin.configure({ component: BoardImageElement })`.
339
+ For pictures, also install `ImagePlugin` and `BoardImagePlugin.configure({ component: BoardImageElement })`. For [picture files](#picture-files), install `UploadPlugin` too.
238
340
 
239
341
  </Steps>
240
342
 
@@ -566,17 +668,21 @@ Every other peer joins the new room with the new plugins and schema, and without
566
668
  ## Limits
567
669
 
568
670
  - Find searches only the page, not the text of notes. Word export leaves out a comment on note text and reports a `comment-range` warning.
569
- - Over note text, the copied toolbars' mark, color, highlight and comment buttons and the AI menu act on the note, as [Toolbar](/docs/toolbar#act-on-the-view-that-holds-the-selection) describes. Other buttons, such as Insert, Turn into, lists and links, act on the page.
671
+ - With the caret in a note, the copied toolbars and the AI menu act on the note, as [Toolbar](/docs/toolbar#act-where-the-caret-is) describes. Insert and Turn into then disable the blocks a note cannot hold, such as tables, quotes and code blocks.
672
+ - Typing `/` or a space in an empty note paragraph inserts the character and opens no menu.
570
673
  - Moving a paragraph inside a note is refused. Moving the whole shape keeps its text.
571
674
  - Undo of a move puts back your old place, even over a teammate's later move of the same shape.
572
675
  - A long note gets slower, because a note's lines sync as one unit.
573
676
  - Each keystroke does some work for every board in the document, so keep a document to 100 boards or fewer.
574
677
  - Markdown keeps the text and pictures of the shapes in stored order and reports what it drops, such as places and arrow ends. Persist the Plate value, or HTML when the board holds only built-in shape types, to keep a board whole.
575
- - A picture file pasted or dropped on a board does not become an image shape. Paste the picture's link, or insert it from code.
678
+ - Without `UploadPlugin`, a picture file pasted or dropped on a board lands no shape, the board reports nothing, and the copied toolbar's Image button is disabled. Paste the picture's link, or insert it from code.
679
+ - A paste, drop or pick of more pictures than `UploadPlugin` takes in one batch lands none of them, and `onError` gets a `too-many-files` failure that holds the limit. The copied `UploadKit` takes three pictures in one batch.
680
+ - A pasted note keeps the note tool's 200 by 200 size, so long text runs past its bottom edge.
576
681
  - A shape property named after a style mark's key, such as `color`, `backgroundColor`, `fontSize` or `fontFamily`, also styles the shape's text while that mark's plugin is installed. Give the property another name, the way the note uses `fill`.
577
682
  - A board inside a note, rotation and cropping a picture are not supported, and the copied board draws no caption under a picture.
578
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.
579
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.
580
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.
581
687
 
582
688
  ## Plugins
@@ -591,7 +697,7 @@ The shape types: `boardNote`, `boardGeo`, `boardArrow`, `boardFrame` and `boardS
591
697
 
592
698
  ### `BoardImagePlugin`
593
699
 
594
- The image shape, `boardImage`: an object block that holds at most one `image` element or upload draft. Install `ImagePlugin` with it. An editor that installs it with neither `ImagePlugin` nor `UploadPlugin` throws an error naming both.
700
+ The image shape, `boardImage`: an object block that holds at most one `image` element or upload draft. Install `ImagePlugin` with it, and `UploadPlugin` too for [picture files](#picture-files). An editor that installs it with neither `ImagePlugin` nor `UploadPlugin` throws an error naming both.
595
701
 
596
702
  ## API Reference
597
703
 
@@ -607,9 +713,11 @@ The image shape, `boardImage`: an object block that holds at most one `image` el
607
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. |
608
714
  | `removeFrame(id)` | `BaseBoardPlugin` | Removes a frame and keeps its shapes where they are. |
609
715
  | `insertCopy(slice, { board, place? })` | `BaseBoardPlugin` | Pastes a copy of the shapes in `slice` into `board`, with fresh ids, and returns the copies' ids. |
610
- | `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. |
611
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. |
612
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. |
613
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`. |
614
- | `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`, and whether it can write as `writable`. A camera `zoom` of 1 is 100 percent. Call `setTool`, `setToolLocked`, `setStyle`, `fit`, `zoomIn`, `zoomOut`, `resetZoom`, `removeFrame` and `focus`. 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. |
615
- | `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. |
@@ -45,6 +45,43 @@ const editor = createEditor({
45
45
 
46
46
  </Steps>
47
47
 
48
+ ## Syntax colors
49
+
50
+ The code block components color highlighted tokens through CSS variables, so
51
+ one set of values styles the editor, the CodeMirror view and static output.
52
+ Installing `code-block` or `code-block-static` adds their light and dark values
53
+ to your stylesheet. Change them there:
54
+
55
+ ```css
56
+ :root {
57
+ --syntax-keyword: #d73a49;
58
+ --syntax-string: #032f62;
59
+ }
60
+
61
+ .dark {
62
+ --syntax-keyword: #ee6960;
63
+ --syntax-string: #3593ff;
64
+ }
65
+ ```
66
+
67
+ | Variable | Tokens |
68
+ | --- | --- |
69
+ | `--syntax-keyword` | Keywords, types, language names such as `this`, doc tags and template tags |
70
+ | `--syntax-constant` | Numbers, literals, attributes, operators, meta and variables |
71
+ | `--syntax-built-in` | Built-ins and symbols |
72
+ | `--syntax-string` | Strings and regular expressions |
73
+ | `--syntax-title` | Function and class names |
74
+ | `--syntax-tag` | Tag names, selectors and quotes |
75
+ | `--syntax-comment` | Comments and formulas |
76
+ | `--syntax-section` | Section headings |
77
+ | `--syntax-bullet` | List bullets |
78
+ | `--syntax-addition`, `--syntax-addition-background` | Added lines in a diff |
79
+ | `--syntax-deletion`, `--syntax-deletion-background` | Removed lines in a diff |
80
+
81
+ The Word export styles code with its own stylesheet in `docx-export.tsx`, which
82
+ never sees your app's variables, so it holds the light values as fixed colors.
83
+ Change those too when you change the light values.
84
+
48
85
  ## High-scale code blocks
49
86
 
50
87
  `CodeBlockKit` keeps code in native editor DOM. Use
@@ -105,6 +142,14 @@ CodeMirror search (`Mod+F`) finds offscreen code. Browser page Find can inspect
105
142
  only the mounted viewport DOM. The copy button and print layout use the full
106
143
  canonical code; printing temporarily renders every line.
107
144
 
145
+ The component binds CodeMirror's code keys. `Tab` and `Shift+Tab` indent the
146
+ selected lines. `Alt+Up` and `Alt+Down` move the current line, and
147
+ `Shift+Alt+Up` and `Shift+Alt+Down` copy it. `Mod+/` toggles a line comment in
148
+ the block's language. `Shift+Mod+\` moves the caret to the matching bracket,
149
+ and CodeMirror highlights the bracket pair beside the caret. A typed bracket or
150
+ quote inserts its closer, and `Backspace` between an empty pair deletes both.
151
+ The editor's history records each of these edits, so `Mod+Z` undoes it.
152
+
108
153
  ### Adapter customization
109
154
 
110
155
  `createCodeMirrorAdapter` from `platejs/code-block/codemirror` owns the
@@ -361,6 +406,8 @@ const editor = createEditor({
361
406
 
362
407
  Each `codeBlock` contains one text child. Newline characters define physical lines; editing and highlighting derive their line behavior from text offsets.
363
408
 
409
+ A code block stores a Markdown fence's language as `language` and the rest of its info string, such as `title="a.ts" {3-5}`, as `meta`. Markdown and HTML keep both. A fence writes `meta` only after a language, so Markdown export reports a `meta` without a `language` as `markdown-property-omitted`.
410
+
364
411
  Inside a code block no [input rule](/docs/plugin-input-rules#where-rules-run) runs, so `# `, `**x**`, `->` and URLs stay as typed. Neither Markdown nor an input rule converts pasted plain text.
365
412
 
366
413
  For plain code blocks, omit `CodeHighlightPlugin`:
@@ -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
 
@@ -98,7 +98,7 @@ Discussion groups unresolved records by block and sorts each block chronological
98
98
  - document undo reverses an accept or reject decision without changing messages or thread resolution;
99
99
  - resolving or reopening a thread stays outside document undo.
100
100
 
101
- `useSuggestionGroups(blockKey)` supplies each block's review cards. Under a preview they are the cards of the content the block shows, as [Suggestions](/docs/suggestion) describes. A card's body reads its changes a page at a time with `read.changes({ group: card.id })`. Discussion derives dates, labels, ranges, and card text in copied registry code, then joins change-targeted threads from Comments.
101
+ `useSuggestionGroups(blockKey)` supplies each block's review cards. Under a preview they are the cards of the content the block shows, as [Suggestions](/docs/suggestion) describes. A card's body reads the changes and parts it shows with `read.groupDetails(card.id, { limit })`, rereads them after each document change, and turns the parts into lines. Discussion derives dates, labels, ranges, and card text in copied registry code, then joins change-targeted threads from Comments.
102
102
 
103
103
  Review cards decide the card they show:
104
104
 
@@ -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.
package/dist/docs/docx.md CHANGED
@@ -67,7 +67,7 @@ A pasted Word picture lands as an image when its address is `http`, `https`, `bl
67
67
 
68
68
  Word paste leaves out hidden text, rows hidden in a table copied from Excel, comment markers and the comment list. It accepts tracked changes, so inserted text lands as plain text and deleted text is left out. It reads each Word equation into an equation node as DOCX import does, or into TeX text without the equation plugins, and leaves out an equation it cannot read. Each paste reports hidden text, comments, tracked changes and unread equations once each as a `lossy` diagnostic, which [`onPasteResult`](/docs/clipboard#paste-results) receives. When nothing else remains, the paste inserts nothing, and `onPasteResult` receives `inserted: false` with those reports. When Word left something out and the cleaned HTML has more elements or deeper nesting than the HTML parser allows, the paste also inserts nothing and reports that the content is too large or too deeply nested. A Word or Excel payload over 5 MiB, the HTML byte limit, skips Word paste and pastes as plain text.
69
69
 
70
- With an upload client configured, as [Pasted pictures](/docs/upload#pasted-pictures) shows, each Word picture that lands as a `data` address uploads like a dropped file. A picture with an `http`, `https` or `blob` address keeps that address. Clipboard paste does not preserve Word table geometry. Configure that destination policy in the table feature.
70
+ With an upload client configured, as [Pasted pictures](/docs/upload#pasted-pictures) shows, each Word picture that lands as a `data` address uploads like a dropped file, and so does one with a `blob` address once the paste reads its bytes. A picture with an `http` or `https` address keeps that address. Clipboard paste does not preserve Word table geometry. Configure that destination policy in the table feature.
71
71
 
72
72
  ## Import a DOCX file
73
73
 
@@ -48,6 +48,11 @@ chrome.
48
48
  Use that callback to open the accordion, activate the tab, or reveal the
49
49
  collapsed panel.
50
50
 
51
+ A block drag that rests for 800 ms on a block whose children sit behind an
52
+ `app-collapse` boundary also calls `onMaterialize`, with `reason: 'drag'`,
53
+ so the drop can land inside once the content mounts. A quick pass leaves the
54
+ content closed. Ignore that reason to keep the content closed during a drag.
55
+
51
56
  ## Copy policy
52
57
 
53
58
  `copyPolicy` controls clipboard output when a copied selection crosses hidden
@@ -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);
@@ -42,9 +42,8 @@ Render `{children}` after the non-editable UI. Plate still needs the hidden void
42
42
  child mounted even when your visible element is fully custom React.
43
43
 
44
44
  The nested editor is a separate Plate editor. It does not share the outer
45
- editor's value, selection, plugins, or undo history. Its own history is not
46
- reachable from the keyboard. Undo and Redo shortcuts pressed inside it run the
47
- outer editor's history, as
45
+ editor's value, selection, plugins, or undo history. Undo and Redo shortcuts
46
+ pressed inside it run its own history and leave the outer document unchanged, as
48
47
  [Embedded widgets](/docs/plugin-components#embedded-widgets) describes.
49
48
 
50
49
  Native controls and a nested editor need no extra marker. A widget built from
@@ -100,6 +100,8 @@ invalid, and read-only edits without changing the document.
100
100
  | `yieldKey(event)` | Offer a keydown the view declined to the editor's `onKeyDown`, which runs Plate's shortcuts and plugin key handlers. Call it from the view's own keydown listener, after every local handler passed on the key. Plate drops the key when something prevents its default or stops its propagation before the editor root. It refuses keys a text input uses natively: composing and modifier keys, typing, Enter without Ctrl or Meta, Tab, navigation and deletion keys, select-all, clipboard, undo and redo, and on Apple hosts Control with a letter, the quote key or Enter. It also refuses every key while the editor or the element is read-only, during an authored preview, or while any part of the selection is outside this Text. |
101
101
 
102
102
  Versioned actions return `{ status: "applied" | "stale" | "read-only" }`.
103
+ `dispatch` returns `stale` when the editor refuses the edit, such as one
104
+ Suggesting cannot record, and resets the view to `state.text` before it returns.
103
105
  An action may synchronously call `update` before returning, including a reset
104
106
  for rejected input. Adapters disable independent undo stacks and never dispatch
105
107
  actions, mutate the owning editor, or reenter their mounted view from `mount`,