@layers-app/editor 0.5.8-optimization → 0.5.10-optimization
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 +0 -19
- package/dist/ExcalidrawComponent-D7Z_2awF.cjs +1 -0
- package/dist/ExcalidrawComponent-Re4zFgLg.js +283 -0
- package/dist/InlineImageComponent-DHgCaPNk.cjs +1 -0
- package/dist/InlineImageComponent-kXhZcmF6.js +265 -0
- package/dist/collaboration-C7xVk0Zj.cjs +4 -0
- package/dist/collaboration-Cn7KizEJ.js +5997 -0
- package/dist/excalidraw-C-6bid_P.js +16497 -0
- package/dist/excalidraw-DpwKTNBz.cjs +574 -0
- package/dist/index-B4yOqKUQ.cjs +1 -0
- package/dist/index-BZu8Qnrg.cjs +1 -0
- package/dist/index-CFA9Drk2.cjs +16 -0
- package/dist/index-CX5msaMB.js +296 -0
- package/dist/index-CbQX0N2c.js +136 -0
- package/dist/index-DEC5JR_F.js +60 -0
- package/dist/index-Dan3tqoj.cjs +1 -0
- package/dist/index-WCOc4LNL.js +16600 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +12 -13
- package/dist/lexical-2rxs76dr.cjs +41 -0
- package/dist/lexical-C60GkwxR.js +13122 -0
- package/dist/lexical-code-DKIWiZdJ.js +604 -0
- package/dist/lexical-code-VafvPacU.cjs +9 -0
- package/dist/lexical-collab-1tX9tFVC.js +1025 -0
- package/dist/lexical-collab-Nk2LVpJv.cjs +1 -0
- package/dist/lexical-file-C52Mze5k.cjs +1 -0
- package/dist/lexical-file-DjHP4vVw.js +43 -0
- package/dist/lexical-markdown-BSl_ahWw.cjs +12 -0
- package/dist/lexical-markdown-DcEwQQba.js +488 -0
- package/dist/lodash-3PEMjFQT.cjs +1 -0
- package/dist/lodash-jftOdrxX.js +711 -0
- package/dist/stats.html +4949 -0
- package/dist/vendor-BrXDSyZX.js +136433 -0
- package/dist/vendor-Bt6Lma3y.cjs +2469 -0
- package/package.json +42 -74
- package/dist/layers.8yssqxrI.js +0 -6774
- package/dist/layers.B8z-e4Vg.js +0 -7
- package/dist/layers.BQLznd92.js +0 -4
- package/dist/layers.BVRvG1mv.js +0 -3
- package/dist/layers.BjCQNcdJ.js +0 -341
- package/dist/layers.BnVn2uMi.js +0 -7723
- package/dist/layers.CLcioDq5.js +0 -2511
- package/dist/layers.CTSBFg3j.js +0 -1
- package/dist/layers.CoCZDINv.js +0 -864
- package/dist/layers.D0ZtUpST.js +0 -2
- package/dist/layers.D2zjLyjP.js +0 -6
- package/dist/layers.DNCgFYS7.js +0 -27
- package/dist/layers.Dt_Jdn4Y.js +0 -2227
- package/dist/layers.DwX5sVtx.js +0 -1
- package/dist/layers.QjAkD17S.js +0 -3677
- package/dist/layers.pre7B8K-.js +0 -530
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
var Re = Object.defineProperty;
|
|
2
|
+
var We = (t, e, n) => e in t ? Re(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var T = (t, e, n) => We(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { w as Te, r as O, x as L, B as Z, F as I, _ as fe, a as w, G as V, H as Ue, m as se, I as Be, N as Ge, $ as Qe, g as Y, y as W, O as Ve, Q as Xe, R as we, V as Ne, W as Pe, Y as D, L as Ee, Z as He, a0 as Je, a1 as Ze, a2 as ue, U as Oe, a3 as qe, a4 as U, a5 as et, a6 as tt, a7 as nt, a8 as G, a9 as ot, aa as st } from "./lexical-C60GkwxR.js";
|
|
5
|
+
import { Y as A, U as Fe, a as F, b as K, D as ee, c as rt, d as de, e as it, f as lt, g as te, h as ct } from "./collaboration-Cn7KizEJ.js";
|
|
6
|
+
import * as at from "react";
|
|
7
|
+
import { useRef as ne, useState as q, useEffect as M, useMemo as Me, useCallback as X } from "react";
|
|
8
|
+
import { createPortal as ft } from "react-dom";
|
|
9
|
+
import { jsx as oe, Fragment as ut } from "react/jsx-runtime";
|
|
10
|
+
function v(t, ...e) {
|
|
11
|
+
const n = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
|
|
12
|
+
o.append("code", t);
|
|
13
|
+
for (const s of e) o.append("v", s);
|
|
14
|
+
throw n.search = o.toString(), Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
|
|
15
|
+
}
|
|
16
|
+
function dt(t, e, n) {
|
|
17
|
+
const o = t.length, s = e.length;
|
|
18
|
+
let r = 0, i = 0;
|
|
19
|
+
for (; r < o && r < s && t[r] === e[r] && r < n; ) r++;
|
|
20
|
+
for (; i + r < o && i + r < s && t[o - i - 1] === e[s - i - 1]; ) i++;
|
|
21
|
+
for (; i + r < o && i + r < s && t[r] === e[r]; ) r++;
|
|
22
|
+
return { index: r, insert: e.slice(r, s - i), remove: o - r - i };
|
|
23
|
+
}
|
|
24
|
+
let z = class {
|
|
25
|
+
constructor(e, n, o) {
|
|
26
|
+
T(this, "_xmlElem");
|
|
27
|
+
T(this, "_key");
|
|
28
|
+
T(this, "_parent");
|
|
29
|
+
T(this, "_type");
|
|
30
|
+
this._key = "", this._xmlElem = e, this._parent = n, this._type = o;
|
|
31
|
+
}
|
|
32
|
+
getPrevNode(e) {
|
|
33
|
+
if (e === null) return null;
|
|
34
|
+
const n = e.get(this._key);
|
|
35
|
+
return V(n) ? n : null;
|
|
36
|
+
}
|
|
37
|
+
getNode() {
|
|
38
|
+
const e = L(this._key);
|
|
39
|
+
return V(e) ? e : null;
|
|
40
|
+
}
|
|
41
|
+
getSharedType() {
|
|
42
|
+
return this._xmlElem;
|
|
43
|
+
}
|
|
44
|
+
getType() {
|
|
45
|
+
return this._type;
|
|
46
|
+
}
|
|
47
|
+
getKey() {
|
|
48
|
+
return this._key;
|
|
49
|
+
}
|
|
50
|
+
getSize() {
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
getOffset() {
|
|
54
|
+
return this._parent.getChildOffset(this);
|
|
55
|
+
}
|
|
56
|
+
syncPropertiesFromLexical(e, n, o) {
|
|
57
|
+
const s = this.getPrevNode(o);
|
|
58
|
+
ce(e, this._xmlElem, s, n);
|
|
59
|
+
}
|
|
60
|
+
syncPropertiesFromYjs(e, n) {
|
|
61
|
+
const o = this.getNode();
|
|
62
|
+
o === null && v(83), le(e, this._xmlElem, o, n);
|
|
63
|
+
}
|
|
64
|
+
destroy(e) {
|
|
65
|
+
const n = e.collabNodeMap;
|
|
66
|
+
n.get(this._key) === this && n.delete(this._key);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function je(t, e, n) {
|
|
70
|
+
const o = new z(t, e, n);
|
|
71
|
+
return t._collabNode = o, o;
|
|
72
|
+
}
|
|
73
|
+
class R {
|
|
74
|
+
constructor(e, n) {
|
|
75
|
+
T(this, "_map");
|
|
76
|
+
T(this, "_key");
|
|
77
|
+
T(this, "_parent");
|
|
78
|
+
T(this, "_type");
|
|
79
|
+
this._key = "", this._map = e, this._parent = n, this._type = "linebreak";
|
|
80
|
+
}
|
|
81
|
+
getNode() {
|
|
82
|
+
const e = L(this._key);
|
|
83
|
+
return se(e) ? e : null;
|
|
84
|
+
}
|
|
85
|
+
getKey() {
|
|
86
|
+
return this._key;
|
|
87
|
+
}
|
|
88
|
+
getSharedType() {
|
|
89
|
+
return this._map;
|
|
90
|
+
}
|
|
91
|
+
getType() {
|
|
92
|
+
return this._type;
|
|
93
|
+
}
|
|
94
|
+
getSize() {
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
getOffset() {
|
|
98
|
+
return this._parent.getChildOffset(this);
|
|
99
|
+
}
|
|
100
|
+
destroy(e) {
|
|
101
|
+
const n = e.collabNodeMap;
|
|
102
|
+
n.get(this._key) === this && n.delete(this._key);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function ze(t, e) {
|
|
106
|
+
const n = new R(t, e);
|
|
107
|
+
return t._collabNode = n, n;
|
|
108
|
+
}
|
|
109
|
+
class P {
|
|
110
|
+
constructor(e, n, o, s) {
|
|
111
|
+
T(this, "_map");
|
|
112
|
+
T(this, "_key");
|
|
113
|
+
T(this, "_parent");
|
|
114
|
+
T(this, "_text");
|
|
115
|
+
T(this, "_type");
|
|
116
|
+
T(this, "_normalized");
|
|
117
|
+
this._key = "", this._map = e, this._parent = o, this._text = n, this._type = s, this._normalized = !1;
|
|
118
|
+
}
|
|
119
|
+
getPrevNode(e) {
|
|
120
|
+
if (e === null) return null;
|
|
121
|
+
const n = e.get(this._key);
|
|
122
|
+
return w(n) ? n : null;
|
|
123
|
+
}
|
|
124
|
+
getNode() {
|
|
125
|
+
const e = L(this._key);
|
|
126
|
+
return w(e) ? e : null;
|
|
127
|
+
}
|
|
128
|
+
getSharedType() {
|
|
129
|
+
return this._map;
|
|
130
|
+
}
|
|
131
|
+
getType() {
|
|
132
|
+
return this._type;
|
|
133
|
+
}
|
|
134
|
+
getKey() {
|
|
135
|
+
return this._key;
|
|
136
|
+
}
|
|
137
|
+
getSize() {
|
|
138
|
+
return this._text.length + (this._normalized ? 0 : 1);
|
|
139
|
+
}
|
|
140
|
+
getOffset() {
|
|
141
|
+
return this._parent.getChildOffset(this);
|
|
142
|
+
}
|
|
143
|
+
spliceText(e, n, o) {
|
|
144
|
+
const s = this._parent._xmlText, r = this.getOffset() + 1 + e;
|
|
145
|
+
n !== 0 && s.delete(r, n), o !== "" && s.insert(r, o);
|
|
146
|
+
}
|
|
147
|
+
syncPropertiesAndTextFromLexical(e, n, o) {
|
|
148
|
+
const s = this.getPrevNode(o), r = n.__text;
|
|
149
|
+
if (ce(e, this._map, s, n), s !== null) {
|
|
150
|
+
const i = s.__text;
|
|
151
|
+
i !== r && ((function(l, c, d, u) {
|
|
152
|
+
const a = Y();
|
|
153
|
+
let f = u.length;
|
|
154
|
+
if (W(a) && a.isCollapsed()) {
|
|
155
|
+
const y = a.anchor;
|
|
156
|
+
y.key === c && (f = y.offset);
|
|
157
|
+
}
|
|
158
|
+
const h = dt(d, u, f);
|
|
159
|
+
l.spliceText(h.index, h.remove, h.insert);
|
|
160
|
+
})(this, n.__key, i, r), this._text = r);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
syncPropertiesAndTextFromYjs(e, n) {
|
|
164
|
+
const o = this.getNode();
|
|
165
|
+
o === null && v(84), le(e, this._map, o, n);
|
|
166
|
+
const s = this._text;
|
|
167
|
+
o.__text !== s && o.setTextContent(s);
|
|
168
|
+
}
|
|
169
|
+
destroy(e) {
|
|
170
|
+
const n = e.collabNodeMap;
|
|
171
|
+
n.get(this._key) === this && n.delete(this._key);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function Le(t, e, n, o) {
|
|
175
|
+
const s = new P(t, e, n, o);
|
|
176
|
+
return t._collabNode = s, s;
|
|
177
|
+
}
|
|
178
|
+
class E {
|
|
179
|
+
constructor(e, n, o) {
|
|
180
|
+
T(this, "_key");
|
|
181
|
+
T(this, "_children");
|
|
182
|
+
T(this, "_xmlText");
|
|
183
|
+
T(this, "_type");
|
|
184
|
+
T(this, "_parent");
|
|
185
|
+
this._key = "", this._children = [], this._xmlText = e, this._type = o, this._parent = n;
|
|
186
|
+
}
|
|
187
|
+
getPrevNode(e) {
|
|
188
|
+
if (e === null) return null;
|
|
189
|
+
const n = e.get(this._key);
|
|
190
|
+
return O(n) ? n : null;
|
|
191
|
+
}
|
|
192
|
+
getNode() {
|
|
193
|
+
const e = L(this._key);
|
|
194
|
+
return O(e) ? e : null;
|
|
195
|
+
}
|
|
196
|
+
getSharedType() {
|
|
197
|
+
return this._xmlText;
|
|
198
|
+
}
|
|
199
|
+
getType() {
|
|
200
|
+
return this._type;
|
|
201
|
+
}
|
|
202
|
+
getKey() {
|
|
203
|
+
return this._key;
|
|
204
|
+
}
|
|
205
|
+
isEmpty() {
|
|
206
|
+
return this._children.length === 0;
|
|
207
|
+
}
|
|
208
|
+
getSize() {
|
|
209
|
+
return 1;
|
|
210
|
+
}
|
|
211
|
+
getOffset() {
|
|
212
|
+
const e = this._parent;
|
|
213
|
+
return e === null && v(90), e.getChildOffset(this);
|
|
214
|
+
}
|
|
215
|
+
syncPropertiesFromYjs(e, n) {
|
|
216
|
+
const o = this.getNode();
|
|
217
|
+
o === null && v(91), le(e, this._xmlText, o, n);
|
|
218
|
+
}
|
|
219
|
+
applyChildrenYjsDelta(e, n) {
|
|
220
|
+
const o = this._children;
|
|
221
|
+
let s = 0, r = null;
|
|
222
|
+
for (let i = 0; i < n.length; i++) {
|
|
223
|
+
const l = n[i], c = l.insert, d = l.delete;
|
|
224
|
+
if (l.retain != null) s += l.retain;
|
|
225
|
+
else if (typeof d == "number") {
|
|
226
|
+
let u = d;
|
|
227
|
+
for (; u > 0; ) {
|
|
228
|
+
const { node: a, nodeIndex: f, offset: h, length: y } = Q(this, s, !1);
|
|
229
|
+
if (a instanceof E || a instanceof R || a instanceof z) o.splice(f, 1), u -= 1;
|
|
230
|
+
else {
|
|
231
|
+
if (!(a instanceof P)) break;
|
|
232
|
+
{
|
|
233
|
+
const p = Math.min(u, y), g = f !== 0 ? o[f - 1] : null, x = a.getSize();
|
|
234
|
+
if (h === 0 && y === x) {
|
|
235
|
+
o.splice(f, 1);
|
|
236
|
+
const m = $(a._text, h, p - 1, "");
|
|
237
|
+
m.length > 0 && (g instanceof P ? g._text += m : this._xmlText.delete(h, m.length));
|
|
238
|
+
} else a._text = $(a._text, h, p, "");
|
|
239
|
+
u -= p;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
if (c == null) throw new Error("Unexpected delta format");
|
|
245
|
+
if (typeof c == "string") {
|
|
246
|
+
const { node: u, offset: a } = Q(this, s, !0);
|
|
247
|
+
u instanceof P ? u._text = $(u._text, a, 0, c) : this._xmlText.delete(a, c.length), s += c.length;
|
|
248
|
+
} else {
|
|
249
|
+
const u = c, { node: a, nodeIndex: f, length: h } = Q(this, s, !1), y = H(e, u, this);
|
|
250
|
+
if (a instanceof P && h > 0 && h < a._text.length) {
|
|
251
|
+
const p = a._text, g = p.length - h;
|
|
252
|
+
a._text = $(p, g, h, ""), o.splice(f + 1, 0, y), r = $(p, 0, g, "");
|
|
253
|
+
} else o.splice(f, 0, y);
|
|
254
|
+
r !== null && y instanceof P && (y._text = r + y._text, r = null), s += 1;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
syncChildrenFromYjs(e) {
|
|
260
|
+
const n = this.getNode();
|
|
261
|
+
n === null && v(92);
|
|
262
|
+
const o = n.__key, s = Z(n, null), r = s.length, i = this._children, l = i.length, c = e.collabNodeMap, d = /* @__PURE__ */ new Set();
|
|
263
|
+
let u, a, f = 0, h = null;
|
|
264
|
+
l !== r && (a = n.getWritable());
|
|
265
|
+
for (let y = 0; y < l; y++) {
|
|
266
|
+
const p = s[f], g = i[y], x = g.getNode(), m = g._key;
|
|
267
|
+
if (x !== null && p === m) {
|
|
268
|
+
const _ = w(x);
|
|
269
|
+
if (d.add(p), _) if (g._key = p, g instanceof E) {
|
|
270
|
+
const b = g._xmlText;
|
|
271
|
+
g.syncPropertiesFromYjs(e, null), g.applyChildrenYjsDelta(e, b.toDelta()), g.syncChildrenFromYjs(e);
|
|
272
|
+
} else g instanceof P ? g.syncPropertiesAndTextFromYjs(e, null) : g instanceof z ? g.syncPropertiesFromYjs(e, null) : g instanceof R || v(93);
|
|
273
|
+
h = x, f++;
|
|
274
|
+
} else {
|
|
275
|
+
if (u === void 0) {
|
|
276
|
+
u = /* @__PURE__ */ new Set();
|
|
277
|
+
for (let S = 0; S < l; S++) {
|
|
278
|
+
const k = i[S]._key;
|
|
279
|
+
k !== "" && u.add(k);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (x !== null && p !== void 0 && !u.has(p)) {
|
|
283
|
+
const S = I(p);
|
|
284
|
+
fe(S), y--, f++;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
a = n.getWritable();
|
|
288
|
+
const _ = kt(e, g, o), b = _.__key;
|
|
289
|
+
if (c.set(b, g), h === null) {
|
|
290
|
+
const S = a.getFirstChild();
|
|
291
|
+
if (a.__first = b, S !== null) {
|
|
292
|
+
const k = S.getWritable();
|
|
293
|
+
k.__prev = b, _.__next = k.__key;
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
const S = h.getWritable(), k = h.getNextSibling();
|
|
297
|
+
if (S.__next = b, _.__prev = h.__key, k !== null) {
|
|
298
|
+
const C = k.getWritable();
|
|
299
|
+
C.__prev = b, _.__next = C.__key;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
y === l - 1 && (a.__last = b), a.__size++, h = _;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
for (let y = 0; y < r; y++) {
|
|
306
|
+
const p = s[y];
|
|
307
|
+
if (!d.has(p)) {
|
|
308
|
+
const g = I(p), x = e.collabNodeMap.get(p);
|
|
309
|
+
x !== void 0 && x.destroy(e), fe(g);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
syncPropertiesFromLexical(e, n, o) {
|
|
314
|
+
ce(e, this._xmlText, this.getPrevNode(o), n);
|
|
315
|
+
}
|
|
316
|
+
_syncChildFromLexical(e, n, o, s, r, i) {
|
|
317
|
+
const l = this._children[n], c = I(o);
|
|
318
|
+
l instanceof E && O(c) ? (l.syncPropertiesFromLexical(e, c, s), l.syncChildrenFromLexical(e, c, s, r, i)) : l instanceof P && w(c) ? l.syncPropertiesAndTextFromLexical(e, c, s) : l instanceof z && V(c) && l.syncPropertiesFromLexical(e, c, s);
|
|
319
|
+
}
|
|
320
|
+
syncChildrenFromLexical(e, n, o, s, r) {
|
|
321
|
+
const i = this.getPrevNode(o), l = i === null ? [] : Z(i, o), c = Z(n, null), d = l.length - 1, u = c.length - 1, a = e.collabNodeMap;
|
|
322
|
+
let f, h, y = 0, p = 0;
|
|
323
|
+
for (; y <= d && p <= u; ) {
|
|
324
|
+
const m = l[y], _ = c[p];
|
|
325
|
+
if (m === _) this._syncChildFromLexical(e, p, _, o, s, r), y++, p++;
|
|
326
|
+
else {
|
|
327
|
+
f === void 0 && (f = new Set(l)), h === void 0 && (h = new Set(c));
|
|
328
|
+
const b = h.has(m), S = f.has(_);
|
|
329
|
+
if (b) {
|
|
330
|
+
const k = he(e, I(_), this);
|
|
331
|
+
a.set(_, k), S ? (this.splice(e, p, 1, k), y++, p++) : (this.splice(e, p, 0, k), p++);
|
|
332
|
+
} else this.splice(e, p, 1), y++;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const g = y > d, x = p > u;
|
|
336
|
+
if (g && !x) for (; p <= u; ++p) {
|
|
337
|
+
const m = c[p], _ = he(e, I(m), this);
|
|
338
|
+
this.append(_), a.set(m, _);
|
|
339
|
+
}
|
|
340
|
+
else if (x && !g) for (let m = this._children.length - 1; m >= p; m--) this.splice(e, m, 1);
|
|
341
|
+
}
|
|
342
|
+
append(e) {
|
|
343
|
+
const n = this._xmlText, o = this._children, s = o[o.length - 1], r = s !== void 0 ? s.getOffset() + s.getSize() : 0;
|
|
344
|
+
if (e instanceof E) n.insertEmbed(r, e._xmlText);
|
|
345
|
+
else if (e instanceof P) {
|
|
346
|
+
const i = e._map;
|
|
347
|
+
i.parent === null && n.insertEmbed(r, i), n.insert(r + 1, e._text);
|
|
348
|
+
} else e instanceof R ? n.insertEmbed(r, e._map) : e instanceof z && n.insertEmbed(r, e._xmlElem);
|
|
349
|
+
this._children.push(e);
|
|
350
|
+
}
|
|
351
|
+
splice(e, n, o, s) {
|
|
352
|
+
const r = this._children, i = r[n];
|
|
353
|
+
if (i === void 0) return s === void 0 && v(94), void this.append(s);
|
|
354
|
+
const l = i.getOffset();
|
|
355
|
+
l === -1 && v(95);
|
|
356
|
+
const c = this._xmlText;
|
|
357
|
+
if (o !== 0 && c.delete(l, i.getSize()), s instanceof E) c.insertEmbed(l, s._xmlText);
|
|
358
|
+
else if (s instanceof P) {
|
|
359
|
+
const d = s._map;
|
|
360
|
+
d.parent === null && c.insertEmbed(l, d), c.insert(l + 1, s._text);
|
|
361
|
+
} else s instanceof R ? c.insertEmbed(l, s._map) : s instanceof z && c.insertEmbed(l, s._xmlElem);
|
|
362
|
+
if (o !== 0) {
|
|
363
|
+
const d = r.slice(n, n + o);
|
|
364
|
+
for (let u = 0; u < d.length; u++) d[u].destroy(e);
|
|
365
|
+
}
|
|
366
|
+
s !== void 0 ? r.splice(n, o, s) : r.splice(n, o);
|
|
367
|
+
}
|
|
368
|
+
getChildOffset(e) {
|
|
369
|
+
let n = 0;
|
|
370
|
+
const o = this._children;
|
|
371
|
+
for (let s = 0; s < o.length; s++) {
|
|
372
|
+
const r = o[s];
|
|
373
|
+
if (r === e) return n;
|
|
374
|
+
n += r.getSize();
|
|
375
|
+
}
|
|
376
|
+
return -1;
|
|
377
|
+
}
|
|
378
|
+
destroy(e) {
|
|
379
|
+
const n = e.collabNodeMap, o = this._children;
|
|
380
|
+
for (let s = 0; s < o.length; s++) o[s].destroy(e);
|
|
381
|
+
n.get(this._key) === this && n.delete(this._key);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function re(t, e, n) {
|
|
385
|
+
const o = new E(t, e, n);
|
|
386
|
+
return t._collabNode = o, o;
|
|
387
|
+
}
|
|
388
|
+
function ht(t, e, n, o, s) {
|
|
389
|
+
n == null && v(81);
|
|
390
|
+
const r = { clientID: n.clientID, cursors: /* @__PURE__ */ new Map(), cursorsContainer: null, doc: n, docMap: o, editor: t, excludedProperties: s || /* @__PURE__ */ new Map(), id: e, nodeProperties: /* @__PURE__ */ new Map() };
|
|
391
|
+
return (function(i) {
|
|
392
|
+
const { editor: l, nodeProperties: c } = i;
|
|
393
|
+
l.update(() => {
|
|
394
|
+
l._nodes.forEach((d) => {
|
|
395
|
+
const u = new d.klass(), a = {};
|
|
396
|
+
for (const [f, h] of Object.entries(u)) De(f, u, i) || (a[f] = h);
|
|
397
|
+
c.set(u.__type, Object.freeze(a));
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
})(r), r;
|
|
401
|
+
}
|
|
402
|
+
function pt(t, e, n, o, s, r) {
|
|
403
|
+
o == null && v(81);
|
|
404
|
+
const i = re(o.get("root", A), null, "root");
|
|
405
|
+
return i._key = "root", { ...ht(t, n, o, s, r), collabNodeMap: /* @__PURE__ */ new Map(), root: i };
|
|
406
|
+
}
|
|
407
|
+
function ie(t) {
|
|
408
|
+
return Object.hasOwn(t, "collabNodeMap");
|
|
409
|
+
}
|
|
410
|
+
const gt = /* @__PURE__ */ new Set(["__key", "__parent", "__next", "__prev", "__state"]), _t = /* @__PURE__ */ new Set(["__first", "__last", "__size"]), yt = /* @__PURE__ */ new Set(["__cachedText"]), mt = /* @__PURE__ */ new Set(["__text"]);
|
|
411
|
+
function De(t, e, n) {
|
|
412
|
+
if (gt.has(t) || typeof e[t] == "function") return !0;
|
|
413
|
+
if (w(e)) {
|
|
414
|
+
if (mt.has(t)) return !0;
|
|
415
|
+
} else if (O(e) && (_t.has(t) || Ue(e) && yt.has(t))) return !0;
|
|
416
|
+
const o = e.constructor, s = n.excludedProperties.get(o);
|
|
417
|
+
return s != null && s.has(t);
|
|
418
|
+
}
|
|
419
|
+
function xt(t, e) {
|
|
420
|
+
const n = t.__type, { nodeProperties: o } = e, s = o.get(n);
|
|
421
|
+
return s === void 0 && v(330, n), s;
|
|
422
|
+
}
|
|
423
|
+
function he(t, e, n) {
|
|
424
|
+
const o = e.__type;
|
|
425
|
+
let s;
|
|
426
|
+
if (O(e))
|
|
427
|
+
s = re(new A(), n, o), s.syncPropertiesFromLexical(t, e, null), s.syncChildrenFromLexical(t, e, null, null, null);
|
|
428
|
+
else if (w(e))
|
|
429
|
+
s = Le(new F(), e.__text, n, o), s.syncPropertiesAndTextFromLexical(t, e, null);
|
|
430
|
+
else if (se(e)) {
|
|
431
|
+
const r = new F();
|
|
432
|
+
r.set("__type", "linebreak"), s = ze(r, n);
|
|
433
|
+
} else V(e) ? (s = je(new K(), n, o), s.syncPropertiesFromLexical(t, e, null)) : v(86);
|
|
434
|
+
return s._key = e.__key, s;
|
|
435
|
+
}
|
|
436
|
+
function Ye(t) {
|
|
437
|
+
const e = J(t, "__type");
|
|
438
|
+
return typeof e != "string" && e !== void 0 && v(87), e;
|
|
439
|
+
}
|
|
440
|
+
function H(t, e, n) {
|
|
441
|
+
const o = e._collabNode;
|
|
442
|
+
if (o === void 0) {
|
|
443
|
+
const s = t.editor._nodes, r = Ye(e);
|
|
444
|
+
typeof r != "string" && v(87), s.get(r) === void 0 && v(88, r);
|
|
445
|
+
const i = e.parent, l = n === void 0 && i !== null ? H(t, i) : n || null;
|
|
446
|
+
if (l instanceof E || v(89), e instanceof A) return re(e, l, r);
|
|
447
|
+
if (e instanceof F) return r === "linebreak" ? ze(e, l) : Le(e, "", l, r);
|
|
448
|
+
if (e instanceof K) return je(e, l, r);
|
|
449
|
+
}
|
|
450
|
+
return o;
|
|
451
|
+
}
|
|
452
|
+
function kt(t, e, n) {
|
|
453
|
+
const o = e.getType(), s = t.editor._nodes.get(o);
|
|
454
|
+
s === void 0 && v(88, o);
|
|
455
|
+
const r = new s.klass();
|
|
456
|
+
if (r.__parent = n, e._key = r.__key, e instanceof E) {
|
|
457
|
+
const i = e._xmlText;
|
|
458
|
+
e.syncPropertiesFromYjs(t, null), e.applyChildrenYjsDelta(t, i.toDelta()), e.syncChildrenFromYjs(t);
|
|
459
|
+
} else e instanceof P ? e.syncPropertiesAndTextFromYjs(t, null) : e instanceof z && e.syncPropertiesFromYjs(t, null);
|
|
460
|
+
return t.collabNodeMap.set(r.__key, e), r;
|
|
461
|
+
}
|
|
462
|
+
function le(t, e, n, o) {
|
|
463
|
+
const s = o === null ? e instanceof F ? Array.from(e.keys()) : e instanceof A || e instanceof K ? Object.keys(e.getAttributes()) : Object.keys(e) : Array.from(o);
|
|
464
|
+
let r;
|
|
465
|
+
for (let i = 0; i < s.length; i++) {
|
|
466
|
+
const l = s[i];
|
|
467
|
+
if (De(l, n, t)) {
|
|
468
|
+
l === "__state" && ie(t) && (r || (r = n.getWritable()), bt(e, r));
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
const c = n[l];
|
|
472
|
+
let d = J(e, l);
|
|
473
|
+
if (c !== d) {
|
|
474
|
+
if (d instanceof ee) {
|
|
475
|
+
const u = t.docMap;
|
|
476
|
+
c instanceof ee && u.delete(c.guid);
|
|
477
|
+
const a = Qe(), f = d.guid;
|
|
478
|
+
a._key = f, u.set(f, d), d = a;
|
|
479
|
+
}
|
|
480
|
+
r === void 0 && (r = n.getWritable()), r[l] = d;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function J(t, e) {
|
|
485
|
+
return t instanceof F ? t.get(e) : t instanceof A || t instanceof K ? t.getAttribute(e) : t[e];
|
|
486
|
+
}
|
|
487
|
+
function pe(t, e, n) {
|
|
488
|
+
t instanceof F ? t.set(e, n) : t.setAttribute(e, n);
|
|
489
|
+
}
|
|
490
|
+
function bt(t, e) {
|
|
491
|
+
const n = J(t, "__state");
|
|
492
|
+
n instanceof F && Pe(e).updateFromJSON(n.toJSON());
|
|
493
|
+
}
|
|
494
|
+
function ce(t, e, n, o) {
|
|
495
|
+
const s = Object.keys(xt(o, t)), r = t.editor.constructor;
|
|
496
|
+
(function(i, l, c, d) {
|
|
497
|
+
const u = d.__state, a = J(l, "__state");
|
|
498
|
+
if (!u) return;
|
|
499
|
+
const [f, h] = u.getInternalState(), y = c && c.__state, p = a instanceof F ? a : new F();
|
|
500
|
+
if (y === u) return;
|
|
501
|
+
const [g, x] = y && p.doc ? y.getInternalState() : [void 0, /* @__PURE__ */ new Map()];
|
|
502
|
+
if (f) for (const [m, _] of Object.entries(f)) g && _ !== g[m] && p.set(m, _);
|
|
503
|
+
for (const [m, _] of h) x.get(m) !== _ && p.set(m.key, m.unparse(_));
|
|
504
|
+
a || pe(l, "__state", p);
|
|
505
|
+
})(0, e, n, o);
|
|
506
|
+
for (let i = 0; i < s.length; i++) {
|
|
507
|
+
const l = s[i], c = n === null ? void 0 : n[l];
|
|
508
|
+
let d = o[l];
|
|
509
|
+
if (c !== d) {
|
|
510
|
+
if (d instanceof r) {
|
|
511
|
+
const u = t.docMap;
|
|
512
|
+
let a;
|
|
513
|
+
if (c instanceof r) {
|
|
514
|
+
const y = c._key;
|
|
515
|
+
a = u.get(y), u.delete(y);
|
|
516
|
+
}
|
|
517
|
+
const f = a || new ee(), h = f.guid;
|
|
518
|
+
d._key = h, u.set(h, f), d = f, t.editor.update(() => {
|
|
519
|
+
o.markDirty();
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
pe(e, l, d);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function $(t, e, n, o) {
|
|
527
|
+
return t.slice(0, e) + o + t.slice(e + n);
|
|
528
|
+
}
|
|
529
|
+
function Q(t, e, n) {
|
|
530
|
+
let o = 0, s = 0;
|
|
531
|
+
const r = t._children, i = r.length;
|
|
532
|
+
for (; s < i; s++) {
|
|
533
|
+
const l = r[s], c = o;
|
|
534
|
+
if (o += l.getSize(), (n ? o >= e : o > e) && l instanceof P) {
|
|
535
|
+
let d = e - c - 1;
|
|
536
|
+
return d < 0 && (d = 0), { length: o - e, node: l, nodeIndex: s, offset: d };
|
|
537
|
+
}
|
|
538
|
+
if (o > e) return { length: 0, node: l, nodeIndex: s, offset: c };
|
|
539
|
+
if (s === i - 1) return { length: 0, node: null, nodeIndex: s + 1, offset: c + 1 };
|
|
540
|
+
}
|
|
541
|
+
return { length: 0, node: null, nodeIndex: 0, offset: 0 };
|
|
542
|
+
}
|
|
543
|
+
function ge(t) {
|
|
544
|
+
const e = t.anchor, n = t.focus;
|
|
545
|
+
let o = !1;
|
|
546
|
+
try {
|
|
547
|
+
const s = e.getNode(), r = n.getNode();
|
|
548
|
+
(!s.isAttached() || !r.isAttached() || w(s) && e.offset > s.getTextContentSize() || w(r) && n.offset > r.getTextContentSize()) && (o = !0);
|
|
549
|
+
} catch {
|
|
550
|
+
o = !0;
|
|
551
|
+
}
|
|
552
|
+
return o;
|
|
553
|
+
}
|
|
554
|
+
function Ct(t, e) {
|
|
555
|
+
t.doc.transact(e, t);
|
|
556
|
+
}
|
|
557
|
+
function Ae(t, e) {
|
|
558
|
+
const n = e._nodeMap.get(t);
|
|
559
|
+
if (!n) return void D().selectStart();
|
|
560
|
+
const o = n.__prev;
|
|
561
|
+
let s = null;
|
|
562
|
+
o && (s = L(o)), s === null && n.__parent !== null && (s = L(n.__parent)), s !== null ? s !== null && s.isAttached() ? s.selectEnd() : Ae(s.__key, e) : D().selectStart();
|
|
563
|
+
}
|
|
564
|
+
He("ychange", { isEqual: (t, e) => t === e, parse: (t) => t ?? null });
|
|
565
|
+
function _e(t, e) {
|
|
566
|
+
const n = e.collabNodeMap.get(t.key);
|
|
567
|
+
if (n === void 0) return null;
|
|
568
|
+
let o = t.offset, s = n.getSharedType();
|
|
569
|
+
if (n instanceof P) {
|
|
570
|
+
s = n._parent._xmlText;
|
|
571
|
+
const r = n.getOffset();
|
|
572
|
+
if (r === -1) return null;
|
|
573
|
+
o = r + 1 + o;
|
|
574
|
+
} else if (n instanceof E && t.type === "element") {
|
|
575
|
+
const r = t.getNode();
|
|
576
|
+
O(r) || v(184);
|
|
577
|
+
let i = 0, l = 0, c = r.getFirstChild();
|
|
578
|
+
for (; c !== null && l++ < o; ) w(c) ? i += c.getTextContentSize() + 1 : i++, c = c.getNextSibling();
|
|
579
|
+
o = i;
|
|
580
|
+
}
|
|
581
|
+
return te(s, o);
|
|
582
|
+
}
|
|
583
|
+
function ye(t, e) {
|
|
584
|
+
const { mapping: n } = e, { offset: o } = t, s = t.getNode(), r = n.getSharedType(s);
|
|
585
|
+
if (r === void 0) return null;
|
|
586
|
+
if (t.type === "text") {
|
|
587
|
+
w(s) || v(326);
|
|
588
|
+
let i = s.getPreviousSibling(), l = o;
|
|
589
|
+
for (; w(i); ) l += i.getTextContentSize(), i = i.getPreviousSibling();
|
|
590
|
+
return te(r, l);
|
|
591
|
+
}
|
|
592
|
+
if (t.type === "element") {
|
|
593
|
+
O(s) || v(184);
|
|
594
|
+
let i = 0, l = s.getFirstChild();
|
|
595
|
+
for (; l !== null && i < o; ) {
|
|
596
|
+
if (w(l)) {
|
|
597
|
+
let c = l.getNextSibling();
|
|
598
|
+
for (; w(c); ) c = c.getNextSibling();
|
|
599
|
+
}
|
|
600
|
+
i++, l = l.getNextSibling();
|
|
601
|
+
}
|
|
602
|
+
return te(r, i);
|
|
603
|
+
}
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
function me(t, e) {
|
|
607
|
+
return rt(t, e.doc);
|
|
608
|
+
}
|
|
609
|
+
function xe(t, e) {
|
|
610
|
+
if (t == null) {
|
|
611
|
+
if (e != null) return !0;
|
|
612
|
+
} else if (e == null || !ct(t, e)) return !0;
|
|
613
|
+
return !1;
|
|
614
|
+
}
|
|
615
|
+
function St(t, e) {
|
|
616
|
+
return { color: e, name: t, selection: null };
|
|
617
|
+
}
|
|
618
|
+
function Ke(t, e) {
|
|
619
|
+
const n = t.cursorsContainer;
|
|
620
|
+
if (n !== null) {
|
|
621
|
+
const o = e.selections, s = o.length;
|
|
622
|
+
for (let r = 0; r < s; r++) n.removeChild(o[r]);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function vt(t, e) {
|
|
626
|
+
const n = e.selection;
|
|
627
|
+
n !== null && Ke(t, n);
|
|
628
|
+
}
|
|
629
|
+
function Tt(t, e, n, o, s) {
|
|
630
|
+
const r = t.color, i = document.createElement("span");
|
|
631
|
+
i.style.cssText = `position:absolute;top:0;bottom:0;right:-1px;width:1px;background-color:${r};z-index:10;`;
|
|
632
|
+
const l = document.createElement("span");
|
|
633
|
+
return l.textContent = t.name, l.style.cssText = `position:absolute;left:-2px;top:-16px;background-color:${r};color:#fff;line-height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;`, i.appendChild(l), { anchor: { key: e, offset: n }, caret: i, color: r, focus: { key: o, offset: s }, name: l, selections: [] };
|
|
634
|
+
}
|
|
635
|
+
function wt(t, e, n, o) {
|
|
636
|
+
const s = t.editor, r = s.getRootElement(), i = t.cursorsContainer;
|
|
637
|
+
if (i === null || r === null) return;
|
|
638
|
+
const l = i.offsetParent;
|
|
639
|
+
if (l === null) return;
|
|
640
|
+
const c = l.getBoundingClientRect(), d = e.selection;
|
|
641
|
+
if (n === null) return d === null ? void 0 : (e.selection = null, void Ke(t, d));
|
|
642
|
+
e.selection = n;
|
|
643
|
+
const u = n.caret, a = n.color, f = n.selections, h = n.anchor, y = n.focus, p = h.key, g = y.key, x = o.get(p), m = o.get(g);
|
|
644
|
+
if (x == null || m == null) return;
|
|
645
|
+
let _;
|
|
646
|
+
if (x === m && se(x))
|
|
647
|
+
_ = [s.getElementByKey(p).getBoundingClientRect()];
|
|
648
|
+
else {
|
|
649
|
+
const k = Be(s, x, h.offset, m, y.offset);
|
|
650
|
+
if (k === null) return;
|
|
651
|
+
_ = Ge(s, k);
|
|
652
|
+
}
|
|
653
|
+
const b = f.length, S = _.length;
|
|
654
|
+
for (let k = 0; k < S; k++) {
|
|
655
|
+
const C = _[k];
|
|
656
|
+
let N = f[k];
|
|
657
|
+
if (N === void 0) {
|
|
658
|
+
N = document.createElement("span"), f[k] = N;
|
|
659
|
+
const B = document.createElement("span");
|
|
660
|
+
N.appendChild(B), i.appendChild(N);
|
|
661
|
+
}
|
|
662
|
+
const j = `position:absolute;top:${C.top - c.top}px;left:${C.left - c.left}px;height:${C.height}px;width:${C.width}px;pointer-events:none;z-index:5;`;
|
|
663
|
+
N.style.cssText = j, N.firstChild.style.cssText = `${j}left:0;top:0;background-color:${a};opacity:0.3;`, k === S - 1 && u.parentNode !== N && N.appendChild(u);
|
|
664
|
+
}
|
|
665
|
+
for (let k = b - 1; k >= S; k--) {
|
|
666
|
+
const C = f[k];
|
|
667
|
+
i.removeChild(C), f.pop();
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
function Ie(t, e) {
|
|
671
|
+
const { anchorPos: n, focusPos: o } = e, s = n ? me(n, t) : null, r = o ? me(o, t) : null;
|
|
672
|
+
if (s === null || r === null) return { anchorKey: null, anchorOffset: 0, focusKey: null, focusOffset: 0 };
|
|
673
|
+
if (ie(t)) {
|
|
674
|
+
const [u, a] = Ce(s.type, s.index), [f, h] = Ce(r.type, r.index);
|
|
675
|
+
return { anchorKey: u !== null ? u.getKey() : null, anchorOffset: a, focusKey: f !== null ? f.getKey() : null, focusOffset: h };
|
|
676
|
+
}
|
|
677
|
+
let [i, l] = Se(t.mapping, s), [c, d] = Se(t.mapping, r);
|
|
678
|
+
if (c && i && (c !== i || d !== l)) {
|
|
679
|
+
const u = c.isBefore(i), a = u ? c : i, f = u ? d : l;
|
|
680
|
+
w(a) && w(a.getNextSibling()) && f === a.getTextContentSize() && (u ? (c = a.getNextSibling(), d = 0) : (i = a.getNextSibling(), l = 0));
|
|
681
|
+
}
|
|
682
|
+
return { anchorKey: i !== null ? i.getKey() : null, anchorOffset: l, focusKey: c !== null ? c.getKey() : null, focusOffset: d };
|
|
683
|
+
}
|
|
684
|
+
function ke(t, e) {
|
|
685
|
+
const n = e.awareness.getLocalState();
|
|
686
|
+
if (n === null) return;
|
|
687
|
+
const { anchorKey: o, anchorOffset: s, focusKey: r, focusOffset: i } = Ie(t, n);
|
|
688
|
+
if (o !== null && r !== null) {
|
|
689
|
+
const l = Y();
|
|
690
|
+
if (!W(l)) return;
|
|
691
|
+
be(l.anchor, o, s), be(l.focus, r, i);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
function be(t, e, n) {
|
|
695
|
+
if (t.key !== e || t.offset !== n) {
|
|
696
|
+
let o = L(e);
|
|
697
|
+
if (o !== null && !O(o) && !w(o)) {
|
|
698
|
+
const s = o.getParentOrThrow();
|
|
699
|
+
e = s.getKey(), n = o.getIndexWithinParent(), o = s;
|
|
700
|
+
}
|
|
701
|
+
t.set(e, n, O(o) ? "element" : "text");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function Ce(t, e) {
|
|
705
|
+
const n = t._collabNode;
|
|
706
|
+
if (n === void 0) return [null, 0];
|
|
707
|
+
if (n instanceof E) {
|
|
708
|
+
const { node: o, offset: s } = Q(n, e, !0);
|
|
709
|
+
return o === null ? [n, 0] : [o, s];
|
|
710
|
+
}
|
|
711
|
+
return [null, 0];
|
|
712
|
+
}
|
|
713
|
+
function Se(t, e) {
|
|
714
|
+
const n = e.type, o = e.index;
|
|
715
|
+
if (n instanceof K) {
|
|
716
|
+
const s = t.get(n);
|
|
717
|
+
if (s === void 0) return [null, 0];
|
|
718
|
+
if (!O(s)) return [s, o];
|
|
719
|
+
let r = o, i = 0;
|
|
720
|
+
const l = s.getChildren();
|
|
721
|
+
for (; r > 0 && i < l.length; ) {
|
|
722
|
+
const c = l[i];
|
|
723
|
+
if (r -= 1, i += 1, w(c)) for (; i < l.length && w(l[i]); ) i += 1;
|
|
724
|
+
}
|
|
725
|
+
return [s, i];
|
|
726
|
+
}
|
|
727
|
+
{
|
|
728
|
+
const s = t.get(n);
|
|
729
|
+
if (s === void 0) return [null, 0];
|
|
730
|
+
let r = 0, i = o;
|
|
731
|
+
for (; i > s[r].getTextContentSize() && r + 1 < s.length; ) i -= s[r].getTextContentSize(), r++;
|
|
732
|
+
const l = s[r];
|
|
733
|
+
return [l, Math.min(i, l.getTextContentSize())];
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function Nt(t, e) {
|
|
737
|
+
return e.awareness.getStates();
|
|
738
|
+
}
|
|
739
|
+
function ae(t, e, n) {
|
|
740
|
+
const { getAwarenessStates: o = Nt } = n ?? {}, s = Array.from(o(t, e)), r = t.clientID, i = t.cursors, l = t.editor, c = l._editorState._nodeMap, d = /* @__PURE__ */ new Set();
|
|
741
|
+
for (let a = 0; a < s.length; a++) {
|
|
742
|
+
const f = s[a], [h, y] = f;
|
|
743
|
+
if (h !== 0 && h !== r) {
|
|
744
|
+
d.add(h);
|
|
745
|
+
const { name: p, color: g, focusing: x } = y;
|
|
746
|
+
let m = null, _ = i.get(h);
|
|
747
|
+
if (_ === void 0 && (_ = St(p, g), i.set(h, _)), x) {
|
|
748
|
+
const { anchorKey: b, anchorOffset: S, focusKey: k, focusOffset: C } = l.read(() => Ie(t, y));
|
|
749
|
+
if (b !== null && k !== null) if (m = _.selection, m === null) m = Tt(_, b, S, k, C);
|
|
750
|
+
else {
|
|
751
|
+
const N = m.anchor, j = m.focus;
|
|
752
|
+
N.key = b, N.offset = S, j.key = k, j.offset = C;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
wt(t, _, m, c);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
const u = Array.from(i.keys());
|
|
759
|
+
for (let a = 0; a < u.length; a++) {
|
|
760
|
+
const f = u[a];
|
|
761
|
+
if (!d.has(f)) {
|
|
762
|
+
const h = i.get(f);
|
|
763
|
+
h !== void 0 && (vt(t, h), i.delete(f));
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function $e(t, e, n, o) {
|
|
768
|
+
const s = e.awareness, r = s.getLocalState();
|
|
769
|
+
if (r === null) return;
|
|
770
|
+
const { anchorPos: i, focusPos: l, name: c, color: d, focusing: u, awarenessData: a } = r;
|
|
771
|
+
let f = null, h = null;
|
|
772
|
+
(o !== null && (i === null || o.is(n)) || n !== null) && (W(o) && (ie(t) ? (f = _e(o.anchor, t), h = _e(o.focus, t)) : (f = ye(o.anchor, t), h = ye(o.focus, t))), (xe(i, f) || xe(l, h)) && s.setLocalState({ ...r, anchorPos: f, awarenessData: a, color: d, focusPos: h, focusing: u, name: c }));
|
|
773
|
+
}
|
|
774
|
+
function Pt(t, e) {
|
|
775
|
+
if (e instanceof de && (function(s, r) {
|
|
776
|
+
const { target: i } = r;
|
|
777
|
+
if (!i._item || i._item.parentSub !== "__state" || Ye(i) !== void 0 || !(i.parent instanceof A || i.parent instanceof K || i.parent instanceof F)) return !1;
|
|
778
|
+
const l = H(s, i.parent).getNode();
|
|
779
|
+
if (l) {
|
|
780
|
+
const c = Pe(l.getWritable());
|
|
781
|
+
for (const d of r.keysChanged) c.updateFromUnknown(d, i.get(d));
|
|
782
|
+
}
|
|
783
|
+
return !0;
|
|
784
|
+
})(t, e)) return;
|
|
785
|
+
const { target: n } = e, o = H(t, n);
|
|
786
|
+
if (o instanceof E && e instanceof it) {
|
|
787
|
+
const { keysChanged: s, childListChanged: r, delta: i } = e;
|
|
788
|
+
s.size > 0 && o.syncPropertiesFromYjs(t, s), r && (o.applyChildrenYjsDelta(t, i), o.syncChildrenFromYjs(t));
|
|
789
|
+
} else if (o instanceof P && e instanceof de) {
|
|
790
|
+
const { keysChanged: s } = e;
|
|
791
|
+
s.size > 0 && o.syncPropertiesAndTextFromYjs(t, s);
|
|
792
|
+
} else if (o instanceof z && e instanceof lt) {
|
|
793
|
+
const { attributesChanged: s } = e;
|
|
794
|
+
s.size > 0 && o.syncPropertiesFromYjs(t, s);
|
|
795
|
+
} else v(82);
|
|
796
|
+
}
|
|
797
|
+
function Et(t, e, n, o, s = ae) {
|
|
798
|
+
const r = t.editor, i = r._editorState;
|
|
799
|
+
n.forEach((l) => l.delta), r.update(() => {
|
|
800
|
+
for (let l = 0; l < n.length; l++) {
|
|
801
|
+
const c = n[l];
|
|
802
|
+
Pt(t, c);
|
|
803
|
+
}
|
|
804
|
+
Ot(i, t, e), o || Ve(Xe);
|
|
805
|
+
}, { onUpdate: () => {
|
|
806
|
+
s(t, e), r.update(() => Ft());
|
|
807
|
+
}, skipTransforms: !0, tag: o ? we : Ne });
|
|
808
|
+
}
|
|
809
|
+
function Ot(t, e, n) {
|
|
810
|
+
const o = Y();
|
|
811
|
+
if (W(o)) if (ge(o)) {
|
|
812
|
+
const s = t._selection;
|
|
813
|
+
W(s) && (ke(e, n), ge(o)) && Ae(o.anchor.key, t), $e(e, n, s, Y());
|
|
814
|
+
} else ke(e, n);
|
|
815
|
+
}
|
|
816
|
+
function Ft() {
|
|
817
|
+
D().getChildrenSize() === 0 && D().append(Ee());
|
|
818
|
+
}
|
|
819
|
+
function Mt(t, e, n, o, s, r, i, l) {
|
|
820
|
+
Ct(t, () => {
|
|
821
|
+
o.read(() => {
|
|
822
|
+
if (l.has(Ne) || l.has(we)) return void (i.size > 0 && (function(u, a) {
|
|
823
|
+
const f = Array.from(a), h = u.collabNodeMap, y = [], p = [];
|
|
824
|
+
for (let g = 0; g < f.length; g++) {
|
|
825
|
+
const x = f[g], m = L(x), _ = h.get(x);
|
|
826
|
+
if (_ instanceof P) if (w(m)) y.push([_, m.__text]);
|
|
827
|
+
else {
|
|
828
|
+
const b = _.getOffset();
|
|
829
|
+
if (b === -1) continue;
|
|
830
|
+
const S = _._parent;
|
|
831
|
+
_._normalized = !0, S._xmlText.delete(b, 1), p.push(_);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
for (let g = 0; g < p.length; g++) {
|
|
835
|
+
const x = p[g], m = x.getKey();
|
|
836
|
+
h.delete(m);
|
|
837
|
+
const _ = x._parent._children, b = _.indexOf(x);
|
|
838
|
+
_.splice(b, 1);
|
|
839
|
+
}
|
|
840
|
+
for (let g = 0; g < y.length; g++) {
|
|
841
|
+
const [x, m] = y[g];
|
|
842
|
+
x._text = m;
|
|
843
|
+
}
|
|
844
|
+
})(t, i));
|
|
845
|
+
if (s.has("root")) {
|
|
846
|
+
const u = n._nodeMap, a = D(), f = t.root;
|
|
847
|
+
f.syncPropertiesFromLexical(t, a, u), f.syncChildrenFromLexical(t, a, u, s, r);
|
|
848
|
+
}
|
|
849
|
+
const c = Y(), d = n._selection;
|
|
850
|
+
$e(t, e, d, c);
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
const jt = Te("CONNECTED_COMMAND"), zt = Te("TOGGLE_CONNECT_COMMAND");
|
|
855
|
+
function Lt(t, e) {
|
|
856
|
+
return new Fe(e, { trackedOrigins: /* @__PURE__ */ new Set([t, null]) });
|
|
857
|
+
}
|
|
858
|
+
function Dt(t, e, n, o, s) {
|
|
859
|
+
t.awareness.setLocalState({ anchorPos: null, awarenessData: s, color: n, focusPos: null, focusing: o, name: e });
|
|
860
|
+
}
|
|
861
|
+
function ve(t, e, n, o, s) {
|
|
862
|
+
const { awareness: r } = t;
|
|
863
|
+
let i = r.getLocalState();
|
|
864
|
+
i === null && (i = { anchorPos: null, awarenessData: s, color: n, focusPos: null, focusing: o, name: e }), i.focusing = o, r.setLocalState(i);
|
|
865
|
+
}
|
|
866
|
+
function Yt(t, e, n, o, s, r, i, l, c, d, u, a, f = ae) {
|
|
867
|
+
const h = ne(!1), y = X(() => {
|
|
868
|
+
const { root: p } = l;
|
|
869
|
+
i && p.isEmpty() && p._xmlText._length === 0 && Wt(t, u);
|
|
870
|
+
}, [l, t, u, i]);
|
|
871
|
+
return M(() => {
|
|
872
|
+
const { root: p } = l, g = (m, _) => {
|
|
873
|
+
const b = _.origin;
|
|
874
|
+
b !== l && Et(l, n, m, b instanceof Fe, f);
|
|
875
|
+
};
|
|
876
|
+
p.getSharedType().observeDeep(g);
|
|
877
|
+
const x = t.registerUpdateListener(({ prevEditorState: m, editorState: _, dirtyLeaves: b, dirtyElements: S, normalizedNodes: k, tags: C }) => {
|
|
878
|
+
C.has(ue) || Mt(l, n, m, _, S, b, k, C);
|
|
879
|
+
});
|
|
880
|
+
return () => {
|
|
881
|
+
p.getSharedType().unobserveDeep(g), x();
|
|
882
|
+
};
|
|
883
|
+
}, [l, n, t, c, o, e, f]), M(() => {
|
|
884
|
+
const p = (x) => {
|
|
885
|
+
(function(m, _) {
|
|
886
|
+
if (m.update(() => {
|
|
887
|
+
const C = D();
|
|
888
|
+
C.clear(), C.select();
|
|
889
|
+
}, { tag: ue }), _.cursors == null) return;
|
|
890
|
+
const b = _.cursors;
|
|
891
|
+
if (b == null) return;
|
|
892
|
+
const S = _.cursorsContainer;
|
|
893
|
+
if (S == null) return;
|
|
894
|
+
const k = Array.from(b.values());
|
|
895
|
+
for (let C = 0; C < k.length; C++) {
|
|
896
|
+
const N = k[C].selection;
|
|
897
|
+
if (N && N.selections != null) {
|
|
898
|
+
const j = N.selections;
|
|
899
|
+
for (let B = 0; B < j.length; B++) S.removeChild(j[C]);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
})(t, l), c(x), o.set(e, x), h.current = !0;
|
|
903
|
+
}, g = () => {
|
|
904
|
+
h.current = !1;
|
|
905
|
+
};
|
|
906
|
+
return n.on("reload", p), n.on("sync", g), () => {
|
|
907
|
+
n.off("reload", p), n.off("sync", g);
|
|
908
|
+
};
|
|
909
|
+
}, [l, n, t, c, o, e]), At(t, n, s, r, h, a, y), Kt(l, n), It(l, d);
|
|
910
|
+
}
|
|
911
|
+
function At(t, e, n, o, s, r, i) {
|
|
912
|
+
const l = X(() => e.connect(), [e]), c = X(() => {
|
|
913
|
+
try {
|
|
914
|
+
e.disconnect();
|
|
915
|
+
} catch {
|
|
916
|
+
}
|
|
917
|
+
}, [e]);
|
|
918
|
+
M(() => {
|
|
919
|
+
const d = ({ status: f }) => {
|
|
920
|
+
t.dispatchCommand(jt, f === "connected");
|
|
921
|
+
}, u = (f) => {
|
|
922
|
+
f && s.current === !1 && i && i();
|
|
923
|
+
};
|
|
924
|
+
Dt(e, n, o, document.activeElement === t.getRootElement(), r || {}), e.on("status", d), e.on("sync", u);
|
|
925
|
+
const a = l();
|
|
926
|
+
return () => {
|
|
927
|
+
s.current === !1 && (a ? a.then(c) : c()), e.off("sync", u), e.off("status", d);
|
|
928
|
+
};
|
|
929
|
+
}, [t, e, n, o, s, r, i, l, c]), M(() => t.registerCommand(zt, (d) => (d ? (console.log("Collaboration connected!"), l()) : (console.log("Collaboration disconnected!"), c()), !0), U), [l, c, t]);
|
|
930
|
+
}
|
|
931
|
+
function Kt(t, e) {
|
|
932
|
+
M(() => {
|
|
933
|
+
const { awareness: n } = e, o = () => {
|
|
934
|
+
ae(t, e);
|
|
935
|
+
};
|
|
936
|
+
return n.on("update", o), () => {
|
|
937
|
+
n.off("update", o);
|
|
938
|
+
};
|
|
939
|
+
}, [t, e]);
|
|
940
|
+
}
|
|
941
|
+
function It(t, e) {
|
|
942
|
+
return Me(() => ft(oe("div", { ref: (n) => {
|
|
943
|
+
t.cursorsContainer = n;
|
|
944
|
+
} }), e && e.current || document.body), [t, e]);
|
|
945
|
+
}
|
|
946
|
+
function $t(t, e, n, o, s) {
|
|
947
|
+
M(() => Oe(t.registerCommand(nt, () => (ve(e, n, o, !0, s || {}), !1), U), t.registerCommand(tt, () => (ve(e, n, o, !1, s || {}), !1), U)), [o, t, n, e, s]);
|
|
948
|
+
}
|
|
949
|
+
function Rt(t, e) {
|
|
950
|
+
M(() => Oe(t.registerCommand(et, () => (e.undo(), !0), U), t.registerCommand(qe, () => (e.redo(), !0), U)));
|
|
951
|
+
const n = X(() => {
|
|
952
|
+
e.clear();
|
|
953
|
+
}, [e]);
|
|
954
|
+
return at.useEffect(() => {
|
|
955
|
+
const o = () => {
|
|
956
|
+
t.dispatchCommand(ot, e.undoStack.length > 0), t.dispatchCommand(st, e.redoStack.length > 0);
|
|
957
|
+
};
|
|
958
|
+
return e.on("stack-item-added", o), e.on("stack-item-popped", o), e.on("stack-cleared", o), () => {
|
|
959
|
+
e.off("stack-item-added", o), e.off("stack-item-popped", o), e.off("stack-cleared", o);
|
|
960
|
+
};
|
|
961
|
+
}, [t, e]), n;
|
|
962
|
+
}
|
|
963
|
+
function Wt(t, e) {
|
|
964
|
+
t.update(() => {
|
|
965
|
+
const n = D();
|
|
966
|
+
if (n.isEmpty()) if (e) switch (typeof e) {
|
|
967
|
+
case "string": {
|
|
968
|
+
const o = t.parseEditorState(e);
|
|
969
|
+
t.setEditorState(o, { tag: G });
|
|
970
|
+
break;
|
|
971
|
+
}
|
|
972
|
+
case "object":
|
|
973
|
+
t.setEditorState(e, { tag: G });
|
|
974
|
+
break;
|
|
975
|
+
case "function":
|
|
976
|
+
t.update(() => {
|
|
977
|
+
D().isEmpty() && e(t);
|
|
978
|
+
}, { tag: G });
|
|
979
|
+
}
|
|
980
|
+
else {
|
|
981
|
+
const o = Ee();
|
|
982
|
+
n.append(o);
|
|
983
|
+
const { activeElement: s } = document;
|
|
984
|
+
(Y() !== null || s !== null && s === t.getRootElement()) && o.select();
|
|
985
|
+
}
|
|
986
|
+
}, { tag: G });
|
|
987
|
+
}
|
|
988
|
+
function qt({ id: t, providerFactory: e, shouldBootstrap: n, username: o, cursorColor: s, cursorsContainerRef: r, initialEditorState: i, excludedProperties: l, awarenessData: c, syncCursorPositionsFn: d }) {
|
|
989
|
+
const u = ne(!1), a = ne(!1), f = Je(o, s), { yjsDocMap: h, name: y, color: p } = f, [g] = Ze();
|
|
990
|
+
Bt(f, g);
|
|
991
|
+
const [x, m] = q(), [_, b] = q();
|
|
992
|
+
M(() => {
|
|
993
|
+
if (a.current) return;
|
|
994
|
+
a.current = !0;
|
|
995
|
+
const C = e(t, h);
|
|
996
|
+
return m(C), b(h.get(t)), () => {
|
|
997
|
+
C.disconnect();
|
|
998
|
+
};
|
|
999
|
+
}, [t, e, h]);
|
|
1000
|
+
const [S, k] = q();
|
|
1001
|
+
return M(() => {
|
|
1002
|
+
if (!x || u.current) return;
|
|
1003
|
+
u.current = !0;
|
|
1004
|
+
const C = pt(g, x, t, _ || h.get(t), h, l);
|
|
1005
|
+
return k(C), () => {
|
|
1006
|
+
C.root.destroy(C);
|
|
1007
|
+
};
|
|
1008
|
+
}, [g, x, t, h, _, l]), x && S ? oe(Ut, { awarenessData: c, binding: S, collabContext: f, color: p, cursorsContainerRef: r, editor: g, id: t, initialEditorState: i, name: y, provider: x, setDoc: b, shouldBootstrap: n, yjsDocMap: h, syncCursorPositionsFn: d }) : oe(ut, {});
|
|
1009
|
+
}
|
|
1010
|
+
function Ut({ editor: t, id: e, provider: n, yjsDocMap: o, name: s, color: r, shouldBootstrap: i, cursorsContainerRef: l, initialEditorState: c, awarenessData: d, collabContext: u, binding: a, setDoc: f, syncCursorPositionsFn: h }) {
|
|
1011
|
+
const y = Yt(t, e, n, o, s, r, i, a, f, l, c, d, h);
|
|
1012
|
+
return (function(p, g) {
|
|
1013
|
+
Rt(p, Me(() => Lt(g, g.root.getSharedType()), [g]));
|
|
1014
|
+
})(t, a), $t(t, n, s, r, d), y;
|
|
1015
|
+
}
|
|
1016
|
+
const Bt = (t, e) => {
|
|
1017
|
+
M(() => (t.isCollabActive = !0, () => {
|
|
1018
|
+
e._parentEditor == null && (t.isCollabActive = !1);
|
|
1019
|
+
}), [t, e]);
|
|
1020
|
+
};
|
|
1021
|
+
export {
|
|
1022
|
+
zt as K,
|
|
1023
|
+
jt as O,
|
|
1024
|
+
qt as V
|
|
1025
|
+
};
|