platejs 54.0.0-beta.1 → 54.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/THIRD_PARTY_NOTICES.md +113 -0
- package/dist/AIChatRequestContext-DY104TqL.d.ts +34 -0
- package/dist/BaseSuggestionPlugin-Deo6n6Fs.d.ts +90 -0
- package/dist/PlateStatic-CJX5bKuv.d.ts +19 -0
- package/dist/_virtual/_rolldown/runtime.js +28 -0
- package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/lib/AIChatRequestContext.js +16 -0
- package/dist/ai/lib/findQuotedSpan.internal.js +63 -0
- package/dist/ai/react/AIChatPlugin.js +1238 -0
- package/dist/ai/react/CopilotPlugin.js +399 -0
- package/dist/ai/react/aiOutputLanding.internal.js +272 -0
- package/dist/ai/react/index.d.ts +1213 -0
- package/dist/ai/react/index.js +4 -0
- package/dist/ai/react/useAIChat.js +327 -0
- package/dist/authored/AuthoredPlugin.js +11 -0
- package/dist/authored/index.d.ts +4 -0
- package/dist/authored/index.js +3 -0
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +507 -0
- package/dist/code-block/codemirror/index.d.ts +18 -0
- package/dist/code-block/codemirror/index.js +2 -0
- package/dist/combobox-DAOYWuvC.d.ts +22 -0
- package/dist/comparison-types-Dt-unJZY-DCddmbSD.d.ts +177 -0
- package/dist/compiler/compileEditor.js +10 -0
- package/dist/compiler/index.d.ts +12 -0
- package/dist/compiler/index.js +2 -0
- package/dist/core-ClHasORr.d.ts +10862 -0
- package/dist/core.js +34 -0
- package/dist/diff/index.d.ts +30 -0
- package/dist/diff/index.js +1 -0
- package/dist/docs/ai.md +596 -0
- package/dist/docs/annotations.md +240 -0
- package/dist/docs/api/anchor.md +90 -0
- package/dist/docs/api/core/plate-components.md +582 -0
- package/dist/docs/api/core/plate-controller.md +81 -0
- package/dist/docs/api/core/plate-editor.md +310 -0
- package/dist/docs/api/core/plate-plugin.md +826 -0
- package/dist/docs/api/core/plate-store.md +106 -0
- package/dist/docs/api/core.md +735 -0
- package/dist/docs/api/document-change.md +225 -0
- package/dist/docs/api/dom.md +475 -0
- package/dist/docs/api/editor-api.md +569 -0
- package/dist/docs/api/editor-transforms.md +673 -0
- package/dist/docs/api/element.md +88 -0
- package/dist/docs/api/location.md +58 -0
- package/dist/docs/api/node.md +213 -0
- package/dist/docs/api/path.md +123 -0
- package/dist/docs/api/plate.md +99 -0
- package/dist/docs/api/point.md +59 -0
- package/dist/docs/api/range.md +88 -0
- package/dist/docs/api/react-hooks.md +636 -0
- package/dist/docs/api/resizable.md +121 -0
- package/dist/docs/api/selection.md +168 -0
- package/dist/docs/api/text.md +55 -0
- package/dist/docs/api/utils.md +149 -0
- package/dist/docs/authored-changes.md +452 -0
- package/dist/docs/autoformat.md +155 -0
- package/dist/docs/basic-blocks.md +205 -0
- package/dist/docs/basic-marks.md +187 -0
- package/dist/docs/block-menu.md +69 -0
- package/dist/docs/block-placeholder.md +164 -0
- package/dist/docs/blockquote.md +164 -0
- package/dist/docs/board.md +670 -0
- package/dist/docs/bold.md +142 -0
- package/dist/docs/browser.md +189 -0
- package/dist/docs/callout.md +148 -0
- package/dist/docs/clear-formatting.md +169 -0
- package/dist/docs/clipboard.md +500 -0
- package/dist/docs/code-block.md +530 -0
- package/dist/docs/code.md +134 -0
- package/dist/docs/column.md +173 -0
- package/dist/docs/combobox.md +247 -0
- package/dist/docs/comment.md +572 -0
- package/dist/docs/controlled.md +280 -0
- package/dist/docs/copilot.md +443 -0
- package/dist/docs/date.md +199 -0
- package/dist/docs/debugging.md +218 -0
- package/dist/docs/decorations.md +67 -0
- package/dist/docs/details.md +276 -0
- package/dist/docs/discussion.md +170 -0
- package/dist/docs/dnd.md +354 -0
- package/dist/docs/document-meta.md +233 -0
- package/dist/docs/document-model.md +383 -0
- package/dist/docs/docx.md +473 -0
- package/dist/docs/dom-coverage.md +101 -0
- package/dist/docs/editing-behavior.md +322 -0
- package/dist/docs/editor-methods.md +233 -0
- package/dist/docs/editor.md +940 -0
- package/dist/docs/emoji.md +209 -0
- package/dist/docs/equation.md +263 -0
- package/dist/docs/examples/collaboration-example.md +61 -0
- package/dist/docs/examples/editable-voids.md +58 -0
- package/dist/docs/examples/export.md +79 -0
- package/dist/docs/examples/huge-document.md +3 -0
- package/dist/docs/examples/hundreds-editors.md +41 -0
- package/dist/docs/examples/preview-markdown.md +43 -0
- package/dist/docs/examples/version-history.md +54 -0
- package/dist/docs/excalidraw.md +200 -0
- package/dist/docs/exit-break.md +267 -0
- package/dist/docs/external-text.md +145 -0
- package/dist/docs/feature-kits.md +147 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +175 -0
- package/dist/docs/font.md +186 -0
- package/dist/docs/footnote.md +530 -0
- package/dist/docs/form.md +441 -0
- package/dist/docs/format-painter.md +224 -0
- package/dist/docs/heading.md +99 -0
- package/dist/docs/highlight.md +135 -0
- package/dist/docs/history.md +408 -0
- package/dist/docs/horizontal-rule.md +181 -0
- package/dist/docs/html.md +379 -0
- package/dist/docs/indent.md +221 -0
- package/dist/docs/index.md +91 -0
- package/dist/docs/installation/docs.md +24 -0
- package/dist/docs/installation/manual.md +392 -0
- package/dist/docs/installation/mcp.md +147 -0
- package/dist/docs/installation/next.md +368 -0
- package/dist/docs/installation/node.md +148 -0
- package/dist/docs/installation/plate-ui.md +269 -0
- package/dist/docs/installation/react.md +347 -0
- package/dist/docs/installation/rsc.md +138 -0
- package/dist/docs/installation.md +93 -0
- package/dist/docs/italic.md +128 -0
- package/dist/docs/kbd.md +125 -0
- package/dist/docs/line-height.md +171 -0
- package/dist/docs/link.md +319 -0
- package/dist/docs/lint.md +408 -0
- package/dist/docs/list.md +213 -0
- package/dist/docs/llms.txt +147 -0
- package/dist/docs/locations.md +232 -0
- package/dist/docs/markdown.md +794 -0
- package/dist/docs/media.md +619 -0
- package/dist/docs/mention.md +187 -0
- package/dist/docs/migration/plite-to-plate.md +251 -0
- package/dist/docs/multi-select.md +97 -0
- package/dist/docs/navigation-feedback.md +196 -0
- package/dist/docs/pagination.md +164 -0
- package/dist/docs/performance.md +105 -0
- package/dist/docs/plugin-components.md +236 -0
- package/dist/docs/plugin-context.md +386 -0
- package/dist/docs/plugin-input-rules.md +974 -0
- package/dist/docs/plugin-methods.md +421 -0
- package/dist/docs/plugin-rules.md +904 -0
- package/dist/docs/plugin-shortcuts.md +387 -0
- package/dist/docs/plugin.md +560 -0
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/releases.md +3 -0
- package/dist/docs/roots.md +313 -0
- package/dist/docs/rtl.md +64 -0
- package/dist/docs/schema.md +148 -0
- package/dist/docs/selection.md +232 -0
- package/dist/docs/serializing.md +187 -0
- package/dist/docs/single-block.md +136 -0
- package/dist/docs/slash-command.md +144 -0
- package/dist/docs/static.md +438 -0
- package/dist/docs/strikethrough.md +131 -0
- package/dist/docs/subscript.md +113 -0
- package/dist/docs/suggestion.md +352 -0
- package/dist/docs/superscript.md +113 -0
- package/dist/docs/tabbable.md +238 -0
- package/dist/docs/table.md +303 -0
- package/dist/docs/text-align.md +161 -0
- package/dist/docs/toc.md +295 -0
- package/dist/docs/toolbar.md +291 -0
- package/dist/docs/trailing-block.md +138 -0
- package/dist/docs/transactions.md +300 -0
- package/dist/docs/troubleshooting.md +159 -0
- package/dist/docs/typescript.md +77 -0
- package/dist/docs/underline.md +125 -0
- package/dist/docs/unit-testing.md +340 -0
- package/dist/docs/upload.md +344 -0
- package/dist/docs/virtualized-rendering.md +75 -0
- package/dist/docs/yjs.md +256 -0
- package/dist/docx/export/index.d.ts +112 -0
- package/dist/docx/export/index.js +2 -0
- package/dist/docx/export/lib/comments.js +231 -0
- package/dist/docx/export/lib/docxStaticComponents.js +381 -0
- package/dist/docx/export/lib/exportDocx.js +379 -0
- package/dist/docx/export/lib/exportHtmlToDocx.internal.js +70 -0
- package/dist/docx/export/lib/generatedParts.js +51 -0
- package/dist/docx/export/lib/html-to-docx.internal.js +40 -0
- package/dist/docx/export/lib/internal/constants.js +106 -0
- package/dist/docx/export/lib/internal/docx-document.js +652 -0
- package/dist/docx/export/lib/internal/escape-xml.js +4 -0
- package/dist/docx/export/lib/internal/html-to-docx.js +148 -0
- package/dist/docx/export/lib/internal/list-item.js +85 -0
- package/dist/docx/export/lib/internal/list.js +43 -0
- package/dist/docx/export/lib/internal/math.js +187 -0
- package/dist/docx/export/lib/internal/namespaces.js +40 -0
- package/dist/docx/export/lib/internal/render-document-file.js +403 -0
- package/dist/docx/export/lib/internal/schemas/content-types.js +25 -0
- package/dist/docx/export/lib/internal/schemas/core.js +26 -0
- package/dist/docx/export/lib/internal/schemas/document-rels.js +15 -0
- package/dist/docx/export/lib/internal/schemas/document.template.js +36 -0
- package/dist/docx/export/lib/internal/schemas/font-table.js +55 -0
- package/dist/docx/export/lib/internal/schemas/generic-rels.js +9 -0
- package/dist/docx/export/lib/internal/schemas/numbering.js +18 -0
- package/dist/docx/export/lib/internal/schemas/rels.js +12 -0
- package/dist/docx/export/lib/internal/schemas/settings.js +17 -0
- package/dist/docx/export/lib/internal/schemas/styles.js +142 -0
- package/dist/docx/export/lib/internal/schemas/theme.js +198 -0
- package/dist/docx/export/lib/internal/schemas/web-settings.js +10 -0
- package/dist/docx/export/lib/internal/unit-conversion.js +24 -0
- package/dist/docx/export/lib/internal/vnode.js +4 -0
- package/dist/docx/export/lib/internal/word-styles.js +123 -0
- package/dist/docx/export/lib/internal/xml-builder.js +1808 -0
- package/dist/docx/export/lib/outputSafety.js +123 -0
- package/dist/docx/export/lib/reviewPart.js +234 -0
- package/dist/docx/export/lib/reviewProjection.js +163 -0
- package/dist/docx/export/lib/sourcePreservation.js +375 -0
- package/dist/docx/html/cleanWordHtml.internal.js +371 -0
- package/dist/docx/import/index.d.ts +44 -0
- package/dist/docx/import/index.js +3 -0
- package/dist/docx/import/lib/importDocx.js +1298 -0
- package/dist/docx/import/lib/wordFormatting.js +608 -0
- package/dist/docx/internal/abort.js +8 -0
- package/dist/docx/internal/docxPackage.js +322 -0
- package/dist/docx/internal/domParser.js +23 -0
- package/dist/docx/internal/packageParts.js +73 -0
- package/dist/docx/internal/readDocxNumbering.js +199 -0
- package/dist/docx/internal/reviewPart.js +249 -0
- package/dist/docx/internal/source.js +77 -0
- package/dist/docx/internal/sourceEligibility.js +349 -0
- package/dist/docx/internal/wordMath.js +375 -0
- package/dist/docx/internal/wordMathVocabulary.js +110 -0
- package/dist/docx/paste/index.d.ts +28 -0
- package/dist/docx/paste/index.js +2 -0
- package/dist/docx/paste/lib/WordPastePlugin.js +329 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.js +2 -0
- package/dist/dom/plite-dom.internal.js +2 -0
- package/dist/excalidraw/index.d.ts +58 -0
- package/dist/excalidraw/index.js +2 -0
- package/dist/excalidraw/lib/BaseExcalidrawPlugin.js +15 -0
- package/dist/excalidraw/react/ExcalidrawPlugin.js +6 -0
- package/dist/excalidraw/react/index.d.ts +102 -0
- package/dist/excalidraw/react/index.js +3 -0
- package/dist/excalidraw/react/useExcalidrawSync.js +103 -0
- package/dist/facade.js +3 -0
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +195 -0
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +126 -0
- package/dist/features/basic-nodes/lib/BaseMarkPlugins.js +326 -0
- package/dist/features/basic-styles/lib/BaseFormattingPlugin.js +391 -0
- package/dist/features/basic-styles/lib/BaseStylePlugins.js +261 -0
- package/dist/features/board/index.d.ts +2 -0
- package/dist/features/board/index.js +9 -0
- package/dist/features/board/lib/BaseBoardArrowPlugin.js +123 -0
- package/dist/features/board/lib/BaseBoardFramePlugin.js +84 -0
- package/dist/features/board/lib/BaseBoardGeoPlugin.js +12 -0
- package/dist/features/board/lib/BaseBoardImagePlugin.js +69 -0
- package/dist/features/board/lib/BaseBoardNotePlugin.js +11 -0
- package/dist/features/board/lib/BaseBoardPlugin.js +622 -0
- package/dist/features/board/lib/BaseBoardStrokePlugin.js +80 -0
- package/dist/features/board/lib/boardArrow.internal.js +193 -0
- package/dist/features/board/lib/boardCopy.internal.js +278 -0
- package/dist/features/board/lib/boardFrame.internal.js +125 -0
- package/dist/features/board/lib/boardHtml.internal.js +97 -0
- package/dist/features/board/lib/boardMember.internal.js +143 -0
- package/dist/features/board/lib/boardRatio.internal.js +21 -0
- package/dist/features/board/lib/boardShape.internal.js +193 -0
- package/dist/features/board/lib/boardStroke.internal.js +45 -0
- package/dist/features/board/lib/boardStyle.internal.js +126 -0
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +85 -0
- package/dist/features/callout/index.js +2 -0
- package/dist/features/callout/lib/BaseCalloutPlugin.js +30 -0
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +713 -0
- package/dist/features/code-block/lib/CodeBlockRules.js +21 -0
- package/dist/features/combobox/index.d.ts +3 -0
- package/dist/features/combobox/index.js +2 -0
- package/dist/features/combobox/lib/combobox.internal.js +111 -0
- package/dist/features/combobox/lib/filterWords.js +23 -0
- package/dist/features/comments/BaseCommentsPlugin.js +1237 -0
- package/dist/features/comments/index.d.ts +2 -0
- package/dist/features/comments/index.js +2 -0
- package/dist/features/comments/plite-comments.internal.js +2 -0
- package/dist/features/date/index.d.ts +42 -0
- package/dist/features/date/index.js +3 -0
- package/dist/features/date/lib/BaseDatePlugin.js +65 -0
- package/dist/features/date/lib/dateValue.js +17 -0
- package/dist/features/date/lib/legacyDateValue.internal.js +39 -0
- package/dist/features/details/index.d.ts +361 -0
- package/dist/features/details/index.js +2 -0
- package/dist/features/details/lib/BaseDetailsPlugin.js +438 -0
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +2 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +414 -0
- package/dist/features/field/lib/fieldRules.internal.js +42 -0
- package/dist/features/find/index.d.ts +75 -0
- package/dist/features/find/index.js +2 -0
- package/dist/features/find/lib/BaseFindPlugin.js +301 -0
- package/dist/features/footnote/index.d.ts +2 -0
- package/dist/features/footnote/index.js +2 -0
- package/dist/features/footnote/lib/BaseFootnotePlugin.js +434 -0
- package/dist/features/footnote/lib/internal/getFootnoteTarget.js +31 -0
- package/dist/features/indent/lib/BaseIndentPlugin.js +164 -0
- package/dist/features/indent/lib/indentLevel.internal.js +9 -0
- package/dist/features/ink/index.d.ts +2 -0
- package/dist/features/ink/index.js +2 -0
- package/dist/features/ink/lib/BaseInkPlugin.js +406 -0
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +288 -0
- package/dist/features/ink/lib/inkMatch.internal.js +207 -0
- package/dist/features/ink/lib/inkPlaces.internal.js +556 -0
- package/dist/features/layout/index.d.ts +2 -0
- package/dist/features/layout/index.js +2 -0
- package/dist/features/layout/lib/BaseColumnPlugin.js +249 -0
- package/dist/features/link/lib/BaseLinkPlugin.js +470 -0
- package/dist/features/lint/index.d.ts +91 -0
- package/dist/features/lint/index.js +2 -0
- package/dist/features/lint/lib/BaseLintPlugin.js +639 -0
- package/dist/features/list/lib/BaseListPlugin.js +869 -0
- package/dist/features/list/lib/listConversion.internal.js +55 -0
- package/dist/features/list/lib/listFamily.internal.js +120 -0
- package/dist/features/list/lib/listHtml.internal.js +79 -0
- package/dist/features/list/lib/listIdentity.internal.js +455 -0
- package/dist/features/list/lib/listIndex.internal.js +342 -0
- package/dist/features/list/lib/listNumbering.internal.js +391 -0
- package/dist/features/list/lib/listPaste.internal.js +81 -0
- package/dist/features/media/index.d.ts +2 -0
- package/dist/features/media/index.js +5 -0
- package/dist/features/media/lib/BaseMediaPlugin.js +351 -0
- package/dist/features/media/lib/image/BaseImagePlugin.js +395 -0
- package/dist/features/media/lib/media/parseMediaUrl.js +161 -0
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +140 -0
- package/dist/features/media/lib/mediaHtml.internal.js +43 -0
- package/dist/features/mention/index.d.ts +73 -0
- package/dist/features/mention/index.js +2 -0
- package/dist/features/mention/lib/BaseMentionPlugin.js +120 -0
- package/dist/features/suggestion/BaseSuggestionPlugin.js +30 -0
- package/dist/features/suggestion/index.d.ts +9 -0
- package/dist/features/suggestion/index.js +3 -0
- package/dist/features/suggestion/suggestionColorOf.js +14 -0
- package/dist/features/table/index.d.ts +2 -0
- package/dist/features/table/index.js +2 -0
- package/dist/features/table/lib/BaseTablePlugin.js +1400 -0
- package/dist/features/table/lib/internal/context.js +58 -0
- package/dist/features/table/lib/internal/grid.js +193 -0
- package/dist/features/table/lib/internal/mutation.js +636 -0
- package/dist/features/table/lib/internal/paste.js +327 -0
- package/dist/features/table/lib/internal/selection.js +309 -0
- package/dist/features/table/lib/internal/tableCellHtml.js +280 -0
- package/dist/features/table/lib/internal/tabularText.js +50 -0
- package/dist/features/toc/index.d.ts +2 -0
- package/dist/features/toc/index.js +2 -0
- package/dist/features/toc/lib/BaseTocPlugin.js +41 -0
- package/dist/features/upload/index.d.ts +2 -0
- package/dist/features/upload/index.js +2 -0
- package/dist/features/upload/lib/BaseUploadPlugin.js +930 -0
- package/dist/features/upload/lib/mimeTypes.internal.js +3982 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.js +1 -0
- package/dist/history/plite-history.internal.js +2 -0
- package/dist/html/index.d.ts +4 -0
- package/dist/html/index.js +3 -0
- package/dist/html/server/index.d.ts +3 -0
- package/dist/html/server/index.js +16 -0
- package/dist/htmlTypes-cg_cWsaN.d.ts +198 -0
- package/dist/hyperscript/index.d.ts +2 -0
- package/dist/hyperscript/index.js +1 -0
- package/dist/index-8WO2vI0U.d.ts +6519 -0
- package/dist/index-B5mYEawV.d.ts +750 -0
- package/dist/index-BZWFoUXt.d.ts +159 -0
- package/dist/index-C0POz7rg.d.ts +400 -0
- package/dist/index-C1_JIhL4.d.ts +526 -0
- package/dist/index-C35V_hj0.d.ts +6 -0
- package/dist/index-C6ql9pKw.d.ts +36 -0
- package/dist/index-C9DiGDVj.d.ts +558 -0
- package/dist/index-CLsEe3LY.d.ts +297 -0
- package/dist/index-CdOLsPaW.d.ts +318 -0
- package/dist/index-CktYvOgk.d.ts +29 -0
- package/dist/index-Cmuluh6f.d.ts +8 -0
- package/dist/index-CzLwBZpY.d.ts +46 -0
- package/dist/index-D3-2iM1b.d.ts +1084 -0
- package/dist/index-DKOFvteF.d.ts +184 -0
- package/dist/index-DPWyk3lG-DOYwohXO.d.ts +59 -0
- package/dist/index-DQnjqtQa.d.ts +678 -0
- package/dist/index-Do9pj1GK.d.ts +1218 -0
- package/dist/index-DpltOCot-A2b3p3Eb.d.ts +7644 -0
- package/dist/index-HPYawTae-BCUQLEWF.d.ts +111 -0
- package/dist/index-baQOK89E.d.ts +166 -0
- package/dist/index-oIJAZxc2.d.ts +2152 -0
- package/dist/index-r7yb77Wy.d.ts +2660 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +45 -7
- package/dist/internal/failInvariant.js +6 -0
- package/dist/internal/mergePlateRenderedAttributes.js +41 -0
- package/dist/internal/penStroke.internal.js +66 -0
- package/dist/internal/plugin/OverridePlugin.js +165 -0
- package/dist/internal/plugin/blockInsertion.js +67 -0
- package/dist/internal/plugin/blockRelease.js +60 -0
- package/dist/internal/plugin/collectPlateNodeMappings.js +62 -0
- package/dist/internal/plugin/compilePlainTextMappings.js +56 -0
- package/dist/internal/plugin/compilePlateFormats.js +127 -0
- package/dist/internal/plugin/compilePlateModel.js +780 -0
- package/dist/internal/plugin/compilePlateShortcuts.js +21 -0
- package/dist/internal/plugin/defaultElementTag.js +8 -0
- package/dist/internal/plugin/getPlateDecorationSources.js +47 -0
- package/dist/internal/plugin/getPluginRenderAttributes.js +20 -0
- package/dist/internal/plugin/imageLink.js +11 -0
- package/dist/internal/plugin/inlineInsertion.js +29 -0
- package/dist/internal/plugin/insertionAnchor.js +28 -0
- package/dist/internal/plugin/isEditOnlyDisabled.js +27 -0
- package/dist/internal/plugin/markdownParagraph.js +7 -0
- package/dist/internal/plugin/mergePluginCapabilities.js +90 -0
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/pipeInjectNodeProps.js +30 -0
- package/dist/internal/plugin/plateChangeHandlers.js +74 -0
- package/dist/internal/plugin/plateRuntime.js +23 -0
- package/dist/internal/plugin/pluginFormatOperation.js +100 -0
- package/dist/internal/plugin/pluginInjectNodeProps.js +79 -0
- package/dist/internal/plugin/pluginStore.js +167 -0
- package/dist/internal/plugin/resolvePlugin.js +231 -0
- package/dist/internal/plugin/resolvePlugins.js +1173 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/isFunction.js +6 -0
- package/dist/internal/utils/mergePlugins.js +219 -0
- package/dist/internal/utils/snapshotApiValue.js +29 -0
- package/dist/internal/utils/trustedContentSlice.js +9 -0
- package/dist/internal/utils/urlPolicy.js +110 -0
- package/dist/lib/editor/editorApplicationSchema.js +19 -0
- package/dist/lib/editor/editorUser.internal.js +39 -0
- package/dist/lib/editor/withPlite.js +480 -0
- package/dist/lib/libs/nanoid.js +2 -0
- package/dist/lib/libs/zustand.js +29 -0
- package/dist/lib/plugin/assertNoPrepareDocument.internal.js +7 -0
- package/dist/lib/plugin/createPluginContext.internal.js +363 -0
- package/dist/lib/plugin/defineBasePlugin.internal.js +203 -0
- package/dist/lib/plugin/definePlugin.js +11 -0
- package/dist/lib/plugin/pluginAuthoringContext.js +19 -0
- package/dist/lib/plugins/HistoryPlugin.js +15 -0
- package/dist/lib/plugins/TransferPlugin.js +7 -0
- package/dist/lib/plugins/affinity/AffinityPlugin.js +163 -0
- package/dist/lib/plugins/debug/DebugPlugin.js +65 -0
- package/dist/lib/plugins/dom/DOMPlugin.js +75 -0
- package/dist/lib/plugins/dom/plateDOMPlugin.internal.js +6 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +53 -0
- package/dist/lib/plugins/element-id/elementIdAdmission.internal.js +34 -0
- package/dist/lib/plugins/element-state/ElementStatePlugin.js +14 -0
- package/dist/lib/plugins/getCorePlugins.internal.js +25 -0
- package/dist/lib/plugins/html/HtmlPlugin.js +1970 -0
- package/dist/lib/plugins/html/htmlAst.js +314 -0
- package/dist/lib/plugins/html/htmlConversion.js +15 -0
- package/dist/lib/plugins/html/htmlDom.js +203 -0
- package/dist/lib/plugins/html/htmlMatcher.internal.js +85 -0
- package/dist/lib/plugins/html/htmlSafety.js +150 -0
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +327 -0
- package/dist/lib/plugins/input-rules/createInputRules.js +290 -0
- package/dist/lib/plugins/input-rules/defineInputRule.js +6 -0
- package/dist/lib/plugins/input-rules/inputRuleContinuation.internal.js +13 -0
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/lib/plugins/input-rules/inputRuleVeto.js +9 -0
- package/dist/lib/plugins/input-rules/markInputRule.internal.js +44 -0
- package/dist/lib/plugins/paragraph/BaseParagraphPlugin.js +17 -0
- package/dist/lib/utils/applyDeepToNodes.js +17 -0
- package/dist/lib/utils/defaultsDeepToNodes.js +12 -0
- package/dist/lib/utils/environment.js +4 -0
- package/dist/lib/utils/getFragmentProp.js +27 -0
- package/dist/lib/utils/getInjectMatch.js +42 -0
- package/dist/lib/utils/hotkeys.js +113 -0
- package/dist/lib/utils/isDefined.js +5 -0
- package/dist/lib/utils/isUrl.js +27 -0
- package/dist/lib/utils/mergeDeepToNodes.js +12 -0
- package/dist/lib/utils/pluginNodeClass.js +10 -0
- package/dist/markdown/index.d.ts +2 -0
- package/dist/markdown/index.js +3 -0
- package/dist/markdown/lib/MarkdownPlugin.js +171 -0
- package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
- package/dist/markdown/lib/deserializer/convertChildrenDeserialize.js +8 -0
- package/dist/markdown/lib/deserializer/convertNodesDeserialize.js +79 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +28 -0
- package/dist/markdown/lib/internal/markdownAttributes.js +178 -0
- package/dist/markdown/lib/internal/markdownConversion.js +1365 -0
- package/dist/markdown/lib/internal/markdownDiagnostics.js +145 -0
- package/dist/markdown/lib/internal/markdownDocument.js +70 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +383 -0
- package/dist/markdown/lib/internal/markdownLine.js +550 -0
- package/dist/markdown/lib/internal/markdownMappings.js +677 -0
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +314 -0
- package/dist/markdown/lib/internal/markdownReferences.js +70 -0
- package/dist/markdown/lib/internal/markdownSafety.js +57 -0
- package/dist/markdown/lib/internal/markdownSegments.js +143 -0
- package/dist/markdown/lib/internal/markdownTags.js +709 -0
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +85 -0
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +235 -0
- package/dist/markdown/lib/serializer/mdastContent.js +22 -0
- package/dist/markdown/lib/serializer/reportOmittedProperties.js +34 -0
- package/dist/markdown/lib/utils/remarkPlugins.js +34 -0
- package/dist/math/index.d.ts +519 -0
- package/dist/math/index.js +2 -0
- package/dist/math/lib/BaseEquationPlugin.js +345 -0
- package/dist/math/lib/mathmlTex.internal.js +1123 -0
- package/dist/math/lib/mathmlTexSymbols.internal.js +1852 -0
- package/dist/math/react/EquationPlugin.js +7 -0
- package/dist/math/react/index.d.ts +66 -0
- package/dist/math/react/index.js +2 -0
- package/dist/migrations/documentMigrationAuthored.internal.js +18 -0
- package/dist/migrations/documentMigrationSelection.internal.js +27 -0
- package/dist/migrations/documentMigrationTarget.internal.js +17 -0
- package/dist/migrations/documentMigrations.js +320 -0
- package/dist/migrations/extractLegacyCommentRanges.js +141 -0
- package/dist/migrations/index.d.ts +206 -0
- package/dist/migrations/index.js +5 -0
- package/dist/migrations/migrateListIdentity.js +93 -0
- package/dist/migrations/migratePlateV54.js +170 -0
- package/dist/migrations/migratePlateV54Ast.internal.js +381 -0
- package/dist/migrations/migratePlateV54BuiltIns.internal.js +87 -0
- package/dist/migrations/migratePlateV54CodeBlocks.internal.js +87 -0
- package/dist/migrations/migratePlateV54Inputs.internal.js +186 -0
- package/dist/migrations/migratePlateV54Ownership.internal.js +20 -0
- package/dist/migrations/migratePlateV54Profile.internal.js +367 -0
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +48 -0
- package/dist/migrations/migratePlateV54Suggestions.internal.js +236 -0
- package/dist/migrations/migratePlateV54Urls.internal.js +125 -0
- package/dist/migrations/v53-manifest.internal.js +271 -0
- package/dist/node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.8/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +73 -0
- package/dist/node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.8/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +75 -0
- package/dist/node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.8/node_modules/use-sync-external-store/with-selector.js +11 -0
- package/dist/pagination/index.d.ts +167 -0
- package/dist/pagination/index.js +2 -0
- package/dist/pagination/react/PagedEditorContent.js +77 -0
- package/dist/pagination/react/index.d.ts +37 -0
- package/dist/pagination/react/index.js +5 -0
- package/dist/plain-text.js +38 -0
- package/dist/react/components/EditorContentView.internal.js +284 -0
- package/dist/react/components/EditorProvider.js +32 -0
- package/dist/react/components/EditorRefEffect.js +65 -0
- package/dist/react/components/NodeSelection.js +836 -0
- package/dist/react/components/Plate.js +244 -0
- package/dist/react/components/PlateContainer.js +103 -0
- package/dist/react/components/PlateContent.js +36 -0
- package/dist/react/components/PlateController.js +39 -0
- package/dist/react/components/PlateRoot.internal.js +89 -0
- package/dist/react/components/PlateView.js +43 -0
- package/dist/react/components/plate-nodes.js +146 -0
- package/dist/react/core.js +59 -0
- package/dist/react/editor/getPlateCorePlugins.internal.js +20 -0
- package/dist/react/editor/useCreateEditor.js +43 -0
- package/dist/react/editor/withPlate.js +22 -0
- package/dist/react/features/basic-nodes/BasicNodesPlugins.js +29 -0
- package/dist/react/features/basic-styles/BasicStylePlugins.js +15 -0
- package/dist/react/features/board/BoardPlugin.js +23 -0
- package/dist/react/features/board/BoardShape.js +272 -0
- package/dist/react/features/board/BoardSurface.js +315 -0
- package/dist/react/features/board/boardClipboard.internal.js +100 -0
- package/dist/react/features/board/boardConnect.internal.js +198 -0
- package/dist/react/features/board/boardGesture.internal.js +583 -0
- package/dist/react/features/board/boardIndex.internal.js +426 -0
- package/dist/react/features/board/boardInk.internal.js +41 -0
- package/dist/react/features/board/boardKeys.internal.js +484 -0
- package/dist/react/features/board/boardPick.internal.js +73 -0
- package/dist/react/features/board/boardPicking.internal.js +84 -0
- package/dist/react/features/board/boardPictures.internal.js +96 -0
- package/dist/react/features/board/boardPreview.internal.js +177 -0
- package/dist/react/features/board/boardResize.internal.js +153 -0
- package/dist/react/features/board/boardSnap.internal.js +267 -0
- package/dist/react/features/board/boardView.internal.js +1074 -0
- package/dist/react/features/board/boardVoice.internal.js +192 -0
- package/dist/react/features/board/index.d.ts +2140 -0
- package/dist/react/features/board/index.js +4 -0
- package/dist/react/features/callout/CalloutPlugin.js +6 -0
- package/dist/react/features/callout/index.d.ts +84 -0
- package/dist/react/features/callout/index.js +2 -0
- package/dist/react/features/code-block/CodeBlockPlugin.js +9 -0
- package/dist/react/features/combobox/comboboxOwner.internal.js +269 -0
- package/dist/react/features/combobox/index.d.ts +63 -0
- package/dist/react/features/combobox/index.js +2 -0
- package/dist/react/features/combobox/useCombobox.js +71 -0
- package/dist/react/features/comments/CommentsPlugin.js +34 -0
- package/dist/react/features/comments/index.d.ts +605 -0
- package/dist/react/features/comments/index.js +2 -0
- package/dist/react/features/date/DatePlugin.js +6 -0
- package/dist/react/features/date/index.d.ts +40 -0
- package/dist/react/features/date/index.js +2 -0
- package/dist/react/features/details/DetailsPlugin.js +8 -0
- package/dist/react/features/details/index.d.ts +500 -0
- package/dist/react/features/details/index.js +2 -0
- package/dist/react/features/field/FieldPlugin.js +34 -0
- package/dist/react/features/field/index.d.ts +312 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/FootnotePlugin.js +36 -0
- package/dist/react/features/footnote/index.d.ts +245 -0
- package/dist/react/features/footnote/index.js +2 -0
- package/dist/react/features/format-painter/FormatPainterPlugin.js +156 -0
- package/dist/react/features/format-painter/index.d.ts +205 -0
- package/dist/react/features/format-painter/index.js +2 -0
- package/dist/react/features/indent/IndentPlugin.js +6 -0
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/InkCopyView.js +203 -0
- package/dist/react/features/ink/InkPlugin.js +35 -0
- package/dist/react/features/ink/index.d.ts +354 -0
- package/dist/react/features/ink/index.js +4 -0
- package/dist/react/features/ink/inkCapture.internal.js +336 -0
- package/dist/react/features/ink/inkInput.internal.js +19 -0
- package/dist/react/features/ink/inkLayout.internal.js +29 -0
- package/dist/react/features/ink/inkMeasure.internal.js +242 -0
- package/dist/react/features/ink/inkPaint.internal.js +93 -0
- package/dist/react/features/ink/inkPlacement.internal.js +557 -0
- package/dist/react/features/ink/inkWatch.internal.js +288 -0
- package/dist/react/features/layout/ColumnPlugin.js +8 -0
- package/dist/react/features/layout/index.d.ts +543 -0
- package/dist/react/features/layout/index.js +2 -0
- package/dist/react/features/link/LinkPlugin.js +7 -0
- package/dist/react/features/list/ListPlugin.js +125 -0
- package/dist/react/features/media/index.d.ts +670 -0
- package/dist/react/features/media/index.js +2 -0
- package/dist/react/features/media/plugins.js +12 -0
- package/dist/react/features/mention/MentionPlugin.js +6 -0
- package/dist/react/features/mention/index.d.ts +63 -0
- package/dist/react/features/mention/index.js +2 -0
- package/dist/react/features/resizable/Resizable.js +201 -0
- package/dist/react/features/resizable/index.d.ts +27 -0
- package/dist/react/features/resizable/index.js +2 -0
- package/dist/react/features/resizable/resizeLength.internal.js +11 -0
- package/dist/react/features/suggestion/SuggestionPlugin.js +24 -0
- package/dist/react/features/suggestion/index.d.ts +45 -0
- package/dist/react/features/suggestion/index.js +3 -0
- package/dist/react/features/suggestion/suggestion-view.internal.js +112 -0
- package/dist/react/features/suggestion/useSuggestion.js +135 -0
- package/dist/react/features/table/TablePlugin.js +425 -0
- package/dist/react/features/table/index.d.ts +4707 -0
- package/dist/react/features/table/index.js +3 -0
- package/dist/react/features/table/tableSelectionHostBinding.internal.js +97 -0
- package/dist/react/features/table/useTableResize.js +88 -0
- package/dist/react/features/toc/TocPlugin.js +6 -0
- package/dist/react/features/toc/index.d.ts +20 -0
- package/dist/react/features/toc/index.js +2 -0
- package/dist/react/features/upload/UploadPlugin.js +41 -0
- package/dist/react/features/upload/index.d.ts +313 -0
- package/dist/react/features/upload/index.js +2 -0
- package/dist/react/index.d.ts +6 -4
- package/dist/react/index.js +76 -7
- package/dist/react/internal/block-redraws.js +83 -0
- package/dist/react/internal/getPlateEditorInstanceKey.js +13 -0
- package/dist/react/internal/plate-context.js +507 -0
- package/dist/react/internal/plite-components.js +12 -0
- package/dist/react/internal/react-helpers.js +19 -0
- package/dist/react/internal/rendered-attributes.js +190 -0
- package/dist/react/internal/useDeepCompareMemo.js +13 -0
- package/dist/react/internal/usePlateInstancesWarn.js +24 -0
- package/dist/react/internal/usePlateModelRevision.js +17 -0
- package/dist/react/internal/useZustandSelector.js +35 -0
- package/dist/react/libs/jotai.js +3 -0
- package/dist/react/plite-react.js +2 -0
- package/dist/react/plugin/createPluginContext.internal.js +7 -0
- package/dist/react/plugin/definePlugin.js +26 -0
- package/dist/react/plugin/pluginFactory.internal.js +43 -0
- package/dist/react/plugin/toReactPlugin.js +86 -0
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +109 -0
- package/dist/react/plugins/paragraph/ParagraphPlugin.js +14 -0
- package/dist/react/stores/element/useElement.js +11 -0
- package/dist/react/stores/element/useElementSelector.js +20 -0
- package/dist/react/stores/element/useElementStore.js +150 -0
- package/dist/react/stores/element/useElementStoreSelector.internal.js +69 -0
- package/dist/react/stores/element/usePath.js +57 -0
- package/dist/react/stores/plate/useEditor.js +136 -0
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +70 -0
- package/dist/react/stores/plate/usePluginStore.js +56 -0
- package/dist/react/stores/plate/useViewStore.js +35 -0
- package/dist/react/stores/plate-controller/document-focus.internal.js +72 -0
- package/dist/react/stores/plate-controller/useFocusedLast.js +30 -0
- package/dist/react/utils/BlockPlaceholderPlugin.js +59 -0
- package/dist/react/utils/annotationPointer.internal.js +35 -0
- package/dist/react/utils/bindPointerSession.internal.js +35 -0
- package/dist/react/utils/dispatchPlateShortcut.internal.js +19 -0
- package/dist/react/utils/dom-attributes.internal.js +160 -0
- package/dist/react/utils/editableKeyDown.internal.js +11 -0
- package/dist/react/utils/getRenderNodeProps.internal.js +58 -0
- package/dist/react/utils/pipeHandler.internal.js +71 -0
- package/dist/react/utils/pipeRenderElement.internal.js +495 -0
- package/dist/react/utils/pipeRenderLeaf.internal.js +181 -0
- package/dist/react/utils/pipeRenderText.internal.js +138 -0
- package/dist/react/utils/pluginRenderElement.internal.js +163 -0
- package/dist/react/utils/pluginRenderLeaf.internal.js +89 -0
- package/dist/react/utils/pluginRenderText.internal.js +52 -0
- package/dist/react/utils/tapOrder.internal.js +106 -0
- package/dist/react/utils/useSelectionFragment.js +24 -0
- package/dist/react/virtualized.d.ts +13 -0
- package/dist/react/virtualized.js +48 -0
- package/dist/root.js +45 -0
- package/dist/source-aUwpNnAw.d.ts +144 -0
- package/dist/static/components/PlateStatic.js +389 -0
- package/dist/static/components/plite-nodes.js +43 -0
- package/dist/static/index.d.ts +129 -1
- package/dist/static/index.js +4 -1
- package/dist/static/internal/getPlainText.js +23 -0
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +33 -0
- package/dist/static/internal/staticDocumentView.js +53 -0
- package/dist/static/internal/staticPresentation.js +67 -0
- package/dist/static/internal/writeStaticSelectionClipboardData.js +222 -0
- package/dist/static/pipeRenderElementStatic.internal.js +32 -0
- package/dist/static/pluginRenderElementStatic.internal.js +70 -0
- package/dist/static/pluginRenderLeafStatic.internal.js +87 -0
- package/dist/static/pluginRenderTextStatic.internal.js +87 -0
- package/dist/static/renderStaticHtml.js +9 -0
- package/dist/static/utils/getRenderNodeStaticProps.internal.js +31 -0
- package/dist/tabbable/index.d.ts +2 -0
- package/dist/tabbable/index.js +0 -0
- package/dist/tabbable/react/TabbableEffects.internal.js +186 -0
- package/dist/tabbable/react/TabbablePlugin.js +15 -0
- package/dist/tabbable/react/index.d.ts +16 -0
- package/dist/tabbable/react/index.js +2 -0
- package/dist/testing/index.d.ts +175 -0
- package/dist/testing/index.js +1 -0
- package/dist/utils/plate-keys.js +78 -0
- package/dist/utils/plugins/ExitBreakPlugin.js +26 -0
- package/dist/utils/plugins/SingleBlockPlugin.js +21 -0
- package/dist/utils/plugins/SingleLinePlugin.js +32 -0
- package/dist/utils/plugins/TrailingBlockPlugin.js +29 -0
- package/dist/utils/plugins/joinSingleRootBlock.internal.js +24 -0
- package/dist/yjs/index.d.ts +2 -0
- package/dist/yjs/index.js +1 -0
- package/dist/yjs/react/YjsPlugin.js +60 -0
- package/dist/yjs/react/index.d.ts +94 -0
- package/dist/yjs/react/index.js +3 -0
- package/package.json +684 -36
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { ElementApi, TextApi } from "../facade.js";
|
|
2
|
+
import { parseLegacyDateValue } from "../features/date/lib/legacyDateValue.internal.js";
|
|
3
|
+
import { resolveV54BuiltIns } from "./migratePlateV54BuiltIns.internal.js";
|
|
4
|
+
import { createPropertyOwnership } from "./migratePlateV54Ownership.internal.js";
|
|
5
|
+
//#region src/migrations/migratePlateV54Ast.internal.ts
|
|
6
|
+
const TEXT_ALIGNMENTS = /* @__PURE__ */ new Set([
|
|
7
|
+
"center",
|
|
8
|
+
"end",
|
|
9
|
+
"justify",
|
|
10
|
+
"left",
|
|
11
|
+
"right",
|
|
12
|
+
"start"
|
|
13
|
+
]);
|
|
14
|
+
const CSS_LINE_HEIGHT = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))(?:e([+-]?\d+))?(%|em)?$/i;
|
|
15
|
+
const migrateLineHeight = (value) => {
|
|
16
|
+
if (typeof value === "number") return Number.isFinite(value) && value > 0 ? value : void 0;
|
|
17
|
+
if (typeof value !== "string") return void 0;
|
|
18
|
+
const match = CSS_LINE_HEIGHT.exec(value.trim());
|
|
19
|
+
if (!match) return void 0;
|
|
20
|
+
const [, digits, exponent = "0", unit] = match;
|
|
21
|
+
const lineHeight = Number(`${digits}e${Number(exponent) - (unit === "%" ? 2 : 0)}`);
|
|
22
|
+
return Number.isFinite(lineHeight) && lineHeight > 0 ? lineHeight : void 0;
|
|
23
|
+
};
|
|
24
|
+
const isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
25
|
+
const safeInteger = (value) => {
|
|
26
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
27
|
+
const integer = Math.trunc(value);
|
|
28
|
+
return Number.isSafeInteger(integer) ? integer : void 0;
|
|
29
|
+
};
|
|
30
|
+
/** Apply the final AST contracts inside the Plate v54 migration. */
|
|
31
|
+
const migratePlateV54Ast = ({ document, target: conversionTarget }) => {
|
|
32
|
+
const { declared, detailsSummaryType, detailsType, elementType, equationTypes, mediaTypes } = resolveV54BuiltIns(conversionTarget);
|
|
33
|
+
const { declares, ownsProperty } = createPropertyOwnership(conversionTarget);
|
|
34
|
+
const dateType = elementType("date");
|
|
35
|
+
const mentionType = elementType("mention");
|
|
36
|
+
const footnoteDefinitionType = elementType("footnoteDefinition");
|
|
37
|
+
const footnoteReferenceType = elementType("footnote");
|
|
38
|
+
const columnGroupType = elementType("columnGroup");
|
|
39
|
+
const columnType = elementType("column");
|
|
40
|
+
const fileType = elementType("file");
|
|
41
|
+
const excalidrawType = elementType("excalidraw");
|
|
42
|
+
const imageType = elementType("image");
|
|
43
|
+
const tableType = elementType("table");
|
|
44
|
+
const tableRowType = elementType("tableRow");
|
|
45
|
+
const tableCellType = elementType("tableCell");
|
|
46
|
+
const legacyDepth = (element, location) => {
|
|
47
|
+
const rawIndent = element.indent;
|
|
48
|
+
if (rawIndent !== void 0 && (typeof rawIndent !== "number" || !Number.isFinite(rawIndent))) throw new Error(`Plate v54 migration cannot group legacy Toggle at ${location}: indentation must be finite.`);
|
|
49
|
+
const indent = rawIndent === void 0 ? 0 : Math.trunc(rawIndent);
|
|
50
|
+
return element.listType === void 0 || indent <= 0 ? indent : indent - 1;
|
|
51
|
+
};
|
|
52
|
+
const consumeLegacyEnclosureDepth = (input, location) => {
|
|
53
|
+
if (TextApi.isText(input)) return input;
|
|
54
|
+
const children = input.children.map((child, index) => consumeLegacyEnclosureDepth(child, `${location}.children.${index}`));
|
|
55
|
+
const rawIndent = input.indent;
|
|
56
|
+
if (rawIndent !== void 0 && (typeof rawIndent !== "number" || !Number.isFinite(rawIndent))) throw new Error(`Plate v54 migration cannot group legacy Toggle at ${location}: indentation must be finite.`);
|
|
57
|
+
return {
|
|
58
|
+
...input,
|
|
59
|
+
...rawIndent === void 0 ? {} : { indent: Math.trunc(rawIndent) - 1 },
|
|
60
|
+
children
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const convertLegacyToggle = (input, body, location, context) => {
|
|
64
|
+
if (!detailsType || !detailsSummaryType) throw new Error(`Plate v54 migration cannot convert legacy Toggle at ${location}: Details and DetailsSummary must be installed.`);
|
|
65
|
+
const detailsProperties = {};
|
|
66
|
+
const summaryProperties = {};
|
|
67
|
+
const detailsStyleProperties = /* @__PURE__ */ new Set([
|
|
68
|
+
"checked",
|
|
69
|
+
"indent",
|
|
70
|
+
"listRestart",
|
|
71
|
+
"listStart",
|
|
72
|
+
"listStyle",
|
|
73
|
+
"listType"
|
|
74
|
+
]);
|
|
75
|
+
const summaryContext = {
|
|
76
|
+
ancestors: [detailsType, ...context.ancestors],
|
|
77
|
+
root: context.root
|
|
78
|
+
};
|
|
79
|
+
for (const [key, value] of Object.entries(input)) {
|
|
80
|
+
if (key === "children" || key === "type") continue;
|
|
81
|
+
if (detailsStyleProperties.has(key)) {
|
|
82
|
+
if (!ownsProperty(detailsType, key, context)) throw new Error(`Plate v54 migration cannot convert legacy Toggle at ${location}: Details does not own property "${key}".`);
|
|
83
|
+
detailsProperties[key] = value;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (ownsProperty(detailsSummaryType, key, summaryContext)) {
|
|
87
|
+
summaryProperties[key] = value;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (ownsProperty(detailsType, key, context)) {
|
|
91
|
+
detailsProperties[key] = value;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (key === "id") continue;
|
|
95
|
+
throw new Error(`Plate v54 migration cannot convert legacy Toggle at ${location}: neither Details nor Summary owns property "${key}".`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
...detailsProperties,
|
|
99
|
+
children: [{
|
|
100
|
+
...summaryProperties,
|
|
101
|
+
children: input.children,
|
|
102
|
+
type: detailsSummaryType
|
|
103
|
+
}, ...body],
|
|
104
|
+
type: detailsType
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const occupiedFootnoteRefs = /* @__PURE__ */ new Set();
|
|
108
|
+
const collectFootnoteRefs = (input) => {
|
|
109
|
+
if (TextApi.isText(input)) return;
|
|
110
|
+
if (input.type === footnoteDefinitionType || input.type === footnoteReferenceType) {
|
|
111
|
+
if (isNonEmptyString(input.identifier)) occupiedFootnoteRefs.add(input.identifier);
|
|
112
|
+
if (isNonEmptyString(input.ref)) occupiedFootnoteRefs.add(input.ref);
|
|
113
|
+
}
|
|
114
|
+
input.children.forEach(collectFootnoteRefs);
|
|
115
|
+
};
|
|
116
|
+
document.children.forEach(collectFootnoteRefs);
|
|
117
|
+
Object.values(document.roots ?? {}).forEach((children) => {
|
|
118
|
+
children.forEach(collectFootnoteRefs);
|
|
119
|
+
});
|
|
120
|
+
const allocateUnresolvedFootnoteRef = (location) => {
|
|
121
|
+
const base = `unresolved:${location}`;
|
|
122
|
+
let candidate = base;
|
|
123
|
+
let suffix = 1;
|
|
124
|
+
while (occupiedFootnoteRefs.has(candidate)) {
|
|
125
|
+
candidate = `${base}:${suffix}`;
|
|
126
|
+
suffix += 1;
|
|
127
|
+
}
|
|
128
|
+
occupiedFootnoteRefs.add(candidate);
|
|
129
|
+
return candidate;
|
|
130
|
+
};
|
|
131
|
+
let migrateChildren;
|
|
132
|
+
const migrateDescendant = (input, location, context) => {
|
|
133
|
+
if (TextApi.isText(input)) return input;
|
|
134
|
+
const children = migrateChildren(input.children, `${location}.children`, {
|
|
135
|
+
ancestors: [input.type, ...context.ancestors],
|
|
136
|
+
root: context.root
|
|
137
|
+
});
|
|
138
|
+
let element = children === input.children ? input : {
|
|
139
|
+
...input,
|
|
140
|
+
children
|
|
141
|
+
};
|
|
142
|
+
const properties = () => element;
|
|
143
|
+
const without = (...keys) => {
|
|
144
|
+
if (!keys.some((key) => Object.hasOwn(element, key))) return;
|
|
145
|
+
const next = { ...element };
|
|
146
|
+
for (const key of keys) delete next[key];
|
|
147
|
+
element = next;
|
|
148
|
+
};
|
|
149
|
+
const setMigratedProperty = (key, value, source) => {
|
|
150
|
+
if (Object.hasOwn(element, key)) {
|
|
151
|
+
if (!Object.is(properties()[key], value)) throw new Error(`Plate v54 migration collision at ${location}: ${source} conflicts with property "${key}".`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
element = {
|
|
155
|
+
...element,
|
|
156
|
+
[key]: value
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
if (dateType && element.type === dateType) {
|
|
160
|
+
const { date: dateProperty, rawDate: rawDateProperty } = properties();
|
|
161
|
+
const rawDate = isNonEmptyString(rawDateProperty) ? rawDateProperty : void 0;
|
|
162
|
+
const date = isNonEmptyString(dateProperty) ? dateProperty : void 0;
|
|
163
|
+
if (rawDate !== void 0 && date !== void 0 && rawDate !== date) throw new Error(`Plate v54 migration collision at ${location}: properties "rawDate" and "date" conflict.`);
|
|
164
|
+
const legacyValue = rawDate ?? (date === void 0 ? void 0 : parseLegacyDateValue(date) ?? date);
|
|
165
|
+
if (!(legacyValue ?? (isNonEmptyString(properties().value) ? properties().value : void 0))) return { text: "" };
|
|
166
|
+
if (Object.hasOwn(element, "value") && (!isNonEmptyString(properties().value) || properties().value === date)) without("value");
|
|
167
|
+
if (legacyValue !== void 0) setMigratedProperty("value", legacyValue, "`date` / `rawDate`");
|
|
168
|
+
without("date", "rawDate");
|
|
169
|
+
}
|
|
170
|
+
if (mentionType && element.type === mentionType) {
|
|
171
|
+
const rawLegacyKey = properties().key;
|
|
172
|
+
const hasLegacyKey = Object.hasOwn(element, "key");
|
|
173
|
+
const legacyKey = isNonEmptyString(rawLegacyKey) ? rawLegacyKey : typeof rawLegacyKey === "number" && Number.isFinite(rawLegacyKey) ? String(rawLegacyKey) : void 0;
|
|
174
|
+
const rawLegacyValue = properties().value;
|
|
175
|
+
const rawExistingLabel = properties().label;
|
|
176
|
+
const rawExistingRef = properties().ref;
|
|
177
|
+
const legacyValue = isNonEmptyString(rawLegacyValue) ? rawLegacyValue : void 0;
|
|
178
|
+
const existingLabel = isNonEmptyString(rawExistingLabel) ? rawExistingLabel : void 0;
|
|
179
|
+
const existingRef = isNonEmptyString(rawExistingRef) ? rawExistingRef : void 0;
|
|
180
|
+
if (hasLegacyKey && legacyKey === void 0 && existingRef === void 0) return { text: `@${existingLabel ?? legacyValue ?? ""}` };
|
|
181
|
+
const legacyRef = existingRef !== void 0 && legacyKey === void 0 ? void 0 : legacyKey ?? (isNonEmptyString(legacyValue) ? legacyValue : void 0);
|
|
182
|
+
const ref = legacyRef ?? existingRef;
|
|
183
|
+
if (!ref) return { text: `@${existingLabel ?? legacyValue ?? ""}` };
|
|
184
|
+
if (Object.hasOwn(element, "ref") && existingRef === void 0) without("ref");
|
|
185
|
+
if (legacyRef !== void 0) setMigratedProperty("ref", legacyRef, "`key` / `value`");
|
|
186
|
+
const legacyLabel = (legacyKey !== void 0 || existingRef !== void 0) && legacyValue !== void 0 && legacyValue !== ref ? legacyValue : void 0;
|
|
187
|
+
if (Object.hasOwn(element, "label") && existingLabel === void 0) without("label");
|
|
188
|
+
if (legacyLabel !== void 0) setMigratedProperty("label", legacyLabel, "`value`");
|
|
189
|
+
without("key", "value");
|
|
190
|
+
}
|
|
191
|
+
if (footnoteDefinitionType && element.type === footnoteDefinitionType || footnoteReferenceType && element.type === footnoteReferenceType) {
|
|
192
|
+
const legacyRef = isNonEmptyString(properties().identifier) ? properties().identifier : void 0;
|
|
193
|
+
const existingRef = isNonEmptyString(properties().ref) ? properties().ref : void 0;
|
|
194
|
+
const ref = legacyRef ?? existingRef ?? allocateUnresolvedFootnoteRef(location);
|
|
195
|
+
if (Object.hasOwn(element, "ref") && existingRef === void 0) without("ref");
|
|
196
|
+
if (legacyRef !== void 0) setMigratedProperty("ref", legacyRef, "`identifier`");
|
|
197
|
+
else if (existingRef === void 0) setMigratedProperty("ref", ref, "missing footnote association");
|
|
198
|
+
without("identifier");
|
|
199
|
+
}
|
|
200
|
+
if (columnGroupType && element.type === columnGroupType) {
|
|
201
|
+
const { layout } = properties();
|
|
202
|
+
if (columnType) {
|
|
203
|
+
const columnCount = element.children.filter((child) => ElementApi.isElement(child) && child.type === columnType).length;
|
|
204
|
+
const fallbackWidth = `${100 / Math.max(columnCount, 1)}%`;
|
|
205
|
+
const nextChildren = element.children.map((child, index) => {
|
|
206
|
+
const width = Array.isArray(layout) ? layout[index] : void 0;
|
|
207
|
+
const layoutWidth = typeof width === "number" && Number.isFinite(width) && width > 0 ? `${width}%` : fallbackWidth;
|
|
208
|
+
if (!ElementApi.isElement(child) || child.type !== columnType) return child;
|
|
209
|
+
if (isNonEmptyString(child.width)) {
|
|
210
|
+
if (typeof width === "number" && Number.isFinite(width) && width > 0 && child.width !== layoutWidth) throw new Error(`Plate v54 migration collision at ${location}.children.${index}: layout width "${layoutWidth}" conflicts with property "width" value "${child.width}".`);
|
|
211
|
+
return child;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
...child,
|
|
215
|
+
width: layoutWidth
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
if (nextChildren.some((child, index) => child !== element.children[index])) element = {
|
|
219
|
+
...element,
|
|
220
|
+
children: nextChildren
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
without("layout");
|
|
224
|
+
}
|
|
225
|
+
if (mediaTypes.has(element.type) && element.type !== fileType && Object.hasOwn(element, "name") && !ownsProperty(element.type, "name", context)) without("name");
|
|
226
|
+
if (element.type === excalidrawType && Object.hasOwn(element, "width") && !ownsProperty(element.type, "width", context)) without("width");
|
|
227
|
+
if (equationTypes.has(element.type)) {
|
|
228
|
+
const legacyLatex = isNonEmptyString(properties().texExpression) ? properties().texExpression : void 0;
|
|
229
|
+
const existingLatexValid = typeof properties().latex === "string" && (legacyLatex === void 0 || isNonEmptyString(properties().latex));
|
|
230
|
+
if (!existingLatexValid && Object.hasOwn(element, "latex")) without("latex");
|
|
231
|
+
if (legacyLatex !== void 0) setMigratedProperty("latex", legacyLatex, "`texExpression`");
|
|
232
|
+
else if (!existingLatexValid) setMigratedProperty("latex", "", "missing equation source");
|
|
233
|
+
without("texExpression");
|
|
234
|
+
}
|
|
235
|
+
for (const key of ["listRestart", "listStart"]) {
|
|
236
|
+
if (!Object.hasOwn(element, key) || !declares(declared.list, element.type, key, context)) continue;
|
|
237
|
+
const value = safeInteger(properties()[key]);
|
|
238
|
+
if (value === void 0) without(key);
|
|
239
|
+
else if (value !== properties()[key]) element = {
|
|
240
|
+
...element,
|
|
241
|
+
[key]: value
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (declares(declared.indent, element.type, "indent", context) && Object.hasOwn(element, "indent")) {
|
|
245
|
+
const indent = safeInteger(properties().indent);
|
|
246
|
+
if (indent === void 0 || indent < 0) without("indent");
|
|
247
|
+
else if (indent !== properties().indent) element = {
|
|
248
|
+
...element,
|
|
249
|
+
indent
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
if (declares(declared.textAlign, element.type, "textAlign", context) && Object.hasOwn(element, "textAlign") && !TEXT_ALIGNMENTS.has(String(properties().textAlign))) without("textAlign");
|
|
253
|
+
if (declares(declared.lineHeight, element.type, "lineHeight", context) && Object.hasOwn(element, "lineHeight")) {
|
|
254
|
+
const lineHeight = migrateLineHeight(properties().lineHeight);
|
|
255
|
+
if (lineHeight === void 0) without("lineHeight");
|
|
256
|
+
else if (lineHeight !== properties().lineHeight) element = {
|
|
257
|
+
...element,
|
|
258
|
+
lineHeight
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (imageType && element.type === imageType) for (const key of ["naturalHeight", "naturalWidth"]) {
|
|
262
|
+
if (!Object.hasOwn(element, key)) continue;
|
|
263
|
+
const value = safeInteger(properties()[key]);
|
|
264
|
+
if (value === void 0 || value <= 0) without(key);
|
|
265
|
+
else if (value !== properties()[key]) element = {
|
|
266
|
+
...element,
|
|
267
|
+
[key]: value
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
if (tableCellType && element.type === tableCellType) {
|
|
271
|
+
for (const key of ["colSpan", "rowSpan"]) {
|
|
272
|
+
if (!Object.hasOwn(element, key)) continue;
|
|
273
|
+
const value = properties()[key];
|
|
274
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) without(key);
|
|
275
|
+
}
|
|
276
|
+
if (Object.hasOwn(element, "borders")) {
|
|
277
|
+
const { borders } = properties();
|
|
278
|
+
if (typeof borders === "object" && borders !== null && !Array.isArray(borders)) {
|
|
279
|
+
let bordersChanged = false;
|
|
280
|
+
const directions = /* @__PURE__ */ new Set([
|
|
281
|
+
"bottom",
|
|
282
|
+
"left",
|
|
283
|
+
"right",
|
|
284
|
+
"top"
|
|
285
|
+
]);
|
|
286
|
+
const nextBorders = Object.fromEntries(Object.entries(borders).flatMap(([direction, border]) => {
|
|
287
|
+
if (!directions.has(direction)) {
|
|
288
|
+
bordersChanged = true;
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
if (typeof border !== "object" || border === null || Array.isArray(border)) {
|
|
292
|
+
bordersChanged = true;
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
const record = border;
|
|
296
|
+
const nextBorder = {};
|
|
297
|
+
if (typeof record.color === "string") nextBorder.color = record.color;
|
|
298
|
+
if (typeof record.style === "string") nextBorder.style = record.style;
|
|
299
|
+
if (typeof record.width === "number" && Number.isFinite(record.width)) nextBorder.width = Math.max(0, record.width);
|
|
300
|
+
if (Object.keys(record).length !== Object.keys(nextBorder).length || Object.entries(nextBorder).some(([key, value]) => !Object.is(record[key], value))) bordersChanged = true;
|
|
301
|
+
return [[direction, nextBorder]];
|
|
302
|
+
}));
|
|
303
|
+
if (bordersChanged) element = {
|
|
304
|
+
...element,
|
|
305
|
+
borders: nextBorders
|
|
306
|
+
};
|
|
307
|
+
} else without("borders");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (tableRowType && element.type === tableRowType && Object.hasOwn(element, "height") && (typeof properties().height !== "number" || !Number.isFinite(properties().height) || Number(properties().height) <= 0)) without("height");
|
|
311
|
+
if (tableType && element.type === tableType) {
|
|
312
|
+
const { columnWidths } = properties();
|
|
313
|
+
if (Array.isArray(columnWidths)) {
|
|
314
|
+
let widthsChanged = false;
|
|
315
|
+
const nextColumnWidths = columnWidths.map((width) => {
|
|
316
|
+
const normalized = typeof width === "number" && Number.isFinite(width) && width > 0 ? width : null;
|
|
317
|
+
if (!Object.is(normalized, width)) widthsChanged = true;
|
|
318
|
+
return normalized;
|
|
319
|
+
});
|
|
320
|
+
if (widthsChanged) element = {
|
|
321
|
+
...element,
|
|
322
|
+
columnWidths: nextColumnWidths
|
|
323
|
+
};
|
|
324
|
+
} else if (Object.hasOwn(element, "columnWidths")) without("columnWidths");
|
|
325
|
+
}
|
|
326
|
+
return element;
|
|
327
|
+
};
|
|
328
|
+
migrateChildren = (children, location, context) => {
|
|
329
|
+
let changed = false;
|
|
330
|
+
const next = [];
|
|
331
|
+
for (let index = 0; index < children.length; index++) {
|
|
332
|
+
const child = children[index];
|
|
333
|
+
if (!child) continue;
|
|
334
|
+
if (ElementApi.isElement(child) && child.type === "toggle") {
|
|
335
|
+
const depth = legacyDepth(child, `${location}.${index}`);
|
|
336
|
+
let end = index + 1;
|
|
337
|
+
for (; end < children.length; end++) {
|
|
338
|
+
const candidate = children[end];
|
|
339
|
+
if (!candidate) break;
|
|
340
|
+
if (!ElementApi.isElement(candidate)) throw new Error(`Plate v54 migration cannot group legacy Toggle at ${location}.${index}: sibling ${location}.${end} is not an element.`);
|
|
341
|
+
if (legacyDepth(candidate, `${location}.${end}`) <= depth) break;
|
|
342
|
+
}
|
|
343
|
+
const body = children.slice(index + 1, end).map((candidate, offset) => consumeLegacyEnclosureDepth(candidate, `${location}.${index + 1 + offset}`));
|
|
344
|
+
const converted = convertLegacyToggle(child, body, `${location}.${index}`, context);
|
|
345
|
+
next.push(migrateDescendant(converted, `${location}.${index}`, context));
|
|
346
|
+
changed = true;
|
|
347
|
+
index = end - 1;
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
const migrated = migrateDescendant(child, `${location}.${index}`, context);
|
|
351
|
+
if (migrated !== child) changed = true;
|
|
352
|
+
next.push(migrated);
|
|
353
|
+
}
|
|
354
|
+
return changed ? next : children;
|
|
355
|
+
};
|
|
356
|
+
const children = migrateChildren(document.children, "main", {
|
|
357
|
+
ancestors: [],
|
|
358
|
+
root: null
|
|
359
|
+
});
|
|
360
|
+
let { roots } = document;
|
|
361
|
+
if (roots) {
|
|
362
|
+
let changed = false;
|
|
363
|
+
const next = Object.fromEntries(Object.entries(roots).map(([root, rootChildren]) => {
|
|
364
|
+
const migrated = migrateChildren(rootChildren, `roots.${root}`, {
|
|
365
|
+
ancestors: [],
|
|
366
|
+
root
|
|
367
|
+
});
|
|
368
|
+
if (migrated !== rootChildren) changed = true;
|
|
369
|
+
return [root, migrated];
|
|
370
|
+
}));
|
|
371
|
+
if (changed) roots = next;
|
|
372
|
+
}
|
|
373
|
+
if (children === document.children && roots === document.roots) return document;
|
|
374
|
+
return {
|
|
375
|
+
...document,
|
|
376
|
+
children,
|
|
377
|
+
...roots ? { roots } : {}
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
//#endregion
|
|
381
|
+
export { migratePlateV54Ast };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BaseParagraphPlugin } from "../lib/plugins/paragraph/BaseParagraphPlugin.js";
|
|
2
|
+
import { BaseBlockquotePlugin, BaseHorizontalRulePlugin } from "../features/basic-nodes/lib/BaseBlockPlugins.js";
|
|
3
|
+
import { BaseHeadingPlugin } from "../features/basic-nodes/lib/BaseHeadingPlugins.js";
|
|
4
|
+
import { BaseScriptPlugin } from "../features/basic-nodes/lib/BaseMarkPlugins.js";
|
|
5
|
+
import { BaseLineHeightPlugin, BaseTextAlignPlugin } from "../features/basic-styles/lib/BaseStylePlugins.js";
|
|
6
|
+
import { BaseCodeBlockPlugin } from "../features/code-block/lib/BaseCodeBlockPlugin.js";
|
|
7
|
+
import { BaseIndentPlugin } from "../features/indent/lib/BaseIndentPlugin.js";
|
|
8
|
+
import { BaseLinkPlugin } from "../features/link/lib/BaseLinkPlugin.js";
|
|
9
|
+
import { BaseListPlugin } from "../features/list/lib/BaseListPlugin.js";
|
|
10
|
+
import { BaseTableCellPlugin, BaseTablePlugin, BaseTableRowPlugin } from "../features/table/lib/BaseTablePlugin.js";
|
|
11
|
+
import { BaseCalloutPlugin } from "../features/callout/lib/BaseCalloutPlugin.js";
|
|
12
|
+
import { BaseDatePlugin } from "../features/date/lib/BaseDatePlugin.js";
|
|
13
|
+
import { BaseDetailsPlugin, BaseDetailsSummaryPlugin } from "../features/details/lib/BaseDetailsPlugin.js";
|
|
14
|
+
import { BaseFootnoteDefinitionPlugin, BaseFootnotePlugin } from "../features/footnote/lib/BaseFootnotePlugin.js";
|
|
15
|
+
import { BaseColumnGroupPlugin, BaseColumnItemPlugin } from "../features/layout/lib/BaseColumnPlugin.js";
|
|
16
|
+
import { BaseAudioPlugin, BaseFilePlugin, BaseVideoPlugin } from "../features/media/lib/BaseMediaPlugin.js";
|
|
17
|
+
import { BaseImagePlugin } from "../features/media/lib/image/BaseImagePlugin.js";
|
|
18
|
+
import { BaseMediaEmbedPlugin } from "../features/media/lib/media-embed/BaseMediaEmbedPlugin.js";
|
|
19
|
+
import { BaseMentionPlugin } from "../features/mention/lib/BaseMentionPlugin.js";
|
|
20
|
+
import { BaseTocPlugin } from "../features/toc/lib/BaseTocPlugin.js";
|
|
21
|
+
import { BaseEquationPlugin, BaseInlineEquationPlugin } from "../math/lib/BaseEquationPlugin.js";
|
|
22
|
+
import { BaseExcalidrawPlugin } from "../excalidraw/lib/BaseExcalidrawPlugin.js";
|
|
23
|
+
import { getMigrationBinding } from "./documentMigrationTarget.internal.js";
|
|
24
|
+
//#region src/migrations/migratePlateV54BuiltIns.internal.ts
|
|
25
|
+
const V53_OWNER_PLUGINS = {
|
|
26
|
+
aiChat: null,
|
|
27
|
+
audio: BaseAudioPlugin,
|
|
28
|
+
blockquote: BaseBlockquotePlugin,
|
|
29
|
+
callout: BaseCalloutPlugin,
|
|
30
|
+
codeBlock: BaseCodeBlockPlugin,
|
|
31
|
+
codeLine: null,
|
|
32
|
+
column: BaseColumnItemPlugin,
|
|
33
|
+
columnGroup: BaseColumnGroupPlugin,
|
|
34
|
+
date: BaseDatePlugin,
|
|
35
|
+
equation: BaseEquationPlugin,
|
|
36
|
+
excalidraw: BaseExcalidrawPlugin,
|
|
37
|
+
file: BaseFilePlugin,
|
|
38
|
+
footnote: BaseFootnotePlugin,
|
|
39
|
+
footnoteDefinition: BaseFootnoteDefinitionPlugin,
|
|
40
|
+
heading: BaseHeadingPlugin,
|
|
41
|
+
horizontalRule: BaseHorizontalRulePlugin,
|
|
42
|
+
image: BaseImagePlugin,
|
|
43
|
+
inlineEquation: BaseInlineEquationPlugin,
|
|
44
|
+
link: BaseLinkPlugin,
|
|
45
|
+
mediaEmbed: BaseMediaEmbedPlugin,
|
|
46
|
+
mention: BaseMentionPlugin,
|
|
47
|
+
paragraph: BaseParagraphPlugin,
|
|
48
|
+
table: BaseTablePlugin,
|
|
49
|
+
tableCell: BaseTableCellPlugin,
|
|
50
|
+
tableRow: BaseTableRowPlugin,
|
|
51
|
+
tag: null,
|
|
52
|
+
toc: BaseTocPlugin,
|
|
53
|
+
toggle: null,
|
|
54
|
+
video: BaseVideoPlugin
|
|
55
|
+
};
|
|
56
|
+
const MEDIA_OWNERS = [
|
|
57
|
+
"audio",
|
|
58
|
+
"file",
|
|
59
|
+
"image",
|
|
60
|
+
"mediaEmbed",
|
|
61
|
+
"video"
|
|
62
|
+
];
|
|
63
|
+
const resolveV54BuiltIns = (target) => {
|
|
64
|
+
const typeOf = (plugin) => getMigrationBinding(target, plugin)?.elementType ?? void 0;
|
|
65
|
+
const propertyIdsOf = (plugin) => new Set(getMigrationBinding(target, plugin)?.propertyIds);
|
|
66
|
+
const elementType = (owner) => {
|
|
67
|
+
const plugin = V53_OWNER_PLUGINS[owner];
|
|
68
|
+
return plugin ? typeOf(plugin) : void 0;
|
|
69
|
+
};
|
|
70
|
+
const elementTypes = (owners) => new Set(owners.map(elementType).filter((type) => type !== void 0));
|
|
71
|
+
return {
|
|
72
|
+
declared: {
|
|
73
|
+
indent: propertyIdsOf(BaseIndentPlugin),
|
|
74
|
+
lineHeight: propertyIdsOf(BaseLineHeightPlugin),
|
|
75
|
+
list: propertyIdsOf(BaseListPlugin),
|
|
76
|
+
textAlign: propertyIdsOf(BaseTextAlignPlugin)
|
|
77
|
+
},
|
|
78
|
+
detailsSummaryType: typeOf(BaseDetailsSummaryPlugin),
|
|
79
|
+
detailsType: typeOf(BaseDetailsPlugin),
|
|
80
|
+
elementType,
|
|
81
|
+
equationTypes: elementTypes(["equation", "inlineEquation"]),
|
|
82
|
+
mediaTypes: elementTypes(MEDIA_OWNERS),
|
|
83
|
+
scriptKey: getMigrationBinding(target, BaseScriptPlugin)?.propertyKey ?? void 0
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { resolveV54BuiltIns };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ElementApi, MAIN_ROOT_KEY, NodeApi, RangeApi, TextApi } from "../facade.js";
|
|
2
|
+
import { resolveV54BuiltIns } from "./migratePlateV54BuiltIns.internal.js";
|
|
3
|
+
import { migratePlateV54ReplacementText } from "./migratePlateV54Suggestions.internal.js";
|
|
4
|
+
//#region src/migrations/migratePlateV54CodeBlocks.internal.ts
|
|
5
|
+
const pointMappingKey = (root, path) => `${root}:${path.join(".")}`;
|
|
6
|
+
/** Flatten legacy code-block lines inside the Plate v54 migration. */
|
|
7
|
+
const migratePlateV54CodeBlocks = ({ document, target: conversionTarget }) => {
|
|
8
|
+
const { roots: inputRoots } = document;
|
|
9
|
+
const codeBlockType = resolveV54BuiltIns(conversionTarget).elementType("codeBlock");
|
|
10
|
+
if (!codeBlockType) return { document };
|
|
11
|
+
const pointMappings = /* @__PURE__ */ new Map();
|
|
12
|
+
const collectPointMappings = (input, path, targetPath, root, offset) => {
|
|
13
|
+
if (TextApi.isText(input)) {
|
|
14
|
+
pointMappings.set(pointMappingKey(root, path), {
|
|
15
|
+
offset,
|
|
16
|
+
path: targetPath
|
|
17
|
+
});
|
|
18
|
+
return offset + input.text.length;
|
|
19
|
+
}
|
|
20
|
+
return input.children.reduce((nextOffset, child, index) => collectPointMappings(child, [...path, index], targetPath, root, nextOffset), offset);
|
|
21
|
+
};
|
|
22
|
+
const migrateDescendant = (input, location, path, root) => {
|
|
23
|
+
if (TextApi.isText(input)) return input;
|
|
24
|
+
if (input.type === codeBlockType) {
|
|
25
|
+
if (input.children.length === 1 && TextApi.isText(input.children[0])) return input;
|
|
26
|
+
if (!input.children.every((child) => ElementApi.isElement(child))) throw new Error(`Plate v54 migration cannot flatten code block at ${location}: expected legacy line elements.`);
|
|
27
|
+
let offset = 0;
|
|
28
|
+
input.children.forEach((line, index) => {
|
|
29
|
+
offset = collectPointMappings(line, [...path, index], [...path, 0], root, offset);
|
|
30
|
+
if (index < input.children.length - 1) offset += 1;
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
...input,
|
|
34
|
+
children: [migratePlateV54ReplacementText(input.children, input.children.map(NodeApi.string).join("\n"), location)]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const children = migrateChildren(input.children, `${location}.children`, path, root);
|
|
38
|
+
return children === input.children ? input : {
|
|
39
|
+
...input,
|
|
40
|
+
children
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
function migrateChildren(children, location, parentPath, root) {
|
|
44
|
+
let changed = false;
|
|
45
|
+
const next = children.map((child, index) => {
|
|
46
|
+
const migrated = migrateDescendant(child, `${location}.${index}`, [...parentPath, index], root);
|
|
47
|
+
if (migrated !== child) changed = true;
|
|
48
|
+
return migrated;
|
|
49
|
+
});
|
|
50
|
+
return changed ? next : children;
|
|
51
|
+
}
|
|
52
|
+
const children = migrateChildren(document.children, "children", [], MAIN_ROOT_KEY);
|
|
53
|
+
let roots = inputRoots;
|
|
54
|
+
if (roots) {
|
|
55
|
+
let rootsChanged = false;
|
|
56
|
+
const nextRoots = Object.fromEntries(Object.entries(roots).map(([key, value]) => {
|
|
57
|
+
const migrated = migrateChildren(value, `roots.${key}`, [], key);
|
|
58
|
+
if (migrated !== value) rootsChanged = true;
|
|
59
|
+
return [key, migrated];
|
|
60
|
+
}));
|
|
61
|
+
if (rootsChanged) roots = nextRoots;
|
|
62
|
+
}
|
|
63
|
+
if (children === document.children && roots === document.roots) return { document };
|
|
64
|
+
const migrated = {
|
|
65
|
+
...document,
|
|
66
|
+
children,
|
|
67
|
+
...roots ? { roots } : {}
|
|
68
|
+
};
|
|
69
|
+
const mapPoint = (point) => {
|
|
70
|
+
const mapping = pointMappings.get(pointMappingKey(point.root ?? MAIN_ROOT_KEY, point.path));
|
|
71
|
+
return mapping ? {
|
|
72
|
+
...point,
|
|
73
|
+
offset: mapping.offset + point.offset,
|
|
74
|
+
path: mapping.path
|
|
75
|
+
} : point;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
document: migrated,
|
|
79
|
+
mapSelection: (selection, mapped) => RangeApi.isRange(selection) ? {
|
|
80
|
+
...selection,
|
|
81
|
+
anchor: mapPoint(selection.anchor),
|
|
82
|
+
focus: mapPoint(selection.focus)
|
|
83
|
+
} : mapped()
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { migratePlateV54CodeBlocks };
|