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/toolbar.md
CHANGED
|
@@ -74,7 +74,7 @@ const fixedToolbarPlugin = definePlugin('fixedToolbar', {
|
|
|
74
74
|
|
|
75
75
|
const floatingToolbarPlugin = definePlugin('floatingToolbar', {
|
|
76
76
|
slots: {
|
|
77
|
-
|
|
77
|
+
caret: () => <FloatingToolbar />,
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -88,7 +88,7 @@ const editor = createEditor({
|
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
- `slots.beforeContainer`: Renders [`FixedToolbar`](/docs/components/fixed-toolbar) before the editor scroll container
|
|
91
|
-
- `slots.
|
|
91
|
+
- `slots.caret`: Renders [`FloatingToolbar`](/docs/components/floating-toolbar) as an overlay after the editor, on the view that holds the caret
|
|
92
92
|
|
|
93
93
|
Place the editor container in an `EditorFrame`. The fixed toolbar and scroll
|
|
94
94
|
container then occupy separate rows inside the same bounded layout.
|
|
@@ -121,39 +121,35 @@ Similarly, you can customize the floating toolbar by editing `components/editor/
|
|
|
121
121
|
|
|
122
122
|
_Registry item `floating-toolbar`: `npx shadcn@latest add @plate/floating-toolbar`._
|
|
123
123
|
|
|
124
|
-
### Act
|
|
124
|
+
### Act where the caret is
|
|
125
125
|
|
|
126
126
|
A nested view, such as the text of a [board](/docs/board) note, is an Editable
|
|
127
|
-
of its own inside the page's Editable.
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
of its own inside the page's Editable. Where a toolbar renders decides the view
|
|
128
|
+
it acts on:
|
|
129
|
+
|
|
130
|
+
- Outside every editing area, such as in `beforeContainer` where the fixed
|
|
131
|
+
toolbar renders, `useEditor()` returns the editor of the root that holds the
|
|
132
|
+
caret. With the caret in a note, the copied fixed toolbar's mark buttons
|
|
133
|
+
change the note.
|
|
134
|
+
- A plugin's `caret` slot renders after the Editable and follows the caret into
|
|
135
|
+
the views mounted inside its editing area. The copied floating toolbar, link
|
|
136
|
+
toolbar and AI menu render there, so they open beside selected note text.
|
|
137
|
+
- Inside an editing area, every other slot, such as `afterEditable`, keeps that
|
|
138
|
+
area's view.
|
|
130
139
|
|
|
131
140
|
```tsx
|
|
132
|
-
import {
|
|
141
|
+
import { definePlugin } from 'platejs/react';
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
<HighlighterIcon />
|
|
138
|
-
</MarkToolbarButton>
|
|
139
|
-
<CommentToolbarButton />
|
|
140
|
-
</EditorSelectionView>
|
|
141
|
-
<AllCommentsButton />
|
|
142
|
-
</ToolbarGroup>
|
|
143
|
+
const FloatingToolbarPlugin = definePlugin('floatingToolbar', {
|
|
144
|
+
slots: { caret: () => <FloatingToolbar /> },
|
|
145
|
+
});
|
|
143
146
|
```
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
`useFocusedLast()` answer for the view
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
The copied `FloatingToolbar` wraps its whole body and positions itself against
|
|
152
|
-
`useEditableRef()`, so it opens beside selected note text. There it shows Ask
|
|
153
|
-
AI, the mark buttons and Comment. The copied `FixedToolbarButtons` wraps its
|
|
154
|
-
mark, color, highlight and comment buttons. Undo, Insert and Turn into sit
|
|
155
|
-
outside the wrapper and act on the page. The copied AI menu wraps itself the
|
|
156
|
-
same way.
|
|
148
|
+
In the `caret` slot, `useEditor()`, `useEditableRef()`, `useEditorFocused()`
|
|
149
|
+
and `useFocusedLast()` answer for the view that holds the caret while that view
|
|
150
|
+
is mounted inside the slot's editing area, and for the slot's own view
|
|
151
|
+
otherwise. So a header `EditorContent`'s floating toolbar stays on the header
|
|
152
|
+
while the caret is in the body.
|
|
157
153
|
|
|
158
154
|
### Creating custom button
|
|
159
155
|
|
|
@@ -288,8 +284,8 @@ Plugin that renders a floating toolbar that appears on text selection.
|
|
|
288
284
|
|
|
289
285
|
<API name="FloatingToolbarKit">
|
|
290
286
|
<APIOptions>
|
|
291
|
-
<APIItem name="slots.
|
|
292
|
-
Renders the floating toolbar as an overlay after the editor. Contains FloatingToolbarButtons by default.
|
|
287
|
+
<APIItem name="slots.caret" type="EditableSiblingComponent">
|
|
288
|
+
Renders the floating toolbar as an overlay after the editor, on the view that holds the caret. Contains FloatingToolbarButtons by default.
|
|
293
289
|
</APIItem>
|
|
294
290
|
</APIOptions>
|
|
295
291
|
</API>
|
package/dist/docs/upload.md
CHANGED
|
@@ -62,7 +62,7 @@ characters, and a positive `FILES_MAX_UPLOAD_SIZE`. Implement
|
|
|
62
62
|
`resolveFilesAccess` in the copied `lib/files.ts` for your session and document
|
|
63
63
|
ACL before accepting requests. It checks read and write access, including on
|
|
64
64
|
the proxy upload `PUT`. The route's `documentId` is an application document ID,
|
|
65
|
-
not an authorization token. Use 1
|
|
65
|
+
not an authorization token. Use 1 to 128 letters, digits, underscores, or hyphens
|
|
66
66
|
for that ID. Return a stable tenant/document namespace shared by authorized
|
|
67
67
|
collaborators.
|
|
68
68
|
|
|
@@ -129,6 +129,7 @@ the active `documentId`, as in the configuration above.
|
|
|
129
129
|
editor.plugin(UploadPlugin).update.submit(files, { after: blockKey });
|
|
130
130
|
editor.plugin(UploadPlugin).update.submit(files, { slot: draftKey });
|
|
131
131
|
editor.plugin(UploadPlugin).api.cancel(draftKey);
|
|
132
|
+
editor.plugin(UploadPlugin).api.fitsAfter(draftKey);
|
|
132
133
|
```
|
|
133
134
|
|
|
134
135
|
`submit` accepts `File[]` or `FileList`. It validates the whole batch before
|
|
@@ -138,6 +139,9 @@ draft. A cancel, a removal of the draft, a later update that replaces the whole
|
|
|
138
139
|
document, or a destroyed editor before then sends no request, and an undo that
|
|
139
140
|
brings the draft back does not restart it. A slot
|
|
140
141
|
option fills an existing draft; block placement options insert new drafts.
|
|
142
|
+
A slot submit of several files gives the draft the first file and inserts a
|
|
143
|
+
draft for each other file after it. When those drafts do not fit there,
|
|
144
|
+
`submit` refuses the batch as `does-not-fit`.
|
|
141
145
|
Without a placement option, `submit` inserts at the selection and replaces the
|
|
142
146
|
selection's block when it is empty, as a paste does.
|
|
143
147
|
Cancellation leaves an idle draft. A failed live task keeps its `File` for
|
|
@@ -150,6 +154,76 @@ element. A custom renderer can read
|
|
|
150
154
|
`AggregateProgress` with `loaded`, `total`, and `fraction` (`0` to `1`).
|
|
151
155
|
Unmounting a renderer does not restart an upload.
|
|
152
156
|
|
|
157
|
+
`api.fitsAfter(draftKey)` says whether a second draft of the same kind fits
|
|
158
|
+
after the draft, where a slot submit puts the draft of a second file. It writes
|
|
159
|
+
nothing and returns `false` for a key that names no upload draft. It reads the
|
|
160
|
+
committed document, so inside an update it does not see the drafts that update
|
|
161
|
+
inserted. The copied `UploadElement` asks it each time its file picker opens, and
|
|
162
|
+
the picker takes several files only when the answer is `true`. So a draft that is
|
|
163
|
+
the only block its container holds, such as the draft in a board's
|
|
164
|
+
[image shape](/docs/board#picture-files), picks one file.
|
|
165
|
+
|
|
166
|
+
## Insert drafts yourself
|
|
167
|
+
|
|
168
|
+
`submit` inserts its drafts as blocks. A container that wraps each draft in an
|
|
169
|
+
element of its own, such as a gallery card or a board's
|
|
170
|
+
[image shape](/docs/board#picture-files), inserts the drafts itself. In one
|
|
171
|
+
update, check the batch with `admit`, insert the drafts it returns, then name
|
|
172
|
+
each file's draft with `fill`:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { BaseUploadPlugin } from 'platejs/upload';
|
|
176
|
+
|
|
177
|
+
editor.update((tx) => {
|
|
178
|
+
const batch = tx.plugin(BaseUploadPlugin).admit(files, { kind: 'image' });
|
|
179
|
+
|
|
180
|
+
if (!batch || 'failure' in batch) return;
|
|
181
|
+
|
|
182
|
+
tx.blocks.insert(
|
|
183
|
+
batch.drafts.map((draft) => ({ children: [draft], type: 'card' })),
|
|
184
|
+
{ at: [0] }
|
|
185
|
+
);
|
|
186
|
+
batch.fill(
|
|
187
|
+
batch.drafts.flatMap((_draft, index) => tx.key([index, 0]) ?? [])
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Here `card` is an element of your app whose content takes one `image` or
|
|
193
|
+
`upload` element. The sample puts each draft in a card at the top of the
|
|
194
|
+
document, then reads each draft's key from the place where it sits.
|
|
195
|
+
|
|
196
|
+
`admit(files, { kind })` writes nothing and returns one of three values:
|
|
197
|
+
|
|
198
|
+
| Value | When |
|
|
199
|
+
| --- | --- |
|
|
200
|
+
| `undefined` | There is nothing to do: the list is empty, the view is a preview, or the editor is read-only or destroyed. |
|
|
201
|
+
| `{ failure }` | Upload refuses the batch. It passes `failure` to `onError` once, after the update commits. |
|
|
202
|
+
| `{ drafts, fill }` | The batch passed. `drafts` holds one new draft per file, in file order. |
|
|
203
|
+
|
|
204
|
+
With `kind`, a file of another upload kind refuses the batch before every other
|
|
205
|
+
check. The failure is `unsupported-file-type`. Its `files` hold only the files
|
|
206
|
+
of another kind and its `allowedTypes` hold the file types of `kind`, so you
|
|
207
|
+
can call `admit` again without those files. After that check, `admit` runs the
|
|
208
|
+
checks that `submit` runs: `rules`, `maxFiles`, the `client` and `getUrl`, and
|
|
209
|
+
an installed media plugin for each kind.
|
|
210
|
+
|
|
211
|
+
Upload does not track the drafts that `admit` returns. Insert them anywhere in
|
|
212
|
+
the same update, then call `fill(keys)` with the node key of each file's draft,
|
|
213
|
+
in file order. `fill` checks every key before it gives any file a draft:
|
|
214
|
+
|
|
215
|
+
- It takes one key per file, and no key twice.
|
|
216
|
+
- Each key names a live upload draft of its file's kind, outside a read-only
|
|
217
|
+
element.
|
|
218
|
+
- No named draft got a file earlier in the same update, from `submit` or `fill`.
|
|
219
|
+
- The batch has not been filled yet.
|
|
220
|
+
|
|
221
|
+
A failed check throws an error that names `fill` and gives no file a draft, and
|
|
222
|
+
a correct `fill` can follow a caught error. Each upload starts after the update
|
|
223
|
+
commits, as with `submit`. A draft that no `fill` names stays an idle draft and
|
|
224
|
+
uploads nothing. The batch lives for the update that admitted it, so call
|
|
225
|
+
`fill` inside that update.
|
|
226
|
+
|
|
153
227
|
## Dropped files
|
|
154
228
|
|
|
155
229
|
The React `UploadPlugin` lands files dropped into the editor at the block edge
|
|
@@ -204,25 +278,37 @@ export const MyFileDropPlugin = definePlugin('myFileDrop', {
|
|
|
204
278
|
|
|
205
279
|
An editor whose `UploadPlugin` has a `client`, a `getUrl`, and a rule with
|
|
206
280
|
`kind: 'image'` uploads the pictures whose bytes come with a paste. These are
|
|
207
|
-
raster `data` addresses in pasted HTML or in the editor's own clipboard,
|
|
281
|
+
raster `data` addresses in pasted HTML or in the editor's own clipboard, the
|
|
208
282
|
pictures that [Word paste](/docs/docx#paste-from-word) rebuilds from the RTF
|
|
209
|
-
copy
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
283
|
+
copy, and pictures with a `blob` address, such as a picture copied from Word in
|
|
284
|
+
Safari. A `blob` address works only in the tab that pasted it, so the paste
|
|
285
|
+
reads its bytes while it runs. Each picture becomes an upload draft where it
|
|
286
|
+
landed, so the document never stores its `data` or `blob` address. Its upload
|
|
287
|
+
starts after the paste commits, and the finished image keeps the picture's alt
|
|
288
|
+
text, width, and caption. Without those three settings, pasted pictures stay as
|
|
289
|
+
pasted. The copied `UploadKit` sets all three.
|
|
290
|
+
|
|
291
|
+
A `blob` picture uploads only when its bytes are a GIF, JPEG, PNG or WebP
|
|
292
|
+
image. Its file takes that type from the bytes and a name such as `image.png`.
|
|
293
|
+
A `blob` picture whose read fails, or whose bytes are of another kind, such as
|
|
294
|
+
SVG, keeps its pasted address while the other pictures upload. The paste reads
|
|
295
|
+
with a synchronous request. So a page whose Content Security Policy sets
|
|
296
|
+
`connect-src` without `blob:` keeps every `blob` picture as pasted, and so does
|
|
297
|
+
a page whose Permissions Policy blocks `sync-xhr` in Chromium. A real Word paste
|
|
298
|
+
in Safari is not yet tested.
|
|
214
299
|
|
|
215
300
|
The paste checks its pictures as one batch against `rules` and `maxFiles`, as
|
|
216
|
-
`submit` does. When those rules refuse the batch, every picture
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
301
|
+
`submit` does. When those rules refuse the batch, every picture keeps the
|
|
302
|
+
address it was pasted with, and `onError` runs once. The paste reads its
|
|
303
|
+
pictures in document order and stops once it holds more than the batch allows,
|
|
304
|
+
so `onError` gets the pictures read up to then. The kit's image rule allows
|
|
305
|
+
three files, so a paste of four or more pictures keeps them all as pasted. A
|
|
306
|
+
picture whose address does not decode, or whose draft cannot sit where the
|
|
307
|
+
picture landed, also stays as pasted while the other pictures upload.
|
|
222
308
|
|
|
223
309
|
One undo removes the paste and its drafts and stops their uploads. Redo brings
|
|
224
|
-
back the drafts without starting an upload.
|
|
225
|
-
|
|
310
|
+
back the drafts without starting an upload. A paste in a Suggesting view or into
|
|
311
|
+
a preview keeps every picture as pasted.
|
|
226
312
|
|
|
227
313
|
A paste does not upload:
|
|
228
314
|
|
|
@@ -230,8 +316,8 @@ A paste does not upload:
|
|
|
230
316
|
address, and the image plugin turns a plain-text picture link into such an
|
|
231
317
|
image.
|
|
232
318
|
- A picture that was in the document before the paste.
|
|
233
|
-
- A picture
|
|
234
|
-
pasted
|
|
319
|
+
- A picture inside a content root the paste adds, such as a copied card's body.
|
|
320
|
+
A paste that adds such a root also keeps every `blob` picture as pasted.
|
|
235
321
|
|
|
236
322
|
An HTML drop uploads its pictures the same way. With the React `UploadPlugin`,
|
|
237
323
|
a drop that carries files uploads those files instead, as
|
|
@@ -245,7 +331,10 @@ a drop that carries files uploads those files instead, as
|
|
|
245
331
|
| `UploadPlugin` from `platejs/upload/react` | React adapter that lands dropped files at the block edge under the pointer. |
|
|
246
332
|
| `UploadPlugin.configure({ initialState })` | Set `client: UploadClient`, synchronous `getUrl: (file: UploadOutcome) => string`, `rules`, `maxFiles`, and `onError`. |
|
|
247
333
|
| `editor.plugin(UploadPlugin).update.submit(files, options)` | Insert a validated batch or fill a draft slot. Slot and block placement options are mutually exclusive. |
|
|
334
|
+
| `tx.plugin(BaseUploadPlugin).admit(files, { kind? })` | Check a batch for drafts the caller inserts itself. It writes nothing and returns `undefined`, an `UploadRefusal` or an `UploadAdmission`. |
|
|
335
|
+
| `fill(keys)` of an `UploadAdmission` | Give each file the draft its node key names, in file order. It throws when a key fails a check. |
|
|
248
336
|
| `editor.plugin(UploadPlugin).api.cancel(key)` | Abort the live task for one draft. |
|
|
337
|
+
| `editor.plugin(UploadPlugin).api.fitsAfter(key)` | Say whether a second draft of the same kind fits after the draft at `key`. It writes nothing. |
|
|
249
338
|
|
|
250
339
|
The draft has persisted type `upload` and a required `kind`, while its
|
|
251
340
|
`File`, progress, and failure stay in editor state. Completed media stores a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { st as BasePluginInput, u as Editor } from "../../core-
|
|
2
|
-
import { n as EditorStaticProps } from "../../PlateStatic-
|
|
3
|
-
import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-
|
|
1
|
+
import { st as BasePluginInput, u as Editor } from "../../core-ClHasORr.js";
|
|
2
|
+
import { n as EditorStaticProps } from "../../PlateStatic-CJX5bKuv.js";
|
|
3
|
+
import { n as DocxComment, r as DocxDiagnostic, t as DocxSource } from "../../source-aUwpNnAw.js";
|
|
4
4
|
type UnitValue = number | string;
|
|
5
5
|
type Margins = {
|
|
6
6
|
bottom?: UnitValue;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseHeadingPlugin } from "../../../features/basic-nodes/lib/BaseHeadingPlugins.js";
|
|
2
2
|
import { BaseCodeBlockPlugin } from "../../../features/code-block/lib/BaseCodeBlockPlugin.js";
|
|
3
3
|
import { BaseListPlugin, ListType } from "../../../features/list/lib/BaseListPlugin.js";
|
|
4
|
+
import { getDefaultElementTag } from "../../../internal/plugin/defaultElementTag.js";
|
|
4
5
|
import { EditorElement } from "../../../static/components/plite-nodes.js";
|
|
5
6
|
import { BaseCalloutPlugin } from "../../../features/callout/lib/BaseCalloutPlugin.js";
|
|
6
7
|
import { BaseFootnoteDefinitionPlugin, BaseFootnotePlugin } from "../../../features/footnote/lib/BaseFootnotePlugin.js";
|
|
@@ -349,8 +350,17 @@ const listItemOf = (editor, element, path, list) => {
|
|
|
349
350
|
default: return;
|
|
350
351
|
}
|
|
351
352
|
};
|
|
352
|
-
const
|
|
353
|
-
|
|
353
|
+
const textComponent = (text) => function DocxText(props) {
|
|
354
|
+
return /* @__PURE__ */ React.createElement(EditorElement, {
|
|
355
|
+
...props,
|
|
356
|
+
as: getDefaultElementTag(props.attributes)
|
|
357
|
+
}, text({ node: props.element }), props.children);
|
|
358
|
+
};
|
|
359
|
+
const docxStaticOverrides = (story, textFormats) => Object.freeze({
|
|
360
|
+
components: {
|
|
361
|
+
...DOCX_STATIC_COMPONENTS,
|
|
362
|
+
...Object.fromEntries(textFormats.map(({ plugin, text }) => [plugin, textComponent(text)]))
|
|
363
|
+
},
|
|
354
364
|
slots: { [BaseListPlugin.name]: { wrapNodeChildren: null } },
|
|
355
365
|
wrapElement: ({ attributes, children, editor, element, path }) => {
|
|
356
366
|
const item = editor.plugin(BaseListPlugin).installed ? listItemOf(editor, element, path, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPlateNodeMappingContributions } from "../../../internal/plugin/collectPlateNodeMappings.js";
|
|
1
2
|
import { BaseParagraphPlugin } from "../../../lib/plugins/paragraph/BaseParagraphPlugin.js";
|
|
2
3
|
import { projectPlateFormatDocument } from "../../../lib/editor/withPlite.js";
|
|
3
4
|
import { DocumentChange, ElementApi } from "../../../core.js";
|
|
@@ -42,7 +43,7 @@ const mapCommentRanges = (comments, project) => Object.freeze(comments.map((comm
|
|
|
42
43
|
const captureExport = (editor, options, comments) => {
|
|
43
44
|
const snapshot = captureExportSnapshot(editor, options.projection);
|
|
44
45
|
if (options.projection === "review") {
|
|
45
|
-
const review = createReviewProjection(snapshot.stored, (node) => editor.plugin(AuthoredPlugin).read.reviewOf(node));
|
|
46
|
+
const review = createReviewProjection(snapshot.stored, (node) => editor.plugin(AuthoredPlugin).read.reviewOf(node), (node) => editor.read.schema.isVoid(node) && editor.read.schema.isInline(node));
|
|
46
47
|
return Object.freeze({
|
|
47
48
|
comments,
|
|
48
49
|
diagnostics: Object.freeze([]),
|
|
@@ -86,6 +87,27 @@ const nativeOnlyDiagnostics = (document) => {
|
|
|
86
87
|
});
|
|
87
88
|
return diagnostics;
|
|
88
89
|
};
|
|
90
|
+
const docxTextFormatsOf = (editor) => getPlateNodeMappingContributions(editor, "docx").map(({ declaration, owner, targetPlugin, targetType }) => {
|
|
91
|
+
if (typeof declaration.dropped !== "string" || typeof declaration.text !== "function" || targetType === null) throw new Error(`DOCX node mapping "${owner}" must define dropped and text for an element.`);
|
|
92
|
+
return {
|
|
93
|
+
dropped: declaration.dropped,
|
|
94
|
+
plugin: targetPlugin,
|
|
95
|
+
text: declaration.text,
|
|
96
|
+
type: targetType
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
const countElements = (nodes, type) => nodes.reduce((count, node) => ElementApi.isElement(node) ? count + (node.type === type ? 1 : 0) + countElements(node.children, type) : count, 0);
|
|
100
|
+
const textFormatDiagnostics = (textFormats, document) => textFormats.flatMap(({ dropped, plugin, type }) => {
|
|
101
|
+
const count = countElements(document.children, type);
|
|
102
|
+
return count > 0 ? [{
|
|
103
|
+
code: "property-dropped",
|
|
104
|
+
count,
|
|
105
|
+
feature: plugin,
|
|
106
|
+
impact: "lossy",
|
|
107
|
+
message: dropped,
|
|
108
|
+
severity: "warning"
|
|
109
|
+
}] : [];
|
|
110
|
+
});
|
|
89
111
|
const isNumberedOrTask = (node) => node.listType === "numbered" || node.listType === "task";
|
|
90
112
|
const canShareListWithOtherKind = (node) => node.listType !== "bulleted" || typeof node.listId === "string";
|
|
91
113
|
const listDiagnostics = (document) => {
|
|
@@ -178,7 +200,7 @@ const quoteDiagnostics = (editor, children, commentId) => {
|
|
|
178
200
|
visit(children, []);
|
|
179
201
|
return diagnostics;
|
|
180
202
|
};
|
|
181
|
-
const renderDocxHtml = async (editor, document, story, { component, fontFamily, presentation, signal }) => {
|
|
203
|
+
const renderDocxHtml = async (editor, document, story, textFormats, { component, fontFamily, presentation, signal }) => {
|
|
182
204
|
const rendered = await renderStaticHtmlWithOverrides(editor, {
|
|
183
205
|
component,
|
|
184
206
|
document,
|
|
@@ -187,7 +209,7 @@ const renderDocxHtml = async (editor, document, story, { component, fontFamily,
|
|
|
187
209
|
padding: "0",
|
|
188
210
|
...fontFamily ? { fontFamily } : {}
|
|
189
211
|
} }
|
|
190
|
-
}, docxStaticOverrides(story));
|
|
212
|
+
}, docxStaticOverrides(story, textFormats));
|
|
191
213
|
throwIfDocxAborted(signal);
|
|
192
214
|
return rendered;
|
|
193
215
|
};
|
|
@@ -276,9 +298,11 @@ async function exportDocx(editor, options) {
|
|
|
276
298
|
ok: true
|
|
277
299
|
});
|
|
278
300
|
}
|
|
301
|
+
const textFormats = docxTextFormatsOf(editor);
|
|
279
302
|
const diagnostics = [
|
|
280
303
|
...sourceResolution.diagnostics,
|
|
281
304
|
...nativeOnly,
|
|
305
|
+
...textFormatDiagnostics(textFormats, capture.document),
|
|
282
306
|
...listDiagnostics(capture.document),
|
|
283
307
|
...quoteDiagnostics(editor, capture.document.children),
|
|
284
308
|
...capture.comments.flatMap(({ body, id, target }) => target ? quoteDiagnostics(editor, body, id) : []),
|
|
@@ -286,9 +310,9 @@ async function exportDocx(editor, options) {
|
|
|
286
310
|
...capture.diagnostics
|
|
287
311
|
];
|
|
288
312
|
try {
|
|
289
|
-
const [main, commentRenders] = await Promise.all([renderDocxHtml(editor, capture.document, "body", options), Promise.all(capture.comments.map(async ({ body, id }) => ({
|
|
313
|
+
const [main, commentRenders] = await Promise.all([renderDocxHtml(editor, capture.document, "body", textFormats, options), Promise.all(capture.comments.map(async ({ body, id }) => ({
|
|
290
314
|
id,
|
|
291
|
-
...await renderDocxHtml(editor, { children: body }, `comment:${id}`, options)
|
|
315
|
+
...await renderDocxHtml(editor, { children: body }, `comment:${id}`, textFormats, options)
|
|
292
316
|
})))]);
|
|
293
317
|
throwIfDocxAborted(options.signal);
|
|
294
318
|
const anchored = anchorDocxComments(main.data, capture.comments);
|
|
@@ -133,7 +133,7 @@ const writeRun = (marker, review) => {
|
|
|
133
133
|
}
|
|
134
134
|
outer = wrap(outer, revisionElement(document, "del", review.deletion));
|
|
135
135
|
}
|
|
136
|
-
for (const insertion of review.
|
|
136
|
+
for (const insertion of review.insertionsOuterFirst.toReversed()) outer = wrap(outer, revisionElement(document, "ins", insertion));
|
|
137
137
|
};
|
|
138
138
|
const bookmarkElements = (document, id, name) => {
|
|
139
139
|
const start = wordElement(document, "bookmarkStart");
|
|
@@ -9,7 +9,7 @@ const holdsMarks = (node) => "authored" in node || ElementApi.isElement(node) &&
|
|
|
9
9
|
* Read the review marks of a stored document as Word revisions. Paths are the
|
|
10
10
|
* stored document's, so ranges into it need no mapping.
|
|
11
11
|
*/
|
|
12
|
-
const createReviewProjection = (stored, reviewOf) => {
|
|
12
|
+
const createReviewProjection = (stored, reviewOf, isInlineVoid) => {
|
|
13
13
|
const revisionIds = /* @__PURE__ */ new Map();
|
|
14
14
|
const runs = /* @__PURE__ */ new Map();
|
|
15
15
|
const structures = /* @__PURE__ */ new Map();
|
|
@@ -31,20 +31,21 @@ const createReviewProjection = (stored, reviewOf) => {
|
|
|
31
31
|
const { authored, ...plain } = node;
|
|
32
32
|
const review = authored ? reviewOf(node) : null;
|
|
33
33
|
const marks = review?.marks ?? [];
|
|
34
|
-
|
|
34
|
+
const isText = !ElementApi.isElement(node);
|
|
35
|
+
if (isText || isInlineVoid(node)) {
|
|
35
36
|
const insertions = marks.filter(({ kind }) => kind === "insert");
|
|
36
37
|
const deletion = marks.find(({ kind }) => kind === "delete");
|
|
37
|
-
const format = marks.find(({ kind }) => kind === "format");
|
|
38
|
-
if (insertions.length > 0 || deletion || format) runs.set(renderKey("text", root, key), {
|
|
38
|
+
const format = isText ? marks.find(({ kind }) => kind === "format") : void 0;
|
|
39
|
+
if (insertions.length > 0 || deletion || format) runs.set(renderKey(isText ? "text" : "element", root, key), {
|
|
39
40
|
deletion: deletion ? revisionOf(deletion) : null,
|
|
40
41
|
format: format && review ? {
|
|
41
42
|
...revisionOf(format),
|
|
42
43
|
previous: review.accepted
|
|
43
44
|
} : null,
|
|
44
|
-
|
|
45
|
+
insertionsOuterFirst: insertions.map(revisionOf)
|
|
45
46
|
});
|
|
46
|
-
return plain;
|
|
47
47
|
}
|
|
48
|
+
if (!ElementApi.isElement(node)) return plain;
|
|
48
49
|
const structure = marks.find((mark) => mark.kind !== "insert" && mark.kind !== "delete" && mark.kind !== "joined");
|
|
49
50
|
if (structure) structures.set(renderKey("element", root, key), revisionOf(structure));
|
|
50
51
|
return {
|
|
@@ -72,6 +73,7 @@ const setStructureAttributes = (element, revision) => {
|
|
|
72
73
|
element.setAttribute("data-editor-author-id", revision.author);
|
|
73
74
|
if (revision.at > 0) element.setAttribute("data-editor-created-at", new Date(revision.at).toISOString());
|
|
74
75
|
};
|
|
76
|
+
const MISSING_ELEMENT_HOST = "A configured static element renderer omitted its Plate path attributes.";
|
|
75
77
|
const missingHost = (feature, key, message) => {
|
|
76
78
|
const [, root, path] = key.split(":");
|
|
77
79
|
return {
|
|
@@ -106,7 +108,7 @@ const applyReviewProjection = (html, projection) => {
|
|
|
106
108
|
for (const [key, run] of projection.runs) {
|
|
107
109
|
const host = hosts.get(key);
|
|
108
110
|
if (!host) {
|
|
109
|
-
diagnostics.push(missingHost("review-text-wrapper", key, "A configured static text renderer omitted its Plate path attributes."));
|
|
111
|
+
diagnostics.push(key.startsWith("text:") ? missingHost("review-text-wrapper", key, "A configured static text renderer omitted its Plate path attributes.") : missingHost("review-structure-wrapper", key, MISSING_ELEMENT_HOST));
|
|
110
112
|
continue;
|
|
111
113
|
}
|
|
112
114
|
const wrapper = document.createElement("span");
|
|
@@ -118,7 +120,7 @@ const applyReviewProjection = (html, projection) => {
|
|
|
118
120
|
for (const [key, structure] of projection.structures) {
|
|
119
121
|
const host = hosts.get(key);
|
|
120
122
|
if (!host) {
|
|
121
|
-
diagnostics.push(missingHost("review-structure-wrapper", key,
|
|
123
|
+
diagnostics.push(missingHost("review-structure-wrapper", key, MISSING_ELEMENT_HOST));
|
|
122
124
|
continue;
|
|
123
125
|
}
|
|
124
126
|
setStructureAttributes(host, structure);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { h as EditorApplicationSchema } from "../../htmlTypes-
|
|
3
|
-
import "../../core-
|
|
4
|
-
import { a as DocxImportLimits, i as DocxErrorDiagnostic, n as DocxComment, o as DocxSourceLocation, r as DocxDiagnostic, s as DocxWarningDiagnostic, t as DocxSource } from "../../source-
|
|
1
|
+
import { Mo as PluginReference, Tt as EditorDocumentValue, ru as Value } from "../../index-DpltOCot-A2b3p3Eb.js";
|
|
2
|
+
import { h as EditorApplicationSchema } from "../../htmlTypes-cg_cWsaN.js";
|
|
3
|
+
import "../../core-ClHasORr.js";
|
|
4
|
+
import { a as DocxImportLimits, i as DocxErrorDiagnostic, n as DocxComment, o as DocxSourceLocation, r as DocxDiagnostic, s as DocxWarningDiagnostic, t as DocxSource } from "../../source-aUwpNnAw.js";
|
|
5
5
|
type DocxImportOptions<TRetainSource extends boolean = false> = Readonly<{
|
|
6
6
|
limits?: Partial<DocxImportLimits>;
|
|
7
7
|
lossPolicy?: 'allow' | 'reject';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult } from "../../htmlTypes-
|
|
3
|
-
import { _ as BasePlugin,
|
|
4
|
-
import "../../index-
|
|
1
|
+
import { ru as Value } from "../../index-DpltOCot-A2b3p3Eb.js";
|
|
2
|
+
import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult } from "../../htmlTypes-cg_cWsaN.js";
|
|
3
|
+
import { _ as BasePlugin, xo as PluginReference, yo as PluginDependency } from "../../core-ClHasORr.js";
|
|
4
|
+
import "../../index-C35V_hj0.js";
|
|
5
5
|
/** Normalizes Word clipboard payloads before the installed HTML parser runs. */
|
|
6
6
|
declare const WordPastePlugin: BasePlugin<Readonly<{
|
|
7
7
|
readonly dependencies: readonly [PluginReference<"html"> & PluginDependency<Readonly<{
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Returns whether an event, node, window, or document belongs to an Apple
|
|
4
|
-
* platform, where `mod` is Command.
|
|
5
|
-
*/
|
|
6
|
-
declare const usesAppleDOMHotkeys: (event: unknown) => boolean;
|
|
1
|
+
import { A as DataTransferSnapshot, B as domCommands, C as DOMVisualPointOptions, D as DataTransferFormat, E as DataTransferEncodeContext, F as KeyboardEventLike, H as usesAppleDOMHotkeys, I as ScrollIntoViewOptions, L as ScrollIntoViewTarget, M as HotkeyMatchOptions, N as HotkeyPlatform, O as DataTransferFormatPhase, P as HotkeySpec, R as ariaKeyShortcuts, S as DOMVisualPoint, T as DataTransferDiagnostic, U as writeDataTransferFragment, V as isHotkey, _ as DOMRange, b as DOMStaticRange, f as DOMElement, g as DOMPoint, i as DOMClipboardApi, k as DataTransferSchemaClaim, n as ClipboardSliceWrite, p as DOMNode, r as DOMApi, t as ClipboardSliceRead, v as DOMResolutionError, w as DataTransferDecodeContext, x as DOMText, y as DOMSelection, z as dataTransferFormats } from "../index-B5mYEawV.js";
|
|
7
2
|
export { type ClipboardSliceRead, type ClipboardSliceWrite, type DOMApi, type DOMClipboardApi, type DOMElement, type DOMNode, type DOMPoint, type DOMRange, DOMResolutionError, type DOMSelection, type DOMStaticRange, type DOMText, type DOMVisualPoint, type DOMVisualPointOptions, type DataTransferDecodeContext, type DataTransferDiagnostic, type DataTransferEncodeContext, type DataTransferFormat, type DataTransferFormatPhase, type DataTransferSchemaClaim, type DataTransferSnapshot, type HotkeyMatchOptions, type HotkeyPlatform, type HotkeySpec, type KeyboardEventLike, type ScrollIntoViewOptions, type ScrollIntoViewTarget, ariaKeyShortcuts, dataTransferFormats, domCommands, isHotkey, usesAppleDOMHotkeys, writeDataTransferFragment };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createCompiledHotkeyMatcher, dataTransferFormats, dom, domCommands, getEditorDOMRoot, getSelection, isGeckoDOMHost, isHotkey, readDOMSelectionRange, usesAppleDOMHotkeys, writeDOMSelection } from "plitejs/dom";
|
|
2
|
-
export { createCompiledHotkeyMatcher, dataTransferFormats, dom, domCommands, getEditorDOMRoot, getSelection, isGeckoDOMHost, isHotkey, readDOMSelectionRange, usesAppleDOMHotkeys, writeDOMSelection };
|
|
1
|
+
import { cleanDOMClipboardContents, createCompiledHotkeyMatcher, dataTransferFormats, dom, domCommands, getEditorDOMRoot, getSelection, isGeckoDOMHost, isHotkey, readDOMSelectionRange, usesAppleDOMHotkeys, writeDOMSelection } from "plitejs/dom";
|
|
2
|
+
export { cleanDOMClipboardContents, createCompiledHotkeyMatcher, dataTransferFormats, dom, domCommands, getEditorDOMRoot, getSelection, isGeckoDOMHost, isHotkey, readDOMSelectionRange, usesAppleDOMHotkeys, writeDOMSelection };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Qo as PropertyJsonDescriptor, Vt as EditorJsonValue, ki as ElementOf } from "../index-DpltOCot-A2b3p3Eb.js";
|
|
2
|
+
import "../htmlTypes-cg_cWsaN.js";
|
|
3
|
+
import { _ as BasePlugin } from "../core-ClHasORr.js";
|
|
3
4
|
type ExcalidrawElementData = {
|
|
4
5
|
elements: readonly EditorJsonValue[];
|
|
5
6
|
files?: Readonly<Record<string, EditorJsonValue>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Qo as PropertyJsonDescriptor, Vt as EditorJsonValue } from "../../index-DpltOCot-A2b3p3Eb.js";
|
|
2
|
+
import "../../htmlTypes-cg_cWsaN.js";
|
|
3
|
+
import { At as Plugin } from "../../index-8WO2vI0U.js";
|
|
3
4
|
import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
|
4
5
|
declare const ExcalidrawPlugin: Plugin<Readonly<{}> & Readonly<{
|
|
5
6
|
name: "excalidraw";
|
package/dist/facade.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ContentSlice, DocumentChange, EditorSchemaValidationError, ElementApi, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, createEditor, defineEditorSchema, definePlugin as defineRuntimePlugin, definePluginPoint, editorCommands, editorReads, getEditorRuntimeOwner, locateAt, property, readEditorSelection, schema, target, transfer, txLocate, txSelection } from "plitejs";
|
|
2
|
-
import { EDITOR_DOCUMENT_FIELDS as EDITOR_DOCUMENT_FIELDS$1, MAIN_ROOT_KEY, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createDetachedEditorSchema as createDetachedEditorSchema$1, createEditorOwner, fitSlicePlacements, getActiveEditorTransaction, getActiveEditorUpdateId, getAuthoredUpdateView, getCaretOwner, getCompiledEditorSchema as getCompiledEditorSchema$1, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability as getEditorAuthoredDocumentCapability$1, getEditorCommitNode, getEditorCommitSnapshot, getEditorDocumentShapeIssueMessage, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getViewAuthor, holdsCaret, isAuthorId, isDocumentView, isEnvelopeInput as isEnvelopeInput$1, isPlugin as isRuntimePlugin, landNodePropertiesAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, readAuthoredView, readDocumentRange, readDocumentRecord as readDocumentRecord$1, readPersistedEnvelope as readPersistedEnvelope$1, readRootViewUse, readStoredEditorDocument, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError as reportEditorLifecycleError$1, runEditorObserver, sameResult, scheduleAfterCommitNotification, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeEditorViewState,
|
|
3
|
-
export { ContentSlice, DocumentChange, EDITOR_DOCUMENT_FIELDS$1 as EDITOR_DOCUMENT_FIELDS, EditorSchemaValidationError, ElementApi, MAIN_ROOT_KEY, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createDetachedEditorSchema$1 as createDetachedEditorSchema, createEditor, createEditorOwner, defineEditorSchema, definePluginPoint, defineRuntimePlugin, editorCommands, editorReads, fitSlicePlacements, getActiveEditorTransaction, getActiveEditorUpdateId, getAuthoredUpdateView, getCaretOwner, getCompiledEditorSchema$1 as getCompiledEditorSchema, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability$1 as getEditorAuthoredDocumentCapability, getEditorCommitNode, getEditorCommitSnapshot, getEditorDocumentShapeIssueMessage, getEditorRuntimeOwner, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getViewAuthor, holdsCaret, isAuthorId, isDocumentView, isEnvelopeInput$1 as isEnvelopeInput, isRuntimePlugin, landNodePropertiesAt, locateAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, property, readAuthoredView, readDocumentRange, readDocumentRecord$1 as readDocumentRecord, readEditorSelection, readPersistedEnvelope$1 as readPersistedEnvelope, readRootViewUse, readStoredEditorDocument, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError$1 as reportEditorLifecycleError, runEditorObserver, sameResult, scheduleAfterCommitNotification, schema, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeEditorViewState,
|
|
2
|
+
import { EDITOR_DOCUMENT_FIELDS as EDITOR_DOCUMENT_FIELDS$1, EditorRefusalError, MAIN_ROOT_KEY, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createDetachedEditorSchema as createDetachedEditorSchema$1, createEditorOwner, fitSlicePlacements, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAuthoredUpdateView, getCaretOwner, getCarriedCaretEditor, getCompiledEditorSchema as getCompiledEditorSchema$1, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability as getEditorAuthoredDocumentCapability$1, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getValueRecords, getViewAuthor, getViewPresentation as getViewPresentation$1, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput as isEnvelopeInput$1, isPlugin as isRuntimePlugin, landNodePropertiesAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord as readDocumentRecord$1, readElementPropertyWrites, readPersistedEnvelope as readPersistedEnvelope$1, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError as reportEditorLifecycleError$1, runEditorObserver, sameResult, scheduleAfterCommitNotification, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse, txStored, vetoesWrite, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withStoredAuthoredRead, withTransactionSpecDraftRead } from "plitejs/internal";
|
|
3
|
+
export { ContentSlice, DocumentChange, EDITOR_DOCUMENT_FIELDS$1 as EDITOR_DOCUMENT_FIELDS, EditorRefusalError, EditorSchemaValidationError, ElementApi, MAIN_ROOT_KEY, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, afterActiveTransactionEnds, assertDetachedSelectionSupported, assertEditorDocumentContainers, attachTransactionSpecAfterCommit, canPlaceBlocksAtPath, canonicalRecordJson, claimsHistoryReplay, completePersistedDocumentFields, configureAuthoredView, containsCompleteEditorSchema, createDetachedEditorSchema$1 as createDetachedEditorSchema, createEditor, createEditorOwner, defineEditorSchema, definePluginPoint, defineRuntimePlugin, editorCommands, editorReads, fitSlicePlacements, getActiveEditorTransaction, getActiveEditorUpdateId, getActiveEditorUpdateTags, getAuthoredUpdateView, getCaretOwner, getCarriedCaretEditor, getCompiledEditorSchema$1 as getCompiledEditorSchema, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates, getDocumentValueNode, getEditorAuthoredDocumentCapability$1 as getEditorAuthoredDocumentCapability, getEditorCommitNode, getEditorCommitSnapshot, getEditorCommitValue, getEditorDocumentShapeIssueMessage, getEditorRuntimeOwner, getEditorRuntimeRootKeys, getEditorUpdateRoot, getInstalledPlugin, getPluginContributions, getReaderRange, getRecordSetVersion, getSchemaElementSourceReference, getSelectionDOMRange, getSnapshotVersion, getTextSearchScope, getValueRecords, getViewAuthor, getViewPresentation$1 as getViewPresentation, holdsCaret, isAuthorId, isDocumentView, isEditorPublishingCommit, isEnvelopeInput$1 as isEnvelopeInput, isRuntimePlugin, landNodePropertiesAt, locateAt, mapDetachedSelectionThroughChange, mapSemanticUpdateMethodArguments, markRootViewUsed, normalizeSetValues, notifyObservers, placeElementAt, preserveCompiledSchemaPropertyIdentity, projectEditorView, property, readAuthoredView, readCaretViewIn, readDocumentRange, readDocumentRecord$1 as readDocumentRecord, readEditorSelection, readElementPropertyWrites, readPersistedEnvelope$1 as readPersistedEnvelope, readRecord, readRootEntries, readRootViewUse, readShownDocument, readShownRecords, readShownViewUse, readStoredEditorDocument, readViewPage, recordSetChanges, recordSetIds, registerEditorTransactionGuard, rejectEditorRecord, repairEditorValue, reportEditorLifecycleError$1 as reportEditorLifecycleError, runEditorObserver, sameResult, scheduleAfterCommitNotification, schema, setEditorStateViewTransform, setEditorTransactionViewTransform, setSelectionAsView, shouldMergeNodesRemovePrevNode, snapshotEditorJsonValue, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse, target, transfer, txLocate, txSelection, txStored, vetoesWrite, withDocumentViewRead, withEditorUpdateRootScope, withMountedPresentation, withStoredAuthoredRead, withTransactionSpecDraftRead };
|
|
@@ -104,16 +104,24 @@ const BaseBlockquotePlugin = definePlugin(PLUGINS.blockquote, {
|
|
|
104
104
|
shortcuts: { untab: { keys: "shift+tab" } },
|
|
105
105
|
update: ({ editor, plugin, tx, schema: { type } }) => ({
|
|
106
106
|
wrap: txLocate(locateAt(0), ({ at } = {}) => {
|
|
107
|
-
|
|
107
|
+
const runs = [];
|
|
108
|
+
for (const [node, path] of tx.nodes.blocks({ at })) {
|
|
108
109
|
if (node.type === type || tx.nodes.above({
|
|
109
110
|
at: path,
|
|
110
111
|
type: plugin
|
|
111
112
|
})) continue;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
const run = runs.at(-1);
|
|
114
|
+
const last = run?.at(-1);
|
|
115
|
+
if (run && last && PathApi.equals(PathApi.next(last), path)) run.push(path);
|
|
116
|
+
else runs.push([path]);
|
|
116
117
|
}
|
|
118
|
+
for (const run of runs.toReversed()) tx.nodes.wrap({
|
|
119
|
+
children: [],
|
|
120
|
+
type
|
|
121
|
+
}, {
|
|
122
|
+
at: PathApi.parent(run[0]),
|
|
123
|
+
match: (_node, path) => run.some((member) => PathApi.equals(member, path))
|
|
124
|
+
});
|
|
117
125
|
}),
|
|
118
126
|
toggle: () => tx.blocks.toggle({ type }, { wrap: true }),
|
|
119
127
|
untab: () => {
|