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,54 +1,436 @@
|
|
|
1
|
-
import { markRootViewUsed, readRootViewUse,
|
|
1
|
+
import { getCarriedCaretEditor, getEditorRuntimeOwner, getViewPresentation, markRootViewUsed, notifyObservers, readCaretViewIn, readRootViewUse, readShownViewUse, subscribeCaretTarget, subscribeEditorViewState, subscribeShownViewUse } from "../../facade.js";
|
|
2
|
+
import { failInvariant } from "../../internal/failInvariant.js";
|
|
2
3
|
import { getEditorDOMRoot } from "../../dom/plite-dom.internal.js";
|
|
3
|
-
import { useEditorRootElement
|
|
4
|
+
import { useEditorRootElement } from "../plite-react.js";
|
|
4
5
|
import { trackEditableFocus } from "../stores/plate-controller/document-focus.internal.js";
|
|
5
|
-
import { createPlateTargetScope } from "./createPlateTargetScope.js";
|
|
6
6
|
import { useEditorContext, useOptionalEditorContext } from "./plite-components.js";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
9
9
|
//#region src/react/internal/plate-context.tsx
|
|
10
|
-
const
|
|
10
|
+
const stopNothing = () => {};
|
|
11
|
+
const subscribeNothing = () => stopNothing;
|
|
12
|
+
const readNothing = () => null;
|
|
13
|
+
const readTrue = () => true;
|
|
14
|
+
const readFalse = () => false;
|
|
15
|
+
const readBoolean = (value) => value ? readTrue : readFalse;
|
|
16
|
+
const readViewFact = {
|
|
17
|
+
composing: (editor) => editor.read.view.isComposing(),
|
|
18
|
+
focused: (editor) => editor.read.view.isFocused(),
|
|
19
|
+
readOnly: (editor) => editor.read.view.isReadOnly()
|
|
20
|
+
};
|
|
21
|
+
const readServerFacts = ({ editor }) => ({
|
|
22
|
+
composing: readViewFact.composing(editor),
|
|
23
|
+
focused: readViewFact.focused(editor),
|
|
24
|
+
mounted: editor.api.dom.root() != null,
|
|
25
|
+
readOnly: readViewFact.readOnly(editor)
|
|
26
|
+
});
|
|
27
|
+
const noTarget = {
|
|
28
|
+
fixed: null,
|
|
29
|
+
getServerSnapshot: readNothing,
|
|
30
|
+
getSnapshot: readNothing,
|
|
31
|
+
server: null,
|
|
32
|
+
subscribe: subscribeNothing
|
|
33
|
+
};
|
|
34
|
+
const useFixedScope = (target) => {
|
|
35
|
+
const $ = c(8);
|
|
36
|
+
let t0;
|
|
37
|
+
if ($[0] !== target) {
|
|
38
|
+
t0 = () => target && readServerFacts(target);
|
|
39
|
+
$[0] = target;
|
|
40
|
+
$[1] = t0;
|
|
41
|
+
} else t0 = $[1];
|
|
42
|
+
const [server] = React.useState(t0);
|
|
43
|
+
let t1;
|
|
44
|
+
bb0: {
|
|
45
|
+
if (!target) {
|
|
46
|
+
t1 = noTarget;
|
|
47
|
+
break bb0;
|
|
48
|
+
}
|
|
49
|
+
let t2;
|
|
50
|
+
if ($[2] !== target) {
|
|
51
|
+
t2 = () => target;
|
|
52
|
+
$[2] = target;
|
|
53
|
+
$[3] = t2;
|
|
54
|
+
} else t2 = $[3];
|
|
55
|
+
const read = t2;
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[4] !== read || $[5] !== server || $[6] !== target) {
|
|
58
|
+
t3 = {
|
|
59
|
+
fixed: target,
|
|
60
|
+
getServerSnapshot: read,
|
|
61
|
+
getSnapshot: read,
|
|
62
|
+
server,
|
|
63
|
+
subscribe: subscribeNothing
|
|
64
|
+
};
|
|
65
|
+
$[4] = read;
|
|
66
|
+
$[5] = server;
|
|
67
|
+
$[6] = target;
|
|
68
|
+
$[7] = t3;
|
|
69
|
+
} else t3 = $[7];
|
|
70
|
+
t1 = t3;
|
|
71
|
+
}
|
|
72
|
+
return t1;
|
|
73
|
+
};
|
|
74
|
+
const createAreaViews = () => {
|
|
75
|
+
const views = /* @__PURE__ */ new Set();
|
|
76
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
77
|
+
const changed = () => listeners.forEach((listener) => listener());
|
|
78
|
+
return {
|
|
79
|
+
hold(view) {
|
|
80
|
+
views.add(view);
|
|
81
|
+
changed();
|
|
82
|
+
return () => {
|
|
83
|
+
views.delete(view);
|
|
84
|
+
changed();
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
subscribe(listener) {
|
|
88
|
+
listeners.add(listener);
|
|
89
|
+
return () => {
|
|
90
|
+
listeners.delete(listener);
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
usedLast() {
|
|
94
|
+
let latest = null;
|
|
95
|
+
for (const view of views) if (!latest || readRootViewUse(view.editor) > readRootViewUse(latest.editor)) latest = view;
|
|
96
|
+
return latest;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const useAreaScope = (around) => {
|
|
101
|
+
const $ = c(13);
|
|
102
|
+
const [views] = React.useState(createAreaViews);
|
|
103
|
+
const model = React.use(PlateModelContext);
|
|
104
|
+
let t0;
|
|
105
|
+
if ($[0] !== around || $[1] !== views) {
|
|
106
|
+
t0 = () => views.usedLast() ?? around.getSnapshot();
|
|
107
|
+
$[0] = around;
|
|
108
|
+
$[1] = views;
|
|
109
|
+
$[2] = t0;
|
|
110
|
+
} else t0 = $[2];
|
|
111
|
+
let t1;
|
|
112
|
+
if ($[3] !== around || $[4] !== model || $[5] !== views) {
|
|
113
|
+
t1 = (listener) => {
|
|
114
|
+
const stops = [
|
|
115
|
+
views.subscribe(listener),
|
|
116
|
+
around.subscribe(listener),
|
|
117
|
+
model ? subscribeShownViewUse(getEditorRuntimeOwner(model.editor), listener) : stopNothing
|
|
118
|
+
];
|
|
119
|
+
return () => stops.forEach(_temp);
|
|
120
|
+
};
|
|
121
|
+
$[3] = around;
|
|
122
|
+
$[4] = model;
|
|
123
|
+
$[5] = views;
|
|
124
|
+
$[6] = t1;
|
|
125
|
+
} else t1 = $[6];
|
|
126
|
+
let t2;
|
|
127
|
+
if ($[7] !== around.getServerSnapshot || $[8] !== around.server || $[9] !== t0 || $[10] !== t1 || $[11] !== views) {
|
|
128
|
+
t2 = {
|
|
129
|
+
getServerSnapshot: around.getServerSnapshot,
|
|
130
|
+
getSnapshot: t0,
|
|
131
|
+
server: around.server,
|
|
132
|
+
subscribe: t1,
|
|
133
|
+
views
|
|
134
|
+
};
|
|
135
|
+
$[7] = around.getServerSnapshot;
|
|
136
|
+
$[8] = around.server;
|
|
137
|
+
$[9] = t0;
|
|
138
|
+
$[10] = t1;
|
|
139
|
+
$[11] = views;
|
|
140
|
+
$[12] = t2;
|
|
141
|
+
} else t2 = $[12];
|
|
142
|
+
return t2;
|
|
143
|
+
};
|
|
144
|
+
const outsideEveryProvider = {
|
|
145
|
+
fixed: null,
|
|
146
|
+
getServerSnapshot: readNothing,
|
|
147
|
+
getSnapshot: readNothing,
|
|
148
|
+
server: null,
|
|
149
|
+
subscribe: subscribeNothing
|
|
150
|
+
};
|
|
11
151
|
const targets = /* @__PURE__ */ new WeakMap();
|
|
12
152
|
const getPlateTarget = (editor) => targets.get(editor);
|
|
13
|
-
const
|
|
14
|
-
|
|
153
|
+
const targetOf = (editor, containerRef) => {
|
|
154
|
+
let target = targets.get(editor);
|
|
155
|
+
if (!target) {
|
|
156
|
+
target = {
|
|
157
|
+
editor,
|
|
158
|
+
containerRef,
|
|
159
|
+
editableRef: { get current() {
|
|
160
|
+
return editor.api.dom.editable();
|
|
161
|
+
} }
|
|
162
|
+
};
|
|
163
|
+
targets.set(editor, target);
|
|
164
|
+
}
|
|
165
|
+
return target;
|
|
166
|
+
};
|
|
167
|
+
const createCaretScope = (view, containerRef) => {
|
|
168
|
+
const getSnapshot = () => targetOf(getCarriedCaretEditor(view) ?? failInvariant("Expected a mounted editor root"), containerRef);
|
|
169
|
+
const first = getSnapshot();
|
|
170
|
+
return {
|
|
171
|
+
getServerSnapshot: () => first,
|
|
172
|
+
getSnapshot,
|
|
173
|
+
server: readServerFacts(first),
|
|
174
|
+
subscribe: (listener) => subscribeCaretTarget(getEditorRuntimeOwner(view), listener)
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
const createCaretSlotScope = (own) => {
|
|
178
|
+
const owner = getEditorRuntimeOwner(own.editor);
|
|
179
|
+
return {
|
|
180
|
+
getServerSnapshot: () => own,
|
|
181
|
+
getSnapshot: () => {
|
|
182
|
+
const view = readCaretViewIn(own.editor);
|
|
183
|
+
return view && view !== own.editor ? targetOf(view, own.containerRef) : own;
|
|
184
|
+
},
|
|
185
|
+
server: readServerFacts(own),
|
|
186
|
+
subscribe: (listener) => {
|
|
187
|
+
const stops = [subscribeCaretTarget(owner, listener), subscribeShownViewUse(owner, listener)];
|
|
188
|
+
return () => stops.forEach((stop) => stop());
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const PlateScopeContext = React.createContext(outsideEveryProvider);
|
|
15
193
|
const PlateModelContext = React.createContext(null);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
194
|
+
const PlateReadOnlyContext = React.createContext(false);
|
|
195
|
+
const PlateEditorPlaceholderContext = React.createContext(false);
|
|
196
|
+
const createPlateController = () => {
|
|
197
|
+
const primaryOf = /* @__PURE__ */ new Map();
|
|
198
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
199
|
+
const notify = () => listeners.forEach((listener) => listener());
|
|
200
|
+
const pickLastUsedRoot = () => {
|
|
201
|
+
let picked = null;
|
|
202
|
+
let pickedAt = 0;
|
|
203
|
+
for (const [entry, isPrimary] of primaryOf) {
|
|
204
|
+
const usedAt = readShownViewUse(getEditorRuntimeOwner(entry.rootView), getViewPresentation(entry.rootView));
|
|
205
|
+
if (usedAt === null) continue;
|
|
206
|
+
if (usedAt > pickedAt) {
|
|
207
|
+
picked = entry;
|
|
208
|
+
pickedAt = usedAt;
|
|
209
|
+
} else if (!picked && isPrimary) picked = entry;
|
|
210
|
+
}
|
|
211
|
+
return picked;
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
getSnapshot: pickLastUsedRoot,
|
|
215
|
+
join(entry, isPrimary) {
|
|
216
|
+
primaryOf.set(entry, isPrimary);
|
|
217
|
+
const stop = subscribeShownViewUse(getEditorRuntimeOwner(entry.rootView), notify);
|
|
218
|
+
notify();
|
|
219
|
+
return () => {
|
|
220
|
+
stop();
|
|
221
|
+
primaryOf.delete(entry);
|
|
222
|
+
notify();
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
subscribe: (listener) => {
|
|
226
|
+
listeners.add(listener);
|
|
227
|
+
return () => {
|
|
228
|
+
listeners.delete(listener);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
const PlateControllerContext = React.createContext(null);
|
|
234
|
+
const PlatePickedContext = React.createContext(null);
|
|
235
|
+
const underController = { ...noTarget };
|
|
236
|
+
const usePickedRoot = () => React.use(PlateScopeContext) === underController ? React.use(PlatePickedContext) : null;
|
|
237
|
+
const usePlateScope = () => {
|
|
238
|
+
return usePickedRoot()?.scope ?? React.use(PlateScopeContext);
|
|
239
|
+
};
|
|
22
240
|
function usePlateModel() {
|
|
23
241
|
const model = React.useContext(PlateModelContext);
|
|
24
242
|
if (!model) throw new Error("EditorContent requires an EditorRoot.");
|
|
25
243
|
return model;
|
|
26
244
|
}
|
|
245
|
+
const useScopeTarget = (scope) => {
|
|
246
|
+
return React.useSyncExternalStore(scope.subscribe, scope.getSnapshot, scope.getServerSnapshot);
|
|
247
|
+
};
|
|
248
|
+
const usePlateTarget = () => {
|
|
249
|
+
return useScopeTarget(usePlateScope());
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Give an `EditorRoot`'s children outside every editing area the editor of the
|
|
253
|
+
* caret's root, and join the controller around the `EditorRoot` with it.
|
|
254
|
+
*/
|
|
255
|
+
function PlateCaretScope(t0) {
|
|
256
|
+
const $ = c(15);
|
|
257
|
+
const { children, primary } = t0;
|
|
258
|
+
const model = usePlateModel();
|
|
259
|
+
const view = useEditorContext();
|
|
260
|
+
let t1;
|
|
261
|
+
if ($[0] !== model.containerRef || $[1] !== view) {
|
|
262
|
+
t1 = createCaretScope(view, model.containerRef);
|
|
263
|
+
$[0] = model.containerRef;
|
|
264
|
+
$[1] = view;
|
|
265
|
+
$[2] = t1;
|
|
266
|
+
} else t1 = $[2];
|
|
267
|
+
let t2;
|
|
268
|
+
if ($[3] !== model || $[4] !== t1 || $[5] !== view) {
|
|
269
|
+
t2 = {
|
|
270
|
+
model,
|
|
271
|
+
scope: t1,
|
|
272
|
+
rootView: view
|
|
273
|
+
};
|
|
274
|
+
$[3] = model;
|
|
275
|
+
$[4] = t1;
|
|
276
|
+
$[5] = view;
|
|
277
|
+
$[6] = t2;
|
|
278
|
+
} else t2 = $[6];
|
|
279
|
+
const outside = t2;
|
|
280
|
+
const controller = React.use(PlateControllerContext);
|
|
281
|
+
let t3;
|
|
282
|
+
let t4;
|
|
283
|
+
if ($[7] !== controller || $[8] !== outside || $[9] !== primary) {
|
|
284
|
+
t3 = () => controller?.join(outside, primary);
|
|
285
|
+
t4 = [
|
|
286
|
+
controller,
|
|
287
|
+
outside,
|
|
288
|
+
primary
|
|
289
|
+
];
|
|
290
|
+
$[7] = controller;
|
|
291
|
+
$[8] = outside;
|
|
292
|
+
$[9] = primary;
|
|
293
|
+
$[10] = t3;
|
|
294
|
+
$[11] = t4;
|
|
295
|
+
} else {
|
|
296
|
+
t3 = $[10];
|
|
297
|
+
t4 = $[11];
|
|
298
|
+
}
|
|
299
|
+
React.useLayoutEffect(t3, t4);
|
|
300
|
+
let t5;
|
|
301
|
+
if ($[12] !== children || $[13] !== outside.scope) {
|
|
302
|
+
t5 = /* @__PURE__ */ React.createElement(PlateScopeContext, { value: outside.scope }, children);
|
|
303
|
+
$[12] = children;
|
|
304
|
+
$[13] = outside.scope;
|
|
305
|
+
$[14] = t5;
|
|
306
|
+
} else t5 = $[14];
|
|
307
|
+
return t5;
|
|
308
|
+
}
|
|
309
|
+
function PlateCaretSlots(t0) {
|
|
310
|
+
const $ = c(10);
|
|
311
|
+
const { slots } = t0;
|
|
312
|
+
const own = React.use(PlateScopeContext).fixed ?? failInvariant("Expected a mounted editing area");
|
|
313
|
+
let t1;
|
|
314
|
+
if ($[0] !== own) {
|
|
315
|
+
t1 = createCaretSlotScope(own);
|
|
316
|
+
$[0] = own;
|
|
317
|
+
$[1] = t1;
|
|
318
|
+
} else t1 = $[1];
|
|
319
|
+
const scope = t1;
|
|
320
|
+
const target = React.useSyncExternalStore(scope.subscribe, scope.getSnapshot, scope.getServerSnapshot);
|
|
321
|
+
let t2;
|
|
322
|
+
if ($[2] !== slots || $[3] !== target) {
|
|
323
|
+
let t3;
|
|
324
|
+
if ($[5] !== target) {
|
|
325
|
+
t3 = (t4) => {
|
|
326
|
+
const { Caret, name } = t4;
|
|
327
|
+
return /* @__PURE__ */ React.createElement(Caret, {
|
|
328
|
+
editableRef: target.editableRef,
|
|
329
|
+
key: name
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
$[5] = target;
|
|
333
|
+
$[6] = t3;
|
|
334
|
+
} else t3 = $[6];
|
|
335
|
+
t2 = slots.map(t3);
|
|
336
|
+
$[2] = slots;
|
|
337
|
+
$[3] = target;
|
|
338
|
+
$[4] = t2;
|
|
339
|
+
} else t2 = $[4];
|
|
340
|
+
let t3;
|
|
341
|
+
if ($[7] !== scope || $[8] !== t2) {
|
|
342
|
+
t3 = /* @__PURE__ */ React.createElement(PlateScopeContext, { value: scope }, t2);
|
|
343
|
+
$[7] = scope;
|
|
344
|
+
$[8] = t2;
|
|
345
|
+
$[9] = t3;
|
|
346
|
+
} else t3 = $[9];
|
|
347
|
+
return t3;
|
|
348
|
+
}
|
|
349
|
+
const viewStateReaders = /* @__PURE__ */ new WeakMap();
|
|
350
|
+
const subscribeSharedViewState = (editor, heard, listener) => {
|
|
351
|
+
let readers = viewStateReaders.get(editor);
|
|
352
|
+
if (!readers) {
|
|
353
|
+
const any = /* @__PURE__ */ new Set();
|
|
354
|
+
const authored = /* @__PURE__ */ new Set();
|
|
355
|
+
const notifyAll = (listeners) => notifyObservers(editor, listeners, "commit-listener", (notify) => notify());
|
|
356
|
+
readers = {
|
|
357
|
+
any,
|
|
358
|
+
authored,
|
|
359
|
+
stop: subscribeEditorViewState(editor, (change) => {
|
|
360
|
+
notifyAll(any);
|
|
361
|
+
if (change !== "authored") return;
|
|
362
|
+
notifyAll(authored);
|
|
363
|
+
})
|
|
364
|
+
};
|
|
365
|
+
viewStateReaders.set(editor, readers);
|
|
366
|
+
}
|
|
367
|
+
const shared = readers;
|
|
368
|
+
const listeners = shared[heard];
|
|
369
|
+
const registration = () => listener();
|
|
370
|
+
listeners.add(registration);
|
|
371
|
+
return () => {
|
|
372
|
+
if (!listeners.delete(registration)) return;
|
|
373
|
+
if (shared.any.size > 0 || shared.authored.size > 0) return;
|
|
374
|
+
shared.stop();
|
|
375
|
+
viewStateReaders.delete(editor);
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
const subscribeAuthoredViewState = (editor, listener) => subscribeSharedViewState(editor, "authored", listener);
|
|
379
|
+
const useTargetViewState = (target, fact, withoutEditor) => {
|
|
380
|
+
const $ = c(8);
|
|
381
|
+
const { server } = usePlateScope();
|
|
382
|
+
const editor = target?.editor;
|
|
383
|
+
let t0;
|
|
384
|
+
if ($[0] !== editor || $[1] !== fact || $[2] !== withoutEditor) {
|
|
385
|
+
t0 = () => editor ? readViewFact[fact](editor) : withoutEditor;
|
|
386
|
+
$[0] = editor;
|
|
387
|
+
$[1] = fact;
|
|
388
|
+
$[2] = withoutEditor;
|
|
389
|
+
$[3] = t0;
|
|
390
|
+
} else t0 = $[3];
|
|
391
|
+
const readFact = t0;
|
|
392
|
+
let t1;
|
|
393
|
+
if ($[4] !== editor) {
|
|
394
|
+
t1 = (listener) => editor ? subscribeSharedViewState(editor, "any", listener) : stopNothing;
|
|
395
|
+
$[4] = editor;
|
|
396
|
+
$[5] = t1;
|
|
397
|
+
} else t1 = $[5];
|
|
398
|
+
const t2 = t1;
|
|
399
|
+
const t3 = server?.[fact] ?? withoutEditor;
|
|
400
|
+
let t4;
|
|
401
|
+
if ($[6] !== t3) {
|
|
402
|
+
t4 = readBoolean(t3);
|
|
403
|
+
$[6] = t3;
|
|
404
|
+
$[7] = t4;
|
|
405
|
+
} else t4 = $[7];
|
|
406
|
+
return React.useSyncExternalStore(t2, readFact, t4);
|
|
407
|
+
};
|
|
27
408
|
/** Bind node renderers to the native view that owns their snapshot. */
|
|
28
409
|
function usePlateRenderContext(fallbackEditor) {
|
|
29
410
|
const $ = c(11);
|
|
30
411
|
const nativeEditor = useOptionalEditorContext();
|
|
31
412
|
const editor = nativeEditor ?? fallbackEditor;
|
|
32
|
-
const inherited = React.useContext(
|
|
413
|
+
const inherited = React.useContext(PlateScopeContext).fixed ?? null;
|
|
33
414
|
const emptyRef = React.useRef(null);
|
|
34
415
|
let t0;
|
|
35
|
-
if ($[0] !== editor || $[1] !== inherited) {
|
|
36
|
-
t0 = inherited?.editor === editor ?
|
|
416
|
+
if ($[0] !== editor || $[1] !== inherited?.containerRef || $[2] !== inherited?.editor) {
|
|
417
|
+
t0 = inherited?.editor === editor ? null : {
|
|
37
418
|
editor,
|
|
38
419
|
containerRef: inherited?.containerRef ?? emptyRef,
|
|
39
420
|
editableRef: emptyRef
|
|
40
421
|
};
|
|
41
422
|
$[0] = editor;
|
|
42
|
-
$[1] = inherited;
|
|
43
|
-
$[2] =
|
|
44
|
-
|
|
423
|
+
$[1] = inherited?.containerRef;
|
|
424
|
+
$[2] = inherited?.editor;
|
|
425
|
+
$[3] = t0;
|
|
426
|
+
} else t0 = $[3];
|
|
45
427
|
const target = t0;
|
|
428
|
+
const scope = useFixedScope(target);
|
|
46
429
|
let t1;
|
|
47
|
-
if ($[
|
|
48
|
-
t1 = (children) => !nativeEditor ||
|
|
49
|
-
$[
|
|
50
|
-
$[
|
|
51
|
-
$[5] = nativeEditor;
|
|
430
|
+
if ($[4] !== nativeEditor || $[5] !== scope || $[6] !== target) {
|
|
431
|
+
t1 = (children) => !nativeEditor || !target ? children : /* @__PURE__ */ React.createElement(PlateScopeContext, { value: scope }, children);
|
|
432
|
+
$[4] = nativeEditor;
|
|
433
|
+
$[5] = scope;
|
|
52
434
|
$[6] = target;
|
|
53
435
|
$[7] = t1;
|
|
54
436
|
} else t1 = $[7];
|
|
@@ -64,117 +446,13 @@ function usePlateRenderContext(fallbackEditor) {
|
|
|
64
446
|
} else t2 = $[10];
|
|
65
447
|
return t2;
|
|
66
448
|
}
|
|
67
|
-
function PlateTargetProvider(t0) {
|
|
68
|
-
const $ = c(15);
|
|
69
|
-
const { children, readOnly, target } = t0;
|
|
70
|
-
const [snapshot, setSnapshot] = React.useState(null);
|
|
71
|
-
let t1;
|
|
72
|
-
if ($[0] !== snapshot || $[1] !== target) {
|
|
73
|
-
t1 = snapshot?.target === target ? snapshot.facts : {
|
|
74
|
-
composing: target?.editor.read.view.isComposing() ?? false,
|
|
75
|
-
focused: target?.editor.read.view.isFocused() ?? false,
|
|
76
|
-
mounted: target?.editor.api.dom.root() != null,
|
|
77
|
-
readOnly: target?.editor.read.view.isReadOnly() ?? true
|
|
78
|
-
};
|
|
79
|
-
$[0] = snapshot;
|
|
80
|
-
$[1] = target;
|
|
81
|
-
$[2] = t1;
|
|
82
|
-
} else t1 = $[2];
|
|
83
|
-
const observedFacts = t1;
|
|
84
|
-
let t2;
|
|
85
|
-
if ($[3] !== observedFacts || $[4] !== readOnly) {
|
|
86
|
-
t2 = readOnly === void 0 ? observedFacts : {
|
|
87
|
-
...observedFacts,
|
|
88
|
-
readOnly
|
|
89
|
-
};
|
|
90
|
-
$[3] = observedFacts;
|
|
91
|
-
$[4] = readOnly;
|
|
92
|
-
$[5] = t2;
|
|
93
|
-
} else t2 = $[5];
|
|
94
|
-
const facts = t2;
|
|
95
|
-
let t3;
|
|
96
|
-
if ($[6] !== target) {
|
|
97
|
-
t3 = target && /* @__PURE__ */ React.createElement(PlateTargetFacts, {
|
|
98
|
-
target,
|
|
99
|
-
onChange: setSnapshot
|
|
100
|
-
});
|
|
101
|
-
$[6] = target;
|
|
102
|
-
$[7] = t3;
|
|
103
|
-
} else t3 = $[7];
|
|
104
|
-
let t4;
|
|
105
|
-
if ($[8] !== children || $[9] !== facts || $[10] !== t3) {
|
|
106
|
-
t4 = /* @__PURE__ */ React.createElement(PlateViewFactsContext, { value: facts }, t3, children);
|
|
107
|
-
$[8] = children;
|
|
108
|
-
$[9] = facts;
|
|
109
|
-
$[10] = t3;
|
|
110
|
-
$[11] = t4;
|
|
111
|
-
} else t4 = $[11];
|
|
112
|
-
let t5;
|
|
113
|
-
if ($[12] !== t4 || $[13] !== target) {
|
|
114
|
-
t5 = /* @__PURE__ */ React.createElement(PlateEditorContext, { value: target }, t4);
|
|
115
|
-
$[12] = t4;
|
|
116
|
-
$[13] = target;
|
|
117
|
-
$[14] = t5;
|
|
118
|
-
} else t5 = $[14];
|
|
119
|
-
return t5;
|
|
120
|
-
}
|
|
121
|
-
function PlateTargetFacts(t0) {
|
|
122
|
-
const $ = c(6);
|
|
123
|
-
const { onChange, target } = t0;
|
|
124
|
-
const facts = useEditorViewState(target.editor, _temp);
|
|
125
|
-
const element = useEditorRootElement(target.editor);
|
|
126
|
-
let t1;
|
|
127
|
-
let t2;
|
|
128
|
-
if ($[0] !== element || $[1] !== facts || $[2] !== onChange || $[3] !== target) {
|
|
129
|
-
t1 = () => {
|
|
130
|
-
onChange({
|
|
131
|
-
target,
|
|
132
|
-
facts: {
|
|
133
|
-
...facts,
|
|
134
|
-
mounted: element !== null
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
t2 = [
|
|
139
|
-
element,
|
|
140
|
-
facts,
|
|
141
|
-
onChange,
|
|
142
|
-
target
|
|
143
|
-
];
|
|
144
|
-
$[0] = element;
|
|
145
|
-
$[1] = facts;
|
|
146
|
-
$[2] = onChange;
|
|
147
|
-
$[3] = target;
|
|
148
|
-
$[4] = t1;
|
|
149
|
-
$[5] = t2;
|
|
150
|
-
} else {
|
|
151
|
-
t1 = $[4];
|
|
152
|
-
t2 = $[5];
|
|
153
|
-
}
|
|
154
|
-
React.useLayoutEffect(t1, t2);
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
function _temp(view) {
|
|
158
|
-
return {
|
|
159
|
-
composing: view.isComposing(),
|
|
160
|
-
focused: view.isFocused(),
|
|
161
|
-
readOnly: view.isReadOnly()
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function PlateScopeProvider({ children, fallback = null, fallbackReadOnly, scope }) {
|
|
165
|
-
const target = React.useSyncExternalStore(scope.subscribe, scope.getSnapshot, () => null);
|
|
166
|
-
return /* @__PURE__ */ React.createElement(PlateTargetProvider, {
|
|
167
|
-
target: target ?? fallback,
|
|
168
|
-
readOnly: target ? void 0 : fallbackReadOnly
|
|
169
|
-
}, children);
|
|
170
|
-
}
|
|
171
449
|
function PlateMountedView(t0) {
|
|
172
|
-
const $ = c(
|
|
450
|
+
const $ = c(16);
|
|
173
451
|
const { children, editableRef } = t0;
|
|
174
452
|
const model = usePlateModel();
|
|
175
453
|
const editor = useEditorContext();
|
|
176
454
|
const element = useEditorRootElement(editor);
|
|
177
|
-
const
|
|
455
|
+
const area = React.useContext(PlateScopeContext).views;
|
|
178
456
|
let value;
|
|
179
457
|
if ($[0] !== editableRef || $[1] !== editor || $[2] !== model.containerRef) {
|
|
180
458
|
value = {
|
|
@@ -189,82 +467,50 @@ function PlateMountedView(t0) {
|
|
|
189
467
|
$[3] = value;
|
|
190
468
|
} else value = $[3];
|
|
191
469
|
const target = value;
|
|
192
|
-
const
|
|
470
|
+
const scope = useFixedScope(target);
|
|
193
471
|
let t1;
|
|
194
|
-
if ($[4] !==
|
|
472
|
+
if ($[4] !== area || $[5] !== editor || $[6] !== target) {
|
|
195
473
|
t1 = () => {
|
|
196
474
|
const root = getEditorDOMRoot(editor);
|
|
197
475
|
if (!root) return;
|
|
198
|
-
const
|
|
199
|
-
const removeController = controller?.register(target, false);
|
|
200
|
-
const removeUse = subscribeRootViewUse(editor, () => {
|
|
201
|
-
model.scope.used(target);
|
|
202
|
-
controller?.used(target);
|
|
203
|
-
});
|
|
476
|
+
const release = area?.hold(target);
|
|
204
477
|
const removeFocus = trackEditableFocus(root, () => markRootViewUsed(editor));
|
|
205
478
|
return () => {
|
|
206
479
|
removeFocus();
|
|
207
|
-
|
|
208
|
-
removeController?.();
|
|
209
|
-
removeLocal();
|
|
480
|
+
release?.();
|
|
210
481
|
};
|
|
211
482
|
};
|
|
212
|
-
$[4] =
|
|
483
|
+
$[4] = area;
|
|
213
484
|
$[5] = editor;
|
|
214
|
-
$[6] =
|
|
215
|
-
$[7] =
|
|
216
|
-
|
|
217
|
-
} else t1 = $[8];
|
|
485
|
+
$[6] = target;
|
|
486
|
+
$[7] = t1;
|
|
487
|
+
} else t1 = $[7];
|
|
218
488
|
let t2;
|
|
219
|
-
if ($[
|
|
489
|
+
if ($[8] !== area || $[9] !== editor || $[10] !== element || $[11] !== target) {
|
|
220
490
|
t2 = [
|
|
221
|
-
|
|
491
|
+
area,
|
|
222
492
|
editor,
|
|
223
493
|
element,
|
|
224
|
-
model.scope,
|
|
225
494
|
target
|
|
226
495
|
];
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
|
|
233
|
-
} else t2 = $[14];
|
|
496
|
+
$[8] = area;
|
|
497
|
+
$[9] = editor;
|
|
498
|
+
$[10] = element;
|
|
499
|
+
$[11] = target;
|
|
500
|
+
$[12] = t2;
|
|
501
|
+
} else t2 = $[12];
|
|
234
502
|
React.useLayoutEffect(t1, t2);
|
|
235
503
|
let t3;
|
|
236
|
-
if ($[
|
|
237
|
-
t3 = (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
$[15] =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if ($[19] !== controller || $[20] !== element || $[21] !== primary || $[22] !== target) {
|
|
247
|
-
t4 = [
|
|
248
|
-
controller,
|
|
249
|
-
element,
|
|
250
|
-
primary,
|
|
251
|
-
target
|
|
252
|
-
];
|
|
253
|
-
$[19] = controller;
|
|
254
|
-
$[20] = element;
|
|
255
|
-
$[21] = primary;
|
|
256
|
-
$[22] = target;
|
|
257
|
-
$[23] = t4;
|
|
258
|
-
} else t4 = $[23];
|
|
259
|
-
React.useLayoutEffect(t3, t4);
|
|
260
|
-
let t5;
|
|
261
|
-
if ($[24] !== children || $[25] !== target) {
|
|
262
|
-
t5 = /* @__PURE__ */ React.createElement(PlateTargetProvider, { target }, children);
|
|
263
|
-
$[24] = children;
|
|
264
|
-
$[25] = target;
|
|
265
|
-
$[26] = t5;
|
|
266
|
-
} else t5 = $[26];
|
|
267
|
-
return t5;
|
|
504
|
+
if ($[13] !== children || $[14] !== scope) {
|
|
505
|
+
t3 = /* @__PURE__ */ React.createElement(PlateScopeContext, { value: scope }, children);
|
|
506
|
+
$[13] = children;
|
|
507
|
+
$[14] = scope;
|
|
508
|
+
$[15] = t3;
|
|
509
|
+
} else t3 = $[15];
|
|
510
|
+
return t3;
|
|
511
|
+
}
|
|
512
|
+
function _temp(stop) {
|
|
513
|
+
return stop();
|
|
268
514
|
}
|
|
269
515
|
//#endregion
|
|
270
|
-
export { PlateControllerContext,
|
|
516
|
+
export { PlateCaretScope, PlateCaretSlots, PlateControllerContext, PlateEditorPlaceholderContext, PlateModelContext, PlateMountedView, PlatePickedContext, PlateReadOnlyContext, PlateScopeContext, createPlateController, getPlateTarget, outsideEveryProvider, readBoolean, subscribeAuthoredViewState, subscribeNothing, underController, useAreaScope, useFixedScope, usePickedRoot, usePlateModel, usePlateRenderContext, usePlateScope, usePlateTarget, useScopeTarget, useTargetViewState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EditorReadOnlyProvider, ReactUpdatePolicy, installBrowserHandle, react, setDOMTextSyncRendererCapability, setRetainedTextFlowRendererCapability, useAnnotation, useAnnotationStore, useAnnotations, useChildRoot, useClaimEditableDOMCommit, useContentRoot, useDropIndicator, useEditableClip, useEditorEditableElement, useEditorFocused, useEditorHistory, useEditorReadOnly, useEditorRootElement, useEditorRuntimeState, useEditorScrollElement, useEditorScrollElementRef, useEditorViewState, useElementPath, useElementSelected, useNodeSelector, useOptionalEditorReadOnly, useRootChrome, useRootEditor, useRootState, useRuntimeState, useSelectionGeometry,
|
|
2
|
-
export { EditorReadOnlyProvider, ReactUpdatePolicy, installBrowserHandle, react, setDOMTextSyncRendererCapability, setRetainedTextFlowRendererCapability, useAnnotation, useAnnotationStore, useAnnotations, useChildRoot, useClaimEditableDOMCommit, useContentRoot, useDropIndicator, useEditableClip, useEditorEditableElement, useEditorFocused, useEditorHistory, useEditorReadOnly, useEditorRootElement, useEditorRuntimeState, useEditorScrollElement, useEditorScrollElementRef, useEditorViewState, useElementPath, useElementSelected, useNodeSelector, useOptionalEditorReadOnly, useRootChrome, useRootEditor, useRootState, useRuntimeState, useSelectionGeometry,
|
|
1
|
+
import { EditorReadOnlyProvider, ReactUpdatePolicy, installBrowserHandle, react, setDOMTextSyncRendererCapability, setRetainedTextFlowRendererCapability, useAnnotation, useAnnotationStore, useAnnotations, useChildRoot, useClaimEditableDOMCommit, useContentRoot, useDropIndicator, useEditableClip, useEditorEditableElement, useEditorFocused, useEditorHistory, useEditorReadOnly, useEditorRootElement, useEditorRuntimeState, useEditorScrollElement, useEditorScrollElementRef, useEditorViewState, useElementPath, useElementSelected, useNodeSelector, useOptionalEditorReadOnly, useRootChrome, useRootEditor, useRootState, useRuntimeState, useSelectionGeometry, useSetStateField, useStateFieldValue } from "plitejs/react";
|
|
2
|
+
export { EditorReadOnlyProvider, ReactUpdatePolicy, installBrowserHandle, react, setDOMTextSyncRendererCapability, setRetainedTextFlowRendererCapability, useAnnotation, useAnnotationStore, useAnnotations, useChildRoot, useClaimEditableDOMCommit, useContentRoot, useDropIndicator, useEditableClip, useEditorEditableElement, useEditorFocused, useEditorHistory, useEditorReadOnly, useEditorRootElement, useEditorRuntimeState, useEditorScrollElement, useEditorScrollElementRef, useEditorViewState, useElementPath, useElementSelected, useNodeSelector, useOptionalEditorReadOnly, useRootChrome, useRootEditor, useRootState, useRuntimeState, useSelectionGeometry, useSetStateField, useStateFieldValue };
|