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,16 +1,180 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElementApi, MAIN_ROOT_KEY, getActiveEditorUpdateId, getDocumentValueNode, getEditorCommitNode, getEditorCommitValue, getEditorRuntimeOwner, getRecordSetVersion, getSnapshotVersion, getValueRecords, readElementById, readShownDocument, readShownRecords, recordSetChanges, withStoredAuthoredRead } from "../../../facade.js";
|
|
2
|
+
import { COPIES, GONE, MARKS, besideAt, goneIn, idOf, reachGone, walkGone } from "./inkGone.internal.js";
|
|
2
3
|
import { inkText } from "./inkMatch.internal.js";
|
|
3
4
|
//#region src/features/ink/lib/inkPlaces.internal.ts
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const committed = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const shownPlaces = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const metrics = {
|
|
8
|
+
chains: 0,
|
|
9
|
+
holders: 0,
|
|
10
|
+
hops: 0,
|
|
11
|
+
reads: 0,
|
|
12
|
+
resolved: 0
|
|
13
|
+
};
|
|
14
|
+
const work = {
|
|
15
|
+
copies: 0,
|
|
16
|
+
directions: 0,
|
|
17
|
+
groups: 0,
|
|
18
|
+
members: 0,
|
|
19
|
+
signs: 0
|
|
20
|
+
};
|
|
21
|
+
const emptyPlaces = (schema) => ({
|
|
22
|
+
blockOfKey: /* @__PURE__ */ new Map(),
|
|
23
|
+
blocks: /* @__PURE__ */ new Map(),
|
|
24
|
+
chainEnds: {
|
|
25
|
+
next: /* @__PURE__ */ new Map(),
|
|
26
|
+
previous: /* @__PURE__ */ new Map()
|
|
27
|
+
},
|
|
28
|
+
changed: /* @__PURE__ */ new Set(),
|
|
29
|
+
copies: /* @__PURE__ */ new Map(),
|
|
30
|
+
groups: /* @__PURE__ */ new Map(),
|
|
31
|
+
held: /* @__PURE__ */ new Map(),
|
|
32
|
+
identity: schema.identity(),
|
|
33
|
+
schema,
|
|
34
|
+
signs: /* @__PURE__ */ new Map(),
|
|
35
|
+
stale: /* @__PURE__ */ new Map(),
|
|
36
|
+
walked: /* @__PURE__ */ new Set()
|
|
37
|
+
});
|
|
38
|
+
const START = {
|
|
39
|
+
beside: { at: "start" },
|
|
40
|
+
kind: "gone"
|
|
41
|
+
};
|
|
42
|
+
const beside = (side, key) => ({
|
|
43
|
+
beside: {
|
|
44
|
+
at: side === "previous" ? "after" : "before",
|
|
45
|
+
key
|
|
46
|
+
},
|
|
47
|
+
kind: "gone"
|
|
48
|
+
});
|
|
49
|
+
const keyOf = (place) => place.kind !== "gone" ? `on:${place.key}` : place.beside.at === "start" ? "start" : `${place.beside.at}:${place.beside.key}`;
|
|
50
|
+
const byMark = (a, b) => a.at - b.at || (a.id < b.id ? -1 : 1);
|
|
51
|
+
const size = (of) => of.marks.ltr.length + of.marks.rtl.length + of.pending.size;
|
|
52
|
+
const touch = (places) => {
|
|
53
|
+
places.deleted = void 0;
|
|
54
|
+
work.groups += 1;
|
|
55
|
+
};
|
|
56
|
+
const groupAt = (places, place, anchor) => {
|
|
57
|
+
let group = places.groups.get(keyOf(place));
|
|
58
|
+
if (!group) {
|
|
59
|
+
group = {
|
|
60
|
+
anchor,
|
|
61
|
+
blocks: /* @__PURE__ */ new Set(),
|
|
62
|
+
ids: {
|
|
63
|
+
ltr: [],
|
|
64
|
+
rtl: []
|
|
65
|
+
},
|
|
66
|
+
marks: {
|
|
67
|
+
ltr: [],
|
|
68
|
+
rtl: []
|
|
69
|
+
},
|
|
70
|
+
members: /* @__PURE__ */ new Map(),
|
|
71
|
+
pending: /* @__PURE__ */ new Map(),
|
|
72
|
+
place,
|
|
73
|
+
sign: {
|
|
74
|
+
place,
|
|
75
|
+
state: "deleted"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
places.groups.set(keyOf(place), group);
|
|
79
|
+
touch(places);
|
|
80
|
+
}
|
|
81
|
+
return group;
|
|
82
|
+
};
|
|
83
|
+
const pend = (places, kept, joins = true) => {
|
|
84
|
+
kept.group?.pending.set(kept.mark.id, {
|
|
85
|
+
joins,
|
|
86
|
+
mark: kept.mark
|
|
13
87
|
});
|
|
88
|
+
if (kept.group) places.changed.add(kept.group);
|
|
89
|
+
places.deleted = void 0;
|
|
90
|
+
};
|
|
91
|
+
const dropSign = (places, mark) => {
|
|
92
|
+
const kept = places.signs.get(mark);
|
|
93
|
+
for (const { block } of kept?.copies ?? []) places.blocks.get(block)?.signed.delete(mark);
|
|
94
|
+
if (!kept) return;
|
|
95
|
+
pend(places, kept, false);
|
|
96
|
+
places.signs.delete(mark);
|
|
97
|
+
places.stale.set(mark, kept.mark);
|
|
98
|
+
};
|
|
99
|
+
const dissolve = (places, from, into) => {
|
|
100
|
+
const key = keyOf(from.place);
|
|
101
|
+
if (places.groups.get(key) === from) places.groups.delete(key);
|
|
102
|
+
places.changed.delete(from);
|
|
103
|
+
touch(places);
|
|
104
|
+
for (const id of from.blocks) {
|
|
105
|
+
const block = places.blocks.get(id);
|
|
106
|
+
into?.blocks.add(id);
|
|
107
|
+
if (block?.group === from) block.group = into;
|
|
108
|
+
}
|
|
109
|
+
for (const id of [...[...from.marks.ltr, ...from.marks.rtl].map((mark) => mark.id), ...from.pending.keys()]) {
|
|
110
|
+
const kept = places.signs.get(id);
|
|
111
|
+
if (kept?.group !== from) continue;
|
|
112
|
+
kept.group = into;
|
|
113
|
+
if (into) pend(places, kept);
|
|
114
|
+
else dropSign(places, id);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const moveGroup = (places, group, place, anchor) => {
|
|
118
|
+
const there = places.groups.get(keyOf(place));
|
|
119
|
+
places.groups.delete(keyOf(group.place));
|
|
120
|
+
touch(places);
|
|
121
|
+
Object.assign(group, {
|
|
122
|
+
anchor,
|
|
123
|
+
place,
|
|
124
|
+
sign: {
|
|
125
|
+
place,
|
|
126
|
+
state: "deleted"
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
const merges = there !== void 0 && size(there) >= size(group);
|
|
130
|
+
const into = merges ? there : group;
|
|
131
|
+
places.groups.set(keyOf(place), into);
|
|
132
|
+
if (there) dissolve(places, merges ? group : there, into);
|
|
133
|
+
};
|
|
134
|
+
const holderIn = (state, id) => {
|
|
135
|
+
metrics.holders += 1;
|
|
136
|
+
const entry = readElementById(state.nodes, id);
|
|
137
|
+
return entry ? {
|
|
138
|
+
key: entry.key,
|
|
139
|
+
node: entry.node,
|
|
140
|
+
root: entry.root ?? MAIN_ROOT_KEY
|
|
141
|
+
} : void 0;
|
|
142
|
+
};
|
|
143
|
+
const keptHolderIn = (commit, holder) => {
|
|
144
|
+
const [node] = holder && getEditorCommitNode(commit, holder.key, holder.root) || [];
|
|
145
|
+
return holder && node ? {
|
|
146
|
+
...holder,
|
|
147
|
+
node
|
|
148
|
+
} : void 0;
|
|
149
|
+
};
|
|
150
|
+
const resolveBlock = (places, id, at) => {
|
|
151
|
+
const block = places.blocks.get(id);
|
|
152
|
+
if (!block) return;
|
|
153
|
+
metrics.resolved += 1;
|
|
154
|
+
if (block.holder?.key !== at?.key) {
|
|
155
|
+
if (block.holder && places.blockOfKey.get(block.holder.key) === id) places.blockOfKey.delete(block.holder.key);
|
|
156
|
+
if (at) places.blockOfKey.set(at.key, id);
|
|
157
|
+
block.holder = at ? {
|
|
158
|
+
key: at.key,
|
|
159
|
+
root: at.root
|
|
160
|
+
} : null;
|
|
161
|
+
}
|
|
162
|
+
const text = at && inkText(places.schema, at.node);
|
|
163
|
+
let moved = false;
|
|
164
|
+
for (const [copyId, copy] of block.copies) {
|
|
165
|
+
const was = places.held.get(copyId);
|
|
166
|
+
const kind = text === copy.text ? "live" : "changed";
|
|
167
|
+
if (at ? was?.key === at.key && was.kind === kind : !was) continue;
|
|
168
|
+
if (at) places.held.set(copyId, {
|
|
169
|
+
key: at.key,
|
|
170
|
+
kind
|
|
171
|
+
});
|
|
172
|
+
else places.held.delete(copyId);
|
|
173
|
+
moved = true;
|
|
174
|
+
}
|
|
175
|
+
if (at) block.group?.blocks.delete(id);
|
|
176
|
+
if (at) block.group = void 0;
|
|
177
|
+
if (moved) for (const mark of block.signed) dropSign(places, mark);
|
|
14
178
|
};
|
|
15
179
|
const trackCopy = (places, read, id) => {
|
|
16
180
|
const tracked = places.copies.get(id);
|
|
@@ -19,67 +183,373 @@ const trackCopy = (places, read, id) => {
|
|
|
19
183
|
if (!copy) return void 0;
|
|
20
184
|
const block = places.blocks.get(copy.block);
|
|
21
185
|
places.copies.set(id, copy);
|
|
22
|
-
if (block) block.set(id, copy);
|
|
23
|
-
else places.blocks.set(copy.block,
|
|
24
|
-
|
|
186
|
+
if (block) block.copies.set(id, copy);
|
|
187
|
+
else places.blocks.set(copy.block, {
|
|
188
|
+
copies: /* @__PURE__ */ new Map([[id, copy]]),
|
|
189
|
+
holder: null,
|
|
190
|
+
signed: /* @__PURE__ */ new Set()
|
|
191
|
+
});
|
|
192
|
+
resolveBlock(places, copy.block, holderIn(read.state, copy.block));
|
|
25
193
|
return copy;
|
|
26
194
|
};
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
walked.add(at);
|
|
41
|
-
at = chainEnds.get(at) ?? goneIn(records, at)?.[side];
|
|
42
|
-
}
|
|
43
|
-
for (const passed of walked) if (passed !== end) chainEnds.set(passed, end);
|
|
44
|
-
return found;
|
|
195
|
+
const untrackCopy = (places, id) => {
|
|
196
|
+
const copy = places.copies.get(id);
|
|
197
|
+
const block = copy && places.blocks.get(copy.block);
|
|
198
|
+
if (!copy || !block) return;
|
|
199
|
+
for (const mark of block.signed) dropSign(places, mark);
|
|
200
|
+
places.copies.delete(id);
|
|
201
|
+
places.held.delete(id);
|
|
202
|
+
block.copies.delete(id);
|
|
203
|
+
if (block.copies.size > 0) return;
|
|
204
|
+
places.blocks.delete(copy.block);
|
|
205
|
+
block.group?.blocks.delete(copy.block);
|
|
206
|
+
if (block.holder && places.blockOfKey.get(block.holder.key) === copy.block) places.blockOfKey.delete(block.holder.key);
|
|
45
207
|
};
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
208
|
+
const startEpoch = (places) => {
|
|
209
|
+
places.chainEnds.next.clear();
|
|
210
|
+
places.chainEnds.previous.clear();
|
|
211
|
+
places.walked.clear();
|
|
212
|
+
for (const group of [...places.groups.values()]) if (group.place.kind === "gone") dissolve(places, group);
|
|
213
|
+
};
|
|
214
|
+
const walkIn = (state, gone) => ({
|
|
215
|
+
holder: (id) => readElementById(state.nodes, id) ?? void 0,
|
|
216
|
+
record: (id) => goneIn(gone, id)
|
|
217
|
+
});
|
|
218
|
+
const goneGroupOf = (places, read, id) => {
|
|
219
|
+
const block = places.blocks.get(id);
|
|
220
|
+
if (block?.group) return block.group;
|
|
221
|
+
const gone = getRecordSetVersion(readShownRecords(read.editor), GONE);
|
|
222
|
+
const memo = {
|
|
223
|
+
...places.chainEnds,
|
|
224
|
+
walked: places.walked
|
|
60
225
|
};
|
|
61
|
-
|
|
62
|
-
|
|
226
|
+
const { found, last } = walkGone(walkIn(read.state, gone), id, memo, metrics);
|
|
227
|
+
const group = found ? groupAt(places, beside(found.side, found.holder.key), {
|
|
228
|
+
...found,
|
|
229
|
+
top: last
|
|
230
|
+
}) : groupAt(places, START);
|
|
231
|
+
group.blocks.add(id);
|
|
232
|
+
if (block) block.group = group;
|
|
233
|
+
return group;
|
|
63
234
|
};
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
235
|
+
const reanchor = (places, state, gone, group) => {
|
|
236
|
+
const { anchor, place } = group;
|
|
237
|
+
if (!anchor || place.kind !== "gone" || place.beside.at === "start") return;
|
|
238
|
+
metrics.holders += 1;
|
|
239
|
+
const holder = readElementById(state.nodes, anchor.id);
|
|
240
|
+
const memo = {
|
|
241
|
+
...places.chainEnds,
|
|
242
|
+
walked: places.walked
|
|
243
|
+
};
|
|
244
|
+
const walk = walkIn(state, gone);
|
|
245
|
+
const back = holder ? {
|
|
246
|
+
found: {
|
|
247
|
+
holder,
|
|
248
|
+
id: anchor.id,
|
|
249
|
+
side: anchor.side
|
|
74
250
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
251
|
+
last: anchor.top
|
|
252
|
+
} : reachGone(walk, anchor.id, anchor.side, memo, metrics);
|
|
253
|
+
const top = goneIn(gone, anchor.id) ? back.last : anchor.top;
|
|
254
|
+
const found = back.found ?? (anchor.side === "previous" ? reachGone(walk, top, "next", memo, metrics).found : void 0);
|
|
255
|
+
if (found?.side === anchor.side && found.holder.key === place.beside.key) return;
|
|
256
|
+
if (found) moveGroup(places, group, beside(found.side, found.holder.key), {
|
|
257
|
+
...found,
|
|
258
|
+
top
|
|
259
|
+
});
|
|
260
|
+
else dissolve(places, group);
|
|
261
|
+
};
|
|
262
|
+
const keepSign = (places, read, mark) => {
|
|
263
|
+
work.signs += 1;
|
|
264
|
+
const copies = mark.blocks.flatMap((block) => trackCopy(places, read, block.copy) ?? []);
|
|
265
|
+
places.stale.delete(mark.id);
|
|
266
|
+
if (copies.length < mark.blocks.length) return void 0;
|
|
267
|
+
const held = copies.map((copy) => places.held.get(copy.id));
|
|
268
|
+
const shown = held.findIndex((place) => place?.kind !== "live");
|
|
269
|
+
const place = held[shown];
|
|
270
|
+
const kept = {
|
|
271
|
+
copies,
|
|
272
|
+
mark
|
|
79
273
|
};
|
|
80
|
-
|
|
274
|
+
if (held.includes(void 0)) {
|
|
275
|
+
kept.group = place ? groupAt(places, place) : goneGroupOf(places, read, copies[shown].block);
|
|
276
|
+
pend(places, kept);
|
|
277
|
+
} else if (!mark.margin && place?.kind === "changed") kept.changed = {
|
|
278
|
+
place,
|
|
279
|
+
state: "changed"
|
|
280
|
+
};
|
|
281
|
+
places.signs.set(mark.id, kept);
|
|
282
|
+
for (const { block } of copies) places.blocks.get(block)?.signed.add(mark.id);
|
|
283
|
+
return kept;
|
|
284
|
+
};
|
|
285
|
+
const placesOf = ({ editor, state }) => {
|
|
286
|
+
const identity = state.schema.identity();
|
|
287
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
288
|
+
const version = getSnapshotVersion(owner);
|
|
289
|
+
const document = readShownDocument(editor) ?? (getActiveEditorUpdateId(editor) ? state.value() : null);
|
|
290
|
+
if (document) {
|
|
291
|
+
const shown = shownPlaces.get(document);
|
|
292
|
+
if (shown?.version === version && shown.places.identity === identity) return shown.places;
|
|
293
|
+
const places = emptyPlaces(state.schema);
|
|
294
|
+
shownPlaces.set(document, {
|
|
295
|
+
places,
|
|
296
|
+
version
|
|
297
|
+
});
|
|
298
|
+
return places;
|
|
299
|
+
}
|
|
300
|
+
const kept = committed.get(owner);
|
|
301
|
+
if (kept?.version === version && kept.places.identity === identity) return kept.places;
|
|
302
|
+
const store = getValueRecords(state.value());
|
|
303
|
+
const places = emptyPlaces(state.schema);
|
|
304
|
+
committed.set(owner, {
|
|
305
|
+
places,
|
|
306
|
+
sets: {
|
|
307
|
+
[COPIES]: getRecordSetVersion(store, COPIES),
|
|
308
|
+
[GONE]: getRecordSetVersion(store, GONE),
|
|
309
|
+
[MARKS]: getRecordSetVersion(store, MARKS)
|
|
310
|
+
},
|
|
311
|
+
version
|
|
312
|
+
});
|
|
81
313
|
return places;
|
|
82
314
|
};
|
|
83
|
-
const
|
|
315
|
+
const memoUpdates = /* @__PURE__ */ new WeakSet();
|
|
316
|
+
const takeFirstChangeWalkMemo = (editor) => {
|
|
317
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
318
|
+
const kept = committed.get(owner);
|
|
319
|
+
const update = getActiveEditorUpdateId(editor);
|
|
320
|
+
if (!update || memoUpdates.has(update)) return void 0;
|
|
321
|
+
memoUpdates.add(update);
|
|
322
|
+
return kept?.version === getSnapshotVersion(owner) ? kept.places.chainEnds : void 0;
|
|
323
|
+
};
|
|
324
|
+
const readInkPlace = (read, copyId) => {
|
|
325
|
+
const places = placesOf(read);
|
|
326
|
+
const copy = trackCopy(places, read, copyId);
|
|
327
|
+
return copy && (places.held.get(copy.id) ?? goneGroupOf(places, read, copy.block).place);
|
|
328
|
+
};
|
|
329
|
+
const indexedMark = (places, read, mark) => places.signs.get(mark.id) ?? keepSign(places, read, mark);
|
|
330
|
+
const readInkIndexedMark = (read, mark) => indexedMark(placesOf(read), read, mark);
|
|
331
|
+
const readInkSign = (read, mark) => {
|
|
332
|
+
const kept = indexedMark(placesOf(read), read, mark);
|
|
333
|
+
return kept?.group?.sign ?? kept?.changed;
|
|
334
|
+
};
|
|
335
|
+
const placeIn = (marks, mark) => {
|
|
336
|
+
let from = 0;
|
|
337
|
+
let to = marks.length;
|
|
338
|
+
while (from < to) {
|
|
339
|
+
const at = from + to >>> 1;
|
|
340
|
+
work.members += 1;
|
|
341
|
+
if (byMark(marks[at], mark) < 0) from = at + 1;
|
|
342
|
+
else to = at;
|
|
343
|
+
}
|
|
344
|
+
return from;
|
|
345
|
+
};
|
|
346
|
+
const byCut = (a, b) => a.at - b.at || (a.mark && b.mark ? byMark(a.mark, b.mark) : a.mark ? -1 : b.mark ? 1 : 0);
|
|
347
|
+
const cutIn = (group, direction, cuts) => {
|
|
348
|
+
const marks = group.marks[direction];
|
|
349
|
+
const ids = group.ids[direction];
|
|
350
|
+
const nextMarks = [];
|
|
351
|
+
const nextIds = [];
|
|
352
|
+
let from = 0;
|
|
353
|
+
const keep = (to) => {
|
|
354
|
+
for (; from < to; from++) {
|
|
355
|
+
nextMarks.push(marks[from]);
|
|
356
|
+
nextIds.push(ids[from]);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
work.copies += 1;
|
|
360
|
+
for (const { at, mark } of cuts) {
|
|
361
|
+
keep(at);
|
|
362
|
+
if (mark) {
|
|
363
|
+
nextMarks.push(mark);
|
|
364
|
+
nextIds.push(mark.id);
|
|
365
|
+
} else from += 1;
|
|
366
|
+
}
|
|
367
|
+
keep(marks.length);
|
|
368
|
+
group.marks[direction] = nextMarks;
|
|
369
|
+
group.ids[direction] = nextIds;
|
|
370
|
+
};
|
|
371
|
+
const settle = (places, group) => {
|
|
372
|
+
const cuts = {
|
|
373
|
+
ltr: [],
|
|
374
|
+
rtl: []
|
|
375
|
+
};
|
|
376
|
+
for (const [id, { joins, mark }] of group.pending) {
|
|
377
|
+
const member = group.members.get(id);
|
|
378
|
+
if (member) {
|
|
379
|
+
cuts[member.direction].push({ at: placeIn(group.marks[member.direction], member) });
|
|
380
|
+
group.members.delete(id);
|
|
381
|
+
}
|
|
382
|
+
if (joins) {
|
|
383
|
+
cuts[mark.direction].push({
|
|
384
|
+
at: placeIn(group.marks[mark.direction], mark),
|
|
385
|
+
mark
|
|
386
|
+
});
|
|
387
|
+
group.members.set(id, mark);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
for (const direction of ["ltr", "rtl"]) {
|
|
391
|
+
if (cuts[direction].length === 0) continue;
|
|
392
|
+
work.directions += 1;
|
|
393
|
+
cutIn(group, direction, cuts[direction].sort(byCut));
|
|
394
|
+
}
|
|
395
|
+
group.pending.clear();
|
|
396
|
+
if (group.blocks.size + size(group) === 0) places.groups.delete(keyOf(group.place));
|
|
397
|
+
};
|
|
398
|
+
const readInkDeletedSigns = (read) => {
|
|
399
|
+
const places = placesOf(read);
|
|
400
|
+
const marks = read.marks();
|
|
401
|
+
if (places.listed !== marks) {
|
|
402
|
+
places.listed = marks;
|
|
403
|
+
for (const mark of marks) if (places.signs.get(mark.id)?.mark !== mark) dropSign(places, mark.id);
|
|
404
|
+
places.stale = new Map(marks.flatMap((mark) => places.signs.has(mark.id) ? [] : [[mark.id, mark]]));
|
|
405
|
+
}
|
|
406
|
+
for (const mark of places.stale.values()) keepSign(places, read, mark);
|
|
407
|
+
if (places.deleted) return places.deleted;
|
|
408
|
+
for (const group of places.changed) settle(places, group);
|
|
409
|
+
places.changed.clear();
|
|
410
|
+
places.deleted = Object.freeze([...places.groups.values()].flatMap(({ ids, marks: of, place }) => ["ltr", "rtl"].flatMap((direction) => of[direction].length > 0 ? [{
|
|
411
|
+
ids: ids[direction],
|
|
412
|
+
marks: of[direction],
|
|
413
|
+
place
|
|
414
|
+
}] : [])).sort((a, b) => byMark(a.marks[0], b.marks[0])));
|
|
415
|
+
return places.deleted;
|
|
416
|
+
};
|
|
417
|
+
const addArrivedBlocks = (places, state, keys, dirty) => {
|
|
418
|
+
for (const key of keys) {
|
|
419
|
+
const [node] = state.nodes.get(key) ?? [];
|
|
420
|
+
const id = node && idOf(node);
|
|
421
|
+
if (id === void 0) continue;
|
|
422
|
+
if (places.blocks.has(id)) dirty.add(id);
|
|
423
|
+
if (places.walked.has(id)) startEpoch(places);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const slideRemoval = (places, commit, gone) => {
|
|
427
|
+
const { changed } = commit;
|
|
428
|
+
const removed = new Set(changed.nodeKeysAll("presence"));
|
|
429
|
+
if (removed.size === 0 || changed.hasAny("properties")) return false;
|
|
430
|
+
const { index } = commit.before;
|
|
431
|
+
const value = getEditorCommitValue(commit, "before");
|
|
432
|
+
const left = /* @__PURE__ */ new Map();
|
|
433
|
+
for (const key of removed) {
|
|
434
|
+
const path = index.pathOf(key);
|
|
435
|
+
const node = path && getDocumentValueNode(value, path);
|
|
436
|
+
if (!node) return false;
|
|
437
|
+
if (ElementApi.isElement(node) && node.children.some((_, at) => {
|
|
438
|
+
const child = index.keyAt([...path, at]);
|
|
439
|
+
return !child || !removed.has(child);
|
|
440
|
+
})) return false;
|
|
441
|
+
left.set(key, {
|
|
442
|
+
id: idOf(node),
|
|
443
|
+
path
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
const ids = new Set([...left.values()].flatMap(({ id }) => id ?? []));
|
|
447
|
+
const skips = (path) => {
|
|
448
|
+
const key = index.keyAt(path);
|
|
449
|
+
return !key || removed.has(key);
|
|
450
|
+
};
|
|
451
|
+
const keptBeside = (path, side) => {
|
|
452
|
+
const found = side === "previous" ? besideAt(value, path, -1, skips) : besideAt(value, [...path.slice(0, -1), (path.at(-1) ?? 0) + 1], 1, skips);
|
|
453
|
+
const key = found && index.keyAt(found.path);
|
|
454
|
+
return found && key ? {
|
|
455
|
+
id: found.id,
|
|
456
|
+
key
|
|
457
|
+
} : void 0;
|
|
458
|
+
};
|
|
459
|
+
const known = (id) => ids.has(id) || places.walked.has(id);
|
|
460
|
+
const walk = {
|
|
461
|
+
holder: (id) => known(id) ? void 0 : id,
|
|
462
|
+
record: (id) => goneIn(gone, id)
|
|
463
|
+
};
|
|
464
|
+
const memo = {
|
|
465
|
+
...places.chainEnds,
|
|
466
|
+
walked: places.walked
|
|
467
|
+
};
|
|
468
|
+
const landing = (id, path, side, top) => {
|
|
469
|
+
const first = reachGone(walk, id, side, memo, metrics);
|
|
470
|
+
const from = first.found || side === "next" || top === void 0 ? void 0 : goneIn(gone, id) ? first.last : top;
|
|
471
|
+
const found = first.found ?? (from === void 0 ? void 0 : reachGone(walk, from, "next", memo, metrics).found);
|
|
472
|
+
const to = found && keptBeside(path, found.side);
|
|
473
|
+
if (!found) return {
|
|
474
|
+
anchor: void 0,
|
|
475
|
+
key: void 0
|
|
476
|
+
};
|
|
477
|
+
if (to?.id !== found.id) return void 0;
|
|
478
|
+
return {
|
|
479
|
+
anchor: {
|
|
480
|
+
id: to.id,
|
|
481
|
+
side: found.side,
|
|
482
|
+
top: from ?? first.last
|
|
483
|
+
},
|
|
484
|
+
key: to.key
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
const steps = [];
|
|
488
|
+
for (const [key, { id, path }] of left) {
|
|
489
|
+
const block = places.blockOfKey.get(key);
|
|
490
|
+
for (const side of ["previous", "next"]) {
|
|
491
|
+
const group = places.groups.get(keyOf(beside(side, key)));
|
|
492
|
+
const anchor = group?.anchor;
|
|
493
|
+
const hints = side === "previous" && block !== void 0;
|
|
494
|
+
if (anchor && anchor.id !== id) return false;
|
|
495
|
+
if (id === void 0 || !(anchor || hints)) continue;
|
|
496
|
+
const lands = landing(id, path, side, anchor?.top);
|
|
497
|
+
if (anchor && !lands) return false;
|
|
498
|
+
if (!lands) continue;
|
|
499
|
+
steps.push(() => {
|
|
500
|
+
const into = lands.anchor && lands.key && beside(lands.anchor.side, lands.key);
|
|
501
|
+
if (group && places.groups.get(keyOf(group.place)) === group) if (into) moveGroup(places, group, into, lands.anchor);
|
|
502
|
+
else dissolve(places, group);
|
|
503
|
+
const kept = block !== void 0 && places.blocks.get(block);
|
|
504
|
+
if (!hints || !into || !kept || lands.anchor?.side !== side) return;
|
|
505
|
+
kept.group = groupAt(places, into, lands.anchor);
|
|
506
|
+
kept.group.blocks.add(block);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
for (const step of steps) step();
|
|
511
|
+
return true;
|
|
512
|
+
};
|
|
513
|
+
const advanceInkPlaces = (editor, commit) => {
|
|
514
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
515
|
+
const kept = committed.get(owner);
|
|
516
|
+
if (!kept || commit.version <= kept.version) return;
|
|
517
|
+
if (commit.previousVersion !== kept.version || commit.changed.hasAny("replace")) {
|
|
518
|
+
committed.delete(owner);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
const { places, sets } = kept;
|
|
522
|
+
const { changed } = commit;
|
|
523
|
+
const store = getValueRecords(getEditorCommitValue(commit));
|
|
524
|
+
const changedIn = (set) => {
|
|
525
|
+
const before = sets[set];
|
|
526
|
+
sets[set] = getRecordSetVersion(store, set);
|
|
527
|
+
return recordSetChanges(before, sets[set]);
|
|
528
|
+
};
|
|
529
|
+
if (changedIn("ink-gone").some((id) => places.walked.has(id))) startEpoch(places);
|
|
530
|
+
for (const id of changedIn(COPIES)) untrackCopy(places, id);
|
|
531
|
+
for (const id of changedIn(MARKS)) dropSign(places, id);
|
|
532
|
+
const dirty = /* @__PURE__ */ new Set();
|
|
533
|
+
const moved = changed.hasAny("structure") || changed.hasAny("properties");
|
|
534
|
+
const keys = moved ? [...changed.nodeKeysAll("node"), ...changed.nodeKeysAll("presence")] : changed.nodeKeysAll("node");
|
|
535
|
+
for (const key of keys) {
|
|
536
|
+
const block = places.blockOfKey.get(key);
|
|
537
|
+
if (block !== void 0) dirty.add(block);
|
|
538
|
+
}
|
|
539
|
+
const watches = places.copies.size > 0 || places.walked.size > 0;
|
|
540
|
+
if (places.schema.identity() !== places.identity) {
|
|
541
|
+
committed.delete(owner);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (moved && (dirty.size > 0 || watches) && !slideRemoval(places, commit, sets["ink-gone"])) withStoredAuthoredRead(editor, () => editor.read((state) => {
|
|
545
|
+
metrics.reads += 1;
|
|
546
|
+
addArrivedBlocks(places, state, keys, dirty);
|
|
547
|
+
for (const block of dirty) resolveBlock(places, block, holderIn(state, block));
|
|
548
|
+
const anchored = keys.flatMap((key) => ["previous", "next"].flatMap((side) => places.groups.get(keyOf(beside(side, key))) ?? []));
|
|
549
|
+
for (const group of anchored) if (places.groups.get(keyOf(group.place)) === group) reanchor(places, state, sets[GONE], group);
|
|
550
|
+
}));
|
|
551
|
+
else for (const id of dirty) resolveBlock(places, id, keptHolderIn(commit, places.blocks.get(id)?.holder));
|
|
552
|
+
kept.version = commit.version;
|
|
553
|
+
};
|
|
84
554
|
//#endregion
|
|
85
|
-
export { readInkPlace };
|
|
555
|
+
export { advanceInkPlaces, byMark, readInkDeletedSigns, readInkIndexedMark, readInkPlace, readInkSign, takeFirstChangeWalkMemo };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ColumnGroupElement, i as ColumnElement, n as BaseColumnItemPlugin, o as SetColumnsOptions, r as ColumnDefinition, s as ToggleColumnGroupOptions, t as BaseColumnGroupPlugin } from "../../index-
|
|
1
|
+
import { a as ColumnGroupElement, i as ColumnElement, n as BaseColumnItemPlugin, o as SetColumnsOptions, r as ColumnDefinition, s as ToggleColumnGroupOptions, t as BaseColumnGroupPlugin } from "../../index-d7io3MzC.js";
|
|
2
2
|
export { BaseColumnGroupPlugin, BaseColumnItemPlugin, ColumnDefinition, ColumnElement, ColumnGroupElement, SetColumnsOptions, ToggleColumnGroupOptions };
|
|
@@ -310,10 +310,9 @@ const BaseLinkPlugin = definePlugin("link", {
|
|
|
310
310
|
}) || void 0;
|
|
311
311
|
})
|
|
312
312
|
}) })).extend(({ plugin }) => ({ commands: ({ around }) => [around(editorCommands.insertText, ({ input, state, next }) => {
|
|
313
|
-
const
|
|
314
|
-
const currentSelection = state.selection();
|
|
315
|
-
if (target && (!currentSelection || !RangeApi.isRange(target) || !RangeApi.equals(target, currentSelection))) return next();
|
|
313
|
+
const { at, ...options } = input.options ?? {};
|
|
316
314
|
const selection = state.selection();
|
|
315
|
+
if (at && (!selection || !RangeApi.isRange(at) || !RangeApi.equals(at, selection))) return next();
|
|
317
316
|
if (!selection || !state.selection.isCollapsed()) return next();
|
|
318
317
|
const link = state.nodes.above({
|
|
319
318
|
at: selection,
|
|
@@ -323,7 +322,10 @@ const BaseLinkPlugin = definePlugin("link", {
|
|
|
323
322
|
const prefix = state.transaction((tx) => {
|
|
324
323
|
tx.plugin(plugin.name).exitEnd();
|
|
325
324
|
});
|
|
326
|
-
return next.after(prefix
|
|
325
|
+
return next.after(prefix, {
|
|
326
|
+
...input,
|
|
327
|
+
options
|
|
328
|
+
});
|
|
327
329
|
})] }));
|
|
328
330
|
const findAutolink = (editor) => {
|
|
329
331
|
const selection = editor.read.selection();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Ci as Element, iu as TxDeclaredMethod } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { _ as BasePlugin, u as Editor } from "../../core-BqR-fEDp.js";
|
|
3
4
|
type LintFinding = Readonly<{
|
|
4
5
|
id: string;
|
|
5
6
|
ruleId: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { AlignedMediaInsertInput, AudioElement, AudioPluginState, BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BaseVideoPlugin, EmbedUrlData, EmbedUrlParser, FileElement, FileInsertInput, FilePluginState, ImageDefinition, ImageElement, ImageInsertInput, ImagePluginState, MediaEmbedDefinition, MediaEmbedElement, MediaEmbedPluginState, MediaInsertInput, MediaPluginState, MediaUrlKind, MediaUrlProperties, ProviderMediaInsertInput, ResizableElement, VIDEO_PROVIDERS, VideoElement, VideoPluginState, defineMediaPlugin, mediaElementProperties, parseIframeUrl, parseMediaUrl, parseTwitterUrl, parseVideoUrl };
|
|
1
|
+
import { A as MediaUrlProperties, C as FileElement, D as MediaInsertInput, E as ImageInsertInput, F as defineMediaPlugin, I as mediaElementProperties, M as ResizableElement, N as VideoElement, O as MediaPluginState, P as VideoPluginState, S as BaseVideoPlugin, T as FilePluginState, _ as AlignedMediaInsertInput, a as MediaEmbedRules, b as BaseAudioPlugin, c as VIDEO_PROVIDERS, d as parseTwitterUrl, f as parseVideoUrl, g as ImagePluginState, h as ImageElement, i as MediaEmbedPluginState, j as ProviderMediaInsertInput, k as MediaUrlKind, l as parseIframeUrl, m as ImageDefinition, n as MediaEmbedDefinition, o as EmbedUrlData, p as BaseImagePlugin, r as MediaEmbedElement, s as EmbedUrlParser, t as BaseMediaEmbedPlugin, u as parseMediaUrl, v as AudioElement, w as FileInsertInput, x as BaseFilePlugin, y as AudioPluginState } from "../../index-B33E1CRJ.js";
|
|
2
|
+
export { AlignedMediaInsertInput, AudioElement, AudioPluginState, BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BaseVideoPlugin, EmbedUrlData, EmbedUrlParser, FileElement, FileInsertInput, FilePluginState, ImageDefinition, ImageElement, ImageInsertInput, ImagePluginState, MediaEmbedDefinition, MediaEmbedElement, MediaEmbedPluginState, MediaEmbedRules, MediaInsertInput, MediaPluginState, MediaUrlKind, MediaUrlProperties, ProviderMediaInsertInput, ResizableElement, VIDEO_PROVIDERS, VideoElement, VideoPluginState, defineMediaPlugin, mediaElementProperties, parseIframeUrl, parseMediaUrl, parseTwitterUrl, parseVideoUrl };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseAudioPlugin, BaseFilePlugin, BaseVideoPlugin, defineMediaPlugin, mediaElementProperties } from "./lib/BaseMediaPlugin.js";
|
|
2
2
|
import { BaseImagePlugin } from "./lib/image/BaseImagePlugin.js";
|
|
3
3
|
import { VIDEO_PROVIDERS, parseIframeUrl, parseMediaUrl, parseTwitterUrl, parseVideoUrl } from "./lib/media/parseMediaUrl.js";
|
|
4
|
-
import { BaseMediaEmbedPlugin } from "./lib/media-embed/BaseMediaEmbedPlugin.js";
|
|
5
|
-
export { BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BaseVideoPlugin, VIDEO_PROVIDERS, defineMediaPlugin, mediaElementProperties, parseIframeUrl, parseMediaUrl, parseTwitterUrl, parseVideoUrl };
|
|
4
|
+
import { BaseMediaEmbedPlugin, MediaEmbedRules } from "./lib/media-embed/BaseMediaEmbedPlugin.js";
|
|
5
|
+
export { BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BaseVideoPlugin, MediaEmbedRules, VIDEO_PROVIDERS, defineMediaPlugin, mediaElementProperties, parseIframeUrl, parseMediaUrl, parseTwitterUrl, parseVideoUrl };
|