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,322 @@
|
|
|
1
|
+
# Editing Behavior
|
|
2
|
+
|
|
3
|
+
How Plate handles Enter, Backspace, merge, normalize, and selection behavior.
|
|
4
|
+
|
|
5
|
+
Editing behavior is the path from a key press or transaction command to the final document shape. Use [Plugin Rules](/docs/plugin-rules) for declarative node policy, and use [Editor Methods](/docs/editor-methods) when you need an explicit `editor.update(...)`. This guide shows how break, delete, merge, normalize, and selection behavior fit together.
|
|
6
|
+
|
|
7
|
+
## On this page
|
|
8
|
+
|
|
9
|
+
- [Choose the Right Surface](#choose-the-right-surface)
|
|
10
|
+
- [Runtime Pipeline](#runtime-pipeline)
|
|
11
|
+
- [Break Behavior](#break-behavior)
|
|
12
|
+
- [Delete Behavior](#delete-behavior)
|
|
13
|
+
- [Merge Behavior](#merge-behavior)
|
|
14
|
+
- [Normalize Behavior](#normalize-behavior)
|
|
15
|
+
- [Selection Behavior](#selection-behavior)
|
|
16
|
+
- [Recipes](#recipes)
|
|
17
|
+
- [API Reference](#api-reference)
|
|
18
|
+
|
|
19
|
+
## Choose the right surface
|
|
20
|
+
|
|
21
|
+
Most editing behavior belongs in `plugin.rules`. Reach for an explicit transaction command or Plate plugin only when the rule table cannot express the behavior.
|
|
22
|
+
|
|
23
|
+
| Need | Use |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| Change how `Enter` works in a node. | `rules.break` |
|
|
26
|
+
| Change how `Backspace` works at the start of a block. | `rules.delete` |
|
|
27
|
+
| Decide whether an empty sibling disappears during a merge. | `rules.merge` |
|
|
28
|
+
| Remove empty nodes during normalization. | `rules.normalize` |
|
|
29
|
+
| Control mark or inline boundaries while typing and moving. | `rules.selection` |
|
|
30
|
+
| Apply a conditional action to another plugin's node. | A resolver on the exact structural rule leaf |
|
|
31
|
+
| Run a product-specific mutation that rules cannot express. | A constructor `update` contribution or an explicit `editor.update(...)` |
|
|
32
|
+
| Compose reusable Enter, Delete, or text-input behavior. | A Plate command handler declared through the constructor's root `commands` field |
|
|
33
|
+
|
|
34
|
+
Rules keep common editor policy close to the plugin that owns the node. Transaction commands are the right tool for toolbar actions and behavior that depends on app state.
|
|
35
|
+
|
|
36
|
+
## Runtime pipeline
|
|
37
|
+
|
|
38
|
+
Plate resolves plugins first, then installs the Plate schema and plugin fragments contributed by those plugins.
|
|
39
|
+
|
|
40
|
+
| Layer | Owner | Handles |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| Structural rule runtime | Core runtime | Break rules, delete rules, merge rules, and normalize rules. |
|
|
43
|
+
| `AffinityPlugin` | Core runtime | `rules.selection` for mark and inline boundaries. |
|
|
44
|
+
| Feature plugins | Feature packages | Default rules for headings, callouts, lists, links, tables, marks, and other nodes. |
|
|
45
|
+
| App plugins | Your app | Local rules, explicit transaction commands, and Plate command or correction plugins. |
|
|
46
|
+
|
|
47
|
+
The normal flow is:
|
|
48
|
+
|
|
49
|
+
```txt
|
|
50
|
+
key press or command
|
|
51
|
+
-> optional input rule for typed patterns
|
|
52
|
+
-> plugin rule lookup for the current node
|
|
53
|
+
-> tx command
|
|
54
|
+
-> merge guard when nodes are joined
|
|
55
|
+
-> normalization
|
|
56
|
+
-> selection affinity cleanup
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Input rules are for text patterns such as markdown shortcuts and autolinks. Plugin rules are for node behavior such as "a heading resets to paragraph on Backspace" or "a callout inserts soft breaks on Enter."
|
|
60
|
+
|
|
61
|
+
Every structural rule leaf can be a direct value or a resolver. A resolver
|
|
62
|
+
receives the owning plugin context plus the current `node` and `path`. Return an
|
|
63
|
+
action to decide that exact leaf, or `undefined` to delegate it. Boolean
|
|
64
|
+
`false` is a final decision; it does not delegate. This keeps a conditional
|
|
65
|
+
merge policy from shadowing unrelated break or delete behavior.
|
|
66
|
+
|
|
67
|
+
## Break behavior
|
|
68
|
+
|
|
69
|
+
`rules.break` controls the break transaction that `Enter` calls.
|
|
70
|
+
|
|
71
|
+
Plate checks the current block and handles these cases in order:
|
|
72
|
+
|
|
73
|
+
| Case | Rule | What happens |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| Empty collapsed block | `break.empty` | Runs `reset`, `exit`, `lift`, `deleteExit`, or falls through. |
|
|
76
|
+
| Cursor after a trailing newline | `break.emptyLineEnd` | Runs `exit`, `deleteExit`, or falls through. |
|
|
77
|
+
| Normal Enter | `break.default` | Runs `lineBreak`, `exit`, `deleteExit`, or falls through. |
|
|
78
|
+
| Split created a new block | `break.splitReset` | Resets the new block to the default type. |
|
|
79
|
+
|
|
80
|
+
Use `splitReset` for blocks that should not keep their type after a normal split.
|
|
81
|
+
|
|
82
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
83
|
+
import { HeadingPlugin } from 'platejs/react';
|
|
84
|
+
|
|
85
|
+
export const AppHeadingPlugin = HeadingPlugin.configure({
|
|
86
|
+
rules: {
|
|
87
|
+
break: {
|
|
88
|
+
splitReset: true,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use `lineBreak` and `deleteExit` for container-like blocks that need soft lines before they leave the block.
|
|
95
|
+
|
|
96
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
97
|
+
import { CalloutPlugin } from 'platejs/callout/react';
|
|
98
|
+
|
|
99
|
+
export const AppCalloutPlugin = CalloutPlugin.configure({
|
|
100
|
+
rules: {
|
|
101
|
+
break: {
|
|
102
|
+
default: 'lineBreak',
|
|
103
|
+
empty: 'reset',
|
|
104
|
+
emptyLineEnd: 'deleteExit',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
That callout keeps normal Enter inside the callout, resets empty callouts to paragraphs, and exits after a trailing empty line.
|
|
111
|
+
|
|
112
|
+
## Delete behavior
|
|
113
|
+
|
|
114
|
+
`rules.delete` controls collapsed `Backspace` behavior. Expanded selections still delete through the normal fragment path unless the whole editor is selected.
|
|
115
|
+
|
|
116
|
+
Plate checks collapsed `deleteBackward` in this order:
|
|
117
|
+
|
|
118
|
+
| Case | Rule | What happens |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| Cursor at the start of the current block | `delete.start` | Runs `reset`, `lift`, or falls through. |
|
|
121
|
+
| Current block is empty | `delete.empty` | Runs `reset` or falls through. |
|
|
122
|
+
| Cursor is at the start of the document | Core default | Resets the first block. |
|
|
123
|
+
| Nothing handled the case | Plate command | Delegates to the built-in delete command. |
|
|
124
|
+
|
|
125
|
+
Use `start: 'reset'` for formatted text blocks that should become paragraphs before they merge into the previous block.
|
|
126
|
+
|
|
127
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
128
|
+
import { HeadingPlugin } from 'platejs/react';
|
|
129
|
+
|
|
130
|
+
export const AppHeadingPlugin = HeadingPlugin.configure({
|
|
131
|
+
rules: {
|
|
132
|
+
delete: {
|
|
133
|
+
start: 'reset',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Use `start: 'lift'` for nested blocks that should move out one ancestor level.
|
|
140
|
+
|
|
141
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
142
|
+
import { schema } from 'platejs';
|
|
143
|
+
import { definePlugin } from 'platejs/react';
|
|
144
|
+
|
|
145
|
+
export const QuoteItemPlugin = definePlugin('quoteItem', {
|
|
146
|
+
rules: {
|
|
147
|
+
delete: {
|
|
148
|
+
start: 'lift',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
schema: {
|
|
152
|
+
element: {
|
|
153
|
+
content: schema.content.text({ default: 'text', min: 1 }),
|
|
154
|
+
type: 'quote_item',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
When a selection spans multiple blocks, Plate deletes the selected content and
|
|
161
|
+
then calls `tx.nodes.merge(...)` at the end boundary. That means cross-block
|
|
162
|
+
deletion can still enter the merge pipeline below.
|
|
163
|
+
|
|
164
|
+
## Merge behavior
|
|
165
|
+
|
|
166
|
+
Merge behavior decides whether two nodes can join and whether empty nodes at the boundary disappear.
|
|
167
|
+
|
|
168
|
+
`tx.nodes.merge(...)` evaluates Plate's internal
|
|
169
|
+
`editorReads.nodes.shouldMergeNodesRemovePrevNode` descriptor before it applies
|
|
170
|
+
the merge. It skips the descriptor when the previous block is empty and fills a
|
|
171
|
+
required `schema.content.prefix` slot, such as a title. The next sibling's
|
|
172
|
+
content must also fit that slot as it stands, with no required block left to
|
|
173
|
+
build, and the update must not have moved the empty block into its slot or
|
|
174
|
+
replaced it.
|
|
175
|
+
The next sibling may hold only text and inlines and may own no content root,
|
|
176
|
+
neither block may be a void, an atom or read-only, and an empty next sibling must
|
|
177
|
+
carry the empty block's text properties. The empty block then keeps its slot and takes the content. An editor
|
|
178
|
+
with
|
|
179
|
+
[`AuthoredPlugin`](/docs/authored-changes) still evaluates the descriptor.
|
|
180
|
+
Plate's merge-rule middleware adds three important guards:
|
|
181
|
+
|
|
182
|
+
| Case | Behavior |
|
|
183
|
+
| --- | --- |
|
|
184
|
+
| Empty text node before the merge point | Remove it when it is not the first child. |
|
|
185
|
+
| Empty previous sibling | Remove it only when the owning plugin has `rules.merge.removeEmpty: true`. An empty required prefix block that takes the content stays. |
|
|
186
|
+
| Target node is void | Do not delete the void target by default; remove the current empty node instead when possible. |
|
|
187
|
+
|
|
188
|
+
Use `removeEmpty: true` for text-like blocks such as paragraphs and headings.
|
|
189
|
+
A heading in a required title slot keeps that slot. After Enter at the start of
|
|
190
|
+
the title, one `Backspace` joins the split-off heading back into the title.
|
|
191
|
+
|
|
192
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
193
|
+
import { HeadingPlugin } from 'platejs/react';
|
|
194
|
+
|
|
195
|
+
export const AppHeadingPlugin = HeadingPlugin.configure({
|
|
196
|
+
rules: {
|
|
197
|
+
merge: {
|
|
198
|
+
removeEmpty: true,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Keep `removeEmpty: false` for structural nodes that own layout, children, or wrappers. Tables, rows, cells, columns, and callouts should not disappear just because a merge crosses their boundary.
|
|
205
|
+
|
|
206
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
207
|
+
import { CalloutPlugin } from 'platejs/callout/react';
|
|
208
|
+
|
|
209
|
+
export const StableCalloutPlugin = CalloutPlugin.configure({
|
|
210
|
+
rules: {
|
|
211
|
+
merge: {
|
|
212
|
+
removeEmpty: false,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
<Callout>
|
|
219
|
+
Merge rules are not table cell merge commands. `rules.merge` protects
|
|
220
|
+
document structure during node joins. Table cell merge and split commands live
|
|
221
|
+
on `tx.plugin(TablePlugin).merge()` and `tx.plugin(TablePlugin).split()`,
|
|
222
|
+
using `TablePlugin` from `platejs/table/react`.
|
|
223
|
+
</Callout>
|
|
224
|
+
|
|
225
|
+
## Normalize behavior
|
|
226
|
+
|
|
227
|
+
`rules.normalize` runs during Plate normalization.
|
|
228
|
+
|
|
229
|
+
Use `normalize.removeEmpty` for elements that should not exist without text content. Links use this shape because an empty link has no useful editing surface.
|
|
230
|
+
|
|
231
|
+
```tsx title="plugins.tsx" showLineNumbers
|
|
232
|
+
import { LinkPlugin } from 'platejs/react';
|
|
233
|
+
|
|
234
|
+
export const AppLinkPlugin = LinkPlugin.configure({
|
|
235
|
+
rules: {
|
|
236
|
+
normalize: {
|
|
237
|
+
removeEmpty: true,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Keep normalization rules boring. If a node needs a richer structural repair,
|
|
244
|
+
write a convergent Plate correction and contribute it through
|
|
245
|
+
the constructor's root `corrections` field so the behavior is explicit and
|
|
246
|
+
testable.
|
|
247
|
+
|
|
248
|
+
## Selection behavior
|
|
249
|
+
|
|
250
|
+
`rules.selection` controls how marks and inline-like boundaries behave while typing, deleting, and moving the cursor.
|
|
251
|
+
|
|
252
|
+
| Affinity | Use for |
|
|
253
|
+
| --- | --- |
|
|
254
|
+
| `default` | Normal Plate boundary behavior. |
|
|
255
|
+
| `directional` | Links and highlights where cursor direction decides whether typed text stays inside. |
|
|
256
|
+
| `outward` | Annotation marks where edge typing should leave the mark. |
|
|
257
|
+
| `hard` | Boundaries that should take an extra arrow-key step to cross. |
|
|
258
|
+
|
|
259
|
+
Element behavior also affects editing. Plate compiles `schema.element.inline`,
|
|
260
|
+
`schema.element.void`, `schema.element.selectable`, and the markable-inline void
|
|
261
|
+
kind into Plate's schema before selection and transaction logic runs.
|
|
262
|
+
|
|
263
|
+
## Recipes
|
|
264
|
+
|
|
265
|
+
| Behavior | Configure |
|
|
266
|
+
| --- | --- |
|
|
267
|
+
| Heading resets to paragraph on Backspace. | `rules.delete.start: 'reset'` |
|
|
268
|
+
| Heading splits into paragraph on Enter. | `rules.break.splitReset: true` |
|
|
269
|
+
| Callout keeps Enter inside the block. | `rules.break.default: 'lineBreak'` |
|
|
270
|
+
| Empty callout becomes a paragraph. | `rules.break.empty: 'reset'` or `rules.delete.start: 'reset'` |
|
|
271
|
+
| Nested item outdents on Backspace. | `rules.delete.start: 'lift'` |
|
|
272
|
+
| Empty text block disappears during merge, unless it fills a required prefix slot that takes the next block's content as it stands. | `rules.merge.removeEmpty: true` |
|
|
273
|
+
| Structural wrapper survives merge. | `rules.merge.removeEmpty: false` |
|
|
274
|
+
| Empty inline element disappears. | `rules.normalize.removeEmpty: true` |
|
|
275
|
+
| Link boundary follows cursor direction. | `rules.selection.affinity: 'directional'` |
|
|
276
|
+
|
|
277
|
+
For list metadata and code-block children, put the predicate on the exact leaf
|
|
278
|
+
that needs it. For example,
|
|
279
|
+
`rules.merge.removeEmpty: ({ node }) => isListItem(node) ? false : undefined`
|
|
280
|
+
lets the list feature protect list items while leaving every other merge rule
|
|
281
|
+
with its canonical owner.
|
|
282
|
+
|
|
283
|
+
## API Reference
|
|
284
|
+
|
|
285
|
+
| Surface | Owner | Reference |
|
|
286
|
+
| --- | --- | --- |
|
|
287
|
+
| `rules.break` | Core rule engine plus feature plugin definition | [Plugin Rules](/docs/plugin-rules#rulesbreak) |
|
|
288
|
+
| `rules.delete` | Core rule engine plus feature plugin definition | [Plugin Rules](/docs/plugin-rules#rulesdelete) |
|
|
289
|
+
| `rules.merge` | Core rule engine plus feature plugin definition | [Plugin Rules](/docs/plugin-rules#rulesmerge) |
|
|
290
|
+
| `rules.normalize` | Core rule engine plus feature plugin definition | [Plugin Rules](/docs/plugin-rules#rulesnormalize) |
|
|
291
|
+
| `rules.selection` | Affinity core plugin plus feature plugin definition | [Plugin Rules](/docs/plugin-rules#rulesselection) |
|
|
292
|
+
| `tx.nodes.merge(...)` | Plate transaction command | [Transforms](/docs/api/editor-transforms#txnodesmergeoptions) |
|
|
293
|
+
| `editorReads.nodes.shouldMergeNodesRemovePrevNode` | Internal Plate descriptor extended by Plate merge-rule middleware | [Plugin Rules](/docs/plugin-rules#rulesmerge) |
|
|
294
|
+
| `tx.plugin(TablePlugin).merge()` | Table feature package | [Table](/docs/table#editing-behavior) |
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
## Correction timing
|
|
298
|
+
|
|
299
|
+
Commands read their own draft writes. Construct the intended valid shape before
|
|
300
|
+
reading it again; corrections run at transaction closeout. Related writes share
|
|
301
|
+
one `editor.update(...)` and publish one immutable commit.
|
|
302
|
+
|
|
303
|
+
Each correction declares the node event that can invalidate its rule:
|
|
304
|
+
`children`, `content`, or `properties`. Corrections begin from changed ranges.
|
|
305
|
+
Further relevant writes queue affected entries in a bounded worklist, so a local
|
|
306
|
+
edit does not require a whole-document scan. Each correction must converge and
|
|
307
|
+
repair a concrete violation with transaction methods.
|
|
308
|
+
|
|
309
|
+
Use `tx.nodes.unset('url', { at })` to delete an optional field. Valid property
|
|
310
|
+
values are determined by the installed schema. Imported `DocumentChange` values
|
|
311
|
+
must validate against that schema; they are not accepted for later repair.
|
|
312
|
+
|
|
313
|
+
### Whole-document repair
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
editor.update.value.repair();
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Call this when loaded data or an installed correction needs an all-root
|
|
320
|
+
maintenance pass. It starts a history-skipped update, scans the primary document
|
|
321
|
+
and named roots, and publishes nothing for an already canonical value. It cannot
|
|
322
|
+
run inside another update. Ordinary feature commands use changed-range closeout.
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Editor Methods
|
|
2
|
+
|
|
3
|
+
Read, mutate, and configure a Plate editor instance.
|
|
4
|
+
|
|
5
|
+
The Plate editor exposes two main method surfaces: `editor.api` for reads and
|
|
6
|
+
services, and `editor.update` for commands that change editor state. In React,
|
|
7
|
+
pick the editor hook by how often the component should re-render.
|
|
8
|
+
|
|
9
|
+
## Access the editor
|
|
10
|
+
|
|
11
|
+
| Need | Use |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Read the required editor inside callbacks. | `useEditor()` |
|
|
14
|
+
| Re-render from an editor-derived value. | `useEditorSelector(selector, options?)` |
|
|
15
|
+
| Re-render from immutable state. | `useEditorState(selector, options?)` |
|
|
16
|
+
| Render while a controller may have no editor. | `useOptionalEditor()` and handle `null`. |
|
|
17
|
+
|
|
18
|
+
```tsx title="components/bold-button.tsx" showLineNumbers
|
|
19
|
+
import { useEditor, useEditorSelector } from 'platejs/react';
|
|
20
|
+
|
|
21
|
+
import { Button } from '@/components/ui/button';
|
|
22
|
+
|
|
23
|
+
export function BoldButton() {
|
|
24
|
+
const editor = useEditor();
|
|
25
|
+
const hasSelection = useEditorSelector((editor) =>
|
|
26
|
+
Boolean(editor.read.selection())
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Button
|
|
31
|
+
disabled={!hasSelection}
|
|
32
|
+
onClick={() => editor.update((tx) => tx.marks.toggle('bold'))}
|
|
33
|
+
>
|
|
34
|
+
Bold
|
|
35
|
+
</Button>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### `useEditor`
|
|
41
|
+
|
|
42
|
+
`useEditor` returns the required stable editor object. Use it for event
|
|
43
|
+
handlers, effects, commands, and reads that should not cause a render. It
|
|
44
|
+
throws when no matching editor is active.
|
|
45
|
+
|
|
46
|
+
```tsx title="components/insert-paragraph-button.tsx"
|
|
47
|
+
const editor = useEditor();
|
|
48
|
+
|
|
49
|
+
editor.update((tx) => {
|
|
50
|
+
tx.nodes.insert({
|
|
51
|
+
children: [{ text: 'Inserted paragraph' }],
|
|
52
|
+
type: 'paragraph',
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `useEditorSelector`
|
|
58
|
+
|
|
59
|
+
`useEditorSelector` subscribes to a derived value. When the call passes no
|
|
60
|
+
`equalityFn`, the hook compares each result with the earlier one by value, so a
|
|
61
|
+
selector may return an object or a list.
|
|
62
|
+
[Selector results](/docs/api/react-hooks#selector-results) gives the limits of
|
|
63
|
+
that comparison and how `equalityFn` replaces it.
|
|
64
|
+
|
|
65
|
+
```tsx title="components/selection-state.tsx"
|
|
66
|
+
const isSelectionExpanded = useEditorSelector(
|
|
67
|
+
(editor) => editor.read.selection.isExpanded()
|
|
68
|
+
);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `useEditorState`
|
|
72
|
+
|
|
73
|
+
`useEditorState` reads through the immutable state view and re-renders only
|
|
74
|
+
when the selected result changes.
|
|
75
|
+
|
|
76
|
+
```tsx title="components/selection-debug.tsx"
|
|
77
|
+
const selection = useEditorState((state) => state.selection());
|
|
78
|
+
|
|
79
|
+
return <pre>{JSON.stringify(selection, null, 2)}</pre>;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Outside Plate
|
|
83
|
+
|
|
84
|
+
Wrap shared UI in `EditorController` when a toolbar, side panel, or inspector
|
|
85
|
+
lives outside a single `<EditorRoot>` tree.
|
|
86
|
+
|
|
87
|
+
```tsx title="components/editor-shell.tsx" showLineNumbers
|
|
88
|
+
import type React from 'react';
|
|
89
|
+
|
|
90
|
+
import { EditorController, useOptionalEditor } from 'platejs/react';
|
|
91
|
+
|
|
92
|
+
import { Button } from '@/components/ui/button';
|
|
93
|
+
|
|
94
|
+
export function EditorShell({ children }: { children: React.ReactNode }) {
|
|
95
|
+
return (
|
|
96
|
+
<EditorController>
|
|
97
|
+
<ActiveEditorToolbar />
|
|
98
|
+
{children}
|
|
99
|
+
</EditorController>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function ActiveEditorToolbar() {
|
|
104
|
+
const editor = useOptionalEditor();
|
|
105
|
+
|
|
106
|
+
if (!editor) return null;
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Button onClick={() => editor.api.dom.focus()}>Focus editor</Button>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`EditorController` resolves an editor by explicit `id`, focused editor, then
|
|
115
|
+
primary editors. `useOptionalEditor()` returns `null` while none is active.
|
|
116
|
+
Components that require an editor should use `useEditor()` and fail fast.
|
|
117
|
+
|
|
118
|
+
## Editor API and commands
|
|
119
|
+
|
|
120
|
+
Use `editor.read` for snapshot-bound queries, `editor.api` for DOM, host, and
|
|
121
|
+
plugin services, and `editor.update` for operations that change the document,
|
|
122
|
+
selection, history, or plugin state.
|
|
123
|
+
|
|
124
|
+
```ts title="editor-methods.ts" showLineNumbers
|
|
125
|
+
import { BoldPlugin } from 'platejs/react';
|
|
126
|
+
|
|
127
|
+
const selection = editor.read.selection();
|
|
128
|
+
const selectedText = selection ? editor.read.text.string(selection) : '';
|
|
129
|
+
|
|
130
|
+
const currentBlock = editor.read.nodes.block();
|
|
131
|
+
const bold = editor.plugin(BoldPlugin);
|
|
132
|
+
|
|
133
|
+
if (selectedText && !bold.read.isActive()) {
|
|
134
|
+
bold.update.toggle();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
editor.update((tx) => {
|
|
138
|
+
tx.nodes.insert({
|
|
139
|
+
children: [{ text: 'New paragraph' }],
|
|
140
|
+
type: 'paragraph',
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
| Surface | Examples | Use for |
|
|
146
|
+
| --- | --- | --- |
|
|
147
|
+
| `editor.read` | `text.string`, `nodes.block`, `marks`, `selection.isExpanded` | Reading the current immutable editor state. |
|
|
148
|
+
| `editor.api` | `dom.focus` and plugin-owned service groups | DOM/runtime services and non-mutating feature APIs. |
|
|
149
|
+
| `editor.update` | `tx.nodes.insert`, `tx.nodes.set`, `tx.marks.toggle`, `tx.selection.set` | Mutating document or editor state. |
|
|
150
|
+
|
|
151
|
+
## Plugin methods
|
|
152
|
+
|
|
153
|
+
Pass a plugin descriptor to `editor.plugin(plugin)` to open its typed portal.
|
|
154
|
+
The portal exposes resolved descriptor fields and owns that plugin's scoped
|
|
155
|
+
API, one-shot update commands, and live state.
|
|
156
|
+
|
|
157
|
+
```ts title="html-methods.ts" showLineNumbers
|
|
158
|
+
import { BoldPlugin } from 'platejs/react';
|
|
159
|
+
|
|
160
|
+
editor.plugin(BoldPlugin).update.toggle();
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
| Method | Use for |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| `editor.plugin(plugin)` | Typed descriptor fields plus scoped API, reads, updates, and store. |
|
|
166
|
+
| `editor.plugin(plugin).name` | The installed capability identity. |
|
|
167
|
+
| `editor.plugin(ElementPlugin).schema.type` | The resolved persisted element type. |
|
|
168
|
+
| `editor.plugin(BoldPlugin).schema.key` | The resolved persisted property key. |
|
|
169
|
+
| `editor.plugin(plugin).inject.nodeProps` | Compiled injected node props for a plugin. |
|
|
170
|
+
|
|
171
|
+
Runtime-name portals are intentionally erased. Use them for dynamic names or
|
|
172
|
+
family-agnostic slots that accept whichever installed descriptor owns the
|
|
173
|
+
name. Check `.installed` before any other field when the named plugin is
|
|
174
|
+
optional; other fields throw when the plugin is absent.
|
|
175
|
+
|
|
176
|
+
## Plugin store
|
|
177
|
+
|
|
178
|
+
Use the scoped store when imperative code needs to read or write editor-local
|
|
179
|
+
plugin state. Use `usePluginStore` when React UI needs to re-render from that
|
|
180
|
+
state.
|
|
181
|
+
|
|
182
|
+
```tsx title="components/panel-control.tsx" showLineNumbers
|
|
183
|
+
import { definePlugin, useEditor, usePluginStore } from 'platejs/react';
|
|
184
|
+
|
|
185
|
+
const PanelPlugin = definePlugin('panel', {
|
|
186
|
+
initialState: { open: false },
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
export function PanelControl() {
|
|
190
|
+
const editor = useEditor();
|
|
191
|
+
const open = usePluginStore(PanelPlugin, 'open');
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<button
|
|
195
|
+
type="button"
|
|
196
|
+
onClick={() => {
|
|
197
|
+
editor.plugin(PanelPlugin).store.set({ open: !open });
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
{open ? 'Close panel' : 'Open panel'}
|
|
201
|
+
</button>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```ts title="plugin-store.ts"
|
|
207
|
+
const state = editor.plugin(PanelPlugin).store.get();
|
|
208
|
+
|
|
209
|
+
editor.plugin(PanelPlugin).store.set({
|
|
210
|
+
open: true,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
editor.plugin(PanelPlugin).store.set((draft) => {
|
|
214
|
+
draft.open = !draft.open;
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
| Method | Use for |
|
|
219
|
+
| --- | --- |
|
|
220
|
+
| `editor.plugin(plugin).store.get(key, ...args)` | One state field or named selector result. |
|
|
221
|
+
| `editor.plugin(plugin).store.get()` | Complete current plugin state. |
|
|
222
|
+
| `editor.plugin(plugin).store.set(partial)` | Merge state fields. |
|
|
223
|
+
| `editor.plugin(plugin).store.set(updater)` | Mutate state through a draft updater. |
|
|
224
|
+
|
|
225
|
+
## Next steps
|
|
226
|
+
|
|
227
|
+
| Task | Guide |
|
|
228
|
+
| --- | --- |
|
|
229
|
+
| Configure editor creation. | [Editor Configuration](/docs/editor) |
|
|
230
|
+
| Add plugin APIs and transaction commands. | [Plugin Methods](/docs/plugin-methods) |
|
|
231
|
+
| Read plugin context inside components. | [Plugin Context](/docs/plugin-context) |
|
|
232
|
+
| Browse editor query contracts. | [Editor API](/docs/api/editor-api) |
|
|
233
|
+
| Browse editor transaction contracts. | [Editor Transactions](/docs/api/editor-transforms) |
|