platejs 54.0.0-beta.7 → 54.0.0-beta.8

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 (218) hide show
  1. package/dist/{AIChatRequestContext-DVGOeWhQ.d.ts → AIChatRequestContext-PbXTTovP.d.ts} +4 -2
  2. package/dist/{BaseSuggestionPlugin-BRFMMyEo.d.ts → BaseSuggestionPlugin-Dg-cdX26.d.ts} +10 -4
  3. package/dist/{PlateStatic-DIwBAVqF.d.ts → PlateStatic-CggiBCuD.d.ts} +3 -3
  4. package/dist/ai/index.d.ts +40 -2
  5. package/dist/ai/index.js +2 -1
  6. package/dist/ai/lib/lockedContext.internal.js +105 -0
  7. package/dist/ai/lib/lockedContext.js +179 -0
  8. package/dist/ai/react/AIChatPlugin.js +498 -103
  9. package/dist/ai/react/CopilotPlugin.js +37 -6
  10. package/dist/ai/react/aiOutputLanding.internal.js +19 -4
  11. package/dist/ai/react/index.d.ts +42 -9
  12. package/dist/authored/index.d.ts +4 -4
  13. package/dist/authored/index.js +2 -2
  14. package/dist/code-block/codemirror/index.d.ts +1 -1
  15. package/dist/{combobox-CfCJYKT0.d.ts → combobox-CUUSZR07.d.ts} +2 -2
  16. package/dist/compiler/index.d.ts +2 -2
  17. package/dist/{core-Cqc_KzpG.d.ts → core-D8i_gkA6.d.ts} +173 -106
  18. package/dist/diff/index.d.ts +3 -30
  19. package/dist/docs/api/core/plate-plugin.md +10 -9
  20. package/dist/docs/api/core.md +10 -5
  21. package/dist/docs/api/document-change.md +17 -10
  22. package/dist/docs/api/react-hooks.md +11 -5
  23. package/dist/docs/authored-changes.md +9 -6
  24. package/dist/docs/board.md +5 -4
  25. package/dist/docs/bold.md +0 -2
  26. package/dist/docs/document-model.md +3 -3
  27. package/dist/docs/docx.md +44 -0
  28. package/dist/docs/editor-methods.md +3 -3
  29. package/dist/docs/examples/version-history.md +1 -1
  30. package/dist/docs/footnote.md +80 -28
  31. package/dist/docs/html.md +10 -5
  32. package/dist/docs/indent.md +7 -5
  33. package/dist/docs/ink.md +18 -20
  34. package/dist/docs/installation/node.md +1 -1
  35. package/dist/docs/list.md +23 -3
  36. package/dist/docs/llms.txt +4 -3
  37. package/dist/docs/lock.md +264 -0
  38. package/dist/docs/markdown.md +13 -96
  39. package/dist/docs/plugin-context.md +14 -10
  40. package/dist/docs/serializing.md +26 -3
  41. package/dist/docs/static.md +19 -5
  42. package/dist/docx/export/index.d.ts +3 -3
  43. package/dist/docx/export/lib/exportDocx.js +58 -12
  44. package/dist/docx/import/index.d.ts +4 -4
  45. package/dist/docx/paste/index.d.ts +4 -4
  46. package/dist/dom/index.d.ts +1 -1
  47. package/dist/excalidraw/index.d.ts +3 -3
  48. package/dist/excalidraw/react/index.d.ts +3 -3
  49. package/dist/facade.js +2 -2
  50. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +1 -1
  51. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +27 -6
  52. package/dist/features/basic-nodes/lib/BaseMarkPlugins.js +64 -12
  53. package/dist/features/board/index.d.ts +1 -1
  54. package/dist/features/board/lib/boardTypes.internal.js +3 -0
  55. package/dist/features/callout/index.d.ts +3 -3
  56. package/dist/features/callout/lib/BaseCalloutPlugin.js +1 -4
  57. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +1 -2
  58. package/dist/features/combobox/index.d.ts +2 -2
  59. package/dist/features/combobox/lib/filterWords.js +7 -11
  60. package/dist/features/comments/index.d.ts +1 -1
  61. package/dist/features/date/index.d.ts +3 -3
  62. package/dist/features/details/index.d.ts +4 -3
  63. package/dist/features/details/lib/BaseDetailsPlugin.js +228 -122
  64. package/dist/features/field/index.d.ts +1 -1
  65. package/dist/features/field/lib/BaseFieldPlugin.js +18 -2
  66. package/dist/features/find/index.d.ts +3 -3
  67. package/dist/features/footnote/index.d.ts +1 -1
  68. package/dist/features/footnote/lib/BaseFootnotePlugin.js +9 -2
  69. package/dist/features/ink/index.d.ts +2 -2
  70. package/dist/features/ink/lib/BaseInkPlugin.js +118 -82
  71. package/dist/features/ink/lib/inkMatch.internal.js +79 -78
  72. package/dist/features/ink/lib/inkPlaces.internal.js +166 -535
  73. package/dist/features/layout/index.d.ts +1 -1
  74. package/dist/features/layout/lib/BaseColumnPlugin.js +37 -14
  75. package/dist/features/link/lib/BaseLinkPlugin.js +38 -3
  76. package/dist/features/lint/index.d.ts +3 -3
  77. package/dist/features/list/lib/BaseListPlugin.js +30 -11
  78. package/dist/features/list/lib/listFamily.internal.js +2 -2
  79. package/dist/features/list/lib/listHtml.internal.js +1 -0
  80. package/dist/features/lock/index.d.ts +2 -0
  81. package/dist/features/lock/index.js +2 -0
  82. package/dist/features/lock/lib/BaseLockPlugin.js +526 -0
  83. package/dist/features/media/index.d.ts +1 -1
  84. package/dist/features/mention/index.d.ts +5 -5
  85. package/dist/features/suggestion/index.d.ts +1 -1
  86. package/dist/features/table/index.d.ts +1 -1
  87. package/dist/features/toc/index.d.ts +1 -1
  88. package/dist/features/upload/index.d.ts +1 -1
  89. package/dist/features/upload/lib/BaseUploadPlugin.js +5 -4
  90. package/dist/history/index.d.ts +2 -2
  91. package/dist/html/index.d.ts +3 -3
  92. package/dist/html/server/index.d.ts +1 -1
  93. package/dist/html/server/index.js +2 -1
  94. package/dist/html/server/serverCssParser.internal.js +500 -0
  95. package/dist/html/server/serverCssStyle.internal.js +208 -0
  96. package/dist/{htmlTypes-i_FBCMf2.d.ts → htmlTypes-zTLU3aTb.d.ts} +9 -13
  97. package/dist/hyperscript/index.d.ts +1 -1
  98. package/dist/index-0YxPsHwd.d.ts +1 -0
  99. package/dist/{index-Bv13FX9o.d.ts → index-3CExu_fj.d.ts} +3 -3
  100. package/dist/{index-CTTjpWgb-Fdrn8NP4.d.ts → index-4PpawhYe-yelJvgk1.d.ts} +1 -1
  101. package/dist/{index-B4ZhSQdk.d.ts → index-BCYBYfGM.d.ts} +3 -3
  102. package/dist/{index-CJGkjkH6.d.ts → index-BODDOPEd.d.ts} +1 -1
  103. package/dist/{index-DNXr_SN-.d.ts → index-BPOa4Z5n.d.ts} +9 -3
  104. package/dist/{index-Cc2ajXAd.d.ts → index-BSBkt2bm.d.ts} +44 -48
  105. package/dist/{index-CLNem74G.d.ts → index-BeyI3RUg.d.ts} +42 -39
  106. package/dist/{index-CmISVYmz.d.ts → index-BisOdLXI.d.ts} +14 -49
  107. package/dist/{index-CVAHIQ3p.d.ts → index-Bt5YI_JN.d.ts} +4 -4
  108. package/dist/{index-CrJ9Km8W.d.ts → index-CD_Ym9WQ.d.ts} +2 -2
  109. package/dist/{index-KteL56rA.d.ts → index-CX_JaDRY.d.ts} +4 -3
  110. package/dist/{index-BI0NS7kx.d.ts → index-CfK4uv4I.d.ts} +3 -3
  111. package/dist/{index-By7BkzIN.d.ts → index-CfRUKYCM.d.ts} +2 -2
  112. package/dist/{index-OMa7dlcS.d.ts → index-Cil7kghY.d.ts} +5 -5
  113. package/dist/index-D11C0iLb.d.ts +97 -0
  114. package/dist/{index-CS4G_W_R.d.ts → index-DJW6AjJ6.d.ts} +1 -1
  115. package/dist/{comparison-types-CsmDG5r2-z1s4gX06.d.ts → index-DM-b6jEe-BqkdOlav.d.ts} +19 -57
  116. package/dist/{index-1PlYsibA.d.ts → index-DoZhM7nD.d.ts} +3 -3
  117. package/dist/{index-DfkFmApH.d.ts → index-DsNwo8dd.d.ts} +35 -14
  118. package/dist/{index-CxG1Atvg.d.ts → index-DuElD_q6.d.ts} +3 -3
  119. package/dist/{index-BWCC4DCP.d.ts → index-f3aV3Kt-.d.ts} +5 -5
  120. package/dist/{index-uVbqCpDa.d.ts → index-u_h6ow4e.d.ts} +3 -3
  121. package/dist/{index-1rcWTB-o.d.ts → index-yZDmK6ab.d.ts} +3 -3
  122. package/dist/index.d.ts +3 -3
  123. package/dist/internal/plugin/OverridePlugin.js +22 -3
  124. package/dist/internal/plugin/blockInsertion.js +4 -4
  125. package/dist/internal/plugin/collectPlateNodeMappings.js +11 -4
  126. package/dist/internal/plugin/compilePlainTextMappings.js +2 -0
  127. package/dist/internal/plugin/plateRuntime.js +7 -1
  128. package/dist/internal/plugin/resolvePlugin.js +4 -1
  129. package/dist/internal/plugin/resolvePlugins.js +5 -3
  130. package/dist/lib/plugins/html/HtmlPlugin.js +32 -13
  131. package/dist/lib/plugins/html/htmlAst.js +5 -3
  132. package/dist/lib/plugins/html/htmlDom.js +1 -10
  133. package/dist/markdown/index.d.ts +2 -2
  134. package/dist/markdown/index.js +1 -2
  135. package/dist/markdown/lib/MarkdownPlugin.js +5 -7
  136. package/dist/markdown/lib/deserializer/convertNodesDeserialize.js +27 -3
  137. package/dist/markdown/lib/internal/markdownConversion.js +308 -340
  138. package/dist/markdown/lib/internal/markdownIntrinsics.js +36 -71
  139. package/dist/markdown/lib/internal/markdownLine.js +2 -4
  140. package/dist/markdown/lib/internal/markdownMappings.js +21 -3
  141. package/dist/markdown/lib/internal/markdownSafety.js +101 -1
  142. package/dist/markdown/lib/internal/markdownTags.js +2 -26
  143. package/dist/markdown/lib/serializer/convertNodesSerialize.js +5 -3
  144. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +1 -10
  145. package/dist/math/index.d.ts +3 -3
  146. package/dist/math/react/index.d.ts +4 -4
  147. package/dist/migrations/documentMigrationSelection.internal.js +107 -2
  148. package/dist/migrations/documentMigrations.js +17 -112
  149. package/dist/migrations/index.d.ts +3 -3
  150. package/dist/migrations/migratePlateV54.js +41 -40
  151. package/dist/migrations/migratePlateV54Ast.internal.js +143 -55
  152. package/dist/migrations/migratePlateV54CodeBlocks.internal.js +24 -29
  153. package/dist/migrations/migratePlateV54Inputs.internal.js +39 -32
  154. package/dist/migrations/migratePlateV54Profile.internal.js +52 -22
  155. package/dist/migrations/migratePlateV54Stage.internal.js +127 -0
  156. package/dist/migrations/migratePlateV54Urls.internal.js +77 -57
  157. package/dist/pagination/index.d.ts +1 -1
  158. package/dist/pagination/react/index.d.ts +2 -2
  159. package/dist/react/components/NodeSelection.js +8 -1
  160. package/dist/react/components/Plate.js +198 -152
  161. package/dist/react/components/PlateView.js +1 -1
  162. package/dist/{static/internal/getPlainText.js → react/components/getPlainText.internal.js} +1 -4
  163. package/dist/react/components/plate-nodes.js +48 -40
  164. package/dist/{static/internal/writeStaticSelectionClipboardData.js → react/components/writeStaticSelectionClipboardData.internal.js} +3 -4
  165. package/dist/react/features/board/BoardShape.js +48 -22
  166. package/dist/react/features/board/boardConnect.internal.js +0 -9
  167. package/dist/react/features/board/boardKeys.internal.js +41 -12
  168. package/dist/react/features/board/boardPicking.internal.js +0 -17
  169. package/dist/react/features/board/boardResize.internal.js +13 -18
  170. package/dist/react/features/board/boardView.internal.js +37 -8
  171. package/dist/react/features/board/boardVoice.internal.js +17 -4
  172. package/dist/react/features/board/index.d.ts +13 -11
  173. package/dist/react/features/callout/index.d.ts +3 -3
  174. package/dist/react/features/combobox/comboboxOwner.internal.js +10 -4
  175. package/dist/react/features/combobox/index.d.ts +5 -5
  176. package/dist/react/features/comments/index.d.ts +5 -5
  177. package/dist/react/features/date/index.d.ts +4 -4
  178. package/dist/react/features/details/index.d.ts +5 -5
  179. package/dist/react/features/field/index.d.ts +6 -5
  180. package/dist/react/features/footnote/index.d.ts +7 -7
  181. package/dist/react/features/format-painter/index.d.ts +4 -4
  182. package/dist/react/features/ink/InkContent.js +28 -100
  183. package/dist/react/features/ink/InkPlugin.js +12 -23
  184. package/dist/react/features/ink/index.d.ts +29 -102
  185. package/dist/react/features/ink/index.js +1 -2
  186. package/dist/react/features/ink/inkCapture.internal.js +97 -61
  187. package/dist/react/features/ink/inkImages.internal.js +20 -5
  188. package/dist/react/features/ink/inkMeasure.internal.js +35 -22
  189. package/dist/react/features/ink/inkPlacement.internal.js +78 -203
  190. package/dist/react/features/ink/inkWatch.internal.js +1 -32
  191. package/dist/react/features/layout/index.d.ts +5 -5
  192. package/dist/react/features/lock/LockPlugin.js +66 -0
  193. package/dist/react/features/lock/index.d.ts +58 -0
  194. package/dist/react/features/lock/index.js +2 -0
  195. package/dist/react/features/media/index.d.ts +5 -5
  196. package/dist/react/features/mention/index.d.ts +6 -6
  197. package/dist/react/features/suggestion/index.d.ts +6 -6
  198. package/dist/react/features/table/index.d.ts +5 -5
  199. package/dist/react/features/toc/index.d.ts +2 -2
  200. package/dist/react/features/upload/index.d.ts +5 -5
  201. package/dist/react/index.d.ts +4 -4
  202. package/dist/react/utils/pipeRenderElement.internal.js +32 -30
  203. package/dist/react/virtualized.d.ts +2 -2
  204. package/dist/{source-Dcgqj5Mf.d.ts → source-B1rLozUs.d.ts} +3 -3
  205. package/dist/static/components/plite-nodes.js +1 -1
  206. package/dist/static/index.d.ts +8 -10
  207. package/dist/static/pluginRenderLeafStatic.internal.js +1 -2
  208. package/dist/tabbable/index.d.ts +1 -1
  209. package/dist/tabbable/react/index.d.ts +3 -3
  210. package/dist/testing/index.d.ts +2 -2
  211. package/dist/{tx-only-1FM45FSj-D40jacZv.d.ts → tx-only-D8lpB-sT-ZiAbZRMU.d.ts} +133 -59
  212. package/dist/yjs/index.d.ts +1 -1
  213. package/dist/yjs/react/index.d.ts +5 -5
  214. package/package.json +16 -3
  215. package/dist/features/ink/lib/inkGone.internal.js +0 -290
  216. package/dist/markdown/lib/RawHtmlPlugin.js +0 -26
  217. package/dist/markdown/lib/internal/markdownRawHtml.js +0 -353
  218. package/dist/react/features/ink/InkCopyView.js +0 -214
@@ -118,8 +118,7 @@ register, after a leading [front matter](#front-matter) block. GFM, math,
118
118
  emoji, and [CJK emphasis](#cjk-emphasis) come from the
119
119
  [remark plugins](#remark-plugins) configured on `MarkdownPlugin`. Registered
120
120
  tags look like HTML, but only registered names are tags and nothing is
121
- evaluated. Other HTML stays text, which [`RawHtmlPlugin`](#raw-html) writes
122
- back as HTML when its block passes a check.
121
+ evaluated. Other HTML stays plain text.
123
122
 
124
123
  ### Registered tags
125
124
 
@@ -139,90 +138,6 @@ A tag is registered only while its feature plugin is installed. Element tags
139
138
  use the schema type, so an application that renames a type also renames its
140
139
  tag.
141
140
 
142
- ### Raw HTML
143
-
144
- `RawHtmlPlugin` keeps a file's raw HTML through a save. The Markdown kit
145
- installs it. An editor with its own plugin list adds it beside
146
- `MarkdownPlugin`:
147
-
148
- ```ts
149
- import { BaseParagraphPlugin, createEditor } from 'platejs';
150
- import { MarkdownPlugin, RawHtmlPlugin } from 'platejs/markdown';
151
-
152
- const editor = createEditor({
153
- plugins: [BaseParagraphPlugin, MarkdownPlugin, RawHtmlPlugin],
154
- });
155
- ```
156
-
157
- An app whose own plugin already declares a `rawHtml` mark keeps that plugin and
158
- leaves `RawHtmlPlugin` out, because two plugins cannot own one mark.
159
-
160
- The plugin changes the editor's schema fingerprint, so an editor with it
161
- refuses a document saved under the earlier schema identity. An app that saves
162
- documents under a named schema increments its `version` and adds a migration
163
- step, as [Document migrations](/docs/editor#document-migrations) shows. An app
164
- that saves `{ document, schema }` under the derived identity opens each saved
165
- document in an editor without the plugin and passes its `read.value()` to the
166
- new editor.
167
-
168
- Import gives the `rawHtml` mark to raw HTML that no registered tag claims, such
169
- as a README's centered header, and to most HTML comments on lines of their own
170
- in the document, a block quote or a list item. The editor shows that text as
171
- plain text, and export writes it back as HTML:
172
-
173
- ```md
174
- <p align="center">
175
- <img src="logo.png" width="200" />
176
- </p>
177
-
178
- <!-- markdownlint-disable -->
179
- ```
180
-
181
- - Import marks only HTML that export can write back. Other raw HTML stays plain
182
- text without the mark and saves escaped, as it does without the plugin. A
183
- comment block that fails the check, such as `<!-- a <!-- b -->`, also stays
184
- plain text, where an editor without the plugin drops it.
185
- - Export checks each block that holds marked text: its paragraph, heading,
186
- table cell or HTML block. Marked text in any other block fails the check.
187
- The check accepts a fixed set of formatting, heading, list, table, media and
188
- disclosure tags, such as `p`, `div`, `img`, `kbd` and `details`, and
189
- attributes such as `align`, `alt`, `href`, `src`, `title` and `width`. It
190
- refuses every other tag and attribute, such as `script`, `class`, `style` and
191
- event handlers, and a doctype.
192
- - An `href` or `src` URL passes when it is empty or Plate's URL safety rules
193
- accept it, and a `cite` or `srcset` URL passes only when those rules accept
194
- it. The rules refuse script-capable schemes such as `javascript:`. The check
195
- does not read the Link plugin's `allowedSchemes`, so
196
- `<a href="smb://server/share">x</a>` writes back as HTML, while the Link
197
- plugin with its default schemes refuses `[x](smb://server/share)`.
198
- - When an edit makes a marked block fail the check, export writes that block's
199
- marked text escaped and reports a lossless `markdown-unsafe-content` warning.
200
- In rare cases, such as a mapping that copies marked text, export writes all
201
- marked text in the document escaped. Plate writes a details summary line as
202
- HTML, so a CommonMark reader still reads escaped text there as HTML, while
203
- Plate reads it back as the same plain text.
204
- - An HTML block writes back as HTML in the document, a block quote or a list
205
- item. Inside a registered block tag's body, such as `<callout>`, raw HTML
206
- writes back only in pieces that fit on one line. An HTML block there stays
207
- plain text and saves escaped, and one directly inside `<details>` fails the
208
- parse with `markdown-schema-invalid`, unless it is a comment. A `<block>`
209
- wrapper around one HTML block drops on import, and its HTML writes back. A
210
- footnote definition keeps all of its raw HTML as plain text.
211
- - A comment drops, as it does without the plugin, when it sits inside a line of
212
- paragraph or heading text, a table cell, a registered tag's body or a
213
- footnote definition, or when it is an unindented `<!---->`, the separator
214
- Plate writes between two blocks.
215
- - Import also leaves unmarked a comment or HTML block whose indent export
216
- cannot write back. That covers one indented past its list item's text on the
217
- line after an empty marker, such as ` <!-- c -->` after `-`, one indented
218
- after a list, such as one space after `- a`, and one whose indent keeps a tab
219
- after the indent of its quote or list item. Such a comment drops, and such
220
- HTML saves escaped.
221
- - HTML, DOCX and plain-text export write marked text as visible text.
222
- - Naming `rawHtml` in `MarkdownPlugin`'s `plainMarks` stops import from
223
- marking, so tags stay plain text and comment blocks drop. Naming it in a
224
- serialize call's `plainMarks` writes marked text escaped, with no warning.
225
-
226
141
  ### Writer output
227
142
 
228
143
  ```md
@@ -254,8 +169,7 @@ Due <date value="2025-01-01" />, ask [Jane](mention:user_123).
254
169
 
255
170
  - Every string parses. Raw HTML that no mapping accepts stays literal text and
256
171
  reports a lossless `markdown-unsupported-node` warning under every policy.
257
- - Without [`RawHtmlPlugin`](#raw-html), an HTML block that holds only closed
258
- comments drops with a lossless warning.
172
+ - An HTML block that holds only closed comments drops with a lossless warning.
259
173
  - `<br>`, `<br/>`, and `<br />` become line breaks.
260
174
  - A line holding only a registered block tag is a block, even next to paragraph
261
175
  text. A block tag elsewhere in a paragraph or heading stays text. A table cell
@@ -665,8 +579,12 @@ markdown: {
665
579
  `mention:` links this way before Link.
666
580
  - `marks` contains the inherited persisted text marks. Pass it to `decode` or
667
581
  `decodeNodes` when nested content must keep those marks.
668
- - `previousSibling` is the Markdown node before this one. Lists use it to read
669
- a list right after another as restarted numbering.
582
+ - `previousSibling` is the Markdown node before this one among its siblings.
583
+ - On a mark mapping, `wrap` returns a childless inline wrapper (`strong`,
584
+ `emphasis`, `delete`, or `mdxJsxTextElement`) or `refuse(message)` when a
585
+ mark needs custom output beyond `node`, `tag`, `value`, or `style`; Markdown
586
+ supplies the encoded children. Both element `encode` and mark `wrap` must
587
+ return output or `refuse(message)` (never `undefined`).
670
588
  - `readTagAttributes(tag?)` returns `{ attributes, properties }`: every
671
589
  attribute as written, and the node's properties decoded as a declared tag
672
590
  decodes them.
@@ -696,8 +614,8 @@ markdown: {
696
614
 
697
615
  Pass an array to declare several mappings for one plugin. Use
698
616
  `defineFormats(map)` for self mappings and `defineFormats(TargetPlugin, map)`
699
- for a foreign target. A plugin's `formats` accept only the `html`, `markdown`,
700
- and `plainText` keys; MIME payloads belong in `dataTransferFormats`.
617
+ for a foreign target. A plugin's `formats` accept `html`, `markdown`,
618
+ `plainText`, and `docx`; MIME payloads belong in `dataTransferFormats`.
701
619
 
702
620
  ### Content roots
703
621
 
@@ -856,8 +774,8 @@ parser returns because mdast does not expose a bounded construction hook.
856
774
  | `editor.api.markdown.parseInline(source, options?)` | Closed, rootless inline `ContentSlice`. |
857
775
  | `editor.api.markdown.serialize(options?)` | Current or supplied document using the installed target. |
858
776
 
859
- Import `MarkdownPlugin`, `RawHtmlPlugin`, the standalone functions, and their
860
- result, diagnostic, and option types from `platejs/markdown`.
777
+ Import `MarkdownPlugin`, the standalone functions, and their result, diagnostic,
778
+ and option types from `platejs/markdown`.
861
779
 
862
780
  | Parse option | Use |
863
781
  | --- | --- |
@@ -879,5 +797,4 @@ result, diagnostic, and option types from `platejs/markdown`.
879
797
  Standalone functions also require `plugins` and accept `schema`. Installed
880
798
  editor methods omit both because the plugin captures them from the editor.
881
799
  `MarkdownPlugin` state holds `remarkPlugins`, `remarkStringifyOptions`, and
882
- `plainMarks`. When its `plainMarks` names `rawHtml`, import gives raw HTML no
883
- mark.
800
+ `plainMarks`.
@@ -29,7 +29,7 @@ but the editor type is `Editor`.
29
29
  | `store` | Read, update, or subscribe to the current plugin's editor-local state. |
30
30
  | `viewStore` | Read, update, or subscribe to the current plugin's state in one view. Available in the `api` factory and on the plugin portal. |
31
31
  | `viewStoreOf(state)`, `viewStoreOf(tx)` | Read or write the current plugin's state in the view a read state or transaction runs in. Available in `.extend` callbacks. |
32
- | `defineFormats(map)` | Bind self-owned HTML, Markdown, and plain-text mappings to this plugin's inferred schema. |
32
+ | `defineFormats(map)` | Bind self-owned HTML, Markdown, plain-text, and DOCX mappings to this plugin's inferred schema. |
33
33
  | `defineFormats(TargetPlugin, map)` | Bind a foreign mapping to an exact descriptor and inject its target. |
34
34
 
35
35
  ## Plugin methods
@@ -158,7 +158,7 @@ export const StrongPlugin = definePlugin('strong', {
158
158
 
159
159
  The one-argument form owns self mappings. For a foreign contribution, call
160
160
  `defineFormats(TargetPlugin, map)`; Plate injects the target into every HTML
161
- rule. The semantic keys are `html`, `markdown`, and `plainText`. Use one HTML
161
+ rule. The semantic keys are `html`, `markdown`, `plainText`, and `docx`. Use one HTML
162
162
  rule or a non-empty ordered rule tuple. Register whole-payload browser MIME
163
163
  handling through `dataTransferFormats`, not `defineFormats`. Do not annotate
164
164
  mapping callback parameters.
@@ -231,18 +231,22 @@ export function CounterStatus() {
231
231
  }
232
232
  ```
233
233
 
234
- To subscribe to another editor registered under the same `<EditorController>`,
235
- pass its ID to the selector overload:
234
+ To subscribe to an explicit editor instance instead of the nearest provider,
235
+ use `useEditorPluginStore`:
236
236
 
237
237
  ```tsx title="counter-badge.tsx" showLineNumbers
238
- import { usePluginStore } from 'platejs/react';
238
+ import type { Editor } from 'platejs/react';
239
+
240
+ import { useEditorPluginStore } from 'platejs/react';
239
241
 
240
242
  import { CounterPlugin } from './counter-plugin';
241
243
 
242
- export function CounterBadge({ editorId }: { editorId: string }) {
243
- const count = usePluginStore(CounterPlugin, (state) => state.count, {
244
- id: editorId,
245
- });
244
+ export function CounterBadge({ editor }: { editor: Editor }) {
245
+ const count = useEditorPluginStore(
246
+ editor,
247
+ CounterPlugin,
248
+ (state) => state.count
249
+ );
246
250
 
247
251
  return <span>{count}</span>;
248
252
  }
@@ -379,7 +383,7 @@ export function FocusModeButton() {
379
383
  | `editor.plugin(plugin)` | Any editor code. | Opens the installed plugin's typed consumer portal. |
380
384
  | `useEditor().plugin(plugin)` | React under `<EditorRoot>`. | Returns the installed plugin's flat consumer portal. |
381
385
  | `usePluginStore(plugin, key, ...args)` | React under `<EditorRoot>`. | Subscribes to one state field or named selector. |
382
- | `usePluginStore(plugin, selector, options?)` | React under `<EditorRoot>` or a registered editor under `<EditorController>`. | Subscribes to a value derived from plugin state on the provider’s selected editor. Use `useEditorPluginStore(editor, plugin, selector)` for an explicit editor. |
386
+ | `usePluginStore(plugin, selector, options?)` | React under `<EditorRoot>` or a registered editor under `<EditorController>`. | Subscribes to a value derived from plugin state on the provider's selected editor. Use `useEditorPluginStore(editor, plugin, selector)` for an explicit editor. |
383
387
  | `useViewStore(plugin, selector)` | React under `<EditorRoot>`. | Subscribes to a value derived from the plugin's view state in the view `useEditor()` returns. |
384
388
 
385
389
  For plugin plugin methods, see [Plugin Methods](/docs/plugin-methods). For
@@ -64,7 +64,30 @@ const result = serializePlainText(editor, { projection: 'accepted' });
64
64
 
65
65
  Feature plugins contribute structural `plainText` mappings through
66
66
  `formats`/`defineFormats`. Plain text is one-way output; it does not become a
67
- universal parser or persistence format.
67
+ universal parser or persistence format. Non-void elements fall back to their
68
+ serialized children and owned content roots automatically, so declare
69
+ `plainText` only when an element needs custom text:
70
+
71
+ ```ts
72
+ import { definePlugin, property, schema } from 'platejs';
73
+
74
+ const MentionPlugin = definePlugin('mention', {
75
+ schema: {
76
+ element: {
77
+ properties: { label: property.string(), ref: property.string({ required: true }) },
78
+ void: 'inline',
79
+ },
80
+ },
81
+ formats: ({ defineFormats }) =>
82
+ defineFormats({
83
+ plainText: {
84
+ encode: ({ node }) => `@${node.label ?? node.ref}`,
85
+ },
86
+ }),
87
+ });
88
+ ```
89
+
90
+ `encode` receives `{ children, node, rootText, document, parent, path, previousSibling, root, pluginState, registry, schema }` and returns a string, or `undefined` to fall through to lower-priority mappings (higher `priority` runs first) or default serialization. Mark-only plugins cannot declare `plainText` mappings.
68
91
 
69
92
  ## Convert HTML
70
93
 
@@ -163,8 +186,8 @@ accepts the exact reported loss.
163
186
  ## Define feature mappings
164
187
 
165
188
  Feature plugins declare semantic mappings through `formats` and
166
- `defineFormats` using the `html`, `markdown`, and `plainText` keys. The narrow
167
- authoring callback cannot read a live editor or store.
189
+ `defineFormats` using the `html`, `markdown`, `plainText`, and `docx` keys. The
190
+ narrow authoring callback cannot read a live editor or store.
168
191
 
169
192
  Whole browser MIME payloads use `DataTransferFormat`, not feature mappings.
170
193
  Clipboard insertion remains destination-aware and can preserve native open
@@ -287,7 +287,7 @@ export function InteractiveViewer({ value }) {
287
287
  | **Environment** | Server/Client (SSR/RSC safe) | Client-only | Client-only |
288
288
  | **Interactivity** | None | Minimal (selection, copy, toolbar, etc.) | Full interactive features (browser-only) |
289
289
  | **Browser APIs** | Not used | Minimal (event handlers) | Full usage |
290
- | **Performance** | Best - static HTML only | Good - static rendering + event delegation | Heavier - full editor internals |
290
+ | **Performance** | Best (static HTML only) | Good (static rendering + event delegation) | Heavier (full editor internals) |
291
291
  | **Bundle Size** | Smallest | Small | Largest |
292
292
  | **Use Cases** | Server rendering, HTML export | Client-side content with basic interactions | Full read-only editor with all features |
293
293
  | **Recommendation** | SSR/RSC without any interactions | Client-side content needing light interactivity | Client-side with complex interactive needs |
@@ -376,10 +376,10 @@ const result = await renderStaticHtml(editor, {
376
376
  });
377
377
  ```
378
378
 
379
- When the live editor installs authored changes, also pass
380
- `projection: 'accepted'` or `'proposed'`. Its document carries authored metadata
381
- even before any proposal, and `renderStaticHtml` throws a `TypeError` without a
382
- projection.
379
+ When the live editor has pending authored changes, also pass
380
+ `projection: 'accepted'` or `'proposed'`. Omitting `projection` when pending
381
+ changes exist throws a `TypeError`. A document with no pending changes renders
382
+ as-is when `projection` is omitted.
383
383
 
384
384
  For each element component, mark component, and wrapper slot function an
385
385
  installed plugin declares, the plugin of the same name in `presentation`
@@ -431,6 +431,20 @@ interface EditorStaticProps<E = Editor>
431
431
  - **`document`**: A document rendered through the editor's plugins instead of the editor's own value; see [Render a document](#render-a-document).
432
432
  - **`editor`**: An editor created with `createEditor` or `useCreateEditor`, including component-bound plugins required by the value.
433
433
 
434
+ ### `renderStaticHtml(editor, options?)`
435
+
436
+ Renders one document snapshot to an HTML string and returns `{ data, diagnostics }`.
437
+
438
+ | Option | Type | Description |
439
+ | --- | --- | --- |
440
+ | `component` | `React.ComponentType<T>` | Static root component. Defaults to `EditorStatic`. |
441
+ | `document` | `EditorDocumentValue` | Document snapshot to render. Defaults to `editor.read.value()`. |
442
+ | `presentation` | `readonly BasePluginInput[]` | Static plugins supplying element, mark, and wrapper drawings while the live editor keeps the document and plugin settings. |
443
+ | `projection` | `'accepted' \| 'proposed'` | Required when pending authored changes exist; `'accepted'` drops pending changes and `'proposed'` applies them as plain content. |
444
+ | `props` | `Partial<Omit<T, 'document' \| 'editor'>>` | Appearance props forwarded to `component` (`editor` and `document` throw a `TypeError`). |
445
+
446
+ `diagnostics` contains `authored-lossy-projection` warnings (when projecting pending changes) and `missing-static-presentation` warnings naming any `plugin` omitted from `presentation`.
447
+
434
448
  ## Next steps
435
449
 
436
450
  - Explore [HTML Serialization](/docs/html) for exporting content.
@@ -1,6 +1,6 @@
1
- import { ct as BasePluginInput, u as Editor } from "../../core-Cqc_KzpG.js";
2
- import { n as EditorStaticProps } from "../../PlateStatic-DIwBAVqF.js";
3
- import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-Dcgqj5Mf.js";
1
+ import { ct as BasePluginInput, u as Editor } from "../../core-D8i_gkA6.js";
2
+ import { n as EditorStaticProps } from "../../PlateStatic-CggiBCuD.js";
3
+ import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-B1rLozUs.js";
4
4
  type UnitValue = number | string;
5
5
  type Margins = {
6
6
  bottom?: UnitValue;
@@ -86,18 +86,64 @@ const namedRootDiagnostics = (document, renderedRoots) => Object.keys(document.r
86
86
  root,
87
87
  severity: "warning"
88
88
  }));
89
- const docxTextFormatsOf = (editor) => getPlateNodeMappingContributions(editor, "docx").map(({ declaration, owner, targetPlugin, targetType }) => {
90
- if (typeof declaration.dropped !== "string" || typeof declaration.text !== "function" || targetType === null) throw new Error(`DOCX node mapping "${owner}" must define dropped and text for an element.`);
89
+ const DOCX_ELEMENT_FIELDS = /* @__PURE__ */ new Set(["dropped", "text"]);
90
+ const DOCX_PROPERTY_FIELDS = /* @__PURE__ */ new Set(["dropped", "property"]);
91
+ const docxFormatsOf = (editor) => {
92
+ const propertyFormats = [];
93
+ const textFormats = [];
94
+ for (const { declaration, ownedPropertyKeys, owner, targetKey, targetPlugin, targetType } of getPlateNodeMappingContributions(editor, "docx")) {
95
+ if (typeof declaration.dropped !== "string") throw new Error(`DOCX node mapping "${owner}" must define a dropped warning message.`);
96
+ if (targetType !== null) {
97
+ for (const field of Object.keys(declaration)) if (!DOCX_ELEMENT_FIELDS.has(field)) throw new Error(`DOCX node mapping "${owner}" has unknown element field "${field}".`);
98
+ if (typeof declaration.text !== "function") throw new Error(`DOCX node mapping "${owner}" must define dropped and text for an element.`);
99
+ textFormats.push({
100
+ dropped: declaration.dropped,
101
+ plugin: targetPlugin,
102
+ text: declaration.text,
103
+ type: targetType
104
+ });
105
+ continue;
106
+ }
107
+ if (ownedPropertyKeys.length === 0) throw new Error(`DOCX node mapping "${owner}" must target an element type or element property.`);
108
+ for (const field of Object.keys(declaration)) if (!DOCX_PROPERTY_FIELDS.has(field)) throw new Error(`DOCX node mapping "${owner}" has unknown property field "${field}".`);
109
+ if (declaration.property !== void 0 && typeof declaration.property !== "string") throw new Error(`DOCX node mapping "${owner}" property must be a string.`);
110
+ const property = typeof declaration.property === "string" ? declaration.property : targetKey;
111
+ if (!property || !ownedPropertyKeys.includes(property)) throw new Error(`DOCX node mapping "${owner}" must name an element property owned by "${targetPlugin}".`);
112
+ propertyFormats.push({
113
+ dropped: declaration.dropped,
114
+ plugin: targetPlugin,
115
+ property
116
+ });
117
+ }
91
118
  return {
92
- dropped: declaration.dropped,
93
- plugin: targetPlugin,
94
- text: declaration.text,
95
- type: targetType
119
+ propertyFormats,
120
+ textFormats
96
121
  };
97
- });
122
+ };
98
123
  const countElements = (nodes, type) => nodes.reduce((count, node) => ElementApi.isElement(node) ? count + (node.type === type ? 1 : 0) + countElements(node.children, type) : count, 0);
99
- const textFormatDiagnostics = (textFormats, document) => textFormats.flatMap(({ dropped, plugin, type }) => {
100
- const count = countElements(document.children, type);
124
+ const countElementsWithProperty = (nodes, property) => nodes.reduce((count, node) => ElementApi.isElement(node) ? count + (node[property] !== void 0 && node[property] !== false ? 1 : 0) + countElementsWithProperty(node.children, property) : count, 0);
125
+ const exportedStoriesOf = (document, renderedRoots, commentBodies) => {
126
+ const stories = [document.children];
127
+ if (renderedRoots && document.roots) for (const rootKey of renderedRoots) {
128
+ const rootNodes = document.roots[rootKey];
129
+ if (rootNodes) stories.push(rootNodes);
130
+ }
131
+ for (const body of commentBodies) stories.push(body);
132
+ return stories;
133
+ };
134
+ const propertyFormatDiagnostics = (propertyFormats, stories) => propertyFormats.flatMap(({ dropped, plugin, property }) => {
135
+ const count = stories.reduce((total, nodes) => total + countElementsWithProperty(nodes, property), 0);
136
+ return count > 0 ? [{
137
+ code: "property-dropped",
138
+ count,
139
+ feature: plugin,
140
+ impact: "lossy",
141
+ message: dropped,
142
+ severity: "warning"
143
+ }] : [];
144
+ });
145
+ const textFormatDiagnostics = (textFormats, stories) => textFormats.flatMap(({ dropped, plugin, type }) => {
146
+ const count = stories.reduce((total, nodes) => total + countElements(nodes, type), 0);
101
147
  return count > 0 ? [{
102
148
  code: "property-dropped",
103
149
  count,
@@ -315,11 +361,10 @@ async function exportDocx(editor, options) {
315
361
  ok: true
316
362
  });
317
363
  }
318
- const textFormats = docxTextFormatsOf(editor);
364
+ const { propertyFormats, textFormats } = docxFormatsOf(editor);
319
365
  const diagnostics = [
320
366
  ...sourceResolution.diagnostics,
321
367
  ...metadata,
322
- ...textFormatDiagnostics(textFormats, capture.document),
323
368
  ...listDiagnostics(capture.document),
324
369
  ...quoteDiagnostics(editor, capture.document.children),
325
370
  ...capture.comments.flatMap(({ body, id, target }) => target ? quoteDiagnostics(editor, body, id) : []),
@@ -338,7 +383,8 @@ async function exportDocx(editor, options) {
338
383
  if (hasStoredNamedRoots && hostIndex) diagnostics.push(...namedRootDiagnostics(snapshot.stored, hostIndex.renderedRoots));
339
384
  const anchored = mainDocument && hostIndex && capture.comments.length > 0 ? anchorDocxComments(mainDocument, hostIndex, capture.comments) : EMPTY_PREPARED_DOCX_COMMENTS;
340
385
  const review = mainDocument && hostIndex && capture.review ? applyReviewProjection(mainDocument, hostIndex, capture.review) : void 0;
341
- diagnostics.push(...review?.diagnostics ?? [], ...missingDrawings([main, ...commentRenders]));
386
+ const exportedStories = exportedStoriesOf(capture.document, hostIndex?.renderedRoots, anchored.comments.map(({ comment }) => comment.body));
387
+ diagnostics.push(...textFormatDiagnostics(textFormats, exportedStories), ...propertyFormatDiagnostics(propertyFormats, exportedStories), ...review?.diagnostics ?? [], ...missingDrawings([main, ...commentRenders]));
342
388
  if (mainDocument && anchored.comments.length > 0) joinDocxCommentBodies(mainDocument, anchored, new Map(commentRenders.map(({ data, id }) => [id, data])));
343
389
  diagnostics.push(...anchored.diagnostics);
344
390
  throwIfDocxAborted(options.signal);
@@ -1,7 +1,7 @@
1
- import { Ho as PluginReference, Tt as EditorDocumentValue, xu as Value } from "../../tx-only-1FM45FSj-D40jacZv.js";
2
- import { h as EditorApplicationSchema } from "../../htmlTypes-i_FBCMf2.js";
3
- import "../../core-Cqc_KzpG.js";
4
- import { a as DocxImportLimits, i as DocxErrorDiagnostic, n as DocxComment, o as DocxSourceLocation, r as DocxDiagnostic, s as DocxWarningDiagnostic, t as DocxSource } from "../../source-Dcgqj5Mf.js";
1
+ import { Ho as PluginReference, Tt as EditorDocumentValue, xu as Value } from "../../tx-only-D8lpB-sT-ZiAbZRMU.js";
2
+ import { h as EditorApplicationSchema } from "../../htmlTypes-zTLU3aTb.js";
3
+ import "../../core-D8i_gkA6.js";
4
+ import { a as DocxImportLimits, i as DocxErrorDiagnostic, n as DocxComment, o as DocxSourceLocation, r as DocxDiagnostic, s as DocxWarningDiagnostic, t as DocxSource } from "../../source-B1rLozUs.js";
5
5
  type DocxImportOptions<TRetainSource extends boolean = false> = Readonly<{
6
6
  limits?: Partial<DocxImportLimits>;
7
7
  lossPolicy?: 'allow' | 'reject';
@@ -1,7 +1,7 @@
1
- import { xu as Value } from "../../tx-only-1FM45FSj-D40jacZv.js";
2
- import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult } from "../../htmlTypes-i_FBCMf2.js";
3
- import { go as PluginReference, mo as PluginDependency, v as BasePlugin } from "../../core-Cqc_KzpG.js";
4
- import "../../index-BI0NS7kx.js";
1
+ import { xu as Value } from "../../tx-only-D8lpB-sT-ZiAbZRMU.js";
2
+ import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult } from "../../htmlTypes-zTLU3aTb.js";
3
+ import { go as PluginReference, mo as PluginDependency, v as BasePlugin } from "../../core-D8i_gkA6.js";
4
+ import "../../index-CfK4uv4I.js";
5
5
  /** Normalizes Word clipboard payloads before the installed HTML parser runs. */
6
6
  declare const WordPastePlugin: BasePlugin<Readonly<{
7
7
  readonly dependencies: readonly [PluginReference<"html"> & PluginDependency<Readonly<{
@@ -1,2 +1,2 @@
1
- import { A as DOMVisualPointOptions, B as HotkeyPlatform, C as DOMPoint, D as DOMStaticRange, E as DOMSelection, F as DataTransferFormatPhase, G as ariaKeyShortcuts, H as KeyboardEventLike, I as DataTransferSchemaClaim, J as isHotkey, K as dataTransferFormats, L as DataTransferSnapshot, M as DataTransferDiagnostic, N as DataTransferEncodeContext, O as DOMText, P as DataTransferFormat, R as DropIndicator, T as DOMResolutionError, U as ScrollIntoViewOptions, V as HotkeySpec, W as ScrollIntoViewTarget, X as writeDataTransferFragment, Y as usesAppleDOMHotkeys, b as DOMNode, d as DOMDragApi, f as DOMDragStart, g as DOMDropTargetOptions, h as DOMDropTargetInput, i as DOMClipboardApi, j as DataTransferDecodeContext, k as DOMVisualPoint, m as DOMDropTarget, n as ClipboardSliceWrite, p as DOMDropEdge, q as domCommands, r as DOMApi, t as ClipboardSliceRead, v as DOMElement, w as DOMRange, y as DOMGeometryRect, z as HotkeyMatchOptions } from "../index-DNXr_SN-.js";
1
+ import { A as DOMVisualPointOptions, B as HotkeyPlatform, C as DOMPoint, D as DOMStaticRange, E as DOMSelection, F as DataTransferFormatPhase, G as ariaKeyShortcuts, H as KeyboardEventLike, I as DataTransferSchemaClaim, J as isHotkey, K as dataTransferFormats, L as DataTransferSnapshot, M as DataTransferDiagnostic, N as DataTransferEncodeContext, O as DOMText, P as DataTransferFormat, R as DropIndicator, T as DOMResolutionError, U as ScrollIntoViewOptions, V as HotkeySpec, W as ScrollIntoViewTarget, X as writeDataTransferFragment, Y as usesAppleDOMHotkeys, b as DOMNode, d as DOMDragApi, f as DOMDragStart, g as DOMDropTargetOptions, h as DOMDropTargetInput, i as DOMClipboardApi, j as DataTransferDecodeContext, k as DOMVisualPoint, m as DOMDropTarget, n as ClipboardSliceWrite, p as DOMDropEdge, q as domCommands, r as DOMApi, t as ClipboardSliceRead, v as DOMElement, w as DOMRange, y as DOMGeometryRect, z as HotkeyMatchOptions } from "../index-BPOa4Z5n.js";
2
2
  export { type ClipboardSliceRead, type ClipboardSliceWrite, type DOMApi, type DOMClipboardApi, type DOMDragApi, type DOMDragStart, type DOMDropEdge, type DOMDropTarget, type DOMDropTargetInput, type DOMDropTargetOptions, type DOMElement, type DOMGeometryRect, type DOMNode, type DOMPoint, type DOMRange, DOMResolutionError, type DOMSelection, type DOMStaticRange, type DOMText, type DOMVisualPoint, type DOMVisualPointOptions, type DataTransferDecodeContext, type DataTransferDiagnostic, type DataTransferEncodeContext, type DataTransferFormat, type DataTransferFormatPhase, type DataTransferSchemaClaim, type DataTransferSnapshot, type DropIndicator, type HotkeyMatchOptions, type HotkeyPlatform, type HotkeySpec, type KeyboardEventLike, type ScrollIntoViewOptions, type ScrollIntoViewTarget, ariaKeyShortcuts, dataTransferFormats, domCommands, isHotkey, usesAppleDOMHotkeys, writeDataTransferFragment };
@@ -1,6 +1,6 @@
1
- import { Ii as ElementOf, Wt as EditorJsonValue, cs as PropertyJsonDescriptor } from "../tx-only-1FM45FSj-D40jacZv.js";
2
- import "../htmlTypes-i_FBCMf2.js";
3
- import { v as BasePlugin } from "../core-Cqc_KzpG.js";
1
+ import { Ii as ElementOf, Wt as EditorJsonValue, cs as PropertyJsonDescriptor } from "../tx-only-D8lpB-sT-ZiAbZRMU.js";
2
+ import "../htmlTypes-zTLU3aTb.js";
3
+ import { v as BasePlugin } from "../core-D8i_gkA6.js";
4
4
  type ExcalidrawElementData = {
5
5
  elements: readonly EditorJsonValue[];
6
6
  files?: Readonly<Record<string, EditorJsonValue>>;
@@ -1,6 +1,6 @@
1
- import { Wt as EditorJsonValue, cs as PropertyJsonDescriptor } from "../../tx-only-1FM45FSj-D40jacZv.js";
2
- import "../../htmlTypes-i_FBCMf2.js";
3
- import { kt as Plugin } from "../../index-DfkFmApH.js";
1
+ import { Wt as EditorJsonValue, cs as PropertyJsonDescriptor } from "../../tx-only-D8lpB-sT-ZiAbZRMU.js";
2
+ import "../../htmlTypes-zTLU3aTb.js";
3
+ import { kt as Plugin } from "../../index-DsNwo8dd.js";
4
4
  import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
5
5
  declare const ExcalidrawPlugin: Plugin<Readonly<{}> & Readonly<{
6
6
  name: "excalidraw";
package/dist/facade.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { ContentSlice, DocumentChange, EditorSchemaValidationError, ElementApi, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, createEditor, defineEditorSchema, definePlugin as defineRuntimePlugin, definePluginPoint, editorCommands, editorReads, getEditorRuntimeOwner, locateAt, readEditorSelection, schema, transfer, txLocate, txSelection } from "plitejs";
2
- import { EDITOR_DOCUMENT_FIELDS as EDITOR_DOCUMENT_FIELDS$1, EditorRefusalError, MAIN_ROOT_KEY, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, commitMatchesSelectorDependencies, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, countCoreWork, createAuthoredEditorView, createDetachedEditorSchema as createDetachedEditorSchema$1, createEditorCommitPublicationQueue, createEditorOwner, didCommitChangePersistedValue, fitSlicePlacements, getActiveCommandEditor, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAnchorRuntimeId, getAuthoredUpdateView, getAuthoredViewCommit, getCaretOwner, getCarriedCaretEditor, getCommitDocumentValue, getCompiledEditorSchema as getCompiledEditorSchema$1, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability as getEditorAuthoredDocumentCapability$1, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getMutationVersion, getPluginContributions, getPluginSlotInput, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getStateViewPresentation as getStateViewPresentation$1, getTextSearchScope, getValueRecords, getViewAuthor, getViewCommitSource, getViewPresentation as getViewPresentation$1, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput as isEnvelopeInput$1, isPlugin as isRuntimePlugin, landNodePropertiesAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewInteraction, normalizeSelectorDependencies, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, publishEditorCommitInVersionOrder, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord as readDocumentRecord$1, readEditorCommitHistoryEntry, readEditorViewStateFacts, readElementPropertyWrites, readPersistedEnvelope as readPersistedEnvelope$1, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownElementById, readShownPreview, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordEditorHistoryEffect, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError as reportEditorLifecycleError$1, resetEditorCommitPublicationQueue, restoreAnchor, runEditorObserver, sameResult, sameSelectorDependencies, scheduleAfterCommitNotification, selectorDependenciesViewSubscription, selectorDependenciesWantCommits, selectorDependenciesWantShownPreview, setDOMClipboardFormatKey, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeSharedEditorViewState, subscribeShownViewUse, txStored, vetoesWrite, viewStateFactsChanged, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withPliteReactPreservedSelection, withStoredAuthoredRead, withTransactionSpecDraftRead } from "plitejs/internal";
3
- export { ContentSlice, DocumentChange, EDITOR_DOCUMENT_FIELDS$1 as EDITOR_DOCUMENT_FIELDS, EditorRefusalError, EditorSchemaValidationError, ElementApi, MAIN_ROOT_KEY, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, commitMatchesSelectorDependencies, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, countCoreWork, createAuthoredEditorView, createDetachedEditorSchema$1 as createDetachedEditorSchema, createEditor, createEditorCommitPublicationQueue, createEditorOwner, defineEditorSchema, definePluginPoint, defineRuntimePlugin, didCommitChangePersistedValue, editorCommands, editorReads, fitSlicePlacements, getActiveCommandEditor, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAnchorRuntimeId, getAuthoredUpdateView, getAuthoredViewCommit, getCaretOwner, getCarriedCaretEditor, getCommitDocumentValue, getCompiledEditorSchema$1 as getCompiledEditorSchema, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability$1 as getEditorAuthoredDocumentCapability, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeOwner, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getMutationVersion, getPluginContributions, getPluginSlotInput, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getStateViewPresentation$1 as getStateViewPresentation, getTextSearchScope, getValueRecords, getViewAuthor, getViewCommitSource, getViewPresentation$1 as getViewPresentation, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput$1 as isEnvelopeInput, isRuntimePlugin, landNodePropertiesAt, locateAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewInteraction, normalizeSelectorDependencies, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, publishEditorCommitInVersionOrder, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord$1 as readDocumentRecord, readEditorCommitHistoryEntry, readEditorSelection, readEditorViewStateFacts, readElementPropertyWrites, readPersistedEnvelope$1 as readPersistedEnvelope, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownElementById, readShownPreview, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordEditorHistoryEffect, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError$1 as reportEditorLifecycleError, resetEditorCommitPublicationQueue, restoreAnchor, runEditorObserver, sameResult, sameSelectorDependencies, scheduleAfterCommitNotification, schema, selectorDependenciesViewSubscription, selectorDependenciesWantCommits, selectorDependenciesWantShownPreview, setDOMClipboardFormatKey, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeSharedEditorViewState, subscribeShownViewUse, transfer, txLocate, txSelection, txStored, vetoesWrite, viewStateFactsChanged, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withPliteReactPreservedSelection, withStoredAuthoredRead, withTransactionSpecDraftRead };
2
+ import { EDITOR_DOCUMENT_FIELDS as EDITOR_DOCUMENT_FIELDS$1, EditorRefusalError, MAIN_ROOT_KEY, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, authoredDirectProperties, canPlaceBlocksAtPath, claimsHistoryReplay, commitMatchesSelectorDependencies, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, countCoreWork, createAuthoredEditorView, createDetachedEditorSchema as createDetachedEditorSchema$1, createEditorCommitPublicationQueue, createEditorOwner, didCommitChangePersistedValue, exportContentSlice, fitSlicePlacements, getActiveCommandEditor, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAnchorRuntimeId, getAuthoredUpdateView, getAuthoredViewCommit, getCaretOwner, getCarriedCaretEditor, getCommitDocumentValue, getCompiledEditorSchema as getCompiledEditorSchema$1, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability as getEditorAuthoredDocumentCapability$1, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getMutationVersion, getPluginContributions, getPluginSlotInput, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getStateViewPresentation as getStateViewPresentation$1, getTextSearchScope, getValueRecords, getViewAuthor, getViewCommitSource, getViewPresentation as getViewPresentation$1, hasNonWritableAt, holdsCaret, isAuthorId, isDocumentView, isEditorDraftView, isEditorPublishingCommit, isEnvelopeInput as isEnvelopeInput$1, isPlugin as isRuntimePlugin, landNodePropertiesAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewInteraction, nonWritableContent, nonWritableRoot, normalizeSelectorDependencies, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, publishEditorCommitInVersionOrder, publishEditorRefusal, readAuthoredView, readCaretViewIn, readCommitRootIndex, readDocumentRange, readDocumentRecord as readDocumentRecord$1, readEditorCommitHistoryEntry, readEditorViewStateFacts, readElementPropertyWrites, readPersistedEnvelope as readPersistedEnvelope$1, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownElementById, readShownPreview, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordEditorHistoryEffect, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError as reportEditorLifecycleError$1, resetEditorCommitPublicationQueue, resolveLocationRoot, restoreAnchor, runEditorObserver, sameResult, sameSelectorDependencies, scheduleAfterCommitNotification, selectorDependenciesViewSubscription, selectorDependenciesWantCommits, selectorDependenciesWantShownPreview, setDOMClipboardFormatKey, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, shouldSkipHistoryForOnlyProperties, skipHistoryIfOnlyProperties, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorRefusals, subscribeEditorViewState, subscribeSharedEditorViewState, subscribeShownViewUse, txStored, vetoesWrite, viewStateFactsChanged, visitDocumentChangeSections, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withPliteReactPreservedSelection, withStoredAuthoredRead, withTransactionSpecDraftRead } from "plitejs/internal";
3
+ export { ContentSlice, DocumentChange, EDITOR_DOCUMENT_FIELDS$1 as EDITOR_DOCUMENT_FIELDS, EditorRefusalError, EditorSchemaValidationError, ElementApi, MAIN_ROOT_KEY, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, authoredDirectProperties, canPlaceBlocksAtPath, claimsHistoryReplay, commitMatchesSelectorDependencies, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, countCoreWork, createAuthoredEditorView, createDetachedEditorSchema$1 as createDetachedEditorSchema, createEditor, createEditorCommitPublicationQueue, createEditorOwner, defineEditorSchema, definePluginPoint, defineRuntimePlugin, didCommitChangePersistedValue, editorCommands, editorReads, exportContentSlice, fitSlicePlacements, getActiveCommandEditor, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAnchorRuntimeId, getAuthoredUpdateView, getAuthoredViewCommit, getCaretOwner, getCarriedCaretEditor, getCommitDocumentValue, getCompiledEditorSchema$1 as getCompiledEditorSchema, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability$1 as getEditorAuthoredDocumentCapability, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeOwner, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getMutationVersion, getPluginContributions, getPluginSlotInput, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getStateViewPresentation$1 as getStateViewPresentation, getTextSearchScope, getValueRecords, getViewAuthor, getViewCommitSource, getViewPresentation$1 as getViewPresentation, hasNonWritableAt, holdsCaret, isAuthorId, isDocumentView, isEditorDraftView, isEditorPublishingCommit, isEnvelopeInput$1 as isEnvelopeInput, isRuntimePlugin, landNodePropertiesAt, locateAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewInteraction, nonWritableContent, nonWritableRoot, normalizeSelectorDependencies, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, publishEditorCommitInVersionOrder, publishEditorRefusal, readAuthoredView, readCaretViewIn, readCommitRootIndex, readDocumentRange, readDocumentRecord$1 as readDocumentRecord, readEditorCommitHistoryEntry, readEditorSelection, readEditorViewStateFacts, readElementPropertyWrites, readPersistedEnvelope$1 as readPersistedEnvelope, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownElementById, readShownPreview, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordEditorHistoryEffect, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError$1 as reportEditorLifecycleError, resetEditorCommitPublicationQueue, resolveLocationRoot, restoreAnchor, runEditorObserver, sameResult, sameSelectorDependencies, scheduleAfterCommitNotification, schema, selectorDependenciesViewSubscription, selectorDependenciesWantCommits, selectorDependenciesWantShownPreview, setDOMClipboardFormatKey, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, shouldSkipHistoryForOnlyProperties, skipHistoryIfOnlyProperties, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorRefusals, subscribeEditorViewState, subscribeSharedEditorViewState, subscribeShownViewUse, transfer, txLocate, txSelection, txStored, vetoesWrite, viewStateFactsChanged, visitDocumentChangeSections, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withPliteReactPreservedSelection, withStoredAuthoredRead, withTransactionSpecDraftRead };
@@ -132,7 +132,7 @@ const BaseBlockquotePlugin = definePlugin(PLUGINS.blockquote, {
132
132
  type: plugin
133
133
  }),
134
134
  mode: "lowest"
135
- })].sort((a, b) => b[1].length - a[1].length || b[1].join(".").localeCompare(a[1].join(".")));
135
+ })].sort((a, b) => PathApi.compare(b[1], a[1]));
136
136
  if (blocks.length === 0) return false;
137
137
  for (const [, path] of blocks) tx.nodes.lift({ at: path });
138
138
  return true;
@@ -3,7 +3,7 @@ import { definePlugin } from "../../../lib/plugin/definePlugin.js";
3
3
  import { defineInputRule } from "../../../lib/plugins/input-rules/defineInputRule.js";
4
4
  import { matchBlockStart } from "../../../lib/plugins/input-rules/createInputRules.js";
5
5
  import { PLUGINS } from "../../../utils/plate-keys.js";
6
- import { property, schema, txLocate } from "../../../core.js";
6
+ import { ElementApi, TextApi, property, schema, txLocate } from "../../../core.js";
7
7
  //#region src/features/basic-nodes/lib/BaseHeadingPlugins.ts
8
8
  const isHeadingLevel = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 6;
9
9
  const levelProps = (level, type, detailsTitleType) => (node) => node.type === detailsTitleType ? { level } : {
@@ -48,11 +48,32 @@ const BaseHeadingPlugin = definePlugin(PLUGINS.heading, {
48
48
  },
49
49
  markdown: {
50
50
  node: "heading",
51
- decode: ({ decode, marks, node }) => isHeadingLevel(node.depth) ? {
52
- children: decode(node.children, marks),
53
- level: node.depth,
54
- type
55
- } : void 0,
51
+ decode: ({ decode, marks, node, schema: formatSchema }) => {
52
+ if (!isHeadingLevel(node.depth)) return void 0;
53
+ const children = decode(node.children, marks);
54
+ const isDisallowedBlock = (child) => ElementApi.isElement(child) && !formatSchema.getElementBehavior(child)?.inline && !formatSchema.allowsElementType(type, child.type);
55
+ if (!children.some(isDisallowedBlock)) return {
56
+ children,
57
+ level: node.depth,
58
+ type
59
+ };
60
+ const nodes = [];
61
+ let run = [];
62
+ const flush = () => {
63
+ if (run.some((child) => !TextApi.isText(child) || child.text.trim() !== "")) nodes.push({
64
+ children: run,
65
+ level: node.depth,
66
+ type
67
+ });
68
+ run = [];
69
+ };
70
+ for (const child of children) if (isDisallowedBlock(child)) {
71
+ flush();
72
+ nodes.push(child);
73
+ } else run.push(child);
74
+ flush();
75
+ return nodes;
76
+ },
56
77
  encode: ({ encodePhrasing, node, preserve }) => {
57
78
  preserve("level");
58
79
  return {