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/docs/discussion.md
CHANGED
|
@@ -98,7 +98,7 @@ Discussion groups unresolved records by block and sorts each block chronological
|
|
|
98
98
|
- document undo reverses an accept or reject decision without changing messages or thread resolution;
|
|
99
99
|
- resolving or reopening a thread stays outside document undo.
|
|
100
100
|
|
|
101
|
-
`useSuggestionGroups(blockKey)` supplies each block's review cards. Under a preview they are the cards of the content the block shows, as [Suggestions](/docs/suggestion) describes. A card's body reads
|
|
101
|
+
`useSuggestionGroups(blockKey)` supplies each block's review cards. Under a preview they are the cards of the content the block shows, as [Suggestions](/docs/suggestion) describes. A card's body reads the changes and parts it shows with `read.groupDetails(card.id, { limit })`, rereads them after each document change, and turns the parts into lines. Discussion derives dates, labels, ranges, and card text in copied registry code, then joins change-targeted threads from Comments.
|
|
102
102
|
|
|
103
103
|
Review cards decide the card they show:
|
|
104
104
|
|
package/dist/docs/docx.md
CHANGED
|
@@ -67,7 +67,7 @@ A pasted Word picture lands as an image when its address is `http`, `https`, `bl
|
|
|
67
67
|
|
|
68
68
|
Word paste leaves out hidden text, rows hidden in a table copied from Excel, comment markers and the comment list. It accepts tracked changes, so inserted text lands as plain text and deleted text is left out. It reads each Word equation into an equation node as DOCX import does, or into TeX text without the equation plugins, and leaves out an equation it cannot read. Each paste reports hidden text, comments, tracked changes and unread equations once each as a `lossy` diagnostic, which [`onPasteResult`](/docs/clipboard#paste-results) receives. When nothing else remains, the paste inserts nothing, and `onPasteResult` receives `inserted: false` with those reports. When Word left something out and the cleaned HTML has more elements or deeper nesting than the HTML parser allows, the paste also inserts nothing and reports that the content is too large or too deeply nested. A Word or Excel payload over 5 MiB, the HTML byte limit, skips Word paste and pastes as plain text.
|
|
69
69
|
|
|
70
|
-
With an upload client configured, as [Pasted pictures](/docs/upload#pasted-pictures) shows, each Word picture that lands as a `data` address uploads like a dropped file. A picture with an `http
|
|
70
|
+
With an upload client configured, as [Pasted pictures](/docs/upload#pasted-pictures) shows, each Word picture that lands as a `data` address uploads like a dropped file, and so does one with a `blob` address once the paste reads its bytes. A picture with an `http` or `https` address keeps that address. Clipboard paste does not preserve Word table geometry. Configure that destination policy in the table feature.
|
|
71
71
|
|
|
72
72
|
## Import a DOCX file
|
|
73
73
|
|
|
@@ -48,6 +48,11 @@ chrome.
|
|
|
48
48
|
Use that callback to open the accordion, activate the tab, or reveal the
|
|
49
49
|
collapsed panel.
|
|
50
50
|
|
|
51
|
+
A block drag that rests for 800 ms on a block whose children sit behind an
|
|
52
|
+
`app-collapse` boundary also calls `onMaterialize`, with `reason: 'drag'`,
|
|
53
|
+
so the drop can land inside once the content mounts. A quick pass leaves the
|
|
54
|
+
content closed. Ignore that reason to keep the content closed during a drag.
|
|
55
|
+
|
|
51
56
|
## Copy policy
|
|
52
57
|
|
|
53
58
|
`copyPolicy` controls clipboard output when a copied selection crosses hidden
|
|
@@ -42,9 +42,8 @@ Render `{children}` after the non-editable UI. Plate still needs the hidden void
|
|
|
42
42
|
child mounted even when your visible element is fully custom React.
|
|
43
43
|
|
|
44
44
|
The nested editor is a separate Plate editor. It does not share the outer
|
|
45
|
-
editor's value, selection, plugins, or undo history.
|
|
46
|
-
|
|
47
|
-
outer editor's history, as
|
|
45
|
+
editor's value, selection, plugins, or undo history. Undo and Redo shortcuts
|
|
46
|
+
pressed inside it run its own history and leave the outer document unchanged, as
|
|
48
47
|
[Embedded widgets](/docs/plugin-components#embedded-widgets) describes.
|
|
49
48
|
|
|
50
49
|
Native controls and a nested editor need no extra marker. A widget built from
|
|
@@ -100,6 +100,8 @@ invalid, and read-only edits without changing the document.
|
|
|
100
100
|
| `yieldKey(event)` | Offer a keydown the view declined to the editor's `onKeyDown`, which runs Plate's shortcuts and plugin key handlers. Call it from the view's own keydown listener, after every local handler passed on the key. Plate drops the key when something prevents its default or stops its propagation before the editor root. It refuses keys a text input uses natively: composing and modifier keys, typing, Enter without Ctrl or Meta, Tab, navigation and deletion keys, select-all, clipboard, undo and redo, and on Apple hosts Control with a letter, the quote key or Enter. It also refuses every key while the editor or the element is read-only, during an authored preview, or while any part of the selection is outside this Text. |
|
|
101
101
|
|
|
102
102
|
Versioned actions return `{ status: "applied" | "stale" | "read-only" }`.
|
|
103
|
+
`dispatch` returns `stale` when the editor refuses the edit, such as one
|
|
104
|
+
Suggesting cannot record, and resets the view to `state.text` before it returns.
|
|
103
105
|
An action may synchronously call `update` before returning, including a reset
|
|
104
106
|
for rejected input. Adapters disable independent undo stacks and never dispatch
|
|
105
107
|
actions, mutate the owning editor, or reenter their mounted view from `mount`,
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
# Field
|
|
2
|
+
|
|
3
|
+
Inline void fields that one role fills, each with a kind, settings, an optional condition on another field and an id unique in the document.
|
|
4
|
+
|
|
5
|
+
A field is a typed blank in a document that one role fills, such as a tenant's name, a start date, a checkbox or a signature. Each field is an inline void `field` element with a `kind`, a `role`, a `label` and a `fieldId` that no other field in the document holds. A field's `condition` names another field by that id. Plate checks roles, never users. Your app decides which person fills which role.
|
|
6
|
+
|
|
7
|
+
_Example `field-demo` in the Plate repository: `apps/www/src/registry/examples/field-demo.tsx`, `apps/www/src/registry/examples/values/field-value.tsx`, `apps/www/src/registry/examples/values/cn/field-value.tsx`._
|
|
8
|
+
|
|
9
|
+
The demo is a lease template for a landlord and a tenant. Insert a field from the toolbar's menu, click a field to change its settings, and read the HTML, Markdown and Word panels under the editor. Pick Fill as landlord or Fill as tenant above the editor to fill the lease as that role.
|
|
10
|
+
|
|
11
|
+
<PackageInfo>
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Inline void `field` element of six kinds: text, number, date, checkbox, choice and signature.
|
|
16
|
+
- A role per field, a label, and an optional required flag, default, choice options and value, each checked against the field's kind.
|
|
17
|
+
- A condition that names another field by its `fieldId` and tests that field's value.
|
|
18
|
+
- `insert` and `update` commands that refuse a setting or condition that does not fit, and reads that report what is wrong with each field.
|
|
19
|
+
- A fill-only view of one role, which takes that role's answers, refuses every other local change and undoes only that role's answers.
|
|
20
|
+
- New ids for the fields a paste, a drag copy, a duplicate or a table fill copies, with copied conditions that name the copies.
|
|
21
|
+
- HTML and Markdown that keep every property, and Word export that keeps each answer and reports the settings it drops.
|
|
22
|
+
- A field chip with a settings popover, an insert menu and a static renderer in the registry UI.
|
|
23
|
+
|
|
24
|
+
</PackageInfo>
|
|
25
|
+
|
|
26
|
+
## Kit usage
|
|
27
|
+
|
|
28
|
+
<Steps>
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
The fastest way to add fields is `FieldKit`, which installs `FieldPlugin` with the registry `FieldElement`. Installing `field` also installs `field-toolbar-button`.
|
|
33
|
+
|
|
34
|
+
_Registry item `field`: `npx shadcn@latest add @plate/field`._
|
|
35
|
+
|
|
36
|
+
- [`FieldElement`](/docs/components/field): renders the field chip and its settings popover.
|
|
37
|
+
|
|
38
|
+
### Add kit
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { useCreateEditor } from 'platejs/react';
|
|
42
|
+
|
|
43
|
+
import { FieldKit } from '@/components/editor/field';
|
|
44
|
+
|
|
45
|
+
const editor = useCreateEditor({
|
|
46
|
+
plugins: [
|
|
47
|
+
// ...otherPlugins,
|
|
48
|
+
...FieldKit,
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Add the insert menu
|
|
54
|
+
|
|
55
|
+
`FieldToolbarButton` inserts a field of each kind. A new field takes the role of the document's first field, or `signer` in a document with no field. The main insert and slash menus have no Field item, so add this menu to a toolbar.
|
|
56
|
+
|
|
57
|
+
_Registry item `field-toolbar-button`: `npx shadcn@latest add @plate/field-toolbar-button`._
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { FieldToolbarButton } from '@/components/editor/field-toolbar-button';
|
|
61
|
+
import { Toolbar } from '@/components/editor/toolbar';
|
|
62
|
+
|
|
63
|
+
export function FieldToolbar() {
|
|
64
|
+
return (
|
|
65
|
+
<Toolbar>
|
|
66
|
+
<FieldToolbarButton />
|
|
67
|
+
</Toolbar>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Add static rendering
|
|
73
|
+
|
|
74
|
+
`BaseFieldKit` renders each field's answer, a choice as its option's label, or the field's label when it has no answer, for read-only output with `platejs/static`.
|
|
75
|
+
|
|
76
|
+
_Registry item `field-static`: `npx shadcn@latest add @plate/field-static`._
|
|
77
|
+
|
|
78
|
+
</Steps>
|
|
79
|
+
|
|
80
|
+
## Manual usage
|
|
81
|
+
|
|
82
|
+
<Steps>
|
|
83
|
+
|
|
84
|
+
### Installation
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm install platejs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Add the plugin
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { FieldPlugin } from 'platejs/field/react';
|
|
94
|
+
import { useCreateEditor } from 'platejs/react';
|
|
95
|
+
|
|
96
|
+
import { FieldElement } from '@/components/editor/field';
|
|
97
|
+
|
|
98
|
+
const editor = useCreateEditor({
|
|
99
|
+
plugins: [FieldPlugin.configure({ component: FieldElement })],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`BaseFieldPlugin` from `platejs/field` runs without React, such as on a server that reads a submitted document:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { createEditor, type Value } from 'platejs';
|
|
107
|
+
import { BaseFieldPlugin } from 'platejs/field';
|
|
108
|
+
|
|
109
|
+
export const readFields = (value: Value) =>
|
|
110
|
+
createEditor({ initialValue: value, plugins: [BaseFieldPlugin] })
|
|
111
|
+
.plugin(BaseFieldPlugin)
|
|
112
|
+
.read.fields();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
</Steps>
|
|
116
|
+
|
|
117
|
+
## Value shape
|
|
118
|
+
|
|
119
|
+
A field sits inside a paragraph, like a date or a mention.
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"type": "paragraph",
|
|
124
|
+
"children": [
|
|
125
|
+
{ "text": "Tenant name: " },
|
|
126
|
+
{
|
|
127
|
+
"type": "field",
|
|
128
|
+
"fieldId": "f_k2x9",
|
|
129
|
+
"kind": "text",
|
|
130
|
+
"role": "tenant",
|
|
131
|
+
"label": "Tenant name",
|
|
132
|
+
"required": true,
|
|
133
|
+
"children": [{ "text": "" }]
|
|
134
|
+
},
|
|
135
|
+
{ "text": "" }
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
| Property | Type | Notes |
|
|
141
|
+
|----------|------|-------|
|
|
142
|
+
| `type` | `'field'` | Inline void element owned by `BaseFieldPlugin`. |
|
|
143
|
+
| `fieldId` | `string` | Unique in the document. A new field gets a random `nanoid`. |
|
|
144
|
+
| `kind` | `FieldKind` | `'text'`, `'number'`, `'date'`, `'checkbox'`, `'choice'` or `'signature'`. Required. |
|
|
145
|
+
| `role` | `string` | The role that fills the field, such as `'tenant'`. Required. |
|
|
146
|
+
| `label` | `string` | Required. The chip shows it, and output shows it when the field has no answer. |
|
|
147
|
+
| `required` | `boolean` | Marks a field that must be filled. Plate stores it, and your app checks it when it collects answers. |
|
|
148
|
+
| `defaultValue` | `FieldValue` | A value of the field's kind. |
|
|
149
|
+
| `options` | `FieldOption[]` | Choice fields only. Each option is `{ value, label }`, and no two share a `value`. |
|
|
150
|
+
| `value` | `FieldValue` | The answer. A field without one is unfilled. |
|
|
151
|
+
| `condition` | `FieldCondition` | `{ ref, test, value? }`, see [Conditions](#conditions). |
|
|
152
|
+
| `children` | `[{ text: '' }]` | Required child of an inline void element. |
|
|
153
|
+
|
|
154
|
+
## Kinds
|
|
155
|
+
|
|
156
|
+
Each kind fixes the shape of its value and the tests a condition on it may use. `fitsField(field, value)` from `platejs/field` says whether a value fits a field's kind, and `FIELD_TESTS` lists each kind's tests.
|
|
157
|
+
|
|
158
|
+
| Kind | Value | Tests |
|
|
159
|
+
|------|-------|-------|
|
|
160
|
+
| `text` | a string | `filled`, `blank`, `equals`, `not-equals` |
|
|
161
|
+
| `number` | a finite number | `filled`, `blank`, `equals`, `not-equals`, `above`, `below` |
|
|
162
|
+
| `date` | an ISO date, `YYYY-MM-DD` | `filled`, `blank`, `equals`, `not-equals`, `above`, `below` |
|
|
163
|
+
| `checkbox` | `true` or `false` | `equals`, `not-equals` |
|
|
164
|
+
| `choice` | one option's `value` | `filled`, `blank`, `equals`, `not-equals` |
|
|
165
|
+
| `signature` | a string your app owns, such as a stored image's id | `filled`, `blank` |
|
|
166
|
+
|
|
167
|
+
A choice stores the option's `value`, so renaming an option's `label` keeps every answer and condition that names it.
|
|
168
|
+
|
|
169
|
+
## Roles
|
|
170
|
+
|
|
171
|
+
Each field names the role that fills it, such as `landlord` or `tenant`. A role is any string. Plate stores it and never checks who a user is. Your app maps each person to a role, as it maps each comment to its author.
|
|
172
|
+
|
|
173
|
+
A [fill-only view](#fill-as-one-role) stops one role from changing another role's field, or the text around it, in that editor. An app that collects answers from several people still checks each submitted value on its server.
|
|
174
|
+
|
|
175
|
+
The settings popover offers the roles the document's fields already use, and takes a new one.
|
|
176
|
+
|
|
177
|
+
## Insert and update
|
|
178
|
+
|
|
179
|
+
`insert` takes a field's settings and returns its new `fieldId`. Its second argument takes node insert options, such as `at` and `select`.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { BaseFieldPlugin } from 'platejs/field';
|
|
183
|
+
|
|
184
|
+
editor.update((tx) => {
|
|
185
|
+
const fieldId = tx.plugin(BaseFieldPlugin).insert(
|
|
186
|
+
{ kind: 'text', label: 'Full name', required: true, role: 'tenant' },
|
|
187
|
+
{ select: true }
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`insert` throws when a value, default or options do not fit the kind, when the settings name a `fieldId`, or when the condition names no field, or a test or value that the named field's kind does not take.
|
|
193
|
+
|
|
194
|
+
`update` changes the settings or value of the field that holds a `fieldId`. A setting given as `undefined` is removed.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
editor.update((tx) => {
|
|
198
|
+
tx.plugin(BaseFieldPlugin).update(fieldId, { value: 'Ada Lovelace' });
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`update` throws, and changes nothing, when:
|
|
203
|
+
|
|
204
|
+
- no field holds `fieldId`;
|
|
205
|
+
- a setting the patch names does not fit the field's kind;
|
|
206
|
+
- the patch removes `kind`, `role` or `label`, or names `fieldId`;
|
|
207
|
+
- the condition names no field, a test or value that the named field's kind does not take, or a field it did not name before whose chain of conditions leads back to this one.
|
|
208
|
+
|
|
209
|
+
A patch that changes `kind` or `options` also drops each value, default and options that the field no longer fits. Turning a number field with a default into a date field drops the default. The field keeps its `fieldId`.
|
|
210
|
+
|
|
211
|
+
## Conditions
|
|
212
|
+
|
|
213
|
+
A condition says when a field applies. It applies when the field whose `fieldId` is `ref` passes `test`. Every test but `filled` and `blank` compares against `value`, which takes the shape of the named field's value. The demo's Pet name field applies when the Pets choice is `yes`:
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
editor.update((tx) => {
|
|
217
|
+
tx.plugin(BaseFieldPlugin).update(petNameId, {
|
|
218
|
+
condition: { ref: petsId, test: 'equals', value: 'yes' },
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The popover's Show when list offers the field the condition names and every other field whose conditions do not lead back to this one. Its test list offers only the tests that field's kind takes. Plate stores the condition and checks that it fits the field it names. It does not hide a field or skip it, so your app decides what a condition that fails means.
|
|
224
|
+
|
|
225
|
+
`update` refuses a condition that would close a loop, such as A naming B while B names A, or a field naming itself. A new test or value on a field of a loop passes. A loop can still come from a loaded document, a plain node write or two peers' updates made at the same time, and each of its fields then reports `condition-loop`.
|
|
226
|
+
|
|
227
|
+
## Read fields and their problems
|
|
228
|
+
|
|
229
|
+
`read.field(fieldId)` returns the field that holds an id, in any root, or `null`. It looks up that field, then one field for each condition it follows along the chain. `read.fields()` returns every field of the document in reading order. Each read is a `FieldRead`: `{ fieldId, node, problems }`.
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { BaseFieldPlugin } from 'platejs/field';
|
|
233
|
+
|
|
234
|
+
const fields = editor.plugin(BaseFieldPlugin).read;
|
|
235
|
+
|
|
236
|
+
const tenant = fields.field(tenantId);
|
|
237
|
+
const broken = fields.fields().filter((field) => field.problems.length > 0);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
| Problem | When |
|
|
241
|
+
|---------|------|
|
|
242
|
+
| `missing-target` | No field holds the id its condition names, such as after that field is deleted. |
|
|
243
|
+
| `unsupported-test` | The kind of the field its condition names does not take the condition's test. |
|
|
244
|
+
| `invalid-value` | Its value, default or options do not fit its kind, or its condition's value does not fit the test or the named field's kind. |
|
|
245
|
+
| `condition-loop` | Its condition names a field whose chain of conditions leads back to it, such as A naming B while B names A. |
|
|
246
|
+
|
|
247
|
+
`insert` and `update` refuse a write that would cause a problem. A problem comes from a later edit, such as deleting or changing the field a condition names, or from a write that skipped the commands, such as a plain `tx.nodes.set` or a loaded document.
|
|
248
|
+
|
|
249
|
+
In React, `useFieldRead(fieldId)` from `platejs/field/react` reads one field and its problems. A commit that changes an element reads it again, and the component renders again only when the field or its problems changed. The registry chip uses it to show a warning when the field its condition names is deleted, and an undo clears the warning.
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import { useFieldRead } from 'platejs/field/react';
|
|
253
|
+
|
|
254
|
+
const field = useFieldRead(element.fieldId);
|
|
255
|
+
const problems = field?.problems ?? [];
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Fill as one role
|
|
259
|
+
|
|
260
|
+
Set `fillRole` to open a fill-only view of one role. The editor then takes answers for that role's fields and refuses every other local change, so a tenant fills the tenant's fields and changes nothing else.
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
import { FieldPlugin } from 'platejs/field/react';
|
|
264
|
+
import { useCreateEditor } from 'platejs/react';
|
|
265
|
+
|
|
266
|
+
import { FieldElement } from '@/components/editor/field';
|
|
267
|
+
|
|
268
|
+
const editor = useCreateEditor({
|
|
269
|
+
initialValue: template,
|
|
270
|
+
plugins: [
|
|
271
|
+
// ...otherPlugins,
|
|
272
|
+
FieldPlugin.configure({
|
|
273
|
+
component: FieldElement,
|
|
274
|
+
initialState: { fillRole: 'tenant' },
|
|
275
|
+
}),
|
|
276
|
+
],
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The demo switches one editor between authoring and each role through the plugin store, and `null` returns to authoring:
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
editor.plugin(FieldPlugin).store.set({ fillRole: 'landlord' });
|
|
284
|
+
editor.plugin(FieldPlugin).store.set({ fillRole: null });
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
`usePluginStore(FieldPlugin, 'fillRole')` from `platejs/react` reads the role in a component. The role is editor state, so every view of one editor fills as the same role. Switch it between updates. A switch writes nothing to the document and leaves undo and redo as they are.
|
|
288
|
+
|
|
289
|
+
While a role is set:
|
|
290
|
+
|
|
291
|
+
- The registry chip of the role's field opens a popover with an input for the answer and a Clear button, and the role's checkbox ticks and unticks on click. A chip whose answer holds a pending suggestion says it waits for review and opens nothing. Another role's chip opens nothing, no chip drags, and the insert menu is disabled.
|
|
292
|
+
- The editor refuses a local commit that writes anything besides a fitting or cleared answer on the role's fields. Typing, paste, cut, a drop, Enter and AI writes change nothing. A refused update throws nothing to its caller and changes nothing.
|
|
293
|
+
- Selection, state fields without `persist` and effects that neither persist nor sync to peers pass, so a person can still select and copy.
|
|
294
|
+
- Undo and redo take back only the role's own answers. Undo stops at the first step that changed anything else, such as the author's edit, and returns `{ reason, status: 'blocked' }`. The first answer after a switch is its own undo step, so an answer typed right after a switch takes two undos.
|
|
295
|
+
- A document replacement, such as `tx.value.replace` or loading another template, is refused, and so is a plugin reconfiguration. Load the template and configure plugins before you set the role, or clear the role first.
|
|
296
|
+
- A comment lands, because creating its thread is a local effect. Your app decides whether people may comment in a fill view. The comment adds an undo step, and undo stops at that step, so the answers before the comment can no longer be undone.
|
|
297
|
+
|
|
298
|
+
A peer's change passes whole. Every commit tagged `collaboration` passes, so collaborators keep one document. Apply a peer's Yjs update from your provider's events, never from inside an editor update. A local write made inside a peer's change takes its `collaboration` tag, passes and never reaches peers. For the same reason, a Yjs `UndoManager` that your app drives itself, or a local update that your app tags `collaboration`, passes the fill check.
|
|
299
|
+
|
|
300
|
+
The fill check runs in the field plugin's `activate`, and the undo step boundary in its `corrections`. A plugin that extends the field plugin with its own `activate` or `corrections` replaces them, so put that work in a companion plugin.
|
|
301
|
+
|
|
302
|
+
The fill check runs in the person's browser, where anyone can run their own code. Your server assigns each person's role and checks each submitted answer.
|
|
303
|
+
|
|
304
|
+
## Copy and paste
|
|
305
|
+
|
|
306
|
+
A field keeps its `fieldId` through a move, a drag move included, through an undo that brings it back and when a saved document loads. A copy gets new ids:
|
|
307
|
+
|
|
308
|
+
- A paste, a drag copy, `tx.blocks.duplicate` and a table fill give each field they copy a new id. A copied condition that names a field in the same copy names that field's copy.
|
|
309
|
+
- A copied condition whose field was not copied, or did not land, keeps naming the original.
|
|
310
|
+
- A paste into a table cell selection copies once per cell, so a condition in each cell names the copy in its own cell.
|
|
311
|
+
- A paste into another document gets new ids too.
|
|
312
|
+
- Cut and paste gives the field a new id, so a condition elsewhere that named it reports `missing-target` until an undo.
|
|
313
|
+
- An app that copies a field with `tx.schema.copy` and inserts the result gets a new id, and the copy's condition keeps naming the original.
|
|
314
|
+
|
|
315
|
+
In Suggesting mode, a change from a field to a mention shows the field as deleted beside the inserted mention, so rejecting it keeps the field and its `fieldId`.
|
|
316
|
+
|
|
317
|
+
## HTML
|
|
318
|
+
|
|
319
|
+
`editor.api.html.serialize()` writes each field as a `span` with one `data-field-*` attribute per property. The span's text is the answer, a choice as its option's label, or the label in brackets when the field has no answer. The id, kind, label and role attributes hold plain text, and the others hold JSON:
|
|
320
|
+
|
|
321
|
+
```html
|
|
322
|
+
<p>Pets? <span data-field-id="pets" data-field-kind="choice" data-field-label="Pets" data-field-options="[{"label":"Yes","value":"yes"},{"label":"No","value":"no"}]" data-field-role="tenant" data-field-value=""yes"">Yes</span> Pet name: <span data-field-condition="{"ref":"pets","test":"equals","value":"yes"}" data-field-id="pet-name" data-field-kind="text" data-field-label="Pet name" data-field-role="tenant">[Pet name]</span></p>
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Parsing that HTML reads every property back. A span needs `data-field-kind`, `data-field-label` and `data-field-role` to read as a field. A pasted HTML template gets new ids, and its conditions name the copies.
|
|
326
|
+
|
|
327
|
+
The demo's HTML panel serializes with `lossPolicy: 'allow'`, because the date element has no HTML encoder. The panel lists one `html-unsupported-content` line for the date it drops.
|
|
328
|
+
|
|
329
|
+
## Markdown
|
|
330
|
+
|
|
331
|
+
Markdown writes each field as a `<field>` tag with every property, the `fieldId` and the condition included:
|
|
332
|
+
|
|
333
|
+
```md
|
|
334
|
+
Pets? <field kind="choice" label="Pets" options="[{"label":"Yes","value":"yes"},{"label":"No","value":"no"}]" role="tenant" value="yes" fieldId="pets" /> Pet name: <field kind="text" label="Pet name" role="tenant" condition="{"ref":"pets","test":"equals","value":"yes"}" fieldId="pet-name" />
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
The reader needs `kind`, `label` and `role`. A tag without them stays as text, with a `markdown-unsupported-node` diagnostic. A pasted Markdown template gets new ids, and its conditions name the copies.
|
|
338
|
+
|
|
339
|
+
## Word
|
|
340
|
+
|
|
341
|
+
Word has no field element. Word export writes each field's answer as text, a choice as its option's label, or the label in brackets when the field has no answer. It needs no static field component, so a headless export keeps the answers.
|
|
342
|
+
|
|
343
|
+
```tsx
|
|
344
|
+
import { exportDocx } from 'platejs/docx/export';
|
|
345
|
+
|
|
346
|
+
const result = await exportDocx(editor);
|
|
347
|
+
const dropped = result.diagnostics.filter(
|
|
348
|
+
(diagnostic) => diagnostic.code === 'property-dropped'
|
|
349
|
+
);
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The export drops each field's id, kind, role, settings and condition. It reports them with one `property-dropped` warning whose message is "Word keeps each field answer and drops its settings.", whose `feature` is `field` and whose `count` is the number of fields. The warning never refuses an export, under `lossPolicy: 'allow'` or `'reject'`. The demo's Word panel shows that warning, and its count goes up as you insert fields.
|
|
353
|
+
|
|
354
|
+
Plain text, through `serializePlainText` from `platejs`, writes the same text as Word.
|
|
355
|
+
|
|
356
|
+
## API Reference
|
|
357
|
+
|
|
358
|
+
| API | Package | Use |
|
|
359
|
+
|-----|---------|-----|
|
|
360
|
+
| `BaseFieldPlugin` | `platejs/field` | Headless inline void field plugin. |
|
|
361
|
+
| `FieldPlugin` | `platejs/field/react` | React field plugin. |
|
|
362
|
+
| `tx.plugin(BaseFieldPlugin).insert(settings, options?)` | `BaseFieldPlugin` update | Inserts a field and returns its `fieldId`. |
|
|
363
|
+
| `tx.plugin(BaseFieldPlugin).update(fieldId, patch)` | `BaseFieldPlugin` update | Changes a field's settings or value. |
|
|
364
|
+
| `editor.plugin(BaseFieldPlugin).read.field(fieldId)` | `BaseFieldPlugin` read | The field that holds an id, with its problems, or `null`. |
|
|
365
|
+
| `editor.plugin(BaseFieldPlugin).read.fields()` | `BaseFieldPlugin` read | Every field in reading order, with its problems. |
|
|
366
|
+
| `fillRole` | `BaseFieldPlugin` state | The role this editor fills as, or `null` while authoring. Set it through `initialState` or `editor.plugin(FieldPlugin).store.set`. |
|
|
367
|
+
| `useFieldRead(fieldId)` | `platejs/field/react` | Reads one field and its problems, and renders again when either changes. |
|
|
368
|
+
| `fitsField(field, value)` | `platejs/field` | Whether a value fits a field's kind and options. |
|
|
369
|
+
| `FIELD_TESTS` | `platejs/field` | The tests a condition may use on each kind. |
|
|
370
|
+
| `FieldElement`, `FieldSettings`, `FieldPatch`, `FieldRead`, `FieldCondition`, `FieldProblem`, `FieldKind`, `FieldTest`, `FieldValue`, `FieldOption` | `platejs/field` | Field types. |
|
package/dist/docs/find.md
CHANGED
|
@@ -8,7 +8,8 @@ _Example `find-demo` in the Plate repository: `apps/www/src/registry/examples/fi
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- Opens with `Mod+F
|
|
11
|
+
- Opens from its Find button or with `Mod+F`, and seeds the query from an
|
|
12
|
+
expanded editor selection.
|
|
12
13
|
- Highlights every match without writing marks into the document or history.
|
|
13
14
|
- Finds a match that runs across text leaves and inline elements within one
|
|
14
15
|
block. Find searches text placed directly beside a block on its own.
|
|
@@ -45,9 +46,10 @@ const editor = createEditor({
|
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
`BaseFindPlugin` owns the current query, matches, navigation and transient
|
|
48
|
-
decoration data. `FindKit` supplies the shortcut, deferred
|
|
49
|
-
search bar.
|
|
50
|
-
|
|
49
|
+
decoration data. `FindKit` supplies the Find button, the shortcut, deferred
|
|
50
|
+
input and accessible search bar. The button sits where the bar opens and lets
|
|
51
|
+
a touch screen without `Mod+F` open Find. The open bar takes the button's place.
|
|
52
|
+
Its configured `decorate.attributes` supplies ordinary and active match styling. Each mounted Editable owns its open bar, draft, focus and scroll
|
|
51
53
|
requests. Views of the same editor share committed queries and results; opening
|
|
52
54
|
one bar does not open another. Open bars follow the committed query when they
|
|
53
55
|
have no pending draft. Only the focused bar scrolls its view. Detaching a view
|
|
@@ -112,8 +114,9 @@ Custom renderers can style `data-find-match` and `data-find-active` attributes.
|
|
|
112
114
|
|
|
113
115
|
## Custom controls
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
`FindKit` already shows a Find button in each Editable. For another opening
|
|
118
|
+
control, use `useFind` in a component rendered by that Editable's
|
|
119
|
+
`beforeEditable` or `afterEditable` slot. `FindKit` supplies the context through `wrapRoot`, so a
|
|
117
120
|
custom control addresses one mounted view without subscribing to search results:
|
|
118
121
|
|
|
119
122
|
```tsx
|
package/dist/docs/form.md
CHANGED
|
@@ -247,6 +247,8 @@ function MyForm() {
|
|
|
247
247
|
|
|
248
248
|
## Migrating from a shadcn textarea to Plate
|
|
249
249
|
|
|
250
|
+
For a chat message field, use [Prompt Editor](/docs/prompt-editor) instead. It takes and reports a string, sends on Enter and holds @ chips.
|
|
251
|
+
|
|
250
252
|
If you have a standard [Field example from shadcn/ui docs](https://ui.shadcn.com/docs/components/field) and want to replace `<Textarea>` with a Plate editor, follow these steps:
|
|
251
253
|
|
|
252
254
|
```tsx
|
package/dist/docs/heading.md
CHANGED
|
@@ -83,6 +83,12 @@ editor.plugin(HeadingPlugin).update.toggle({ level: 2 });
|
|
|
83
83
|
|
|
84
84
|
Calling toggle with the active level resets the selected heading to the root default block. Calling it with another level changes the level on the same heading type.
|
|
85
85
|
|
|
86
|
+
~~~ts
|
|
87
|
+
editor.plugin(HeadingPlugin).read.canSetLevel(2);
|
|
88
|
+
~~~
|
|
89
|
+
|
|
90
|
+
`canSetLevel` answers whether every selected block can take that level where it sits, under the rule `setLevel` enforces. A menu can disable a level the caret's parent cannot hold, as the copied Turn into menu does.
|
|
91
|
+
|
|
86
92
|
## API Reference
|
|
87
93
|
|
|
88
94
|
| API | Purpose |
|
|
@@ -152,8 +152,6 @@ import {
|
|
|
152
152
|
BlockquotePlugin,
|
|
153
153
|
BoldPlugin,
|
|
154
154
|
HeadingPlugin,
|
|
155
|
-
|
|
156
|
-
|
|
157
155
|
ItalicPlugin,
|
|
158
156
|
UnderlinePlugin,
|
|
159
157
|
} from 'platejs/react';
|
|
@@ -252,8 +250,6 @@ import {
|
|
|
252
250
|
BlockquotePlugin,
|
|
253
251
|
BoldPlugin,
|
|
254
252
|
HeadingPlugin,
|
|
255
|
-
|
|
256
|
-
|
|
257
253
|
ItalicPlugin,
|
|
258
254
|
UnderlinePlugin,
|
|
259
255
|
} from 'platejs/react';
|
package/dist/docs/link.md
CHANGED
|
@@ -86,14 +86,14 @@ const editor = createEditor({
|
|
|
86
86
|
LinkPlugin.configure({
|
|
87
87
|
component: LinkElement,
|
|
88
88
|
slots: {
|
|
89
|
-
|
|
89
|
+
caret: LinkFloatingToolbar,
|
|
90
90
|
},
|
|
91
91
|
}),
|
|
92
92
|
],
|
|
93
93
|
});
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
- `slots.
|
|
96
|
+
- `slots.caret`: Renders [`LinkFloatingToolbar`](/docs/components/link) after the editable area for link editing, on the view that holds the caret, such as a board note.
|
|
97
97
|
- `.configure({ component: LinkElement })`: Renders link elements with
|
|
98
98
|
[`LinkElement`](/docs/components/link).
|
|
99
99
|
|
|
@@ -161,7 +161,7 @@ LinkPlugin.configure({
|
|
|
161
161
|
|
|
162
162
|
Options:
|
|
163
163
|
|
|
164
|
-
- `allowedSchemes?: string[]`
|
|
164
|
+
- `allowedSchemes?: string[]` lists the URL schemes the link feature accepts when it
|
|
165
165
|
inserts, types, pastes or imports a link, and that a rendered link may use.
|
|
166
166
|
Relative URLs are always allowed. Add a scheme such as `vscode` for app deep links. Script-capable
|
|
167
167
|
destinations, such as `javascript:`, `vbscript:`, and `data:`, are never
|
package/dist/docs/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Plate docs for platejs@54.0.0-beta.
|
|
1
|
+
# Plate docs for platejs@54.0.0-beta.3
|
|
2
2
|
|
|
3
3
|
These pages match the installed `platejs` version. A `/docs/<path>` link in a page is the file `<path>.md` in this folder when the list below names it, and `/docs` is `index.md`. Read the pages your task needs before you write editor code.
|
|
4
4
|
|
|
@@ -73,6 +73,7 @@ These pages match the installed `platejs` version. A `/docs/<path>` link in a pa
|
|
|
73
73
|
- [Exit Break](exit-break.md)
|
|
74
74
|
- [External Text Views](external-text.md): Render one canonical Plate Text through an adapter-owned editing surface.
|
|
75
75
|
- [Feature Kits](feature-kits.md): Use registry kits to add groups of Plate plugins and UI wiring.
|
|
76
|
+
- [Field](field.md): Inline void fields that one role fills, each with a kind, settings, an optional condition on another field and an id unique in the document.
|
|
76
77
|
- [Find](find.md): Search editable text with transient highlights and keyboard navigation.
|
|
77
78
|
- [Font](font.md): Provide extended formatting options for document content.
|
|
78
79
|
- [Footnote](footnote.md)
|
|
@@ -116,9 +117,10 @@ These pages match the installed `platejs` version. A `/docs/<path>` link in a pa
|
|
|
116
117
|
- [Plugin Rules](plugin-rules.md): Configure common editing behaviors.
|
|
117
118
|
- [Plugin Shortcuts](plugin-shortcuts.md): Configure keyboard shortcuts on Plate plugins.
|
|
118
119
|
- [Plugin Configuration](plugin.md): How to configure and customize Plate plugins.
|
|
120
|
+
- [Prompt Editor](prompt-editor.md): A chat message field that holds @ chips and sends on Enter.
|
|
119
121
|
- [Releases](releases.md)
|
|
120
122
|
- [Roots](roots.md): Use extra roots for headers, footers, synced blocks, captions, and other editable regions.
|
|
121
|
-
- [Right-to-left](rtl.md): Edit
|
|
123
|
+
- [Right-to-left](rtl.md): Edit Arabic, Hebrew and other right-to-left documents.
|
|
122
124
|
- [Schema](schema.md): Declare Plate document structure, validate saved values, and fit imported content.
|
|
123
125
|
- [Selection](selection.md): Read, update, focus, and render text and node selections in Plate.
|
|
124
126
|
- [Serializing](serializing.md): Save complete Plate documents and convert them to text, HTML, Markdown, or DOCX.
|