platejs 54.0.0-beta.2 → 54.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +113 -78
- package/dist/ai/react/CopilotPlugin.js +1 -1
- package/dist/ai/react/index.d.ts +23 -16
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/ai.md +4 -3
- package/dist/docs/api/core/plate-components.md +0 -19
- package/dist/docs/api/core/plate-controller.md +5 -3
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +11 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +45 -13
- package/dist/docs/authored-changes.md +9 -4
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +118 -10
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/comment.md +2 -2
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- package/dist/docs/editor.md +50 -4
- package/dist/docs/examples/editable-voids.md +2 -3
- package/dist/docs/external-text.md +2 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +9 -6
- package/dist/docs/form.md +2 -0
- package/dist/docs/heading.md +6 -0
- package/dist/docs/installation/manual.md +0 -4
- package/dist/docs/link.md +3 -3
- package/dist/docs/llms.txt +4 -2
- package/dist/docs/markdown.md +270 -14
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +66 -15
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/roots.md +8 -6
- package/dist/docs/rtl.md +6 -4
- package/dist/docs/selection.md +7 -4
- package/dist/docs/suggestion.md +1 -1
- package/dist/docs/toolbar.md +26 -30
- package/dist/docs/upload.md +106 -17
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/docxStaticComponents.js +12 -2
- package/dist/docx/export/lib/exportDocx.js +46 -17
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +52 -10
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -6
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -2
- package/dist/excalidraw/react/index.d.ts +3 -2
- package/dist/facade.js +2 -2
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
- package/dist/features/board/lib/boardStroke.internal.js +13 -1
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +3 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +33 -17
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -2
- package/dist/features/details/index.d.ts +3 -2
- package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +4 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +204 -0
- package/dist/features/find/index.d.ts +3 -2
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +229 -48
- package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
- package/dist/features/lint/index.d.ts +3 -2
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
- package/dist/features/mention/index.d.ts +5 -4
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +64 -15
- package/dist/features/table/lib/internal/selection.js +4 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
- package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
- package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
- package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
- package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
- package/dist/index-C9Fu-P4E.d.ts +773 -0
- package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
- package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
- package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
- package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
- package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
- package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
- package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
- package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
- package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
- package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
- package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
- package/dist/internal/plugin/OverridePlugin.js +101 -119
- package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/resolvePlugin.js +1 -1
- package/dist/internal/plugin/resolvePlugins.js +3 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/mergePlugins.js +1 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
- package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
- package/dist/lib/plugins/html/htmlSafety.js +1 -1
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +3 -1
- package/dist/markdown/lib/MarkdownPlugin.js +14 -11
- package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +776 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
- package/dist/markdown/lib/internal/markdownLine.js +5 -3
- package/dist/markdown/lib/internal/markdownMappings.js +19 -7
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +29 -9
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
- package/dist/math/index.d.ts +3 -2
- package/dist/math/react/index.d.ts +4 -3
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +42 -23
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +102 -128
- package/dist/react/components/PlateContainer.js +40 -32
- package/dist/react/components/PlateController.js +28 -16
- package/dist/react/components/PlateRoot.internal.js +3 -2
- package/dist/react/core.js +4 -4
- package/dist/react/features/board/BoardSurface.js +116 -87
- package/dist/react/features/board/boardClipboard.internal.js +15 -5
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +190 -50
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +108 -18
- package/dist/react/features/callout/index.d.ts +3 -2
- package/dist/react/features/combobox/index.d.ts +8 -8
- package/dist/react/features/comments/index.d.ts +6 -5
- package/dist/react/features/date/index.d.ts +4 -3
- package/dist/react/features/details/index.d.ts +4 -3
- package/dist/react/features/field/FieldPlugin.js +35 -0
- package/dist/react/features/field/index.d.ts +315 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/index.d.ts +7 -6
- package/dist/react/features/format-painter/index.d.ts +4 -3
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/index.d.ts +57 -33
- package/dist/react/features/ink/index.js +2 -2
- package/dist/react/features/ink/inkCapture.internal.js +39 -17
- package/dist/react/features/ink/inkInput.internal.js +1 -1
- package/dist/react/features/ink/inkLayout.internal.js +6 -3
- package/dist/react/features/ink/inkPaint.internal.js +78 -2
- package/dist/react/features/ink/inkPlacement.internal.js +332 -104
- package/dist/react/features/ink/inkWatch.internal.js +7 -5
- package/dist/react/features/layout/index.d.ts +5 -4
- package/dist/react/features/media/index.d.ts +5 -4
- package/dist/react/features/mention/index.d.ts +6 -5
- package/dist/react/features/resizable/Resizable.js +4 -6
- package/dist/react/features/resizable/index.d.ts +5 -5
- package/dist/react/features/suggestion/index.d.ts +6 -5
- package/dist/react/features/table/TablePlugin.js +4 -11
- package/dist/react/features/table/index.d.ts +10 -8
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +11 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +4 -4
- package/dist/react/internal/plate-context.js +434 -188
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
- package/dist/react/stores/plate/useEditor.js +32 -14
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +79 -21
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/utils/pipeRenderElement.internal.js +1 -1
- package/dist/react/utils/pluginRenderElement.internal.js +1 -1
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
- package/dist/static/index.d.ts +18 -18
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
- package/dist/static/internal/staticPresentation.js +4 -4
- package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +6 -6
- package/package.json +20 -2
- package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
- package/dist/react/components/EditorSelectionView.js +0 -40
- package/dist/react/features/ink/InkLayer.js +0 -218
- package/dist/react/internal/createPlateTargetScope.js +0 -62
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ElementApi } from "../../../facade.js";
|
|
1
|
+
import { ElementApi, getEditorRuntimeOwner } from "../../../facade.js";
|
|
2
2
|
import { DOMPlugin } from "../../../lib/plugins/dom/DOMPlugin.js";
|
|
3
3
|
import { useEditorRootElement } from "../../plite-react.js";
|
|
4
4
|
import { definePlugin } from "../../plugin/definePlugin.js";
|
|
5
5
|
import React from "react";
|
|
6
6
|
//#region src/react/plugins/navigation-feedback/NavigationFeedbackPlugin.ts
|
|
7
|
-
const
|
|
7
|
+
const feedbackByRoot = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
const isModelEditor = (editor) => getEditorRuntimeOwner(editor) === editor;
|
|
8
9
|
const emptySnapshot = () => null;
|
|
9
10
|
const publish = (state, target) => {
|
|
10
11
|
if (state.target === target) return;
|
|
@@ -24,8 +25,9 @@ const NavigationFeedbackPlugin = definePlugin("navigation", {
|
|
|
24
25
|
api: ({ editor, store }) => ({
|
|
25
26
|
/** Flash one live element in this mounted view without changing the document or selection. */
|
|
26
27
|
flashTarget: ({ key, attributes = {}, duration = store.get("duration") }) => {
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const root = isModelEditor(editor) ? null : editor.api.dom.root();
|
|
29
|
+
const state = root && feedbackByRoot.get(root);
|
|
30
|
+
if (!root || !state) return false;
|
|
29
31
|
const path = editor.read.nodes.path(key);
|
|
30
32
|
if (!path || !ElementApi.isElement(editor.read.nodes.get(path)?.[0])) return false;
|
|
31
33
|
if (!Number.isFinite(duration) || duration < 0) throw new RangeError("Flash duration must be a finite non-negative number.");
|
|
@@ -43,14 +45,15 @@ const NavigationFeedbackPlugin = definePlugin("navigation", {
|
|
|
43
45
|
pulse
|
|
44
46
|
}));
|
|
45
47
|
state.timeout = setTimeout(() => {
|
|
46
|
-
if (
|
|
48
|
+
if (feedbackByRoot.get(root) === state && state.target?.pulse === pulse) clear(state);
|
|
47
49
|
}, duration);
|
|
48
50
|
return true;
|
|
49
51
|
},
|
|
50
52
|
/** Clear this mounted view's feedback, returning whether a target was active. */
|
|
51
53
|
clear: () => {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
+
const root = isModelEditor(editor) ? null : editor.api.dom.root();
|
|
55
|
+
const state = root && feedbackByRoot.get(root);
|
|
56
|
+
if (!state) return false;
|
|
54
57
|
const hadTarget = state.target !== null;
|
|
55
58
|
clear(state);
|
|
56
59
|
return hadTarget;
|
|
@@ -62,20 +65,19 @@ const NavigationFeedbackPlugin = definePlugin("navigation", {
|
|
|
62
65
|
React.useLayoutEffect(() => {
|
|
63
66
|
if (!root) return void 0;
|
|
64
67
|
const next = {
|
|
65
|
-
root,
|
|
66
68
|
target: null,
|
|
67
69
|
pulse: 0,
|
|
68
70
|
timeout: null,
|
|
69
71
|
listeners: /* @__PURE__ */ new Set()
|
|
70
72
|
};
|
|
71
|
-
|
|
73
|
+
feedbackByRoot.set(root, next);
|
|
72
74
|
setState(next);
|
|
73
75
|
const unsubscribe = view.subscribeCommit(() => {
|
|
74
76
|
if (next.target && !view.read.nodes.path(next.target.key)) clear(next);
|
|
75
77
|
});
|
|
76
78
|
return () => {
|
|
77
79
|
unsubscribe();
|
|
78
|
-
if (
|
|
80
|
+
if (feedbackByRoot.get(root) === next) feedbackByRoot.delete(root);
|
|
79
81
|
next.listeners.clear();
|
|
80
82
|
clear(next);
|
|
81
83
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RangeApi } from "../../../facade.js";
|
|
2
|
-
import { useEditorRuntimeState } from "../../plite-react.js";
|
|
3
|
-
import {
|
|
2
|
+
import { useEditorRootElement, useEditorRuntimeState } from "../../plite-react.js";
|
|
3
|
+
import { PlateModelContext, outsideEveryProvider, readBoolean, subscribeNothing, usePickedRoot, usePlateScope, usePlateTarget, useTargetViewState } from "../../internal/plate-context.js";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
//#region src/react/stores/plate/useEditor.ts
|
|
@@ -14,46 +14,64 @@ function useEditor() {
|
|
|
14
14
|
}
|
|
15
15
|
/** Get the complete document editor owned by the nearest EditorRoot. */
|
|
16
16
|
function useModelEditor() {
|
|
17
|
-
const editor = React.
|
|
17
|
+
const editor = (usePickedRoot()?.model ?? React.use(PlateModelContext))?.editor;
|
|
18
18
|
if (!editor) throw new Error("useModelEditor() requires an active EditorRoot.");
|
|
19
19
|
return editor;
|
|
20
20
|
}
|
|
21
21
|
/** Get the provider's selected editor, or null when no editor is available. */
|
|
22
22
|
function useOptionalEditor() {
|
|
23
|
-
return
|
|
23
|
+
return usePlateTarget()?.editor ?? null;
|
|
24
24
|
}
|
|
25
25
|
/** Get the selected editor's application ID. */
|
|
26
26
|
const useEditorId = () => {
|
|
27
27
|
return useEditor().id;
|
|
28
28
|
};
|
|
29
|
+
const noEditorDOM = { api: { dom: {
|
|
30
|
+
editable: () => null,
|
|
31
|
+
root: () => null,
|
|
32
|
+
scroll: () => null
|
|
33
|
+
} } };
|
|
29
34
|
/** Whether the selected command view has a mounted editable. */
|
|
30
35
|
const useEditorMounted = () => {
|
|
31
|
-
|
|
36
|
+
const $ = c(4);
|
|
37
|
+
const { server } = usePlateScope();
|
|
38
|
+
const mounted = useEditorRootElement(useOptionalEditor() ?? noEditorDOM) != null;
|
|
39
|
+
let t0;
|
|
40
|
+
if ($[0] !== mounted) {
|
|
41
|
+
t0 = readBoolean(mounted);
|
|
42
|
+
$[0] = mounted;
|
|
43
|
+
$[1] = t0;
|
|
44
|
+
} else t0 = $[1];
|
|
45
|
+
const t1 = server?.mounted ?? false;
|
|
46
|
+
let t2;
|
|
47
|
+
if ($[2] !== t1) {
|
|
48
|
+
t2 = readBoolean(t1);
|
|
49
|
+
$[2] = t1;
|
|
50
|
+
$[3] = t2;
|
|
51
|
+
} else t2 = $[3];
|
|
52
|
+
return React.useSyncExternalStore(subscribeNothing, t0, t2);
|
|
32
53
|
};
|
|
33
54
|
/** Whether the selected command view is currently focused. */
|
|
34
55
|
const useEditorFocused = () => {
|
|
35
|
-
return
|
|
56
|
+
return useTargetViewState(usePlateTarget(), "focused", false);
|
|
36
57
|
};
|
|
37
58
|
/** Whether the selected command view is composing text. */
|
|
38
59
|
const useEditorComposing = () => {
|
|
39
|
-
return
|
|
60
|
+
return useTargetViewState(usePlateTarget(), "composing", false);
|
|
40
61
|
};
|
|
41
62
|
/** Whether the selected command view rejects editing, including after unmount. */
|
|
42
63
|
const useEditorReadOnly = () => {
|
|
43
|
-
return
|
|
64
|
+
return useTargetViewState(usePlateTarget(), "readOnly", usePlateScope() !== outsideEveryProvider);
|
|
44
65
|
};
|
|
45
66
|
/** Get the selected Plate container ref; its value is null before mount. */
|
|
46
67
|
function useEditorContainerRef() {
|
|
47
|
-
const target =
|
|
68
|
+
const target = usePlateTarget();
|
|
48
69
|
const emptyRef = React.useRef(null);
|
|
49
70
|
return target?.containerRef ?? emptyRef;
|
|
50
71
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the selected view's Editable ref; its value is null before mount. Inside
|
|
53
|
-
* `EditorSelectionView` it is the Editable of the view holding the selection.
|
|
54
|
-
*/
|
|
72
|
+
/** Get the selected view's Editable ref; its value is null before mount. */
|
|
55
73
|
function useEditableRef() {
|
|
56
|
-
const target =
|
|
74
|
+
const target = usePlateTarget();
|
|
57
75
|
const emptyRef = React.useRef(null);
|
|
58
76
|
return target?.editableRef ?? emptyRef;
|
|
59
77
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getViewPresentation } from "../../../facade.js";
|
|
2
|
+
import { useEditorHistory as useEditorHistory$1 } from "../../plite-react.js";
|
|
3
|
+
import { useOptionalEditorContext } from "../../internal/plite-components.js";
|
|
4
|
+
import { useOptionalEditor } from "./useEditor.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
//#region src/react/stores/plate/useEditorHistory.ts
|
|
7
|
+
/**
|
|
8
|
+
* Create undo/redo commands and keyboard handling.
|
|
9
|
+
*
|
|
10
|
+
* Without `editor` or `root`, while the editor `useEditor()` returns belongs to
|
|
11
|
+
* the `EditorRoot` around the hook, they run through that `EditorRoot`'s shown
|
|
12
|
+
* writable view used last, and are on only while a shown writable `Editable`
|
|
13
|
+
* reaches every root the next undo or redo changes. When no provider gives an
|
|
14
|
+
* editor, they do the same and need an `EditorRoot` around the hook.
|
|
15
|
+
* Otherwise, such as under `EditorController` or under an `EditorProvider`
|
|
16
|
+
* given another editor, they bind to that editor, as with `editor`. With
|
|
17
|
+
* `editor` or `root`, they replay the next batch whatever roots it changes.
|
|
18
|
+
* With `root`, they are off while no view of it is shown. With `editor`, they
|
|
19
|
+
* can stay on while no `Editable` runs that editor, and a click then does
|
|
20
|
+
* nothing. They are off while their view is read-only or composes text.
|
|
21
|
+
*/
|
|
22
|
+
function useEditorHistory(t0) {
|
|
23
|
+
const $ = c(9);
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[0] !== t0) {
|
|
26
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
27
|
+
$[0] = t0;
|
|
28
|
+
$[1] = t1;
|
|
29
|
+
} else t1 = $[1];
|
|
30
|
+
const options = t1;
|
|
31
|
+
const editor = useOptionalEditor();
|
|
32
|
+
const around = useOptionalEditorContext();
|
|
33
|
+
let t2;
|
|
34
|
+
if ($[2] !== around || $[3] !== editor) {
|
|
35
|
+
t2 = editor !== null && around !== null && getViewPresentation(editor) === getViewPresentation(around);
|
|
36
|
+
$[2] = around;
|
|
37
|
+
$[3] = editor;
|
|
38
|
+
$[4] = t2;
|
|
39
|
+
} else t2 = $[4];
|
|
40
|
+
const followsRoot = t2;
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[5] !== editor || $[6] !== followsRoot || $[7] !== options) {
|
|
43
|
+
t3 = options.editor || options.root || !editor || followsRoot ? options : {
|
|
44
|
+
editor,
|
|
45
|
+
focusPolicy: options.focusPolicy
|
|
46
|
+
};
|
|
47
|
+
$[5] = editor;
|
|
48
|
+
$[6] = followsRoot;
|
|
49
|
+
$[7] = options;
|
|
50
|
+
$[8] = t3;
|
|
51
|
+
} else t3 = $[8];
|
|
52
|
+
return useEditorHistory$1(t3);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useEditorHistory };
|
|
@@ -1,25 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { readShownPreview, runEditorObserver, sameResult } from "../../../facade.js";
|
|
2
|
+
import { subscribeAuthoredViewState, usePlateScope } from "../../internal/plate-context.js";
|
|
3
|
+
import React from "react";
|
|
4
4
|
//#region src/react/stores/plate/useEditorSelector.ts
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
const createSelection = () => {
|
|
6
|
+
let last;
|
|
7
|
+
let shouldUpdate;
|
|
8
|
+
return {
|
|
9
|
+
read: (editor, selector, equalityFn, shouldUpdateNow) => {
|
|
10
|
+
if (!editor) throw new Error("useEditor() requires an active Plate editor.");
|
|
11
|
+
shouldUpdate = shouldUpdateNow;
|
|
12
|
+
const version = editor.read.lastCommit()?.version;
|
|
13
|
+
const preview = readShownPreview(editor);
|
|
14
|
+
if (last?.editor !== editor || last.selector !== selector || last.version !== version || last.preview !== preview) {
|
|
15
|
+
const value = editor.read(() => selector(editor));
|
|
16
|
+
last = {
|
|
17
|
+
editor,
|
|
18
|
+
preview,
|
|
19
|
+
selector,
|
|
20
|
+
value: last && equalityFn(last.value, value) ? last.value : value,
|
|
21
|
+
version
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return last.value;
|
|
25
|
+
},
|
|
26
|
+
previewChanged: (editor) => last?.editor !== editor || last.preview !== readShownPreview(editor),
|
|
27
|
+
wants: (editor, change) => {
|
|
28
|
+
let wanted = true;
|
|
29
|
+
runEditorObserver(editor, "commit-listener", () => {
|
|
30
|
+
wanted = shouldUpdate?.(change) ?? true;
|
|
31
|
+
});
|
|
32
|
+
return wanted;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Subscribe to a value derived from the selected editor. A selector that
|
|
38
|
+
* keeps its identity between renders runs at most once per commit, once more
|
|
39
|
+
* when the selected editor changes, such as when the caret moves to another
|
|
40
|
+
* root, and once more when the editor shows a different review preview than
|
|
41
|
+
* the selector last read. A selector written inline gets a new identity each
|
|
42
|
+
* render, so it also runs on every render of its component. A change that
|
|
43
|
+
* leaves the value equal renders nothing.
|
|
44
|
+
*/
|
|
45
|
+
const useEditorSelector = (selector, options = {}) => {
|
|
46
|
+
const { equalityFn = sameResult, shouldUpdate } = options;
|
|
47
|
+
const scope = usePlateScope();
|
|
48
|
+
const [selection] = React.useState(createSelection);
|
|
49
|
+
const read = (editor) => selection.read(editor, selector, equalityFn, shouldUpdate);
|
|
50
|
+
return React.useSyncExternalStore(React.useCallback((listener) => {
|
|
51
|
+
let editor_0;
|
|
52
|
+
let stopCommits;
|
|
53
|
+
let stopView;
|
|
54
|
+
const follow = () => {
|
|
55
|
+
const next = scope.getSnapshot()?.editor;
|
|
56
|
+
if (next === editor_0) return;
|
|
57
|
+
stopCommits?.();
|
|
58
|
+
stopView?.();
|
|
59
|
+
stopCommits = void 0;
|
|
60
|
+
stopView = void 0;
|
|
61
|
+
editor_0 = next;
|
|
62
|
+
if (!next) return;
|
|
63
|
+
stopCommits = next.subscribeCommit((change) => {
|
|
64
|
+
if (selection.wants(next, change)) listener();
|
|
65
|
+
});
|
|
66
|
+
stopView = subscribeAuthoredViewState(next, () => {
|
|
67
|
+
if (selection.previewChanged(next)) listener();
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
follow();
|
|
71
|
+
const stopScope = scope.subscribe(() => {
|
|
72
|
+
follow();
|
|
73
|
+
listener();
|
|
74
|
+
});
|
|
75
|
+
return () => {
|
|
76
|
+
stopScope();
|
|
77
|
+
stopCommits?.();
|
|
78
|
+
stopView?.();
|
|
79
|
+
};
|
|
80
|
+
}, [scope, selection]), () => read(scope.getSnapshot()?.editor), () => read(scope.getServerSnapshot()?.editor));
|
|
23
81
|
};
|
|
24
82
|
//#endregion
|
|
25
83
|
export { useEditorSelector };
|
|
@@ -2,8 +2,10 @@ import { getCompiledPlatePlugin } from "../../internal/plugin/compilePlateModel.
|
|
|
2
2
|
import { ElementStatePlugin } from "../../lib/plugins/element-state/ElementStatePlugin.js";
|
|
3
3
|
import { PLUGINS } from "../../utils/plate-keys.js";
|
|
4
4
|
import { useEditorFocused, useEditorReadOnly, useEditorRuntimeState, useEditorViewState } from "../plite-react.js";
|
|
5
|
+
import { PlateEditorPlaceholderContext } from "../internal/plate-context.js";
|
|
5
6
|
import { useEditorPluginStore } from "../stores/plate/usePluginStore.js";
|
|
6
7
|
import { definePlugin } from "../plugin/definePlugin.js";
|
|
8
|
+
import React from "react";
|
|
7
9
|
//#region src/react/utils/BlockPlaceholderPlugin.tsx
|
|
8
10
|
const getBlockPlaceholderTarget = (editor, viewEditor, state, view) => {
|
|
9
11
|
if (view.readOnly || view.composing || !view.focused || !viewEditor.read.selection() || viewEditor.read.selection.isExpanded()) return null;
|
|
@@ -13,12 +15,12 @@ const getBlockPlaceholderTarget = (editor, viewEditor, state, view) => {
|
|
|
13
15
|
const children = viewEditor.read.children();
|
|
14
16
|
const firstNode = children[0];
|
|
15
17
|
if (!firstNode) return null;
|
|
16
|
-
const
|
|
18
|
+
const isEditorPlaceholderState = children.length === 1 && viewEditor.read.nodes.isEmpty(firstNode) && (view.hasEditorPlaceholder || editor.plugin(ElementStatePlugin).api.isEmpty(firstNode));
|
|
17
19
|
const placeholderPlugin = Object.keys(state.placeholders).find((name) => {
|
|
18
20
|
const descriptor = getCompiledPlatePlugin(editor, name);
|
|
19
21
|
return descriptor ? editor.plugin(descriptor).schema.type === node.type : false;
|
|
20
22
|
});
|
|
21
|
-
if (
|
|
23
|
+
if (isEditorPlaceholderState || !placeholderPlugin || !state.query({
|
|
22
24
|
editor,
|
|
23
25
|
node,
|
|
24
26
|
path,
|
|
@@ -43,6 +45,7 @@ const BlockPlaceholderPlugin = definePlugin(PLUGINS.blockPlaceholder, {
|
|
|
43
45
|
const view = {
|
|
44
46
|
composing: useEditorViewState(viewEditor, () => viewEditor.api.dom.isComposing()),
|
|
45
47
|
focused: useEditorFocused(),
|
|
48
|
+
hasEditorPlaceholder: React.use(PlateEditorPlaceholderContext),
|
|
46
49
|
readOnly: useEditorReadOnly()
|
|
47
50
|
};
|
|
48
51
|
const target = useEditorRuntimeState(viewEditor, () => getBlockPlaceholderTarget(editor, viewEditor, pluginState, view));
|
|
@@ -6,9 +6,9 @@ import { getPluginNodeClass } from "../../lib/utils/pluginNodeClass.js";
|
|
|
6
6
|
import { useEditorReadOnly } from "../plite-react.js";
|
|
7
7
|
import { useEditorContext } from "../internal/plite-components.js";
|
|
8
8
|
import { usePlateRenderContext } from "../internal/plate-context.js";
|
|
9
|
-
import { ElementProvider } from "../stores/element/useElementStore.js";
|
|
10
9
|
import { getElementNodeKey, usePlateRenderedAttributes } from "../internal/rendered-attributes.js";
|
|
11
10
|
import { createPluginContext } from "../plugin/createPluginContext.internal.js";
|
|
11
|
+
import { ElementProvider } from "../stores/element/useElementStore.js";
|
|
12
12
|
import { getDefaultElementTag } from "../../internal/plugin/defaultElementTag.js";
|
|
13
13
|
import { pipeInjectNodeProps } from "../../internal/plugin/pipeInjectNodeProps.js";
|
|
14
14
|
import { EditorElement, isHtmlVoidElementTag } from "../components/plate-nodes.js";
|
|
@@ -5,9 +5,9 @@ import { isEditOnly } from "../../internal/plugin/isEditOnlyDisabled.js";
|
|
|
5
5
|
import { useClaimEditableDOMCommit, useEditorReadOnly } from "../plite-react.js";
|
|
6
6
|
import { useEditorContext } from "../internal/plite-components.js";
|
|
7
7
|
import { useEditor } from "../stores/plate/useEditor.js";
|
|
8
|
-
import { ElementProvider } from "../stores/element/useElementStore.js";
|
|
9
8
|
import { getElementNodeKey, usePlateRenderedAttributes } from "../internal/rendered-attributes.js";
|
|
10
9
|
import { createPluginContext } from "../plugin/createPluginContext.internal.js";
|
|
10
|
+
import { ElementProvider } from "../stores/element/useElementStore.js";
|
|
11
11
|
import { getDefaultElementTag } from "../../internal/plugin/defaultElementTag.js";
|
|
12
12
|
import { EditorElement } from "../components/plate-nodes.js";
|
|
13
13
|
import { useRedrawWithBlock } from "../internal/block-redraws.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import React from "react";
|
|
1
|
+
import { Ci as Element, ws as RootKey } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import { Wn as EditableProps, _n as EditorContentProps } from "../index-DPowErHa.js";
|
|
3
|
+
import React$1 from "react";
|
|
4
4
|
type VirtualizedEditableProps<TElement extends Element = Element, TRoot extends RootKey = RootKey> = EditableProps<TElement, TRoot> & {
|
|
5
5
|
/** Estimated height in CSS pixels for an unmeasured top-level block. */
|
|
6
6
|
estimatedBlockSize?: number;
|
|
@@ -9,5 +9,5 @@ type VirtualizedEditableProps<TElement extends Element = Element, TRoot extends
|
|
|
9
9
|
};
|
|
10
10
|
type VirtualizedEditorContentProps<TElement extends Element = Element, TRoot extends RootKey = RootKey> = EditorContentProps<TElement, TRoot> & Pick<VirtualizedEditableProps<TElement, TRoot>, 'estimatedBlockSize' | 'overscan'>;
|
|
11
11
|
/** Render Plate content with explicit top-level viewport virtualization. */
|
|
12
|
-
declare const VirtualizedEditorContent: <TElement extends Element = Element, TRoot extends RootKey = RootKey>({ estimatedBlockSize, overscan, ...props }: VirtualizedEditorContentProps<TElement, TRoot>) => React.JSX.Element;
|
|
12
|
+
declare const VirtualizedEditorContent: <TElement extends Element = Element, TRoot extends RootKey = RootKey>({ estimatedBlockSize, overscan, ...props }: VirtualizedEditorContentProps<TElement, TRoot>) => React$1.JSX.Element;
|
|
13
13
|
export { VirtualizedEditorContent, VirtualizedEditorContentProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./core-
|
|
3
|
-
import "./index-
|
|
1
|
+
import { $a as Path, Zn as EditorSchemaRepairCode, m as AuthoredProjectionDiagnostic, ps as Range, su as Value, ws as RootKey } from "./index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "./core-BqR-fEDp.js";
|
|
3
|
+
import "./index-M781pyx9.js";
|
|
4
4
|
import "saxes";
|
|
5
5
|
type DocxImportLimits = Readonly<{
|
|
6
6
|
maxComments: number;
|
|
@@ -86,7 +86,7 @@ type DocxDiagnostic = AuthoredProjectionDiagnostic | Readonly<{
|
|
|
86
86
|
severity: 'warning';
|
|
87
87
|
}> | Readonly<{
|
|
88
88
|
code: 'property-dropped';
|
|
89
|
-
/** How many runs, paragraphs or
|
|
89
|
+
/** How many runs, paragraphs, cells or elements lost the property. */
|
|
90
90
|
count: number;
|
|
91
91
|
feature: string;
|
|
92
92
|
impact: 'lossy';
|
package/dist/static/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../htmlTypes-
|
|
3
|
-
import { Er as RenderTextProps,
|
|
4
|
-
import { n as EditorStaticProps, t as EditorStatic } from "../PlateStatic-
|
|
5
|
-
import "../index-
|
|
6
|
-
import React from "react";
|
|
1
|
+
import { $a as Path, Ci as Element, Qn as EditorSchemaSource, Tt as EditorDocumentValue, dl as Text, ji as ElementOf, m as AuthoredProjectionDiagnostic, wl as TextOf } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference, Er as RenderTextProps, Ha as AnyBasePluginDefinition, Jo as UnknownObject, Na as RenderElementProps, Va as InternalPluginDefinitionOf, Wa as BasePluginDefinition, kr as StaticRenderLeafProps, st as BasePluginInput, u as Editor, y as BasePluginContext } from "../core-BqR-fEDp.js";
|
|
4
|
+
import { n as EditorStaticProps, t as EditorStatic } from "../PlateStatic-D3Cb-QwH.js";
|
|
5
|
+
import "../index-M781pyx9.js";
|
|
6
|
+
import React$1 from "react";
|
|
7
7
|
type NodePropsDescriptor = EditorSchemaSource & PluginReference;
|
|
8
8
|
type ElementPropsNode<TPlugin extends NodePropsDescriptor> = Extract<ElementOf<TPlugin>, Element>;
|
|
9
9
|
type ElementPropsConfig<TPlugin extends NodePropsDescriptor> = InternalPluginDefinitionOf<TPlugin>;
|
|
@@ -17,32 +17,32 @@ type ElementRenderProps<N extends Element = Element, C extends AnyBasePluginDefi
|
|
|
17
17
|
type EditorElementProps<TPlugin extends NodePropsDescriptor> = TPlugin extends NodePropsDescriptor ? ElementRenderProps<ElementPropsNode<TPlugin>, ElementPropsConfig<TPlugin>> : never;
|
|
18
18
|
type EditorNodeProps<C extends AnyBasePluginDefinition = BasePluginDefinition> = Omit<BasePluginContext<C>, 'slots'> & {
|
|
19
19
|
/** Merged with `attributes.ref`. */
|
|
20
|
-
ref?: React.Ref<HTMLElement>;
|
|
20
|
+
ref?: React$1.Ref<HTMLElement>;
|
|
21
21
|
};
|
|
22
22
|
type EditorHTMLProps<C extends AnyBasePluginDefinition = BasePluginDefinition, T extends keyof HTMLElementTagNameMap = 'div'> = EditorNodeProps<C> & {
|
|
23
23
|
/** HTML attributes to pass to the underlying HTML element. */
|
|
24
|
-
attributes: React.PropsWithoutRef<React.JSX.IntrinsicElements[T]> & UnknownObject;
|
|
24
|
+
attributes: React$1.PropsWithoutRef<React$1.JSX.IntrinsicElements[T]> & UnknownObject;
|
|
25
25
|
as?: T;
|
|
26
26
|
/** Class to be merged with `attributes.className`. */
|
|
27
27
|
className?: string;
|
|
28
28
|
/** Style to be merged with `attributes.style`. */
|
|
29
|
-
style?: React.CSSProperties;
|
|
29
|
+
style?: React$1.CSSProperties;
|
|
30
30
|
};
|
|
31
31
|
declare const EditorElement: {
|
|
32
32
|
<N extends Element = Element, C extends AnyBasePluginDefinition = BasePluginDefinition, T extends keyof HTMLElementTagNameMap = 'div'>(props: Omit<RenderElementProps<N>, 'attributes'> & Pick<EditorNodeProps<C>, 'ref'> & {
|
|
33
|
-
attributes: React.PropsWithoutRef<React.JSX.IntrinsicElements[T]> & UnknownObject;
|
|
33
|
+
attributes: React$1.PropsWithoutRef<React$1.JSX.IntrinsicElements[T]> & UnknownObject;
|
|
34
34
|
as?: T;
|
|
35
35
|
className?: string;
|
|
36
36
|
path: Path;
|
|
37
|
-
style?: React.CSSProperties;
|
|
38
|
-
}): React.ReactElement;
|
|
37
|
+
style?: React$1.CSSProperties;
|
|
38
|
+
}): React$1.ReactElement;
|
|
39
39
|
<T extends keyof HTMLElementTagNameMap = 'div'>(props: Omit<RenderElementProps, 'attributes'> & Pick<EditorNodeProps<never>, 'ref'> & {
|
|
40
|
-
attributes: React.PropsWithoutRef<React.JSX.IntrinsicElements[T]> & UnknownObject;
|
|
40
|
+
attributes: React$1.PropsWithoutRef<React$1.JSX.IntrinsicElements[T]> & UnknownObject;
|
|
41
41
|
as?: T;
|
|
42
42
|
className?: string;
|
|
43
43
|
path: Path;
|
|
44
|
-
style?: React.CSSProperties;
|
|
45
|
-
}): React.ReactElement;
|
|
44
|
+
style?: React$1.CSSProperties;
|
|
45
|
+
}): React$1.ReactElement;
|
|
46
46
|
};
|
|
47
47
|
/** Props for the static text component owned by a plugin descriptor. */
|
|
48
48
|
type EditorTextProps<TPlugin extends NodePropsDescriptor> = TPlugin extends NodePropsDescriptor ? EditorNodeProps<TextPropsConfig<TPlugin>> & RenderTextProps<TextPropsNode<TPlugin>> & {
|
|
@@ -50,7 +50,7 @@ type EditorTextProps<TPlugin extends NodePropsDescriptor> = TPlugin extends Node
|
|
|
50
50
|
} : never;
|
|
51
51
|
declare const EditorText: <N extends Text = Text, C extends AnyBasePluginDefinition = BasePluginDefinition, T extends keyof HTMLElementTagNameMap = 'span'>(props: (EditorNodeProps<C> & RenderTextProps<N> & {
|
|
52
52
|
attributes: UnknownObject;
|
|
53
|
-
}) & EditorHTMLProps<C, T>) => React.ReactElement;
|
|
53
|
+
}) & EditorHTMLProps<C, T>) => React$1.ReactElement;
|
|
54
54
|
type LeafRenderProps<N extends Text = Text, C extends AnyBasePluginDefinition = BasePluginDefinition> = EditorNodeProps<C> & StaticRenderLeafProps<N, N> & {
|
|
55
55
|
attributes: UnknownObject;
|
|
56
56
|
inset?: boolean;
|
|
@@ -60,7 +60,7 @@ type EditorLeafProps<TPlugin extends NodePropsDescriptor> = TPlugin extends Node
|
|
|
60
60
|
declare const EditorLeaf: <N extends Text = Text, C extends AnyBasePluginDefinition = BasePluginDefinition, T extends keyof HTMLElementTagNameMap = 'span'>({ className, ...props }: (EditorNodeProps<C> & StaticRenderLeafProps<N, N> & {
|
|
61
61
|
attributes: UnknownObject;
|
|
62
62
|
inset?: boolean;
|
|
63
|
-
}) & EditorHTMLProps<C, T>) => React.ReactElement;
|
|
63
|
+
}) & EditorHTMLProps<C, T>) => React$1.ReactElement;
|
|
64
64
|
type StaticHtmlDiagnostic = AuthoredProjectionDiagnostic | Readonly<{
|
|
65
65
|
code: 'missing-static-presentation';
|
|
66
66
|
message: string;
|
|
@@ -77,7 +77,7 @@ type StaticHtmlResult = Readonly<{
|
|
|
77
77
|
}>;
|
|
78
78
|
type RenderStaticHtmlOptions<T extends EditorStaticProps = EditorStaticProps> = {
|
|
79
79
|
/** Component used to render the captured document. */
|
|
80
|
-
component?: React.ComponentType<T>;
|
|
80
|
+
component?: React$1.ComponentType<T>;
|
|
81
81
|
/** Complete document to render. Defaults to the editor's current document. */
|
|
82
82
|
document?: EditorDocumentValue;
|
|
83
83
|
/**
|
|
@@ -21,7 +21,7 @@ const renderStaticHtmlWithOverrides = async (editor, { component: Component = Ed
|
|
|
21
21
|
}));
|
|
22
22
|
return Object.freeze({
|
|
23
23
|
data: html,
|
|
24
|
-
diagnostics: Object.freeze([...projected.diagnostics, ...Array.from(missing, (plugin) => Object.freeze({
|
|
24
|
+
diagnostics: Object.freeze([...projected.diagnostics, ...Array.from(missing.keys(), (plugin) => Object.freeze({
|
|
25
25
|
code: "missing-static-presentation",
|
|
26
26
|
message: `Plugin "${plugin}" has no drawing in the presentation, so its content was drawn without it.`,
|
|
27
27
|
plugin,
|
|
@@ -30,4 +30,4 @@ const renderStaticHtmlWithOverrides = async (editor, { component: Component = Ed
|
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
//#endregion
|
|
33
|
-
export { renderStaticHtmlWithOverrides };
|
|
33
|
+
export { loadStaticRenderer, renderStaticHtmlWithOverrides };
|
|
@@ -15,11 +15,11 @@ const compilePeers = (plugins) => {
|
|
|
15
15
|
return peers;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Returns the
|
|
19
|
-
* the presentation lacked.
|
|
18
|
+
* Returns the map that rendering fills from the name of each plugin whose
|
|
19
|
+
* drawing the presentation lacked to the features it lacked, render or slots.
|
|
20
20
|
*/
|
|
21
21
|
const bindStaticPresentation = (editor, { overrides, plugins }) => {
|
|
22
|
-
const missing = /* @__PURE__ */ new
|
|
22
|
+
const missing = /* @__PURE__ */ new Map();
|
|
23
23
|
if (overrides || plugins) PRESENTATIONS.set(editor, {
|
|
24
24
|
...overrides,
|
|
25
25
|
missing,
|
|
@@ -43,7 +43,7 @@ const resolveDrawing = (editor, plugin, feature, read, readInstalled = read) =>
|
|
|
43
43
|
const drawing = peer ? read(peer) ?? void 0 : void 0;
|
|
44
44
|
if (drawing !== void 0) return drawing;
|
|
45
45
|
if (!isComponent(readInstalled(plugin))) return own;
|
|
46
|
-
presentation.missing.
|
|
46
|
+
presentation.missing.set(plugin.name, (presentation.missing.get(plugin.name) ?? /* @__PURE__ */ new Set()).add(feature));
|
|
47
47
|
};
|
|
48
48
|
const getStaticElementComponent = (editor, plugin) => PRESENTATIONS.get(editor)?.components?.[plugin.name] ?? resolveDrawing(editor, plugin, "render", ({ component }) => component);
|
|
49
49
|
const getStaticMarkComponent = (editor, plugin, placement) => resolveDrawing(editor, plugin, "render", ({ component, render }) => placement === "text" ? component : render.mark?.leafComponent ?? (render.mark?.placement === "text" ? void 0 : component));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContentSlice, MAIN_ROOT_KEY, PathApi, SelectionApi, TextApi, projectEditorView } from "../../facade.js";
|
|
2
|
-
import { readDOMSelectionRange } from "../../dom/plite-dom.internal.js";
|
|
2
|
+
import { cleanDOMClipboardContents, readDOMSelectionRange } from "../../dom/plite-dom.internal.js";
|
|
3
3
|
import { getPlainText } from "./getPlainText.js";
|
|
4
4
|
import { exportContentSlice } from "plitejs/internal";
|
|
5
5
|
//#region src/static/internal/writeStaticSelectionClipboardData.ts
|
|
@@ -195,10 +195,15 @@ const getStaticSelectionPayload = (editor, host) => {
|
|
|
195
195
|
textNode.nodeValue = textNode.nodeValue?.replaceAll(sentinelToken, "") ?? "";
|
|
196
196
|
textNode = textWalker.nextNode();
|
|
197
197
|
}
|
|
198
|
+
const text = getPlainText(htmlContainer);
|
|
199
|
+
htmlContainer.querySelectorAll("[data-editor-string]").forEach((marker) => {
|
|
200
|
+
if (marker.textContent === "") marker.textContent = "";
|
|
201
|
+
});
|
|
202
|
+
cleanDOMClipboardContents(htmlContainer);
|
|
198
203
|
return {
|
|
199
204
|
html: htmlContainer.innerHTML,
|
|
200
205
|
slice: exportContentSlice(editor, assembled),
|
|
201
|
-
text
|
|
206
|
+
text
|
|
202
207
|
};
|
|
203
208
|
};
|
|
204
209
|
const writeStaticSelectionClipboardData = (editor, data, host) => {
|
package/dist/tabbable/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TabbableEventContext, r as TabbablePluginState, t as TabbableEntry } from "../index-
|
|
1
|
+
import { n as TabbableEventContext, r as TabbablePluginState, t as TabbableEntry } from "../index-B8QJDAmG.js";
|
|
2
2
|
export { TabbableEntry, TabbableEventContext, TabbablePluginState };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { At as Plugin } from "../../index-
|
|
3
|
-
import { n as TabbableEventContext, t as TabbableEntry } from "../../index-
|
|
1
|
+
import { qa as DefinitionOf } from "../../core-BqR-fEDp.js";
|
|
2
|
+
import { At as Plugin } from "../../index-DPowErHa.js";
|
|
3
|
+
import { n as TabbableEventContext, t as TabbableEntry } from "../../index-B8QJDAmG.js";
|
|
4
4
|
declare const TabbablePlugin: Plugin<Readonly<{
|
|
5
5
|
readonly name: "tabbable";
|
|
6
6
|
readonly initialState: {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
1
|
+
import { $u as setEditorFocused, Bu as isEditor, Ci as Element, Cu as deleteBackward, El as TextSelection, Fc as Selection, Fu as getSnapshot, Gu as positions, H as Descendant, Iu as insertBreak, Ji as Location, Ju as replace, Lu as insertText, Nu as getLiveSelection, Pu as getSelection, Uu as move, Y as Editor, dl as Text, f as AnyEditor, fu as before$1, ju as getChildren, ld as unhangRange, nd as string, ps as Range, qo as Point, su as Value, uu as after$1, wu as deleteForward, zu as isBlock } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import { i as createEditor, o as createHyperscript } from "../index-Dq3Jlj8O-BJ6NxZm0.js";
|
|
3
3
|
declare const createDataTransfer: (dataMap?: Map<string, string>) => DataTransfer;
|
|
4
4
|
type TestEditorFixture = {
|
|
5
5
|
children: Element[];
|
|
@@ -172,4 +172,4 @@ declare const hjsx: typeof jsx;
|
|
|
172
172
|
declare const end: (editor: AnyEditor, at: Location) => Point;
|
|
173
173
|
/** The editable element property `installBrowserHandle()` sets. */
|
|
174
174
|
declare const BROWSER_HANDLE_KEY = "__EDITOR_BROWSER_HANDLE__";
|
|
175
|
-
export { BROWSER_HANDLE_KEY, TestEditor, TestEditorFixture, after, before, createDataTransfer, createEditor, createEditorFromFixture, createHyperscript, deleteBackward, deleteForward, elements, end, getChildren, getLiveSelection as getEditorLiveSelection, getSelection, getSnapshot, hjsx, insertBreak, insertText, isBlock, isEditor, jsx, jsxt, move, positions, projectTestSelectionRange, replace, setEditorFocused, string, unhangRange, voidChildren };
|
|
175
|
+
export { BROWSER_HANDLE_KEY, TestEditor, TestEditorFixture, after$1 as after, before$1 as before, createDataTransfer, createEditor, createEditorFromFixture, createHyperscript, deleteBackward, deleteForward, elements, end, getChildren, getLiveSelection as getEditorLiveSelection, getSelection, getSnapshot, hjsx, insertBreak, insertText, isBlock, isEditor, jsx, jsxt, move, positions, projectTestSelectionRange, replace, setEditorFocused, string, unhangRange, voidChildren };
|
package/dist/yjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as YjsPluginOptions, d as YjsRemoteCursorData, f as YjsUpdatePolicy, i as YjsAwarenessState, n as YjsAwarenessChange, o as YjsCursorDataSchema, p as yjs, r as YjsAwarenessLike, s as YjsInitialReadiness, t as YjsAdmissionStatus, u as YjsRemoteCursor } from "../index-B7moSod7.js";
|
|
2
2
|
export { type YjsAdmissionStatus, type YjsAwarenessChange, type YjsAwarenessLike, type YjsAwarenessState, type YjsCursorDataSchema, type YjsInitialReadiness, type YjsPluginOptions, type YjsRemoteCursor, type YjsRemoteCursorData, YjsUpdatePolicy, yjs };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../htmlTypes-
|
|
3
|
-
import {
|
|
4
|
-
import { At as Plugin, Ct as InternalPluginAuthorStageInput,
|
|
5
|
-
import { a as
|
|
1
|
+
import { Ca as NodeKey, Co as PluginFactoryTypeProviderOf, I as DecorationRefresh, pa as NodeEntry, x as BaseRange, xo as PluginFactoryTypeLambda$1 } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference, Ha as AnyBasePluginDefinition, Po as PluginSelectors, V as InternalBasePluginRuntimeExtension, Va as InternalPluginDefinitionOf } from "../../core-BqR-fEDp.js";
|
|
4
|
+
import { At as Plugin, Ct as InternalPluginAuthorStageInput, Nt as PluginContext, St as InternalPluginAuthorStageCompatibility, Tt as InternalPluginAuthorState, Wt as Shortcuts, Xr as RangeGeometry, cn as InternalReactPluginAdapterResult, wt as InternalPluginAuthorStageKeys, xt as InternalPluginAuthorExtension } from "../../index-DPowErHa.js";
|
|
5
|
+
import { a as YjsBaseApi, c as YjsPluginOptions, d as YjsRemoteCursorData, f as YjsUpdatePolicy, i as YjsAwarenessState, l as YjsPresenceApi, n as YjsAwarenessChange, o as YjsCursorDataSchema, p as yjs, r as YjsAwarenessLike, s as YjsInitialReadiness, t as YjsAdmissionStatus, u as YjsRemoteCursor } from "../../index-B7moSod7.js";
|
|
6
6
|
import { RefObject } from "react";
|
|
7
7
|
import "yjs";
|
|
8
8
|
type YjsCursorDataForApi<TApi> = TApi extends YjsPresenceApi<infer TCursorData> ? TCursorData : YjsRemoteCursorData;
|
|
@@ -90,5 +90,5 @@ interface YjsPluginFactoryType {
|
|
|
90
90
|
readonly output: PlateYjsPlugin<this['input']>;
|
|
91
91
|
}
|
|
92
92
|
/** Creates complete Plate Yjs descriptors from app-owned resources. */
|
|
93
|
-
declare const YjsPlugin: PluginFactory<YjsPluginFactoryType, YjsPluginOptions
|
|
93
|
+
declare const YjsPlugin: PluginFactory<YjsPluginFactoryType, YjsPluginOptions<Readonly<Record<string, unknown>>>>;
|
|
94
94
|
export { type YjsAdmissionStatus, type YjsAwarenessChange, type YjsAwarenessLike, type YjsAwarenessState, type YjsCursorDataSchema, type YjsInitialReadiness, YjsPlugin, type YjsPluginOptions, type YjsRemoteCursor, type YjsRemoteCursorData, YjsUpdatePolicy, useYjsAdmissionStatus, useYjsRemoteCursor, useYjsRemoteCursorGeometry, useYjsRemoteCursorIds, yjs };
|