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.
- package/THIRD_PARTY_NOTICES.md +0 -28
- package/dist/EditorStatic-BKBBZZn8.d.ts +771 -0
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.js +5 -2
- package/dist/ai/lib/aiDraftSession.js +984 -0
- package/dist/ai/{react → lib}/aiOutputLanding.internal.js +90 -96
- package/dist/ai/lib/aiPolicy.internal.js +403 -0
- package/dist/ai/lib/editorAgent.js +1696 -0
- package/dist/ai/lib/lockedContext.internal.js +130 -0
- package/dist/ai/lib/lockedContext.js +271 -0
- package/dist/ai/lib/registerEditorTools.js +235 -0
- package/dist/ai/react/AIPlugin.js +246 -0
- package/dist/ai/react/CopilotPlugin.js +327 -178
- package/dist/ai/react/copilotInline.internal.js +358 -0
- package/dist/ai/react/index.d.ts +200 -788
- package/dist/ai/react/index.js +3 -3
- package/dist/ai/react/useEditorAgent.js +193 -0
- package/dist/authored/AuthoredPlugin.js +34 -2
- package/dist/authored/index.d.ts +5 -4
- package/dist/authored/index.js +3 -2
- package/dist/{features/suggestion → authored}/suggestionColorOf.js +4 -4
- package/dist/{index-CLNem74G.d.ts → authored-BQAGqGhS-DN3sw1OP.d.ts} +101 -75
- package/dist/clipboard-format-key-CWuwPPe2-BJGVrNlz.d.ts +1 -0
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +224 -58
- package/dist/code-block/codemirror/index.d.ts +2 -1
- package/dist/comment-anchor.internal-L2GsNCIh.d.ts +28 -0
- package/dist/compiler/index.d.ts +9 -3
- package/dist/compiler/index.js +3 -1
- package/dist/{core-Cqc_KzpG.d.ts → core-N8rIvQxS.d.ts} +2451 -2213
- package/dist/core.js +4 -8
- package/dist/diff/index.d.ts +3 -30
- package/dist/docs/ai.md +475 -387
- package/dist/docs/api/anchor.md +1 -1
- package/dist/docs/api/core/plate-components.md +12 -3
- package/dist/docs/api/core/plate-editor.md +1 -1
- package/dist/docs/api/core/plate-plugin.md +40 -27
- package/dist/docs/api/core/plate-store.md +14 -13
- package/dist/docs/api/core.md +68 -92
- package/dist/docs/api/document-change.md +39 -28
- package/dist/docs/api/dom.md +66 -102
- package/dist/docs/api/editor-api.md +74 -42
- package/dist/docs/api/editor-transforms.md +17 -39
- package/dist/docs/api/location.md +5 -12
- package/dist/docs/api/plate.md +2 -2
- package/dist/docs/api/react-hooks.md +119 -54
- package/dist/docs/api/selection.md +10 -2
- package/dist/docs/api/utils.md +14 -14
- package/dist/docs/authored-changes.md +38 -33
- package/dist/docs/autoformat.md +4 -1
- package/dist/docs/basic-marks.md +0 -1
- package/dist/docs/block-menu.md +2 -3
- package/dist/docs/block-placeholder.md +2 -3
- package/dist/docs/board.md +28 -24
- package/dist/docs/bold.md +0 -2
- package/dist/docs/clear-formatting.md +4 -4
- package/dist/docs/clipboard.md +25 -18
- package/dist/docs/code-block.md +62 -40
- package/dist/docs/column.md +28 -15
- package/dist/docs/combobox.md +36 -51
- package/dist/docs/comment.md +171 -141
- package/dist/docs/controlled.md +5 -7
- package/dist/docs/copilot.md +183 -148
- package/dist/docs/debugging.md +5 -14
- package/dist/docs/discussion.md +34 -28
- package/dist/docs/dnd.md +7 -6
- package/dist/docs/document-meta.md +27 -28
- package/dist/docs/document-model.md +12 -11
- package/dist/docs/docx.md +102 -111
- package/dist/docs/editor-methods.md +3 -3
- package/dist/docs/editor.md +59 -95
- package/dist/docs/emoji.md +4 -5
- package/dist/docs/equation.md +4 -4
- package/dist/docs/examples/collaboration-example.md +15 -30
- package/dist/docs/examples/export.md +10 -9
- package/dist/docs/examples/version-history.md +7 -6
- package/dist/docs/exit-break.md +32 -59
- package/dist/docs/external-text.md +28 -15
- package/dist/docs/field.md +3 -3
- package/dist/docs/find.md +70 -102
- package/dist/docs/footnote.md +104 -92
- package/dist/docs/format-painter.md +1 -1
- package/dist/docs/history.md +49 -63
- package/dist/docs/html.md +69 -33
- package/dist/docs/indent.md +46 -34
- package/dist/docs/ink.md +46 -31
- package/dist/docs/installation/docs.md +10 -0
- package/dist/docs/installation/node.md +12 -8
- package/dist/docs/installation/plate-ui.md +12 -7
- package/dist/docs/line-height.md +1 -1
- package/dist/docs/link.md +95 -98
- package/dist/docs/list.md +75 -47
- package/dist/docs/llms.txt +14 -11
- package/dist/docs/lock.md +271 -0
- package/dist/docs/markdown.md +124 -209
- package/dist/docs/media.md +31 -31
- package/dist/docs/mention.md +6 -9
- package/dist/docs/multi-select.md +17 -9
- package/dist/docs/pagination.md +144 -127
- package/dist/docs/performance.md +2 -2
- package/dist/docs/plugin-context.md +18 -13
- package/dist/docs/plugin-input-rules.md +84 -125
- package/dist/docs/plugin-methods.md +11 -9
- package/dist/docs/plugin-rules.md +11 -35
- package/dist/docs/plugin-shortcuts.md +1 -1
- package/dist/docs/plugin.md +53 -2
- package/dist/docs/prompt-editor.md +0 -1
- package/dist/docs/roots.md +2 -3
- package/dist/docs/schema.md +12 -3
- package/dist/docs/selection.md +3 -1
- package/dist/docs/serializing.md +34 -10
- package/dist/docs/slash-command.md +4 -4
- package/dist/docs/static.md +30 -10
- package/dist/docs/suggestion.md +51 -71
- package/dist/docs/sync.md +256 -0
- package/dist/docs/table.md +35 -20
- package/dist/docs/text-align.md +4 -4
- package/dist/docs/toolbar.md +26 -5
- package/dist/docs/trailing-block.md +18 -45
- package/dist/docs/underline.md +2 -2
- package/dist/docs/unit-testing.md +1 -1
- package/dist/docs/upload.md +71 -36
- package/dist/docx/export/index.d.ts +152 -56
- package/dist/docx/export/lib/colors.js +268 -0
- package/dist/docx/export/lib/compileAst.js +1825 -0
- package/dist/docx/export/lib/exportDocx.js +57 -113
- package/dist/docx/export/lib/mathOmml.js +233 -0
- package/dist/docx/export/lib/ooxmlBuilder.js +1759 -0
- package/dist/docx/export/lib/outputSafety.js +155 -82
- package/dist/docx/export/lib/reviewProjection.js +31 -202
- package/dist/docx/export/lib/sourcePreservation.js +133 -73
- package/dist/docx/export/lib/wordStyles.js +399 -0
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/import/lib/importDocx.js +1401 -1062
- package/dist/docx/import/lib/opcRelationships.js +77 -0
- package/dist/docx/import/lib/readWordDocument.js +990 -0
- package/dist/docx/import/lib/wordStyles.js +534 -0
- package/dist/docx/internal/diagnostics.js +67 -0
- package/dist/docx/internal/docxPackage.js +20 -44
- package/dist/docx/internal/domParser.js +2 -21
- package/dist/docx/internal/packageParts.js +15 -16
- package/dist/docx/internal/readDocxNumbering.js +35 -38
- package/dist/docx/internal/reviewPart.js +22 -21
- package/dist/docx/internal/sourceEligibility.js +87 -30
- package/dist/docx/internal/wordMath.js +102 -137
- package/dist/docx/internal/xmlTree.js +262 -0
- package/dist/docx/internal/xmlWriter.js +44 -0
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/docx/paste/lib/WordPastePlugin.js +12 -11
- package/dist/dom/index.d.ts +2 -2
- package/dist/dom/index.js +2 -2
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +6 -4
- package/dist/excalidraw/lib/BaseExcalidrawPlugin.js +19 -7
- package/dist/excalidraw/react/index.d.ts +6 -4
- package/dist/facade.js +3 -3
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +32 -12
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +46 -7
- package/dist/features/basic-nodes/lib/BaseMarkPlugins.js +159 -81
- package/dist/features/basic-styles/lib/BaseStylePlugins.js +79 -82
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/index.js +2 -2
- package/dist/features/board/lib/BaseBoardArrowPlugin.js +90 -87
- package/dist/features/board/lib/BaseBoardFramePlugin.js +7 -7
- package/dist/features/board/lib/BaseBoardGeoPlugin.js +3 -2
- package/dist/features/board/lib/BaseBoardImagePlugin.js +9 -6
- package/dist/features/board/lib/BaseBoardNotePlugin.js +3 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +368 -283
- package/dist/features/board/lib/BaseBoardStrokePlugin.js +8 -5
- package/dist/features/board/lib/BaseBoardTextPlugin.js +3 -2
- package/dist/features/board/lib/boardArrow.internal.js +2 -2
- package/dist/features/board/lib/boardCopy.internal.js +42 -36
- package/dist/features/board/lib/boardFrame.internal.js +5 -7
- package/dist/features/board/lib/boardGeometry.internal.js +124 -0
- package/dist/features/board/lib/boardHtml.internal.js +36 -36
- package/dist/features/board/lib/boardMember.internal.js +8 -8
- package/dist/features/board/lib/boardShape.internal.js +10 -124
- package/dist/features/board/lib/boardStyle.internal.js +6 -6
- package/dist/features/board/lib/boardTypes.internal.js +9 -0
- package/dist/features/callout/index.d.ts +3 -3
- package/dist/features/callout/lib/BaseCalloutPlugin.js +43 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +208 -181
- package/dist/features/code-block/lib/CodeBlockRules.js +133 -14
- package/dist/features/column/index.d.ts +2 -0
- package/dist/features/column/lib/BaseColumnPlugin.js +693 -0
- package/dist/features/comments/BaseCommentsPlugin.js +1315 -408
- package/dist/features/comments/comment-thread-index.internal.js +5 -4
- package/dist/features/comments/index.d.ts +3 -2
- package/dist/features/date/index.d.ts +3 -3
- package/dist/features/date/lib/BaseDatePlugin.js +72 -31
- package/dist/features/details/index.d.ts +4 -3
- package/dist/features/details/lib/BaseDetailsPlugin.js +226 -122
- package/dist/features/field/index.d.ts +1 -1
- package/dist/features/field/lib/BaseFieldPlugin.js +64 -48
- package/dist/features/field/lib/fieldRules.internal.js +6 -6
- package/dist/features/find/index.d.ts +98 -34
- package/dist/features/find/lib/BaseFindPlugin.js +939 -370
- package/dist/features/footnote/index.d.ts +428 -2
- package/dist/features/footnote/lib/BaseFootnotePlugin.js +437 -160
- package/dist/features/indent/lib/BaseIndentPlugin.js +222 -75
- package/dist/features/indent/lib/indentHtml.internal.js +9 -0
- package/dist/features/indent/lib/indentLevel.internal.js +3 -3
- package/dist/features/ink/index.d.ts +2 -2
- package/dist/features/ink/lib/BaseInkPlugin.js +122 -85
- package/dist/features/ink/lib/inkMatch.internal.js +79 -78
- package/dist/features/ink/lib/inkPlaces.internal.js +167 -536
- package/dist/features/link/lib/BaseLinkPlugin.js +504 -188
- package/dist/features/lint/index.d.ts +5 -5
- package/dist/features/lint/lib/BaseLintPlugin.js +3 -1
- package/dist/features/list/lib/BaseListPlugin.js +100 -691
- package/dist/features/list/lib/listCommands.internal.js +161 -0
- package/dist/features/list/lib/listFamily.internal.js +68 -23
- package/dist/features/list/lib/listHtml.internal.js +185 -69
- package/dist/features/list/lib/listIndex.internal.js +50 -20
- package/dist/features/list/lib/listKeyboard.internal.js +176 -0
- package/dist/features/list/lib/listMarkdown.internal.js +127 -0
- package/dist/features/list/lib/listRules.internal.js +125 -0
- package/dist/features/lock/index.d.ts +2 -0
- package/dist/features/lock/index.js +2 -0
- package/dist/features/lock/lib/BaseLockPlugin.js +626 -0
- package/dist/features/media/index.d.ts +1 -1
- package/dist/features/media/lib/BaseMediaPlugin.js +117 -4
- package/dist/features/media/lib/image/BaseImagePlugin.js +46 -10
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +26 -8
- package/dist/features/media/lib/mediaHtml.internal.js +2 -2
- package/dist/features/mention/index.d.ts +4 -11
- package/dist/features/mention/lib/BaseMentionPlugin.js +12 -16
- package/dist/features/table/index.d.ts +2 -2
- package/dist/features/table/lib/BaseTablePlugin.js +711 -410
- package/dist/features/table/lib/internal/authoredProjection.js +172 -0
- package/dist/features/table/lib/internal/axisMove.js +152 -0
- package/dist/features/table/lib/internal/docxBorders.js +39 -0
- package/dist/features/table/lib/internal/grid.js +34 -1
- package/dist/features/table/lib/internal/mutation.js +18 -121
- package/dist/features/table/lib/internal/selection.js +114 -3
- package/dist/features/table/lib/internal/tabularText.js +2 -1
- package/dist/features/table/lib/internal/widths.js +118 -0
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/toc/lib/BaseTocPlugin.js +42 -2
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/index.js +3 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +262 -298
- package/dist/features/upload/lib/uploadRules.internal.js +259 -0
- package/dist/history/index.d.ts +2 -3
- package/dist/html/index.d.ts +4 -3
- package/dist/html/server/index.d.ts +6 -2
- package/dist/html/server/index.js +7 -3
- package/dist/html/server/serverCssParser.internal.js +500 -0
- package/dist/html/server/serverCssStyle.internal.js +208 -0
- package/dist/{index-BI0NS7kx.d.ts → htmlConversion-DkPBUAhF.d.ts} +6 -3
- package/dist/{htmlTypes-i_FBCMf2.d.ts → htmlTypes-BtbQ2kEr.d.ts} +24 -14
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-KteL56rA.d.ts → index-1OVDeYPV.d.ts} +4 -3
- package/dist/{index-Cc2ajXAd.d.ts → index-B32tPEDz.d.ts} +152 -83
- package/dist/index-BG8rVWFU.d.ts +21 -0
- package/dist/{index-B4ZhSQdk.d.ts → index-BTr77Bx4.d.ts} +65 -79
- package/dist/{index-1rcWTB-o.d.ts → index-Bjidr3Bh.d.ts} +89 -38
- package/dist/index-BrH9LjUL.d.ts +1 -0
- package/dist/index-C5UBSjnN.d.ts +3 -0
- package/dist/{index-CrJ9Km8W.d.ts → index-C9NdczaJ.d.ts} +9 -12
- package/dist/{index-1PlYsibA.d.ts → index-CQIZktRx.d.ts} +144 -55
- package/dist/{index-uVbqCpDa.d.ts → index-CXykQDCy.d.ts} +172 -115
- package/dist/{comparison-types-CsmDG5r2-z1s4gX06.d.ts → index-CkM6HC0j-Dl58Hah-.d.ts} +19 -57
- package/dist/{index-By7BkzIN.d.ts → index-CpPTPirx.d.ts} +2 -2
- package/dist/index-DFTcRJUh.d.ts +97 -0
- package/dist/index-DUPlSPvg.d.ts +81 -0
- package/dist/{index-CxG1Atvg.d.ts → index-DayqETUb.d.ts} +243 -241
- package/dist/{index-DNXr_SN-.d.ts → index-DlfamnX-.d.ts} +128 -230
- package/dist/index-DlmWL_1-.d.ts +116 -0
- package/dist/index-Dqd1rrEG-BSmp1a8x.d.ts +316 -0
- package/dist/{index-CTTjpWgb-Fdrn8NP4.d.ts → index-Du3tBg6V-CtvB7eak.d.ts} +3 -3
- package/dist/{index-CmISVYmz.d.ts → index-MQmrgI2L.d.ts} +20 -50
- package/dist/{index-Bv13FX9o.d.ts → index-SKTw56CW.d.ts} +9 -9
- package/dist/{index-DfkFmApH.d.ts → index-drvpTZ3S.d.ts} +743 -1532
- package/dist/index-vP4xFieu.d.ts +184 -0
- package/dist/index-zK527a0f.d.ts +57 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -11
- package/dist/internal/comments/comment-anchor.internal.js +636 -0
- package/dist/internal/plugin/OverridePlugin.js +155 -53
- package/dist/internal/plugin/blockInsertion.js +4 -4
- package/dist/internal/plugin/collectPlateNodeMappings.js +18 -8
- package/dist/internal/plugin/compilePlainTextMappings.js +68 -15
- package/dist/internal/plugin/compilePlateModel.js +56 -17
- package/dist/internal/plugin/compilePlateShortcuts.js +2 -1
- package/dist/internal/plugin/compilePluginInputMaps.js +126 -0
- package/dist/internal/plugin/createPlateModelPublication.js +261 -0
- package/dist/internal/plugin/createPlateRuntimePlugins.js +263 -0
- package/dist/internal/plugin/getPlateDecorationSources.js +2 -1
- package/dist/internal/plugin/indentShift.js +44 -0
- package/dist/internal/plugin/markdownParagraph.js +23 -1
- package/dist/internal/plugin/plateRuntime.js +9 -3
- package/dist/internal/plugin/pluginDescriptorSnapshot.js +178 -0
- package/dist/internal/plugin/pluginFormatOperation.js +8 -3
- package/dist/internal/plugin/pluginStore.js +4 -7
- package/dist/internal/plugin/resolvePlugin.js +32 -14
- package/dist/internal/plugin/resolvePluginGraph.js +354 -0
- package/dist/internal/plugin/resolvePlugins.js +19 -1135
- package/dist/internal/plugin/staticReuseKey.internal.js +15 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -1
- package/dist/internal/utils/mergePlugins.js +6 -5
- package/dist/internal/utils/trustedContentSlice.js +1 -1
- package/dist/internal/utils/urlPolicy.js +19 -1
- package/dist/lib/editor/editorUser.internal.js +13 -5
- package/dist/lib/editor/withPlite.js +55 -44
- package/dist/lib/libs/zustand.js +31 -7
- package/dist/lib/plugin/basePluginFactory.internal.js +7 -0
- package/dist/lib/plugin/createPluginContext.internal.js +6 -24
- package/dist/lib/plugin/defineBasePlugin.internal.js +69 -9
- package/dist/lib/plugin/definePlugin.js +1 -1
- package/dist/lib/plugin/pluginFactoryRuntime.internal.js +40 -0
- package/dist/lib/plugins/affinity/AffinityPlugin.js +9 -8
- package/dist/lib/plugins/debug/DebugPlugin.js +1 -4
- package/dist/lib/plugins/dom/DOMPlugin.js +20 -7
- package/dist/lib/plugins/dom/clipboardFormatKey.internal.js +9 -0
- package/dist/lib/plugins/dom/isPlainTextPasteTarget.internal.js +13 -0
- package/dist/lib/plugins/getCorePlugins.internal.js +1 -3
- package/dist/lib/plugins/html/HtmlPlugin.js +30 -1747
- package/dist/lib/plugins/html/htmlAst.js +10 -5
- package/dist/lib/plugins/html/htmlConversion.js +4 -0
- package/dist/lib/plugins/html/htmlDecode.internal.js +891 -0
- package/dist/lib/plugins/html/htmlDom.js +1 -10
- package/dist/lib/plugins/html/htmlMatcher.internal.js +24 -1
- package/dist/lib/plugins/html/htmlRules.internal.js +490 -0
- package/dist/lib/plugins/html/htmlSerialize.internal.js +462 -0
- package/dist/lib/plugins/html/htmlWhitespace.internal.js +137 -0
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +114 -30
- package/dist/lib/plugins/input-rules/createInputRules.js +64 -68
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +111 -9
- package/dist/lib/plugins/input-rules/inputRuleVeto.js +2 -2
- package/dist/lib/plugins/input-rules/inputRules.internal.js +20 -0
- package/dist/lib/plugins/input-rules/markInputRule.internal.js +64 -2
- package/dist/lib/plugins/paragraph/BaseParagraphPlugin.js +21 -8
- package/dist/lib/utils/pluginNodeClass.js +1 -5
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +1 -2
- package/dist/markdown/lib/MarkdownPlugin.js +40 -49
- package/dist/markdown/lib/deserializer/convertNodesDeserialize.js +30 -6
- package/dist/markdown/lib/deserializer/mdastToSlate.js +2 -4
- package/dist/markdown/lib/internal/markdownBareLinks.js +265 -0
- package/dist/markdown/lib/internal/markdownBreaks.js +191 -0
- package/dist/markdown/lib/internal/markdownDiagnostics.js +2 -2
- package/dist/markdown/lib/internal/markdownDocument.js +13 -32
- package/dist/markdown/lib/internal/markdownIntrinsics.js +68 -228
- package/dist/markdown/lib/internal/markdownLine.js +134 -118
- package/dist/markdown/lib/internal/markdownMappings.js +178 -88
- package/dist/markdown/lib/internal/markdownParse.js +601 -0
- package/dist/markdown/lib/internal/markdownReferences.js +9 -3
- package/dist/markdown/lib/internal/markdownRuntime.js +353 -0
- package/dist/markdown/lib/internal/markdownSafety.js +101 -1
- package/dist/markdown/lib/internal/markdownSerialize.js +197 -0
- package/dist/markdown/lib/internal/markdownStream.js +1239 -0
- package/dist/markdown/lib/internal/markdownTags.js +52 -63
- package/dist/markdown/lib/internal/markdownTailHeal.js +813 -0
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +18 -5
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +134 -53
- package/dist/markdown/lib/serializer/listToMdastTree.js +23 -4
- package/dist/markdown/lib/serializer/reportOmittedProperties.js +1 -0
- package/dist/markdown/lib/utils/remarkPlugins.js +44 -23
- package/dist/math/index.d.ts +11 -11
- package/dist/math/lib/BaseEquationPlugin.js +99 -20
- package/dist/math/react/index.d.ts +4 -4
- package/dist/migrations/documentMigrationAuthored.internal.js +2 -1
- package/dist/migrations/documentMigrationSelection.internal.js +138 -2
- package/dist/migrations/documentMigrationTarget.internal.js +10 -2
- package/dist/migrations/documentMigrations.js +113 -140
- package/dist/migrations/index.d.ts +30 -44
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/migratePlateV54.js +50 -45
- package/dist/migrations/migratePlateV54Ast.internal.js +180 -119
- package/dist/migrations/migratePlateV54BuiltIns.internal.js +2 -2
- package/dist/migrations/migratePlateV54CodeBlocks.internal.js +68 -34
- package/dist/migrations/migratePlateV54Inputs.internal.js +39 -32
- package/dist/migrations/migratePlateV54ListIdentity.internal.js +220 -0
- package/dist/migrations/migratePlateV54Profile.internal.js +52 -22
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +2 -2
- package/dist/migrations/migratePlateV54Stage.internal.js +127 -0
- package/dist/migrations/migratePlateV54Toggle.internal.js +66 -0
- package/dist/migrations/migratePlateV54Urls.internal.js +86 -57
- package/dist/pagination/index.d.ts +2 -167
- package/dist/pagination/index.js +2 -2
- package/dist/pagination/react/PaginationPlugin.js +278 -0
- package/dist/pagination/react/index.d.ts +94 -34
- package/dist/pagination/react/index.js +3 -5
- package/dist/plain-text.js +9 -12
- package/dist/react/authored/AuthoredReactPlugin.js +126 -0
- package/dist/react/authored/index.d.ts +34 -0
- package/dist/react/authored/index.js +3 -0
- package/dist/react/authored/useAuthored.js +82 -0
- package/dist/react/components/EditorContentView.internal.js +64 -45
- package/dist/react/components/EditorProvider.js +25 -24
- package/dist/react/components/EditorRefEffect.internal.js +56 -0
- package/dist/react/components/EditorRefEffect.js +12 -56
- package/dist/react/components/NodeSelection.js +435 -486
- package/dist/react/components/Plate.js +215 -168
- package/dist/react/components/PlateContainer.js +96 -43
- package/dist/react/components/PlateView.js +2 -2
- package/dist/{static/internal/getPlainText.js → react/components/getPlainText.internal.js} +1 -4
- package/dist/react/components/plate-nodes.js +49 -42
- package/dist/{static/internal/writeStaticSelectionClipboardData.js → react/components/writeStaticSelectionClipboardData.internal.js} +4 -5
- package/dist/react/core.js +7 -11
- package/dist/react/editor/useCreateEditor.js +19 -17
- package/dist/react/editor/withPlate.js +10 -13
- package/dist/react/features/basic-styles/BasicStylePlugins.js +2 -3
- package/dist/react/features/board/BoardPlugin.js +1 -1
- package/dist/react/features/board/BoardShape.js +51 -26
- package/dist/react/features/board/BoardSurface.js +1 -1
- package/dist/react/features/board/boardCamera.internal.js +295 -0
- package/dist/react/features/board/boardClipboard.internal.js +20 -20
- package/dist/react/features/board/boardConnect.internal.js +2 -10
- package/dist/react/features/board/boardExport.internal.js +5 -4
- package/dist/react/features/board/boardGesture.internal.js +44 -38
- package/dist/react/features/board/boardIndex.internal.js +1 -1
- package/dist/react/features/board/boardKeys.internal.js +68 -43
- package/dist/react/features/board/boardLanding.internal.js +147 -0
- package/dist/react/features/board/boardPick.internal.js +2 -2
- package/dist/react/features/board/boardPicking.internal.js +0 -17
- package/dist/react/features/board/boardPreview.internal.js +16 -2
- package/dist/react/features/board/boardResize.internal.js +17 -32
- package/dist/react/features/board/boardStyleView.internal.js +123 -0
- package/dist/react/features/board/boardTextFit.internal.js +311 -0
- package/dist/react/features/board/boardView.internal.js +333 -909
- package/dist/react/features/board/boardVoice.internal.js +19 -7
- package/dist/react/features/board/boardWindow.internal.js +138 -0
- package/dist/react/features/board/index.d.ts +97 -89
- package/dist/react/features/callout/index.d.ts +3 -3
- package/dist/react/features/{layout → column}/ColumnPlugin.js +4 -3
- package/dist/react/features/{layout → column}/index.d.ts +61 -44
- package/dist/react/features/combobox/combobox.internal.js +106 -0
- package/dist/react/features/combobox/comboboxOwner.internal.js +28 -26
- package/dist/react/features/combobox/index.d.ts +47 -16
- package/dist/react/features/combobox/useCombobox.js +50 -13
- package/dist/react/features/comments/CommentsPlugin.js +3 -3
- package/dist/react/features/comments/index.d.ts +142 -75
- package/dist/react/features/comments/index.js +2 -1
- package/dist/react/features/comments/useCommentThreadIndex.js +288 -0
- package/dist/react/features/date/index.d.ts +4 -4
- package/dist/react/features/details/index.d.ts +5 -5
- package/dist/react/features/field/index.d.ts +6 -5
- package/dist/react/features/footnote/FootnotePlugin.js +13 -8
- package/dist/react/features/footnote/index.d.ts +952 -105
- package/dist/react/features/format-painter/index.d.ts +6 -6
- package/dist/react/features/ink/InkContent.js +28 -100
- package/dist/react/features/ink/InkPlugin.js +12 -23
- package/dist/react/features/ink/index.d.ts +53 -106
- package/dist/react/features/ink/index.js +1 -2
- package/dist/react/features/ink/inkCapture.internal.js +107 -65
- package/dist/react/features/ink/inkImages.internal.js +20 -5
- package/dist/react/features/ink/inkMeasure.internal.js +35 -22
- package/dist/react/features/ink/inkPlacement.internal.js +78 -203
- package/dist/react/features/ink/inkWatch.internal.js +1 -32
- package/dist/react/features/list/ListPlugin.js +68 -36
- package/dist/react/features/lock/LockPlugin.js +105 -0
- package/dist/react/features/lock/index.d.ts +58 -0
- package/dist/react/features/lock/index.js +2 -0
- package/dist/react/features/media/index.d.ts +10 -10
- package/dist/react/features/mention/index.d.ts +4 -11
- package/dist/react/features/table/TablePlugin.js +215 -61
- package/dist/react/features/table/index.d.ts +158 -59
- package/dist/react/features/table/index.js +2 -1
- package/dist/react/features/table/measureTableColumnWidths.internal.js +44 -0
- package/dist/react/features/table/useTableControls.js +897 -0
- package/dist/react/features/table/useTableResize.js +33 -16
- package/dist/react/features/toc/index.d.ts +8 -11
- package/dist/react/features/upload/UploadPlugin.js +12 -3
- package/dist/react/features/upload/index.d.ts +36 -97
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +11 -15
- package/dist/react/internal/plate-context.js +118 -68
- package/dist/react/internal/useDeepCompareMemo.js +36 -7
- package/dist/react/internal/usePlateModelRevision.js +12 -7
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugin/pluginFactory.internal.js +1 -37
- package/dist/react/plugin/toReactPlugin.js +15 -4
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +2 -2
- package/dist/react/stores/element/useElement.js +2 -2
- package/dist/react/stores/element/useElementSelector.js +4 -2
- package/dist/react/stores/element/useElementStore.js +96 -86
- package/dist/react/stores/element/useElementStoreSelector.internal.js +80 -24
- package/dist/react/stores/element/usePath.js +32 -32
- package/dist/react/stores/plate/pluginStoreSelector.internal.js +44 -0
- package/dist/react/stores/plate/useEditor.js +62 -89
- package/dist/react/stores/plate/useEditorSelector.js +17 -204
- package/dist/react/stores/plate/usePluginStore.js +36 -43
- package/dist/react/stores/plate/useViewStore.js +38 -23
- package/dist/react/utils/BlockPlaceholderPlugin.js +13 -4
- package/dist/react/utils/pipeHandler.internal.js +20 -7
- package/dist/react/utils/pipeRenderElement.internal.js +32 -30
- package/dist/react/utils/pipeRenderLeaf.internal.js +1 -2
- package/dist/react/utils/pipeRenderText.internal.js +1 -1
- package/dist/react/utils/useSelectionFragment.js +8 -2
- package/dist/react/virtualized.d.ts +6 -5
- package/dist/refusal-CBecclcb-BJGVrNlz.d.ts +1 -0
- package/dist/registerEditorTools-dPLJZ0PP.d.ts +386 -0
- package/dist/root.js +7 -11
- package/dist/skills/plate/SKILL.md +43 -0
- package/dist/{source-Dcgqj5Mf.d.ts → source-BnYE-ryK.d.ts} +14 -14
- package/dist/static/components/{PlateStatic.js → EditorStatic.js} +86 -31
- package/dist/static/components/plite-nodes.js +32 -12
- package/dist/static/index.d.ts +24 -20
- package/dist/static/index.js +1 -1
- package/dist/static/internal/loadStaticRenderer.js +4 -0
- package/dist/static/internal/staticDocumentView.js +8 -5
- package/dist/static/internal/staticPendingMedia.internal.js +136 -0
- package/dist/static/internal/staticPresentation.js +12 -12
- package/dist/static/pipeRenderElementStatic.internal.js +2 -10
- package/dist/static/pluginRenderElementStatic.internal.js +28 -5
- package/dist/static/pluginRenderLeafStatic.internal.js +4 -3
- package/dist/static/pluginRenderTextStatic.internal.js +3 -1
- package/dist/static/renderStaticHtml.js +31 -2
- package/dist/static/utils/getRenderNodeStaticProps.internal.js +8 -3
- package/dist/sync/SyncPlugin.js +16 -0
- package/dist/sync/cloudflare/index.d.ts +56 -0
- package/dist/sync/cloudflare/index.js +2 -0
- package/dist/sync/index.d.ts +3 -0
- package/dist/sync/index.js +3 -0
- package/dist/sync/react/SyncReactPlugin.js +20 -0
- package/dist/sync/react/hooks.js +64 -0
- package/dist/{yjs → sync}/react/index.d.ts +74 -68
- package/dist/sync/react/index.js +4 -0
- package/dist/sync/server/index.d.ts +3 -0
- package/dist/sync/server/index.js +2 -0
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/TabbableEffects.internal.js +5 -5
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +7 -6
- package/dist/transport-CRrArpJZ-Bm6uVAsa.d.ts +115 -0
- package/dist/{tx-only-1FM45FSj-D40jacZv.d.ts → tx-only-DXWFNuXJ-DuOaZk8U.d.ts} +2818 -2677
- package/dist/utils/plate-keys.js +2 -8
- package/dist/utils/plugins/TrailingBlockPlugin.js +10 -7
- package/dist/utils/plugins/resolveTrailingBlockType.internal.js +8 -0
- package/package.json +61 -115
- package/dist/AIChatRequestContext-DVGOeWhQ.d.ts +0 -34
- package/dist/BaseSuggestionPlugin-BRFMMyEo.d.ts +0 -91
- package/dist/PlateStatic-DIwBAVqF.d.ts +0 -19
- package/dist/ai/lib/AIChatRequestContext.js +0 -16
- package/dist/ai/lib/findQuotedSpan.internal.js +0 -63
- package/dist/ai/react/AIChatPlugin.js +0 -1244
- package/dist/ai/react/useAIChat.js +0 -332
- package/dist/combobox-CfCJYKT0.d.ts +0 -22
- package/dist/docs/yjs.md +0 -256
- package/dist/docx/export/lib/comments.js +0 -311
- package/dist/docx/export/lib/docxStaticComponents.js +0 -381
- package/dist/docx/export/lib/exportHtmlToDocx.internal.js +0 -70
- package/dist/docx/export/lib/generatedParts.js +0 -51
- package/dist/docx/export/lib/hostIndex.js +0 -92
- package/dist/docx/export/lib/html-to-docx.internal.js +0 -40
- package/dist/docx/export/lib/internal/constants.js +0 -106
- package/dist/docx/export/lib/internal/docx-document.js +0 -652
- package/dist/docx/export/lib/internal/escape-xml.js +0 -4
- package/dist/docx/export/lib/internal/html-to-docx.js +0 -148
- package/dist/docx/export/lib/internal/list-item.js +0 -85
- package/dist/docx/export/lib/internal/list.js +0 -43
- package/dist/docx/export/lib/internal/math.js +0 -187
- package/dist/docx/export/lib/internal/namespaces.js +0 -40
- package/dist/docx/export/lib/internal/render-document-file.js +0 -403
- package/dist/docx/export/lib/internal/schemas/content-types.js +0 -25
- package/dist/docx/export/lib/internal/schemas/core.js +0 -26
- package/dist/docx/export/lib/internal/schemas/document-rels.js +0 -15
- package/dist/docx/export/lib/internal/schemas/document.template.js +0 -36
- package/dist/docx/export/lib/internal/schemas/font-table.js +0 -55
- package/dist/docx/export/lib/internal/schemas/generic-rels.js +0 -9
- package/dist/docx/export/lib/internal/schemas/numbering.js +0 -18
- package/dist/docx/export/lib/internal/schemas/rels.js +0 -12
- package/dist/docx/export/lib/internal/schemas/settings.js +0 -17
- package/dist/docx/export/lib/internal/schemas/styles.js +0 -142
- package/dist/docx/export/lib/internal/schemas/theme.js +0 -198
- package/dist/docx/export/lib/internal/schemas/web-settings.js +0 -10
- package/dist/docx/export/lib/internal/unit-conversion.js +0 -24
- package/dist/docx/export/lib/internal/vnode.js +0 -4
- package/dist/docx/export/lib/internal/word-styles.js +0 -123
- package/dist/docx/export/lib/internal/xml-builder.js +0 -1803
- package/dist/docx/export/lib/reviewPart.js +0 -234
- package/dist/docx/import/lib/wordFormatting.js +0 -608
- package/dist/features/combobox/index.d.ts +0 -3
- package/dist/features/combobox/index.js +0 -2
- package/dist/features/combobox/lib/combobox.internal.js +0 -111
- package/dist/features/combobox/lib/filterWords.js +0 -23
- package/dist/features/ink/lib/inkGone.internal.js +0 -290
- package/dist/features/layout/index.d.ts +0 -2
- package/dist/features/layout/lib/BaseColumnPlugin.js +0 -249
- package/dist/features/suggestion/BaseSuggestionPlugin.js +0 -31
- package/dist/features/suggestion/index.d.ts +0 -10
- package/dist/features/suggestion/index.js +0 -3
- package/dist/features/upload/lib/mimeTypes.internal.js +0 -3982
- package/dist/index-BWCC4DCP.d.ts +0 -156
- package/dist/index-CJGkjkH6.d.ts +0 -8
- package/dist/index-CS4G_W_R.d.ts +0 -184
- package/dist/index-CVAHIQ3p.d.ts +0 -29
- package/dist/index-OMa7dlcS.d.ts +0 -161
- package/dist/lib/plugins/element-state/ElementStatePlugin.js +0 -14
- package/dist/lib/utils/hotkeys.js +0 -113
- package/dist/markdown/lib/RawHtmlPlugin.js +0 -26
- package/dist/markdown/lib/internal/markdownConversion.js +0 -1358
- package/dist/markdown/lib/internal/markdownOpenTail.js +0 -381
- package/dist/markdown/lib/internal/markdownRawHtml.js +0 -353
- package/dist/markdown/lib/internal/markdownSegments.js +0 -143
- package/dist/migrations/migrateListIdentity.js +0 -93
- package/dist/pagination/react/PagedEditorContent.js +0 -77
- package/dist/react/features/ink/InkCopyView.js +0 -214
- package/dist/react/features/suggestion/SuggestionPlugin.js +0 -24
- package/dist/react/features/suggestion/index.d.ts +0 -45
- package/dist/react/features/suggestion/index.js +0 -3
- package/dist/react/features/suggestion/suggestion-view.internal.js +0 -114
- package/dist/react/features/suggestion/useSuggestion.js +0 -138
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +0 -33
- package/dist/utils/plugins/ExitBreakPlugin.js +0 -26
- package/dist/yjs/index.d.ts +0 -2
- package/dist/yjs/index.js +0 -1
- package/dist/yjs/react/YjsPlugin.js +0 -60
- package/dist/yjs/react/index.js +0 -3
- /package/dist/features/{layout → column}/index.js +0 -0
- /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 {
|
|
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
|
-
|
|
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
|
-
|
|
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) =>
|
|
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 {
|
|
2
|
-
import "../../htmlTypes-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
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 };
|