platejs 54.0.0-beta.2 → 54.0.0-beta.4
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 +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +113 -78
- package/dist/ai/react/CopilotPlugin.js +1 -1
- package/dist/ai/react/index.d.ts +23 -16
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/ai.md +4 -3
- package/dist/docs/api/core/plate-components.md +0 -19
- package/dist/docs/api/core/plate-controller.md +5 -3
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +11 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +45 -13
- package/dist/docs/authored-changes.md +9 -4
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +118 -10
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/comment.md +2 -2
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- package/dist/docs/editor.md +50 -4
- package/dist/docs/examples/editable-voids.md +2 -3
- package/dist/docs/external-text.md +2 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +9 -6
- package/dist/docs/form.md +2 -0
- package/dist/docs/heading.md +6 -0
- package/dist/docs/installation/manual.md +0 -4
- package/dist/docs/link.md +3 -3
- package/dist/docs/llms.txt +4 -2
- package/dist/docs/markdown.md +270 -14
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +66 -15
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/roots.md +8 -6
- package/dist/docs/rtl.md +6 -4
- package/dist/docs/selection.md +7 -4
- package/dist/docs/suggestion.md +1 -1
- package/dist/docs/toolbar.md +26 -30
- package/dist/docs/upload.md +106 -17
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/docxStaticComponents.js +12 -2
- package/dist/docx/export/lib/exportDocx.js +46 -17
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +52 -10
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -6
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -2
- package/dist/excalidraw/react/index.d.ts +3 -2
- package/dist/facade.js +2 -2
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
- package/dist/features/board/lib/boardStroke.internal.js +13 -1
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +3 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +33 -17
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -2
- package/dist/features/details/index.d.ts +3 -2
- package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +4 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +204 -0
- package/dist/features/find/index.d.ts +3 -2
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +229 -48
- package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
- package/dist/features/lint/index.d.ts +3 -2
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
- package/dist/features/mention/index.d.ts +5 -4
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +64 -15
- package/dist/features/table/lib/internal/selection.js +4 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
- package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
- package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
- package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
- package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
- package/dist/index-C9Fu-P4E.d.ts +773 -0
- package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
- package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
- package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
- package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
- package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
- package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
- package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
- package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
- package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
- package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
- package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
- package/dist/internal/plugin/OverridePlugin.js +101 -119
- package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/resolvePlugin.js +1 -1
- package/dist/internal/plugin/resolvePlugins.js +3 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/mergePlugins.js +1 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
- package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
- package/dist/lib/plugins/html/htmlSafety.js +1 -1
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +3 -1
- package/dist/markdown/lib/MarkdownPlugin.js +14 -11
- package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +776 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
- package/dist/markdown/lib/internal/markdownLine.js +5 -3
- package/dist/markdown/lib/internal/markdownMappings.js +19 -7
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +29 -9
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
- package/dist/math/index.d.ts +3 -2
- package/dist/math/react/index.d.ts +4 -3
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +42 -23
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +102 -128
- package/dist/react/components/PlateContainer.js +40 -32
- package/dist/react/components/PlateController.js +28 -16
- package/dist/react/components/PlateRoot.internal.js +3 -2
- package/dist/react/core.js +4 -4
- package/dist/react/features/board/BoardSurface.js +116 -87
- package/dist/react/features/board/boardClipboard.internal.js +15 -5
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +190 -50
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +108 -18
- package/dist/react/features/callout/index.d.ts +3 -2
- package/dist/react/features/combobox/index.d.ts +8 -8
- package/dist/react/features/comments/index.d.ts +6 -5
- package/dist/react/features/date/index.d.ts +4 -3
- package/dist/react/features/details/index.d.ts +4 -3
- package/dist/react/features/field/FieldPlugin.js +35 -0
- package/dist/react/features/field/index.d.ts +315 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/index.d.ts +7 -6
- package/dist/react/features/format-painter/index.d.ts +4 -3
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/index.d.ts +57 -33
- package/dist/react/features/ink/index.js +2 -2
- package/dist/react/features/ink/inkCapture.internal.js +39 -17
- package/dist/react/features/ink/inkInput.internal.js +1 -1
- package/dist/react/features/ink/inkLayout.internal.js +6 -3
- package/dist/react/features/ink/inkPaint.internal.js +78 -2
- package/dist/react/features/ink/inkPlacement.internal.js +332 -104
- package/dist/react/features/ink/inkWatch.internal.js +7 -5
- package/dist/react/features/layout/index.d.ts +5 -4
- package/dist/react/features/media/index.d.ts +5 -4
- package/dist/react/features/mention/index.d.ts +6 -5
- package/dist/react/features/resizable/Resizable.js +4 -6
- package/dist/react/features/resizable/index.d.ts +5 -5
- package/dist/react/features/suggestion/index.d.ts +6 -5
- package/dist/react/features/table/TablePlugin.js +4 -11
- package/dist/react/features/table/index.d.ts +10 -8
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +11 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +4 -4
- package/dist/react/internal/plate-context.js +434 -188
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
- package/dist/react/stores/plate/useEditor.js +32 -14
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +79 -21
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/utils/pipeRenderElement.internal.js +1 -1
- package/dist/react/utils/pluginRenderElement.internal.js +1 -1
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
- package/dist/static/index.d.ts +18 -18
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
- package/dist/static/internal/staticPresentation.js +4 -4
- package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +6 -6
- package/package.json +20 -2
- package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
- package/dist/react/components/EditorSelectionView.js +0 -40
- package/dist/react/features/ink/InkLayer.js +0 -218
- package/dist/react/internal/createPlateTargetScope.js +0 -62
package/dist/diff/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as ComparisonConflictAlternative, c as ComparisonEffect, d as ComparisonResolutionResult, f as ComparisonSnapshot, h as TwoWayComparison, i as ComparisonConflict, l as ComparisonEvidence, m as ThreeWayComparison, n as Comparison, o as ComparisonCorrespondence, p as ComparisonSpan, r as ComparisonBranch, s as ComparisonDiagnostic, t as ComparedChange, u as ComparisonResolution } from "../comparison-types-
|
|
1
|
+
import { su as Value, yr as EditorStateSchemaApi } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import { a as ComparisonConflictAlternative, c as ComparisonEffect, d as ComparisonResolutionResult, f as ComparisonSnapshot, h as TwoWayComparison, i as ComparisonConflict, l as ComparisonEvidence, m as ThreeWayComparison, n as Comparison, o as ComparisonCorrespondence, p as ComparisonSpan, r as ComparisonBranch, s as ComparisonDiagnostic, t as ComparedChange, u as ComparisonResolution } from "../comparison-types-DdwE6mYq-BogsHoUO.js";
|
|
3
3
|
type TwoWayInput<V extends Value> = Readonly<{
|
|
4
4
|
after: unknown;
|
|
5
5
|
before: unknown;
|
package/dist/docs/ai.md
CHANGED
|
@@ -110,7 +110,7 @@ const editor = createEditor({
|
|
|
110
110
|
AIChatTransportPlugin.configure({
|
|
111
111
|
slots: {
|
|
112
112
|
afterContainer: AILoadingBar,
|
|
113
|
-
|
|
113
|
+
caret: AIMenu,
|
|
114
114
|
},
|
|
115
115
|
initialState: {
|
|
116
116
|
chatOptions: {
|
|
@@ -123,7 +123,7 @@ const editor = createEditor({
|
|
|
123
123
|
});
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
`AIKit` includes the Markdown dependency and the required React integration. Custom `afterContainer` and `
|
|
126
|
+
`AIKit` includes the Markdown dependency and the required React integration. Custom `afterContainer` and `caret` slots preserve the session. Replacing `wrapRoot` replaces its React attachment; compose the attachment inside your wrapper when customizing that slot. For AI comments, install `DiscussionKit`, create the editor with the current user as `createEditor({ userId })`, and configure `CommentsPlugin` with `initialComments: { ranges, threads }`, the thread rows from your tables and the ranges saved with the matching revision. AI comments are ordinary threads, so `api.ranges()` saves their ranges too. List `aiUser` from the copied `use-chat` among the comment users:
|
|
127
127
|
|
|
128
128
|
```tsx
|
|
129
129
|
import { CommentsPlugin } from 'platejs/comments/react';
|
|
@@ -282,7 +282,8 @@ Publish the accumulated Markdown response with
|
|
|
282
282
|
the editor's installed Markdown mappings and stores the result in
|
|
283
283
|
`previewValue`. With `final: false`, the parse uses
|
|
284
284
|
`{ lossPolicy: 'allow', partial: true }`: an unfinished trailing tag stays hidden
|
|
285
|
-
and unsupported content previews as text.
|
|
285
|
+
and unsupported content previews as text. Bold, italic and strikethrough preview
|
|
286
|
+
styled before their closing markers arrive. `final` defaults to `true`; that parse
|
|
286
287
|
is strict, and a response that Markdown cannot represent clears the draft.
|
|
287
288
|
Each parse, the final one included, continues the latest partial parse of the
|
|
288
289
|
same response. After a final parse, `hide()`, `reset()`, `reload()` or
|
|
@@ -181,7 +181,6 @@ The frame does not impose a fixed height by itself.
|
|
|
181
181
|
| `EditorElement` | Default element renderer for block and inline elements. |
|
|
182
182
|
| `EditorLeaf` | Default persisted-mark renderer for a text segment. |
|
|
183
183
|
| `EditorText` | Default wrapper around every rendered segment of one text node. |
|
|
184
|
-
| `EditorSelectionView` | Hooks of its children read the nested view that holds the selection, such as a board note's text. |
|
|
185
184
|
|
|
186
185
|
## Render pipeline
|
|
187
186
|
|
|
@@ -574,24 +573,6 @@ for minimal, scrollable, and fixed-toolbar compositions.
|
|
|
574
573
|
</APIProps>
|
|
575
574
|
</API>
|
|
576
575
|
|
|
577
|
-
### `EditorSelectionView`
|
|
578
|
-
|
|
579
|
-
Gives its children the mounted view whose root holds the selection, such as a
|
|
580
|
-
board note's view inside the page, as their editor. Inside it `useEditor()`,
|
|
581
|
-
`useEditableRef()`, `useEditorFocused()` and `useFocusedLast()` answer for that
|
|
582
|
-
view. Children keep the current editor when the selection is in that editor's root, when
|
|
583
|
-
no view of the selection's root is mounted inside its Editable, or when several
|
|
584
|
-
are and none is focused or was focused last. See
|
|
585
|
-
[Toolbar](/docs/toolbar#act-on-the-view-that-holds-the-selection).
|
|
586
|
-
|
|
587
|
-
<API name="EditorSelectionView">
|
|
588
|
-
<APIProps>
|
|
589
|
-
<APIItem name="children" type="React.ReactNode">
|
|
590
|
-
UI that acts on the view holding the selection.
|
|
591
|
-
</APIItem>
|
|
592
|
-
</APIProps>
|
|
593
|
-
</API>
|
|
594
|
-
|
|
595
576
|
### Render primitives
|
|
596
577
|
|
|
597
578
|
| API | Default Element | Notes |
|
|
@@ -47,10 +47,10 @@ Set `primary` on `EditorRoot`; it defaults to `true`. A view with `primary={fals
|
|
|
47
47
|
|
|
48
48
|
## Editor lookup
|
|
49
49
|
|
|
50
|
-
`useEditor()` returns the nearest provider
|
|
50
|
+
`useEditor()` returns the nearest provider's selected editor and throws when no target exists. `useOptionalEditor()` uses the same selection and returns `null` without a provider or target.
|
|
51
51
|
|
|
52
52
|
- Inside `EditorContent`, hooks use that exact editable view, including its root, DOM, and current read-only state.
|
|
53
|
-
- Inside `EditorRoot`, outside its content, UI follows the view of that Plate the user focused or pressed last, then its first mounted view. A Plate without content
|
|
53
|
+
- Inside `EditorRoot`, outside its content, UI follows the view of that Plate the user focused or pressed last, then its first mounted view. A Plate without content gives its UI a root editor of that Plate, so its UI acts on that Plate alone, even while another Plate of the same editor holds the caret.
|
|
54
54
|
- Shared UI under the controller follows the mounted view the user focused or pressed last, then the first mounted primary view.
|
|
55
55
|
- Nested `EditorRoot` and `EditorController` components scope their descendants independently.
|
|
56
56
|
|
|
@@ -58,6 +58,8 @@ A press on a read-only view counts, though it takes no focus. When the view used
|
|
|
58
58
|
|
|
59
59
|
Blur retains the active view for toolbar interaction. `EditorContent` owns registration and cleanup; only views with editable DOM participate in controller selection.
|
|
60
60
|
|
|
61
|
+
UI outside every `EditorContent` gets the editor of the root that holds the caret in the view it follows. With the caret in the text of a [board](/docs/board) note, it gets the editor of the board's root, so the fixed toolbar's buttons change the note. A plugin's `caret` slot follows the caret into the views mounted inside its `EditorContent`, as [Toolbar](/docs/toolbar#act-where-the-caret-is) describes.
|
|
62
|
+
|
|
61
63
|
## Captured interactions
|
|
62
64
|
|
|
63
65
|
Use `EditorProvider` to bind controls to an existing editor. For example, a popup can capture the value returned by `useEditor()` when it opens and keep that target until it closes.
|
|
@@ -70,7 +72,7 @@ import { EditorProvider } from 'platejs/react';
|
|
|
70
72
|
</EditorProvider>
|
|
71
73
|
```
|
|
72
74
|
|
|
73
|
-
`EditorProvider` accepts `editor: Editor | null` and `children: React.ReactNode`; it creates no editable view. React portals retain this context. Commands read the target
|
|
75
|
+
`EditorProvider` accepts `editor: Editor | null` and `children: React.ReactNode`; it creates no editable view. React portals retain this context. Commands read the target's current permissions. Read-only or unmounted targets reject writes, and captured interactions never select a replacement view automatically.
|
|
74
76
|
|
|
75
77
|
## API Reference
|
|
76
78
|
|
|
@@ -483,6 +483,9 @@ Renders before Editable and receives `{ editableRef }`.
|
|
|
483
483
|
<APISubListItem parent="slots" name="afterEditable" type="EditableSiblingComponent" optional>
|
|
484
484
|
Renders after Editable and receives `{ editableRef }`.
|
|
485
485
|
</APISubListItem>
|
|
486
|
+
<APISubListItem parent="slots" name="caret" type="EditableSiblingComponent" optional>
|
|
487
|
+
Renders after Editable. While the view that holds the caret is this view or is mounted inside its Editable, such as the text of a board note, the slot's hooks and its `editableRef` prop answer for that view. Otherwise they answer for this view. See [Act where the caret is](/docs/toolbar#act-where-the-caret-is).
|
|
488
|
+
</APISubListItem>
|
|
486
489
|
<APISubListItem parent="slots" name="beforeContainer" type="ContainerSiblingComponent" optional>
|
|
487
490
|
Renders before `EditorContainer` and receives `{ containerRef }`.
|
|
488
491
|
</APISubListItem>
|
|
@@ -42,9 +42,9 @@ editor UI to its container; it does not identify the editable DOM element.
|
|
|
42
42
|
|
|
43
43
|
`useEditableRef()` returns the matching view's `Editable` element ref. Its
|
|
44
44
|
`current` value is `null` before mount. Use it to read the DOM selection or position UI against the text,
|
|
45
|
-
as the copied floating toolbar does.
|
|
46
|
-
[`
|
|
47
|
-
|
|
45
|
+
as the copied floating toolbar does. In a plugin's
|
|
46
|
+
[`caret` slot](/docs/toolbar#act-where-the-caret-is) it is the `Editable` of the view that
|
|
47
|
+
holds the caret while that view is mounted inside the slot's editing area.
|
|
48
48
|
|
|
49
49
|
`EditorRoot` and `EditorContent` manage editor registration and mount status. Set
|
|
50
50
|
primary-editor eligibility through `EditorRoot`'s `primary` prop and pass read-only
|
package/dist/docs/api/core.md
CHANGED
|
@@ -524,9 +524,41 @@ const editor = createEditor({
|
|
|
524
524
|
const elementId = editor.plugin(ElementIdPlugin);
|
|
525
525
|
const key = editor.key(element);
|
|
526
526
|
const id = elementId.read.id(key);
|
|
527
|
-
const entry = id ?
|
|
527
|
+
const entry = id ? editor.read.nodes.byId(id) : null;
|
|
528
|
+
|
|
529
|
+
editor.update.nodes.move({ at: { id: "intro" }, to: [0] });
|
|
530
|
+
editor.update((tx) => tx.nodes.remove({ at: { id: "intro" } }));
|
|
528
531
|
```
|
|
529
532
|
|
|
533
|
+
An editor that stores IDs finds and targets an element by its ID:
|
|
534
|
+
|
|
535
|
+
- `editor.read.nodes.byId(id)`: the element that holds `id`, as
|
|
536
|
+
`{ key, node, path, root? }`, or `null`. `root` is present only when the
|
|
537
|
+
element lives in a named root.
|
|
538
|
+
- `tx.nodes.byId(id)`: the same lookup inside an update, read from its draft.
|
|
539
|
+
It throws once its update ends.
|
|
540
|
+
- `{ id }`: a node target, such as `nodes.path({ id })` on a read or
|
|
541
|
+
`at: { id }` on a transform, which acts as the key of the element that holds
|
|
542
|
+
the ID. Text, mark, range and offset targets keep their point or range. A
|
|
543
|
+
target is an ID only as an object, not an array, whose one own key is a
|
|
544
|
+
string `id`.
|
|
545
|
+
|
|
546
|
+
An editor stores IDs when the schema gives every element type a generated,
|
|
547
|
+
unique string `id`, as the plugin's default target does, and no content admits
|
|
548
|
+
undeclared element types. In any other editor, `byId` and `at: { id }` throw.
|
|
549
|
+
|
|
550
|
+
A command, a plugin update method and every one-shot on `editor.update` or on
|
|
551
|
+
a writable view's `update` look an ID up in the command's document. Over
|
|
552
|
+
another author's pending suggestions, they reach a moved element's moved copy
|
|
553
|
+
and change nothing for an ID that only a struck original holds. A path in
|
|
554
|
+
`to`, `after` or `before`, and a child `position`, still names a place in the
|
|
555
|
+
stored document. A raw `editor.update((tx) => ...)` looks the ID up in the
|
|
556
|
+
stored draft, as it resolves a path or a key, so it reaches the struck
|
|
557
|
+
original. An editor view answers from its own document, except a read while a
|
|
558
|
+
command runs, which answers from the command's document. When no element holds
|
|
559
|
+
the ID, a write changes nothing and a read returns its empty result.
|
|
560
|
+
[Node identity](/docs/editor#node-identity) shows each route.
|
|
561
|
+
|
|
530
562
|
Configure `initialState.generateId` to replace the default full-length
|
|
531
563
|
`nanoid()` generator. Include `ElementIdPlugin` in the target passed to
|
|
532
564
|
`defineDocumentMigrations`. The plugin declares its `id` with `unique: true`,
|
|
@@ -542,7 +574,8 @@ The application schema can narrow the plugin-owned `id` target. Current
|
|
|
542
574
|
document admission generates and retains IDs only for elements that match the
|
|
543
575
|
compiled target. A narrowed target must match every type that can take a
|
|
544
576
|
matched type's place, so `target.group("block")` works while no element's
|
|
545
|
-
content admits both a block and an inline element.
|
|
577
|
+
content admits both a block and an inline element. Narrow it only when the
|
|
578
|
+
application never finds or targets an element by ID:
|
|
546
579
|
|
|
547
580
|
```ts
|
|
548
581
|
const editor = createEditor({
|
|
@@ -557,6 +590,10 @@ const editor = createEditor({
|
|
|
557
590
|
});
|
|
558
591
|
```
|
|
559
592
|
|
|
593
|
+
A block-only target leaves inline elements without IDs, so `nodes.byId` and
|
|
594
|
+
`at: { id }` throw in that editor, even for a block's ID. `read.id(key)` and
|
|
595
|
+
pen marks from `platejs/ink` keep working.
|
|
596
|
+
|
|
560
597
|
### `ElementStatePlugin`
|
|
561
598
|
|
|
562
599
|
Extend editor behavior.
|
|
@@ -670,7 +707,8 @@ Generic component for rendering an element.
|
|
|
670
707
|
Necessary for rendering the node children.
|
|
671
708
|
</APIItem>
|
|
672
709
|
<APIItem name="as" type="React.ElementType" optional>
|
|
673
|
-
The component type to render as.
|
|
710
|
+
The component type to render as.
|
|
711
|
+
- **Default:** `'div'`
|
|
674
712
|
</APIItem>
|
|
675
713
|
</APIProps>
|
|
676
714
|
</API>
|
|
@@ -705,7 +743,8 @@ Generic component for rendering a leaf.
|
|
|
705
743
|
</APISubList>
|
|
706
744
|
</APIItem>
|
|
707
745
|
<APIItem name="as" type="React.ElementType" optional>
|
|
708
|
-
The component type to render as.
|
|
746
|
+
The component type to render as.
|
|
747
|
+
- **Default:** `'span'`
|
|
709
748
|
</APIItem>
|
|
710
749
|
</APIProps>
|
|
711
750
|
</API>
|
|
@@ -729,7 +768,8 @@ Generic component for rendering text.
|
|
|
729
768
|
Necessary for rendering the node children.
|
|
730
769
|
</APIItem>
|
|
731
770
|
<APIItem name="as" type="React.ElementType" optional>
|
|
732
|
-
The component type to render as.
|
|
771
|
+
The component type to render as.
|
|
772
|
+
- **Default:** `'span'`
|
|
733
773
|
</APIItem>
|
|
734
774
|
</APIProps>
|
|
735
775
|
</API>
|
package/dist/docs/api/dom.md
CHANGED
|
@@ -33,8 +33,11 @@ view, picked by the editor you call it on:
|
|
|
33
33
|
- An editor from `useRootEditor(root)` runs in the view of `root` it follows,
|
|
34
34
|
as [`useRootEditor`](/docs/api/react-hooks) describes, so its DOM calls and
|
|
35
35
|
its commands reach the same view, even after focus moves to a button. While
|
|
36
|
-
no `EditorContent`
|
|
37
|
-
|
|
36
|
+
no `EditorContent` in its `EditorRoot` shows `root`, it finds no
|
|
37
|
+
`EditorContent`, even when one in another `EditorRoot` holds the caret, so
|
|
38
|
+
`editable()` returns `null` and `hasDOMNode` returns `false`. `resolveNode`
|
|
39
|
+
and `resolvePoint` still resolve a text node of `root` that another view
|
|
40
|
+
renders with the default leaf.
|
|
38
41
|
- The editor `createEditor` returns runs in a view that shows the root the
|
|
39
42
|
call is about: its target's root, else the caret's root, else the primary
|
|
40
43
|
document. When the caret was placed in that root from an `EditorRoot`,
|
|
@@ -116,11 +119,15 @@ Check if the DOM editor is in read-only mode.
|
|
|
116
119
|
|
|
117
120
|
#### `editor.api.dom.blur(): void`
|
|
118
121
|
|
|
119
|
-
Blur the editor
|
|
122
|
+
Blur the editor, and take focus from the root's `nodeSelectionFocus` element
|
|
123
|
+
while it holds it. An unmounted editor only clears its focused state.
|
|
120
124
|
|
|
121
125
|
#### `editor.api.dom.focus(options?: { retries?: number }): void`
|
|
122
126
|
|
|
123
|
-
Focus the editor's [view](#views). Does nothing when no view is picked.
|
|
127
|
+
Focus the editor's [view](#views). Does nothing when no view is picked. The
|
|
128
|
+
root's `nodeSelectionFocus` element takes focus while there is no selection or
|
|
129
|
+
a node selection holds only the root's top-level blocks, and a range shown
|
|
130
|
+
across roots stays shown.
|
|
124
131
|
|
|
125
132
|
#### `editor.api.dom.deselect(): void`
|
|
126
133
|
|
|
@@ -301,7 +301,8 @@ target has no default it can become.
|
|
|
301
301
|
editor.update.blocks.toggle({ type: "heading", level: 2 });
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
Pass `{ wrap: true }` to wrap or unwrap the targeted blocks instead.
|
|
304
|
+
Pass `{ wrap: true }` to wrap or unwrap the targeted blocks instead. Adjacent
|
|
305
|
+
targeted blocks with the same parent share one wrapper.
|
|
305
306
|
|
|
306
307
|
## Break methods
|
|
307
308
|
|
|
@@ -351,9 +351,40 @@ The editor follows the `EditorContent` that shows its root inside the
|
|
|
351
351
|
the user last focused or pressed. Until the user has focused or pressed one,
|
|
352
352
|
it follows the first one mounted. Once the one it follows unmounts, it follows
|
|
353
353
|
the one the user focused or pressed before that, or the first one mounted when
|
|
354
|
-
the user has focused or pressed no other. While
|
|
355
|
-
|
|
356
|
-
|
|
354
|
+
the user has focused or pressed no other. While every `EditorContent` of the
|
|
355
|
+
root there is hidden, as under an `Activity` or a plugin whose `wrapRoot`
|
|
356
|
+
returns `null`, it follows a hidden one. While none of the root is mounted
|
|
357
|
+
there, it follows the `EditorRoot`, or the `EditorContent` around the hook when
|
|
358
|
+
the hook renders inside one. An `EditorRoot`'s `readOnly` holds for every
|
|
359
|
+
write of the render that sets it. That includes writes through each
|
|
360
|
+
`EditorContent` inside it that sets no `readOnly` and that the render keeps,
|
|
361
|
+
mounts, removes, hides or suspends. An `EditorContent` inside another
|
|
362
|
+
`EditorContent`, or inside an `EditorReadOnlyProvider` that sets `readOnly`,
|
|
363
|
+
takes the lock through its own `readOnly` instead. The lock covers a control's unmount code and a custom
|
|
364
|
+
element's connect. It does not cover the first `attributeChangedCallback` of a
|
|
365
|
+
custom element that React creates in that render with an observed attribute,
|
|
366
|
+
because React runs that callback while it renders. When `readOnly` turns off,
|
|
367
|
+
writes stay refused until React has removed and inserted the nodes of that
|
|
368
|
+
render. A preview takes hold in the `EditorRoot`'s layout effect, and an
|
|
369
|
+
`EditorContent`'s own `readOnly` takes hold in its layout effect in the render
|
|
370
|
+
that mounts it. In such a render, a write from code that runs before that
|
|
371
|
+
layout effect can still land, such as a control's mount or unmount code or an
|
|
372
|
+
earlier layout effect. An `EditorContent` that the render keeps applies its
|
|
373
|
+
own `readOnly` where it sits in the tree. So a class component's
|
|
374
|
+
`getSnapshotBeforeUpdate` placed before it can still write, and a render that
|
|
375
|
+
hides or suspends it applies the lock only once it shows again.
|
|
376
|
+
`setEditorViewing(editor, true)` on the hook's editor and `AuthoredPlugin`'s
|
|
377
|
+
`api.setView` take hold at the call, so call one before that render to refuse
|
|
378
|
+
those writes too. A preview set while the user composes text takes hold when
|
|
379
|
+
the composition ends.
|
|
380
|
+
|
|
381
|
+
The editor never acts in another `EditorRoot`, even while an `EditorContent`
|
|
382
|
+
there holds the caret in the hook's root, and that `EditorRoot`'s lock and
|
|
383
|
+
authored mode never apply to it. So a press in a writable `EditorRoot` writes
|
|
384
|
+
plain text into a root that another `EditorRoot` shows read-only or in
|
|
385
|
+
suggesting mode. A write through it that places the
|
|
386
|
+
caret moves the caret into its own `EditorRoot`. Under an `EditorRoot` that
|
|
387
|
+
shows a preview, its content edits throw and its selection changes go through.
|
|
357
388
|
|
|
358
389
|
While what it follows is read-only, every update through the editor throws,
|
|
359
390
|
and `{ readOnly: false }` does not make the editor writable. An `EditorContent`
|
|
@@ -362,8 +393,8 @@ The editor also takes the
|
|
|
362
393
|
[authored view](/docs/api/core/plate-components#authored-view) of what it
|
|
363
394
|
follows, so it records its edits as proposals in suggesting mode.
|
|
364
395
|
|
|
365
|
-
A nested `EditorRoot` is a view of its own
|
|
366
|
-
|
|
396
|
+
A nested `EditorRoot` is a view of its own, and an editor from a hook outside
|
|
397
|
+
it never acts in it.
|
|
367
398
|
|
|
368
399
|
Its `editor.api.dom` calls run in the view it follows, so it can focus the
|
|
369
400
|
view it edits, even after focus moves to the button:
|
|
@@ -374,11 +405,12 @@ const note = useRootEditor("note");
|
|
|
374
405
|
return <button onClick={() => note.api.dom.focus()}>Edit note</button>;
|
|
375
406
|
```
|
|
376
407
|
|
|
377
|
-
While no `EditorContent`
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
408
|
+
While no `EditorContent` in its `EditorRoot` shows the root, `editable()`
|
|
409
|
+
returns `null` and `focus()` does nothing, even when an `EditorContent` in
|
|
410
|
+
another `EditorRoot` holds the caret. A call given a
|
|
411
|
+
DOM node, an event or pointer coordinates runs in the view of the root that
|
|
412
|
+
holds them, when that view belongs to the same `EditorRoot`, as
|
|
413
|
+
[Views](/docs/api/dom#views) describes.
|
|
382
414
|
|
|
383
415
|
#### `useRootChrome(root?, options?): RootChromeController`
|
|
384
416
|
|
|
@@ -532,9 +564,9 @@ const referenceRect = geometry?.boundingRect ?? null;
|
|
|
532
564
|
- `boundingRect`, `focusRect` and `rects` cover the whole range, scrolled out
|
|
533
565
|
of view or not. Use `boundingRect` to place a toolbar and `focusRect` to
|
|
534
566
|
place a caret or label.
|
|
535
|
-
- `clipRect` is the
|
|
536
|
-
cut by every box that clips it, its own box included when
|
|
537
|
-
It is `null` when
|
|
567
|
+
- `clipRect` is the area where the `EditorContent`'s text can show: the
|
|
568
|
+
viewport cut by every box that clips it, its own box included when its
|
|
569
|
+
overflow clips. It is `null` when that area is empty.
|
|
538
570
|
- `visible` holds the same three boxes cut to `clipRect`. A line that only
|
|
539
571
|
touches the edge is dropped, and a caret on the edge stays. It is `null`
|
|
540
572
|
when no part of the range shows.
|
|
@@ -125,9 +125,11 @@ export function SuggestionEditor() {
|
|
|
125
125
|
|
|
126
126
|
The editor must install an authored plugin, either directly or through `SuggestionPlugin`. Changing the `authored` prop updates this view. Rerendering with an equivalent value preserves later mode changes made through the mounted view's portal.
|
|
127
127
|
|
|
128
|
-
For an interactive mode control, set the intent on the mounted view:
|
|
128
|
+
For an interactive mode control, set the intent on the mounted view, which `useEditor()` returns inside `EditorRoot`. The mounted view keeps its own mode, so `setView` on the editor passed to `EditorRoot` does not change what it shows:
|
|
129
129
|
|
|
130
130
|
```tsx
|
|
131
|
+
const editor = useEditor();
|
|
132
|
+
|
|
131
133
|
editor.plugin(AuthoredPlugin).api.setView({ intent: "propose" });
|
|
132
134
|
```
|
|
133
135
|
|
|
@@ -202,7 +204,7 @@ Each `AuthoredChange` has its `id`, `authorId`, `createdAt`, `kind`, current `ra
|
|
|
202
204
|
|
|
203
205
|
Except for a split or join inside a top-level block, no revision covers where a change sits, so an edit before it keeps the revision. Its `ranges` can move while its revision stays the same, so read them again after each document change. A join, split, wrap or unwrap's revision ignores the text and leaves inside the element, so typing inside keeps it. It changes when the element's own fields change, or the order or shapes of the elements inside it. The revision of a split or join inside a top-level block, such as a quote, also covers its index inside that block, because a decision merges its line into the block before it. The index counts blocks, so it does not say which block comes before the line. After the blocks before it change order, or one of them is replaced or changes type, a decision read before still applies and merges the line into the block now before it. A block that lands between the halves of a top-level split or join also keeps the revision, and a decision read before merges the line into that block.
|
|
204
206
|
|
|
205
|
-
A decision names the changes as they were read, and a change whose revision moved since returns `stale`. Accepting a change can need other changes accepted with it, and rejecting one can need its dependants rejected. The result is then `blocked`, `with` names the changes it needs, and nothing applies. The editor never decides a change you did not name. Several decisions in one call decide together:
|
|
207
|
+
A decision names the changes as they were read, and a change whose revision moved since returns `stale`. Accepting a change can need other changes accepted with it, and rejecting one can need its dependants rejected. The result is then `blocked`, `with` names the changes it needs, and nothing applies. The editor never decides a change you did not name. Accepting a line someone typed right after another author's pending join applies without waiting for that join. The line stays where it is stored, and accepting the join later places it after the joined line, as deciding both at once does. Between different authors, the order of decisions can still change where such a line ends. It can also change where a line someone moved in Editing ends when the split that made it is rejected. Several decisions in one call decide together:
|
|
206
208
|
|
|
207
209
|
```tsx
|
|
208
210
|
if (result.status === "blocked") {
|
|
@@ -225,7 +227,7 @@ for (const part of details?.parts ?? []) {
|
|
|
225
227
|
}
|
|
226
228
|
```
|
|
227
229
|
|
|
228
|
-
`details(id)` returns the change and its parts. Content parts include before and after slices. A content part's `action` is `replace` for a deletion and the insertion right after it that touch in the document as it stands. A deletion and an insertion apart, such as a moved paragraph's two copies, are a `delete` part and an `insert` part. Boundary parts distinguish paragraph splits from joins. Enclosure parts name wraps and unwraps. Property parts
|
|
230
|
+
`details(id)` returns the change and its parts. Content parts include before and after slices. A content part's `action` is `replace` for a deletion and the insertion right after it that touch in the document as it stands, when neither node is the other or holds it. A deletion and an insertion apart, such as a moved paragraph's two copies, are a `delete` part and an `insert` part. Boundary parts distinguish paragraph splits from joins. Enclosure parts name wraps and unwraps. Property parts hold the before and after values recorded with each write. A format write reads no part when it sets the value the node held when the write was recorded, or when it removes a property that the node never had and no other suggestion wrote. After a decision on another suggestion under the write, it still reads what it recorded: no part, or a `before` that rejecting the write may no longer restore. A removal of a property that the node did not have, written over another suggestion's write, reads a part that names no property.
|
|
229
231
|
|
|
230
232
|
### Review cards
|
|
231
233
|
|
|
@@ -235,13 +237,15 @@ A review card groups one author's adjacent pending changes, such as a deletion a
|
|
|
235
237
|
const [card] = authored.read.groups({ at: [0] });
|
|
236
238
|
|
|
237
239
|
if (card) {
|
|
238
|
-
const
|
|
240
|
+
const shown = authored.read.groupDetails(card.id, { limit: 20 });
|
|
239
241
|
const decided = authored.update.decide({ action: "accept", groups: [card] });
|
|
240
242
|
}
|
|
241
243
|
```
|
|
242
244
|
|
|
243
245
|
`groups({ at })` returns summaries of the cards touching a place of the document the view shows, in document order: `id`, `authorId`, `createdAt`, `changeCount`, and `revision`. A card's ID is its oldest change, so every peer and reload names it alike. The ID moves when the card splits or merges, or when that change leaves it. `groupOf(changeId)` returns the card that holds a change.
|
|
244
246
|
|
|
247
|
+
`groupDetails(changeId, { limit })` reads what a card shows: its first `limit` changes in document order and their parts, or `null` when the ID names no pending change. Any change of the card finds it. Without `limit` the read takes the whole card, and a `limit` that is not a positive safe integer throws. A deletion that ends one change and a touching insertion that starts the next read as one `replace` part when neither node is the other or holds it, as in `details`. A deletion inside a node that a change in the read deletes reads in that node's part, and so does an insertion inside a node that a change in the read inserts. An insertion inside a deleted node keeps its own part, and the deleted node's part still holds the inserted text. Property changes with the same `before` and the same `after` read as one part with no location, so two removals that name no property read as one part. An edit beside the card can change which of its parts touch while its revision stays the same, so read it again after each document change while the card is open.
|
|
248
|
+
|
|
245
249
|
Deciding a card decides every change it holds at that moment. The decision reads as `stale` once the card's ID or revision moved, so read the card again with `groupOf` before retrying.
|
|
246
250
|
|
|
247
251
|
### Decision results
|
|
@@ -416,6 +420,7 @@ After `const authored = editor.plugin(AuthoredPlugin)`, use these methods:
|
|
|
416
420
|
| `authored.read.changes(query?)` | Read a page of pending changes in document order. |
|
|
417
421
|
| `authored.read.groups({ at })` | Read summaries of the cards touching a place of the document the view shows. |
|
|
418
422
|
| `authored.read.groupOf(changeId)` | Read the card that holds a change, or `null`. |
|
|
423
|
+
| `authored.read.groupDetails(changeId, options?)` | Read a card's changes and parts as a review card shows them, or `null`. |
|
|
419
424
|
| `authored.read.outcome(id)` | Read whether a change is pending, accepted, rejected or `'contested'`, or `null` when it left with no verdict. |
|
|
420
425
|
| `authored.read.reviewOf(node)` | Read a stored node's pending marks and the accepted values of the properties they format. |
|
|
421
426
|
| `authored.update.decide(decision)` | Accept or reject changes or cards; an array of decisions decides together. |
|
|
@@ -99,7 +99,7 @@ plugin selection, rendering, input rules, and shortcuts editable.
|
|
|
99
99
|
| Block | Plugin | Registry Component | Notes |
|
|
100
100
|
|-------|--------|--------------------|-------|
|
|
101
101
|
| Paragraph | `ParagraphPlugin` | `ParagraphElement` | Comes from `platejs/react`; the registry kit adds the UI component. |
|
|
102
|
-
| Heading 1-6 | `HeadingPlugin`
|
|
102
|
+
| Heading 1-6 | `HeadingPlugin` | `HeadingElement` | Takes `level` 1 to 6; each level has a `mod+alt+<level>` shortcut. |
|
|
103
103
|
| Blockquote | `BlockquotePlugin` | `BlockquoteElement` | Uses a wrapping transform and `mod+shift+period`. |
|
|
104
104
|
| Horizontal rule | `HorizontalRulePlugin` | `HrElement` | Void block; supports dash and underscore markdown rules. |
|
|
105
105
|
|
|
@@ -130,42 +130,55 @@ import {
|
|
|
130
130
|
} from 'platejs';
|
|
131
131
|
import {
|
|
132
132
|
BlockquotePlugin,
|
|
133
|
+
createEditor,
|
|
133
134
|
HeadingPlugin,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
135
|
HorizontalRulePlugin,
|
|
136
|
+
ParagraphPlugin,
|
|
140
137
|
} from 'platejs/react';
|
|
141
|
-
import { createEditor, ParagraphPlugin } from 'platejs/react';
|
|
142
138
|
|
|
143
139
|
export const editor = createEditor({
|
|
144
140
|
plugins: [
|
|
145
141
|
ParagraphPlugin,
|
|
146
142
|
HeadingPlugin.configure({
|
|
147
143
|
inputRules: [HeadingRules.markdown()],
|
|
148
|
-
shortcuts: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
shortcuts: {
|
|
145
|
+
toggleHeading1: {
|
|
146
|
+
handler: ({ editor }) => {
|
|
147
|
+
editor.plugin(HeadingPlugin).update.toggle({ level: 1 });
|
|
148
|
+
},
|
|
149
|
+
keys: 'mod+alt+1',
|
|
150
|
+
},
|
|
151
|
+
toggleHeading2: {
|
|
152
|
+
handler: ({ editor }) => {
|
|
153
|
+
editor.plugin(HeadingPlugin).update.toggle({ level: 2 });
|
|
154
|
+
},
|
|
155
|
+
keys: 'mod+alt+2',
|
|
156
|
+
},
|
|
157
|
+
toggleHeading3: {
|
|
158
|
+
handler: ({ editor }) => {
|
|
159
|
+
editor.plugin(HeadingPlugin).update.toggle({ level: 3 });
|
|
160
|
+
},
|
|
161
|
+
keys: 'mod+alt+3',
|
|
162
|
+
},
|
|
163
|
+
toggleHeading4: {
|
|
164
|
+
handler: ({ editor }) => {
|
|
165
|
+
editor.plugin(HeadingPlugin).update.toggle({ level: 4 });
|
|
166
|
+
},
|
|
167
|
+
keys: 'mod+alt+4',
|
|
168
|
+
},
|
|
169
|
+
toggleHeading5: {
|
|
170
|
+
handler: ({ editor }) => {
|
|
171
|
+
editor.plugin(HeadingPlugin).update.toggle({ level: 5 });
|
|
172
|
+
},
|
|
173
|
+
keys: 'mod+alt+5',
|
|
174
|
+
},
|
|
175
|
+
toggleHeading6: {
|
|
176
|
+
handler: ({ editor }) => {
|
|
177
|
+
editor.plugin(HeadingPlugin).update.toggle({ level: 6 });
|
|
178
|
+
},
|
|
179
|
+
keys: 'mod+alt+6',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
169
182
|
}),
|
|
170
183
|
BlockquotePlugin.configure({
|
|
171
184
|
inputRules: [BlockquoteRules.markdown()],
|
|
@@ -187,6 +200,6 @@ export const editor = createEditor({
|
|
|
187
200
|
|-----|-----|
|
|
188
201
|
| `BasicBlocksKit` from `@/components/editor/basic-blocks` | App-owned React preset for paragraph, blockquote, H1-H6, and horizontal rule behavior. |
|
|
189
202
|
| `BaseBasicBlocksKit` from `@/components/editor/basic-blocks-static` | App-owned static/base preset for the same block family. |
|
|
190
|
-
| `HeadingRules.markdown()` | Creates
|
|
203
|
+
| `HeadingRules.markdown()` | Creates one block-start rule for `# ` through `###### ` that sets the matching heading level. |
|
|
191
204
|
| `BlockquoteRules.markdown()` | Creates the `> ` block-start rule. |
|
|
192
205
|
| `HorizontalRuleRules.markdown({ variant })` | Creates dash or underscore thematic-break rules. |
|
|
@@ -123,14 +123,16 @@ The plugin shows a placeholder only when every gate passes.
|
|
|
123
123
|
| Focus | Editor is focused and has a selection. |
|
|
124
124
|
| Selection | Selection is collapsed. |
|
|
125
125
|
| Active block | `editor.read.nodes.block()` returns an empty block. |
|
|
126
|
-
| Whole editor | The editor is not in its pristine single-empty-block state. Empty blocks with visible structural state, such as list metadata, still qualify. |
|
|
126
|
+
| Whole editor | The editor is not in its pristine single-empty-block state. Empty blocks with visible structural state, such as list metadata, still qualify, unless the editor's own `placeholder` already shows. |
|
|
127
127
|
| Placeholder map | The block type matches one entry in `placeholders`. |
|
|
128
128
|
| Query | `query({ editor, node, path, ...ctx })` returns `true`. |
|
|
129
129
|
|
|
130
130
|
The default `query` returns `true` for root blocks only. The whole-editor guard
|
|
131
131
|
uses `editor.plugin(ElementStatePlugin).api.isEmpty`, so only `type` and
|
|
132
132
|
compiled element properties declared with `role: "metadata"` are treated as
|
|
133
|
-
pristine metadata.
|
|
133
|
+
pristine metadata. When the editor content has a `placeholder`, that placeholder
|
|
134
|
+
covers any single empty block, a list item included, so the block placeholder
|
|
135
|
+
stays hidden and only one placeholder shows.
|
|
134
136
|
|
|
135
137
|
```tsx
|
|
136
138
|
query: ({ path }) => path.length === 1
|
package/dist/docs/blockquote.md
CHANGED
|
@@ -146,8 +146,9 @@ Plugin for blockquote container elements. Renders as `<blockquote>` HTML element
|
|
|
146
146
|
|
|
147
147
|
### `editor.plugin(BlockquotePlugin).update.wrap()`
|
|
148
148
|
|
|
149
|
-
Wrap
|
|
150
|
-
|
|
149
|
+
Wrap the selected blocks in blockquotes. Adjacent selected blocks share one
|
|
150
|
+
blockquote, and blocks already in a quote stay as they are. Pass `at` to target
|
|
151
|
+
a location or node selection.
|
|
151
152
|
|
|
152
153
|
```tsx
|
|
153
154
|
editor.plugin(BlockquotePlugin).update.wrap();
|
|
@@ -155,7 +156,8 @@ editor.plugin(BlockquotePlugin).update.wrap();
|
|
|
155
156
|
|
|
156
157
|
### `editor.plugin(BlockquotePlugin).update.toggle()`
|
|
157
158
|
|
|
158
|
-
Wraps the current block or selection in a blockquote
|
|
159
|
+
Wraps the current block or selection in a blockquote, with adjacent selected
|
|
160
|
+
blocks in one blockquote. If the selection is already inside a blockquote, it unwraps the quoted blocks. Returns `false` and changes nothing when the schema refuses the quote, as it does on a Details title.
|
|
159
161
|
|
|
160
162
|
```tsx
|
|
161
163
|
editor.plugin(BlockquotePlugin).update.toggle();
|