@clevertask/scribe 0.1.9 → 0.1.10

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.
Files changed (27) hide show
  1. package/README.md +10 -9
  2. package/dist/{BarMenu-BG_w4DVo.js → BarMenu-5S2vKAtc.js} +1 -1
  3. package/dist/components/Menu/BarMenu.js +1 -1
  4. package/dist/components/Menu/BubbleMenu.js +2 -2
  5. package/dist/components/Menu/LinkBubbleMenu.js +2 -2
  6. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  7. package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
  8. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  9. package/dist/components/Scribe/extension/extension-link.js +1 -1
  10. package/dist/components/Scribe/extension/extension-markdown-paste.js +11 -11
  11. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  12. package/dist/components/Scribe/extension/index.js +1 -1
  13. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  14. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  15. package/dist/components/Scribe/extension/tableOfContents.js +4 -4
  16. package/dist/components/Scribe/index.js +3 -3
  17. package/dist/dist-DErUltkU.js +3245 -0
  18. package/dist/{dist-BgEySLwo.js → dist-wYqYXEOz.js} +1 -1
  19. package/dist/{extension-BVGWENts.js → extension-6I5t1ZxQ.js} +1744 -2294
  20. package/dist/{extension-link-CMRfHUc5.js → extension-link-DJy7XDoj.js} +62 -62
  21. package/dist/{menus-D9OsP28c.js → menus-m_EkiaUN.js} +66 -66
  22. package/dist/{slashCommand-B6Iz1i0d.js → slashCommand-DuSH9sXJ.js} +46 -45
  23. package/dist/utils/index.js +2 -2
  24. package/package.json +3 -2
  25. package/dist/dist-BMKyBtRa.js +0 -7023
  26. package/dist/dist-FrapLVQu.js +0 -3513
  27. package/dist/tables-CXpUVKdw.js +0 -1347
@@ -1,3513 +0,0 @@
1
- //#region node_modules/.pnpm/orderedmap@2.1.1/node_modules/orderedmap/dist/index.js
2
- function e(e) {
3
- this.content = e;
4
- }
5
- e.prototype = {
6
- constructor: e,
7
- find: function(e) {
8
- for (var t = 0; t < this.content.length; t += 2) if (this.content[t] === e) return t;
9
- return -1;
10
- },
11
- get: function(e) {
12
- var t = this.find(e);
13
- return t == -1 ? void 0 : this.content[t + 1];
14
- },
15
- update: function(t, n, r) {
16
- var i = r && r != t ? this.remove(r) : this, a = i.find(t), o = i.content.slice();
17
- return a == -1 ? o.push(r || t, n) : (o[a + 1] = n, r && (o[a] = r)), new e(o);
18
- },
19
- remove: function(t) {
20
- var n = this.find(t);
21
- if (n == -1) return this;
22
- var r = this.content.slice();
23
- return r.splice(n, 2), new e(r);
24
- },
25
- addToStart: function(t, n) {
26
- return new e([t, n].concat(this.remove(t).content));
27
- },
28
- addToEnd: function(t, n) {
29
- var r = this.remove(t).content.slice();
30
- return r.push(t, n), new e(r);
31
- },
32
- addBefore: function(t, n, r) {
33
- var i = this.remove(n), a = i.content.slice(), o = i.find(t);
34
- return a.splice(o == -1 ? a.length : o, 0, n, r), new e(a);
35
- },
36
- forEach: function(e) {
37
- for (var t = 0; t < this.content.length; t += 2) e(this.content[t], this.content[t + 1]);
38
- },
39
- prepend: function(t) {
40
- return t = e.from(t), t.size ? new e(t.content.concat(this.subtract(t).content)) : this;
41
- },
42
- append: function(t) {
43
- return t = e.from(t), t.size ? new e(this.subtract(t).content.concat(t.content)) : this;
44
- },
45
- subtract: function(t) {
46
- var n = this;
47
- t = e.from(t);
48
- for (var r = 0; r < t.content.length; r += 2) n = n.remove(t.content[r]);
49
- return n;
50
- },
51
- toObject: function() {
52
- var e = {};
53
- return this.forEach(function(t, n) {
54
- e[t] = n;
55
- }), e;
56
- },
57
- get size() {
58
- return this.content.length >> 1;
59
- }
60
- }, e.from = function(t) {
61
- if (t instanceof e) return t;
62
- var n = [];
63
- if (t) for (var r in t) n.push(r, t[r]);
64
- return new e(n);
65
- };
66
- //#endregion
67
- //#region node_modules/.pnpm/prosemirror-model@1.25.11/node_modules/prosemirror-model/dist/index.js
68
- function t(e, n, a) {
69
- for (let o = 0;; o++) {
70
- if (o == e.childCount || o == n.childCount) return e.childCount == n.childCount ? null : a;
71
- let s = e.child(o), c = n.child(o);
72
- if (s == c) {
73
- a += s.nodeSize;
74
- continue;
75
- }
76
- if (!s.sameMarkup(c)) return a;
77
- if (s.isText && s.text != c.text) {
78
- let e = s.text, t = c.text, n = 0;
79
- for (; e[n] == t[n]; n++) a++;
80
- return n && n < e.length && n < t.length && i(e.charCodeAt(n - 1)) && r(e.charCodeAt(n)) && a--, a;
81
- }
82
- if (s.content.size || c.content.size) {
83
- let e = t(s.content, c.content, a + 1);
84
- if (e != null) return e;
85
- }
86
- a += s.nodeSize;
87
- }
88
- }
89
- function n(e, t, a, o) {
90
- for (let s = e.childCount, c = t.childCount;;) {
91
- if (s == 0 || c == 0) return s == c ? null : {
92
- a,
93
- b: o
94
- };
95
- let l = e.child(--s), u = t.child(--c), d = l.nodeSize;
96
- if (l == u) {
97
- a -= d, o -= d;
98
- continue;
99
- }
100
- if (!l.sameMarkup(u)) return {
101
- a,
102
- b: o
103
- };
104
- if (l.isText && l.text != u.text) {
105
- let e = l.text, t = u.text, n = e.length, s = t.length;
106
- for (; n > 0 && s > 0 && e[n - 1] == t[s - 1];) n--, s--, a--, o--;
107
- return n && s && n < e.length && i(e.charCodeAt(n - 1)) && r(e.charCodeAt(n)) && (a++, o++), {
108
- a,
109
- b: o
110
- };
111
- }
112
- if (l.content.size || u.content.size) {
113
- let e = n(l.content, u.content, a - 1, o - 1);
114
- if (e) return e;
115
- }
116
- a -= d, o -= d;
117
- }
118
- }
119
- function r(e) {
120
- return e >= 56320 && e < 57344;
121
- }
122
- function i(e) {
123
- return e >= 55296 && e < 56320;
124
- }
125
- var a = class e {
126
- constructor(e, t) {
127
- if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize;
128
- }
129
- nodesBetween(e, t, n, r = 0, i) {
130
- for (let a = 0, o = 0; o < t; a++) {
131
- let s = this.content[a], c = o + s.nodeSize;
132
- if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) {
133
- let i = o + 1;
134
- s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i);
135
- }
136
- o = c;
137
- }
138
- }
139
- descendants(e) {
140
- this.nodesBetween(0, this.size, e);
141
- }
142
- textBetween(e, t, n, r) {
143
- let i = "", a = !0;
144
- return this.nodesBetween(e, t, (o, s) => {
145
- let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : "";
146
- o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c;
147
- }, 0), i;
148
- }
149
- append(t) {
150
- if (!t.size) return this;
151
- if (!this.size) return t;
152
- let n = this.lastChild, r = t.firstChild, i = this.content.slice(), a = 0;
153
- for (n.isText && n.sameMarkup(r) && (i[i.length - 1] = n.withText(n.text + r.text), a = 1); a < t.content.length; a++) i.push(t.content[a]);
154
- return new e(i, this.size + t.size);
155
- }
156
- cut(t, n = this.size) {
157
- if (t == 0 && n == this.size) return this;
158
- let r = [], i = 0;
159
- if (n > t) for (let e = 0, a = 0; a < n; e++) {
160
- let o = this.content[e], s = a + o.nodeSize;
161
- s > t && ((a < t || s > n) && (o = o.isText ? o.cut(Math.max(0, t - a), Math.min(o.text.length, n - a)) : o.cut(Math.max(0, t - a - 1), Math.min(o.content.size, n - a - 1))), r.push(o), i += o.nodeSize), a = s;
162
- }
163
- return new e(r, i);
164
- }
165
- cutByIndex(t, n) {
166
- return t == n ? e.empty : t == 0 && n == this.content.length ? this : new e(this.content.slice(t, n));
167
- }
168
- replaceChild(t, n) {
169
- let r = this.content[t];
170
- if (r == n) return this;
171
- let i = this.content.slice(), a = this.size + n.nodeSize - r.nodeSize;
172
- return i[t] = n, new e(i, a);
173
- }
174
- addToStart(t) {
175
- return new e([t].concat(this.content), this.size + t.nodeSize);
176
- }
177
- addToEnd(t) {
178
- return new e(this.content.concat(t), this.size + t.nodeSize);
179
- }
180
- eq(e) {
181
- if (this.content.length != e.content.length) return !1;
182
- for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1;
183
- return !0;
184
- }
185
- get firstChild() {
186
- return this.content.length ? this.content[0] : null;
187
- }
188
- get lastChild() {
189
- return this.content.length ? this.content[this.content.length - 1] : null;
190
- }
191
- get childCount() {
192
- return this.content.length;
193
- }
194
- child(e) {
195
- let t = this.content[e];
196
- if (!t) throw RangeError("Index " + e + " out of range for " + this);
197
- return t;
198
- }
199
- maybeChild(e) {
200
- return this.content[e] || null;
201
- }
202
- forEach(e) {
203
- for (let t = 0, n = 0; t < this.content.length; t++) {
204
- let r = this.content[t];
205
- e(r, n, t), n += r.nodeSize;
206
- }
207
- }
208
- findDiffStart(e, n = 0) {
209
- return t(this, e, n);
210
- }
211
- findDiffEnd(e, t = this.size, r = e.size) {
212
- return n(this, e, t, r);
213
- }
214
- findIndex(e) {
215
- if (e == 0) return s(0, e);
216
- if (e == this.size) return s(this.content.length, e);
217
- if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`);
218
- for (let t = 0, n = 0;; t++) {
219
- let r = this.child(t), i = n + r.nodeSize;
220
- if (i >= e) return i == e ? s(t + 1, i) : s(t, n);
221
- n = i;
222
- }
223
- }
224
- toString() {
225
- return "<" + this.toStringInner() + ">";
226
- }
227
- toStringInner() {
228
- return this.content.join(", ");
229
- }
230
- toJSON() {
231
- return this.content.length ? this.content.map((e) => e.toJSON()) : null;
232
- }
233
- static fromJSON(t, n) {
234
- if (!n) return e.empty;
235
- if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON");
236
- return e.fromArray(n.map(t.nodeFromJSON));
237
- }
238
- static fromArray(t) {
239
- if (!t.length) return e.empty;
240
- let n, r = 0;
241
- for (let e = 0; e < t.length; e++) {
242
- let i = t[e];
243
- r += i.nodeSize, e && i.isText && t[e - 1].sameMarkup(i) ? (n ||= t.slice(0, e), n[n.length - 1] = i.withText(n[n.length - 1].text + i.text)) : n && n.push(i);
244
- }
245
- return new e(n || t, r);
246
- }
247
- static from(t) {
248
- if (!t) return e.empty;
249
- if (t instanceof e) return t;
250
- if (Array.isArray(t)) return this.fromArray(t);
251
- if (t.attrs) return new e([t], t.nodeSize);
252
- throw RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
253
- }
254
- };
255
- a.empty = new a([], 0);
256
- var o = {
257
- index: 0,
258
- offset: 0
259
- };
260
- function s(e, t) {
261
- return o.index = e, o.offset = t, o;
262
- }
263
- function c(e, t) {
264
- if (e === t) return !0;
265
- if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1;
266
- let n = Array.isArray(e);
267
- if (Array.isArray(t) != n) return !1;
268
- if (n) {
269
- if (e.length != t.length) return !1;
270
- for (let n = 0; n < e.length; n++) if (!c(e[n], t[n])) return !1;
271
- } else {
272
- for (let n in e) if (!(n in t) || !c(e[n], t[n])) return !1;
273
- for (let n in t) if (!(n in e)) return !1;
274
- }
275
- return !0;
276
- }
277
- var l = class e {
278
- constructor(e, t) {
279
- this.type = e, this.attrs = t;
280
- }
281
- addToSet(e) {
282
- let t, n = !1;
283
- for (let r = 0; r < e.length; r++) {
284
- let i = e[r];
285
- if (this.eq(i)) return e;
286
- if (this.type.excludes(i.type)) t ||= e.slice(0, r);
287
- else if (i.type.excludes(this.type)) return e;
288
- else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i);
289
- }
290
- return t ||= e.slice(), n || t.push(this), t;
291
- }
292
- removeFromSet(e) {
293
- for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1));
294
- return e;
295
- }
296
- isInSet(e) {
297
- for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0;
298
- return !1;
299
- }
300
- eq(e) {
301
- return this == e || this.type == e.type && c(this.attrs, e.attrs);
302
- }
303
- toJSON() {
304
- let e = { type: this.type.name };
305
- for (let t in this.attrs) {
306
- e.attrs = this.attrs;
307
- break;
308
- }
309
- return e;
310
- }
311
- static fromJSON(e, t) {
312
- if (!t) throw RangeError("Invalid input for Mark.fromJSON");
313
- let n = e.marks[t.type];
314
- if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`);
315
- let r = n.create(t.attrs);
316
- return n.checkAttrs(r.attrs), r;
317
- }
318
- static sameSet(e, t) {
319
- if (e == t) return !0;
320
- if (e.length != t.length) return !1;
321
- for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1;
322
- return !0;
323
- }
324
- static setFrom(t) {
325
- if (!t || Array.isArray(t) && t.length == 0) return e.none;
326
- if (t instanceof e) return [t];
327
- let n = t.slice();
328
- return n.sort((e, t) => e.type.rank - t.type.rank), n;
329
- }
330
- };
331
- l.none = [];
332
- var u = class extends Error {}, d = class e {
333
- constructor(e, t, n) {
334
- this.content = e, this.openStart = t, this.openEnd = n;
335
- }
336
- get size() {
337
- return this.content.size - this.openStart - this.openEnd;
338
- }
339
- insertAt(t, n) {
340
- let r = p(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1);
341
- return r && new e(r, this.openStart, this.openEnd);
342
- }
343
- removeBetween(t, n) {
344
- return new e(f(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd);
345
- }
346
- eq(e) {
347
- return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
348
- }
349
- toString() {
350
- return this.content + "(" + this.openStart + "," + this.openEnd + ")";
351
- }
352
- toJSON() {
353
- if (!this.content.size) return null;
354
- let e = { content: this.content.toJSON() };
355
- return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
356
- }
357
- static fromJSON(t, n) {
358
- if (!n) return e.empty;
359
- let r = n.openStart || 0, i = n.openEnd || 0;
360
- if (typeof r != "number" || typeof i != "number") throw RangeError("Invalid input for Slice.fromJSON");
361
- return new e(a.fromJSON(t, n.content), r, i);
362
- }
363
- static maxOpen(t, n = !0) {
364
- let r = 0, i = 0;
365
- for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++;
366
- for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++;
367
- return new e(t, r, i);
368
- }
369
- };
370
- d.empty = new d(a.empty, 0, 0);
371
- function f(e, t, n) {
372
- let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n);
373
- if (i == t || a.isText) {
374
- if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range");
375
- return e.cut(0, t).append(e.cut(n));
376
- }
377
- if (r != o) throw RangeError("Removing non-flat range");
378
- return e.replaceChild(r, a.copy(f(a.content, t - i - 1, n - i - 1)));
379
- }
380
- function p(e, t, n, r, i, a) {
381
- let { index: o, offset: s } = e.findIndex(t), c = e.maybeChild(o);
382
- if (s == t || c.isText) return a && r <= 0 && i <= 0 && !a.canReplace(o, o, n) ? null : e.cut(0, t).append(n).append(e.cut(t));
383
- let l = p(c.content, t - s - 1, n, o == 0 ? r - 1 : 0, o == e.childCount - 1 ? i - 1 : 0, c);
384
- return l && e.replaceChild(o, c.copy(l));
385
- }
386
- function m(e, t, n) {
387
- if (n.openStart > e.depth) throw new u("Inserted content deeper than insertion position");
388
- if (e.depth - n.openStart != t.depth - n.openEnd) throw new u("Inconsistent open depths");
389
- return h(e, t, n, 0);
390
- }
391
- function h(e, t, n, r) {
392
- let i = e.index(r), a = e.node(r);
393
- if (i == t.index(r) && r < e.depth - n.openStart) {
394
- let o = h(e, t, n, r + 1);
395
- return a.copy(a.content.replaceChild(i, o));
396
- }
397
- if (!n.content.size) return y(a, b(e, t, r));
398
- if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) {
399
- let r = e.parent, i = r.content;
400
- return y(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset)));
401
- }
402
- {
403
- let { start: i, end: o } = ne(n, e);
404
- return y(a, te(e, i, o, t, r));
405
- }
406
- }
407
- function ee(e, t) {
408
- if (!t.type.compatibleContent(e.type)) throw new u("Cannot join " + t.type.name + " onto " + e.type.name);
409
- }
410
- function g(e, t, n) {
411
- let r = e.node(n);
412
- return ee(r, t.node(n)), r;
413
- }
414
- function _(e, t) {
415
- let n = t.length - 1;
416
- n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e);
417
- }
418
- function v(e, t, n, r) {
419
- let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount;
420
- e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (_(e.nodeAfter, r), a++));
421
- for (let e = a; e < o; e++) _(i.child(e), r);
422
- t && t.depth == n && t.textOffset && _(t.nodeBefore, r);
423
- }
424
- function y(e, t) {
425
- if (!e.type.validContent(t)) throw new u("Invalid content for node " + e.type.name);
426
- return e.copy(t);
427
- }
428
- function te(e, t, n, r, i) {
429
- let o = e.depth > i && g(e, t, i + 1), s = r.depth > i && g(n, r, i + 1), c = [];
430
- return v(null, e, i, c), o && s && t.index(i) == n.index(i) ? (ee(o, s), _(y(o, te(e, t, n, r, i + 1)), c)) : (o && _(y(o, b(e, t, i + 1)), c), v(t, n, i, c), s && _(y(s, b(n, r, i + 1)), c)), v(r, null, i, c), new a(c);
431
- }
432
- function b(e, t, n) {
433
- let r = [];
434
- return v(null, e, n, r), e.depth > n && _(y(g(e, t, n + 1), b(e, t, n + 1)), r), v(t, null, n, r), new a(r);
435
- }
436
- function ne(e, t) {
437
- let n = t.depth - e.openStart, r = t.node(n).copy(e.content);
438
- for (let e = n - 1; e >= 0; e--) r = t.node(e).copy(a.from(r));
439
- return {
440
- start: r.resolveNoCache(e.openStart + n),
441
- end: r.resolveNoCache(r.content.size - e.openEnd - n)
442
- };
443
- }
444
- var re = class e {
445
- constructor(e, t, n) {
446
- this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1;
447
- }
448
- resolveDepth(e) {
449
- return e == null ? this.depth : e < 0 ? this.depth + e : e;
450
- }
451
- get parent() {
452
- return this.node(this.depth);
453
- }
454
- get doc() {
455
- return this.node(0);
456
- }
457
- node(e) {
458
- return this.path[this.resolveDepth(e) * 3];
459
- }
460
- index(e) {
461
- return this.path[this.resolveDepth(e) * 3 + 1];
462
- }
463
- indexAfter(e) {
464
- return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
465
- }
466
- start(e) {
467
- return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
468
- }
469
- end(e) {
470
- return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
471
- }
472
- before(e) {
473
- if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node");
474
- return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
475
- }
476
- after(e) {
477
- if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node");
478
- return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
479
- }
480
- get textOffset() {
481
- return this.pos - this.path[this.path.length - 1];
482
- }
483
- get nodeAfter() {
484
- let e = this.parent, t = this.index(this.depth);
485
- if (t == e.childCount) return null;
486
- let n = this.pos - this.path[this.path.length - 1], r = e.child(t);
487
- return n ? e.child(t).cut(n) : r;
488
- }
489
- get nodeBefore() {
490
- let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
491
- return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
492
- }
493
- posAtIndex(e, t) {
494
- t = this.resolveDepth(t);
495
- let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
496
- for (let t = 0; t < e; t++) r += n.child(t).nodeSize;
497
- return r;
498
- }
499
- marks() {
500
- let e = this.parent, t = this.index();
501
- if (e.content.size == 0) return l.none;
502
- if (this.textOffset) return e.child(t).marks;
503
- let n = e.maybeChild(t - 1), r = e.maybeChild(t);
504
- if (!n) {
505
- let e = n;
506
- n = r, r = e;
507
- }
508
- let i = n.marks;
509
- for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i));
510
- return i;
511
- }
512
- marksAcross(e) {
513
- let t = this.parent.maybeChild(this.index());
514
- if (!t || !t.isInline) return null;
515
- let n = t.marks, r = e.parent.maybeChild(e.index());
516
- for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n));
517
- return n;
518
- }
519
- sharedDepth(e) {
520
- for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t;
521
- return 0;
522
- }
523
- blockRange(e = this, t) {
524
- if (e.pos < this.pos) return e.blockRange(this);
525
- for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new se(this, e, n);
526
- return null;
527
- }
528
- sameParent(e) {
529
- return this.pos - this.parentOffset == e.pos - e.parentOffset;
530
- }
531
- max(e) {
532
- return e.pos > this.pos ? e : this;
533
- }
534
- min(e) {
535
- return e.pos < this.pos ? e : this;
536
- }
537
- toString() {
538
- let e = "";
539
- for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
540
- return e + ":" + this.parentOffset;
541
- }
542
- static resolve(t, n) {
543
- if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range");
544
- let r = [], i = 0, a = n;
545
- for (let e = t;;) {
546
- let { index: t, offset: n } = e.content.findIndex(a), o = a - n;
547
- if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break;
548
- a = o - 1, i += n + 1;
549
- }
550
- return new e(n, r, a);
551
- }
552
- static resolveCached(t, n) {
553
- let r = oe.get(t);
554
- if (r) for (let e = 0; e < r.elts.length; e++) {
555
- let t = r.elts[e];
556
- if (t.pos == n) return t;
557
- }
558
- else oe.set(t, r = new ie());
559
- let i = r.elts[r.i] = e.resolve(t, n);
560
- return r.i = (r.i + 1) % ae, i;
561
- }
562
- }, ie = class {
563
- constructor() {
564
- this.elts = [], this.i = 0;
565
- }
566
- }, ae = 12, oe = /* @__PURE__ */ new WeakMap(), se = class {
567
- constructor(e, t, n) {
568
- this.$from = e, this.$to = t, this.depth = n;
569
- }
570
- get start() {
571
- return this.$from.before(this.depth + 1);
572
- }
573
- get end() {
574
- return this.$to.after(this.depth + 1);
575
- }
576
- get parent() {
577
- return this.$from.node(this.depth);
578
- }
579
- get startIndex() {
580
- return this.$from.index(this.depth);
581
- }
582
- get endIndex() {
583
- return this.$to.indexAfter(this.depth);
584
- }
585
- }, ce = Object.create(null), x = class e {
586
- constructor(e, t, n, r = l.none) {
587
- this.type = e, this.attrs = t, this.marks = r, this.content = n || a.empty;
588
- }
589
- get children() {
590
- return this.content.content;
591
- }
592
- get nodeSize() {
593
- return this.isLeaf ? 1 : 2 + this.content.size;
594
- }
595
- get childCount() {
596
- return this.content.childCount;
597
- }
598
- child(e) {
599
- return this.content.child(e);
600
- }
601
- maybeChild(e) {
602
- return this.content.maybeChild(e);
603
- }
604
- forEach(e) {
605
- this.content.forEach(e);
606
- }
607
- nodesBetween(e, t, n, r = 0) {
608
- this.content.nodesBetween(e, t, n, r, this);
609
- }
610
- descendants(e) {
611
- this.nodesBetween(0, this.content.size, e);
612
- }
613
- get textContent() {
614
- return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
615
- }
616
- textBetween(e, t, n, r) {
617
- return this.content.textBetween(e, t, n, r);
618
- }
619
- get firstChild() {
620
- return this.content.firstChild;
621
- }
622
- get lastChild() {
623
- return this.content.lastChild;
624
- }
625
- eq(e) {
626
- return this == e || this.sameMarkup(e) && this.content.eq(e.content);
627
- }
628
- sameMarkup(e) {
629
- return this.hasMarkup(e.type, e.attrs, e.marks);
630
- }
631
- hasMarkup(e, t, n) {
632
- return this.type == e && c(this.attrs, t || e.defaultAttrs || ce) && l.sameSet(this.marks, n || l.none);
633
- }
634
- copy(t = null) {
635
- return t == this.content ? this : new e(this.type, this.attrs, t, this.marks);
636
- }
637
- mark(t) {
638
- return t == this.marks ? this : new e(this.type, this.attrs, this.content, t);
639
- }
640
- cut(e, t = this.content.size) {
641
- return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
642
- }
643
- slice(e, t = this.content.size, n = !1) {
644
- if (e == t) return d.empty;
645
- let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a);
646
- return new d(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a);
647
- }
648
- replace(e, t, n) {
649
- return m(this.resolve(e), this.resolve(t), n);
650
- }
651
- nodeAt(e) {
652
- for (let t = this;;) {
653
- let { index: n, offset: r } = t.content.findIndex(e);
654
- if (t = t.maybeChild(n), !t) return null;
655
- if (r == e || t.isText) return t;
656
- e -= r + 1;
657
- }
658
- }
659
- childAfter(e) {
660
- let { index: t, offset: n } = this.content.findIndex(e);
661
- return {
662
- node: this.content.maybeChild(t),
663
- index: t,
664
- offset: n
665
- };
666
- }
667
- childBefore(e) {
668
- if (e == 0) return {
669
- node: null,
670
- index: 0,
671
- offset: 0
672
- };
673
- let { index: t, offset: n } = this.content.findIndex(e);
674
- if (n < e) return {
675
- node: this.content.child(t),
676
- index: t,
677
- offset: n
678
- };
679
- let r = this.content.child(t - 1);
680
- return {
681
- node: r,
682
- index: t - 1,
683
- offset: n - r.nodeSize
684
- };
685
- }
686
- resolve(e) {
687
- return re.resolveCached(this, e);
688
- }
689
- resolveNoCache(e) {
690
- return re.resolve(this, e);
691
- }
692
- rangeHasMark(e, t, n) {
693
- let r = !1;
694
- return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r;
695
- }
696
- get isBlock() {
697
- return this.type.isBlock;
698
- }
699
- get isTextblock() {
700
- return this.type.isTextblock;
701
- }
702
- get inlineContent() {
703
- return this.type.inlineContent;
704
- }
705
- get isInline() {
706
- return this.type.isInline;
707
- }
708
- get isText() {
709
- return this.type.isText;
710
- }
711
- get isLeaf() {
712
- return this.type.isLeaf;
713
- }
714
- get isAtom() {
715
- return this.type.isAtom;
716
- }
717
- toString() {
718
- if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
719
- let e = this.type.name;
720
- return this.content.size && (e += "(" + this.content.toStringInner() + ")"), ue(this.marks, e);
721
- }
722
- contentMatchAt(e) {
723
- let t = this.type.contentMatch.matchFragment(this.content, 0, e);
724
- if (!t) throw Error("Called contentMatchAt on a node with invalid content");
725
- return t;
726
- }
727
- canReplace(e, t, n = a.empty, r = 0, i = n.childCount) {
728
- let o = this.contentMatchAt(e).matchFragment(n, r, i), s = o && o.matchFragment(this.content, t);
729
- if (!s || !s.validEnd) return !1;
730
- for (let e = r; e < i; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1;
731
- return !0;
732
- }
733
- canReplaceWith(e, t, n, r) {
734
- if (r && !this.type.allowsMarks(r)) return !1;
735
- let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t);
736
- return a ? a.validEnd : !1;
737
- }
738
- canAppend(e) {
739
- return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
740
- }
741
- check() {
742
- this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
743
- let e = l.none;
744
- for (let t = 0; t < this.marks.length; t++) {
745
- let n = this.marks[t];
746
- n.type.checkAttrs(n.attrs), e = n.addToSet(e);
747
- }
748
- if (!l.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`);
749
- this.content.forEach((e) => e.check());
750
- }
751
- toJSON() {
752
- let e = { type: this.type.name };
753
- for (let t in this.attrs) {
754
- e.attrs = this.attrs;
755
- break;
756
- }
757
- return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e;
758
- }
759
- static fromJSON(e, t) {
760
- if (!t) throw RangeError("Invalid input for Node.fromJSON");
761
- let n;
762
- if (t.marks) {
763
- if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON");
764
- n = t.marks.map(e.markFromJSON);
765
- }
766
- if (t.type == "text") {
767
- if (typeof t.text != "string") throw RangeError("Invalid text node in JSON");
768
- return e.text(t.text, n);
769
- }
770
- let r = a.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, r, n);
771
- return i.type.checkAttrs(i.attrs), i;
772
- }
773
- };
774
- x.prototype.text = void 0;
775
- var le = class e extends x {
776
- constructor(e, t, n, r) {
777
- if (super(e, t, null, r), !n) throw RangeError("Empty text nodes are not allowed");
778
- this.text = n;
779
- }
780
- toString() {
781
- return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : ue(this.marks, JSON.stringify(this.text));
782
- }
783
- get textContent() {
784
- return this.text;
785
- }
786
- textBetween(e, t) {
787
- return this.text.slice(e, t);
788
- }
789
- get nodeSize() {
790
- return this.text.length;
791
- }
792
- mark(t) {
793
- return t == this.marks ? this : new e(this.type, this.attrs, this.text, t);
794
- }
795
- withText(t) {
796
- return t == this.text ? this : new e(this.type, this.attrs, t, this.marks);
797
- }
798
- cut(e = 0, t = this.text.length) {
799
- return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t));
800
- }
801
- eq(e) {
802
- return this.sameMarkup(e) && this.text == e.text;
803
- }
804
- toJSON() {
805
- let e = super.toJSON();
806
- return e.text = this.text, e;
807
- }
808
- };
809
- function ue(e, t) {
810
- for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")";
811
- return t;
812
- }
813
- var S = class e {
814
- constructor(e) {
815
- this.validEnd = e, this.next = [], this.wrapCache = [];
816
- }
817
- static parse(t, n) {
818
- let r = new de(t, n);
819
- if (r.next == null) return e.empty;
820
- let i = fe(r);
821
- r.next && r.err("Unexpected trailing text");
822
- let a = Se(ye(i));
823
- return Ce(a, r), a;
824
- }
825
- matchType(e) {
826
- for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next;
827
- return null;
828
- }
829
- matchFragment(e, t = 0, n = e.childCount) {
830
- let r = this;
831
- for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type);
832
- return r;
833
- }
834
- get inlineContent() {
835
- return this.next.length != 0 && this.next[0].type.isInline;
836
- }
837
- get defaultType() {
838
- for (let e = 0; e < this.next.length; e++) {
839
- let { type: t } = this.next[e];
840
- if (!(t.isText || t.hasRequiredAttrs())) return t;
841
- }
842
- return null;
843
- }
844
- compatible(e) {
845
- for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0;
846
- return !1;
847
- }
848
- fillBefore(e, t = !1, n = 0) {
849
- let r = [this];
850
- function i(o, s) {
851
- let c = o.matchFragment(e, n);
852
- if (c && (!t || c.validEnd)) return a.from(s.map((e) => e.createAndFill()));
853
- for (let e = 0; e < o.next.length; e++) {
854
- let { type: t, next: n } = o.next[e];
855
- if (!(t.isText || t.hasRequiredAttrs()) && r.indexOf(n) == -1) {
856
- r.push(n);
857
- let e = i(n, s.concat(t));
858
- if (e) return e;
859
- }
860
- }
861
- return null;
862
- }
863
- return i(this, []);
864
- }
865
- findWrapping(e) {
866
- for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1];
867
- let t = this.computeWrapping(e);
868
- return this.wrapCache.push(e, t), t;
869
- }
870
- computeWrapping(e) {
871
- let t = Object.create(null), n = [{
872
- match: this,
873
- type: null,
874
- via: null
875
- }];
876
- for (; n.length;) {
877
- let r = n.shift(), i = r.match;
878
- if (i.matchType(e)) {
879
- let e = [];
880
- for (let t = r; t.type; t = t.via) e.push(t.type);
881
- return e.reverse();
882
- }
883
- for (let e = 0; e < i.next.length; e++) {
884
- let { type: a, next: o } = i.next[e];
885
- !a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({
886
- match: a.contentMatch,
887
- type: a,
888
- via: r
889
- }), t[a.name] = !0);
890
- }
891
- }
892
- return null;
893
- }
894
- get edgeCount() {
895
- return this.next.length;
896
- }
897
- edge(e) {
898
- if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`);
899
- return this.next[e];
900
- }
901
- toString() {
902
- let e = [];
903
- function t(n) {
904
- e.push(n);
905
- for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next);
906
- }
907
- return t(this), e.map((t, n) => {
908
- let r = n + (t.validEnd ? "*" : " ") + " ";
909
- for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next);
910
- return r;
911
- }).join("\n");
912
- }
913
- };
914
- S.empty = new S(!0);
915
- var de = class {
916
- constructor(e, t) {
917
- this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
918
- }
919
- get next() {
920
- return this.tokens[this.pos];
921
- }
922
- eat(e) {
923
- return this.next == e && (this.pos++ || !0);
924
- }
925
- err(e) {
926
- throw SyntaxError(e + " (in content expression '" + this.string + "')");
927
- }
928
- };
929
- function fe(e) {
930
- let t = [];
931
- do
932
- t.push(pe(e));
933
- while (e.eat("|"));
934
- return t.length == 1 ? t[0] : {
935
- type: "choice",
936
- exprs: t
937
- };
938
- }
939
- function pe(e) {
940
- let t = [];
941
- do
942
- t.push(me(e));
943
- while (e.next && e.next != ")" && e.next != "|");
944
- return t.length == 1 ? t[0] : {
945
- type: "seq",
946
- exprs: t
947
- };
948
- }
949
- function me(e) {
950
- let t = ve(e);
951
- for (;;) if (e.eat("+")) t = {
952
- type: "plus",
953
- expr: t
954
- };
955
- else if (e.eat("*")) t = {
956
- type: "star",
957
- expr: t
958
- };
959
- else if (e.eat("?")) t = {
960
- type: "opt",
961
- expr: t
962
- };
963
- else if (e.eat("{")) t = ge(e, t);
964
- else break;
965
- return t;
966
- }
967
- function he(e) {
968
- /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'");
969
- let t = Number(e.next);
970
- return e.pos++, t;
971
- }
972
- function ge(e, t) {
973
- let n = he(e), r = n;
974
- return e.eat(",") && (r = e.next == "}" ? -1 : he(e)), e.eat("}") || e.err("Unclosed braced range"), {
975
- type: "range",
976
- min: n,
977
- max: r,
978
- expr: t
979
- };
980
- }
981
- function _e(e, t) {
982
- let n = e.nodeTypes, r = n[t];
983
- if (r) return [r];
984
- let i = [];
985
- for (let e in n) {
986
- let r = n[e];
987
- r.isInGroup(t) && i.push(r);
988
- }
989
- return i.length == 0 && e.err("No node type or group '" + t + "' found"), i;
990
- }
991
- function ve(e) {
992
- if (e.eat("(")) {
993
- let t = fe(e);
994
- return e.eat(")") || e.err("Missing closing paren"), t;
995
- }
996
- if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'");
997
- else {
998
- let t = _e(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), {
999
- type: "name",
1000
- value: t
1001
- }));
1002
- return e.pos++, t.length == 1 ? t[0] : {
1003
- type: "choice",
1004
- exprs: t
1005
- };
1006
- }
1007
- }
1008
- function ye(e) {
1009
- let t = [[]];
1010
- return i(a(e, 0), n()), t;
1011
- function n() {
1012
- return t.push([]) - 1;
1013
- }
1014
- function r(e, n, r) {
1015
- let i = {
1016
- term: r,
1017
- to: n
1018
- };
1019
- return t[e].push(i), i;
1020
- }
1021
- function i(e, t) {
1022
- e.forEach((e) => e.to = t);
1023
- }
1024
- function a(e, t) {
1025
- if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []);
1026
- if (e.type == "seq") for (let r = 0;; r++) {
1027
- let o = a(e.exprs[r], t);
1028
- if (r == e.exprs.length - 1) return o;
1029
- i(o, t = n());
1030
- }
1031
- else if (e.type == "star") {
1032
- let o = n();
1033
- return r(t, o), i(a(e.expr, o), o), [r(o)];
1034
- } else if (e.type == "plus") {
1035
- let o = n();
1036
- return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)];
1037
- } else if (e.type == "opt") return [r(t)].concat(a(e.expr, t));
1038
- else if (e.type == "range") {
1039
- let o = t;
1040
- for (let t = 0; t < e.min; t++) {
1041
- let t = n();
1042
- i(a(e.expr, o), t), o = t;
1043
- }
1044
- if (e.max == -1) i(a(e.expr, o), o);
1045
- else for (let t = e.min; t < e.max; t++) {
1046
- let t = n();
1047
- r(o, t), i(a(e.expr, o), t), o = t;
1048
- }
1049
- return [r(o)];
1050
- } else if (e.type == "name") return [r(t, void 0, e.value)];
1051
- else throw Error("Unknown expr type");
1052
- }
1053
- }
1054
- function be(e, t) {
1055
- return t - e;
1056
- }
1057
- function xe(e, t) {
1058
- let n = [];
1059
- return r(t), n.sort(be);
1060
- function r(t) {
1061
- let i = e[t];
1062
- if (i.length == 1 && !i[0].term) return r(i[0].to);
1063
- n.push(t);
1064
- for (let e = 0; e < i.length; e++) {
1065
- let { term: t, to: a } = i[e];
1066
- !t && n.indexOf(a) == -1 && r(a);
1067
- }
1068
- }
1069
- }
1070
- function Se(e) {
1071
- let t = Object.create(null);
1072
- return n(xe(e, 0));
1073
- function n(r) {
1074
- let i = [];
1075
- r.forEach((t) => {
1076
- e[t].forEach(({ term: t, to: n }) => {
1077
- if (!t) return;
1078
- let r;
1079
- for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]);
1080
- xe(e, n).forEach((e) => {
1081
- r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e);
1082
- });
1083
- });
1084
- });
1085
- let a = t[r.join(",")] = new S(r.indexOf(e.length - 1) > -1);
1086
- for (let e = 0; e < i.length; e++) {
1087
- let r = i[e][1].sort(be);
1088
- a.next.push({
1089
- type: i[e][0],
1090
- next: t[r.join(",")] || n(r)
1091
- });
1092
- }
1093
- return a;
1094
- }
1095
- }
1096
- function Ce(e, t) {
1097
- for (let n = 0, r = [e]; n < r.length; n++) {
1098
- let e = r[n], i = !e.validEnd, a = [];
1099
- for (let t = 0; t < e.next.length; t++) {
1100
- let { type: n, next: o } = e.next[t];
1101
- a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o);
1102
- }
1103
- i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
1104
- }
1105
- }
1106
- function we(e) {
1107
- let t = Object.create(null);
1108
- for (let n in e) {
1109
- let r = e[n];
1110
- if (!r.hasDefault) return null;
1111
- t[n] = r.default;
1112
- }
1113
- return t;
1114
- }
1115
- function Te(e, t) {
1116
- let n = Object.create(null);
1117
- for (let r in e) {
1118
- let i = t && t[r];
1119
- if (i === void 0) {
1120
- let t = e[r];
1121
- if (t.hasDefault) i = t.default;
1122
- else throw RangeError("No value supplied for attribute " + r);
1123
- }
1124
- n[r] = i;
1125
- }
1126
- return n;
1127
- }
1128
- function Ee(e, t, n, r) {
1129
- for (let i in t) if (!(i in e)) throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);
1130
- for (let n in e) e[n].validate && e[n].validate(t[n]);
1131
- }
1132
- function De(e, t) {
1133
- let n = Object.create(null);
1134
- if (t) for (let r in t) n[r] = new Ae(e, r, t[r]);
1135
- return n;
1136
- }
1137
- var Oe = class e {
1138
- constructor(e, t, n) {
1139
- this.name = e, this.schema = t, this.spec = n, this.markSet = null, this.groups = n.group ? n.group.split(" ") : [], this.attrs = De(e, n.attrs), this.defaultAttrs = we(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(n.inline || e == "text"), this.isText = e == "text";
1140
- }
1141
- get isInline() {
1142
- return !this.isBlock;
1143
- }
1144
- get isTextblock() {
1145
- return this.isBlock && this.inlineContent;
1146
- }
1147
- get isLeaf() {
1148
- return this.contentMatch == S.empty;
1149
- }
1150
- get isAtom() {
1151
- return this.isLeaf || !!this.spec.atom;
1152
- }
1153
- isInGroup(e) {
1154
- return this.groups.indexOf(e) > -1;
1155
- }
1156
- get whitespace() {
1157
- return this.spec.whitespace || (this.spec.code ? "pre" : "normal");
1158
- }
1159
- hasRequiredAttrs() {
1160
- for (let e in this.attrs) if (this.attrs[e].isRequired) return !0;
1161
- return !1;
1162
- }
1163
- compatibleContent(e) {
1164
- return this == e || this.contentMatch.compatible(e.contentMatch);
1165
- }
1166
- computeAttrs(e) {
1167
- return !e && this.defaultAttrs ? this.defaultAttrs : Te(this.attrs, e);
1168
- }
1169
- create(e = null, t, n) {
1170
- if (this.isText) throw Error("NodeType.create can't construct text nodes");
1171
- return new x(this, this.computeAttrs(e), a.from(t), l.setFrom(n));
1172
- }
1173
- createChecked(e = null, t, n) {
1174
- return t = a.from(t), this.checkContent(t), new x(this, this.computeAttrs(e), t, l.setFrom(n));
1175
- }
1176
- createAndFill(e = null, t, n) {
1177
- if (e = this.computeAttrs(e), t = a.from(t), t.size) {
1178
- let e = this.contentMatch.fillBefore(t);
1179
- if (!e) return null;
1180
- t = e.append(t);
1181
- }
1182
- let r = this.contentMatch.matchFragment(t), i = r && r.fillBefore(a.empty, !0);
1183
- return i ? new x(this, e, t.append(i), l.setFrom(n)) : null;
1184
- }
1185
- validContent(e) {
1186
- let t = this.contentMatch.matchFragment(e);
1187
- if (!t || !t.validEnd) return !1;
1188
- for (let t = 0; t < e.childCount; t++) if (!this.allowsMarks(e.child(t).marks)) return !1;
1189
- return !0;
1190
- }
1191
- checkContent(e) {
1192
- if (!this.validContent(e)) throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`);
1193
- }
1194
- checkAttrs(e) {
1195
- Ee(this.attrs, e, "node", this.name);
1196
- }
1197
- allowsMarkType(e) {
1198
- return this.markSet == null || this.markSet.indexOf(e) > -1;
1199
- }
1200
- allowsMarks(e) {
1201
- if (this.markSet == null) return !0;
1202
- for (let t = 0; t < e.length; t++) if (!this.allowsMarkType(e[t].type)) return !1;
1203
- return !0;
1204
- }
1205
- allowedMarks(e) {
1206
- if (this.markSet == null) return e;
1207
- let t;
1208
- for (let n = 0; n < e.length; n++) this.allowsMarkType(e[n].type) ? t && t.push(e[n]) : t ||= e.slice(0, n);
1209
- return t ? t.length ? t : l.none : e;
1210
- }
1211
- static compile(t, n) {
1212
- let r = Object.create(null);
1213
- t.forEach((t, i) => r[t] = new e(t, n, i));
1214
- let i = n.spec.topNode || "doc";
1215
- if (!r[i]) throw RangeError("Schema is missing its top node type ('" + i + "')");
1216
- if (!r.text) throw RangeError("Every schema needs a 'text' type");
1217
- for (let e in r.text.attrs) throw RangeError("The text node type should not have attributes");
1218
- return r;
1219
- }
1220
- };
1221
- function ke(e, t, n) {
1222
- let r = n.split("|");
1223
- return (n) => {
1224
- let i = n === null ? "null" : typeof n;
1225
- if (r.indexOf(i) < 0) throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`);
1226
- };
1227
- }
1228
- var Ae = class {
1229
- constructor(e, t, n) {
1230
- this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default"), this.default = n.default, this.validate = typeof n.validate == "string" ? ke(e, t, n.validate) : n.validate;
1231
- }
1232
- get isRequired() {
1233
- return !this.hasDefault;
1234
- }
1235
- }, je = class e {
1236
- constructor(e, t, n, r) {
1237
- this.name = e, this.rank = t, this.schema = n, this.spec = r, this.attrs = De(e, r.attrs), this.excluded = null;
1238
- let i = we(this.attrs);
1239
- this.instance = i ? new l(this, i) : null;
1240
- }
1241
- create(e = null) {
1242
- return !e && this.instance ? this.instance : new l(this, Te(this.attrs, e));
1243
- }
1244
- static compile(t, n) {
1245
- let r = Object.create(null), i = 0;
1246
- return t.forEach((t, a) => r[t] = new e(t, i++, n, a)), r;
1247
- }
1248
- removeFromSet(e) {
1249
- for (var t = 0; t < e.length; t++) e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--);
1250
- return e;
1251
- }
1252
- isInSet(e) {
1253
- for (let t = 0; t < e.length; t++) if (e[t].type == this) return e[t];
1254
- }
1255
- checkAttrs(e) {
1256
- Ee(this.attrs, e, "mark", this.name);
1257
- }
1258
- excludes(e) {
1259
- return this.excluded.indexOf(e) > -1;
1260
- }
1261
- }, Me = class {
1262
- constructor(t) {
1263
- this.linebreakReplacement = null, this.cached = Object.create(null);
1264
- let n = this.spec = {};
1265
- for (let e in t) n[e] = t[e];
1266
- n.nodes = e.from(t.nodes), n.marks = e.from(t.marks || {}), this.nodes = Oe.compile(this.spec.nodes, this), this.marks = je.compile(this.spec.marks, this);
1267
- let r = Object.create(null);
1268
- for (let e in this.nodes) {
1269
- if (e in this.marks) throw RangeError(e + " can not be both a node and a mark");
1270
- let t = this.nodes[e], n = t.spec.content || "", i = t.spec.marks;
1271
- if (t.contentMatch = r[n] || (r[n] = S.parse(n, this.nodes)), t.inlineContent = t.contentMatch.inlineContent, t.spec.linebreakReplacement) {
1272
- if (this.linebreakReplacement) throw RangeError("Multiple linebreak nodes defined");
1273
- if (!t.isInline || !t.isLeaf) throw RangeError("Linebreak replacement nodes must be inline leaf nodes");
1274
- this.linebreakReplacement = t;
1275
- }
1276
- t.markSet = i == "_" ? null : i ? Ne(this, i.split(" ")) : i == "" || !t.inlineContent ? [] : null;
1277
- }
1278
- for (let e in this.marks) {
1279
- let t = this.marks[e], n = t.spec.excludes;
1280
- t.excluded = n == null ? [t] : n == "" ? [] : Ne(this, n.split(" "));
1281
- }
1282
- this.nodeFromJSON = (e) => x.fromJSON(this, e), this.markFromJSON = (e) => l.fromJSON(this, e), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = Object.create(null);
1283
- }
1284
- node(e, t = null, n, r) {
1285
- if (typeof e == "string") e = this.nodeType(e);
1286
- else if (!(e instanceof Oe)) throw RangeError("Invalid node type: " + e);
1287
- else if (e.schema != this) throw RangeError("Node type from different schema used (" + e.name + ")");
1288
- return e.createChecked(t, n, r);
1289
- }
1290
- text(e, t) {
1291
- let n = this.nodes.text;
1292
- return new le(n, n.defaultAttrs, e, l.setFrom(t));
1293
- }
1294
- mark(e, t) {
1295
- return typeof e == "string" && (e = this.marks[e]), e.create(t);
1296
- }
1297
- nodeType(e) {
1298
- let t = this.nodes[e];
1299
- if (!t) throw RangeError("Unknown node type: " + e);
1300
- return t;
1301
- }
1302
- };
1303
- function Ne(e, t) {
1304
- let n = [];
1305
- for (let r = 0; r < t.length; r++) {
1306
- let i = t[r], a = e.marks[i], o = a;
1307
- if (a) n.push(a);
1308
- else for (let t in e.marks) {
1309
- let r = e.marks[t];
1310
- (i == "_" || r.spec.group && r.spec.group.split(" ").indexOf(i) > -1) && n.push(o = r);
1311
- }
1312
- if (!o) throw SyntaxError("Unknown mark type: '" + t[r] + "'");
1313
- }
1314
- return n;
1315
- }
1316
- function Pe(e) {
1317
- return e.tag != null;
1318
- }
1319
- function Fe(e) {
1320
- return e.style != null;
1321
- }
1322
- var Ie = class e {
1323
- constructor(e, t) {
1324
- this.schema = e, this.rules = t, this.tags = [], this.styles = [];
1325
- let n = this.matchedStyles = [];
1326
- t.forEach((e) => {
1327
- if (Pe(e)) this.tags.push(e);
1328
- else if (Fe(e)) {
1329
- let t = /[^=]*/.exec(e.style)[0];
1330
- n.indexOf(t) < 0 && n.push(t), this.styles.push(e);
1331
- }
1332
- }), this.normalizeLists = !this.tags.some((t) => {
1333
- if (!/^(ul|ol)\b/.test(t.tag) || !t.node) return !1;
1334
- let n = e.nodes[t.node];
1335
- return n.contentMatch.matchType(n);
1336
- });
1337
- }
1338
- parse(e, t = {}) {
1339
- let n = new He(this, t, !1);
1340
- return n.addAll(e, l.none, t.from, t.to), n.finish();
1341
- }
1342
- parseSlice(e, t = {}) {
1343
- let n = new He(this, t, !0);
1344
- return n.addAll(e, l.none, t.from, t.to), d.maxOpen(n.finish());
1345
- }
1346
- matchTag(e, t, n) {
1347
- for (let r = n ? this.tags.indexOf(n) + 1 : 0; r < this.tags.length; r++) {
1348
- let n = this.tags[r];
1349
- if (We(e, n.tag) && (n.namespace === void 0 || e.namespaceURI == n.namespace) && (!n.context || t.matchesContext(n.context))) {
1350
- if (n.getAttrs) {
1351
- let t = n.getAttrs(e);
1352
- if (t === !1) continue;
1353
- n.attrs = t || void 0;
1354
- }
1355
- return n;
1356
- }
1357
- }
1358
- }
1359
- matchStyle(e, t, n, r) {
1360
- for (let i = r ? this.styles.indexOf(r) + 1 : 0; i < this.styles.length; i++) {
1361
- let r = this.styles[i], a = r.style;
1362
- if (!(a.indexOf(e) != 0 || r.context && !n.matchesContext(r.context) || a.length > e.length && (a.charCodeAt(e.length) != 61 || a.slice(e.length + 1) != t))) {
1363
- if (r.getAttrs) {
1364
- let e = r.getAttrs(t);
1365
- if (e === !1) continue;
1366
- r.attrs = e || void 0;
1367
- }
1368
- return r;
1369
- }
1370
- }
1371
- }
1372
- static schemaRules(e) {
1373
- let t = [];
1374
- function n(e) {
1375
- let n = e.priority == null ? 50 : e.priority, r = 0;
1376
- for (; r < t.length; r++) {
1377
- let e = t[r];
1378
- if ((e.priority == null ? 50 : e.priority) < n) break;
1379
- }
1380
- t.splice(r, 0, e);
1381
- }
1382
- for (let t in e.marks) {
1383
- let r = e.marks[t].spec.parseDOM;
1384
- r && r.forEach((e) => {
1385
- n(e = Ge(e)), e.mark || e.ignore || e.clearMark || (e.mark = t);
1386
- });
1387
- }
1388
- for (let t in e.nodes) {
1389
- let r = e.nodes[t].spec.parseDOM;
1390
- r && r.forEach((e) => {
1391
- n(e = Ge(e)), e.node || e.ignore || e.mark || (e.node = t);
1392
- });
1393
- }
1394
- return t;
1395
- }
1396
- static fromSchema(t) {
1397
- return t.cached.domParser || (t.cached.domParser = new e(t, e.schemaRules(t)));
1398
- }
1399
- }, Le = {
1400
- address: !0,
1401
- article: !0,
1402
- aside: !0,
1403
- blockquote: !0,
1404
- body: !0,
1405
- canvas: !0,
1406
- dd: !0,
1407
- div: !0,
1408
- dl: !0,
1409
- fieldset: !0,
1410
- figcaption: !0,
1411
- figure: !0,
1412
- footer: !0,
1413
- form: !0,
1414
- h1: !0,
1415
- h2: !0,
1416
- h3: !0,
1417
- h4: !0,
1418
- h5: !0,
1419
- h6: !0,
1420
- header: !0,
1421
- hgroup: !0,
1422
- hr: !0,
1423
- li: !0,
1424
- noscript: !0,
1425
- ol: !0,
1426
- output: !0,
1427
- p: !0,
1428
- pre: !0,
1429
- section: !0,
1430
- table: !0,
1431
- tfoot: !0,
1432
- ul: !0
1433
- }, Re = {
1434
- head: !0,
1435
- noscript: !0,
1436
- object: !0,
1437
- script: !0,
1438
- style: !0,
1439
- title: !0
1440
- }, ze = {
1441
- ol: !0,
1442
- ul: !0
1443
- }, C = 1, Be = 2, w = 4;
1444
- function Ve(e, t, n) {
1445
- return t == null ? e && e.whitespace == "pre" ? 3 : n & -5 : (t ? C : 0) | (t === "full" ? Be : 0);
1446
- }
1447
- var T = class {
1448
- constructor(e, t, n, r, i, a) {
1449
- this.type = e, this.attrs = t, this.marks = n, this.solid = r, this.options = a, this.content = [], this.activeMarks = l.none, this.match = i || (a & w ? null : e.contentMatch);
1450
- }
1451
- findWrapping(e) {
1452
- if (!this.match) {
1453
- if (!this.type) return [];
1454
- let t = this.type.contentMatch.fillBefore(a.from(e));
1455
- if (t) this.match = this.type.contentMatch.matchFragment(t);
1456
- else {
1457
- let t = this.type.contentMatch, n;
1458
- return (n = t.findWrapping(e.type)) ? (this.match = t, n) : null;
1459
- }
1460
- }
1461
- return this.match.findWrapping(e.type);
1462
- }
1463
- finish(e) {
1464
- if (!(this.options & C)) {
1465
- let e = this.content[this.content.length - 1], t;
1466
- if (e && e.isText && (t = /[ \t\r\n\u000c]+$/.exec(e.text))) {
1467
- let n = e;
1468
- e.text.length == t[0].length ? this.content.pop() : this.content[this.content.length - 1] = n.withText(n.text.slice(0, n.text.length - t[0].length));
1469
- }
1470
- }
1471
- let t = a.from(this.content);
1472
- return !e && this.match && (t = t.append(this.match.fillBefore(a.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t;
1473
- }
1474
- inlineContext(e) {
1475
- return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !Le.hasOwnProperty(e.parentNode.nodeName.toLowerCase());
1476
- }
1477
- }, He = class {
1478
- constructor(e, t, n) {
1479
- this.parser = e, this.options = t, this.isOpen = n, this.open = 0, this.localPreserveWS = !1;
1480
- let r = t.topNode, i, a = Ve(null, t.preserveWhitespace, 0) | (n ? w : 0);
1481
- i = r ? new T(r.type, r.attrs, l.none, !0, t.topMatch || r.type.contentMatch, a) : n ? new T(null, null, l.none, !0, null, a) : new T(e.schema.topNodeType, null, l.none, !0, null, a), this.nodes = [i], this.find = t.findPositions, this.needsBlock = !1;
1482
- }
1483
- get top() {
1484
- return this.nodes[this.open];
1485
- }
1486
- addDOM(e, t) {
1487
- e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
1488
- }
1489
- addTextNode(e, t) {
1490
- let n = e.nodeValue, r = this.top, i = r.options & Be ? "full" : this.localPreserveWS || (r.options & C) > 0, { schema: a } = this.parser;
1491
- if (i === "full" || r.inlineContext(e) || /[^ \t\r\n\u000c]/.test(n)) {
1492
- if (!i) {
1493
- if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) {
1494
- let t = r.content[r.content.length - 1], i = e.previousSibling;
1495
- (!t || i && i.nodeName == "BR" || t.isText && /[ \t\r\n\u000c]$/.test(t.text)) && (n = n.slice(1));
1496
- }
1497
- } else if (i === "full") n = n.replace(/\r\n?/g, "\n");
1498
- else if (a.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(a.linebreakReplacement.create())) {
1499
- let e = n.split(/\r?\n|\r/);
1500
- for (let n = 0; n < e.length; n++) n && this.insertNode(a.linebreakReplacement.create(), t, !0), e[n] && this.insertNode(a.text(e[n]), t, !/\S/.test(e[n]));
1501
- n = "";
1502
- } else n = n.replace(/\r?\n|\r/g, " ");
1503
- n && this.insertNode(a.text(n), t, !/\S/.test(n)), this.findInText(e);
1504
- } else this.findInside(e);
1505
- }
1506
- addElement(e, t, n) {
1507
- let r = this.localPreserveWS, i = this.top;
1508
- (e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0);
1509
- let a = e.nodeName.toLowerCase(), o;
1510
- ze.hasOwnProperty(a) && this.parser.normalizeLists && Ue(e);
1511
- let s = this.options.ruleFromNode && this.options.ruleFromNode(e) || (o = this.parser.matchTag(e, this, n));
1512
- out: if (s ? s.ignore : Re.hasOwnProperty(a)) this.findInside(e), this.ignoreFallback(e, t);
1513
- else if (!s || s.skip || s.closeParent) {
1514
- s && s.closeParent ? this.open = Math.max(0, this.open - 1) : s && s.skip.nodeType && (e = s.skip);
1515
- let n, r = this.needsBlock;
1516
- if (Le.hasOwnProperty(a)) i.content.length && i.content[0].isInline && this.open && (this.open--, i = this.top), n = !0, i.type || (this.needsBlock = !0);
1517
- else if (!e.firstChild) {
1518
- this.leafFallback(e, t);
1519
- break out;
1520
- }
1521
- let o = s && s.skip ? t : this.readStyles(e, t);
1522
- o && this.addAll(e, o), n && this.sync(i), this.needsBlock = r;
1523
- } else {
1524
- let n = this.readStyles(e, t);
1525
- n && this.addElementByRule(e, s, n, s.consuming === !1 ? o : void 0);
1526
- }
1527
- this.localPreserveWS = r;
1528
- }
1529
- leafFallback(e, t) {
1530
- e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode("\n"), t);
1531
- }
1532
- ignoreFallback(e, t) {
1533
- e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, !0);
1534
- }
1535
- readStyles(e, t) {
1536
- let n = e.style;
1537
- if (n && n.length) for (let e = 0; e < this.parser.matchedStyles.length; e++) {
1538
- let r = this.parser.matchedStyles[e], i = n.getPropertyValue(r);
1539
- if (i) for (let e;;) {
1540
- let n = this.parser.matchStyle(r, i, this, e);
1541
- if (!n) break;
1542
- if (n.ignore) return null;
1543
- if (t = n.clearMark ? t.filter((e) => !n.clearMark(e)) : t.concat(this.parser.schema.marks[n.mark].create(n.attrs)), n.consuming === !1) e = n;
1544
- else break;
1545
- }
1546
- }
1547
- return t;
1548
- }
1549
- addElementByRule(e, t, n, r) {
1550
- let i, a;
1551
- if (t.node) if (a = this.parser.schema.nodes[t.node], a.isLeaf) this.insertNode(a.create(t.attrs), n, e.nodeName == "BR") || this.leafFallback(e, n);
1552
- else {
1553
- let e = this.enter(a, t.attrs || null, n, t.preserveWhitespace);
1554
- e && (i = !0, n = e);
1555
- }
1556
- else {
1557
- let e = this.parser.schema.marks[t.mark];
1558
- n = n.concat(e.create(t.attrs));
1559
- }
1560
- let o = this.top;
1561
- if (a && a.isLeaf) this.findInside(e);
1562
- else if (r) this.addElement(e, n, r);
1563
- else if (t.getContent) this.findInside(e), t.getContent(e, this.parser.schema).forEach((e) => this.insertNode(e, n, !1));
1564
- else {
1565
- let r = e;
1566
- typeof t.contentElement == "string" ? r = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? r = t.contentElement(e) : t.contentElement && (r = t.contentElement), this.findAround(e, r, !0), this.addAll(r, n), this.findAround(e, r, !1);
1567
- }
1568
- i && this.sync(o) && this.open--;
1569
- }
1570
- addAll(e, t, n, r) {
1571
- let i = n || 0;
1572
- for (let a = n ? e.childNodes[n] : e.firstChild, o = r == null ? null : e.childNodes[r]; a != o; a = a.nextSibling, ++i) this.findAtPoint(e, i), this.addDOM(a, t);
1573
- this.findAtPoint(e, i);
1574
- }
1575
- findPlace(e, t, n) {
1576
- let r, i;
1577
- for (let t = this.open, a = 0; t >= 0; t--) {
1578
- let o = this.nodes[t], s = o.findWrapping(e);
1579
- if (s && (!r || r.length > s.length + a) && (r = s, i = o, !s.length)) break;
1580
- if (o.solid) {
1581
- if (n) break;
1582
- a += 2;
1583
- }
1584
- }
1585
- if (!r) return null;
1586
- this.sync(i);
1587
- for (let e = 0; e < r.length; e++) t = this.enterInner(r[e], null, t, !1);
1588
- return t;
1589
- }
1590
- insertNode(e, t, n) {
1591
- if (e.isInline && this.needsBlock && !this.top.type) {
1592
- let e = this.textblockFromContext();
1593
- e && (t = this.enterInner(e, null, t));
1594
- }
1595
- let r = this.findPlace(e, t, n);
1596
- if (r) {
1597
- this.closeExtra();
1598
- let t = this.top;
1599
- t.match &&= t.match.matchType(e.type);
1600
- let n = l.none;
1601
- for (let i of r.concat(e.marks)) (t.type ? t.type.allowsMarkType(i.type) : Ke(i.type, e.type)) && (n = i.addToSet(n));
1602
- return t.content.push(e.mark(n)), !0;
1603
- }
1604
- return !1;
1605
- }
1606
- enter(e, t, n, r) {
1607
- let i = this.findPlace(e.create(t), n, !1);
1608
- return i &&= this.enterInner(e, t, n, !0, r), i;
1609
- }
1610
- enterInner(e, t, n, r = !1, i) {
1611
- this.closeExtra();
1612
- let a = this.top;
1613
- a.match = a.match && a.match.matchType(e);
1614
- let o = Ve(e, i, a.options);
1615
- a.options & w && a.content.length == 0 && (o |= w);
1616
- let s = l.none;
1617
- return n = n.filter((t) => !(a.type ? a.type.allowsMarkType(t.type) : Ke(t.type, e)) || (s = t.addToSet(s), !1)), this.nodes.push(new T(e, t, s, r, null, o)), this.open++, n;
1618
- }
1619
- closeExtra(e = !1) {
1620
- let t = this.nodes.length - 1;
1621
- if (t > this.open) {
1622
- for (; t > this.open; t--) this.nodes[t - 1].content.push(this.nodes[t].finish(e));
1623
- this.nodes.length = this.open + 1;
1624
- }
1625
- }
1626
- finish() {
1627
- return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
1628
- }
1629
- sync(e) {
1630
- for (let t = this.open; t >= 0; t--) if (this.nodes[t] == e) return this.open = t, !0;
1631
- else this.localPreserveWS && (this.nodes[t].options |= C);
1632
- return !1;
1633
- }
1634
- get currentPos() {
1635
- this.closeExtra();
1636
- let e = 0;
1637
- for (let t = this.open; t >= 0; t--) {
1638
- let n = this.nodes[t].content;
1639
- for (let t = n.length - 1; t >= 0; t--) e += n[t].nodeSize;
1640
- t && e++;
1641
- }
1642
- return e;
1643
- }
1644
- findAtPoint(e, t) {
1645
- if (this.find) for (let n = 0; n < this.find.length; n++) this.find[n].node == e && this.find[n].offset == t && (this.find[n].pos = this.currentPos);
1646
- }
1647
- findInside(e) {
1648
- if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos);
1649
- }
1650
- findAround(e, t, n) {
1651
- if (e != t && this.find) for (let r = 0; r < this.find.length; r++) this.find[r].pos == null && e.nodeType == 1 && e.contains(this.find[r].node) && t.compareDocumentPosition(this.find[r].node) & (n ? 2 : 4) && (this.find[r].pos = this.currentPos);
1652
- }
1653
- findInText(e) {
1654
- if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset));
1655
- }
1656
- matchesContext(e) {
1657
- if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this);
1658
- let t = e.split("/"), n = this.options.context, r = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), i = -(n ? n.depth + 1 : 0) + +!r, a = (e, o) => {
1659
- for (; e >= 0; e--) {
1660
- let s = t[e];
1661
- if (s == "") {
1662
- if (e == t.length - 1 || e == 0) continue;
1663
- for (; o >= i; o--) if (a(e - 1, o)) return !0;
1664
- return !1;
1665
- }
1666
- {
1667
- let e = o > 0 || o == 0 && r ? this.nodes[o].type : n && o >= i ? n.node(o - i).type : null;
1668
- if (!e || e.name != s && !e.isInGroup(s)) return !1;
1669
- o--;
1670
- }
1671
- }
1672
- return !0;
1673
- };
1674
- return a(t.length - 1, this.open);
1675
- }
1676
- textblockFromContext() {
1677
- let e = this.options.context;
1678
- if (e) for (let t = e.depth; t >= 0; t--) {
1679
- let n = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;
1680
- if (n && n.isTextblock && n.defaultAttrs) return n;
1681
- }
1682
- for (let e in this.parser.schema.nodes) {
1683
- let t = this.parser.schema.nodes[e];
1684
- if (t.isTextblock && t.defaultAttrs) return t;
1685
- }
1686
- }
1687
- };
1688
- function Ue(e) {
1689
- for (let t = e.firstChild, n = null; t; t = t.nextSibling) {
1690
- let e = t.nodeType == 1 ? t.nodeName.toLowerCase() : null;
1691
- e && ze.hasOwnProperty(e) && n ? (n.appendChild(t), t = n) : e == "li" ? n = t : e && (n = null);
1692
- }
1693
- }
1694
- function We(e, t) {
1695
- return (e.matches || e.msMatchesSelector || e.webkitMatchesSelector || e.mozMatchesSelector).call(e, t);
1696
- }
1697
- function Ge(e) {
1698
- let t = {};
1699
- for (let n in e) t[n] = e[n];
1700
- return t;
1701
- }
1702
- function Ke(e, t) {
1703
- let n = t.schema.nodes;
1704
- for (let r in n) {
1705
- let i = n[r];
1706
- if (!i.allowsMarkType(e)) continue;
1707
- let a = [], o = (e) => {
1708
- a.push(e);
1709
- for (let n = 0; n < e.edgeCount; n++) {
1710
- let { type: r, next: i } = e.edge(n);
1711
- if (r == t || a.indexOf(i) < 0 && o(i)) return !0;
1712
- }
1713
- };
1714
- if (o(i.contentMatch)) return !0;
1715
- }
1716
- }
1717
- var qe = class e {
1718
- constructor(e, t) {
1719
- this.nodes = e, this.marks = t;
1720
- }
1721
- serializeFragment(e, t = {}, n) {
1722
- n ||= E(t).createDocumentFragment();
1723
- let r = n, i = [];
1724
- return e.forEach((e) => {
1725
- if (i.length || e.marks.length) {
1726
- let n = 0, a = 0;
1727
- for (; n < i.length && a < e.marks.length;) {
1728
- let t = e.marks[a];
1729
- if (!this.marks[t.type.name]) {
1730
- a++;
1731
- continue;
1732
- }
1733
- if (!t.eq(i[n][0]) || t.type.spec.spanning === !1) break;
1734
- n++, a++;
1735
- }
1736
- for (; n < i.length;) r = i.pop()[1];
1737
- for (; a < e.marks.length;) {
1738
- let n = e.marks[a++], o = this.serializeMark(n, e.isInline, t);
1739
- o && (i.push([n, r]), r.appendChild(o.dom), r = o.contentDOM || o.dom);
1740
- }
1741
- }
1742
- r.appendChild(this.serializeNodeInner(e, t));
1743
- }), n;
1744
- }
1745
- serializeNodeInner(e, t) {
1746
- if (e.isText) return E(t).createTextNode(e.text);
1747
- let { dom: n, contentDOM: r } = D(E(t), this.nodes[e.type.name](e), null, e.attrs);
1748
- if (r) {
1749
- if (e.isLeaf) throw RangeError("Content hole not allowed in a leaf node spec");
1750
- this.serializeFragment(e.content, t, r);
1751
- }
1752
- return n;
1753
- }
1754
- serializeNode(e, t = {}) {
1755
- let n = this.serializeNodeInner(e, t);
1756
- for (let r = e.marks.length - 1; r >= 0; r--) {
1757
- let i = this.serializeMark(e.marks[r], e.isInline, t);
1758
- i && ((i.contentDOM || i.dom).appendChild(n), n = i.dom);
1759
- }
1760
- return n;
1761
- }
1762
- serializeMark(e, t, n = {}) {
1763
- let r = this.marks[e.type.name];
1764
- return r && D(E(n), r(e, t), null, e.attrs);
1765
- }
1766
- static renderSpec(e, t, n = null, r) {
1767
- return typeof t == "string" ? { dom: e.createTextNode(t) } : D(e, t, n, r);
1768
- }
1769
- static fromSchema(t) {
1770
- return t.cached.domSerializer || (t.cached.domSerializer = new e(this.nodesFromSchema(t), this.marksFromSchema(t)));
1771
- }
1772
- static nodesFromSchema(e) {
1773
- let t = Je(e.nodes);
1774
- return t.text ||= (e) => e.text, t;
1775
- }
1776
- static marksFromSchema(e) {
1777
- return Je(e.marks);
1778
- }
1779
- };
1780
- function Je(e) {
1781
- let t = {};
1782
- for (let n in e) {
1783
- let r = e[n].spec.toDOM;
1784
- r && (t[n] = r);
1785
- }
1786
- return t;
1787
- }
1788
- function E(e) {
1789
- return e.document || window.document;
1790
- }
1791
- var Ye = /* @__PURE__ */ new WeakMap();
1792
- function Xe(e) {
1793
- let t = Ye.get(e);
1794
- return t === void 0 && Ye.set(e, t = Ze(e)), t;
1795
- }
1796
- function Ze(e) {
1797
- let t = null;
1798
- function n(e) {
1799
- if (e && typeof e == "object") if (Array.isArray(e)) if (typeof e[0] == "string") t ||= [], t.push(e);
1800
- else for (let t = 0; t < e.length; t++) n(e[t]);
1801
- else for (let t in e) n(e[t]);
1802
- }
1803
- return n(e), t;
1804
- }
1805
- function D(e, t, n, r) {
1806
- if (t.nodeType == 1) return { dom: t };
1807
- if (t.dom && t.dom.nodeType == 1) return t;
1808
- let i = t[0], a;
1809
- if (typeof i != "string") throw RangeError("Invalid array passed to renderSpec");
1810
- if (r && (a = Xe(r)) && a.indexOf(t) > -1) throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
1811
- let o = i.indexOf(" ");
1812
- o > 0 && (n = i.slice(0, o), i = i.slice(o + 1));
1813
- let s, c = n ? e.createElementNS(n, i) : e.createElement(i), l = t[1], u = 1;
1814
- if (l && typeof l == "object" && l.nodeType == null && !Array.isArray(l)) {
1815
- u = 2;
1816
- for (let e in l) if (l[e] != null) {
1817
- let t = e.indexOf(" ");
1818
- t > 0 ? c.setAttributeNS(e.slice(0, t), e.slice(t + 1), l[e]) : e == "style" && c.style ? c.style.cssText = l[e] : c.setAttribute(e, l[e]);
1819
- }
1820
- }
1821
- for (let i = u; i < t.length; i++) {
1822
- let a = t[i];
1823
- if (a === 0) {
1824
- if (i < t.length - 1 || i > u) throw RangeError("Content hole must be the only child of its parent node");
1825
- return {
1826
- dom: c,
1827
- contentDOM: c
1828
- };
1829
- }
1830
- if (typeof a == "string") c.appendChild(e.createTextNode(a));
1831
- else {
1832
- let { dom: t, contentDOM: i } = D(e, a, n, r);
1833
- if (c.appendChild(t), i) {
1834
- if (s) throw RangeError("Multiple content holes");
1835
- s = i;
1836
- }
1837
- }
1838
- }
1839
- return {
1840
- dom: c,
1841
- contentDOM: s
1842
- };
1843
- }
1844
- //#endregion
1845
- //#region node_modules/.pnpm/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.js
1846
- var Qe = 65535, $e = 2 ** 16;
1847
- function et(e, t) {
1848
- return e + t * $e;
1849
- }
1850
- function tt(e) {
1851
- return e & Qe;
1852
- }
1853
- function nt(e) {
1854
- return (e - (e & Qe)) / $e;
1855
- }
1856
- var rt = 1, it = 2, at = 4, ot = 8, O = class {
1857
- constructor(e, t, n) {
1858
- this.pos = e, this.delInfo = t, this.recover = n;
1859
- }
1860
- get deleted() {
1861
- return (this.delInfo & ot) > 0;
1862
- }
1863
- get deletedBefore() {
1864
- return (this.delInfo & 5) > 0;
1865
- }
1866
- get deletedAfter() {
1867
- return (this.delInfo & 6) > 0;
1868
- }
1869
- get deletedAcross() {
1870
- return (this.delInfo & at) > 0;
1871
- }
1872
- }, k = class e {
1873
- constructor(t, n = !1) {
1874
- if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty;
1875
- }
1876
- recover(e) {
1877
- let t = 0, n = tt(e);
1878
- if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1];
1879
- return this.ranges[n * 3] + t + nt(e);
1880
- }
1881
- mapResult(e, t = 1) {
1882
- return this._map(e, t, !1);
1883
- }
1884
- map(e, t = 1) {
1885
- return this._map(e, t, !0);
1886
- }
1887
- _map(e, t, n) {
1888
- let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1889
- for (let o = 0; o < this.ranges.length; o += 3) {
1890
- let s = this.ranges[o] - (this.inverted ? r : 0);
1891
- if (s > e) break;
1892
- let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c;
1893
- if (e <= u) {
1894
- let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l);
1895
- if (n) return a;
1896
- let d = e == (t < 0 ? s : u) ? null : et(o / 3, e - s), f = e == s ? it : e == u ? rt : at;
1897
- return (t < 0 ? e != s : e != u) && (f |= ot), new O(a, f, d);
1898
- }
1899
- r += l - c;
1900
- }
1901
- return n ? e + r : new O(e + r, 0, null);
1902
- }
1903
- touches(e, t) {
1904
- let n = 0, r = tt(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2;
1905
- for (let t = 0; t < this.ranges.length; t += 3) {
1906
- let o = this.ranges[t] - (this.inverted ? n : 0);
1907
- if (o > e) break;
1908
- let s = this.ranges[t + i];
1909
- if (e <= o + s && t == r * 3) return !0;
1910
- n += this.ranges[t + a] - s;
1911
- }
1912
- return !1;
1913
- }
1914
- forEach(e) {
1915
- let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2;
1916
- for (let r = 0, i = 0; r < this.ranges.length; r += 3) {
1917
- let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n];
1918
- e(o, o + c, s, s + l), i += l - c;
1919
- }
1920
- }
1921
- invert() {
1922
- return new e(this.ranges, !this.inverted);
1923
- }
1924
- toString() {
1925
- return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
1926
- }
1927
- static offset(t) {
1928
- return t == 0 ? e.empty : new e(t < 0 ? [
1929
- 0,
1930
- -t,
1931
- 0
1932
- ] : [
1933
- 0,
1934
- 0,
1935
- t
1936
- ]);
1937
- }
1938
- };
1939
- k.empty = new k([]);
1940
- var st = class e {
1941
- constructor(e, t, n = 0, r = e ? e.length : 0) {
1942
- this.mirror = t, this.from = n, this.to = r, this._maps = e || [], this.ownData = !(e || t);
1943
- }
1944
- get maps() {
1945
- return this._maps;
1946
- }
1947
- slice(t = 0, n = this.maps.length) {
1948
- return new e(this._maps, this.mirror, t, n);
1949
- }
1950
- appendMap(e, t) {
1951
- this.ownData ||= (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t);
1952
- }
1953
- appendMapping(e) {
1954
- for (let t = 0, n = this._maps.length; t < e._maps.length; t++) {
1955
- let r = e.getMirror(t);
1956
- this.appendMap(e._maps[t], r != null && r < t ? n + r : void 0);
1957
- }
1958
- }
1959
- getMirror(e) {
1960
- if (this.mirror) {
1961
- for (let t = 0; t < this.mirror.length; t++) if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)];
1962
- }
1963
- }
1964
- setMirror(e, t) {
1965
- this.mirror ||= [], this.mirror.push(e, t);
1966
- }
1967
- appendMappingInverted(e) {
1968
- for (let t = e.maps.length - 1, n = this._maps.length + e._maps.length; t >= 0; t--) {
1969
- let r = e.getMirror(t);
1970
- this.appendMap(e._maps[t].invert(), r != null && r > t ? n - r - 1 : void 0);
1971
- }
1972
- }
1973
- invert() {
1974
- let t = new e();
1975
- return t.appendMappingInverted(this), t;
1976
- }
1977
- map(e, t = 1) {
1978
- if (this.mirror) return this._map(e, t, !0);
1979
- for (let n = this.from; n < this.to; n++) e = this._maps[n].map(e, t);
1980
- return e;
1981
- }
1982
- mapResult(e, t = 1) {
1983
- return this._map(e, t, !1);
1984
- }
1985
- _map(e, t, n) {
1986
- let r = 0;
1987
- for (let n = this.from; n < this.to; n++) {
1988
- let i = this._maps[n].mapResult(e, t);
1989
- if (i.recover != null) {
1990
- let t = this.getMirror(n);
1991
- if (t != null && t > n && t < this.to) {
1992
- n = t, e = this._maps[t].recover(i.recover);
1993
- continue;
1994
- }
1995
- }
1996
- r |= i.delInfo, e = i.pos;
1997
- }
1998
- return n ? e : new O(e, r, null);
1999
- }
2000
- }, A = Object.create(null), j = class {
2001
- getMap() {
2002
- return k.empty;
2003
- }
2004
- merge(e) {
2005
- return null;
2006
- }
2007
- static fromJSON(e, t) {
2008
- if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON");
2009
- let n = A[t.stepType];
2010
- if (!n) throw RangeError(`No step type ${t.stepType} defined`);
2011
- return n.fromJSON(e, t);
2012
- }
2013
- static jsonID(e, t) {
2014
- if (e in A) throw RangeError("Duplicate use of step JSON ID " + e);
2015
- return A[e] = t, t.prototype.jsonID = e, t;
2016
- }
2017
- }, M = class e {
2018
- constructor(e, t) {
2019
- this.doc = e, this.failed = t;
2020
- }
2021
- static ok(t) {
2022
- return new e(t, null);
2023
- }
2024
- static fail(t) {
2025
- return new e(null, t);
2026
- }
2027
- static fromReplace(t, n, r, i) {
2028
- try {
2029
- return e.ok(t.replace(n, r, i));
2030
- } catch (t) {
2031
- if (t instanceof u) return e.fail(t.message);
2032
- throw t;
2033
- }
2034
- }
2035
- };
2036
- function N(e, t, n) {
2037
- let r = [];
2038
- for (let i = 0; i < e.childCount; i++) {
2039
- let a = e.child(i);
2040
- a.content.size && (a = a.copy(N(a.content, t, a))), a.isInline && (a = t(a, n, i)), r.push(a);
2041
- }
2042
- return a.fromArray(r);
2043
- }
2044
- var P = class e extends j {
2045
- constructor(e, t, n) {
2046
- super(), this.from = e, this.to = t, this.mark = n;
2047
- }
2048
- apply(e) {
2049
- let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new d(N(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd);
2050
- return M.fromReplace(e, this.from, this.to, i);
2051
- }
2052
- invert() {
2053
- return new F(this.from, this.to, this.mark);
2054
- }
2055
- map(t) {
2056
- let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
2057
- return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
2058
- }
2059
- merge(t) {
2060
- return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
2061
- }
2062
- toJSON() {
2063
- return {
2064
- stepType: "addMark",
2065
- mark: this.mark.toJSON(),
2066
- from: this.from,
2067
- to: this.to
2068
- };
2069
- }
2070
- static fromJSON(t, n) {
2071
- if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON");
2072
- return new e(n.from, n.to, t.markFromJSON(n.mark));
2073
- }
2074
- };
2075
- j.jsonID("addMark", P);
2076
- var F = class e extends j {
2077
- constructor(e, t, n) {
2078
- super(), this.from = e, this.to = t, this.mark = n;
2079
- }
2080
- apply(e) {
2081
- let t = e.slice(this.from, this.to), n = new d(N(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd);
2082
- return M.fromReplace(e, this.from, this.to, n);
2083
- }
2084
- invert() {
2085
- return new P(this.from, this.to, this.mark);
2086
- }
2087
- map(t) {
2088
- let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1);
2089
- return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark);
2090
- }
2091
- merge(t) {
2092
- return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null;
2093
- }
2094
- toJSON() {
2095
- return {
2096
- stepType: "removeMark",
2097
- mark: this.mark.toJSON(),
2098
- from: this.from,
2099
- to: this.to
2100
- };
2101
- }
2102
- static fromJSON(t, n) {
2103
- if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON");
2104
- return new e(n.from, n.to, t.markFromJSON(n.mark));
2105
- }
2106
- };
2107
- j.jsonID("removeMark", F);
2108
- var I = class e extends j {
2109
- constructor(e, t) {
2110
- super(), this.pos = e, this.mark = t;
2111
- }
2112
- apply(e) {
2113
- let t = e.nodeAt(this.pos);
2114
- if (!t) return M.fail("No node at mark step's position");
2115
- let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
2116
- return M.fromReplace(e, this.pos, this.pos + 1, new d(a.from(n), 0, +!t.isLeaf));
2117
- }
2118
- invert(t) {
2119
- let n = t.nodeAt(this.pos);
2120
- if (n) {
2121
- let t = this.mark.addToSet(n.marks);
2122
- if (t.length == n.marks.length) {
2123
- for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]);
2124
- return new e(this.pos, this.mark);
2125
- }
2126
- }
2127
- return new L(this.pos, this.mark);
2128
- }
2129
- map(t) {
2130
- let n = t.mapResult(this.pos, 1);
2131
- return n.deletedAfter ? null : new e(n.pos, this.mark);
2132
- }
2133
- toJSON() {
2134
- return {
2135
- stepType: "addNodeMark",
2136
- pos: this.pos,
2137
- mark: this.mark.toJSON()
2138
- };
2139
- }
2140
- static fromJSON(t, n) {
2141
- if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");
2142
- return new e(n.pos, t.markFromJSON(n.mark));
2143
- }
2144
- };
2145
- j.jsonID("addNodeMark", I);
2146
- var L = class e extends j {
2147
- constructor(e, t) {
2148
- super(), this.pos = e, this.mark = t;
2149
- }
2150
- apply(e) {
2151
- let t = e.nodeAt(this.pos);
2152
- if (!t) return M.fail("No node at mark step's position");
2153
- let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
2154
- return M.fromReplace(e, this.pos, this.pos + 1, new d(a.from(n), 0, +!t.isLeaf));
2155
- }
2156
- invert(e) {
2157
- let t = e.nodeAt(this.pos);
2158
- return !t || !this.mark.isInSet(t.marks) ? this : new I(this.pos, this.mark);
2159
- }
2160
- map(t) {
2161
- let n = t.mapResult(this.pos, 1);
2162
- return n.deletedAfter ? null : new e(n.pos, this.mark);
2163
- }
2164
- toJSON() {
2165
- return {
2166
- stepType: "removeNodeMark",
2167
- pos: this.pos,
2168
- mark: this.mark.toJSON()
2169
- };
2170
- }
2171
- static fromJSON(t, n) {
2172
- if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
2173
- return new e(n.pos, t.markFromJSON(n.mark));
2174
- }
2175
- };
2176
- j.jsonID("removeNodeMark", L);
2177
- var R = class e extends j {
2178
- constructor(e, t, n, r = !1) {
2179
- super(), this.from = e, this.to = t, this.slice = n, this.structure = r;
2180
- }
2181
- apply(e) {
2182
- return this.structure && B(e, this.from, this.to) ? M.fail("Structure replace would overwrite content") : M.fromReplace(e, this.from, this.to, this.slice);
2183
- }
2184
- getMap() {
2185
- return new k([
2186
- this.from,
2187
- this.to - this.from,
2188
- this.slice.size
2189
- ]);
2190
- }
2191
- invert(t) {
2192
- return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to));
2193
- }
2194
- map(t) {
2195
- let n = t.mapResult(this.to, -1), r = this.from == this.to && e.MAP_BIAS < 0 ? n : t.mapResult(this.from, 1);
2196
- return r.deletedAcross && n.deletedAcross ? null : new e(r.pos, Math.max(r.pos, n.pos), this.slice, this.structure);
2197
- }
2198
- merge(t) {
2199
- if (!(t instanceof e) || t.structure || this.structure) return null;
2200
- if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) {
2201
- let n = this.slice.size + t.slice.size == 0 ? d.empty : new d(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd);
2202
- return new e(this.from, this.to + (t.to - t.from), n, this.structure);
2203
- }
2204
- if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) {
2205
- let n = this.slice.size + t.slice.size == 0 ? d.empty : new d(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd);
2206
- return new e(t.from, this.to, n, this.structure);
2207
- }
2208
- return null;
2209
- }
2210
- toJSON() {
2211
- let e = {
2212
- stepType: "replace",
2213
- from: this.from,
2214
- to: this.to
2215
- };
2216
- return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
2217
- }
2218
- static fromJSON(t, n) {
2219
- if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON");
2220
- return new e(n.from, n.to, d.fromJSON(t, n.slice), !!n.structure);
2221
- }
2222
- };
2223
- R.MAP_BIAS = 1, j.jsonID("replace", R);
2224
- var z = class e extends j {
2225
- constructor(e, t, n, r, i, a, o = !1) {
2226
- super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o;
2227
- }
2228
- apply(e) {
2229
- if (this.structure && (B(e, this.from, this.gapFrom) || B(e, this.gapTo, this.to))) return M.fail("Structure gap-replace would overwrite content");
2230
- let t = e.slice(this.gapFrom, this.gapTo);
2231
- if (t.openStart || t.openEnd) return M.fail("Gap is not a flat range");
2232
- let n = this.slice.insertAt(this.insert, t.content);
2233
- return n ? M.fromReplace(e, this.from, this.to, n) : M.fail("Content does not fit in gap");
2234
- }
2235
- getMap() {
2236
- return new k([
2237
- this.from,
2238
- this.gapFrom - this.from,
2239
- this.insert,
2240
- this.gapTo,
2241
- this.to - this.gapTo,
2242
- this.slice.size - this.insert
2243
- ]);
2244
- }
2245
- invert(t) {
2246
- let n = this.gapTo - this.gapFrom;
2247
- return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
2248
- }
2249
- map(t) {
2250
- let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1);
2251
- return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure);
2252
- }
2253
- toJSON() {
2254
- let e = {
2255
- stepType: "replaceAround",
2256
- from: this.from,
2257
- to: this.to,
2258
- gapFrom: this.gapFrom,
2259
- gapTo: this.gapTo,
2260
- insert: this.insert
2261
- };
2262
- return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
2263
- }
2264
- static fromJSON(t, n) {
2265
- if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");
2266
- return new e(n.from, n.to, n.gapFrom, n.gapTo, d.fromJSON(t, n.slice), n.insert, !!n.structure);
2267
- }
2268
- };
2269
- j.jsonID("replaceAround", z);
2270
- function B(e, t, n) {
2271
- let r = e.resolve(t), i = n - t, a = r.depth;
2272
- for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--;
2273
- if (i > 0) {
2274
- let e = r.node(a).maybeChild(r.indexAfter(a));
2275
- for (; i > 0;) {
2276
- if (!e || e.isLeaf) return !0;
2277
- e = e.firstChild, i--;
2278
- }
2279
- }
2280
- return !1;
2281
- }
2282
- function ct(e, t, n, r) {
2283
- let i = [], a = [], o, s;
2284
- e.doc.nodesBetween(t, n, (e, c, l) => {
2285
- if (!e.isInline) return;
2286
- let u = e.marks;
2287
- if (!r.isInSet(u) && l.type.allowsMarkType(r.type)) {
2288
- let l = Math.max(c, t), d = Math.min(c + e.nodeSize, n), f = r.addToSet(u);
2289
- for (let e = 0; e < u.length; e++) u[e].isInSet(f) || (o && o.to == l && o.mark.eq(u[e]) ? o.to = d : i.push(o = new F(l, d, u[e])));
2290
- s && s.to == l ? s.to = d : a.push(s = new P(l, d, r));
2291
- }
2292
- }), i.forEach((t) => e.step(t)), a.forEach((t) => e.step(t));
2293
- }
2294
- function lt(e, t, n, r) {
2295
- let i = [], a = 0;
2296
- e.doc.nodesBetween(t, n, (e, o) => {
2297
- if (!e.isInline) return;
2298
- a++;
2299
- let s = null;
2300
- if (r instanceof je) {
2301
- let t = e.marks, n;
2302
- for (; n = r.isInSet(t);) (s ||= []).push(n), t = n.removeFromSet(t);
2303
- } else r ? r.isInSet(e.marks) && (s = [r]) : s = e.marks;
2304
- if (s && s.length) {
2305
- let r = Math.min(o + e.nodeSize, n);
2306
- for (let e = 0; e < s.length; e++) {
2307
- let n = s[e], c;
2308
- for (let e = 0; e < i.length; e++) {
2309
- let t = i[e];
2310
- t.step == a - 1 && n.eq(i[e].style) && (c = t);
2311
- }
2312
- c ? (c.to = r, c.step = a) : i.push({
2313
- style: n,
2314
- from: Math.max(o, t),
2315
- to: r,
2316
- step: a
2317
- });
2318
- }
2319
- }
2320
- }), i.forEach((t) => e.step(new F(t.from, t.to, t.style)));
2321
- }
2322
- function V(e, t, n, r = n.contentMatch, i = !0) {
2323
- let o = e.doc.nodeAt(t), s = [], c = t + 1;
2324
- for (let t = 0; t < o.childCount; t++) {
2325
- let l = o.child(t), u = c + l.nodeSize, f = r.matchType(l.type);
2326
- if (!f) s.push(new R(c, u, d.empty));
2327
- else {
2328
- r = f;
2329
- for (let t = 0; t < l.marks.length; t++) n.allowsMarkType(l.marks[t].type) || e.step(new F(c, u, l.marks[t]));
2330
- if (i && l.isText && n.whitespace != "pre") {
2331
- let e, t = /\r?\n|\r/g, r;
2332
- for (; e = t.exec(l.text);) r ||= new d(a.from(n.schema.text(" ", n.allowedMarks(l.marks))), 0, 0), s.push(new R(c + e.index, c + e.index + e[0].length, r));
2333
- }
2334
- }
2335
- c = u;
2336
- }
2337
- if (!r.validEnd) {
2338
- let t = r.fillBefore(a.empty, !0);
2339
- e.replace(c, c, new d(t, 0, 0));
2340
- }
2341
- for (let t = s.length - 1; t >= 0; t--) e.step(s[t]);
2342
- }
2343
- function ut(e, t, n) {
2344
- return (t == 0 || e.canReplace(t, e.childCount)) && (n == e.childCount || e.canReplace(0, n));
2345
- }
2346
- function dt(e) {
2347
- let t = e.parent.content.cutByIndex(e.startIndex, e.endIndex);
2348
- for (let n = e.depth, r = 0, i = 0;; --n) {
2349
- let a = e.$from.node(n), o = e.$from.index(n) + r, s = e.$to.indexAfter(n) - i;
2350
- if (n < e.depth && a.canReplace(o, s, t)) return n;
2351
- if (n == 0 || a.type.spec.isolating || !ut(a, o, s)) break;
2352
- o && (r = 1), s < a.childCount && (i = 1);
2353
- }
2354
- return null;
2355
- }
2356
- function ft(e, t, n) {
2357
- let { $from: r, $to: i, depth: o } = t, s = r.before(o + 1), c = i.after(o + 1), l = s, u = c, f = a.empty, p = 0;
2358
- for (let e = o, t = !1; e > n; e--) t || r.index(e) > 0 ? (t = !0, f = a.from(r.node(e).copy(f)), p++) : l--;
2359
- let m = a.empty, h = 0;
2360
- for (let e = o, t = !1; e > n; e--) t || i.after(e + 1) < i.end(e) ? (t = !0, m = a.from(i.node(e).copy(m)), h++) : u++;
2361
- e.step(new z(l, u, s, c, new d(f.append(m), p, h), f.size - p, !0));
2362
- }
2363
- function pt(e, t, n = null, r = e) {
2364
- let i = ht(e, t), a = i && gt(r, t);
2365
- return a ? i.map(mt).concat({
2366
- type: t,
2367
- attrs: n
2368
- }).concat(a.map(mt)) : null;
2369
- }
2370
- function mt(e) {
2371
- return {
2372
- type: e,
2373
- attrs: null
2374
- };
2375
- }
2376
- function ht(e, t) {
2377
- let { parent: n, startIndex: r, endIndex: i } = e, a = n.contentMatchAt(r).findWrapping(t);
2378
- if (!a) return null;
2379
- let o = a.length ? a[0] : t;
2380
- return n.canReplaceWith(r, i, o) ? a : null;
2381
- }
2382
- function gt(e, t) {
2383
- let { parent: n, startIndex: r, endIndex: i } = e, a = n.child(r), o = t.contentMatch.findWrapping(a.type);
2384
- if (!o) return null;
2385
- let s = (o.length ? o[o.length - 1] : t).contentMatch;
2386
- for (let e = r; s && e < i; e++) s = s.matchType(n.child(e).type);
2387
- return !s || !s.validEnd ? null : o;
2388
- }
2389
- function _t(e, t, n) {
2390
- let r = a.empty;
2391
- for (let e = n.length - 1; e >= 0; e--) {
2392
- if (r.size) {
2393
- let t = n[e].type.contentMatch.matchFragment(r);
2394
- if (!t || !t.validEnd) throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
2395
- }
2396
- r = a.from(n[e].type.create(n[e].attrs, r));
2397
- }
2398
- let i = t.start, o = t.end;
2399
- e.step(new z(i, o, i, o, new d(r, 0, 0), n.length, !0));
2400
- }
2401
- function vt(e, t, n, r, i) {
2402
- if (!r.isTextblock) throw RangeError("Type given to setBlockType should be a textblock");
2403
- let o = e.steps.length;
2404
- e.doc.nodesBetween(t, n, (t, n) => {
2405
- let s = typeof i == "function" ? i(t) : i;
2406
- if (t.isTextblock && !t.hasMarkup(r, s) && xt(e.doc, e.mapping.slice(o).map(n), r)) {
2407
- let i = null;
2408
- if (r.schema.linebreakReplacement) {
2409
- let e = r.whitespace == "pre", t = !!r.contentMatch.matchType(r.schema.linebreakReplacement);
2410
- e && !t ? i = !1 : !e && t && (i = !0);
2411
- }
2412
- i === !1 && bt(e, t, n, o), V(e, e.mapping.slice(o).map(n, 1), r, void 0, i === null);
2413
- let c = e.mapping.slice(o), l = c.map(n, 1), u = c.map(n + t.nodeSize, 1);
2414
- return e.step(new z(l, u, l + 1, u - 1, new d(a.from(r.create(s, null, t.marks)), 0, 0), 1, !0)), i === !0 && yt(e, t, n, o), !1;
2415
- }
2416
- });
2417
- }
2418
- function yt(e, t, n, r) {
2419
- t.forEach((i, a) => {
2420
- if (i.isText) {
2421
- let o, s = /\r?\n|\r/g;
2422
- for (; o = s.exec(i.text);) {
2423
- let i = e.mapping.slice(r).map(n + 1 + a + o.index);
2424
- e.replaceWith(i, i + 1, t.type.schema.linebreakReplacement.create());
2425
- }
2426
- }
2427
- });
2428
- }
2429
- function bt(e, t, n, r) {
2430
- t.forEach((i, a) => {
2431
- if (i.type == i.type.schema.linebreakReplacement) {
2432
- let i = e.mapping.slice(r).map(n + 1 + a);
2433
- e.replaceWith(i, i + 1, t.type.schema.text("\n"));
2434
- }
2435
- });
2436
- }
2437
- function xt(e, t, n) {
2438
- let r = e.resolve(t), i = r.index();
2439
- return r.parent.canReplaceWith(i, i + 1, n);
2440
- }
2441
- function St(e, t, n, r, i) {
2442
- let o = e.doc.nodeAt(t);
2443
- if (!o) throw RangeError("No node at given position");
2444
- n ||= o.type;
2445
- let s = n.create(r, null, i || o.marks);
2446
- if (o.isLeaf) return e.replaceWith(t, t + o.nodeSize, s);
2447
- if (!n.validContent(o.content)) throw RangeError("Invalid content for node type " + n.name);
2448
- e.step(new z(t, t + o.nodeSize, t + 1, t + o.nodeSize - 1, new d(a.from(s), 0, 0), 1, !0));
2449
- }
2450
- function Ct(e, t, n = 1, r) {
2451
- let i = e.resolve(t), a = i.depth - n, o = r && r[r.length - 1] || i.parent;
2452
- if (a < 0 || i.parent.type.spec.isolating || !i.parent.canReplace(i.index(), i.parent.childCount) || !o.type.validContent(i.parent.content.cutByIndex(i.index(), i.parent.childCount))) return !1;
2453
- for (let e = i.depth - 1, t = n - 2; e > a; e--, t--) {
2454
- let n = i.node(e), a = i.index(e);
2455
- if (n.type.spec.isolating) return !1;
2456
- let o = n.content.cutByIndex(a, n.childCount), s = r && r[t + 1];
2457
- s && (o = o.replaceChild(0, s.type.create(s.attrs)));
2458
- let c = r && r[t] || n;
2459
- if (!n.canReplace(a + 1, n.childCount) || !c.type.validContent(o)) return !1;
2460
- }
2461
- let s = i.indexAfter(a), c = r && r[0];
2462
- return i.node(a).canReplaceWith(s, s, c ? c.type : i.node(a + 1).type);
2463
- }
2464
- function wt(e, t, n = 1, r) {
2465
- let i = e.doc.resolve(t), o = a.empty, s = a.empty;
2466
- for (let e = i.depth, t = i.depth - n, c = n - 1; e > t; e--, c--) {
2467
- o = a.from(i.node(e).copy(o));
2468
- let t = r && r[c];
2469
- s = a.from(t ? t.type.create(t.attrs, s) : i.node(e).copy(s));
2470
- }
2471
- e.step(new R(t, t, new d(o.append(s), n, n), !0));
2472
- }
2473
- function Tt(e, t) {
2474
- let n = e.resolve(t), r = n.index();
2475
- return Dt(n.nodeBefore, n.nodeAfter) && n.parent.canReplace(r, r + 1);
2476
- }
2477
- function Et(e, t) {
2478
- t.content.size || e.type.compatibleContent(t.type);
2479
- let n = e.contentMatchAt(e.childCount), { linebreakReplacement: r } = e.type.schema;
2480
- for (let i = 0; i < t.childCount; i++) {
2481
- let a = t.child(i), o = a.type == r ? e.type.schema.nodes.text : a.type;
2482
- if (n = n.matchType(o), !n || !e.type.allowsMarks(a.marks)) return !1;
2483
- }
2484
- return n.validEnd;
2485
- }
2486
- function Dt(e, t) {
2487
- return !!(e && t && !e.isLeaf && Et(e, t));
2488
- }
2489
- function Ot(e, t, n = -1) {
2490
- let r = e.resolve(t);
2491
- for (let e = r.depth;; e--) {
2492
- let i, a, o = r.index(e);
2493
- if (e == r.depth ? (i = r.nodeBefore, a = r.nodeAfter) : n > 0 ? (i = r.node(e + 1), o++, a = r.node(e).maybeChild(o)) : (i = r.node(e).maybeChild(o - 1), a = r.node(e + 1)), i && !i.isTextblock && Dt(i, a) && r.node(e).canReplace(o, o + 1)) return t;
2494
- if (e == 0) break;
2495
- t = n < 0 ? r.before(e) : r.after(e);
2496
- }
2497
- }
2498
- function kt(e, t, n) {
2499
- let r = null, { linebreakReplacement: i } = e.doc.type.schema, a = e.doc.resolve(t - n), o = a.node().type;
2500
- if (i && o.inlineContent) {
2501
- let e = o.whitespace == "pre", t = !!o.contentMatch.matchType(i);
2502
- e && !t ? r = !1 : !e && t && (r = !0);
2503
- }
2504
- let s = e.steps.length;
2505
- if (r === !1) {
2506
- let r = e.doc.resolve(t + n);
2507
- bt(e, r.node(), r.before(), s);
2508
- }
2509
- o.inlineContent && V(e, t + n - 1, o, a.node().contentMatchAt(a.index()), r == null);
2510
- let c = e.mapping.slice(s), l = c.map(t - n);
2511
- if (e.step(new R(l, c.map(t + n, -1), d.empty, !0)), r === !0) {
2512
- let t = e.doc.resolve(l);
2513
- yt(e, t.node(), t.before(), e.steps.length);
2514
- }
2515
- return e;
2516
- }
2517
- function At(e, t, n) {
2518
- let r = e.resolve(t);
2519
- if (r.parent.canReplaceWith(r.index(), r.index(), n)) return t;
2520
- if (r.parentOffset == 0) for (let e = r.depth - 1; e >= 0; e--) {
2521
- let t = r.index(e);
2522
- if (r.node(e).canReplaceWith(t, t, n)) return r.before(e + 1);
2523
- if (t > 0) return null;
2524
- }
2525
- if (r.parentOffset == r.parent.content.size) for (let e = r.depth - 1; e >= 0; e--) {
2526
- let t = r.indexAfter(e);
2527
- if (r.node(e).canReplaceWith(t, t, n)) return r.after(e + 1);
2528
- if (t < r.node(e).childCount) return null;
2529
- }
2530
- return null;
2531
- }
2532
- function jt(e, t, n) {
2533
- let r = e.resolve(t);
2534
- if (!n.content.size) return t;
2535
- let i = n.content;
2536
- for (let e = 0; e < n.openStart; e++) i = i.firstChild.content;
2537
- for (let e = 1; e <= (n.openStart == 0 && n.size ? 2 : 1); e++) for (let t = r.depth; t >= 0; t--) {
2538
- let n = t == r.depth ? 0 : r.pos <= (r.start(t + 1) + r.end(t + 1)) / 2 ? -1 : 1, a = r.index(t) + +(n > 0), o = r.node(t), s = !1;
2539
- if (e == 1) s = o.canReplace(a, a, i);
2540
- else {
2541
- let e = o.contentMatchAt(a).findWrapping(i.firstChild.type);
2542
- s = e && o.canReplaceWith(a, a, e[0]);
2543
- }
2544
- if (s) return n == 0 ? r.pos : n < 0 ? r.before(t + 1) : r.after(t + 1);
2545
- }
2546
- return null;
2547
- }
2548
- function Mt(e, t, n = t, r = d.empty) {
2549
- if (t == n && !r.size) return null;
2550
- let i = e.resolve(t), a = e.resolve(n);
2551
- return Nt(i, a, r) ? new R(t, n, r) : new Pt(i, a, r).fit();
2552
- }
2553
- function Nt(e, t, n) {
2554
- return !n.openStart && !n.openEnd && e.start() == t.start() && e.parent.canReplace(e.index(), t.index(), n.content);
2555
- }
2556
- var Pt = class {
2557
- constructor(e, t, n) {
2558
- this.$from = e, this.$to = t, this.unplaced = n, this.frontier = [], this.placed = a.empty;
2559
- for (let t = 0; t <= e.depth; t++) {
2560
- let n = e.node(t);
2561
- this.frontier.push({
2562
- type: n.type,
2563
- match: n.contentMatchAt(e.indexAfter(t))
2564
- });
2565
- }
2566
- for (let t = e.depth; t > 0; t--) this.placed = a.from(e.node(t).copy(this.placed));
2567
- }
2568
- get depth() {
2569
- return this.frontier.length - 1;
2570
- }
2571
- fit() {
2572
- for (; this.unplaced.size;) {
2573
- let e = this.findFittable();
2574
- e ? this.placeNodes(e) : this.openMore() || this.dropNode();
2575
- }
2576
- let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, n = this.$from, r = this.close(e < 0 ? this.$to : n.doc.resolve(e));
2577
- if (!r) return null;
2578
- let i = this.placed, a = n.depth, o = r.depth;
2579
- for (; a && o && i.childCount == 1;) i = i.firstChild.content, a--, o--;
2580
- let s = new d(i, a, o);
2581
- return e > -1 ? new z(n.pos, e, this.$to.pos, this.$to.end(), s, t) : s.size || n.pos != this.$to.pos ? new R(n.pos, r.pos, s) : null;
2582
- }
2583
- findFittable() {
2584
- let e = this.unplaced.openStart;
2585
- for (let t = this.unplaced.content, n = 0, r = this.unplaced.openEnd; n < e; n++) {
2586
- let i = t.firstChild;
2587
- if (t.childCount > 1 && (r = 0), i.type.spec.isolating && r <= n) {
2588
- e = n;
2589
- break;
2590
- }
2591
- t = i.content;
2592
- }
2593
- for (let t = 1; t <= 2; t++) for (let n = t == 1 ? e : this.unplaced.openStart; n >= 0; n--) {
2594
- let e, r = null;
2595
- n ? (r = W(this.unplaced.content, n - 1).firstChild, e = r.content) : e = this.unplaced.content;
2596
- let i = e.firstChild;
2597
- for (let e = this.depth; e >= 0; e--) {
2598
- let { type: o, match: s } = this.frontier[e], c, l = null;
2599
- if (t == 1 && (i ? s.matchType(i.type) || (l = s.fillBefore(a.from(i), !1)) : r && o.compatibleContent(r.type))) return {
2600
- sliceDepth: n,
2601
- frontierDepth: e,
2602
- parent: r,
2603
- inject: l
2604
- };
2605
- if (t == 2 && i && (c = s.findWrapping(i.type))) return {
2606
- sliceDepth: n,
2607
- frontierDepth: e,
2608
- parent: r,
2609
- wrap: c
2610
- };
2611
- if (r && s.matchType(r.type)) break;
2612
- }
2613
- }
2614
- }
2615
- openMore() {
2616
- let { content: e, openStart: t, openEnd: n } = this.unplaced, r = W(e, t);
2617
- return !r.childCount || r.firstChild.isLeaf ? !1 : (this.unplaced = new d(e, t + 1, Math.max(n, r.size + t >= e.size - n ? t + 1 : 0)), !0);
2618
- }
2619
- dropNode() {
2620
- let { content: e, openStart: t, openEnd: n } = this.unplaced, r = W(e, t);
2621
- if (r.childCount <= 1 && t > 0) {
2622
- let i = e.size - t <= t + r.size;
2623
- this.unplaced = new d(H(e, t - 1, 1), t - 1, i ? t - 1 : n);
2624
- } else this.unplaced = new d(H(e, t, 1), t, n);
2625
- }
2626
- placeNodes({ sliceDepth: e, frontierDepth: t, parent: n, inject: r, wrap: i }) {
2627
- for (; this.depth > t;) this.closeFrontierNode();
2628
- if (i) for (let e = 0; e < i.length; e++) this.openFrontierNode(i[e]);
2629
- let o = this.unplaced, s = n ? n.content : o.content, c = o.openStart - e, l = 0, u = [], { match: f, type: p } = this.frontier[t];
2630
- if (r) {
2631
- for (let e = 0; e < r.childCount; e++) u.push(r.child(e));
2632
- f = f.matchFragment(r);
2633
- }
2634
- let m = s.size + e - (o.content.size - o.openEnd);
2635
- for (; l < s.childCount;) {
2636
- let e = s.child(l), t = f.matchType(e.type);
2637
- if (!t) break;
2638
- l++, (l > 1 || c == 0 || e.content.size) && (f = t, u.push(Ft(e.mark(p.allowedMarks(e.marks)), l == 1 ? c : 0, l == s.childCount ? m : -1)));
2639
- }
2640
- let h = l == s.childCount;
2641
- h || (m = -1), this.placed = U(this.placed, t, a.from(u)), this.frontier[t].match = f, h && m < 0 && n && n.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
2642
- for (let e = 0, t = s; e < m; e++) {
2643
- let e = t.lastChild;
2644
- this.frontier.push({
2645
- type: e.type,
2646
- match: e.contentMatchAt(e.childCount)
2647
- }), t = e.content;
2648
- }
2649
- this.unplaced = h ? e == 0 ? d.empty : new d(H(o.content, e - 1, 1), e - 1, m < 0 ? o.openEnd : e - 1) : new d(H(o.content, e, l), o.openStart, o.openEnd);
2650
- }
2651
- mustMoveInline() {
2652
- if (!this.$to.parent.isTextblock) return -1;
2653
- let e = this.frontier[this.depth], t;
2654
- if (!e.type.isTextblock || !G(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) return -1;
2655
- let { depth: n } = this.$to, r = this.$to.after(n);
2656
- for (; n > 1 && r == this.$to.end(--n);) ++r;
2657
- return r;
2658
- }
2659
- findCloseLevel(e) {
2660
- scan: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) {
2661
- let { match: n, type: r } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), a = G(e, t, r, n, i);
2662
- if (a) {
2663
- for (let n = t - 1; n >= 0; n--) {
2664
- let { match: t, type: r } = this.frontier[n], i = G(e, n, r, t, !0);
2665
- if (!i || i.childCount) continue scan;
2666
- }
2667
- return {
2668
- depth: t,
2669
- fit: a,
2670
- move: i ? e.doc.resolve(e.after(t + 1)) : e
2671
- };
2672
- }
2673
- }
2674
- }
2675
- close(e) {
2676
- let t = this.findCloseLevel(e);
2677
- if (!t) return null;
2678
- for (; this.depth > t.depth;) this.closeFrontierNode();
2679
- t.fit.childCount && (this.placed = U(this.placed, t.depth, t.fit)), e = t.move;
2680
- for (let n = t.depth + 1; n <= e.depth; n++) {
2681
- let t = e.node(n), r = t.type.contentMatch.fillBefore(t.content, !0, e.index(n));
2682
- this.openFrontierNode(t.type, t.attrs, r);
2683
- }
2684
- return e;
2685
- }
2686
- openFrontierNode(e, t = null, n) {
2687
- let r = this.frontier[this.depth];
2688
- r.match = r.match.matchType(e), this.placed = U(this.placed, this.depth, a.from(e.create(t, n))), this.frontier.push({
2689
- type: e,
2690
- match: e.contentMatch
2691
- });
2692
- }
2693
- closeFrontierNode() {
2694
- let e = this.frontier.pop().match.fillBefore(a.empty, !0);
2695
- e.childCount && (this.placed = U(this.placed, this.frontier.length, e));
2696
- }
2697
- };
2698
- function H(e, t, n) {
2699
- return t == 0 ? e.cutByIndex(n, e.childCount) : e.replaceChild(0, e.firstChild.copy(H(e.firstChild.content, t - 1, n)));
2700
- }
2701
- function U(e, t, n) {
2702
- return t == 0 ? e.append(n) : e.replaceChild(e.childCount - 1, e.lastChild.copy(U(e.lastChild.content, t - 1, n)));
2703
- }
2704
- function W(e, t) {
2705
- for (let n = 0; n < t; n++) e = e.firstChild.content;
2706
- return e;
2707
- }
2708
- function Ft(e, t, n) {
2709
- if (t <= 0) return e;
2710
- let r = e.content;
2711
- return t > 1 && (r = r.replaceChild(0, Ft(r.firstChild, t - 1, r.childCount == 1 ? n - 1 : 0))), t > 0 && (r = e.type.contentMatch.fillBefore(r).append(r), n <= 0 && (r = r.append(e.type.contentMatch.matchFragment(r).fillBefore(a.empty, !0)))), e.copy(r);
2712
- }
2713
- function G(e, t, n, r, i) {
2714
- let a = e.node(t), o = i ? e.indexAfter(t) : e.index(t);
2715
- if (o == a.childCount && !n.compatibleContent(a.type)) return null;
2716
- let s = r.fillBefore(a.content, !0, o);
2717
- return s && !It(n, a.content, o) ? s : null;
2718
- }
2719
- function It(e, t, n) {
2720
- for (let r = n; r < t.childCount; r++) if (!e.allowsMarks(t.child(r).marks)) return !0;
2721
- return !1;
2722
- }
2723
- function Lt(e) {
2724
- return e.spec.defining || e.spec.definingForContent;
2725
- }
2726
- function Rt(e, t, n, r) {
2727
- if (!r.size) return e.deleteRange(t, n);
2728
- let i = e.doc.resolve(t), a = e.doc.resolve(n);
2729
- if (Nt(i, a, r)) return e.step(new R(t, n, r));
2730
- let o = Ht(i, a);
2731
- o[o.length - 1] == 0 && o.pop();
2732
- let s = -(i.depth + 1);
2733
- o.unshift(s);
2734
- for (let e = i.depth, t = i.pos - 1; e > 0; e--, t--) {
2735
- let n = i.node(e).type.spec;
2736
- if (n.defining || n.definingAsContext || n.isolating) break;
2737
- o.indexOf(e) > -1 ? s = e : i.before(e) == t && o.splice(1, 0, -e);
2738
- }
2739
- let c = o.indexOf(s), l = [], u = r.openStart;
2740
- for (let e = r.content, t = 0;; t++) {
2741
- let n = e.firstChild;
2742
- if (l.push(n), t == r.openStart) break;
2743
- e = n.content;
2744
- }
2745
- for (let e = u - 1; e >= 0; e--) {
2746
- let t = l[e], n = Lt(t.type);
2747
- if (n && !t.sameMarkup(i.node(Math.abs(s) - 1))) u = e;
2748
- else if (n || !t.type.isTextblock) break;
2749
- }
2750
- for (let t = r.openStart; t >= 0; t--) {
2751
- let s = (t + u + 1) % (r.openStart + 1), f = l[s];
2752
- if (f) for (let t = 0; t < o.length; t++) {
2753
- let l = o[(t + c) % o.length], u = !0;
2754
- l < 0 && (u = !1, l = -l);
2755
- let p = i.node(l - 1), m = i.index(l - 1);
2756
- if (p.canReplaceWith(m, m, f.type, f.marks)) return e.replace(i.before(l), u ? a.after(l) : n, new d(zt(r.content, 0, r.openStart, s), s, r.openEnd));
2757
- }
2758
- }
2759
- let f = e.steps.length;
2760
- for (let s = o.length - 1; s >= 0 && (e.replace(t, n, r), !(e.steps.length > f)); s--) {
2761
- let e = o[s];
2762
- e < 0 || (t = i.before(e), n = a.after(e));
2763
- }
2764
- }
2765
- function zt(e, t, n, r, i) {
2766
- if (t < n) {
2767
- let i = e.firstChild;
2768
- e = e.replaceChild(0, i.copy(zt(i.content, t + 1, n, r, i)));
2769
- }
2770
- if (t > r) {
2771
- let t = i.contentMatchAt(0), n = t.fillBefore(e).append(e);
2772
- e = n.append(t.matchFragment(n).fillBefore(a.empty, !0));
2773
- }
2774
- return e;
2775
- }
2776
- function Bt(e, t, n, r) {
2777
- if (!r.isInline && t == n && e.doc.resolve(t).parent.content.size) {
2778
- let i = At(e.doc, t, r.type);
2779
- i != null && (t = n = i);
2780
- }
2781
- e.replaceRange(t, n, new d(a.from(r), 0, 0));
2782
- }
2783
- function Vt(e, t, n) {
2784
- let r = e.doc.resolve(t), i = e.doc.resolve(n);
2785
- if (r.parent.isTextblock && i.parent.isTextblock && r.start() != i.start() && r.parentOffset == 0 && i.parentOffset == 0) {
2786
- let a = r.sharedDepth(n), o = !1;
2787
- for (let e = r.depth; e > a; e--) r.node(e).type.spec.isolating && (o = !0);
2788
- for (let e = i.depth; e > a; e--) i.node(e).type.spec.isolating && (o = !0);
2789
- if (!o) {
2790
- for (let e = r.depth; e > 0 && t == r.start(e); e--) t = r.before(e);
2791
- for (let e = i.depth; e > 0 && n == i.start(e); e--) n = i.before(e);
2792
- r = e.doc.resolve(t), i = e.doc.resolve(n);
2793
- }
2794
- }
2795
- let a = Ht(r, i);
2796
- for (let t = 0; t < a.length; t++) {
2797
- let n = a[t], o = t == a.length - 1;
2798
- if (o && n == 0 || r.node(n).type.contentMatch.validEnd) return e.delete(r.start(n), i.end(n));
2799
- if (n > 0 && (o || r.node(n - 1).canReplace(r.index(n - 1), i.indexAfter(n - 1)))) return e.delete(r.before(n), i.after(n));
2800
- }
2801
- for (let a = 1; a <= r.depth && a <= i.depth; a++) if (t - r.start(a) == r.depth - a && n > r.end(a) && i.end(a) - n != i.depth - a && r.start(a - 1) == i.start(a - 1) && r.node(a - 1).canReplace(r.index(a - 1), i.index(a - 1))) return e.delete(r.before(a), n);
2802
- e.delete(t, n);
2803
- }
2804
- function Ht(e, t) {
2805
- let n = [], r = Math.min(e.depth, t.depth);
2806
- for (let i = r; i >= 0; i--) {
2807
- let r = e.start(i);
2808
- if (r < e.pos - (e.depth - i) || t.end(i) > t.pos + (t.depth - i) || e.node(i).type.spec.isolating || t.node(i).type.spec.isolating) break;
2809
- (r == t.start(i) || i == e.depth && i == t.depth && e.parent.inlineContent && t.parent.inlineContent && i && t.start(i - 1) == r - 1) && n.push(i);
2810
- }
2811
- return n;
2812
- }
2813
- var Ut = class e extends j {
2814
- constructor(e, t, n) {
2815
- super(), this.pos = e, this.attr = t, this.value = n;
2816
- }
2817
- apply(e) {
2818
- let t = e.nodeAt(this.pos);
2819
- if (!t) return M.fail("No node at attribute step's position");
2820
- let n = Object.create(null);
2821
- for (let e in t.attrs) n[e] = t.attrs[e];
2822
- n[this.attr] = this.value;
2823
- let r = t.type.create(n, null, t.marks);
2824
- return M.fromReplace(e, this.pos, this.pos + 1, new d(a.from(r), 0, +!t.isLeaf));
2825
- }
2826
- getMap() {
2827
- return k.empty;
2828
- }
2829
- invert(t) {
2830
- return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]);
2831
- }
2832
- map(t) {
2833
- let n = t.mapResult(this.pos, 1);
2834
- return n.deletedAfter ? null : new e(n.pos, this.attr, this.value);
2835
- }
2836
- toJSON() {
2837
- return {
2838
- stepType: "attr",
2839
- pos: this.pos,
2840
- attr: this.attr,
2841
- value: this.value
2842
- };
2843
- }
2844
- static fromJSON(t, n) {
2845
- if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON");
2846
- return new e(n.pos, n.attr, n.value);
2847
- }
2848
- };
2849
- j.jsonID("attr", Ut);
2850
- var Wt = class e extends j {
2851
- constructor(e, t) {
2852
- super(), this.attr = e, this.value = t;
2853
- }
2854
- apply(e) {
2855
- let t = Object.create(null);
2856
- for (let n in e.attrs) t[n] = e.attrs[n];
2857
- t[this.attr] = this.value;
2858
- let n = e.type.create(t, e.content, e.marks);
2859
- return M.ok(n);
2860
- }
2861
- getMap() {
2862
- return k.empty;
2863
- }
2864
- invert(t) {
2865
- return new e(this.attr, t.attrs[this.attr]);
2866
- }
2867
- map(e) {
2868
- return this;
2869
- }
2870
- toJSON() {
2871
- return {
2872
- stepType: "docAttr",
2873
- attr: this.attr,
2874
- value: this.value
2875
- };
2876
- }
2877
- static fromJSON(t, n) {
2878
- if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON");
2879
- return new e(n.attr, n.value);
2880
- }
2881
- };
2882
- j.jsonID("docAttr", Wt);
2883
- var K = class extends Error {};
2884
- K = function e(t) {
2885
- let n = Error.call(this, t);
2886
- return n.__proto__ = e.prototype, n;
2887
- }, K.prototype = Object.create(Error.prototype), K.prototype.constructor = K, K.prototype.name = "TransformError";
2888
- var Gt = class {
2889
- constructor(e) {
2890
- this.doc = e, this.steps = [], this.docs = [], this.mapping = new st();
2891
- }
2892
- get before() {
2893
- return this.docs.length ? this.docs[0] : this.doc;
2894
- }
2895
- step(e) {
2896
- let t = this.maybeStep(e);
2897
- if (t.failed) throw new K(t.failed);
2898
- return this;
2899
- }
2900
- maybeStep(e) {
2901
- let t = e.apply(this.doc);
2902
- return t.failed || this.addStep(e, t.doc), t;
2903
- }
2904
- get docChanged() {
2905
- return this.steps.length > 0;
2906
- }
2907
- changedRange() {
2908
- let e = 1e9, t = -1e9;
2909
- for (let n = 0; n < this.mapping.maps.length; n++) {
2910
- let r = this.mapping.maps[n];
2911
- n && (e = r.map(e, 1), t = r.map(t, -1)), r.forEach((n, r, i, a) => {
2912
- e = Math.min(e, i), t = Math.max(t, a);
2913
- });
2914
- }
2915
- return e == 1e9 ? null : {
2916
- from: e,
2917
- to: t
2918
- };
2919
- }
2920
- addStep(e, t) {
2921
- this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t;
2922
- }
2923
- replace(e, t = e, n = d.empty) {
2924
- let r = Mt(this.doc, e, t, n);
2925
- return r && this.step(r), this;
2926
- }
2927
- replaceWith(e, t, n) {
2928
- return this.replace(e, t, new d(a.from(n), 0, 0));
2929
- }
2930
- delete(e, t) {
2931
- return this.replace(e, t, d.empty);
2932
- }
2933
- insert(e, t) {
2934
- return this.replaceWith(e, e, t);
2935
- }
2936
- replaceRange(e, t, n) {
2937
- return Rt(this, e, t, n), this;
2938
- }
2939
- replaceRangeWith(e, t, n) {
2940
- return Bt(this, e, t, n), this;
2941
- }
2942
- deleteRange(e, t) {
2943
- return Vt(this, e, t), this;
2944
- }
2945
- lift(e, t) {
2946
- return ft(this, e, t), this;
2947
- }
2948
- join(e, t = 1) {
2949
- return kt(this, e, t), this;
2950
- }
2951
- wrap(e, t) {
2952
- return _t(this, e, t), this;
2953
- }
2954
- setBlockType(e, t = e, n, r = null) {
2955
- return vt(this, e, t, n, r), this;
2956
- }
2957
- setNodeMarkup(e, t, n = null, r) {
2958
- return St(this, e, t, n, r), this;
2959
- }
2960
- setNodeAttribute(e, t, n) {
2961
- return this.step(new Ut(e, t, n)), this;
2962
- }
2963
- setDocAttribute(e, t) {
2964
- return this.step(new Wt(e, t)), this;
2965
- }
2966
- addNodeMark(e, t) {
2967
- return this.step(new I(e, t)), this;
2968
- }
2969
- removeNodeMark(e, t) {
2970
- let n = this.doc.nodeAt(e);
2971
- if (!n) throw RangeError("No node at position " + e);
2972
- if (t instanceof l) t.isInSet(n.marks) && this.step(new L(e, t));
2973
- else {
2974
- let r = n.marks, i, a = [];
2975
- for (; i = t.isInSet(r);) a.push(new L(e, i)), r = i.removeFromSet(r);
2976
- for (let e = a.length - 1; e >= 0; e--) this.step(a[e]);
2977
- }
2978
- return this;
2979
- }
2980
- split(e, t = 1, n) {
2981
- return wt(this, e, t, n), this;
2982
- }
2983
- addMark(e, t, n) {
2984
- return ct(this, e, t, n), this;
2985
- }
2986
- removeMark(e, t, n) {
2987
- return lt(this, e, t, n), this;
2988
- }
2989
- clearIncompatible(e, t, n) {
2990
- return V(this, e, t, n), this;
2991
- }
2992
- }, Kt = Object.create(null), q = class {
2993
- constructor(e, t, n) {
2994
- this.$anchor = e, this.$head = t, this.ranges = n || [new qt(e.min(t), e.max(t))];
2995
- }
2996
- get anchor() {
2997
- return this.$anchor.pos;
2998
- }
2999
- get head() {
3000
- return this.$head.pos;
3001
- }
3002
- get from() {
3003
- return this.$from.pos;
3004
- }
3005
- get to() {
3006
- return this.$to.pos;
3007
- }
3008
- get $from() {
3009
- return this.ranges[0].$from;
3010
- }
3011
- get $to() {
3012
- return this.ranges[0].$to;
3013
- }
3014
- get empty() {
3015
- let e = this.ranges;
3016
- for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1;
3017
- return !0;
3018
- }
3019
- content() {
3020
- return this.$from.doc.slice(this.from, this.to, !0);
3021
- }
3022
- replace(e, t = d.empty) {
3023
- let n = t.content.lastChild, r = null;
3024
- for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild;
3025
- let i = e.steps.length, a = this.ranges;
3026
- for (let o = 0; o < a.length; o++) {
3027
- let { $from: s, $to: c } = a[o], l = e.mapping.slice(i);
3028
- e.replaceRange(l.map(s.pos), l.map(c.pos), o ? d.empty : t), o == 0 && $t(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1);
3029
- }
3030
- }
3031
- replaceWith(e, t) {
3032
- let n = e.steps.length, r = this.ranges;
3033
- for (let i = 0; i < r.length; i++) {
3034
- let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos);
3035
- i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), $t(e, n, t.isInline ? -1 : 1));
3036
- }
3037
- }
3038
- static findFrom(e, t, n = !1) {
3039
- let r = e.parent.inlineContent ? new J(e) : Z(e.node(0), e.parent, e.pos, e.index(), t, n);
3040
- if (r) return r;
3041
- for (let r = e.depth - 1; r >= 0; r--) {
3042
- let i = t < 0 ? Z(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : Z(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n);
3043
- if (i) return i;
3044
- }
3045
- return null;
3046
- }
3047
- static near(e, t = 1) {
3048
- return this.findFrom(e, t) || this.findFrom(e, -t) || new X(e.node(0));
3049
- }
3050
- static atStart(e) {
3051
- return Z(e, e, 0, 0, 1) || new X(e);
3052
- }
3053
- static atEnd(e) {
3054
- return Z(e, e, e.content.size, e.childCount, -1) || new X(e);
3055
- }
3056
- static fromJSON(e, t) {
3057
- if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON");
3058
- let n = Kt[t.type];
3059
- if (!n) throw RangeError(`No selection type ${t.type} defined`);
3060
- return n.fromJSON(e, t);
3061
- }
3062
- static jsonID(e, t) {
3063
- if (e in Kt) throw RangeError("Duplicate use of selection JSON ID " + e);
3064
- return Kt[e] = t, t.prototype.jsonID = e, t;
3065
- }
3066
- getBookmark() {
3067
- return J.between(this.$anchor, this.$head).getBookmark();
3068
- }
3069
- };
3070
- q.prototype.visible = !0;
3071
- var qt = class {
3072
- constructor(e, t) {
3073
- this.$from = e, this.$to = t;
3074
- }
3075
- }, Jt = !1;
3076
- function Yt(e) {
3077
- !Jt && !e.parent.inlineContent && (Jt = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")"));
3078
- }
3079
- var J = class e extends q {
3080
- constructor(e, t = e) {
3081
- Yt(e), Yt(t), super(e, t);
3082
- }
3083
- get $cursor() {
3084
- return this.$anchor.pos == this.$head.pos ? this.$head : null;
3085
- }
3086
- map(t, n) {
3087
- let r = t.resolve(n.map(this.head));
3088
- if (!r.parent.inlineContent) return q.near(r);
3089
- let i = t.resolve(n.map(this.anchor));
3090
- return new e(i.parent.inlineContent ? i : r, r);
3091
- }
3092
- replace(e, t = d.empty) {
3093
- if (super.replace(e, t), t == d.empty) {
3094
- let t = this.$from.marksAcross(this.$to);
3095
- t && e.ensureMarks(t);
3096
- }
3097
- }
3098
- eq(t) {
3099
- return t instanceof e && t.anchor == this.anchor && t.head == this.head;
3100
- }
3101
- getBookmark() {
3102
- return new Xt(this.anchor, this.head);
3103
- }
3104
- toJSON() {
3105
- return {
3106
- type: "text",
3107
- anchor: this.anchor,
3108
- head: this.head
3109
- };
3110
- }
3111
- static fromJSON(t, n) {
3112
- if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON");
3113
- return new e(t.resolve(n.anchor), t.resolve(n.head));
3114
- }
3115
- static create(e, t, n = t) {
3116
- let r = e.resolve(t);
3117
- return new this(r, n == t ? r : e.resolve(n));
3118
- }
3119
- static between(t, n, r) {
3120
- let i = t.pos - n.pos;
3121
- if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) {
3122
- let e = q.findFrom(n, r, !0) || q.findFrom(n, -r, !0);
3123
- if (e) n = e.$head;
3124
- else return q.near(n, r);
3125
- }
3126
- return t.parent.inlineContent || (i == 0 ? t = n : (t = (q.findFrom(t, -r, !0) || q.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n);
3127
- }
3128
- };
3129
- q.jsonID("text", J);
3130
- var Xt = class e {
3131
- constructor(e, t) {
3132
- this.anchor = e, this.head = t;
3133
- }
3134
- map(t) {
3135
- return new e(t.map(this.anchor), t.map(this.head));
3136
- }
3137
- resolve(e) {
3138
- return J.between(e.resolve(this.anchor), e.resolve(this.head));
3139
- }
3140
- }, Y = class e extends q {
3141
- constructor(e) {
3142
- let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
3143
- super(e, n), this.node = t;
3144
- }
3145
- map(t, n) {
3146
- let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i);
3147
- return r ? q.near(a) : new e(a);
3148
- }
3149
- content() {
3150
- return new d(a.from(this.node), 0, 0);
3151
- }
3152
- eq(t) {
3153
- return t instanceof e && t.anchor == this.anchor;
3154
- }
3155
- toJSON() {
3156
- return {
3157
- type: "node",
3158
- anchor: this.anchor
3159
- };
3160
- }
3161
- getBookmark() {
3162
- return new Zt(this.anchor);
3163
- }
3164
- static fromJSON(t, n) {
3165
- if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON");
3166
- return new e(t.resolve(n.anchor));
3167
- }
3168
- static create(t, n) {
3169
- return new e(t.resolve(n));
3170
- }
3171
- static isSelectable(e) {
3172
- return !e.isText && e.type.spec.selectable !== !1;
3173
- }
3174
- };
3175
- Y.prototype.visible = !1, q.jsonID("node", Y);
3176
- var Zt = class e {
3177
- constructor(e) {
3178
- this.anchor = e;
3179
- }
3180
- map(t) {
3181
- let { deleted: n, pos: r } = t.mapResult(this.anchor);
3182
- return n ? new Xt(r, r) : new e(r);
3183
- }
3184
- resolve(e) {
3185
- let t = e.resolve(this.anchor), n = t.nodeAfter;
3186
- return n && Y.isSelectable(n) ? new Y(t) : q.near(t);
3187
- }
3188
- }, X = class e extends q {
3189
- constructor(e) {
3190
- super(e.resolve(0), e.resolve(e.content.size));
3191
- }
3192
- replace(e, t = d.empty) {
3193
- if (t == d.empty) {
3194
- e.delete(0, e.doc.content.size);
3195
- let t = q.atStart(e.doc);
3196
- t.eq(e.selection) || e.setSelection(t);
3197
- } else super.replace(e, t);
3198
- }
3199
- toJSON() {
3200
- return { type: "all" };
3201
- }
3202
- static fromJSON(t) {
3203
- return new e(t);
3204
- }
3205
- map(t) {
3206
- return new e(t);
3207
- }
3208
- eq(t) {
3209
- return t instanceof e;
3210
- }
3211
- getBookmark() {
3212
- return Qt;
3213
- }
3214
- };
3215
- q.jsonID("all", X);
3216
- var Qt = {
3217
- map() {
3218
- return this;
3219
- },
3220
- resolve(e) {
3221
- return new X(e);
3222
- }
3223
- };
3224
- function Z(e, t, n, r, i, a = !1) {
3225
- if (t.inlineContent) return J.create(e, n);
3226
- for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) {
3227
- let r = t.child(o);
3228
- if (!r.isAtom) {
3229
- let t = Z(e, r, n + i, i < 0 ? r.childCount : 0, i, a);
3230
- if (t) return t;
3231
- } else if (!a && Y.isSelectable(r)) return Y.create(e, n - (i < 0 ? r.nodeSize : 0));
3232
- n += r.nodeSize * i;
3233
- }
3234
- return null;
3235
- }
3236
- function $t(e, t, n) {
3237
- let r = e.steps.length - 1;
3238
- if (r < t) return;
3239
- let i = e.steps[r];
3240
- if (!(i instanceof R || i instanceof z)) return;
3241
- let a = e.mapping.maps[r], o;
3242
- a.forEach((e, t, n, r) => {
3243
- o ??= r;
3244
- }), e.setSelection(q.near(e.doc.resolve(o), n));
3245
- }
3246
- var en = 1, tn = 2, nn = 4, rn = class extends Gt {
3247
- constructor(e) {
3248
- super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks;
3249
- }
3250
- get selection() {
3251
- return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection;
3252
- }
3253
- setSelection(e) {
3254
- if (e.$from.doc != this.doc) throw RangeError("Selection passed to setSelection must point at the current document");
3255
- return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | en) & -3, this.storedMarks = null, this;
3256
- }
3257
- get selectionSet() {
3258
- return (this.updated & en) > 0;
3259
- }
3260
- setStoredMarks(e) {
3261
- return this.storedMarks = e, this.updated |= tn, this;
3262
- }
3263
- ensureMarks(e) {
3264
- return l.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this;
3265
- }
3266
- addStoredMark(e) {
3267
- return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks()));
3268
- }
3269
- removeStoredMark(e) {
3270
- return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks()));
3271
- }
3272
- get storedMarksSet() {
3273
- return (this.updated & tn) > 0;
3274
- }
3275
- addStep(e, t) {
3276
- super.addStep(e, t), this.updated &= -3, this.storedMarks = null;
3277
- }
3278
- setTime(e) {
3279
- return this.time = e, this;
3280
- }
3281
- replaceSelection(e) {
3282
- return this.selection.replace(this, e), this;
3283
- }
3284
- replaceSelectionWith(e, t = !0) {
3285
- let n = this.selection;
3286
- return t && (e = e.mark(this.storedMarks || (n.empty ? n.$from.marks() : n.$from.marksAcross(n.$to) || l.none))), n.replaceWith(this, e), this;
3287
- }
3288
- deleteSelection() {
3289
- return this.selection.replace(this), this;
3290
- }
3291
- insertText(e, t, n) {
3292
- let r = this.doc.type.schema;
3293
- if (t == null) return e ? this.replaceSelectionWith(r.text(e), !0) : this.deleteSelection();
3294
- {
3295
- if (n ??= t, !e) return this.deleteRange(t, n);
3296
- let i = this.storedMarks;
3297
- if (!i) {
3298
- let e = this.doc.resolve(t);
3299
- i = n == t ? e.marks() : e.marksAcross(this.doc.resolve(n));
3300
- }
3301
- return this.replaceRangeWith(t, n, r.text(e, i)), !this.selection.empty && this.selection.to == t + e.length && this.setSelection(q.near(this.selection.$to)), this;
3302
- }
3303
- }
3304
- setMeta(e, t) {
3305
- return this.meta[typeof e == "string" ? e : e.key] = t, this;
3306
- }
3307
- getMeta(e) {
3308
- return this.meta[typeof e == "string" ? e : e.key];
3309
- }
3310
- get isGeneric() {
3311
- for (let e in this.meta) return !1;
3312
- return !0;
3313
- }
3314
- scrollIntoView() {
3315
- return this.updated |= nn, this;
3316
- }
3317
- get scrolledIntoView() {
3318
- return (this.updated & nn) > 0;
3319
- }
3320
- };
3321
- function an(e, t) {
3322
- return !t || !e ? e : e.bind(t);
3323
- }
3324
- var Q = class {
3325
- constructor(e, t, n) {
3326
- this.name = e, this.init = an(t.init, n), this.apply = an(t.apply, n);
3327
- }
3328
- }, on = [
3329
- new Q("doc", {
3330
- init(e) {
3331
- return e.doc || e.schema.topNodeType.createAndFill();
3332
- },
3333
- apply(e) {
3334
- return e.doc;
3335
- }
3336
- }),
3337
- new Q("selection", {
3338
- init(e, t) {
3339
- return e.selection || q.atStart(t.doc);
3340
- },
3341
- apply(e) {
3342
- return e.selection;
3343
- }
3344
- }),
3345
- new Q("storedMarks", {
3346
- init(e) {
3347
- return e.storedMarks || null;
3348
- },
3349
- apply(e, t, n, r) {
3350
- return r.selection.$cursor ? e.storedMarks : null;
3351
- }
3352
- }),
3353
- new Q("scrollToSelection", {
3354
- init() {
3355
- return 0;
3356
- },
3357
- apply(e, t) {
3358
- return e.scrolledIntoView ? t + 1 : t;
3359
- }
3360
- })
3361
- ], sn = class {
3362
- constructor(e, t) {
3363
- this.schema = e, this.plugins = [], this.pluginsByKey = Object.create(null), this.fields = on.slice(), t && t.forEach((e) => {
3364
- if (this.pluginsByKey[e.key]) throw RangeError("Adding different instances of a keyed plugin (" + e.key + ")");
3365
- this.plugins.push(e), this.pluginsByKey[e.key] = e, e.spec.state && this.fields.push(new Q(e.key, e.spec.state, e));
3366
- });
3367
- }
3368
- }, cn = class e {
3369
- constructor(e) {
3370
- this.config = e;
3371
- }
3372
- get schema() {
3373
- return this.config.schema;
3374
- }
3375
- get plugins() {
3376
- return this.config.plugins;
3377
- }
3378
- apply(e) {
3379
- return this.applyTransaction(e).state;
3380
- }
3381
- filterTransaction(e, t = -1) {
3382
- for (let n = 0; n < this.config.plugins.length; n++) if (n != t) {
3383
- let t = this.config.plugins[n];
3384
- if (t.spec.filterTransaction && !t.spec.filterTransaction.call(t, e, this)) return !1;
3385
- }
3386
- return !0;
3387
- }
3388
- applyTransaction(e) {
3389
- if (!this.filterTransaction(e)) return {
3390
- state: this,
3391
- transactions: []
3392
- };
3393
- let t = [e], n = this.applyInner(e), r = null;
3394
- for (;;) {
3395
- let i = !1;
3396
- for (let a = 0; a < this.config.plugins.length; a++) {
3397
- let o = this.config.plugins[a];
3398
- if (o.spec.appendTransaction) {
3399
- let s = r ? r[a].n : 0, c = r ? r[a].state : this, l = s < t.length && o.spec.appendTransaction.call(o, s ? t.slice(s) : t, c, n);
3400
- if (l && n.filterTransaction(l, a)) {
3401
- if (l.setMeta("appendedTransaction", e), !r) {
3402
- r = [];
3403
- for (let e = 0; e < this.config.plugins.length; e++) r.push(e < a ? {
3404
- state: n,
3405
- n: t.length
3406
- } : {
3407
- state: this,
3408
- n: 0
3409
- });
3410
- }
3411
- t.push(l), n = n.applyInner(l), i = !0;
3412
- }
3413
- r && (r[a] = {
3414
- state: n,
3415
- n: t.length
3416
- });
3417
- }
3418
- }
3419
- if (!i) return {
3420
- state: n,
3421
- transactions: t
3422
- };
3423
- }
3424
- }
3425
- applyInner(t) {
3426
- if (!t.before.eq(this.doc)) throw RangeError("Applying a mismatched transaction");
3427
- let n = new e(this.config), r = this.config.fields;
3428
- for (let e = 0; e < r.length; e++) {
3429
- let i = r[e];
3430
- n[i.name] = i.apply(t, this[i.name], this, n);
3431
- }
3432
- return n;
3433
- }
3434
- get tr() {
3435
- return new rn(this);
3436
- }
3437
- static create(t) {
3438
- let n = new sn(t.doc ? t.doc.type.schema : t.schema, t.plugins), r = new e(n);
3439
- for (let e = 0; e < n.fields.length; e++) r[n.fields[e].name] = n.fields[e].init(t, r);
3440
- return r;
3441
- }
3442
- reconfigure(t) {
3443
- let n = new sn(this.schema, t.plugins), r = n.fields, i = new e(n);
3444
- for (let e = 0; e < r.length; e++) {
3445
- let n = r[e].name;
3446
- i[n] = this.hasOwnProperty(n) ? this[n] : r[e].init(t, i);
3447
- }
3448
- return i;
3449
- }
3450
- toJSON(e) {
3451
- let t = {
3452
- doc: this.doc.toJSON(),
3453
- selection: this.selection.toJSON()
3454
- };
3455
- if (this.storedMarks && (t.storedMarks = this.storedMarks.map((e) => e.toJSON())), e && typeof e == "object") for (let n in e) {
3456
- if (n == "doc" || n == "selection") throw RangeError("The JSON fields `doc` and `selection` are reserved");
3457
- let r = e[n], i = r.spec.state;
3458
- i && i.toJSON && (t[n] = i.toJSON.call(r, this[r.key]));
3459
- }
3460
- return t;
3461
- }
3462
- static fromJSON(t, n, r) {
3463
- if (!n) throw RangeError("Invalid input for EditorState.fromJSON");
3464
- if (!t.schema) throw RangeError("Required config field 'schema' missing");
3465
- let i = new sn(t.schema, t.plugins), a = new e(i);
3466
- return i.fields.forEach((e) => {
3467
- if (e.name == "doc") a.doc = x.fromJSON(t.schema, n.doc);
3468
- else if (e.name == "selection") a.selection = q.fromJSON(a.doc, n.selection);
3469
- else if (e.name == "storedMarks") n.storedMarks && (a.storedMarks = n.storedMarks.map(t.schema.markFromJSON));
3470
- else {
3471
- if (r) for (let i in r) {
3472
- let o = r[i], s = o.spec.state;
3473
- if (o.key == e.name && s && s.fromJSON && Object.prototype.hasOwnProperty.call(n, i)) {
3474
- a[e.name] = s.fromJSON.call(o, t, n[i], a);
3475
- return;
3476
- }
3477
- }
3478
- a[e.name] = e.init(t, a);
3479
- }
3480
- }), a;
3481
- }
3482
- };
3483
- function ln(e, t, n) {
3484
- for (let r in e) {
3485
- let i = e[r];
3486
- i instanceof Function ? i = i.bind(t) : r == "handleDOMEvents" && (i = ln(i, t, {})), n[r] = i;
3487
- }
3488
- return n;
3489
- }
3490
- var un = class {
3491
- constructor(e) {
3492
- this.spec = e, this.props = {}, e.props && ln(e.props, this, this.props), this.key = e.key ? e.key.key : dn("plugin");
3493
- }
3494
- getState(e) {
3495
- return e[this.key];
3496
- }
3497
- }, $ = Object.create(null);
3498
- function dn(e) {
3499
- return e in $ ? e + "$" + ++$[e] : ($[e] = 0, e + "$");
3500
- }
3501
- var fn = class {
3502
- constructor(e = "key") {
3503
- this.key = dn(e);
3504
- }
3505
- get(e) {
3506
- return e.config.pluginsByKey[this.key];
3507
- }
3508
- getState(e) {
3509
- return e[this.key];
3510
- }
3511
- };
3512
- //#endregion
3513
- export { a as C, Me as D, se as E, d as O, qe as S, x as T, pt as _, fn as a, Mt as b, J as c, z as d, R as f, jt as g, Ct as h, un as i, st as l, Tt as m, cn as n, q as o, Gt as p, Y as r, qt as s, X as t, F as u, Ot as v, l as w, Ie as x, dt as y };