platejs 54.0.0-beta.2 → 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 +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DY104TqL.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-Deo6n6Fs.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-CJX5bKuv.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-DAOYWuvC.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-Dt-unJZY-DCddmbSD.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-ClHasORr.d.ts} +433 -95
- 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 +4 -2
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/dom.md +14 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +25 -11
- package/dist/docs/authored-changes.md +5 -2
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +63 -8
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- 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 +176 -8
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +4 -12
- 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 +29 -5
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +10 -8
- 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/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 +10 -10
- 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 +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 +533 -62
- 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 +1 -1
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +6 -2
- 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 +14 -8
- 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-cg_cWsaN.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-D1CFXA-i.d.ts → index-8WO2vI0U.d.ts} +475 -143
- package/dist/{index-DaM37gF6.d.ts → index-B5mYEawV.d.ts} +37 -21
- package/dist/{index-Bq3sdm3S.d.ts → index-BZWFoUXt.d.ts} +5 -4
- package/dist/{index-DdIRduDG.d.ts → index-C0POz7rg.d.ts} +3 -2
- package/dist/{index-Bxfvicyy.d.ts → index-C1_JIhL4.d.ts} +4 -3
- package/dist/{index-DC_MNGyu.d.ts → index-C35V_hj0.d.ts} +3 -3
- package/dist/{index-kLKMc-pI.d.ts → index-C6ql9pKw.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-C9DiGDVj.d.ts} +35 -5
- package/dist/{index-DTgaSxKr.d.ts → index-CLsEe3LY.d.ts} +40 -4
- package/dist/{index-CT7miqQN.d.ts → index-CdOLsPaW.d.ts} +29 -9
- package/dist/{index-DLA2DUR2.d.ts → index-CktYvOgk.d.ts} +4 -3
- package/dist/{index-BBKGrsG3.d.ts → index-Cmuluh6f.d.ts} +1 -1
- package/dist/{index-BiQerPJS.d.ts → index-CzLwBZpY.d.ts} +2 -2
- package/dist/{index-DzD6BIFJ.d.ts → index-D3-2iM1b.d.ts} +7 -5
- package/dist/{index-Cl77E9yr.d.ts → index-DKOFvteF.d.ts} +2 -2
- package/dist/{index-iaZOhA76.d.ts → index-DPWyk3lG-DOYwohXO.d.ts} +1 -1
- package/dist/index-DQnjqtQa.d.ts +678 -0
- package/dist/{index-CcZbqPqk.d.ts → index-Do9pj1GK.d.ts} +73 -39
- package/dist/{index-BU6k1Aev.d.ts → index-DpltOCot-A2b3p3Eb.d.ts} +4735 -4586
- package/dist/{index-Bc2Yg_2j.d.ts → index-HPYawTae-BCUQLEWF.d.ts} +2 -2
- package/dist/{index-BkR7-GLI.d.ts → index-baQOK89E.d.ts} +2 -2
- package/dist/{index-D5W-p9bS.d.ts → index-oIJAZxc2.d.ts} +49 -4
- package/dist/{index-xdmCBvlT.d.ts → index-r7yb77Wy.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 +8 -2
- 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 +5 -15
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +2 -1
- package/dist/markdown/lib/MarkdownPlugin.js +16 -9
- package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +773 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- 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 +314 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +22 -8
- 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/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +17 -8
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +103 -122
- 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/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +184 -49
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +64 -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 +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/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 -29
- 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 +331 -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 +8 -7
- 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 +425 -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 +66 -21
- 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-aUwpNnAw.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 { ru as Value, vr as EditorStateSchemaApi } from "../index-DpltOCot-A2b3p3Eb.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-Dt-unJZY-DCddmbSD.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,7 +47,7 @@ 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
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 provides its model.
|
|
@@ -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/dom.md
CHANGED
|
@@ -33,8 +33,14 @@ 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
|
-
|
|
37
|
-
|
|
36
|
+
it follows an `EditorContent` in another `EditorRoot`, its DOM calls run in
|
|
37
|
+
that `EditorContent`, but `resolveEventRange` returns `null` for an event
|
|
38
|
+
from it, such as a drop. While it follows its own `EditorRoot` because no `EditorContent`
|
|
39
|
+
there shows `root`, and once a write through it that places the caret ends
|
|
40
|
+
a follow into another `EditorRoot`, it finds no `EditorContent`, so
|
|
41
|
+
`editable()` returns `null` and `hasDOMNode` returns `false`. `resolveNode`
|
|
42
|
+
and `resolvePoint` still resolve a text node that any view of the editor
|
|
43
|
+
renders.
|
|
38
44
|
- The editor `createEditor` returns runs in a view that shows the root the
|
|
39
45
|
call is about: its target's root, else the caret's root, else the primary
|
|
40
46
|
document. When the caret was placed in that root from an `EditorRoot`,
|
|
@@ -116,11 +122,15 @@ Check if the DOM editor is in read-only mode.
|
|
|
116
122
|
|
|
117
123
|
#### `editor.api.dom.blur(): void`
|
|
118
124
|
|
|
119
|
-
Blur the editor
|
|
125
|
+
Blur the editor, and take focus from the root's `nodeSelectionFocus` element
|
|
126
|
+
while it holds it. An unmounted editor only clears its focused state.
|
|
120
127
|
|
|
121
128
|
#### `editor.api.dom.focus(options?: { retries?: number }): void`
|
|
122
129
|
|
|
123
|
-
Focus the editor's [view](#views). Does nothing when no view is picked.
|
|
130
|
+
Focus the editor's [view](#views). Does nothing when no view is picked. The
|
|
131
|
+
root's `nodeSelectionFocus` element takes focus while there is no selection or
|
|
132
|
+
a node selection holds only the root's top-level blocks, and a range shown
|
|
133
|
+
across roots stays shown.
|
|
124
134
|
|
|
125
135
|
#### `editor.api.dom.deselect(): void`
|
|
126
136
|
|
|
@@ -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
|
|
|
@@ -353,17 +353,31 @@ 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
354
|
the user has focused or pressed no other. While no `EditorContent` there shows
|
|
355
355
|
the root, it follows the `EditorRoot`, or the `EditorContent` around the hook
|
|
356
|
-
when the hook renders inside one.
|
|
356
|
+
when the hook renders inside one. While that `EditorRoot` is writable and
|
|
357
|
+
shows no `EditorContent` at all, and the caret sits in the hook's root inside
|
|
358
|
+
another `EditorRoot` of the same editor, the editor follows the
|
|
359
|
+
`EditorContent` that holds the caret instead, for that `EditorContent`'s DOM
|
|
360
|
+
and for the read-only state of the `EditorRoot` around it. A read-only `EditorContent` that shares
|
|
361
|
+
its `EditorRoot` with a writable one leaves the editor writable. The editor
|
|
362
|
+
keeps the authored view of its own `EditorRoot`. A write through it that
|
|
363
|
+
places the caret, even where the caret already is, moves the caret into its
|
|
364
|
+
own `EditorRoot`, which ends the follow. A caret that moves only because the
|
|
365
|
+
content around it changed stays in the followed `EditorContent`. An
|
|
366
|
+
`EditorRoot` that shows a preview counts as writable here, so its editor
|
|
367
|
+
follows too. The preview refuses the editor's content edits, but a selection
|
|
368
|
+
change through the editor still ends the follow, and a review decision still
|
|
369
|
+
changes the document. When that `EditorRoot` is read-only, the editor stays
|
|
370
|
+
read-only instead.
|
|
357
371
|
|
|
358
372
|
While what it follows is read-only, every update through the editor throws,
|
|
359
373
|
and `{ readOnly: false }` does not make the editor writable. An `EditorContent`
|
|
360
374
|
that overrides the `readOnly` of its `EditorRoot` decides for the editor too.
|
|
361
|
-
|
|
375
|
+
Outside that follow into another `EditorRoot`, the editor also takes the
|
|
362
376
|
[authored view](/docs/api/core/plate-components#authored-view) of what it
|
|
363
377
|
follows, so it records its edits as proposals in suggesting mode.
|
|
364
378
|
|
|
365
379
|
A nested `EditorRoot` is a view of its own. An editor from a hook outside it
|
|
366
|
-
|
|
380
|
+
follows it only while it holds the caret, as above.
|
|
367
381
|
|
|
368
382
|
Its `editor.api.dom` calls run in the view it follows, so it can focus the
|
|
369
383
|
view it edits, even after focus moves to the button:
|
|
@@ -374,11 +388,11 @@ const note = useRootEditor("note");
|
|
|
374
388
|
return <button onClick={() => note.api.dom.focus()}>Edit note</button>;
|
|
375
389
|
```
|
|
376
390
|
|
|
377
|
-
While
|
|
378
|
-
return `null` and `focus()` does nothing. A call given a
|
|
379
|
-
pointer coordinates runs in the view of the root that
|
|
380
|
-
view belongs to the same `EditorRoot`, as
|
|
381
|
-
describes.
|
|
391
|
+
While the editor follows its `EditorRoot` because no `EditorContent` shows the
|
|
392
|
+
root, its DOM lookups return `null` and `focus()` does nothing. A call given a
|
|
393
|
+
DOM node, an event or pointer coordinates runs in the view of the root that
|
|
394
|
+
holds them, when that view belongs to the same `EditorRoot`, as
|
|
395
|
+
[Views](/docs/api/dom#views) describes.
|
|
382
396
|
|
|
383
397
|
#### `useRootChrome(root?, options?): RootChromeController`
|
|
384
398
|
|
|
@@ -532,9 +546,9 @@ const referenceRect = geometry?.boundingRect ?? null;
|
|
|
532
546
|
- `boundingRect`, `focusRect` and `rects` cover the whole range, scrolled out
|
|
533
547
|
of view or not. Use `boundingRect` to place a toolbar and `focusRect` to
|
|
534
548
|
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
|
|
549
|
+
- `clipRect` is the area where the `EditorContent`'s text can show: the
|
|
550
|
+
viewport cut by every box that clips it, its own box included when its
|
|
551
|
+
overflow clips. It is `null` when that area is empty.
|
|
538
552
|
- `visible` holds the same three boxes cut to `clipRect`. A line that only
|
|
539
553
|
touches the edge is dropped, and a caret on the edge stays. It is `null`
|
|
540
554
|
when no part of the range shows.
|
|
@@ -225,7 +225,7 @@ for (const part of details?.parts ?? []) {
|
|
|
225
225
|
}
|
|
226
226
|
```
|
|
227
227
|
|
|
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
|
|
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, 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
229
|
|
|
230
230
|
### Review cards
|
|
231
231
|
|
|
@@ -235,13 +235,15 @@ A review card groups one author's adjacent pending changes, such as a deletion a
|
|
|
235
235
|
const [card] = authored.read.groups({ at: [0] });
|
|
236
236
|
|
|
237
237
|
if (card) {
|
|
238
|
-
const
|
|
238
|
+
const shown = authored.read.groupDetails(card.id, { limit: 20 });
|
|
239
239
|
const decided = authored.update.decide({ action: "accept", groups: [card] });
|
|
240
240
|
}
|
|
241
241
|
```
|
|
242
242
|
|
|
243
243
|
`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
244
|
|
|
245
|
+
`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.
|
|
246
|
+
|
|
245
247
|
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
248
|
|
|
247
249
|
### Decision results
|
|
@@ -416,6 +418,7 @@ After `const authored = editor.plugin(AuthoredPlugin)`, use these methods:
|
|
|
416
418
|
| `authored.read.changes(query?)` | Read a page of pending changes in document order. |
|
|
417
419
|
| `authored.read.groups({ at })` | Read summaries of the cards touching a place of the document the view shows. |
|
|
418
420
|
| `authored.read.groupOf(changeId)` | Read the card that holds a change, or `null`. |
|
|
421
|
+
| `authored.read.groupDetails(changeId, options?)` | Read a card's changes and parts as a review card shows them, or `null`. |
|
|
419
422
|
| `authored.read.outcome(id)` | Read whether a change is pending, accepted, rejected or `'contested'`, or `null` when it left with no verdict. |
|
|
420
423
|
| `authored.read.reviewOf(node)` | Read a stored node's pending marks and the accepted values of the properties they format. |
|
|
421
424
|
| `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. |
|
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();
|
package/dist/docs/board.md
CHANGED
|
@@ -13,7 +13,8 @@ _Example `board-demo` in the Plate repository: `apps/www/src/registry/examples/b
|
|
|
13
13
|
- Styles stored on each shape: fill, outline color, line style, outline width, opacity and text size, each with a default for its shape type. One pick restyles the selected shapes as one undo step, or the next shape while a drawing tool is picked.
|
|
14
14
|
- Commands to insert, move, resize, restack and remove shapes. Undo never splits a call, and in Suggesting mode each call is one suggestion.
|
|
15
15
|
- Copy, paste and duplicate with fresh shape ids. A copied arrow binds the copied shapes. The copies land on top, with frames still behind the other shapes. They land at the pointer when it is over the board, and step 24px down and right off any shape already at their place.
|
|
16
|
-
- Paste
|
|
16
|
+
- Paste text or a link, and it lands as a selected note at the pointer.
|
|
17
|
+
- Paste an image link or a picture copied from a web page, and it lands as an image shape at the pointer, at the picture's proportions. With [`UploadPlugin`](/docs/upload) installed, picture files that you paste, drop or pick from the toolbar land as image shapes too, and each uploads in its own shape.
|
|
17
18
|
- A camera, a tool, a tool lock and a next style for each mounted view, which the document never stores.
|
|
18
19
|
- Tab and Mod with an arrow move between shapes, Shift+Enter reaches the toolbar, and keys zoom, pan and fit. Enter places a note, shape or frame, and connects two shapes with an arrow. A screen reader hears the selected shape, the picked tool, the zoom, each removal and each step of a connect, in words your app passes.
|
|
19
20
|
- Only the shapes near the camera mount, so the work each keystroke does stays the same as the board grows.
|
|
@@ -34,7 +35,7 @@ _Registry item `board`: `npx shadcn@latest add @plate/board`._
|
|
|
34
35
|
- `BoardPageElement`: renders a board that fills its container. `BoardPageKit` installs it in place of `BoardElement`.
|
|
35
36
|
- `BoardNoteElement`, `BoardGeoElement`, `BoardArrowElement`, `BoardFrameElement` and `BoardStrokeElement`: render each shape type.
|
|
36
37
|
- `BoardImageElement`: renders an image shape. `BoardImageKit` installs it apart from `BoardKit`, as [Images](#images) shows.
|
|
37
|
-
- `BoardToolbar`: picks the select, hand, note, shape, arrow, frame, pen or eraser tool, and its shape menu picks a rectangle, ellipse, diamond or triangle for the next shape. The lock button after them turns the tool lock on or off, as Q does, and shows pressed while the lock is on. Zoom out and zoom in move one zoom step, the zoom level between them shows the zoom as a percentage and goes back to 100% when clicked, and the fit button brings every shape into view. With a frame selected, an icon button removes the frame and keeps the frame's shapes.
|
|
38
|
+
- `BoardToolbar`: picks the select, hand, note, shape, arrow, frame, pen or eraser tool, and its shape menu picks a rectangle, ellipse, diamond or triangle for the next shape. The lock button after them turns the tool lock on or off, as Q does, and shows pressed while the lock is on. The Image button after the lock opens a file picker and lands the picked pictures, as [Picture files](#picture-files) describes, and is disabled on a board that takes no picture files. Zoom out and zoom in move one zoom step, the zoom level between them shows the zoom as a percentage and goes back to 100% when clicked, and the fit button brings every shape into view. With a frame selected, an icon button removes the frame and keeps the frame's shapes.
|
|
38
39
|
- `BoardStylePanel`: docks at the board's top right and styles the selected shapes, or the next shape while a drawing tool is picked, as [Style panel](#style-panel) shows.
|
|
39
40
|
|
|
40
41
|
### Add kit
|
|
@@ -62,7 +63,7 @@ In this example the board is the page's only block, like a whiteboard app. It fi
|
|
|
62
63
|
|
|
63
64
|
_Example `board-page-demo` in the Plate repository: `apps/www/src/registry/examples/board-page-demo.tsx`, `apps/www/src/registry/examples/values/board-value.tsx`._
|
|
64
65
|
|
|
65
|
-
`BoardPageKit` draws the board with `BoardPageElement`, which passes `height="100%"` to `BoardSurface`. That `height` replaces the board's stored `height` in this view and never changes the document, so the board takes the height of the editor around it. Give the editor a height, as the example does with `<Editor className="h-full" variant="none" />` inside a container of set height. Leave out kits that wrap each block or add a paragraph after the last one, such as the drag handles and the trailing block of `EditorKit`. The example installs `ImagePlugin` and `BoardImageKit`, so a pasted picture lands on its board as [Images](#images) describes.
|
|
66
|
+
`BoardPageKit` draws the board with `BoardPageElement`, which passes `height="100%"` to `BoardSurface`. That `height` replaces the board's stored `height` in this view and never changes the document, so the board takes the height of the editor around it. Give the editor a height, as the example does with `<Editor className="h-full" variant="none" />` inside a container of set height. Leave out kits that wrap each block or add a paragraph after the last one, such as the drag handles and the trailing block of `EditorKit`. The example installs `ImagePlugin` and `BoardImageKit`, so a pasted image link or web picture lands on its board as [Images](#images) describes. It installs no `UploadPlugin`, so its board takes no [picture files](#picture-files) and its Image button is disabled.
|
|
66
67
|
|
|
67
68
|
## Style panel
|
|
68
69
|
|
|
@@ -134,6 +135,16 @@ function TextSizeRow() {
|
|
|
134
135
|
}
|
|
135
136
|
```
|
|
136
137
|
|
|
138
|
+
## Pasted text
|
|
139
|
+
|
|
140
|
+
Paste text or a link while the board has focus, such as after a click on its empty space, and a new note holds it. With the caret in the page's text, the page takes the paste at the caret, even while the pointer is over the board.
|
|
141
|
+
|
|
142
|
+
- The note lands centered on the pointer, or on the view's center when the pointer is off the board, at the note tool's 200 by 200 size and in the next style. It lands as one undo step, and the board selects it.
|
|
143
|
+
- The note's text takes the paste as a paste into a note's text does, so the paste plugins your editor installs apply. With `LinkPlugin`, a pasted URL becomes a link.
|
|
144
|
+
- With a shape selected, pasted text still lands as a new note, and the selected shape keeps its text.
|
|
145
|
+
- Blank text, or a paste on a read-only board, lands nothing. An image link lands as an image shape, as [Images](#images) says.
|
|
146
|
+
- While a shape's text is being edited, a paste goes into that text.
|
|
147
|
+
|
|
137
148
|
## Images
|
|
138
149
|
|
|
139
150
|
`BoardImageKit` adds the image shape, a box that holds one picture. Its one child is the document's own image element, so `ImagePlugin` keeps the picture's link, alt text, HTML and Markdown. Install the kit in an editor that installs `ImagePlugin`, such as one with the [media kit](/docs/media). The demo at the top of this page gets it from `EditorKit`.
|
|
@@ -188,6 +199,47 @@ editor.update((tx) => {
|
|
|
188
199
|
});
|
|
189
200
|
```
|
|
190
201
|
|
|
202
|
+
### Picture files
|
|
203
|
+
|
|
204
|
+
Install `UploadPlugin` beside `ImagePlugin`, and the board takes picture files. Each file lands in its own image shape, which holds an upload draft until the file finishes uploading and holds the picture after that. [Upload Files](/docs/upload) sets up the plugin, its client and its rules. `EditorKit` holds both plugins, so the demo at the top of this page takes files. That demo keeps each upload in the browser tab.
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
import { createEditor } from 'platejs/react';
|
|
208
|
+
|
|
209
|
+
import { BoardImageKit, BoardKit } from '@/components/editor/board';
|
|
210
|
+
import { MediaKit } from '@/components/editor/media';
|
|
211
|
+
import { UploadKit } from '@/components/editor/upload';
|
|
212
|
+
|
|
213
|
+
const editor = createEditor({
|
|
214
|
+
plugins: [
|
|
215
|
+
// ...otherPlugins,
|
|
216
|
+
...MediaKit,
|
|
217
|
+
...UploadKit,
|
|
218
|
+
...BoardKit,
|
|
219
|
+
...BoardImageKit,
|
|
220
|
+
],
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
| Gesture | Where the pictures land |
|
|
225
|
+
| --- | --- |
|
|
226
|
+
| Paste copied files while the board has focus | Centered on the pointer, or on the view's center when the pointer is off the board. |
|
|
227
|
+
| Drop files on the board | Centered on the drop point. |
|
|
228
|
+
| Click the toolbar's Image button and pick files | Centered on the view. |
|
|
229
|
+
|
|
230
|
+
- The files of one paste, drop or pick land as image shapes in a row, in file order and 16px apart. They land as one undo step, and the board selects them.
|
|
231
|
+
- The board measures each file before it lands, and sizes its shape as it sizes a pasted link's shape. A file that does not load as a picture lands at 320 by 240.
|
|
232
|
+
- The landing waits for each file to load. It drops the files when another landing starts, when a key or pointer is pressed on the board, when another paste arrives, when focus leaves the board, when the document or the selection changes, or when the view stops being able to write.
|
|
233
|
+
- While a file uploads, its shape draws your upload element. The copied `UploadElement` shows the picture with its progress and a Cancel button. After a failed upload it shows the file's name and "Upload failed. Try again.", and a click on it opens a file picker.
|
|
234
|
+
- Cancel stops the upload and keeps the shape. The shape then shows the upload element's Add an image button. Its file picker takes one file, which uploads in the same shape. Delete removes the shape.
|
|
235
|
+
- One undo removes the shapes of a paste, drop or pick and stops their uploads. An upload that finishes after the undo changes nothing. Redo brings back the pictures of uploads that had finished. For the other shapes it brings back empty drafts, which upload nothing until you pick a file.
|
|
236
|
+
- A file that is not a picture, such as a PDF, lands no shape. `UploadPlugin` passes it to `onError` as `unsupported-file-type`, which the copied `UploadKit` shows as a toast. The pictures beside it still land.
|
|
237
|
+
- `UploadPlugin` checks the pictures of one paste, drop or pick as one batch against its `rules` and `maxFiles`. A batch it refuses lands no shape, and `onError` gets the reason.
|
|
238
|
+
- A picture copied from a web page can carry both its link and its file. The board lands the link, and uploads the file only when the link does not load.
|
|
239
|
+
- While a shape's text is being edited, the board leaves pasted and dropped files to the page. A file pasted into a note's text lands no shape, and `UploadPlugin` reports that it does not fit there.
|
|
240
|
+
|
|
241
|
+
The board takes picture files only in a view that can write, in an editor that installs both `UploadPlugin` and `ImagePlugin`. On any other board, the Image button is disabled and a pasted or dropped file lands no shape. The copied button reads that check as `takesPictureFiles` from `useBoardView`, and lands its files with `upload(files)` from `useBoardActions`.
|
|
242
|
+
|
|
191
243
|
## Manual usage
|
|
192
244
|
|
|
193
245
|
<Steps>
|
|
@@ -234,7 +286,7 @@ const editor = createEditor({
|
|
|
234
286
|
});
|
|
235
287
|
```
|
|
236
288
|
|
|
237
|
-
For pictures, also install `ImagePlugin` and `BoardImagePlugin.configure({ component: BoardImageElement })`.
|
|
289
|
+
For pictures, also install `ImagePlugin` and `BoardImagePlugin.configure({ component: BoardImageElement })`. For [picture files](#picture-files), install `UploadPlugin` too.
|
|
238
290
|
|
|
239
291
|
</Steps>
|
|
240
292
|
|
|
@@ -566,13 +618,16 @@ Every other peer joins the new room with the new plugins and schema, and without
|
|
|
566
618
|
## Limits
|
|
567
619
|
|
|
568
620
|
- Find searches only the page, not the text of notes. Word export leaves out a comment on note text and reports a `comment-range` warning.
|
|
569
|
-
-
|
|
621
|
+
- With the caret in a note, the copied toolbars and the AI menu act on the note, as [Toolbar](/docs/toolbar#act-where-the-caret-is) describes. Insert and Turn into then disable the blocks a note cannot hold, such as tables, quotes and code blocks.
|
|
622
|
+
- Typing `/` or a space in an empty note paragraph inserts the character and opens no menu.
|
|
570
623
|
- Moving a paragraph inside a note is refused. Moving the whole shape keeps its text.
|
|
571
624
|
- Undo of a move puts back your old place, even over a teammate's later move of the same shape.
|
|
572
625
|
- A long note gets slower, because a note's lines sync as one unit.
|
|
573
626
|
- Each keystroke does some work for every board in the document, so keep a document to 100 boards or fewer.
|
|
574
627
|
- Markdown keeps the text and pictures of the shapes in stored order and reports what it drops, such as places and arrow ends. Persist the Plate value, or HTML when the board holds only built-in shape types, to keep a board whole.
|
|
575
|
-
-
|
|
628
|
+
- Without `UploadPlugin`, a picture file pasted or dropped on a board lands no shape, the board reports nothing, and the copied toolbar's Image button is disabled. Paste the picture's link, or insert it from code.
|
|
629
|
+
- A paste, drop or pick of more pictures than `UploadPlugin` takes in one batch lands none of them, and `onError` gets a `too-many-files` failure that holds the limit. The copied `UploadKit` takes three pictures in one batch.
|
|
630
|
+
- A pasted note keeps the note tool's 200 by 200 size, so long text runs past its bottom edge.
|
|
576
631
|
- A shape property named after a style mark's key, such as `color`, `backgroundColor`, `fontSize` or `fontFamily`, also styles the shape's text while that mark's plugin is installed. Give the property another name, the way the note uses `fill`.
|
|
577
632
|
- A board inside a note, rotation and cropping a picture are not supported, and the copied board draws no caption under a picture.
|
|
578
633
|
- Drawing with the pen needs a pointer. A keyboard resize keeps the proportions of an image shape only, and cannot resize around the center, which Shift and Alt do on a corner drag.
|
|
@@ -591,7 +646,7 @@ The shape types: `boardNote`, `boardGeo`, `boardArrow`, `boardFrame` and `boardS
|
|
|
591
646
|
|
|
592
647
|
### `BoardImagePlugin`
|
|
593
648
|
|
|
594
|
-
The image shape, `boardImage`: an object block that holds at most one `image` element or upload draft. Install `ImagePlugin` with it. An editor that installs it with neither `ImagePlugin` nor `UploadPlugin` throws an error naming both.
|
|
649
|
+
The image shape, `boardImage`: an object block that holds at most one `image` element or upload draft. Install `ImagePlugin` with it, and `UploadPlugin` too for [picture files](#picture-files). An editor that installs it with neither `ImagePlugin` nor `UploadPlugin` throws an error naming both.
|
|
595
650
|
|
|
596
651
|
## API Reference
|
|
597
652
|
|
|
@@ -611,5 +666,5 @@ The image shape, `boardImage`: an object block that holds at most one `image` el
|
|
|
611
666
|
| `BoardSurface`, `BoardShape` | `platejs/board/react` | The board's mounted view and a shape's positioned wrapper, for copied renderers. The surface's required `messages` holds every word the board says, as [Screen readers](#screen-readers) lists. Its `height` sets its view's height and defaults to the board's stored `height`. A shape the eraser will remove shows `data-erasing`, which the copied board fades, and the shape under the picking cursor shows `data-board-cursor`, which the copied board rings. A plain wheel over a toolbar element that can still scroll in the wheel's main direction scrolls that element instead of panning the board. |
|
|
612
667
|
| `data-board-dock` | `platejs/board/react` | Marks an element at the top level of the surface's `toolbar` that sits at the board's `"left"` or `"right"` side. Every other top-level toolbar element counts as a row at the board's top or bottom. `fit` and Shift+1 fit the shapes into the room the toolbar leaves clear. Where that room's width or height cannot hold them at 10 percent, they use the board's whole width or height. Both zoom between 10 and 100 percent, so shapes the board cannot hold at 10 percent run past its edges. |
|
|
613
668
|
| `BoardMessages`, `BoardShapeDescription`, `BoardCorner`, `BoardPickState` | `platejs/board/react` | The type of `messages`, the shape that `messages.shape` describes, the corner a resize moves, and where picking stands when the board says `picking` or `pick`. |
|
|
614
|
-
| `useBoardView(selector)`, `useBoardActions()` | `platejs/board/react` | Inside the surface's `toolbar`, read the view's `tool`, `toolLocked`, `camera` and `nextStyle`, its board's selected shapes as `selectedShapes`, each style a pick would set as `styles`,
|
|
669
|
+
| `useBoardView(selector)`, `useBoardActions()` | `platejs/board/react` | Inside the surface's `toolbar`, read the view's `tool`, `toolLocked`, `camera` and `nextStyle`, its board's selected shapes as `selectedShapes`, each style a pick would set as `styles`, whether it can write as `writable`, and whether its board takes picture files as `takesPictureFiles`. A camera `zoom` of 1 is 100 percent. Call `setTool`, `setToolLocked`, `setStyle`, `fit`, `zoomIn`, `zoomOut`, `resetZoom`, `removeFrame`, `focus` and `upload`. From any zoom, `zoomIn` and `zoomOut` go to the next step the `=` or `+` and `-` keys use, and stop at 800 and 10 percent. `resetZoom` zooms to 100 percent, as Shift+0 does. All three work in a read-only view too. `toolLocked` says whether the note, shape, frame and arrow tools stay picked after they add a shape. It is off when the view mounts and is never stored, and `setToolLocked` turns it on or off, as Q does, without changing the tool or the selection. `focus` moves focus back to the board and keeps its selection, such as after a toolbar menu closes. A shape whose text is being edited ends its edit and stays selected. `setStyle` merges into the next style. With the select tool it also writes each style to every selected shape that takes it and to the shape whose text is being edited, as one undo step that keeps the caret. With a drawing tool it styles only the next shape. Each entry of `styles` is `{ mixed: false, value }` when its targets share a value and `{ mixed: true }` when they differ, and a style no target takes has no entry. A read-only view's `setStyle` changes nothing. `upload(files)` lands picture files as image shapes in a row centered on the view, as [Picture files](#picture-files) describes. It changes nothing with an empty list or while `takesPictureFiles` is false. |
|
|
615
670
|
| `useArrowPath(element)`, `useStrokePath(element)` | `platejs/board/react` | The drawn path of an arrow or a pen line. |
|
package/dist/docs/code-block.md
CHANGED
|
@@ -45,6 +45,43 @@ const editor = createEditor({
|
|
|
45
45
|
|
|
46
46
|
</Steps>
|
|
47
47
|
|
|
48
|
+
## Syntax colors
|
|
49
|
+
|
|
50
|
+
The code block components color highlighted tokens through CSS variables, so
|
|
51
|
+
one set of values styles the editor, the CodeMirror view and static output.
|
|
52
|
+
Installing `code-block` or `code-block-static` adds their light and dark values
|
|
53
|
+
to your stylesheet. Change them there:
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
:root {
|
|
57
|
+
--syntax-keyword: #d73a49;
|
|
58
|
+
--syntax-string: #032f62;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.dark {
|
|
62
|
+
--syntax-keyword: #ee6960;
|
|
63
|
+
--syntax-string: #3593ff;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Variable | Tokens |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `--syntax-keyword` | Keywords, types, language names such as `this`, doc tags and template tags |
|
|
70
|
+
| `--syntax-constant` | Numbers, literals, attributes, operators, meta and variables |
|
|
71
|
+
| `--syntax-built-in` | Built-ins and symbols |
|
|
72
|
+
| `--syntax-string` | Strings and regular expressions |
|
|
73
|
+
| `--syntax-title` | Function and class names |
|
|
74
|
+
| `--syntax-tag` | Tag names, selectors and quotes |
|
|
75
|
+
| `--syntax-comment` | Comments and formulas |
|
|
76
|
+
| `--syntax-section` | Section headings |
|
|
77
|
+
| `--syntax-bullet` | List bullets |
|
|
78
|
+
| `--syntax-addition`, `--syntax-addition-background` | Added lines in a diff |
|
|
79
|
+
| `--syntax-deletion`, `--syntax-deletion-background` | Removed lines in a diff |
|
|
80
|
+
|
|
81
|
+
The Word export styles code with its own stylesheet in `docx-export.tsx`, which
|
|
82
|
+
never sees your app's variables, so it holds the light values as fixed colors.
|
|
83
|
+
Change those too when you change the light values.
|
|
84
|
+
|
|
48
85
|
## High-scale code blocks
|
|
49
86
|
|
|
50
87
|
`CodeBlockKit` keeps code in native editor DOM. Use
|
|
@@ -105,6 +142,14 @@ CodeMirror search (`Mod+F`) finds offscreen code. Browser page Find can inspect
|
|
|
105
142
|
only the mounted viewport DOM. The copy button and print layout use the full
|
|
106
143
|
canonical code; printing temporarily renders every line.
|
|
107
144
|
|
|
145
|
+
The component binds CodeMirror's code keys. `Tab` and `Shift+Tab` indent the
|
|
146
|
+
selected lines. `Alt+Up` and `Alt+Down` move the current line, and
|
|
147
|
+
`Shift+Alt+Up` and `Shift+Alt+Down` copy it. `Mod+/` toggles a line comment in
|
|
148
|
+
the block's language. `Shift+Mod+\` moves the caret to the matching bracket,
|
|
149
|
+
and CodeMirror highlights the bracket pair beside the caret. A typed bracket or
|
|
150
|
+
quote inserts its closer, and `Backspace` between an empty pair deletes both.
|
|
151
|
+
The editor's history records each of these edits, so `Mod+Z` undoes it.
|
|
152
|
+
|
|
108
153
|
### Adapter customization
|
|
109
154
|
|
|
110
155
|
`createCodeMirrorAdapter` from `platejs/code-block/codemirror` owns the
|
|
@@ -361,6 +406,8 @@ const editor = createEditor({
|
|
|
361
406
|
|
|
362
407
|
Each `codeBlock` contains one text child. Newline characters define physical lines; editing and highlighting derive their line behavior from text offsets.
|
|
363
408
|
|
|
409
|
+
A code block stores a Markdown fence's language as `language` and the rest of its info string, such as `title="a.ts" {3-5}`, as `meta`. Markdown and HTML keep both. A fence writes `meta` only after a language, so Markdown export reports a `meta` without a `language` as `markdown-property-omitted`.
|
|
410
|
+
|
|
364
411
|
Inside a code block no [input rule](/docs/plugin-input-rules#where-rules-run) runs, so `# `, `**x**`, `->` and URLs stay as typed. Neither Markdown nor an input rule converts pasted plain text.
|
|
365
412
|
|
|
366
413
|
For plain code blocks, omit `CodeHighlightPlugin`:
|