platejs 54.0.0-beta.7 → 54.0.0-beta.9

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 (612) hide show
  1. package/THIRD_PARTY_NOTICES.md +0 -28
  2. package/dist/EditorStatic-BKBBZZn8.d.ts +771 -0
  3. package/dist/ai/index.d.ts +2 -2
  4. package/dist/ai/index.js +5 -2
  5. package/dist/ai/lib/aiDraftSession.js +984 -0
  6. package/dist/ai/{react → lib}/aiOutputLanding.internal.js +90 -96
  7. package/dist/ai/lib/aiPolicy.internal.js +403 -0
  8. package/dist/ai/lib/editorAgent.js +1696 -0
  9. package/dist/ai/lib/lockedContext.internal.js +130 -0
  10. package/dist/ai/lib/lockedContext.js +271 -0
  11. package/dist/ai/lib/registerEditorTools.js +235 -0
  12. package/dist/ai/react/AIPlugin.js +246 -0
  13. package/dist/ai/react/CopilotPlugin.js +327 -178
  14. package/dist/ai/react/copilotInline.internal.js +358 -0
  15. package/dist/ai/react/index.d.ts +200 -788
  16. package/dist/ai/react/index.js +3 -3
  17. package/dist/ai/react/useEditorAgent.js +193 -0
  18. package/dist/authored/AuthoredPlugin.js +34 -2
  19. package/dist/authored/index.d.ts +5 -4
  20. package/dist/authored/index.js +3 -2
  21. package/dist/{features/suggestion → authored}/suggestionColorOf.js +4 -4
  22. package/dist/{index-CLNem74G.d.ts → authored-BQAGqGhS-DN3sw1OP.d.ts} +101 -75
  23. package/dist/clipboard-format-key-CWuwPPe2-BJGVrNlz.d.ts +1 -0
  24. package/dist/code-block/codemirror/createCodeMirrorAdapter.js +224 -58
  25. package/dist/code-block/codemirror/index.d.ts +2 -1
  26. package/dist/comment-anchor.internal-L2GsNCIh.d.ts +28 -0
  27. package/dist/compiler/index.d.ts +9 -3
  28. package/dist/compiler/index.js +3 -1
  29. package/dist/{core-Cqc_KzpG.d.ts → core-N8rIvQxS.d.ts} +2451 -2213
  30. package/dist/core.js +4 -8
  31. package/dist/diff/index.d.ts +3 -30
  32. package/dist/docs/ai.md +475 -387
  33. package/dist/docs/api/anchor.md +1 -1
  34. package/dist/docs/api/core/plate-components.md +12 -3
  35. package/dist/docs/api/core/plate-editor.md +1 -1
  36. package/dist/docs/api/core/plate-plugin.md +40 -27
  37. package/dist/docs/api/core/plate-store.md +14 -13
  38. package/dist/docs/api/core.md +68 -92
  39. package/dist/docs/api/document-change.md +39 -28
  40. package/dist/docs/api/dom.md +66 -102
  41. package/dist/docs/api/editor-api.md +74 -42
  42. package/dist/docs/api/editor-transforms.md +17 -39
  43. package/dist/docs/api/location.md +5 -12
  44. package/dist/docs/api/plate.md +2 -2
  45. package/dist/docs/api/react-hooks.md +119 -54
  46. package/dist/docs/api/selection.md +10 -2
  47. package/dist/docs/api/utils.md +14 -14
  48. package/dist/docs/authored-changes.md +38 -33
  49. package/dist/docs/autoformat.md +4 -1
  50. package/dist/docs/basic-marks.md +0 -1
  51. package/dist/docs/block-menu.md +2 -3
  52. package/dist/docs/block-placeholder.md +2 -3
  53. package/dist/docs/board.md +28 -24
  54. package/dist/docs/bold.md +0 -2
  55. package/dist/docs/clear-formatting.md +4 -4
  56. package/dist/docs/clipboard.md +25 -18
  57. package/dist/docs/code-block.md +62 -40
  58. package/dist/docs/column.md +28 -15
  59. package/dist/docs/combobox.md +36 -51
  60. package/dist/docs/comment.md +171 -141
  61. package/dist/docs/controlled.md +5 -7
  62. package/dist/docs/copilot.md +183 -148
  63. package/dist/docs/debugging.md +5 -14
  64. package/dist/docs/discussion.md +34 -28
  65. package/dist/docs/dnd.md +7 -6
  66. package/dist/docs/document-meta.md +27 -28
  67. package/dist/docs/document-model.md +12 -11
  68. package/dist/docs/docx.md +102 -111
  69. package/dist/docs/editor-methods.md +3 -3
  70. package/dist/docs/editor.md +59 -95
  71. package/dist/docs/emoji.md +4 -5
  72. package/dist/docs/equation.md +4 -4
  73. package/dist/docs/examples/collaboration-example.md +15 -30
  74. package/dist/docs/examples/export.md +10 -9
  75. package/dist/docs/examples/version-history.md +7 -6
  76. package/dist/docs/exit-break.md +32 -59
  77. package/dist/docs/external-text.md +28 -15
  78. package/dist/docs/field.md +3 -3
  79. package/dist/docs/find.md +70 -102
  80. package/dist/docs/footnote.md +104 -92
  81. package/dist/docs/format-painter.md +1 -1
  82. package/dist/docs/history.md +49 -63
  83. package/dist/docs/html.md +69 -33
  84. package/dist/docs/indent.md +46 -34
  85. package/dist/docs/ink.md +46 -31
  86. package/dist/docs/installation/docs.md +10 -0
  87. package/dist/docs/installation/node.md +12 -8
  88. package/dist/docs/installation/plate-ui.md +12 -7
  89. package/dist/docs/line-height.md +1 -1
  90. package/dist/docs/link.md +95 -98
  91. package/dist/docs/list.md +75 -47
  92. package/dist/docs/llms.txt +14 -11
  93. package/dist/docs/lock.md +271 -0
  94. package/dist/docs/markdown.md +124 -209
  95. package/dist/docs/media.md +31 -31
  96. package/dist/docs/mention.md +6 -9
  97. package/dist/docs/multi-select.md +17 -9
  98. package/dist/docs/pagination.md +144 -127
  99. package/dist/docs/performance.md +2 -2
  100. package/dist/docs/plugin-context.md +18 -13
  101. package/dist/docs/plugin-input-rules.md +84 -125
  102. package/dist/docs/plugin-methods.md +11 -9
  103. package/dist/docs/plugin-rules.md +11 -35
  104. package/dist/docs/plugin-shortcuts.md +1 -1
  105. package/dist/docs/plugin.md +53 -2
  106. package/dist/docs/prompt-editor.md +0 -1
  107. package/dist/docs/roots.md +2 -3
  108. package/dist/docs/schema.md +12 -3
  109. package/dist/docs/selection.md +3 -1
  110. package/dist/docs/serializing.md +34 -10
  111. package/dist/docs/slash-command.md +4 -4
  112. package/dist/docs/static.md +30 -10
  113. package/dist/docs/suggestion.md +51 -71
  114. package/dist/docs/sync.md +256 -0
  115. package/dist/docs/table.md +35 -20
  116. package/dist/docs/text-align.md +4 -4
  117. package/dist/docs/toolbar.md +26 -5
  118. package/dist/docs/trailing-block.md +18 -45
  119. package/dist/docs/underline.md +2 -2
  120. package/dist/docs/unit-testing.md +1 -1
  121. package/dist/docs/upload.md +71 -36
  122. package/dist/docx/export/index.d.ts +152 -56
  123. package/dist/docx/export/lib/colors.js +268 -0
  124. package/dist/docx/export/lib/compileAst.js +1825 -0
  125. package/dist/docx/export/lib/exportDocx.js +57 -113
  126. package/dist/docx/export/lib/mathOmml.js +233 -0
  127. package/dist/docx/export/lib/ooxmlBuilder.js +1759 -0
  128. package/dist/docx/export/lib/outputSafety.js +155 -82
  129. package/dist/docx/export/lib/reviewProjection.js +31 -202
  130. package/dist/docx/export/lib/sourcePreservation.js +133 -73
  131. package/dist/docx/export/lib/wordStyles.js +399 -0
  132. package/dist/docx/import/index.d.ts +4 -4
  133. package/dist/docx/import/lib/importDocx.js +1401 -1062
  134. package/dist/docx/import/lib/opcRelationships.js +77 -0
  135. package/dist/docx/import/lib/readWordDocument.js +990 -0
  136. package/dist/docx/import/lib/wordStyles.js +534 -0
  137. package/dist/docx/internal/diagnostics.js +67 -0
  138. package/dist/docx/internal/docxPackage.js +20 -44
  139. package/dist/docx/internal/domParser.js +2 -21
  140. package/dist/docx/internal/packageParts.js +15 -16
  141. package/dist/docx/internal/readDocxNumbering.js +35 -38
  142. package/dist/docx/internal/reviewPart.js +22 -21
  143. package/dist/docx/internal/sourceEligibility.js +87 -30
  144. package/dist/docx/internal/wordMath.js +102 -137
  145. package/dist/docx/internal/xmlTree.js +262 -0
  146. package/dist/docx/internal/xmlWriter.js +44 -0
  147. package/dist/docx/paste/index.d.ts +4 -4
  148. package/dist/docx/paste/lib/WordPastePlugin.js +12 -11
  149. package/dist/dom/index.d.ts +2 -2
  150. package/dist/dom/index.js +2 -2
  151. package/dist/dom/plite-dom.internal.js +2 -2
  152. package/dist/excalidraw/index.d.ts +6 -4
  153. package/dist/excalidraw/lib/BaseExcalidrawPlugin.js +19 -7
  154. package/dist/excalidraw/react/index.d.ts +6 -4
  155. package/dist/facade.js +3 -3
  156. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +32 -12
  157. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +46 -7
  158. package/dist/features/basic-nodes/lib/BaseMarkPlugins.js +159 -81
  159. package/dist/features/basic-styles/lib/BaseStylePlugins.js +79 -82
  160. package/dist/features/board/index.d.ts +2 -2
  161. package/dist/features/board/index.js +2 -2
  162. package/dist/features/board/lib/BaseBoardArrowPlugin.js +90 -87
  163. package/dist/features/board/lib/BaseBoardFramePlugin.js +7 -7
  164. package/dist/features/board/lib/BaseBoardGeoPlugin.js +3 -2
  165. package/dist/features/board/lib/BaseBoardImagePlugin.js +9 -6
  166. package/dist/features/board/lib/BaseBoardNotePlugin.js +3 -2
  167. package/dist/features/board/lib/BaseBoardPlugin.js +368 -283
  168. package/dist/features/board/lib/BaseBoardStrokePlugin.js +8 -5
  169. package/dist/features/board/lib/BaseBoardTextPlugin.js +3 -2
  170. package/dist/features/board/lib/boardArrow.internal.js +2 -2
  171. package/dist/features/board/lib/boardCopy.internal.js +42 -36
  172. package/dist/features/board/lib/boardFrame.internal.js +5 -7
  173. package/dist/features/board/lib/boardGeometry.internal.js +124 -0
  174. package/dist/features/board/lib/boardHtml.internal.js +36 -36
  175. package/dist/features/board/lib/boardMember.internal.js +8 -8
  176. package/dist/features/board/lib/boardShape.internal.js +10 -124
  177. package/dist/features/board/lib/boardStyle.internal.js +6 -6
  178. package/dist/features/board/lib/boardTypes.internal.js +9 -0
  179. package/dist/features/callout/index.d.ts +3 -3
  180. package/dist/features/callout/lib/BaseCalloutPlugin.js +43 -2
  181. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +208 -181
  182. package/dist/features/code-block/lib/CodeBlockRules.js +133 -14
  183. package/dist/features/column/index.d.ts +2 -0
  184. package/dist/features/column/lib/BaseColumnPlugin.js +693 -0
  185. package/dist/features/comments/BaseCommentsPlugin.js +1315 -408
  186. package/dist/features/comments/comment-thread-index.internal.js +5 -4
  187. package/dist/features/comments/index.d.ts +3 -2
  188. package/dist/features/date/index.d.ts +3 -3
  189. package/dist/features/date/lib/BaseDatePlugin.js +72 -31
  190. package/dist/features/details/index.d.ts +4 -3
  191. package/dist/features/details/lib/BaseDetailsPlugin.js +226 -122
  192. package/dist/features/field/index.d.ts +1 -1
  193. package/dist/features/field/lib/BaseFieldPlugin.js +64 -48
  194. package/dist/features/field/lib/fieldRules.internal.js +6 -6
  195. package/dist/features/find/index.d.ts +98 -34
  196. package/dist/features/find/lib/BaseFindPlugin.js +939 -370
  197. package/dist/features/footnote/index.d.ts +428 -2
  198. package/dist/features/footnote/lib/BaseFootnotePlugin.js +437 -160
  199. package/dist/features/indent/lib/BaseIndentPlugin.js +222 -75
  200. package/dist/features/indent/lib/indentHtml.internal.js +9 -0
  201. package/dist/features/indent/lib/indentLevel.internal.js +3 -3
  202. package/dist/features/ink/index.d.ts +2 -2
  203. package/dist/features/ink/lib/BaseInkPlugin.js +122 -85
  204. package/dist/features/ink/lib/inkMatch.internal.js +79 -78
  205. package/dist/features/ink/lib/inkPlaces.internal.js +167 -536
  206. package/dist/features/link/lib/BaseLinkPlugin.js +504 -188
  207. package/dist/features/lint/index.d.ts +5 -5
  208. package/dist/features/lint/lib/BaseLintPlugin.js +3 -1
  209. package/dist/features/list/lib/BaseListPlugin.js +100 -691
  210. package/dist/features/list/lib/listCommands.internal.js +161 -0
  211. package/dist/features/list/lib/listFamily.internal.js +68 -23
  212. package/dist/features/list/lib/listHtml.internal.js +185 -69
  213. package/dist/features/list/lib/listIndex.internal.js +50 -20
  214. package/dist/features/list/lib/listKeyboard.internal.js +176 -0
  215. package/dist/features/list/lib/listMarkdown.internal.js +127 -0
  216. package/dist/features/list/lib/listRules.internal.js +125 -0
  217. package/dist/features/lock/index.d.ts +2 -0
  218. package/dist/features/lock/index.js +2 -0
  219. package/dist/features/lock/lib/BaseLockPlugin.js +626 -0
  220. package/dist/features/media/index.d.ts +1 -1
  221. package/dist/features/media/lib/BaseMediaPlugin.js +117 -4
  222. package/dist/features/media/lib/image/BaseImagePlugin.js +46 -10
  223. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +26 -8
  224. package/dist/features/media/lib/mediaHtml.internal.js +2 -2
  225. package/dist/features/mention/index.d.ts +4 -11
  226. package/dist/features/mention/lib/BaseMentionPlugin.js +12 -16
  227. package/dist/features/table/index.d.ts +2 -2
  228. package/dist/features/table/lib/BaseTablePlugin.js +711 -410
  229. package/dist/features/table/lib/internal/authoredProjection.js +172 -0
  230. package/dist/features/table/lib/internal/axisMove.js +152 -0
  231. package/dist/features/table/lib/internal/docxBorders.js +39 -0
  232. package/dist/features/table/lib/internal/grid.js +34 -1
  233. package/dist/features/table/lib/internal/mutation.js +18 -121
  234. package/dist/features/table/lib/internal/selection.js +114 -3
  235. package/dist/features/table/lib/internal/tabularText.js +2 -1
  236. package/dist/features/table/lib/internal/widths.js +118 -0
  237. package/dist/features/toc/index.d.ts +1 -1
  238. package/dist/features/toc/lib/BaseTocPlugin.js +42 -2
  239. package/dist/features/upload/index.d.ts +2 -2
  240. package/dist/features/upload/index.js +3 -2
  241. package/dist/features/upload/lib/BaseUploadPlugin.js +262 -298
  242. package/dist/features/upload/lib/uploadRules.internal.js +259 -0
  243. package/dist/history/index.d.ts +2 -3
  244. package/dist/html/index.d.ts +4 -3
  245. package/dist/html/server/index.d.ts +6 -2
  246. package/dist/html/server/index.js +7 -3
  247. package/dist/html/server/serverCssParser.internal.js +500 -0
  248. package/dist/html/server/serverCssStyle.internal.js +208 -0
  249. package/dist/{index-BI0NS7kx.d.ts → htmlConversion-DkPBUAhF.d.ts} +6 -3
  250. package/dist/{htmlTypes-i_FBCMf2.d.ts → htmlTypes-BtbQ2kEr.d.ts} +24 -14
  251. package/dist/hyperscript/index.d.ts +1 -1
  252. package/dist/{index-KteL56rA.d.ts → index-1OVDeYPV.d.ts} +4 -3
  253. package/dist/{index-Cc2ajXAd.d.ts → index-B32tPEDz.d.ts} +152 -83
  254. package/dist/index-BG8rVWFU.d.ts +21 -0
  255. package/dist/{index-B4ZhSQdk.d.ts → index-BTr77Bx4.d.ts} +65 -79
  256. package/dist/{index-1rcWTB-o.d.ts → index-Bjidr3Bh.d.ts} +89 -38
  257. package/dist/index-BrH9LjUL.d.ts +1 -0
  258. package/dist/index-C5UBSjnN.d.ts +3 -0
  259. package/dist/{index-CrJ9Km8W.d.ts → index-C9NdczaJ.d.ts} +9 -12
  260. package/dist/{index-1PlYsibA.d.ts → index-CQIZktRx.d.ts} +144 -55
  261. package/dist/{index-uVbqCpDa.d.ts → index-CXykQDCy.d.ts} +172 -115
  262. package/dist/{comparison-types-CsmDG5r2-z1s4gX06.d.ts → index-CkM6HC0j-Dl58Hah-.d.ts} +19 -57
  263. package/dist/{index-By7BkzIN.d.ts → index-CpPTPirx.d.ts} +2 -2
  264. package/dist/index-DFTcRJUh.d.ts +97 -0
  265. package/dist/index-DUPlSPvg.d.ts +81 -0
  266. package/dist/{index-CxG1Atvg.d.ts → index-DayqETUb.d.ts} +243 -241
  267. package/dist/{index-DNXr_SN-.d.ts → index-DlfamnX-.d.ts} +128 -230
  268. package/dist/index-DlmWL_1-.d.ts +116 -0
  269. package/dist/index-Dqd1rrEG-BSmp1a8x.d.ts +316 -0
  270. package/dist/{index-CTTjpWgb-Fdrn8NP4.d.ts → index-Du3tBg6V-CtvB7eak.d.ts} +3 -3
  271. package/dist/{index-CmISVYmz.d.ts → index-MQmrgI2L.d.ts} +20 -50
  272. package/dist/{index-Bv13FX9o.d.ts → index-SKTw56CW.d.ts} +9 -9
  273. package/dist/{index-DfkFmApH.d.ts → index-drvpTZ3S.d.ts} +743 -1532
  274. package/dist/index-vP4xFieu.d.ts +184 -0
  275. package/dist/index-zK527a0f.d.ts +57 -0
  276. package/dist/index.d.ts +4 -4
  277. package/dist/index.js +7 -11
  278. package/dist/internal/comments/comment-anchor.internal.js +636 -0
  279. package/dist/internal/plugin/OverridePlugin.js +155 -53
  280. package/dist/internal/plugin/blockInsertion.js +4 -4
  281. package/dist/internal/plugin/collectPlateNodeMappings.js +18 -8
  282. package/dist/internal/plugin/compilePlainTextMappings.js +68 -15
  283. package/dist/internal/plugin/compilePlateModel.js +56 -17
  284. package/dist/internal/plugin/compilePlateShortcuts.js +2 -1
  285. package/dist/internal/plugin/compilePluginInputMaps.js +126 -0
  286. package/dist/internal/plugin/createPlateModelPublication.js +261 -0
  287. package/dist/internal/plugin/createPlateRuntimePlugins.js +263 -0
  288. package/dist/internal/plugin/getPlateDecorationSources.js +2 -1
  289. package/dist/internal/plugin/indentShift.js +44 -0
  290. package/dist/internal/plugin/markdownParagraph.js +23 -1
  291. package/dist/internal/plugin/plateRuntime.js +9 -3
  292. package/dist/internal/plugin/pluginDescriptorSnapshot.js +178 -0
  293. package/dist/internal/plugin/pluginFormatOperation.js +8 -3
  294. package/dist/internal/plugin/pluginStore.js +4 -7
  295. package/dist/internal/plugin/resolvePlugin.js +32 -14
  296. package/dist/internal/plugin/resolvePluginGraph.js +354 -0
  297. package/dist/internal/plugin/resolvePlugins.js +19 -1135
  298. package/dist/internal/plugin/staticReuseKey.internal.js +15 -0
  299. package/dist/internal/plugin/uploadDrafts.js +6 -1
  300. package/dist/internal/utils/mergePlugins.js +6 -5
  301. package/dist/internal/utils/trustedContentSlice.js +1 -1
  302. package/dist/internal/utils/urlPolicy.js +19 -1
  303. package/dist/lib/editor/editorUser.internal.js +13 -5
  304. package/dist/lib/editor/withPlite.js +55 -44
  305. package/dist/lib/libs/zustand.js +31 -7
  306. package/dist/lib/plugin/basePluginFactory.internal.js +7 -0
  307. package/dist/lib/plugin/createPluginContext.internal.js +6 -24
  308. package/dist/lib/plugin/defineBasePlugin.internal.js +69 -9
  309. package/dist/lib/plugin/definePlugin.js +1 -1
  310. package/dist/lib/plugin/pluginFactoryRuntime.internal.js +40 -0
  311. package/dist/lib/plugins/affinity/AffinityPlugin.js +9 -8
  312. package/dist/lib/plugins/debug/DebugPlugin.js +1 -4
  313. package/dist/lib/plugins/dom/DOMPlugin.js +20 -7
  314. package/dist/lib/plugins/dom/clipboardFormatKey.internal.js +9 -0
  315. package/dist/lib/plugins/dom/isPlainTextPasteTarget.internal.js +13 -0
  316. package/dist/lib/plugins/getCorePlugins.internal.js +1 -3
  317. package/dist/lib/plugins/html/HtmlPlugin.js +30 -1747
  318. package/dist/lib/plugins/html/htmlAst.js +10 -5
  319. package/dist/lib/plugins/html/htmlConversion.js +4 -0
  320. package/dist/lib/plugins/html/htmlDecode.internal.js +891 -0
  321. package/dist/lib/plugins/html/htmlDom.js +1 -10
  322. package/dist/lib/plugins/html/htmlMatcher.internal.js +24 -1
  323. package/dist/lib/plugins/html/htmlRules.internal.js +490 -0
  324. package/dist/lib/plugins/html/htmlSerialize.internal.js +462 -0
  325. package/dist/lib/plugins/html/htmlWhitespace.internal.js +137 -0
  326. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +114 -30
  327. package/dist/lib/plugins/input-rules/createInputRules.js +64 -68
  328. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +111 -9
  329. package/dist/lib/plugins/input-rules/inputRuleVeto.js +2 -2
  330. package/dist/lib/plugins/input-rules/inputRules.internal.js +20 -0
  331. package/dist/lib/plugins/input-rules/markInputRule.internal.js +64 -2
  332. package/dist/lib/plugins/paragraph/BaseParagraphPlugin.js +21 -8
  333. package/dist/lib/utils/pluginNodeClass.js +1 -5
  334. package/dist/markdown/index.d.ts +2 -2
  335. package/dist/markdown/index.js +1 -2
  336. package/dist/markdown/lib/MarkdownPlugin.js +40 -49
  337. package/dist/markdown/lib/deserializer/convertNodesDeserialize.js +30 -6
  338. package/dist/markdown/lib/deserializer/mdastToSlate.js +2 -4
  339. package/dist/markdown/lib/internal/markdownBareLinks.js +265 -0
  340. package/dist/markdown/lib/internal/markdownBreaks.js +191 -0
  341. package/dist/markdown/lib/internal/markdownDiagnostics.js +2 -2
  342. package/dist/markdown/lib/internal/markdownDocument.js +13 -32
  343. package/dist/markdown/lib/internal/markdownIntrinsics.js +68 -228
  344. package/dist/markdown/lib/internal/markdownLine.js +134 -118
  345. package/dist/markdown/lib/internal/markdownMappings.js +178 -88
  346. package/dist/markdown/lib/internal/markdownParse.js +601 -0
  347. package/dist/markdown/lib/internal/markdownReferences.js +9 -3
  348. package/dist/markdown/lib/internal/markdownRuntime.js +353 -0
  349. package/dist/markdown/lib/internal/markdownSafety.js +101 -1
  350. package/dist/markdown/lib/internal/markdownSerialize.js +197 -0
  351. package/dist/markdown/lib/internal/markdownStream.js +1239 -0
  352. package/dist/markdown/lib/internal/markdownTags.js +52 -63
  353. package/dist/markdown/lib/internal/markdownTailHeal.js +813 -0
  354. package/dist/markdown/lib/serializer/convertNodesSerialize.js +18 -5
  355. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +134 -53
  356. package/dist/markdown/lib/serializer/listToMdastTree.js +23 -4
  357. package/dist/markdown/lib/serializer/reportOmittedProperties.js +1 -0
  358. package/dist/markdown/lib/utils/remarkPlugins.js +44 -23
  359. package/dist/math/index.d.ts +11 -11
  360. package/dist/math/lib/BaseEquationPlugin.js +99 -20
  361. package/dist/math/react/index.d.ts +4 -4
  362. package/dist/migrations/documentMigrationAuthored.internal.js +2 -1
  363. package/dist/migrations/documentMigrationSelection.internal.js +138 -2
  364. package/dist/migrations/documentMigrationTarget.internal.js +10 -2
  365. package/dist/migrations/documentMigrations.js +113 -140
  366. package/dist/migrations/index.d.ts +30 -44
  367. package/dist/migrations/index.js +1 -2
  368. package/dist/migrations/migratePlateV54.js +50 -45
  369. package/dist/migrations/migratePlateV54Ast.internal.js +180 -119
  370. package/dist/migrations/migratePlateV54BuiltIns.internal.js +2 -2
  371. package/dist/migrations/migratePlateV54CodeBlocks.internal.js +68 -34
  372. package/dist/migrations/migratePlateV54Inputs.internal.js +39 -32
  373. package/dist/migrations/migratePlateV54ListIdentity.internal.js +220 -0
  374. package/dist/migrations/migratePlateV54Profile.internal.js +52 -22
  375. package/dist/migrations/migratePlateV54RetiredMarks.internal.js +2 -2
  376. package/dist/migrations/migratePlateV54Stage.internal.js +127 -0
  377. package/dist/migrations/migratePlateV54Toggle.internal.js +66 -0
  378. package/dist/migrations/migratePlateV54Urls.internal.js +86 -57
  379. package/dist/pagination/index.d.ts +2 -167
  380. package/dist/pagination/index.js +2 -2
  381. package/dist/pagination/react/PaginationPlugin.js +278 -0
  382. package/dist/pagination/react/index.d.ts +94 -34
  383. package/dist/pagination/react/index.js +3 -5
  384. package/dist/plain-text.js +9 -12
  385. package/dist/react/authored/AuthoredReactPlugin.js +126 -0
  386. package/dist/react/authored/index.d.ts +34 -0
  387. package/dist/react/authored/index.js +3 -0
  388. package/dist/react/authored/useAuthored.js +82 -0
  389. package/dist/react/components/EditorContentView.internal.js +64 -45
  390. package/dist/react/components/EditorProvider.js +25 -24
  391. package/dist/react/components/EditorRefEffect.internal.js +56 -0
  392. package/dist/react/components/EditorRefEffect.js +12 -56
  393. package/dist/react/components/NodeSelection.js +435 -486
  394. package/dist/react/components/Plate.js +215 -168
  395. package/dist/react/components/PlateContainer.js +96 -43
  396. package/dist/react/components/PlateView.js +2 -2
  397. package/dist/{static/internal/getPlainText.js → react/components/getPlainText.internal.js} +1 -4
  398. package/dist/react/components/plate-nodes.js +49 -42
  399. package/dist/{static/internal/writeStaticSelectionClipboardData.js → react/components/writeStaticSelectionClipboardData.internal.js} +4 -5
  400. package/dist/react/core.js +7 -11
  401. package/dist/react/editor/useCreateEditor.js +19 -17
  402. package/dist/react/editor/withPlate.js +10 -13
  403. package/dist/react/features/basic-styles/BasicStylePlugins.js +2 -3
  404. package/dist/react/features/board/BoardPlugin.js +1 -1
  405. package/dist/react/features/board/BoardShape.js +51 -26
  406. package/dist/react/features/board/BoardSurface.js +1 -1
  407. package/dist/react/features/board/boardCamera.internal.js +295 -0
  408. package/dist/react/features/board/boardClipboard.internal.js +20 -20
  409. package/dist/react/features/board/boardConnect.internal.js +2 -10
  410. package/dist/react/features/board/boardExport.internal.js +5 -4
  411. package/dist/react/features/board/boardGesture.internal.js +44 -38
  412. package/dist/react/features/board/boardIndex.internal.js +1 -1
  413. package/dist/react/features/board/boardKeys.internal.js +68 -43
  414. package/dist/react/features/board/boardLanding.internal.js +147 -0
  415. package/dist/react/features/board/boardPick.internal.js +2 -2
  416. package/dist/react/features/board/boardPicking.internal.js +0 -17
  417. package/dist/react/features/board/boardPreview.internal.js +16 -2
  418. package/dist/react/features/board/boardResize.internal.js +17 -32
  419. package/dist/react/features/board/boardStyleView.internal.js +123 -0
  420. package/dist/react/features/board/boardTextFit.internal.js +311 -0
  421. package/dist/react/features/board/boardView.internal.js +333 -909
  422. package/dist/react/features/board/boardVoice.internal.js +19 -7
  423. package/dist/react/features/board/boardWindow.internal.js +138 -0
  424. package/dist/react/features/board/index.d.ts +97 -89
  425. package/dist/react/features/callout/index.d.ts +3 -3
  426. package/dist/react/features/{layout → column}/ColumnPlugin.js +4 -3
  427. package/dist/react/features/{layout → column}/index.d.ts +61 -44
  428. package/dist/react/features/combobox/combobox.internal.js +106 -0
  429. package/dist/react/features/combobox/comboboxOwner.internal.js +28 -26
  430. package/dist/react/features/combobox/index.d.ts +47 -16
  431. package/dist/react/features/combobox/useCombobox.js +50 -13
  432. package/dist/react/features/comments/CommentsPlugin.js +3 -3
  433. package/dist/react/features/comments/index.d.ts +142 -75
  434. package/dist/react/features/comments/index.js +2 -1
  435. package/dist/react/features/comments/useCommentThreadIndex.js +288 -0
  436. package/dist/react/features/date/index.d.ts +4 -4
  437. package/dist/react/features/details/index.d.ts +5 -5
  438. package/dist/react/features/field/index.d.ts +6 -5
  439. package/dist/react/features/footnote/FootnotePlugin.js +13 -8
  440. package/dist/react/features/footnote/index.d.ts +952 -105
  441. package/dist/react/features/format-painter/index.d.ts +6 -6
  442. package/dist/react/features/ink/InkContent.js +28 -100
  443. package/dist/react/features/ink/InkPlugin.js +12 -23
  444. package/dist/react/features/ink/index.d.ts +53 -106
  445. package/dist/react/features/ink/index.js +1 -2
  446. package/dist/react/features/ink/inkCapture.internal.js +107 -65
  447. package/dist/react/features/ink/inkImages.internal.js +20 -5
  448. package/dist/react/features/ink/inkMeasure.internal.js +35 -22
  449. package/dist/react/features/ink/inkPlacement.internal.js +78 -203
  450. package/dist/react/features/ink/inkWatch.internal.js +1 -32
  451. package/dist/react/features/list/ListPlugin.js +68 -36
  452. package/dist/react/features/lock/LockPlugin.js +105 -0
  453. package/dist/react/features/lock/index.d.ts +58 -0
  454. package/dist/react/features/lock/index.js +2 -0
  455. package/dist/react/features/media/index.d.ts +10 -10
  456. package/dist/react/features/mention/index.d.ts +4 -11
  457. package/dist/react/features/table/TablePlugin.js +215 -61
  458. package/dist/react/features/table/index.d.ts +158 -59
  459. package/dist/react/features/table/index.js +2 -1
  460. package/dist/react/features/table/measureTableColumnWidths.internal.js +44 -0
  461. package/dist/react/features/table/useTableControls.js +897 -0
  462. package/dist/react/features/table/useTableResize.js +33 -16
  463. package/dist/react/features/toc/index.d.ts +8 -11
  464. package/dist/react/features/upload/UploadPlugin.js +12 -3
  465. package/dist/react/features/upload/index.d.ts +36 -97
  466. package/dist/react/index.d.ts +7 -5
  467. package/dist/react/index.js +11 -15
  468. package/dist/react/internal/plate-context.js +118 -68
  469. package/dist/react/internal/useDeepCompareMemo.js +36 -7
  470. package/dist/react/internal/usePlateModelRevision.js +12 -7
  471. package/dist/react/plite-react.js +2 -2
  472. package/dist/react/plugin/pluginFactory.internal.js +1 -37
  473. package/dist/react/plugin/toReactPlugin.js +15 -4
  474. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +2 -2
  475. package/dist/react/stores/element/useElement.js +2 -2
  476. package/dist/react/stores/element/useElementSelector.js +4 -2
  477. package/dist/react/stores/element/useElementStore.js +96 -86
  478. package/dist/react/stores/element/useElementStoreSelector.internal.js +80 -24
  479. package/dist/react/stores/element/usePath.js +32 -32
  480. package/dist/react/stores/plate/pluginStoreSelector.internal.js +44 -0
  481. package/dist/react/stores/plate/useEditor.js +62 -89
  482. package/dist/react/stores/plate/useEditorSelector.js +17 -204
  483. package/dist/react/stores/plate/usePluginStore.js +36 -43
  484. package/dist/react/stores/plate/useViewStore.js +38 -23
  485. package/dist/react/utils/BlockPlaceholderPlugin.js +13 -4
  486. package/dist/react/utils/pipeHandler.internal.js +20 -7
  487. package/dist/react/utils/pipeRenderElement.internal.js +32 -30
  488. package/dist/react/utils/pipeRenderLeaf.internal.js +1 -2
  489. package/dist/react/utils/pipeRenderText.internal.js +1 -1
  490. package/dist/react/utils/useSelectionFragment.js +8 -2
  491. package/dist/react/virtualized.d.ts +6 -5
  492. package/dist/refusal-CBecclcb-BJGVrNlz.d.ts +1 -0
  493. package/dist/registerEditorTools-dPLJZ0PP.d.ts +386 -0
  494. package/dist/root.js +7 -11
  495. package/dist/skills/plate/SKILL.md +43 -0
  496. package/dist/{source-Dcgqj5Mf.d.ts → source-BnYE-ryK.d.ts} +14 -14
  497. package/dist/static/components/{PlateStatic.js → EditorStatic.js} +86 -31
  498. package/dist/static/components/plite-nodes.js +32 -12
  499. package/dist/static/index.d.ts +24 -20
  500. package/dist/static/index.js +1 -1
  501. package/dist/static/internal/loadStaticRenderer.js +4 -0
  502. package/dist/static/internal/staticDocumentView.js +8 -5
  503. package/dist/static/internal/staticPendingMedia.internal.js +136 -0
  504. package/dist/static/internal/staticPresentation.js +12 -12
  505. package/dist/static/pipeRenderElementStatic.internal.js +2 -10
  506. package/dist/static/pluginRenderElementStatic.internal.js +28 -5
  507. package/dist/static/pluginRenderLeafStatic.internal.js +4 -3
  508. package/dist/static/pluginRenderTextStatic.internal.js +3 -1
  509. package/dist/static/renderStaticHtml.js +31 -2
  510. package/dist/static/utils/getRenderNodeStaticProps.internal.js +8 -3
  511. package/dist/sync/SyncPlugin.js +16 -0
  512. package/dist/sync/cloudflare/index.d.ts +56 -0
  513. package/dist/sync/cloudflare/index.js +2 -0
  514. package/dist/sync/index.d.ts +3 -0
  515. package/dist/sync/index.js +3 -0
  516. package/dist/sync/react/SyncReactPlugin.js +20 -0
  517. package/dist/sync/react/hooks.js +64 -0
  518. package/dist/{yjs → sync}/react/index.d.ts +74 -68
  519. package/dist/sync/react/index.js +4 -0
  520. package/dist/sync/server/index.d.ts +3 -0
  521. package/dist/sync/server/index.js +2 -0
  522. package/dist/tabbable/index.d.ts +1 -1
  523. package/dist/tabbable/react/TabbableEffects.internal.js +5 -5
  524. package/dist/tabbable/react/index.d.ts +3 -3
  525. package/dist/testing/index.d.ts +7 -6
  526. package/dist/transport-CRrArpJZ-Bm6uVAsa.d.ts +115 -0
  527. package/dist/{tx-only-1FM45FSj-D40jacZv.d.ts → tx-only-DXWFNuXJ-DuOaZk8U.d.ts} +2818 -2677
  528. package/dist/utils/plate-keys.js +2 -8
  529. package/dist/utils/plugins/TrailingBlockPlugin.js +10 -7
  530. package/dist/utils/plugins/resolveTrailingBlockType.internal.js +8 -0
  531. package/package.json +61 -115
  532. package/dist/AIChatRequestContext-DVGOeWhQ.d.ts +0 -34
  533. package/dist/BaseSuggestionPlugin-BRFMMyEo.d.ts +0 -91
  534. package/dist/PlateStatic-DIwBAVqF.d.ts +0 -19
  535. package/dist/ai/lib/AIChatRequestContext.js +0 -16
  536. package/dist/ai/lib/findQuotedSpan.internal.js +0 -63
  537. package/dist/ai/react/AIChatPlugin.js +0 -1244
  538. package/dist/ai/react/useAIChat.js +0 -332
  539. package/dist/combobox-CfCJYKT0.d.ts +0 -22
  540. package/dist/docs/yjs.md +0 -256
  541. package/dist/docx/export/lib/comments.js +0 -311
  542. package/dist/docx/export/lib/docxStaticComponents.js +0 -381
  543. package/dist/docx/export/lib/exportHtmlToDocx.internal.js +0 -70
  544. package/dist/docx/export/lib/generatedParts.js +0 -51
  545. package/dist/docx/export/lib/hostIndex.js +0 -92
  546. package/dist/docx/export/lib/html-to-docx.internal.js +0 -40
  547. package/dist/docx/export/lib/internal/constants.js +0 -106
  548. package/dist/docx/export/lib/internal/docx-document.js +0 -652
  549. package/dist/docx/export/lib/internal/escape-xml.js +0 -4
  550. package/dist/docx/export/lib/internal/html-to-docx.js +0 -148
  551. package/dist/docx/export/lib/internal/list-item.js +0 -85
  552. package/dist/docx/export/lib/internal/list.js +0 -43
  553. package/dist/docx/export/lib/internal/math.js +0 -187
  554. package/dist/docx/export/lib/internal/namespaces.js +0 -40
  555. package/dist/docx/export/lib/internal/render-document-file.js +0 -403
  556. package/dist/docx/export/lib/internal/schemas/content-types.js +0 -25
  557. package/dist/docx/export/lib/internal/schemas/core.js +0 -26
  558. package/dist/docx/export/lib/internal/schemas/document-rels.js +0 -15
  559. package/dist/docx/export/lib/internal/schemas/document.template.js +0 -36
  560. package/dist/docx/export/lib/internal/schemas/font-table.js +0 -55
  561. package/dist/docx/export/lib/internal/schemas/generic-rels.js +0 -9
  562. package/dist/docx/export/lib/internal/schemas/numbering.js +0 -18
  563. package/dist/docx/export/lib/internal/schemas/rels.js +0 -12
  564. package/dist/docx/export/lib/internal/schemas/settings.js +0 -17
  565. package/dist/docx/export/lib/internal/schemas/styles.js +0 -142
  566. package/dist/docx/export/lib/internal/schemas/theme.js +0 -198
  567. package/dist/docx/export/lib/internal/schemas/web-settings.js +0 -10
  568. package/dist/docx/export/lib/internal/unit-conversion.js +0 -24
  569. package/dist/docx/export/lib/internal/vnode.js +0 -4
  570. package/dist/docx/export/lib/internal/word-styles.js +0 -123
  571. package/dist/docx/export/lib/internal/xml-builder.js +0 -1803
  572. package/dist/docx/export/lib/reviewPart.js +0 -234
  573. package/dist/docx/import/lib/wordFormatting.js +0 -608
  574. package/dist/features/combobox/index.d.ts +0 -3
  575. package/dist/features/combobox/index.js +0 -2
  576. package/dist/features/combobox/lib/combobox.internal.js +0 -111
  577. package/dist/features/combobox/lib/filterWords.js +0 -23
  578. package/dist/features/ink/lib/inkGone.internal.js +0 -290
  579. package/dist/features/layout/index.d.ts +0 -2
  580. package/dist/features/layout/lib/BaseColumnPlugin.js +0 -249
  581. package/dist/features/suggestion/BaseSuggestionPlugin.js +0 -31
  582. package/dist/features/suggestion/index.d.ts +0 -10
  583. package/dist/features/suggestion/index.js +0 -3
  584. package/dist/features/upload/lib/mimeTypes.internal.js +0 -3982
  585. package/dist/index-BWCC4DCP.d.ts +0 -156
  586. package/dist/index-CJGkjkH6.d.ts +0 -8
  587. package/dist/index-CS4G_W_R.d.ts +0 -184
  588. package/dist/index-CVAHIQ3p.d.ts +0 -29
  589. package/dist/index-OMa7dlcS.d.ts +0 -161
  590. package/dist/lib/plugins/element-state/ElementStatePlugin.js +0 -14
  591. package/dist/lib/utils/hotkeys.js +0 -113
  592. package/dist/markdown/lib/RawHtmlPlugin.js +0 -26
  593. package/dist/markdown/lib/internal/markdownConversion.js +0 -1358
  594. package/dist/markdown/lib/internal/markdownOpenTail.js +0 -381
  595. package/dist/markdown/lib/internal/markdownRawHtml.js +0 -353
  596. package/dist/markdown/lib/internal/markdownSegments.js +0 -143
  597. package/dist/migrations/migrateListIdentity.js +0 -93
  598. package/dist/pagination/react/PagedEditorContent.js +0 -77
  599. package/dist/react/features/ink/InkCopyView.js +0 -214
  600. package/dist/react/features/suggestion/SuggestionPlugin.js +0 -24
  601. package/dist/react/features/suggestion/index.d.ts +0 -45
  602. package/dist/react/features/suggestion/index.js +0 -3
  603. package/dist/react/features/suggestion/suggestion-view.internal.js +0 -114
  604. package/dist/react/features/suggestion/useSuggestion.js +0 -138
  605. package/dist/static/internal/renderStaticHtmlWithOverrides.js +0 -33
  606. package/dist/utils/plugins/ExitBreakPlugin.js +0 -26
  607. package/dist/yjs/index.d.ts +0 -2
  608. package/dist/yjs/index.js +0 -1
  609. package/dist/yjs/react/YjsPlugin.js +0 -60
  610. package/dist/yjs/react/index.js +0 -3
  611. /package/dist/features/{layout → column}/index.js +0 -0
  612. /package/dist/react/features/{layout → column}/index.js +0 -0
@@ -1,5 +1,6 @@
1
1
  import { definePlugin } from "../../lib/plugin/definePlugin.js";
2
- import { compileMatcher, matches } from "../../lib/plugins/html/htmlMatcher.internal.js";
2
+ import { isHtmlBlockElement } from "../../lib/plugins/html/htmlDom.js";
3
+ import { compileMatcher, isHtmlContainerBoundary, isHtmlMappedBlock, matches } from "../../lib/plugins/html/htmlMatcher.internal.js";
3
4
  import { BaseParagraphPlugin } from "../../lib/plugins/paragraph/BaseParagraphPlugin.js";
4
5
  import { defineInputRule } from "../../lib/plugins/input-rules/defineInputRule.js";
5
6
  import { createBlockFenceInputRule, matchDelimitedInline } from "../../lib/plugins/input-rules/createInputRules.js";
@@ -9,15 +10,15 @@ import { rebuildTexFromMathml } from "./mathmlTex.internal.js";
9
10
  //#region src/math/lib/BaseEquationPlugin.ts
10
11
  const INLINE_EQUATION_BOUNDARY_RE = /[\s([{'"`]/;
11
12
  const INLINE_EQUATION_FOLLOW_RE = /[\s)\]}:;,.!?'"`]/;
12
- const EQUATION_ATTRIBUTES = ["data-editor-equation", "data-editor-equation-latex"];
13
- const EQUATION_SELECTOR = "math, [data-editor-equation]";
14
- const BLOCK_EQUATION_MATCH = [{ attributes: { "data-editor-equation": "block" } }, {
13
+ const EQUATION_ATTRIBUTES = ["data-editor-html-equation", "data-editor-html-equation-latex"];
14
+ const EQUATION_SELECTOR = "math, [data-editor-html-equation]";
15
+ const BLOCK_EQUATION_MATCH = [{ attributes: { "data-editor-html-equation": "block" } }, {
15
16
  attributes: { display: "block" },
16
17
  tag: "math"
17
18
  }];
18
19
  const BLOCK_EQUATION_MATCHERS = BLOCK_EQUATION_MATCH.map((matcher, index) => compileMatcher(PLUGINS.equation, matcher, index));
19
20
  const readEquationTex = (element) => {
20
- const latex = element.getAttribute("data-editor-equation-latex");
21
+ const latex = element.getAttribute("data-editor-html-equation-latex");
21
22
  if (latex !== null) return latex;
22
23
  for (const annotation of element.querySelectorAll("annotation[encoding=\"application/x-tex\"]")) if (annotation.closest("math") === element) return annotation.textContent ?? "";
23
24
  if (!element.getAttribute("typeof")?.split(/[\t\n\f\r ]+/u).includes("mw:Extension/math")) return;
@@ -102,7 +103,39 @@ const prepareEquationHtml = ({ document, registry, report }) => {
102
103
  block: math.getAttribute("display") === "block",
103
104
  math
104
105
  }));
105
- for (const { block, math } of formulas) if (block && (!hasBlock || math.closest("li, h1, h2, h3, h4, h5, h6"))) math.removeAttribute("display");
106
+ const hasVisibleContent = (node) => {
107
+ if (node.nodeType === 3) return (node.textContent ?? "").trim().length > 0;
108
+ if (node.nodeType !== 1) return false;
109
+ const el = node;
110
+ if (el.hasAttribute("data-editor-spacer")) return false;
111
+ if (el.tagName === "BR") return !el.classList.contains("Apple-interchange-newline");
112
+ if (isHtmlMappedBlock(el) || el.tagName === "IMG" || el.tagName === "HR" || el.tagName === "TABLE" || el.tagName === "MATH" || el.tagName === "VIDEO" || el.tagName === "AUDIO" || el.tagName === "IFRAME" || el.tagName === "CANVAS") return true;
113
+ return Array.from(el.childNodes).some(hasVisibleContent);
114
+ };
115
+ const containsBlockOrMappedBlock = (node) => {
116
+ if (node.nodeType !== 1) return false;
117
+ const el = node;
118
+ if (el.hasAttribute("data-editor-spacer")) return false;
119
+ if (isHtmlBlockElement(el) || isHtmlMappedBlock(el)) return true;
120
+ return Array.from(el.childNodes).some(containsBlockOrMappedBlock);
121
+ };
122
+ const isInListItemHead = (math) => {
123
+ let container = math.parentElement;
124
+ while (container && container.tagName !== "LI" && !isHtmlContainerBoundary(container)) container = container.parentElement;
125
+ if (container?.tagName !== "LI") return false;
126
+ let current = math;
127
+ while (current && current !== container) {
128
+ const currentIsBlock = current !== math && isHtmlBlockElement(current);
129
+ for (let sibling = current.previousSibling; sibling; sibling = sibling.previousSibling) {
130
+ if (!hasVisibleContent(sibling)) continue;
131
+ if (containsBlockOrMappedBlock(sibling)) return false;
132
+ if (currentIsBlock) return false;
133
+ }
134
+ current = current.parentElement;
135
+ }
136
+ return true;
137
+ };
138
+ for (const { block, math } of formulas) if (block && (!hasBlock || math.closest("h1, h2, h3, h4, h5, h6") || isInListItemHead(math))) math.removeAttribute("display");
106
139
  const katexes = Array.from(body.querySelectorAll("span.katex")).flatMap((katex) => {
107
140
  const math = readEquationTex(katex) === void 0 ? readKatexOutputMath(katex) : void 0;
108
141
  return math ? [{
@@ -112,7 +145,7 @@ const prepareEquationHtml = ({ document, registry, report }) => {
112
145
  });
113
146
  const katexMaths = new Set(katexes.map(({ math }) => math));
114
147
  const carriesTex = (math) => {
115
- for (let carrier = math.parentElement?.closest("[data-editor-equation]"); carrier; carrier = carrier.parentElement?.closest("[data-editor-equation]")) if (readEquationTex(carrier) !== void 0) return true;
148
+ for (let carrier = math.parentElement?.closest("[data-editor-html-equation]"); carrier; carrier = carrier.parentElement?.closest("[data-editor-html-equation]")) if (readEquationTex(carrier) !== void 0) return true;
116
149
  return false;
117
150
  };
118
151
  const warnings = /* @__PURE__ */ new Map();
@@ -125,7 +158,7 @@ const prepareEquationHtml = ({ document, registry, report }) => {
125
158
  refusals.set(math, rebuilt.element.localName);
126
159
  continue;
127
160
  }
128
- math.setAttribute("data-editor-equation-latex", rebuilt.tex);
161
+ math.setAttribute("data-editor-html-equation-latex", rebuilt.tex);
129
162
  if (rebuilt.kind === "approximate" || rebuilt.picks.length > 0) warnings.set(math, rebuildWarning(rebuilt));
130
163
  }
131
164
  const kept = /* @__PURE__ */ new Set();
@@ -168,17 +201,18 @@ const prepareEquationHtml = ({ document, registry, report }) => {
168
201
  });
169
202
  unwrapped.add(link);
170
203
  }
171
- const indent = element.closest("p")?.getAttribute("data-indent");
172
- if (isMath && element.getAttribute("display") === "block" && indent && !element.hasAttribute("data-indent")) indents.push([element, indent]);
204
+ const indent = element.closest("p")?.getAttribute("data-editor-html-indent");
205
+ if (isMath && element.getAttribute("display") === "block" && indent && !element.hasAttribute("data-editor-html-indent")) indents.push([element, indent]);
173
206
  }
174
207
  for (const { katex, math } of katexes) {
175
- if (!kept.has(math)) continue;
208
+ const carrier = katex.closest("[data-editor-html-equation]");
209
+ if (!kept.has(math) && !(carrier && kept.has(carrier))) continue;
176
210
  const display = katex.parentElement;
177
211
  (display?.classList.contains("katex-display") && holdsOnly(display, (node) => node === katex) ? display : katex).replaceWith(math);
178
212
  }
179
213
  for (const math of dropped) math.remove();
180
214
  for (const link of unwrapped) link.replaceWith(...Array.from(link.childNodes));
181
- for (const [math, indent] of indents) math.setAttribute("data-indent", indent);
215
+ for (const [math, indent] of indents) math.setAttribute("data-editor-html-indent", indent);
182
216
  };
183
217
  const decodeEquationHtml = ({ element, preserve }) => {
184
218
  const latex = readEquationTex(element);
@@ -191,14 +225,33 @@ const decodeEquationHtml = ({ element, preserve }) => {
191
225
  };
192
226
  const BaseEquationPlugin = definePlugin(PLUGINS.equation, {
193
227
  formats: ({ defineFormats, schema: { type } }) => defineFormats({
228
+ docx: {
229
+ decode: ({ node }) => ({
230
+ children: [{ text: "" }],
231
+ latex: node.latex,
232
+ type
233
+ }),
234
+ encode: ({ node }) => node.latex ? {
235
+ kind: "blockEquation",
236
+ latex: node.latex
237
+ } : {
238
+ children: [{
239
+ kind: "text",
240
+ placeholder: "equation",
241
+ text: "[Empty equation]"
242
+ }],
243
+ kind: "paragraph"
244
+ },
245
+ node: "blockEquation"
246
+ },
194
247
  html: {
195
248
  decode: decodeEquationHtml,
196
249
  encode: ({ content, node, preserve }) => {
197
250
  preserve("latex");
198
251
  return {
199
252
  attributes: {
200
- "data-editor-equation": "block",
201
- "data-editor-equation-latex": node.latex
253
+ "data-editor-html-equation": "block",
254
+ "data-editor-html-equation-latex": node.latex
202
255
  },
203
256
  children: [content, { text: `$$${node.latex}$$` }],
204
257
  tag: "div"
@@ -235,20 +288,36 @@ const BaseEquationPlugin = definePlugin(PLUGINS.equation, {
235
288
  });
236
289
  const BaseInlineEquationPlugin = definePlugin(PLUGINS.inlineEquation, {
237
290
  formats: ({ defineFormats, schema: { type } }) => defineFormats({
291
+ docx: {
292
+ decode: ({ node }) => ({
293
+ children: [{ text: "" }],
294
+ latex: node.latex,
295
+ type
296
+ }),
297
+ encode: ({ node }) => node.latex ? {
298
+ kind: "inlineEquation",
299
+ latex: node.latex
300
+ } : {
301
+ kind: "text",
302
+ placeholder: "equation",
303
+ text: "[equation]"
304
+ },
305
+ node: "inlineEquation"
306
+ },
238
307
  html: {
239
308
  decode: decodeEquationHtml,
240
309
  encode: ({ content, node, preserve }) => {
241
310
  preserve("latex");
242
311
  return {
243
312
  attributes: {
244
- "data-editor-equation": true,
245
- "data-editor-equation-latex": node.latex
313
+ "data-editor-html-equation": true,
314
+ "data-editor-html-equation-latex": node.latex
246
315
  },
247
316
  children: [content, { text: `$${node.latex}$` }],
248
317
  tag: "span"
249
318
  };
250
319
  },
251
- match: [{ attributes: { "data-editor-equation": true } }, { tag: "math" }],
320
+ match: [{ attributes: { "data-editor-html-equation": true } }, { tag: "math" }],
252
321
  prepareDocument: prepareEquationHtml,
253
322
  priority: 11
254
323
  },
@@ -284,13 +353,17 @@ const BaseInlineEquationPlugin = definePlugin(PLUGINS.inlineEquation, {
284
353
  }, options);
285
354
  }) }) }));
286
355
  const MathRules = (() => {
287
- const isEnabled = (context, enabled) => (!enabled || enabled(context)) && !context.editor.read.nodes.some({ type: [BaseEquationPlugin, BaseInlineEquationPlugin] });
356
+ const isEnabled = (context, enabled) => {
357
+ if (enabled && !enabled(context)) return false;
358
+ const equationPlugins = [BaseEquationPlugin, BaseInlineEquationPlugin].filter((plugin) => context.editor.plugin(plugin).installed);
359
+ return equationPlugins.length === 0 || !context.editor.read.nodes.some({ type: equationPlugins });
360
+ };
288
361
  const blockRule = ({ block = BaseParagraphPlugin, enabled, fence = "$$", on, priority = 100 }) => createBlockFenceInputRule({
289
362
  block,
290
363
  fence,
291
364
  on,
292
365
  priority,
293
- enabled: (context) => isEnabled(context, enabled),
366
+ enabled: (context) => context.editor.plugin(BaseEquationPlugin).installed && isEnabled(context, enabled),
294
367
  apply: ({ editor, tx }, match) => {
295
368
  tx.nodes.remove({ at: match.path });
296
369
  tx.nodes.insert({
@@ -307,7 +380,7 @@ const MathRules = (() => {
307
380
  target: "insertText",
308
381
  trigger: "$",
309
382
  priority,
310
- enabled: (context) => isEnabled(context, enabled),
383
+ enabled: (context) => context.editor.plugin(BaseInlineEquationPlugin).installed && isEnabled(context, enabled),
311
384
  resolve: (context) => {
312
385
  const match = matchDelimitedInline(context, {
313
386
  boundaryRe: INLINE_EQUATION_BOUNDARY_RE,
@@ -317,6 +390,12 @@ const MathRules = (() => {
317
390
  trim: "reject"
318
391
  });
319
392
  if (!match) return void 0;
393
+ const inlineEquation = {
394
+ children: [{ text: "" }],
395
+ latex: match.content,
396
+ type: context.editor.plugin(BaseInlineEquationPlugin).schema.type
397
+ };
398
+ if (!context.editor.read.schema.canWrap(inlineEquation, { at: match.deleteRange.anchor })) return;
320
399
  return {
321
400
  deleteRange: match.deleteRange,
322
401
  latex: match.content
@@ -1,7 +1,7 @@
1
- import { ms as PropertyStringDescriptor, vu as TxDeclaredMethod } from "../../tx-only-1FM45FSj-D40jacZv.js";
2
- import "../../htmlTypes-i_FBCMf2.js";
3
- import { vt as NodeInsertOptions } from "../../core-Cqc_KzpG.js";
4
- import { kt as Plugin } from "../../index-DfkFmApH.js";
1
+ import { Vl as TxDeclaredMethod, Yo as PropertyStringDescriptor } from "../../tx-only-DXWFNuXJ-DuOaZk8U.js";
2
+ import "../../htmlTypes-BtbQ2kEr.js";
3
+ import { wt as NodeInsertOptions } from "../../core-N8rIvQxS.js";
4
+ import { Ct as Plugin } from "../../index-drvpTZ3S.js";
5
5
  declare const EquationPlugin: Plugin<Readonly<{
6
6
  formats: true;
7
7
  }> & Readonly<{
@@ -4,7 +4,8 @@ const registerDocumentMigrationAuthoredCapability = (target, capability, schema)
4
4
  authoredCapabilities.set(target, Object.freeze({
5
5
  pending: capability.pending,
6
6
  projectDecided: (document, projection) => capability.projectDecided(document, projection, schema),
7
- repair: (document) => capability.repair(document, schema)
7
+ repair: (document) => capability.repair(document, schema),
8
+ repairWithChange: (document) => capability.repairWithChange(document, schema, { elementIds: "mint" })
8
9
  }));
9
10
  };
10
11
  /** The target's authored capability, when it installs the authored plugin. */
@@ -1,4 +1,4 @@
1
- import { ElementApi, SelectionApi, TextApi } from "../facade.js";
1
+ import { ElementApi, PathApi, RangeApi, SelectionApi, TextApi, assertDetachedSelectionSupported, mapDetachedSelectionThroughChange, readDocumentRange, snapshotEditorJsonValue } from "../facade.js";
2
2
  //#region src/migrations/documentMigrationSelection.internal.ts
3
3
  const textAt = (children, path) => {
4
4
  let node;
@@ -23,5 +23,141 @@ const landSelectionMarks = (schema, selection, marks, value) => marks === void 0
23
23
  value
24
24
  })
25
25
  });
26
+ const isConcreteSelection = (selection) => selection !== void 0 && selection !== null && selection !== "start" && selection !== "end";
27
+ const assertHistoricalSelection = (schema, selection, document) => {
28
+ if (selection === void 0 || selection === null) return;
29
+ if (selection === "start" || selection === "end") return;
30
+ assertDetachedSelectionSupported(schema, historicalSelectionGeometry(selection), document, SelectionApi.root(selection) ?? "main");
31
+ };
32
+ const mapDetachedStepSelection = (schema, selection, change, before, after) => {
33
+ const geometry = historicalSelectionGeometry(selection);
34
+ const mapped = mapDetachedSelectionThroughChange(schema, geometry, change, before, after, SelectionApi.root(selection) ?? "main", {
35
+ association: "backward",
36
+ preferPositionMapping: true
37
+ });
38
+ if (mapped === geometry) return selection;
39
+ return landSelectionMarks(schema, mapped, SelectionApi.isText(selection) ? selection.marks : void 0, after);
40
+ };
41
+ const rangeCoversContent = (children, range, schema) => {
42
+ const [start, end] = RangeApi.edges(range);
43
+ let covered = false;
44
+ const visit = (nodes, parent) => {
45
+ if (covered) return;
46
+ const first = PathApi.isCommon(parent, start.path) ? start.path[parent.length] ?? 0 : 0;
47
+ for (let index = first; index < nodes.length; index += 1) {
48
+ if (covered) return;
49
+ const node = nodes[index];
50
+ const path = [...parent, index];
51
+ if (PathApi.isAfter(path, end.path)) return;
52
+ if (ElementApi.isElement(node)) {
53
+ if (schema?.isVoid(node) && !PathApi.isAncestor(path, start.path) && !PathApi.isAncestor(path, end.path) && !PathApi.equals(path, start.path) && !PathApi.equals(path, end.path)) {
54
+ covered = true;
55
+ return;
56
+ }
57
+ visit(node.children, path);
58
+ } else if (TextApi.isText(node)) {
59
+ const from = PathApi.equals(path, start.path) ? start.offset : 0;
60
+ if ((PathApi.equals(path, end.path) ? end.offset : node.text.length) > from) {
61
+ covered = true;
62
+ return;
63
+ }
64
+ }
65
+ }
66
+ };
67
+ visit(children, []);
68
+ return covered;
69
+ };
70
+ const isTextPoint = (children, point) => {
71
+ const text = textAt(children, point.path);
72
+ return text !== void 0 && Number.isInteger(point.offset) && point.offset >= 0 && point.offset <= text.text.length;
73
+ };
74
+ const readRange = (value, label) => {
75
+ if (value === null) return null;
76
+ const range = readDocumentRange(snapshotEditorJsonValue(value, label), "saved");
77
+ if (!range) throw new Error(`${label} must be a document range or null.`);
78
+ return range;
79
+ };
80
+ const rootHolding = (document, range) => {
81
+ const root = SelectionApi.root(range);
82
+ const roots = document.roots ?? {};
83
+ const children = root === void 0 ? document.children : Object.hasOwn(roots, root) ? roots[root] : void 0;
84
+ return children && isTextPoint(children, range.anchor) && isTextPoint(children, range.focus) ? children : null;
85
+ };
86
+ const savedRangeOrNull = (value, document, schema) => {
87
+ const range = readDocumentRange(value, "saved");
88
+ const children = range && rootHolding(document, range);
89
+ return range && children && rangeCoversContent(children, range, schema) ? range : null;
90
+ };
91
+ const readCoveringRange = (value, document, label, schema) => {
92
+ const range = readRange(value, label);
93
+ if (!range) return null;
94
+ const children = rootHolding(document, range);
95
+ if (!children) throw new Error(`${label} ${JSON.stringify(range)} points outside the document.`);
96
+ return rangeCoversContent(children, range, schema) ? range : null;
97
+ };
98
+ const uncrossedRange = (source, range) => range && RangeApi.isBackward(range) === RangeApi.isBackward(source) && SelectionApi.root(range) === SelectionApi.root(source) ? range : null;
99
+ const mapRangesThroughChange = (schema, ranges, change, before, after) => {
100
+ if (change.empty) return ranges;
101
+ return ranges.map((range) => {
102
+ if (!range) return null;
103
+ const mapped = mapDetachedSelectionThroughChange(schema, SelectionApi.text(range), change, before, after, SelectionApi.root(range) ?? "main", {
104
+ association: "backward",
105
+ preferPositionMapping: true
106
+ });
107
+ const nextRange = mapped && SelectionApi.isText(mapped) ? {
108
+ anchor: mapped.anchor,
109
+ focus: mapped.focus
110
+ } : null;
111
+ const uncrossed = uncrossedRange(range, nextRange);
112
+ if (!uncrossed) return null;
113
+ const children = rootHolding(after, uncrossed);
114
+ return children && rangeCoversContent(children, uncrossed, schema) ? uncrossed : null;
115
+ });
116
+ };
117
+ const mapLiveRanges = (ranges, values, map) => {
118
+ let next = 0;
119
+ return ranges.map((range) => {
120
+ if (!range) return null;
121
+ const value = values[next];
122
+ next += 1;
123
+ return map(range, value);
124
+ });
125
+ };
126
+ const mapStepRanges = (to, ranges, mapRanges, change, after, schema) => {
127
+ const live = ranges.flatMap((range) => range ? [range] : []);
128
+ if (live.length === 0) return ranges;
129
+ if (!mapRanges) return change().empty ? ranges : ranges.map(() => null);
130
+ const mapped = mapRanges(Object.freeze({ ranges: Object.freeze(live) }));
131
+ if (!Array.isArray(mapped) || mapped.length !== live.length) throw new Error(`Document migration step ${to} mapRanges must return one range or null per range.`);
132
+ return mapLiveRanges(ranges, mapped, (range, value) => uncrossedRange(range, readCoveringRange(value, after, `Document migration step ${to} range`, schema)));
133
+ };
134
+ const edgePoint = (children, edge) => {
135
+ const visit = (nodes, parent) => {
136
+ const indexes = edge === "start" ? nodes.map((_, index) => index) : nodes.map((_, index) => index).reverse();
137
+ for (const index of indexes) {
138
+ const node = nodes[index];
139
+ if (!node || typeof node !== "object") continue;
140
+ const path = [...parent, index];
141
+ if (typeof node.text === "string") return Object.freeze({
142
+ offset: edge === "start" ? 0 : node.text.length,
143
+ path: Object.freeze(path)
144
+ });
145
+ if (ElementApi.isElement(node)) {
146
+ const point = visit(node.children, path);
147
+ if (point) return point;
148
+ }
149
+ }
150
+ return null;
151
+ };
152
+ return visit(children, []);
153
+ };
154
+ const resolveSelection = (selection, document) => {
155
+ if (selection !== "start" && selection !== "end") return selection;
156
+ const point = edgePoint(document.children, selection);
157
+ return point ? SelectionApi.text({
158
+ anchor: point,
159
+ focus: point
160
+ }) : null;
161
+ };
26
162
  //#endregion
27
- export { historicalSelectionGeometry, landSelectionMarks, textAt };
163
+ export { assertHistoricalSelection, historicalSelectionGeometry, isConcreteSelection, landSelectionMarks, mapDetachedStepSelection, mapLiveRanges, mapRangesThroughChange, mapStepRanges, readCoveringRange, resolveSelection, savedRangeOrNull, textAt, uncrossedRange };
@@ -2,10 +2,18 @@ import { failInvariant } from "../internal/failInvariant.js";
2
2
  import { getPluginSchemaFamily } from "../internal/utils/mergePlugins.js";
3
3
  //#region src/migrations/documentMigrationTarget.internal.ts
4
4
  const migrationBindings = /* @__PURE__ */ new WeakMap();
5
- const registerMigrationBindings = (target, modelBindings) => {
5
+ const migrationSchemas = /* @__PURE__ */ new WeakMap();
6
+ const registerMigrationBindings = (target, modelBindings, schema) => {
6
7
  const bindings = /* @__PURE__ */ new Map();
7
8
  for (const binding of modelBindings) if (binding.family) bindings.set(binding.family, binding);
8
9
  migrationBindings.set(target, bindings);
10
+ migrationSchemas.set(target, schema);
11
+ };
12
+ const isDeclaredMigrationTextProperty = (target, key) => {
13
+ const schema = migrationSchemas.get(target);
14
+ if (!schema) throw new Error("A document migration requires the migration target from defineDocumentMigrations.");
15
+ const { exact, prefixes } = schema.properties.lookup.text;
16
+ return exact.has(key) || prefixes.some(({ prefix }) => key.startsWith(prefix));
9
17
  };
10
18
  const getMigrationBinding = (target, plugin) => {
11
19
  const bindings = migrationBindings.get(target);
@@ -14,4 +22,4 @@ const getMigrationBinding = (target, plugin) => {
14
22
  return bindings.get(family);
15
23
  };
16
24
  //#endregion
17
- export { getMigrationBinding, registerMigrationBindings };
25
+ export { getMigrationBinding, isDeclaredMigrationTextProperty, registerMigrationBindings };