plitejs 54.0.0-beta.6 → 54.0.0-beta.8
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 +4 -4
- package/dist/authored/index.d.ts +67 -47
- package/dist/authored/index.js +7640 -4563
- package/dist/{authored-veto-BsBDXC0b.js → authored-veto-DLmBMIcy.js} +1 -1
- package/dist/clipboard-format-key-SzffxWqa.js +14 -0
- package/dist/{comparison-plan-IOewH50q.js → comparison-plan-BqFJWjO4.js} +142 -14
- package/dist/{create-editor-DRRzGwaC.js → create-editor-kU8fg-PF.js} +30 -78
- package/dist/diff/index.d.ts +2 -32
- package/dist/diff/index.js +92 -372
- package/dist/dom/index.d.ts +3 -2
- package/dist/dom/index.js +3 -2
- package/dist/{dom-CVYV5Qd5.js → dom-SUWlnfT9.js} +1052 -261
- package/dist/history/index.d.ts +5 -5
- package/dist/history/index.js +3237 -2096
- package/dist/history-skip-CcEhIzak.js +35 -0
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/hyperscript/index.js +1 -1
- package/dist/{hyperscript-CT6hhnAY.js → hyperscript-DdeGYoSc.js} +3 -2
- package/dist/{index-PDROnF1G.d.ts → index-4PpawhYe.d.ts} +1 -1
- package/dist/{index-VZrKWWeh.d.ts → index-BsOySJwr.d.ts} +86 -203
- package/dist/{index-D7-n2GCk.d.ts → index-CHEKdrHP.d.ts} +32 -24
- package/dist/{comparison-types-DBQFu7Rt.d.ts → index-DM-b6jEe.d.ts} +21 -57
- package/dist/{index-BT7D4vtf.d.ts → index-DqmhcD_0.d.ts} +1 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -4
- package/dist/internal/index.d.ts +2 -2
- package/dist/internal/index.js +66 -5
- package/dist/law-check-Bvnz2EKh.js +19271 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/pagination/react.d.ts +14 -11
- package/dist/pagination/react.js +237 -144
- package/dist/{pagination-Cs5ka6hW.js → pagination-XEnxZ1DX.js} +2 -1
- package/dist/{plugin-Bm6nsPHh.js → plugin-B8uCi-Hr.js} +17196 -22475
- package/dist/{range-geometry-DO-kbNrb.d.ts → range-geometry-B2f67yLv.d.ts} +1 -1
- package/dist/{range-geometry-D1XfYWs0.js → range-geometry-BGKYQHqO.js} +3 -2
- package/dist/react/index.d.ts +4 -5
- package/dist/react/index.js +8 -7
- package/dist/react/virtualized.d.ts +5 -5
- package/dist/react/virtualized.js +69 -43
- package/dist/{react-BYtwRr4v.js → react-B6B-5z7t.js} +141 -171
- package/dist/{retraction-DnEUo8oE.js → retraction-BMzQ2on5.js} +2 -18
- package/dist/scroll-root-DudA40xj.js +25 -0
- package/dist/{src-DIQDddmh.js → src--BZ7fZY4.js} +183 -64
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +4 -3
- package/dist/{index-DHt8nZQ6.d.ts → tx-only-D8lpB-sT.d.ts} +9246 -8660
- package/dist/{editor-owner-CGj1wYCa.js → update-policy-J-4sHmrg.js} +54 -2
- package/dist/{use-editor-dom-scope-hT7W9d-p.js → use-editor-dom-scope-BFWvutxn.js} +18267 -15917
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/index.js +1 -1
- package/dist/yjs/react/index.d.ts +3 -3
- package/dist/yjs/react/index.js +3 -3
- package/dist/{yjs-C_g9gZwI.js → yjs-DPngKQWQ.js} +420 -164
- package/package.json +2 -9
- package/dist/annotation-store-metrics-Ccjkef45.js +0 -12
- package/dist/annotations/index.d.ts +0 -2
- package/dist/annotations/index.js +0 -2
- package/dist/index-BvQzYVAW.d.ts +0 -71
- package/dist/mapped-view-store-CBk2-bDR.js +0 -120
- package/dist/store-BLYxJgOU.js +0 -747
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cd as definePluginPoint } from "./plugin-B8uCi-Hr.js";
|
|
2
2
|
//#region src/core/authored-veto.ts
|
|
3
3
|
/** Contribute a reason Suggesting refuses a change that touches an element. */
|
|
4
4
|
const authoredVeto = definePluginPoint("authored.veto");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Ld as getEditorRuntimeOwner } from "./plugin-B8uCi-Hr.js";
|
|
2
|
+
//#region src/internal/clipboard-format-key.ts
|
|
3
|
+
const DEFAULT_CLIPBOARD_FORMAT_KEY = "x-editor-fragment";
|
|
4
|
+
const EDITOR_TO_CLIPBOARD_FORMAT_KEY = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
const setDOMClipboardFormatKey = (editor, clipboardFormatKey) => {
|
|
6
|
+
EDITOR_TO_CLIPBOARD_FORMAT_KEY.set(getEditorRuntimeOwner(editor), clipboardFormatKey);
|
|
7
|
+
};
|
|
8
|
+
const clearDOMClipboardFormatKey = (editor) => {
|
|
9
|
+
EDITOR_TO_CLIPBOARD_FORMAT_KEY.delete(getEditorRuntimeOwner(editor));
|
|
10
|
+
};
|
|
11
|
+
/** Read the configured MIME suffix used for exact Plite clipboard payloads. */
|
|
12
|
+
const getDOMClipboardFormatKey = (editor) => EDITOR_TO_CLIPBOARD_FORMAT_KEY.get(getEditorRuntimeOwner(editor)) ?? "x-editor-fragment";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { setDOMClipboardFormatKey as i, clearDOMClipboardFormatKey as n, getDOMClipboardFormatKey as r, DEFAULT_CLIPBOARD_FORMAT_KEY as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as recordOpsToJson, Dn as isElementNode, E as getInternalDocumentChangeEntries, Gr as snapshotEditorJsonValue, H as isUnboundV4DocumentChange, Ii as isRecord, Jt as storedElementIdOf, Li as jsonEqual, Ni as cloneFrozen, O as getInternalDocumentChangeRecords, On as isTextNode, cn as canonicalJsonKey, gt as RootChange, kn as nodeProps, p as createInternalDocumentChange, s as attachLazyV4Steps, t as lawCheckEnabled, tn as DocumentIndex, u as bindV4DocumentChange } from "./law-check-Bvnz2EKh.js";
|
|
2
2
|
//#region src/core/json-fingerprint.ts
|
|
3
3
|
/** Deterministic fingerprint for already validated JSON-compatible data. */
|
|
4
4
|
const fingerprintEditorJson = (value) => {
|
|
@@ -25,11 +25,27 @@ const stableStringify = (value) => {
|
|
|
25
25
|
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`).join(",")}}`;
|
|
26
26
|
};
|
|
27
27
|
const comparisonHash = (value) => fingerprintEditorJson(value);
|
|
28
|
+
const comparisonChangeHashPayload = (change) => {
|
|
29
|
+
try {
|
|
30
|
+
return change.toJSON();
|
|
31
|
+
} catch {
|
|
32
|
+
const records = getInternalDocumentChangeRecords(change);
|
|
33
|
+
return {
|
|
34
|
+
createRoots: [...change.createRoots].sort(),
|
|
35
|
+
deleteRoots: [...change.deleteRoots].sort(),
|
|
36
|
+
...records.size > 0 ? { records: recordOpsToJson(records) } : {},
|
|
37
|
+
roots: [...getInternalDocumentChangeEntries(change)].map(([root, rootChange]) => [root, rootChange.toJSON()]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
28
41
|
const detachComparisonEnvelope = (input) => {
|
|
29
42
|
if (Array.isArray(input) || typeof input !== "object" || input === null) return null;
|
|
30
|
-
const { meta } = input;
|
|
31
|
-
if (meta === void 0) return null;
|
|
32
|
-
return fingerprintEditorJson(
|
|
43
|
+
const { meta, records } = input;
|
|
44
|
+
if (meta === void 0 && records === void 0) return null;
|
|
45
|
+
return fingerprintEditorJson({
|
|
46
|
+
...meta === void 0 ? {} : { meta: snapshotEditorJsonValue(meta, "Comparison document metadata") },
|
|
47
|
+
...records === void 0 ? {} : { records: snapshotEditorJsonValue(records, "Comparison document records") }
|
|
48
|
+
});
|
|
33
49
|
};
|
|
34
50
|
const detachComparisonDocument = (input, schema) => {
|
|
35
51
|
const candidate = Array.isArray(input) ? { children: input } : input;
|
|
@@ -39,6 +55,112 @@ const detachComparisonDocument = (input, schema) => {
|
|
|
39
55
|
...candidate.roots ? { roots: candidate.roots } : {}
|
|
40
56
|
}, "Comparison document");
|
|
41
57
|
};
|
|
58
|
+
const scanIds = (nodes, onElement) => {
|
|
59
|
+
for (const node of nodes) {
|
|
60
|
+
if (!isElementNode(node)) continue;
|
|
61
|
+
onElement(storedElementIdOf(node));
|
|
62
|
+
scanIds(node.children, onElement);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const scanDocumentIds = (document, onElement) => {
|
|
66
|
+
scanIds(document.children, onElement);
|
|
67
|
+
const { roots } = document;
|
|
68
|
+
if (!roots) return;
|
|
69
|
+
for (const root of Object.keys(roots).sort()) scanIds(roots[root], onElement);
|
|
70
|
+
};
|
|
71
|
+
const pathKey = (root, path) => `${root ?? ""}:${path.join(",")}`;
|
|
72
|
+
const stripElementIdsFromNodes = (nodes) => nodes.map((node) => {
|
|
73
|
+
if (!isElementNode(node)) return node;
|
|
74
|
+
const children = stripElementIdsFromNodes(node.children);
|
|
75
|
+
if (storedElementIdOf(node) === void 0 && children === node.children) return node;
|
|
76
|
+
const { id: _id, ...rest } = node;
|
|
77
|
+
return Object.freeze({
|
|
78
|
+
...rest,
|
|
79
|
+
children
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
const needsComparisonElementIds = (before, after) => {
|
|
83
|
+
let beforeHasId = false;
|
|
84
|
+
scanDocumentIds(before, (id) => {
|
|
85
|
+
if (id !== void 0) beforeHasId = true;
|
|
86
|
+
});
|
|
87
|
+
if (!beforeHasId) return false;
|
|
88
|
+
let afterMissingId = false;
|
|
89
|
+
scanDocumentIds(after, (id) => {
|
|
90
|
+
if (id === void 0) afterMissingId = true;
|
|
91
|
+
});
|
|
92
|
+
return afterMissingId;
|
|
93
|
+
};
|
|
94
|
+
const stripComparisonElementIds = (document) => {
|
|
95
|
+
const { roots } = document;
|
|
96
|
+
return Object.freeze({
|
|
97
|
+
children: stripElementIdsFromNodes(document.children),
|
|
98
|
+
...roots ? { roots: Object.freeze(Object.fromEntries(Object.keys(roots).sort().map((root) => [root, stripElementIdsFromNodes(roots[root])]))) } : {}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const nodeAtPath = (document, root, path) => {
|
|
102
|
+
let list = root === null ? document.children : document.roots?.[root];
|
|
103
|
+
let current;
|
|
104
|
+
for (const index of path) {
|
|
105
|
+
current = list?.[index];
|
|
106
|
+
if (!current || !isElementNode(current)) return void 0;
|
|
107
|
+
list = current.children;
|
|
108
|
+
}
|
|
109
|
+
return current;
|
|
110
|
+
};
|
|
111
|
+
const fillComparisonElementIds = (before, after, beforeIndex, afterIndex, inPlaceMatches) => {
|
|
112
|
+
const used = /* @__PURE__ */ new Set();
|
|
113
|
+
scanDocumentIds(before, (id) => {
|
|
114
|
+
if (id !== void 0) used.add(id);
|
|
115
|
+
});
|
|
116
|
+
scanDocumentIds(after, (id) => {
|
|
117
|
+
if (id !== void 0) used.add(id);
|
|
118
|
+
});
|
|
119
|
+
const matchedIds = /* @__PURE__ */ new Map();
|
|
120
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
121
|
+
scanDocumentIds(after, (id) => {
|
|
122
|
+
if (id !== void 0) claimed.add(id);
|
|
123
|
+
});
|
|
124
|
+
for (const [bIndex, aIndex] of inPlaceMatches) {
|
|
125
|
+
const bMeta = beforeIndex.nodes[bIndex];
|
|
126
|
+
const aMeta = afterIndex.nodes[aIndex];
|
|
127
|
+
const bNode = nodeAtPath(before, bMeta.root, bMeta.path);
|
|
128
|
+
const id = bNode ? storedElementIdOf(bNode) : void 0;
|
|
129
|
+
if (id !== void 0 && !claimed.has(id)) {
|
|
130
|
+
claimed.add(id);
|
|
131
|
+
matchedIds.set(pathKey(aMeta.root, aMeta.path), id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
let next = 0;
|
|
135
|
+
const draw = () => {
|
|
136
|
+
while (used.has(`fill.${next}`)) next += 1;
|
|
137
|
+
const id = `fill.${next}`;
|
|
138
|
+
used.add(id);
|
|
139
|
+
next += 1;
|
|
140
|
+
return id;
|
|
141
|
+
};
|
|
142
|
+
const fillNodes = (nodes, root, prefix) => nodes.map((node, index) => {
|
|
143
|
+
if (!isElementNode(node)) return node;
|
|
144
|
+
const path = [...prefix, index];
|
|
145
|
+
const children = fillNodes(node.children, root, path);
|
|
146
|
+
const existing = storedElementIdOf(node);
|
|
147
|
+
const id = existing ?? matchedIds.get(pathKey(root, path)) ?? draw();
|
|
148
|
+
if (existing !== void 0 && children === node.children) return node;
|
|
149
|
+
return Object.freeze({
|
|
150
|
+
...node,
|
|
151
|
+
...existing === void 0 ? { id } : {},
|
|
152
|
+
children
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
const afterRoots = after.roots;
|
|
156
|
+
const afterRootKeys = Object.keys(afterRoots ?? {}).sort();
|
|
157
|
+
const children = fillNodes(after.children, null, []);
|
|
158
|
+
const roots = afterRoots && afterRootKeys.length > 0 ? Object.freeze(Object.fromEntries(afterRootKeys.map((root) => [root, fillNodes(afterRoots[root], root, [])]))) : void 0;
|
|
159
|
+
return Object.freeze({
|
|
160
|
+
children,
|
|
161
|
+
...roots ? { roots } : {}
|
|
162
|
+
});
|
|
163
|
+
};
|
|
42
164
|
const createComparisonSnapshot = (document, schema, projection, envelopeFingerprint) => {
|
|
43
165
|
const identity = schema.identity();
|
|
44
166
|
const fingerprint = fingerprintEditorJson({
|
|
@@ -1247,14 +1369,15 @@ const walkPlan = (input) => {
|
|
|
1247
1369
|
const flags = (kind) => lifecycle.filter((flag) => flag.kind === kind && keep(flag.owners)).map(({ root }) => root);
|
|
1248
1370
|
const createRoots = flags("create");
|
|
1249
1371
|
const deleteRoots = flags("delete");
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1372
|
+
const rootChanges = /* @__PURE__ */ new Map();
|
|
1373
|
+
if (primary) rootChanges.set("main", RootChange.fromJSON(primary));
|
|
1374
|
+
for (const [root, rootChange] of named) rootChanges.set(root, RootChange.fromJSON(rootChange));
|
|
1375
|
+
const selected = createInternalDocumentChange(rootChanges, {
|
|
1376
|
+
createRoots,
|
|
1377
|
+
deleteRoots
|
|
1378
|
+
});
|
|
1379
|
+
attachLazyV4Steps(selected, before, selected.apply(before));
|
|
1380
|
+
return selected;
|
|
1258
1381
|
};
|
|
1259
1382
|
const change = select("all");
|
|
1260
1383
|
return Object.freeze({
|
|
@@ -1320,7 +1443,12 @@ const comparisonPlanOf = (comparison, schema) => {
|
|
|
1320
1443
|
beforeIndex,
|
|
1321
1444
|
groups: comparison.changes
|
|
1322
1445
|
});
|
|
1323
|
-
|
|
1446
|
+
const rootEntriesJson = (change) => ({
|
|
1447
|
+
createRoots: [...change.createRoots].sort(),
|
|
1448
|
+
deleteRoots: [...change.deleteRoots].sort(),
|
|
1449
|
+
roots: [...getInternalDocumentChangeEntries(change)].map(([root, rootChange]) => [root, rootChange.toJSON()]).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
|
|
1450
|
+
});
|
|
1451
|
+
if (!(isUnboundV4DocumentChange(comparison.change) ? jsonEqual(bindV4DocumentChange(comparison.change, comparison.before.document).apply(comparison.before.document), plan.change.apply(comparison.before.document)) : jsonEqual(rootEntriesJson(plan.change), rootEntriesJson(comparison.change))) || !sameChanges(plan, comparison.changes)) return null;
|
|
1324
1452
|
PLANS.set(comparison.change, plan);
|
|
1325
1453
|
return plan;
|
|
1326
1454
|
} catch {
|
|
@@ -1335,4 +1463,4 @@ const closeOverRequired = (groups, ids) => {
|
|
|
1335
1463
|
return closed;
|
|
1336
1464
|
};
|
|
1337
1465
|
//#endregion
|
|
1338
|
-
export {
|
|
1466
|
+
export { uniqueSpans as C, stripComparisonElementIds as S, fingerprintEditorJson as T, fillComparisonElementIds as _, comparisonTextRuns as a, spanKey$1 as b, COMPARISON_POLICY as c, comparisonChangeHashPayload as d, comparisonDocumentsEqual as f, detachComparisonEnvelope as g, detachComparisonDocument as h, comparisonTextPoint as i, COMPARISON_WORD as l, createComparisonSnapshot as m, comparisonPlanOf as n, comparisonTextSpans as o, comparisonHash as p, planComparison as r, createComparisonIndex as s, closeOverRequired as t, assertComparisonActive as u, mergeGroups as v, yieldComparisonWork as w, stableStringify as x, needsComparisonElementIds as y };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Wi as getDefined, Xr as defineEffect, ai as MAIN_ROOT_KEY, hi as PathApi, ii as PointApi, ni as LocationApi, oi as getCommonLocationRoot, ti as RangeApi } from "./law-check-Bvnz2EKh.js";
|
|
2
|
+
import { $a as previous, Al as authoredDocumentCapabilityPoint, As as createEditorReadApi, At as isVoid, Au as getPluginRegistry, Bc as constructLoadedDocumentChange, Bt as path$1, Cc as mapDetachedSelectionThroughChange, Cn as applyTransactionSpecToDocument, Co as nodes, Cu as setEditorLifecycleErrorSink, Ds as subscribe, Dt as isInline, Du as getCompiledEditorSchema, Ed as SelectionApi, Et as isEnd$1, Eu as finalizePluginRegistry, Fr as initializePublicState, Fu as registerEffectTypeInRegistry, G as before, Ga as range$1, Gn as getChildren$1, Gr as readEditor, Gt as range, H as above, Hr as loadOpenedRecords, Hs as admitDocument, Ic as loadElementIds, Id as getEditorRuntime, Ir as invalidateEditorTransactionSpecs, Ka as above$1, Ks as onlyDocumentAdmission, M as createCommandDispatch, Ma as getFragment, Md as isEditorContent, Ml as createEditorAnchorApi, Mr as initializeEditorSchemaDocument, Mu as initializeBasePluginRegistry, Ni as transformEditorSnapshotInput, Nr as initializeEditorSchemaSelection, Os as subscribeCommit, Pi as updateEditor, Pr as initializeEditorSchemaSnapshot, Qn as getEditorChildrenRoot, Ri as withEditorRootChildren, To as node, Tt as isEmpty$1, Tu as createPluginRegistry, Us as admitEditorDocument, V as NodeApi, Vd as setEditorRuntime, Vt as point, W as after, Wn as getChildList, Ws as documentAdmissionPoint, Xn as getCurrentSelection, Yl as assertNoDocumentViewRead, Zn as getCurrentSelectionRoot, _ as markEditorDormant, _c as assertSelectionSupported, _r as getPathByNodeKey, bd as failInvariant, d as extendEditor, dr as getLiveNode, eo as elementReadOnly, fn as voidEditor, fr as getLiveSelection, ft as hasInlines$1, hr as getNodeKey, io as after$1, jc as isEmptyElement, js as createEditorUpdateApi, jt as last$1, kn as createTransactionSpec, ks as subscribeSource, kt as isStart$1, ku as getPluginContributions, li as seedUniqueMaps, lo as getCharacterDistance, nc as createDetachedEditorSchema, ni as repairEditorValue, nt as getChildren, nu as hasActiveAnchors, oo as resolveShouldMergeNodesRemovePrevNode, pr as getLiveText, qs as repairLoadedDocument, rc as createEditorSchema, ro as before$1, s as createEditorViewPluginApis, si as saveEditorSchemaDocument, tr as getEditorDocumentValue, u as destroyEditor, uo as getWordDistances, ur as getLastCommit, ut as getSnapshot, v as prepareInitialPluginPublication, wc as mapSelectionThroughChange, wd as point$1, wi as snapshotInitialDocumentState, wo as normalizeNodeMatch, wu as assertPluginPublicationInactive, xr as getSnapshot$1, xt as isBlock$1, y as prepareScopedPluginPublication, zd as getEditorSchema, zi as withEditorRootChildrenGenerator, zt as parent$1 } from "./plugin-B8uCi-Hr.js";
|
|
2
3
|
/**
|
|
3
4
|
* Local, ephemeral screen-reader text emitted by an application command.
|
|
4
5
|
*
|
|
@@ -12,31 +13,6 @@ const screenReaderAnnouncementEffect = defineEffect({
|
|
|
12
13
|
});
|
|
13
14
|
const getScreenReaderAnnouncements = (effects) => effects.flatMap((effect) => effect.type.key === "screen-reader-announcement" && typeof effect.value === "string" && effect.value.trim().length > 0 ? [effect.value] : []);
|
|
14
15
|
//#endregion
|
|
15
|
-
//#region src/editor/above.ts
|
|
16
|
-
const assertNumericPath = (path) => {
|
|
17
|
-
for (const index of path) if (typeof index !== "number") throw new Error("Got non-numeric path index");
|
|
18
|
-
};
|
|
19
|
-
const above = ((editor, options = {}) => {
|
|
20
|
-
const { voids = false, mode = "lowest", at = getSnapshot(editor).selection, match, type } = options;
|
|
21
|
-
if (!at || !LocationApi.isLocation(at)) return;
|
|
22
|
-
let path;
|
|
23
|
-
path = path$1(editor, at);
|
|
24
|
-
assertNumericPath(path);
|
|
25
|
-
if (!LocationApi.isRange(at) || PathApi.equals(at.focus.path, at.anchor.path)) {
|
|
26
|
-
if (path.length === 0) return void 0;
|
|
27
|
-
path = PathApi.parent(path);
|
|
28
|
-
}
|
|
29
|
-
if (!NodeApi.has(editor, path)) return;
|
|
30
|
-
const [firstMatch] = levels$1(editor, {
|
|
31
|
-
at: path,
|
|
32
|
-
voids,
|
|
33
|
-
match,
|
|
34
|
-
reverse: mode === "lowest",
|
|
35
|
-
type
|
|
36
|
-
});
|
|
37
|
-
return firstMatch;
|
|
38
|
-
});
|
|
39
|
-
//#endregion
|
|
40
16
|
//#region src/editor/edges.ts
|
|
41
17
|
const edges = (editor, at) => [point(editor, at, { edge: "start" }), point(editor, at, { edge: "end" })];
|
|
42
18
|
//#endregion
|
|
@@ -46,7 +22,7 @@ const first = (editor, at) => {
|
|
|
46
22
|
};
|
|
47
23
|
//#endregion
|
|
48
24
|
//#region src/editor/get-void.ts
|
|
49
|
-
const getVoid = (editor, options = {}) => above
|
|
25
|
+
const getVoid = (editor, options = {}) => above(editor, {
|
|
50
26
|
...options,
|
|
51
27
|
match: (n) => NodeApi.isElement(n) && isVoid(editor, n)
|
|
52
28
|
});
|
|
@@ -198,7 +174,7 @@ const comparePoints = (left, right) => {
|
|
|
198
174
|
};
|
|
199
175
|
const getAtomicNonTraversablePoint = (editor, path, voids) => {
|
|
200
176
|
if (voids) return null;
|
|
201
|
-
const atomicEntry = above
|
|
177
|
+
const atomicEntry = above(editor, {
|
|
202
178
|
at: path,
|
|
203
179
|
match: (node) => NodeApi.isElement(node) && (getEditorSchema(editor).isAtom(node) || getEditorSchema(editor).isReadOnly(node)),
|
|
204
180
|
mode: "highest",
|
|
@@ -480,46 +456,6 @@ function* positions(editor, options = {}) {
|
|
|
480
456
|
}
|
|
481
457
|
}
|
|
482
458
|
//#endregion
|
|
483
|
-
//#region src/editor/previous.ts
|
|
484
|
-
const previous = ((editor, options = {}) => {
|
|
485
|
-
const { from = "before", mode = "lowest", voids = false } = options;
|
|
486
|
-
const { at = getSnapshot(editor).selection } = options;
|
|
487
|
-
let match = normalizeNodeMatch(options.type, options.match);
|
|
488
|
-
if (!at || !LocationApi.isLocation(at)) return;
|
|
489
|
-
if (LocationApi.isPath(at) && at.length === 0) return;
|
|
490
|
-
if (options.sibling) {
|
|
491
|
-
if (!LocationApi.isPath(at)) return;
|
|
492
|
-
if (!PathApi.hasPrevious(at)) return;
|
|
493
|
-
const previousPath = PathApi.previous(at);
|
|
494
|
-
if (!NodeApi.has(editor, previousPath)) return;
|
|
495
|
-
return node(editor, previousPath);
|
|
496
|
-
}
|
|
497
|
-
let start;
|
|
498
|
-
if (from === "parent" && LocationApi.isPath(at) && at.length > 1) {
|
|
499
|
-
start = at;
|
|
500
|
-
const baseMatch = match;
|
|
501
|
-
match = (node, path) => !PathApi.isAfter(path, at) && !PathApi.equals(path, at) && (baseMatch?.(node, path) ?? true);
|
|
502
|
-
}
|
|
503
|
-
const pointBeforeLocation = start ? void 0 : before(editor, at, { voids });
|
|
504
|
-
if (!start) {
|
|
505
|
-
if (!pointBeforeLocation) return;
|
|
506
|
-
start = pointBeforeLocation.path;
|
|
507
|
-
}
|
|
508
|
-
const firstEntry = first$1(editor, []);
|
|
509
|
-
if (!firstEntry) return;
|
|
510
|
-
const [, to] = firstEntry;
|
|
511
|
-
const span = [start, to];
|
|
512
|
-
if (match == null) match = LocationApi.isPath(at) ? (_node, path) => PathApi.isSibling(path, at) : () => true;
|
|
513
|
-
const [innerPrevious] = nodes(editor, {
|
|
514
|
-
reverse: true,
|
|
515
|
-
at: span,
|
|
516
|
-
match,
|
|
517
|
-
mode,
|
|
518
|
-
voids
|
|
519
|
-
});
|
|
520
|
-
return innerPrevious;
|
|
521
|
-
});
|
|
522
|
-
//#endregion
|
|
523
459
|
//#region src/range-projection.ts
|
|
524
460
|
const lastProjection = /* @__PURE__ */ new WeakMap();
|
|
525
461
|
const projectRangeInSnapshot = (snapshot, range) => {
|
|
@@ -628,7 +564,7 @@ const unhangRange = (editor, range, options = {}) => {
|
|
|
628
564
|
const [start, initialEnd] = RangeApi.edges(range);
|
|
629
565
|
let end = initialEnd;
|
|
630
566
|
if (start.offset !== 0 || end.offset !== 0 || RangeApi.isCollapsed(range) || PathApi.hasPrevious(end.path)) return inputRange;
|
|
631
|
-
const endBlock = above
|
|
567
|
+
const endBlock = above(editor, {
|
|
632
568
|
at: end,
|
|
633
569
|
match: (n) => NodeApi.isElement(n) && isBlock$1(editor, n),
|
|
634
570
|
voids
|
|
@@ -696,7 +632,7 @@ const withExplicitRangeRoot = (innerRange, root) => root ? {
|
|
|
696
632
|
focus: withExplicitPointRoot(innerRange.focus, root)
|
|
697
633
|
} : innerRange;
|
|
698
634
|
const createEditorReadRuntime = (editor) => ({
|
|
699
|
-
above: (options) => (({ options: innerOptions }) => withOptionsQueryRoot(editor, innerOptions, () => above(editor, innerOptions), { selectionFallback: usesImplicitSelectionLocation(innerOptions) }))({ options }),
|
|
635
|
+
above: (options) => (({ options: innerOptions }) => withOptionsQueryRoot(editor, innerOptions, () => above$1(editor, innerOptions), { selectionFallback: usesImplicitSelectionLocation(innerOptions) }))({ options }),
|
|
700
636
|
after: (at, options) => (({ at: innerAt, options: innerOptions2 }) => {
|
|
701
637
|
const root = getQueryRoot(editor, [innerAt]);
|
|
702
638
|
return withQueryRoot(editor, [innerAt], () => withExplicitPointRoot(after$1(editor, innerAt, innerOptions2), root));
|
|
@@ -875,9 +811,10 @@ const publishInitialPlugins = (editor, input, explicitInitialDocument, options =
|
|
|
875
811
|
const initialSelectionRoot = getCurrentSelectionRoot(editor);
|
|
876
812
|
const preparedDocumentValidated = publication.configurationChanged && explicitInitialDocument && publication.documentChange.empty;
|
|
877
813
|
try {
|
|
878
|
-
adoptInitialDocumentChange(editor, publication.documentChange, publication.schemaCompilation());
|
|
814
|
+
const mappedSelection = adoptInitialDocumentChange(editor, publication.documentChange, publication.schemaCompilation());
|
|
879
815
|
publication.stage();
|
|
880
816
|
publication.commit();
|
|
817
|
+
if (mappedSelection) initializeEditorSchemaSelection(editor, mappedSelection.selection, mappedSelection.root);
|
|
881
818
|
const validatePublishedDocument = (requireExplicitDocument = explicitInitialDocument, validateDocument = true) => {
|
|
882
819
|
const publishedDocument = getEditorDocumentValue(editor);
|
|
883
820
|
if (requireExplicitDocument && publishedDocument.children.length === 0) throw new Error("initialValue is invalid! Expected at least one element.");
|
|
@@ -919,20 +856,31 @@ const publishInitialPlugins = (editor, input, explicitInitialDocument, options =
|
|
|
919
856
|
if (getPluginRegistry(editor).schemaContributions.records.size > 0) disarmSchemaBootstrap(editor);
|
|
920
857
|
};
|
|
921
858
|
const adoptInitialDocumentChange = (editor, change, compilation) => {
|
|
922
|
-
if (change.empty) return;
|
|
859
|
+
if (change.empty) return null;
|
|
923
860
|
const initialDocument = getEditorDocumentValue(editor);
|
|
924
861
|
const initialSelection = getLiveSelection(editor);
|
|
925
862
|
const initialSelectionRoot = getCurrentSelectionRoot(editor);
|
|
926
863
|
const schema = compilation?.schema ?? getCompiledEditorSchema(editor);
|
|
927
864
|
const admitted = admitDocument(compilation && onlyDocumentAdmission(compilation.contributions(documentAdmissionPoint)), change.apply(initialDocument), schema);
|
|
928
|
-
initializeEditorSchemaDocument(editor, admitted.document, schema);
|
|
929
|
-
if (!initialSelection) return;
|
|
930
|
-
const
|
|
865
|
+
initializeEditorSchemaDocument(editor, admitted.document, schema, true);
|
|
866
|
+
if (!initialSelection) return null;
|
|
867
|
+
const detachedSchema = compilation ? createDetachedEditorSchema(schema, admitted.document) : null;
|
|
868
|
+
const mapped = detachedSchema ? mapDetachedSelectionThroughChange(detachedSchema, initialSelection, change.compose(admitted.change), initialDocument, admitted.document, initialSelectionRoot, {
|
|
869
|
+
association: "backward",
|
|
870
|
+
preferPositionMapping: true
|
|
871
|
+
}) : mapSelectionThroughChange(editor, initialSelection, change.compose(admitted.change), initialDocument, admitted.document, initialSelectionRoot, {
|
|
931
872
|
association: "backward",
|
|
932
873
|
preferPositionMapping: true
|
|
933
874
|
}).selection;
|
|
934
875
|
if (!mapped) throw new Error("Initial selection cannot be mapped through schema fitting.");
|
|
935
|
-
|
|
876
|
+
if (detachedSchema && SelectionApi.isText(initialSelection) && initialSelection.marks !== void 0 && SelectionApi.isText(mapped)) {
|
|
877
|
+
const marksRoot = mapped.focus.root ?? SelectionApi.root(mapped) ?? initialSelectionRoot;
|
|
878
|
+
detachedSchema.validateTextPropertiesAtValue(initialSelection.marks, mapped.focus.path, admitted.document, marksRoot);
|
|
879
|
+
}
|
|
880
|
+
return {
|
|
881
|
+
root: initialSelectionRoot,
|
|
882
|
+
selection: mapped
|
|
883
|
+
};
|
|
936
884
|
};
|
|
937
885
|
const assertEditorSchemaBootstrap = (editor) => {
|
|
938
886
|
if (!PENDING_SCHEMA_BOOTSTRAP.has(editor)) throw new Error("Editor schema initialization requires an editor without an installed schema.");
|
|
@@ -1094,15 +1042,19 @@ const createEditorImplementation = (options, dormant) => {
|
|
|
1094
1042
|
armSchemaBootstrap(editor);
|
|
1095
1043
|
if (options.plugins) publishInitialPlugins(editor, options.plugins, initialState.explicit);
|
|
1096
1044
|
else {
|
|
1045
|
+
snapshotInitialDocumentState(editor);
|
|
1097
1046
|
loadOpenedRecords(editor, void 0);
|
|
1098
1047
|
const initialDocument = getEditorDocumentValue(editor);
|
|
1099
1048
|
if (initialState.explicit && initialDocument.children.length === 0) throw new Error("initialValue is invalid! Expected at least one element.");
|
|
1100
1049
|
assertSelectionSupported(editor, getLiveSelection(editor), initialDocument);
|
|
1101
|
-
|
|
1050
|
+
getEditorSchema(editor).assertDocument(initialDocument);
|
|
1051
|
+
const compiled = getCompiledEditorSchema(editor);
|
|
1052
|
+
const repair = repairLoadedDocument(null, initialDocument, compiled, loadElementIds(compiled, initialDocument, null));
|
|
1053
|
+
adoptInitialDocumentChange(editor, repair ? repair.change.compose(constructLoadedDocumentChange(editor, repair.value)) : constructLoadedDocumentChange(editor, initialDocument), null);
|
|
1102
1054
|
seedUniqueMaps(editor);
|
|
1103
1055
|
}
|
|
1104
1056
|
snapshotInitialDocumentState(editor);
|
|
1105
1057
|
return editor;
|
|
1106
1058
|
};
|
|
1107
1059
|
//#endregion
|
|
1108
|
-
export {
|
|
1060
|
+
export { createEditor as a, initializePlugins as c, assertEditorOptions as d, readEditorOptions as f, screenReaderAnnouncementEffect as g, getScreenReaderAnnouncements as h, createDormantEditor as i, withCompiledEditorSchemaCapabilityEntries as l, getTextRunBetweenAtomics as m, compileEditorSchemaContract as n, getEditorAuthoredDocumentCapability as o, projectRangeInSnapshot as p, compileEditorSchemaContractEntries as r, initializePluginEntries as s, compileEditorSchemaCapabilityEntries as t, EDITOR_OPTION_KEYS as u };
|
package/dist/diff/index.d.ts
CHANGED
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/diff/lib/compare.d.ts
|
|
4
|
-
type TwoWayInput<V extends Value> = Readonly<{
|
|
5
|
-
after: unknown;
|
|
6
|
-
before: unknown;
|
|
7
|
-
projection?: Readonly<{
|
|
8
|
-
after: 'accepted' | 'proposed';
|
|
9
|
-
before: 'accepted' | 'proposed';
|
|
10
|
-
}>;
|
|
11
|
-
schema: EditorStateSchemaApi<V>;
|
|
12
|
-
signal?: AbortSignal;
|
|
13
|
-
}>;
|
|
14
|
-
type ThreeWayInput<V extends Value> = Readonly<{
|
|
15
|
-
base: unknown;
|
|
16
|
-
local: unknown;
|
|
17
|
-
remote: unknown;
|
|
18
|
-
schema: EditorStateSchemaApi<V>;
|
|
19
|
-
signal?: AbortSignal;
|
|
20
|
-
}>;
|
|
21
|
-
/** Compare immutable schema-valid documents without installing editor state. */
|
|
22
|
-
declare function compare<V extends Value>(input: ThreeWayInput<V>): Promise<ThreeWayComparison<V>>;
|
|
23
|
-
declare function compare<V extends Value>(input: TwoWayInput<V>): Promise<TwoWayComparison<V>>;
|
|
24
|
-
/** Resolve one published three-way comparison without rematching its inputs. */
|
|
25
|
-
declare function resolveComparison<V extends Value>(input: Readonly<{
|
|
26
|
-
baseline: 'base' | ComparisonBranch;
|
|
27
|
-
comparison: ThreeWayComparison<V>;
|
|
28
|
-
resolutions?: readonly ComparisonResolution[];
|
|
29
|
-
signal?: AbortSignal;
|
|
30
|
-
}>): Promise<ComparisonResolutionResult<V>>;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { ComparedChange, Comparison, ComparisonBranch, ComparisonConflict, ComparisonConflictAlternative, ComparisonCorrespondence, ComparisonDiagnostic, ComparisonEffect, ComparisonEvidence, ComparisonResolution, ComparisonResolutionResult, ComparisonSnapshot, ComparisonSpan, ThreeWayComparison, TwoWayComparison, compare, resolveComparison };
|
|
1
|
+
import { a as ComparisonDiagnostic, c as ComparisonSnapshot, i as ComparisonCorrespondence, l as ComparisonSpan, n as ComparedChange, o as ComparisonEffect, r as Comparison, s as ComparisonEvidence, t as compare } from "../index-DM-b6jEe.js";
|
|
2
|
+
export { ComparedChange, Comparison, ComparisonCorrespondence, ComparisonDiagnostic, ComparisonEffect, ComparisonEvidence, ComparisonSnapshot, ComparisonSpan, compare };
|