platejs 54.0.0-beta.2 → 54.0.0-beta.3

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 (237) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DY104TqL.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-Deo6n6Fs.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-CJX5bKuv.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-DAOYWuvC.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-Dt-unJZY-DCddmbSD.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-ClHasORr.d.ts} +433 -95
  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 +4 -2
  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/dom.md +14 -4
  24. package/dist/docs/api/editor-transforms.md +2 -1
  25. package/dist/docs/api/react-hooks.md +25 -11
  26. package/dist/docs/authored-changes.md +5 -2
  27. package/dist/docs/basic-blocks.md +42 -29
  28. package/dist/docs/blockquote.md +5 -3
  29. package/dist/docs/board.md +63 -8
  30. package/dist/docs/code-block.md +47 -0
  31. package/dist/docs/discussion.md +1 -1
  32. package/dist/docs/docx.md +1 -1
  33. package/dist/docs/dom-coverage.md +5 -0
  34. package/dist/docs/examples/editable-voids.md +2 -3
  35. package/dist/docs/external-text.md +2 -0
  36. package/dist/docs/field.md +370 -0
  37. package/dist/docs/find.md +9 -6
  38. package/dist/docs/form.md +2 -0
  39. package/dist/docs/heading.md +6 -0
  40. package/dist/docs/installation/manual.md +0 -4
  41. package/dist/docs/link.md +3 -3
  42. package/dist/docs/llms.txt +4 -2
  43. package/dist/docs/markdown.md +176 -8
  44. package/dist/docs/plugin-components.md +13 -10
  45. package/dist/docs/plugin-input-rules.md +4 -12
  46. package/dist/docs/prompt-editor.md +205 -0
  47. package/dist/docs/roots.md +8 -6
  48. package/dist/docs/rtl.md +6 -4
  49. package/dist/docs/selection.md +7 -4
  50. package/dist/docs/suggestion.md +1 -1
  51. package/dist/docs/toolbar.md +26 -30
  52. package/dist/docs/upload.md +106 -17
  53. package/dist/docx/export/index.d.ts +3 -3
  54. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  55. package/dist/docx/export/lib/exportDocx.js +29 -5
  56. package/dist/docx/export/lib/reviewPart.js +1 -1
  57. package/dist/docx/export/lib/reviewProjection.js +10 -8
  58. package/dist/docx/import/index.d.ts +4 -4
  59. package/dist/docx/paste/index.d.ts +4 -4
  60. package/dist/dom/index.d.ts +1 -6
  61. package/dist/dom/plite-dom.internal.js +2 -2
  62. package/dist/excalidraw/index.d.ts +3 -2
  63. package/dist/excalidraw/react/index.d.ts +3 -2
  64. package/dist/facade.js +2 -2
  65. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  66. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  67. package/dist/features/board/index.d.ts +2 -2
  68. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  69. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  70. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  71. package/dist/features/callout/index.d.ts +3 -2
  72. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  73. package/dist/features/combobox/index.d.ts +2 -2
  74. package/dist/features/comments/index.d.ts +1 -1
  75. package/dist/features/date/index.d.ts +3 -2
  76. package/dist/features/details/index.d.ts +3 -2
  77. package/dist/features/details/lib/BaseDetailsPlugin.js +10 -10
  78. package/dist/features/field/index.d.ts +2 -0
  79. package/dist/features/field/index.js +2 -0
  80. package/dist/features/field/lib/BaseFieldPlugin.js +414 -0
  81. package/dist/features/field/lib/fieldRules.internal.js +42 -0
  82. package/dist/features/find/index.d.ts +3 -2
  83. package/dist/features/footnote/index.d.ts +1 -1
  84. package/dist/features/ink/index.d.ts +1 -1
  85. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  86. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  87. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  88. package/dist/features/ink/lib/inkPlaces.internal.js +533 -62
  89. package/dist/features/layout/index.d.ts +1 -1
  90. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  91. package/dist/features/lint/index.d.ts +3 -2
  92. package/dist/features/media/index.d.ts +1 -1
  93. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  94. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +6 -2
  95. package/dist/features/mention/index.d.ts +5 -4
  96. package/dist/features/suggestion/index.d.ts +1 -1
  97. package/dist/features/table/index.d.ts +1 -1
  98. package/dist/features/table/lib/BaseTablePlugin.js +14 -8
  99. package/dist/features/table/lib/internal/selection.js +4 -2
  100. package/dist/features/toc/index.d.ts +1 -1
  101. package/dist/features/upload/index.d.ts +2 -2
  102. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  103. package/dist/history/index.d.ts +2 -2
  104. package/dist/html/index.d.ts +3 -3
  105. package/dist/html/server/index.d.ts +1 -1
  106. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-cg_cWsaN.d.ts} +2 -31
  107. package/dist/hyperscript/index.d.ts +1 -1
  108. package/dist/{index-D1CFXA-i.d.ts → index-8WO2vI0U.d.ts} +475 -143
  109. package/dist/{index-DaM37gF6.d.ts → index-B5mYEawV.d.ts} +37 -21
  110. package/dist/{index-Bq3sdm3S.d.ts → index-BZWFoUXt.d.ts} +5 -4
  111. package/dist/{index-DdIRduDG.d.ts → index-C0POz7rg.d.ts} +3 -2
  112. package/dist/{index-Bxfvicyy.d.ts → index-C1_JIhL4.d.ts} +4 -3
  113. package/dist/{index-DC_MNGyu.d.ts → index-C35V_hj0.d.ts} +3 -3
  114. package/dist/{index-kLKMc-pI.d.ts → index-C6ql9pKw.d.ts} +2 -2
  115. package/dist/{index-hsC_sOn2.d.ts → index-C9DiGDVj.d.ts} +35 -5
  116. package/dist/{index-DTgaSxKr.d.ts → index-CLsEe3LY.d.ts} +40 -4
  117. package/dist/{index-CT7miqQN.d.ts → index-CdOLsPaW.d.ts} +29 -9
  118. package/dist/{index-DLA2DUR2.d.ts → index-CktYvOgk.d.ts} +4 -3
  119. package/dist/{index-BBKGrsG3.d.ts → index-Cmuluh6f.d.ts} +1 -1
  120. package/dist/{index-BiQerPJS.d.ts → index-CzLwBZpY.d.ts} +2 -2
  121. package/dist/{index-DzD6BIFJ.d.ts → index-D3-2iM1b.d.ts} +7 -5
  122. package/dist/{index-Cl77E9yr.d.ts → index-DKOFvteF.d.ts} +2 -2
  123. package/dist/{index-iaZOhA76.d.ts → index-DPWyk3lG-DOYwohXO.d.ts} +1 -1
  124. package/dist/index-DQnjqtQa.d.ts +678 -0
  125. package/dist/{index-CcZbqPqk.d.ts → index-Do9pj1GK.d.ts} +73 -39
  126. package/dist/{index-BU6k1Aev.d.ts → index-DpltOCot-A2b3p3Eb.d.ts} +4735 -4586
  127. package/dist/{index-Bc2Yg_2j.d.ts → index-HPYawTae-BCUQLEWF.d.ts} +2 -2
  128. package/dist/{index-BkR7-GLI.d.ts → index-baQOK89E.d.ts} +2 -2
  129. package/dist/{index-D5W-p9bS.d.ts → index-oIJAZxc2.d.ts} +49 -4
  130. package/dist/{index-xdmCBvlT.d.ts → index-r7yb77Wy.d.ts} +3 -2
  131. package/dist/index.d.ts +4 -4
  132. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  133. package/dist/internal/plugin/OverridePlugin.js +101 -119
  134. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  135. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  136. package/dist/internal/plugin/resolvePlugin.js +1 -1
  137. package/dist/internal/plugin/resolvePlugins.js +3 -0
  138. package/dist/internal/plugin/uploadDrafts.js +6 -0
  139. package/dist/internal/utils/mergePlugins.js +1 -0
  140. package/dist/lib/plugins/element-id/ElementIdPlugin.js +8 -2
  141. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  142. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  143. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +5 -15
  144. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  145. package/dist/markdown/index.d.ts +2 -2
  146. package/dist/markdown/index.js +2 -1
  147. package/dist/markdown/lib/MarkdownPlugin.js +16 -9
  148. package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
  149. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  150. package/dist/markdown/lib/internal/markdownConversion.js +773 -74
  151. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  152. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  153. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  154. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  155. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  156. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  157. package/dist/markdown/lib/internal/markdownRawHtml.js +314 -0
  158. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  159. package/dist/markdown/lib/internal/markdownTags.js +22 -8
  160. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  161. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  162. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  163. package/dist/math/index.d.ts +3 -2
  164. package/dist/math/react/index.d.ts +4 -3
  165. package/dist/migrations/index.d.ts +3 -3
  166. package/dist/pagination/index.d.ts +1 -1
  167. package/dist/pagination/react/index.d.ts +4 -4
  168. package/dist/react/components/EditorContentView.internal.js +17 -8
  169. package/dist/react/components/EditorProvider.js +5 -5
  170. package/dist/react/components/Plate.js +103 -122
  171. package/dist/react/components/PlateContainer.js +40 -32
  172. package/dist/react/components/PlateController.js +28 -16
  173. package/dist/react/components/PlateRoot.internal.js +3 -2
  174. package/dist/react/core.js +4 -4
  175. package/dist/react/features/board/BoardSurface.js +116 -87
  176. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  177. package/dist/react/features/board/boardGesture.internal.js +6 -3
  178. package/dist/react/features/board/boardIndex.internal.js +7 -18
  179. package/dist/react/features/board/boardPictures.internal.js +19 -13
  180. package/dist/react/features/board/boardView.internal.js +184 -49
  181. package/dist/react/features/board/boardVoice.internal.js +10 -11
  182. package/dist/react/features/board/index.d.ts +64 -18
  183. package/dist/react/features/callout/index.d.ts +3 -2
  184. package/dist/react/features/combobox/index.d.ts +8 -8
  185. package/dist/react/features/comments/index.d.ts +6 -5
  186. package/dist/react/features/date/index.d.ts +4 -3
  187. package/dist/react/features/details/index.d.ts +4 -3
  188. package/dist/react/features/field/FieldPlugin.js +34 -0
  189. package/dist/react/features/field/index.d.ts +312 -0
  190. package/dist/react/features/field/index.js +2 -0
  191. package/dist/react/features/footnote/index.d.ts +7 -6
  192. package/dist/react/features/format-painter/index.d.ts +4 -3
  193. package/dist/react/features/ink/InkContent.js +313 -0
  194. package/dist/react/features/ink/index.d.ts +57 -29
  195. package/dist/react/features/ink/index.js +2 -2
  196. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  197. package/dist/react/features/ink/inkInput.internal.js +1 -1
  198. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  199. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  200. package/dist/react/features/ink/inkPlacement.internal.js +331 -104
  201. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  202. package/dist/react/features/layout/index.d.ts +5 -4
  203. package/dist/react/features/media/index.d.ts +5 -4
  204. package/dist/react/features/mention/index.d.ts +6 -5
  205. package/dist/react/features/resizable/Resizable.js +4 -6
  206. package/dist/react/features/resizable/index.d.ts +5 -5
  207. package/dist/react/features/suggestion/index.d.ts +6 -5
  208. package/dist/react/features/table/TablePlugin.js +4 -11
  209. package/dist/react/features/table/index.d.ts +8 -7
  210. package/dist/react/features/toc/index.d.ts +2 -2
  211. package/dist/react/features/upload/index.d.ts +11 -6
  212. package/dist/react/index.d.ts +6 -6
  213. package/dist/react/index.js +4 -4
  214. package/dist/react/internal/plate-context.js +425 -188
  215. package/dist/react/plite-react.js +2 -2
  216. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  217. package/dist/react/stores/plate/useEditor.js +32 -14
  218. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  219. package/dist/react/stores/plate/useEditorSelector.js +66 -21
  220. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  221. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  222. package/dist/react/virtualized.d.ts +4 -4
  223. package/dist/{source-CNKy99Th.d.ts → source-aUwpNnAw.d.ts} +4 -4
  224. package/dist/static/index.d.ts +18 -18
  225. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  226. package/dist/static/internal/staticPresentation.js +4 -4
  227. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  228. package/dist/tabbable/index.d.ts +1 -1
  229. package/dist/tabbable/react/index.d.ts +3 -3
  230. package/dist/testing/index.d.ts +3 -3
  231. package/dist/yjs/index.d.ts +1 -1
  232. package/dist/yjs/react/index.d.ts +6 -6
  233. package/package.json +20 -2
  234. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  235. package/dist/react/components/EditorSelectionView.js +0 -40
  236. package/dist/react/features/ink/InkLayer.js +0 -218
  237. package/dist/react/internal/createPlateTargetScope.js +0 -62
@@ -30,8 +30,9 @@ if (result.ok) {
30
30
  showDiagnostics(result.diagnostics);
31
31
  ```
32
32
 
33
- `parse` returns one complete `EditorDocumentValue`, including roots and metadata
34
- that Markdown can represent. Use `parseSlice` for block insertion and
33
+ `parse` returns one complete `EditorDocumentValue`, including the roots that
34
+ mappings read and a leading [front matter](#front-matter) block in `meta`. Use
35
+ `parseSlice` for block insertion and
35
36
  `parseInline` for inline insertion. Both return a closed, rootless
36
37
  `ContentSlice`.
37
38
 
@@ -113,9 +114,11 @@ in a [table cell](#table-cells), warns under every policy.
113
114
  ## Syntax
114
115
 
115
116
  Plate reads and writes CommonMark plus the tags that installed feature plugins
116
- register. GFM, math, and emoji come from the [remark plugins](#remark-plugins)
117
- configured on `MarkdownPlugin`. Registered tags look like HTML, but only
118
- registered names are tags and nothing is evaluated.
117
+ register, after a leading [front matter](#front-matter) block. GFM, math,
118
+ emoji, and [CJK emphasis](#cjk-emphasis) come from the
119
+ [remark plugins](#remark-plugins) configured on `MarkdownPlugin`. Registered
120
+ tags look like HTML, but only registered names are tags and nothing is
121
+ evaluated.
119
122
 
120
123
  ### Registered tags
121
124
 
@@ -158,6 +161,9 @@ Due <date value="2025-01-01" />, ask [Jane](mention:user_123).
158
161
  `&quot;`, a newline as `&#10;`, and `|` as `&#124;`.
159
162
  - Footnote labels that CommonMark would merge, such as `A` and `a`, are written
160
163
  as distinct labels.
164
+ - A file without front matter whose opening lines would read back as a block,
165
+ such as two `---` rules written with `rule: '-'`, opens with a line ending so
166
+ it reads back as written.
161
167
 
162
168
  ### Reading rules
163
169
 
@@ -239,6 +245,106 @@ reads a `<block id="…">` wrapper around one block: with `ElementIdPlugin`
239
245
  installed, the block keeps that `id`; otherwise the wrapper is removed with a
240
246
  `markdown-unsupported-node` warning. Mappings cannot claim the `block` tag.
241
247
 
248
+ ### Front matter
249
+
250
+ `parse` reads one leading YAML or TOML block, as Obsidian, Jekyll, and Hugo
251
+ notes open with, into the document's metadata instead of a rule and a heading:
252
+
253
+ ```md
254
+ ---
255
+ title: Hello
256
+ tags: [a, b]
257
+ ---
258
+
259
+ # Body
260
+ ```
261
+
262
+ ```ts
263
+ import { getMarkdownFrontmatter } from 'platejs/markdown';
264
+
265
+ const result = editor.api.markdown.parse(source);
266
+
267
+ if (result.ok) {
268
+ getMarkdownFrontmatter(result.document);
269
+ // { format: 'yaml', value: 'title: Hello\ntags: [a, b]' }
270
+ }
271
+ ```
272
+
273
+ The block is stored at `meta['markdown.frontmatter']` as
274
+ `{ format: 'yaml' | 'toml', value: string }`, where `value` is the text between
275
+ the fences with LF line endings. `serialize` writes it first, then the body
276
+ right after the closing line. A note with no other content exports as the
277
+ block alone.
278
+
279
+ - The file opens with the fence, after at most one byte-order mark: `---` for
280
+ YAML or `+++` for TOML, with optional trailing spaces or tabs. A YAML block
281
+ closes on a `---` or `...` line, a TOML block on a `+++` line.
282
+ - The first line inside that is not blank or a `#` comment must be a setting,
283
+ such as `title: Hello` in YAML, or `title = 'Hello'` or `[params]` in TOML.
284
+ A note that opens with a rule and plain text keeps them.
285
+ - Two fence lines with nothing between are an empty block.
286
+ - An unclosed block, a JSON block, and a block whose text is not well-formed
287
+ Unicode read as CommonMark.
288
+ - Only `parse` reads front matter. `parseSlice`, `parseInline`, paste, and AI
289
+ streaming read the same lines as CommonMark.
290
+
291
+ Parse `value` with a parser for its format. Add a line ending to a non-empty
292
+ value first, because the last line of a YAML block scalar keeps its line break
293
+ only when one follows:
294
+
295
+ ```ts
296
+ import { parse as parseToml } from 'smol-toml';
297
+ import { parse as parseYaml } from 'yaml';
298
+
299
+ const frontmatter = getMarkdownFrontmatter(result.document);
300
+ const text = frontmatter?.value ? `${frontmatter.value}\n` : '';
301
+ const data = frontmatter?.format === 'toml' ? parseToml(text) : parseYaml(text);
302
+ ```
303
+
304
+ To change the block, change it on the copy of the document you pass to
305
+ `serialize`. Replacing a live editor's value with new `meta` resets its caret,
306
+ undo history, and local fields. Edit YAML with `yaml`'s `parseDocument` and
307
+ `set`, which keep the quoting the reader needs, and store the result minus
308
+ exactly one final line ending. Never trim it, because a `|+` block scalar keeps
309
+ its trailing line breaks:
310
+
311
+ ```ts
312
+ import { getMarkdownFrontmatter } from 'platejs/markdown';
313
+ import { parseDocument } from 'yaml';
314
+
315
+ const document = editor.read.value();
316
+ const frontmatter = getMarkdownFrontmatter(document);
317
+
318
+ if (frontmatter?.format === 'yaml') {
319
+ const yaml = parseDocument(frontmatter.value ? `${frontmatter.value}\n` : '');
320
+
321
+ yaml.set('draft', false);
322
+
323
+ const text = yaml.toString();
324
+ const value = text.endsWith('\n') ? text.slice(0, -1) : text;
325
+
326
+ const result = editor.api.markdown.serialize({
327
+ document: {
328
+ ...document,
329
+ meta: {
330
+ ...document.meta,
331
+ 'markdown.frontmatter': { format: 'yaml', value },
332
+ },
333
+ },
334
+ });
335
+ }
336
+ ```
337
+
338
+ A document replaced with only its `children` has no `meta`, so it loses the
339
+ block. In a collaborative editor, Yjs does not sync `meta`, so a peer that did
340
+ not import the file exports the note without its front matter.
341
+
342
+ Two rules around text read as front matter when the first line between them
343
+ that is not blank or a comment reads as a YAML setting. That includes a line of
344
+ text holding `: `, such as `_Note_: read this`, and a line that opens with `{`.
345
+ Export writes those lines back unchanged. A block of only blank lines or
346
+ comments reads as CommonMark.
347
+
242
348
  ## Streaming previews
243
349
 
244
350
  Parse each unfinished stream prefix with `partial: true` and the previous
@@ -269,6 +375,21 @@ nothing. A source with a link reference or footnote definition (`[id]: url`,
269
375
  `[^1]: note`) always parses whole, because a definition can change blocks
270
376
  before it.
271
377
 
378
+ A `partial` parse also shows bold, italic and strikethrough that have not
379
+ closed yet, so the preview of `Use **bold` shows `bold` in bold. It parses a
380
+ closed copy of the unfinished block, with the closers that block needs. The
381
+ copy goes through the same plugins and schema, and the preview shows it only
382
+ when it keeps every received character. Up to three trailing `*`, `_` or `~`
383
+ that could still open styling, or one trailing backslash, stay hidden until the
384
+ next character arrives. Markers that cannot open styling show as received, such
385
+ as the star in `2*3` and the underscore in `foo_bar`. The parse makes no closed
386
+ copy when the unfinished block holds more than 2,000 characters, or when the
387
+ source has a link reference or footnote definition or starts with a byte order
388
+ mark. Styling that opened more than 1,000 characters back gets no closer
389
+ either. Such a block shows its markers until they close. Code spans, links,
390
+ images, math and block syntax such as table rows show as received until they
391
+ finish, and so does styling inside link text or after an unclosed backtick.
392
+
272
393
  A `partial` parse converts only the text after the kept blocks. Each kept block
273
394
  came from a parse of its own part of the source, so a remark plugin that reads
274
395
  the whole tree, such as one that numbers or joins blocks, can make a preview
@@ -533,7 +654,8 @@ root that no mapping reads through `contentRoot` as
533
654
  ## Remark plugins
534
655
 
535
656
  Configure remark plugins once on `MarkdownPlugin`. Every parse and serialize
536
- operation of that editor uses them. `MarkdownKit` enables GFM, math, and emoji:
657
+ operation of that editor uses them. `MarkdownKit` enables GFM, math, emoji,
658
+ and CJK emphasis:
537
659
 
538
660
  _Registry item `markdown`: `npx shadcn@latest add @plate/markdown`._
539
661
 
@@ -552,7 +674,52 @@ const plugins = [
552
674
  Standalone functions read the configured `MarkdownPlugin` from `plugins`.
553
675
  Remark plugins must be synchronous. An attacher or transformer that returns a
554
676
  Promise is a configuration error and throws. The synchronous functions never
555
- return `Result | Promise<Result>`.
677
+ return `Result | Promise<Result>`. Remark plugins must also keep no state
678
+ between parses, because a `partial` parse runs them on the closed copy of an
679
+ unfinished block as well as on the received text. See
680
+ [Streaming previews](#streaming-previews).
681
+
682
+ ### remark-frontmatter
683
+
684
+ Files need no `remark-frontmatter` for their [front matter](#front-matter).
685
+ When the list still holds it, it reads every slice and every block Plate's
686
+ reader refuses. Unless a mapping decodes the `yaml` or `toml` node it makes,
687
+ that node is a lossy `markdown-unsupported-node`, which fails the parse under
688
+ 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.
691
+
692
+ ### CJK emphasis
693
+
694
+ CommonMark leaves `**` literal when punctuation ends the bold text and a letter
695
+ follows, so `这是**重点。**然后继续` stays plain text. `remark-cjk-friendly`
696
+ and `remark-cjk-friendly-gfm-strikethrough` read bold, strikethrough, and `*`
697
+ italic that end in Chinese, Japanese, or Korean punctuation as marks. They read
698
+ a source without CJK characters as CommonMark does. `MarkdownKit` installs
699
+ both. A custom plugin list adds them after `remarkGfm`:
700
+
701
+ ```ts
702
+ import { MarkdownPlugin } from 'platejs/markdown';
703
+ import remarkCjkFriendlyGfmStrikethrough from 'remark-cjk-friendly-gfm-strikethrough/bidi';
704
+ import remarkCjkFriendly from 'remark-cjk-friendly/bidi';
705
+ import remarkGfm from 'remark-gfm';
706
+
707
+ MarkdownPlugin.configure({
708
+ initialState: {
709
+ remarkPlugins: [
710
+ remarkGfm,
711
+ remarkCjkFriendly,
712
+ remarkCjkFriendlyGfmStrikethrough,
713
+ ],
714
+ },
715
+ });
716
+ ```
717
+
718
+ Serialize runs the same plugins, so it writes bold and strikethrough next to CJK
719
+ text with plain `**` and `~~`. That needs `mdast-util-to-markdown` 2.1.3 or
720
+ later. `_` keeps CommonMark's rule, and Plate writes italic with `_`, so it
721
+ writes italic next to CJK letters with character references, such as
722
+ `这&#x662F;_斜体。_&#x6587;字`.
556
723
 
557
724
  ## Results and diagnostics
558
725
 
@@ -580,7 +747,8 @@ reportWarnings(result.diagnostics);
580
747
  | `markdown-inline-blocks` | Error | `parseInline` input that produced blocks. |
581
748
  | `markdown-schema-repair` | Warning; error when lossy under `'reject'` | A schema repair applied to the parsed document. |
582
749
  | `markdown-schema-invalid` | Error | Parsed content the schema rejects. |
583
- | `markdown-unsupported-root`, `markdown-unsupported-metadata` | Warning | A named root that no mapping read through [`contentRoot`](#content-roots), or document metadata, omitted on export. |
750
+ | `markdown-unsupported-root`, `markdown-unsupported-metadata` | Warning | A named root that no mapping read through [`contentRoot`](#content-roots), or document metadata other than [front matter](#front-matter), omitted on export. |
751
+ | `markdown-frontmatter-omitted` | Lossy: error under `'reject'`, warning under `'allow'` | Stored [front matter](#front-matter) that export cannot write back. Its `reason` is `shape` for a value that is not `{ format, value }` strings, `format` for a format other than `yaml` or `toml`, or `unreadable` for a value that holds a CR, is not well-formed Unicode, or would not read back the same. Under the default policy the export fails; `lossPolicy: 'allow'` exports the file without the block. |
584
752
 
585
753
  Authored projection diagnostics use the same result. Configuration failures and
586
754
  mapping contract violations throw.
@@ -188,15 +188,18 @@ still selects the node. The [Excalidraw](/docs/excalidraw) element is
188
188
  a complete example.
189
189
 
190
190
  <Callout type="info" title="Keys the editor still takes">
191
- Outside an IME composition, the editor takes Undo and Redo shortcuts before
192
- the widget's own key handlers run, in a marked widget, a native control, or a
193
- nested editor alike. An editable editor runs its own history for them, even
194
- when it has nothing to undo. A read-only editor only stops them, so a native
195
- text field still applies the browser's own undo. The editor also takes
196
- Shift+Arrow keys from a nested editor, and from any widget while its own
197
- selection is in another root. While it holds a selection it draws itself,
198
- such as one that spans roots, it also takes Backspace, Delete, and Enter from
199
- any widget, unless Alt, Ctrl, or Meta is held.
191
+ Outside an IME composition, a widget gets the Undo and Redo keys first. A
192
+ widget that stops the key or prevents its default keeps it, and a native text
193
+ field applies the browser's own undo. Otherwise an editable editor runs its
194
+ own history, even when it has nothing to undo. A read-only editor only stops
195
+ the key. An independent nested editor, such as the inner editor of
196
+ [Editable Voids](/docs/examples/editable-voids), runs its own history. The
197
+ editor takes Undo and Redo before a nested editor's key handlers run only
198
+ when that nested editor shows another root of the same editor. The editor
199
+ also takes Shift+Arrow keys from a nested editor, and from any widget while
200
+ its own selection is in another root. While it holds a selection it draws
201
+ itself, such as one that spans roots, it also takes Backspace, Delete, and
202
+ Enter from any widget, unless Alt, Ctrl, or Meta is held.
200
203
  </Callout>
201
204
 
202
205
  ## Styling
@@ -227,7 +230,7 @@ replace from the registry.
227
230
  | `EditorLeaf` | Marked and decorated text. | Defaults to `span`; use with plugins that declare `schema.mark`. |
228
231
  | `plugin.configure({ component: Component })` | Ordinary node component binding. | Include the component and every consumer override in the same terminal call. |
229
232
  | `plugin.configure({ component: 'tag' })` | Default wrapper with an intrinsic tag. | Accepts an HTML tag such as `'blockquote'`, `'strong'`, or `'code'`. |
230
- | `data-editor-root-chrome-ignore="true"` | A wrapper around a widget that owns its input. | Pair with `contentEditable={false}`; Undo and Redo shortcuts still reach the editor. |
233
+ | `data-editor-root-chrome-ignore="true"` | A wrapper around a widget that owns its input. | Pair with `contentEditable={false}`; Undo and Redo reach the editor unless the widget stops them. |
231
234
 
232
235
  For plugin method details, see [Plugin Methods](/docs/plugin-methods). For static
233
236
  rendering components, see [Static Rendering](/docs/static).
@@ -133,21 +133,13 @@ plugin's `inputRules`.
133
133
 
134
134
  Basic block rules ship with `platejs`. Register them per plugin.
135
135
 
136
- **Headings.** `HeadingRules.markdown()` is the same factory for H1 through H6.
137
- It reads the heading depth from a resolved persisted type matching `h1` through
138
- `h6`, so you pass it once on each heading plugin. If an application remaps a
139
- heading to a different type, provide an app-owned rule for that type instead.
136
+ **Headings.** `HeadingRules.markdown()` is one rule for every heading level. It
137
+ counts the `#` characters typed before the space, `# ` through `###### `, and
138
+ gives the heading that `level`. Pass it once, on `HeadingPlugin`.
140
139
 
141
140
  ```tsx showLineNumbers
142
141
  import { HeadingRules } from 'platejs';
143
- import {
144
- HeadingPlugin,
145
-
146
-
147
-
148
-
149
-
150
- } from 'platejs/react';
142
+ import { HeadingPlugin } from 'platejs/react';
151
143
 
152
144
  export const HeadingInputRulesKit = [
153
145
  HeadingPlugin.configure({ inputRules: [HeadingRules.markdown()] }),
@@ -0,0 +1,205 @@
1
+ # Prompt Editor
2
+
3
+ A chat message field that holds @ chips and sends on Enter.
4
+
5
+ _Registry item `prompt-editor-demo`: `npx shadcn@latest add @plate/prompt-editor-demo`._
6
+
7
+ `PromptEditor` is the message field of a chat form, in place of a text area. Typing @ opens a menu of the app's `items`, and a picked item becomes a chip. Enter presses the form's Send button. The message is a string, the typed text with each chip written as a `<mention>` tag.
8
+
9
+ ## Installation
10
+
11
+ _Registry item `prompt-editor`: `npx shadcn@latest add @plate/prompt-editor`._
12
+
13
+ The registry item adds `prompt-editor.tsx` and the `mention` and `inline-combobox` items it imports.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ 'use client';
19
+
20
+ import * as React from 'react';
21
+
22
+ import { ArrowUpIcon } from 'lucide-react';
23
+
24
+ import { PromptEditor } from '@/components/editor/prompt-editor';
25
+ import {
26
+ InputGroup,
27
+ InputGroupAddon,
28
+ InputGroupButton,
29
+ } from '@/components/ui/input-group';
30
+
31
+ const items = [
32
+ { label: 'Spec', ref: 'docs/spec.md' },
33
+ { label: 'Changelog', ref: 'docs/changelog.md' },
34
+ ];
35
+
36
+ export function ChatForm({ onSend }: { onSend: (message: string) => void }) {
37
+ const [message, setMessage] = React.useState('');
38
+
39
+ return (
40
+ <form
41
+ onSubmit={(event) => {
42
+ event.preventDefault();
43
+ onSend(message);
44
+ setMessage('');
45
+ }}
46
+ >
47
+ <InputGroup>
48
+ <PromptEditor
49
+ items={items}
50
+ placeholder="Ask anything..."
51
+ value={message}
52
+ onChange={setMessage}
53
+ />
54
+ <InputGroupAddon align="block-end">
55
+ <InputGroupButton
56
+ aria-label="Send"
57
+ className="ml-auto rounded-full"
58
+ disabled={!message.trim()}
59
+ size="icon-sm"
60
+ type="submit"
61
+ variant="default"
62
+ >
63
+ <ArrowUpIcon />
64
+ </InputGroupButton>
65
+ </InputGroupAddon>
66
+ </InputGroup>
67
+ </form>
68
+ );
69
+ }
70
+ ```
71
+
72
+ Enter presses the form's first submit button, so the form sends from `onSubmit` as it does for a text area. Enter does nothing while that button is disabled, so disable it while the message is empty or a reply streams.
73
+
74
+ `InputGroup` keeps the height of one line until it holds a block addon. Without one, give it `className="h-auto"` so it grows with the field.
75
+
76
+ ## Examples
77
+
78
+ ### AI SDK chat
79
+
80
+ The demo sends the message and its attached files through the AI SDK's `useChat`, with a local transport that streams a fixed reply instead of calling a model. Pasted and dropped files go to `onFiles`, and removing one moves focus back to the field through its `ref`.
81
+
82
+ _Registry item `prompt-editor-demo`: `npx shadcn@latest add @plate/prompt-editor-demo`._
83
+
84
+ ### AI Elements
85
+
86
+ AI Elements' `PromptInput` reads the message from the form's data under `message`, the name its own text area uses. Give the field that `name` and put it where `PromptInputTextarea` goes:
87
+
88
+ ```tsx
89
+ import {
90
+ PromptInput,
91
+ PromptInputBody,
92
+ PromptInputFooter,
93
+ PromptInputSubmit,
94
+ PromptInputTools,
95
+ } from '@/components/ai-elements/prompt-input';
96
+ import { PromptEditor } from '@/components/editor/prompt-editor';
97
+
98
+ <PromptInput onSubmit={({ text }) => sendMessage({ text })}>
99
+ <PromptInputBody>
100
+ <PromptEditor items={items} name="message" placeholder="Ask anything..." />
101
+ </PromptInputBody>
102
+ <PromptInputFooter>
103
+ <PromptInputTools />
104
+ <PromptInputSubmit status={status} />
105
+ </PromptInputFooter>
106
+ </PromptInput>;
107
+ ```
108
+
109
+ `PromptInput` attaches the files dropped on its form itself. For pasted files, pass `add` from `usePromptInputAttachments()` as `onFiles`, in a component inside `PromptInput`.
110
+
111
+ ### AI Elements with its provider
112
+
113
+ Under `PromptInputProvider`, `PromptInput` reads the message from the provider instead of the form's data. Connect the field through `value` and `onChange`:
114
+
115
+ ```tsx
116
+ import {
117
+ PromptInput,
118
+ PromptInputBody,
119
+ PromptInputProvider,
120
+ usePromptInputController,
121
+ } from '@/components/ai-elements/prompt-input';
122
+ import { PromptEditor } from '@/components/editor/prompt-editor';
123
+
124
+ function MessageField() {
125
+ const { textInput } = usePromptInputController();
126
+
127
+ return (
128
+ <PromptEditor
129
+ items={items}
130
+ value={textInput.value}
131
+ onChange={textInput.setInput}
132
+ />
133
+ );
134
+ }
135
+
136
+ <PromptInputProvider>
137
+ <PromptInput onSubmit={({ text }) => sendMessage({ text })}>
138
+ <PromptInputBody>
139
+ <MessageField />
140
+ </PromptInputBody>
141
+ </PromptInput>
142
+ </PromptInputProvider>;
143
+ ```
144
+
145
+ ## Message
146
+
147
+ The message holds one line per paragraph, joined with `\n`. A chip is `<mention ref="docs/spec.md">Spec</mention>`. Its `ref` and label escape `&`, `<` and `>`, and its `ref` also escapes `"`. The rest of the text is what the user typed. The app's server reads each `ref` and gives the model what the chip points to.
148
+
149
+ A `value` sets the same shape back: each tag becomes a chip, and each `\n` starts a paragraph.
150
+
151
+ ## Behavior
152
+
153
+ - Enter, and Ctrl, Cmd or Alt with Enter, press the form's first submit button. Enter outside a form or while that button is disabled sends nothing and keeps the draft.
154
+ - Shift+Enter breaks the line.
155
+ - Enter while an input method composes sends nothing.
156
+ - With the @ menu showing a match, Enter and Tab pick it. When the menu finds nothing, Enter sends the typed text.
157
+ - Without `items`, a typed @ stays text.
158
+ - A pasted or dropped file goes to `onFiles` and never into the text. A disabled field passes no file on.
159
+ - A paste keeps plain lines and chips only. A pasted chip stays a chip when `items` holds its `ref` and label, and becomes its label as text otherwise.
160
+ - A form reset that no listener cancels clears the field.
161
+ - A `value` other than the last message the field reported replaces the text and puts the caret at the end. A change the app turns down, such as one past a length limit, puts the app's `value` back, as a controlled text area does.
162
+
163
+ Edit `PromptEditorPlugin` in the copied `prompt-editor.tsx` to change these rules.
164
+
165
+ ## Limits
166
+
167
+ - The field fires no `input` event while the user types, so a form `onInput` listener never runs for it. Read changes through `onChange`.
168
+ - A class that changes the field's minimum height needs `!`, such as `min-h-24!`, because the editable sets an inline minimum height while the placeholder shows.
169
+ - AI Elements clears the field whenever it clears its own text area. That includes a send the app refuses without the provider and a failed send with it.
170
+
171
+ ## API Reference
172
+
173
+ ### PromptEditor
174
+
175
+ <API name="PromptEditor">
176
+ <APIProps>
177
+ <APIItem name="items" type="readonly { label: string; ref: string }[]" optional>
178
+ What the @ menu offers. The menu matches the start of any word in a label, or the start of a `ref`.
179
+ </APIItem>
180
+ <APIItem name="name" type="string" optional>
181
+ The key the message takes in the form's `FormData`.
182
+ </APIItem>
183
+ <APIItem name="value" type="string" optional>
184
+ The message of a controlled field.
185
+ </APIItem>
186
+ <APIItem name="onChange" type="(message: string) => void" optional>
187
+ Called with the message after each change, and before Enter sends.
188
+ </APIItem>
189
+ <APIItem name="onFiles" type="(files: File[]) => void" optional>
190
+ Called with the files of a paste or a drop.
191
+ </APIItem>
192
+ <APIItem name="placeholder" type="string" optional>
193
+ The text shown while the field is empty.
194
+ </APIItem>
195
+ <APIItem name="disabled" type="boolean" optional>
196
+ Turns off editing and file handling.
197
+ </APIItem>
198
+ <APIItem name="className" type="string" optional>
199
+ Classes for the editable.
200
+ </APIItem>
201
+ <APIItem name="ref" type="React.Ref<{ focus: () => void }>" optional>
202
+ Gives the app `focus()`.
203
+ </APIItem>
204
+ </APIProps>
205
+ </API>
@@ -277,12 +277,14 @@ const SyncedBlock = ({ attributes, element, slots }) => (
277
277
  A root whose blocks are selected as whole objects, such as a board's shapes,
278
278
  can give focus to an element of its own instead of its editable. Pass
279
279
  `nodeSelectionFocus`, a ref to that element. That element takes focus when the
280
- editor moves focus into the root, as after an undo, while there is no selection
281
- or a node selection holds only the root's top-level blocks. It does not take
282
- focus while the editor shows a caret or a text selection, or on a call to
283
- `editor.api.dom.focus()`, which focuses the root's editable. Unless the element
284
- is a control, such as a button, the editor reads no keys from it, so it must
285
- handle the keys it needs, such as undo and redo through the `onKeyDown` of
280
+ editor moves focus into the root, as after an undo or on a call to
281
+ `editor.api.dom.focus()`, while there is no selection or a node selection holds
282
+ only the root's top-level blocks. It does not take focus while the editor shows
283
+ a caret or a text selection, and a click that selects an object in the root
284
+ focuses the editable. Keep the element mounted across renders. When the render
285
+ that follows a focus call replaces it, focus falls to the page. Unless the
286
+ element is a control, such as a button, the editor reads no keys from it, so it
287
+ must handle the keys it needs, such as undo and redo through the `onKeyDown` of
286
288
  `useEditorHistory`.
287
289
 
288
290
  ```tsx
package/dist/docs/rtl.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Right-to-left
2
2
 
3
- Edit Hebrew, Arabic and other right-to-left documents.
3
+ Edit Arabic, Hebrew and other right-to-left documents.
4
4
 
5
5
  _Example `rtl-demo` in the Plate repository: `apps/www/src/registry/examples/rtl-demo.tsx`, `apps/www/src/registry/examples/values/rtl-value.tsx`._
6
6
 
7
- Plate lays out each block by its own text. A Hebrew or Arabic paragraph starts at the right, an English paragraph in the same document starts at the left, and the editor UI mirrors with the page.
7
+ Plate lays out each block by its own text. An Arabic or Hebrew paragraph starts at the right, an English paragraph in the same document starts at the left, and the editor UI mirrors with the page.
8
8
 
9
9
  ## Setup
10
10
 
@@ -23,7 +23,7 @@ export default function RootLayout({
23
23
  children: React.ReactNode;
24
24
  }) {
25
25
  return (
26
- <html lang="he" dir="rtl">
26
+ <html lang="ar" dir="rtl">
27
27
  <body>
28
28
  <DirectionProvider direction="rtl">{children}</DirectionProvider>
29
29
  </body>
@@ -32,11 +32,13 @@ export default function RootLayout({
32
32
  }
33
33
  ```
34
34
 
35
+ In a Radix style, pass `dir="rtl"` instead, because Radix's types require it.
36
+
35
37
  Plate's editor UI uses start and end classes, so it needs no `rtl` setting in `components.json` and works the same with one. shadcn's [RTL guide](https://ui.shadcn.com/docs/rtl) covers fonts and the rest of your app.
36
38
 
37
39
  ## Text direction
38
40
 
39
- Each text block, such as a paragraph, heading or list item, takes its direction from its first Hebrew, Arabic or Latin letter. A block without one, such as an empty line or a line of digits, follows the editor. Typing a first letter in the other script flips the block.
41
+ Each text block, such as a paragraph, heading or list item, takes its direction from its first Arabic, Hebrew or Latin letter. A block without one, such as an empty line or a line of digits, follows the editor. Typing a first letter in the other script flips the block.
40
42
 
41
43
  Arrow keys follow the block's direction, so in a right-to-left block ArrowLeft moves forward through the text.
42
44
 
@@ -85,8 +85,9 @@ model updates back to the DOM. Application code should not patch
85
85
  _Example `inactive-selection-demo` in the Plate repository: `apps/www/src/registry/examples/inactive-selection-demo.tsx`._
86
86
 
87
87
  Plate `EditorContent` renders an inactive selection when focus moves to a marked
88
- control. The behavior is built in; it does not require a prop, plugin, kit, or
89
- copied selection state.
88
+ control, or when a click on a marked control takes focus from the editor
89
+ without focusing the control, as Safari on Mac does for buttons. The behavior is
90
+ built in; it does not require a prop, plugin, kit, or copied selection state.
90
91
 
91
92
  ### Mark a focus target
92
93
 
@@ -102,7 +103,8 @@ ancestor:
102
103
  The exact `EditorContent` that loses focus reads its live canonical selection. An
103
104
  expanded range renders a highlight. A collapsed range renders a caret. Focus
104
105
  returning to the editor or moving to an unmarked target removes the inactive
105
- paint.
106
+ paint. A click outside a marked control removes it too, unless the click lands
107
+ on a non-editable part of an editor, such as a void's controls.
106
108
 
107
109
  This marker only keeps the selection painted while focus is elsewhere. To let a
108
110
  widget inside a node handle its own input, use the
@@ -131,9 +133,10 @@ The copied `Editor` registry component already styles both hooks.
131
133
  | Focus target | Inactive paint |
132
134
  | --- | --- |
133
135
  | Marked control or composed ancestor | One highlight or caret from the originating `EditorContent` |
136
+ | Nothing, after a click on a marked control | One highlight or caret from the originating `EditorContent` |
134
137
  | The editor | None; the browser owns the active selection |
135
138
  | Any unmarked control | None |
136
- | Window blur or missing focus target | None |
139
+ | Window blur, or nothing after any other click | None |
137
140
 
138
141
  The marker controls presentation only. It does not modify the document,
139
142
  selection, history, clipboard, or collaboration state.
@@ -164,7 +164,7 @@ const { activeId, setActiveId } = useActiveSuggestion();
164
164
 
165
165
  `useSuggestionChanges(path)` returns the native `AuthoredChange` records of the block at that path of the mounted view. A nested block's path returns its own changes and those of a container around it that the preview takes away. It never returns the pending wrap or unwrap of a container the view still shows, which that container's own path returns. It rereads on each commit that changes the document or its state and when the review delta names the path's top-level block, and keeps its result stable while those records are unchanged. A change's `ranges` stay places of the stored document on every view.
166
166
 
167
- `useSuggestionGroups(blockKey)` returns the review cards of the block with that key, as `read.groups` summaries. A nested block's key reads that block's own cards. It rereads when the component that calls it renders and when the review delta names the block, which happens when a change reaches or leaves that block or one of its changes moves to another card. A delta names top-level blocks only, so for a nested block's key it rereads only when that component renders. An edit to the same card in another block does neither, so a summary's `changeCount` or `revision` can trail; read `editor.plugin(AuthoredPlugin).read.groupOf(card.id)` when a control needs the current one. Read a card's changes a page at a time with `read.changes({ group: card.id })`.
167
+ `useSuggestionGroups(blockKey)` returns the review cards of the block with that key, as `read.groups` summaries. A nested block's key reads that block's own cards. It rereads when the component that calls it renders and when the review delta names the block, which happens when a change reaches or leaves that block or one of its changes moves to another card. A delta names top-level blocks only, so for a nested block's key it rereads only when that component renders. An edit to the same card in another block does neither, so a summary's `changeCount` or `revision` can trail; read `editor.plugin(AuthoredPlugin).read.groupOf(card.id)` when a control needs the current one. Read a card's changes a page at a time with `read.changes({ group: card.id })`, or the changes and parts a review card shows with `read.groupDetails(card.id, { limit })`.
168
168
 
169
169
  In the current view, clicking a marked element activates the first card its `data-editor-authored-groups` attribute names. Clicking unmarked editor content clears it. In Safari with an input method such as WeType, a tap gets no click of its own, so its press activates or clears instead. A drag clears the active card when the card under the pointer changes from the one where the drag started, or when the pointer leaves the editor. Unmounting the view, switching it to another intent or preview, or deciding the card also clears stale active state. Use `setActiveId` when a custom card or control needs to activate a card directly.
170
170