plitejs 0.0.1 → 54.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -1
- package/README.md +83 -0
- package/dist/annotation-store-metrics-Ccjkef45.js +12 -0
- package/dist/annotations/index.d.ts +2 -0
- package/dist/annotations/index.js +2 -0
- package/dist/authored/index.d.ts +596 -0
- package/dist/authored/index.js +18558 -0
- package/dist/authored-veto-DSnQcHGR.js +6 -0
- package/dist/browser-protocol-pvt4HFF7.js +5 -0
- package/dist/comparison-plan-CEQL0ooW.js +1338 -0
- package/dist/comparison-types-Dt-unJZY.d.ts +179 -0
- package/dist/create-editor-CkHtPWXV.js +1107 -0
- package/dist/diff/index.d.ts +32 -0
- package/dist/diff/index.js +1748 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.js +2 -0
- package/dist/dom-Cgfscvnm.js +9220 -0
- package/dist/editor-owner-IUmkTeXz.js +171 -0
- package/dist/editor-view-lifetime-GJKa_QGh.js +23 -0
- package/dist/history/index.d.ts +170 -0
- package/dist/history/index.js +6718 -0
- package/dist/hyperscript/index.d.ts +2 -0
- package/dist/hyperscript/index.js +2 -0
- package/dist/hyperscript-FPuoArEi.js +299 -0
- package/dist/index-BpQx2UG4.d.ts +1093 -0
- package/dist/index-Cw-oC2ps.d.ts +190 -0
- package/dist/index-DPWyk3lG.d.ts +65 -0
- package/dist/index-DpltOCot.d.ts +9753 -0
- package/dist/index-HPYawTae.d.ts +119 -0
- package/dist/index-K0Za9YXc.d.ts +1246 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +156 -0
- package/dist/mapped-view-store-ld-6uxEU.js +120 -0
- package/dist/native-grouping-input-DMNcsIaW.js +8 -0
- package/dist/pagination/index.d.ts +169 -0
- package/dist/pagination/index.js +2 -0
- package/dist/pagination/react.d.ts +33 -0
- package/dist/pagination/react.js +1509 -0
- package/dist/pagination-D_A8iPJP.js +1021 -0
- package/dist/plugin-DWzkJbnJ.js +50999 -0
- package/dist/range-geometry-BLAHRE11.d.ts +38 -0
- package/dist/range-geometry-BjeLHOnl.js +486 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.js +7 -0
- package/dist/react/virtualized.d.ts +13 -0
- package/dist/react/virtualized.js +209 -0
- package/dist/react-DZ15gmz2.js +1018 -0
- package/dist/retraction-BMem8Rfk.js +109 -0
- package/dist/src-cT1OTKP_.js +1386 -0
- package/dist/store-Cz2mXyDe.js +704 -0
- package/dist/testing/index.d.ts +183 -0
- package/dist/testing/index.js +96 -0
- package/dist/use-editor-dom-scope-BbMDSCpW.js +28354 -0
- package/dist/yjs/index.d.ts +2 -0
- package/dist/yjs/index.js +2 -0
- package/dist/yjs/react/index.d.ts +26 -0
- package/dist/yjs/react/index.js +85 -0
- package/dist/yjs-DOK-m7kl.js +13413 -0
- package/package.json +191 -43
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Td as applyPropertyModifications, Wd as PreparedTokenSlice, Xd as isTextNode, Yd as isElementNode, ip as getDefined, nf as tokensEqual } from "./plugin-DWzkJbnJ.js";
|
|
2
|
+
//#region src/core/missing-reference.ts
|
|
3
|
+
/**
|
|
4
|
+
* A draft names something the document does not hold yet, such as a record a
|
|
5
|
+
* collaborator has not sent, so a collaboration binding waits for more input
|
|
6
|
+
* instead of failing. A refusal carries it as its cause.
|
|
7
|
+
*/
|
|
8
|
+
var EditorMissingReferenceError = class extends Error {
|
|
9
|
+
name = "EditorMissingReferenceError";
|
|
10
|
+
};
|
|
11
|
+
const isMissingReference = (error) => {
|
|
12
|
+
for (let current = error; current instanceof Error; current = current.cause) if (current instanceof EditorMissingReferenceError) return true;
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/core/change/retraction.ts
|
|
17
|
+
const blockAt = (base, position) => {
|
|
18
|
+
let low = 0;
|
|
19
|
+
let high = base.size - 1;
|
|
20
|
+
while (low < high) {
|
|
21
|
+
const middle = low + high + 1 >> 1;
|
|
22
|
+
if (base.childPosition([], middle) <= position) low = middle;
|
|
23
|
+
else high = middle - 1;
|
|
24
|
+
}
|
|
25
|
+
return low;
|
|
26
|
+
};
|
|
27
|
+
const pathKey = (path) => path.join(",");
|
|
28
|
+
const parentAt = (base, position) => {
|
|
29
|
+
const last = base.openContextAt(position).at(-1);
|
|
30
|
+
if (!last) return [];
|
|
31
|
+
return last.kind === "element" && last.from < position && position < last.to ? last.path : last.path.slice(0, -1);
|
|
32
|
+
};
|
|
33
|
+
const holdsLetterOrElement = (tokens) => tokens.some((token) => token.kind === "text" ? token.text.length > 0 : token.nodeKind !== "text");
|
|
34
|
+
const retractionOf = (base, change, readEmpty) => {
|
|
35
|
+
const modified = /* @__PURE__ */ new Map();
|
|
36
|
+
let from = 0;
|
|
37
|
+
for (let index = 0; index < change.sections.length; index += 2) {
|
|
38
|
+
const length = getDefined(change.sections[index]);
|
|
39
|
+
if (change.sections[index + 1] === -2) modified.set(from, change.data[index / 2]);
|
|
40
|
+
from += length;
|
|
41
|
+
}
|
|
42
|
+
const propsAt = (path) => {
|
|
43
|
+
const { children: _children, ...props } = base.node(path);
|
|
44
|
+
const modifications = modified.get(base.nodeRange(path).from);
|
|
45
|
+
return modifications ? applyPropertyModifications(props, modifications) : props;
|
|
46
|
+
};
|
|
47
|
+
const storesText = (insert, position) => {
|
|
48
|
+
if (!insert.tokens.some((token) => token.kind === "open")) return true;
|
|
49
|
+
const parent = parentAt(base, position);
|
|
50
|
+
if (parent.length === 0) return false;
|
|
51
|
+
const node = base.node(parent);
|
|
52
|
+
if (isElementNode(node) && node.children.some(isTextNode)) return true;
|
|
53
|
+
const read = readEmpty(parent.map((_, depth) => propsAt(parent.slice(0, parent.length - depth))));
|
|
54
|
+
const expected = read && PreparedTokenSlice.fromNodes([read]);
|
|
55
|
+
return !!expected && expected.tokens.length === insert.tokens.length && expected.tokens.every((token, at) => tokensEqual(token, getDefined(insert.tokens[at])));
|
|
56
|
+
};
|
|
57
|
+
const elements = [];
|
|
58
|
+
const characters = [];
|
|
59
|
+
const touched = /* @__PURE__ */ new Set();
|
|
60
|
+
from = 0;
|
|
61
|
+
for (let index = 0; index < change.sections.length; index += 2) {
|
|
62
|
+
const length = getDefined(change.sections[index]);
|
|
63
|
+
const inserted = getDefined(change.sections[index + 1]);
|
|
64
|
+
if (inserted !== -1) {
|
|
65
|
+
if (base.size === 0) return null;
|
|
66
|
+
const last = blockAt(base, Math.max(from, from + length - 1));
|
|
67
|
+
for (let block = blockAt(base, from); block <= last; block += 1) touched.add(block);
|
|
68
|
+
}
|
|
69
|
+
if (inserted >= 0) {
|
|
70
|
+
const insert = change.data[index / 2] ?? PreparedTokenSlice.empty;
|
|
71
|
+
if (holdsLetterOrElement(insert.tokens) || !storesText(insert, from)) return null;
|
|
72
|
+
const open = [];
|
|
73
|
+
let at = from;
|
|
74
|
+
for (const token of length > 0 ? base.slice(from, from + length).tokens : []) {
|
|
75
|
+
if (token.kind === "text") {
|
|
76
|
+
if (open.length === 0 && token.text.length > 0) {
|
|
77
|
+
const text = getDefined(base.textAt(at));
|
|
78
|
+
const offset = at - text.contentFrom;
|
|
79
|
+
const previous = characters.at(-1);
|
|
80
|
+
if (previous && previous.to === offset && pathKey(previous.path) === pathKey(text.path)) previous.to += token.text.length;
|
|
81
|
+
else characters.push({
|
|
82
|
+
from: offset,
|
|
83
|
+
path: text.path,
|
|
84
|
+
to: offset + token.text.length
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
at += token.text.length;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (token.nodeKind === "element") if (token.kind === "open") open.push(at);
|
|
91
|
+
else {
|
|
92
|
+
const opened = open.pop();
|
|
93
|
+
if (opened === void 0) return null;
|
|
94
|
+
if (open.length === 0) elements.push(getDefined(base.nodeStartingAt(opened)).path);
|
|
95
|
+
}
|
|
96
|
+
at += 1;
|
|
97
|
+
}
|
|
98
|
+
if (open.length > 0) return null;
|
|
99
|
+
}
|
|
100
|
+
from += length;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
blocks: [...touched].sort((left, right) => left - right),
|
|
104
|
+
characters,
|
|
105
|
+
elements
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { EditorMissingReferenceError as n, isMissingReference as r, retractionOf as t };
|