@clevertask/scribe 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +1,2070 @@
1
- import { E as x, a as H, P, j as ie, b as F, D as B, N as v, m as y, w as E, M as R, k as A, c as C, S as O, t as V, T as I, l as oe, n as ae, o as W, F as G, p as Q, q as le, r as ue, s as de, u as pe, v as ee } from "../../../index-CzwFCNeI.js";
2
- import { SlashCommand as ce } from "./slashCommand/index.js";
3
- import { getSuggestionItems as he } from "./slashCommand/items.js";
4
- import fe from "./slashCommand/renderItems.js";
5
- import me from "./extension-selectedText.js";
6
- import ge from "./extension-link.js";
7
- const ye = x.create({
8
- name: "placeholder",
1
+ import ct from "./extension-link.js";
2
+ import { E as J, a as B, P as D, D as F, b as X, N as k, m as v, n as qe, S, k as Xe, j as dt, T as x, F as R, l as N, o as ue, p as ut, q as Ge, r as Je, s as pt, w as G, M as ee, t as K, c as j, u as be, v as ht, x as ft, y as mt, z as gt } from "../../../index-CUP7vhu5.js";
3
+ import { SlashCommand as bt } from "./slashCommand/index.js";
4
+ import wt from "./extension-selectedText.js";
5
+ import yt from "./slashCommand/renderItems.js";
6
+ import { getSuggestionItems as Ct } from "./slashCommand/items.js";
7
+ const Mt = J.create({
8
+ name: "focus",
9
+ addOptions() {
10
+ return {
11
+ className: "has-focus",
12
+ mode: "all"
13
+ };
14
+ },
15
+ addProseMirrorPlugins() {
16
+ return [
17
+ new B({
18
+ key: new D("focus"),
19
+ props: {
20
+ decorations: ({ doc: t, selection: e }) => {
21
+ const { isEditable: n, isFocused: o } = this.editor, { anchor: r } = e, s = [];
22
+ if (!n || !o)
23
+ return F.create(t, []);
24
+ let i = 0;
25
+ this.options.mode === "deepest" && t.descendants((a, c) => {
26
+ if (a.isText)
27
+ return;
28
+ if (!(r >= c && r <= c + a.nodeSize - 1))
29
+ return !1;
30
+ i += 1;
31
+ });
32
+ let l = 0;
33
+ return t.descendants((a, c) => {
34
+ if (a.isText || !(r >= c && r <= c + a.nodeSize - 1))
35
+ return !1;
36
+ if (l += 1, this.options.mode === "deepest" && i - l > 0 || this.options.mode === "shallowest" && l > 1)
37
+ return this.options.mode === "deepest";
38
+ s.push(X.node(c, c + a.nodeSize, {
39
+ class: this.options.className
40
+ }));
41
+ }), F.create(t, s);
42
+ }
43
+ }
44
+ })
45
+ ];
46
+ }
47
+ }), vt = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, At = k.create({
48
+ name: "image",
49
+ addOptions() {
50
+ return {
51
+ inline: !1,
52
+ allowBase64: !1,
53
+ HTMLAttributes: {}
54
+ };
55
+ },
56
+ inline() {
57
+ return this.options.inline;
58
+ },
59
+ group() {
60
+ return this.options.inline ? "inline" : "block";
61
+ },
62
+ draggable: !0,
63
+ addAttributes() {
64
+ return {
65
+ src: {
66
+ default: null
67
+ },
68
+ alt: {
69
+ default: null
70
+ },
71
+ title: {
72
+ default: null
73
+ }
74
+ };
75
+ },
76
+ parseHTML() {
77
+ return [
78
+ {
79
+ tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
80
+ }
81
+ ];
82
+ },
83
+ renderHTML({ HTMLAttributes: t }) {
84
+ return ["img", v(this.options.HTMLAttributes, t)];
85
+ },
86
+ addCommands() {
87
+ return {
88
+ setImage: (t) => ({ commands: e }) => e.insertContent({
89
+ type: this.name,
90
+ attrs: t
91
+ })
92
+ };
93
+ },
94
+ addInputRules() {
95
+ return [
96
+ qe({
97
+ find: vt,
98
+ type: this.type,
99
+ getAttributes: (t) => {
100
+ const [, , e, n, o] = t;
101
+ return { src: n, alt: e, title: o };
102
+ }
103
+ })
104
+ ];
105
+ }
106
+ });
107
+ var we, ye;
108
+ if (typeof WeakMap < "u") {
109
+ let t = /* @__PURE__ */ new WeakMap();
110
+ we = (e) => t.get(e), ye = (e, n) => (t.set(e, n), n);
111
+ } else {
112
+ const t = [];
113
+ let n = 0;
114
+ we = (o) => {
115
+ for (let r = 0; r < t.length; r += 2)
116
+ if (t[r] == o)
117
+ return t[r + 1];
118
+ }, ye = (o, r) => (n == 10 && (n = 0), t[n++] = o, t[n++] = r);
119
+ }
120
+ var M = class {
121
+ constructor(t, e, n, o) {
122
+ this.width = t, this.height = e, this.map = n, this.problems = o;
123
+ }
124
+ // Find the dimensions of the cell at the given position.
125
+ findCell(t) {
126
+ for (let e = 0; e < this.map.length; e++) {
127
+ const n = this.map[e];
128
+ if (n != t)
129
+ continue;
130
+ const o = e % this.width, r = e / this.width | 0;
131
+ let s = o + 1, i = r + 1;
132
+ for (let l = 1; s < this.width && this.map[e + l] == n; l++)
133
+ s++;
134
+ for (let l = 1; i < this.height && this.map[e + this.width * l] == n; l++)
135
+ i++;
136
+ return { left: o, top: r, right: s, bottom: i };
137
+ }
138
+ throw new RangeError(`No cell with offset ${t} found`);
139
+ }
140
+ // Find the left side of the cell at the given position.
141
+ colCount(t) {
142
+ for (let e = 0; e < this.map.length; e++)
143
+ if (this.map[e] == t)
144
+ return e % this.width;
145
+ throw new RangeError(`No cell with offset ${t} found`);
146
+ }
147
+ // Find the next cell in the given direction, starting from the cell
148
+ // at `pos`, if any.
149
+ nextCell(t, e, n) {
150
+ const { left: o, right: r, top: s, bottom: i } = this.findCell(t);
151
+ return e == "horiz" ? (n < 0 ? o == 0 : r == this.width) ? null : this.map[s * this.width + (n < 0 ? o - 1 : r)] : (n < 0 ? s == 0 : i == this.height) ? null : this.map[o + this.width * (n < 0 ? s - 1 : i)];
152
+ }
153
+ // Get the rectangle spanning the two given cells.
154
+ rectBetween(t, e) {
155
+ const {
156
+ left: n,
157
+ right: o,
158
+ top: r,
159
+ bottom: s
160
+ } = this.findCell(t), {
161
+ left: i,
162
+ right: l,
163
+ top: a,
164
+ bottom: c
165
+ } = this.findCell(e);
166
+ return {
167
+ left: Math.min(n, i),
168
+ top: Math.min(r, a),
169
+ right: Math.max(o, l),
170
+ bottom: Math.max(s, c)
171
+ };
172
+ }
173
+ // Return the position of all cells that have the top left corner in
174
+ // the given rectangle.
175
+ cellsInRect(t) {
176
+ const e = [], n = {};
177
+ for (let o = t.top; o < t.bottom; o++)
178
+ for (let r = t.left; r < t.right; r++) {
179
+ const s = o * this.width + r, i = this.map[s];
180
+ n[i] || (n[i] = !0, !(r == t.left && r && this.map[s - 1] == i || o == t.top && o && this.map[s - this.width] == i) && e.push(i));
181
+ }
182
+ return e;
183
+ }
184
+ // Return the position at which the cell at the given row and column
185
+ // starts, or would start, if a cell started there.
186
+ positionAt(t, e, n) {
187
+ for (let o = 0, r = 0; ; o++) {
188
+ const s = r + n.child(o).nodeSize;
189
+ if (o == t) {
190
+ let i = e + t * this.width;
191
+ const l = (t + 1) * this.width;
192
+ for (; i < l && this.map[i] < r; )
193
+ i++;
194
+ return i == l ? s - 1 : this.map[i];
195
+ }
196
+ r = s;
197
+ }
198
+ }
199
+ // Find the table map for the given table node.
200
+ static get(t) {
201
+ return we(t) || ye(t, kt(t));
202
+ }
203
+ };
204
+ function kt(t) {
205
+ if (t.type.spec.tableRole != "table")
206
+ throw new RangeError("Not a table node: " + t.type.name);
207
+ const e = Tt(t), n = t.childCount, o = [];
208
+ let r = 0, s = null;
209
+ const i = [];
210
+ for (let c = 0, d = e * n; c < d; c++)
211
+ o[c] = 0;
212
+ for (let c = 0, d = 0; c < n; c++) {
213
+ const u = t.child(c);
214
+ d++;
215
+ for (let f = 0; ; f++) {
216
+ for (; r < o.length && o[r] != 0; )
217
+ r++;
218
+ if (f == u.childCount)
219
+ break;
220
+ const m = u.child(f), { colspan: g, rowspan: w, colwidth: b } = m.attrs;
221
+ for (let P = 0; P < w; P++) {
222
+ if (P + c >= n) {
223
+ (s || (s = [])).push({
224
+ type: "overlong_rowspan",
225
+ pos: d,
226
+ n: w - P
227
+ });
228
+ break;
229
+ }
230
+ const Y = r + P * e;
231
+ for (let W = 0; W < g; W++) {
232
+ o[Y + W] == 0 ? o[Y + W] = d : (s || (s = [])).push({
233
+ type: "collision",
234
+ row: c,
235
+ pos: d,
236
+ n: g - W
237
+ });
238
+ const te = b && b[W];
239
+ if (te) {
240
+ const Z = (Y + W) % e * 2, he = i[Z];
241
+ he == null || he != te && i[Z + 1] == 1 ? (i[Z] = te, i[Z + 1] = 1) : he == te && i[Z + 1]++;
242
+ }
243
+ }
244
+ }
245
+ r += g, d += m.nodeSize;
246
+ }
247
+ const p = (c + 1) * e;
248
+ let h = 0;
249
+ for (; r < p; )
250
+ o[r++] == 0 && h++;
251
+ h && (s || (s = [])).push({ type: "missing", row: c, n: h }), d++;
252
+ }
253
+ const l = new M(e, n, o, s);
254
+ let a = !1;
255
+ for (let c = 0; !a && c < i.length; c += 2)
256
+ i[c] != null && i[c + 1] < n && (a = !0);
257
+ return a && St(l, i, t), l;
258
+ }
259
+ function Tt(t) {
260
+ let e = -1, n = !1;
261
+ for (let o = 0; o < t.childCount; o++) {
262
+ const r = t.child(o);
263
+ let s = 0;
264
+ if (n)
265
+ for (let i = 0; i < o; i++) {
266
+ const l = t.child(i);
267
+ for (let a = 0; a < l.childCount; a++) {
268
+ const c = l.child(a);
269
+ i + c.attrs.rowspan > o && (s += c.attrs.colspan);
270
+ }
271
+ }
272
+ for (let i = 0; i < r.childCount; i++) {
273
+ const l = r.child(i);
274
+ s += l.attrs.colspan, l.attrs.rowspan > 1 && (n = !0);
275
+ }
276
+ e == -1 ? e = s : e != s && (e = Math.max(e, s));
277
+ }
278
+ return e;
279
+ }
280
+ function St(t, e, n) {
281
+ t.problems || (t.problems = []);
282
+ const o = {};
283
+ for (let r = 0; r < t.map.length; r++) {
284
+ const s = t.map[r];
285
+ if (o[s])
286
+ continue;
287
+ o[s] = !0;
288
+ const i = n.nodeAt(s);
289
+ if (!i)
290
+ throw new RangeError(`No cell with offset ${s} found`);
291
+ let l = null;
292
+ const a = i.attrs;
293
+ for (let c = 0; c < a.colspan; c++) {
294
+ const d = (r + c) % t.width, u = e[d * 2];
295
+ u != null && (!a.colwidth || a.colwidth[c] != u) && ((l || (l = xt(a)))[c] = u);
296
+ }
297
+ l && t.problems.unshift({
298
+ type: "colwidth mismatch",
299
+ pos: s,
300
+ colwidth: l
301
+ });
302
+ }
303
+ }
304
+ function xt(t) {
305
+ if (t.colwidth)
306
+ return t.colwidth.slice();
307
+ const e = [];
308
+ for (let n = 0; n < t.colspan; n++)
309
+ e.push(0);
310
+ return e;
311
+ }
312
+ function T(t) {
313
+ let e = t.cached.tableNodeTypes;
314
+ if (!e) {
315
+ e = t.cached.tableNodeTypes = {};
316
+ for (const n in t.nodes) {
317
+ const o = t.nodes[n], r = o.spec.tableRole;
318
+ r && (e[r] = o);
319
+ }
320
+ }
321
+ return e;
322
+ }
323
+ var _ = new D("selectingCells");
324
+ function U(t) {
325
+ for (let e = t.depth - 1; e > 0; e--)
326
+ if (t.node(e).type.spec.tableRole == "row")
327
+ return t.node(0).resolve(t.before(e + 1));
328
+ return null;
329
+ }
330
+ function Lt(t) {
331
+ for (let e = t.depth; e > 0; e--) {
332
+ const n = t.node(e).type.spec.tableRole;
333
+ if (n === "cell" || n === "header_cell")
334
+ return t.node(e);
335
+ }
336
+ return null;
337
+ }
338
+ function E(t) {
339
+ const e = t.selection.$head;
340
+ for (let n = e.depth; n > 0; n--)
341
+ if (e.node(n).type.spec.tableRole == "row")
342
+ return !0;
343
+ return !1;
344
+ }
345
+ function pe(t) {
346
+ const e = t.selection;
347
+ if ("$anchorCell" in e && e.$anchorCell)
348
+ return e.$anchorCell.pos > e.$headCell.pos ? e.$anchorCell : e.$headCell;
349
+ if ("node" in e && e.node && e.node.type.spec.tableRole == "cell")
350
+ return e.$anchor;
351
+ const n = U(e.$head) || Rt(e.$head);
352
+ if (n)
353
+ return n;
354
+ throw new RangeError(`No cell found around position ${e.head}`);
355
+ }
356
+ function Rt(t) {
357
+ for (let e = t.nodeAfter, n = t.pos; e; e = e.firstChild, n++) {
358
+ const o = e.type.spec.tableRole;
359
+ if (o == "cell" || o == "header_cell")
360
+ return t.doc.resolve(n);
361
+ }
362
+ for (let e = t.nodeBefore, n = t.pos; e; e = e.lastChild, n--) {
363
+ const o = e.type.spec.tableRole;
364
+ if (o == "cell" || o == "header_cell")
365
+ return t.doc.resolve(n - e.nodeSize);
366
+ }
367
+ }
368
+ function Ce(t) {
369
+ return t.parent.type.spec.tableRole == "row" && !!t.nodeAfter;
370
+ }
371
+ function Ht(t) {
372
+ return t.node(0).resolve(t.pos + t.nodeAfter.nodeSize);
373
+ }
374
+ function ke(t, e) {
375
+ return t.depth == e.depth && t.pos >= e.start(-1) && t.pos <= e.end(-1);
376
+ }
377
+ function Ue(t, e, n) {
378
+ const o = t.node(-1), r = M.get(o), s = t.start(-1), i = r.nextCell(t.pos - s, e, n);
379
+ return i == null ? null : t.node(0).resolve(s + i);
380
+ }
381
+ function q(t, e, n = 1) {
382
+ const o = { ...t, colspan: t.colspan - n };
383
+ return o.colwidth && (o.colwidth = o.colwidth.slice(), o.colwidth.splice(e, n), o.colwidth.some((r) => r > 0) || (o.colwidth = null)), o;
384
+ }
385
+ function Ye(t, e, n = 1) {
386
+ const o = { ...t, colspan: t.colspan + n };
387
+ if (o.colwidth) {
388
+ o.colwidth = o.colwidth.slice();
389
+ for (let r = 0; r < n; r++)
390
+ o.colwidth.splice(e, 0, 0);
391
+ }
392
+ return o;
393
+ }
394
+ function Et(t, e, n) {
395
+ const o = T(e.type.schema).header_cell;
396
+ for (let r = 0; r < t.height; r++)
397
+ if (e.nodeAt(t.map[n + r * t.width]).type != o)
398
+ return !1;
399
+ return !0;
400
+ }
401
+ var y = class z extends S {
402
+ // A table selection is identified by its anchor and head cells. The
403
+ // positions given to this constructor should point _before_ two
404
+ // cells in the same table. They may be the same, to select a single
405
+ // cell.
406
+ constructor(e, n = e) {
407
+ const o = e.node(-1), r = M.get(o), s = e.start(-1), i = r.rectBetween(
408
+ e.pos - s,
409
+ n.pos - s
410
+ ), l = e.node(0), a = r.cellsInRect(i).filter((d) => d != n.pos - s);
411
+ a.unshift(n.pos - s);
412
+ const c = a.map((d) => {
413
+ const u = o.nodeAt(d);
414
+ if (!u)
415
+ throw RangeError(`No cell with offset ${d} found`);
416
+ const p = s + d + 1;
417
+ return new dt(
418
+ l.resolve(p),
419
+ l.resolve(p + u.content.size)
420
+ );
421
+ });
422
+ super(c[0].$from, c[0].$to, c), this.$anchorCell = e, this.$headCell = n;
423
+ }
424
+ map(e, n) {
425
+ const o = e.resolve(n.map(this.$anchorCell.pos)), r = e.resolve(n.map(this.$headCell.pos));
426
+ if (Ce(o) && Ce(r) && ke(o, r)) {
427
+ const s = this.$anchorCell.node(-1) != o.node(-1);
428
+ return s && this.isRowSelection() ? z.rowSelection(o, r) : s && this.isColSelection() ? z.colSelection(o, r) : new z(o, r);
429
+ }
430
+ return x.between(o, r);
431
+ }
432
+ // Returns a rectangular slice of table rows containing the selected
433
+ // cells.
434
+ content() {
435
+ const e = this.$anchorCell.node(-1), n = M.get(e), o = this.$anchorCell.start(-1), r = n.rectBetween(
436
+ this.$anchorCell.pos - o,
437
+ this.$headCell.pos - o
438
+ ), s = {}, i = [];
439
+ for (let a = r.top; a < r.bottom; a++) {
440
+ const c = [];
441
+ for (let d = a * n.width + r.left, u = r.left; u < r.right; u++, d++) {
442
+ const p = n.map[d];
443
+ if (s[p])
444
+ continue;
445
+ s[p] = !0;
446
+ const h = n.findCell(p);
447
+ let f = e.nodeAt(p);
448
+ if (!f)
449
+ throw RangeError(`No cell with offset ${p} found`);
450
+ const m = r.left - h.left, g = h.right - r.right;
451
+ if (m > 0 || g > 0) {
452
+ let w = f.attrs;
453
+ if (m > 0 && (w = q(w, 0, m)), g > 0 && (w = q(
454
+ w,
455
+ w.colspan - g,
456
+ g
457
+ )), h.left < r.left) {
458
+ if (f = f.type.createAndFill(w), !f)
459
+ throw RangeError(
460
+ `Could not create cell with attrs ${JSON.stringify(w)}`
461
+ );
462
+ } else
463
+ f = f.type.create(w, f.content);
464
+ }
465
+ if (h.top < r.top || h.bottom > r.bottom) {
466
+ const w = {
467
+ ...f.attrs,
468
+ rowspan: Math.min(h.bottom, r.bottom) - Math.max(h.top, r.top)
469
+ };
470
+ h.top < r.top ? f = f.type.createAndFill(w) : f = f.type.create(w, f.content);
471
+ }
472
+ c.push(f);
473
+ }
474
+ i.push(e.child(a).copy(R.from(c)));
475
+ }
476
+ const l = this.isColSelection() && this.isRowSelection() ? e : i;
477
+ return new N(R.from(l), 1, 1);
478
+ }
479
+ replace(e, n = N.empty) {
480
+ const o = e.steps.length, r = this.ranges;
481
+ for (let i = 0; i < r.length; i++) {
482
+ const { $from: l, $to: a } = r[i], c = e.mapping.slice(o);
483
+ e.replace(
484
+ c.map(l.pos),
485
+ c.map(a.pos),
486
+ i ? N.empty : n
487
+ );
488
+ }
489
+ const s = S.findFrom(
490
+ e.doc.resolve(e.mapping.slice(o).map(this.to)),
491
+ -1
492
+ );
493
+ s && e.setSelection(s);
494
+ }
495
+ replaceWith(e, n) {
496
+ this.replace(e, new N(R.from(n), 0, 0));
497
+ }
498
+ forEachCell(e) {
499
+ const n = this.$anchorCell.node(-1), o = M.get(n), r = this.$anchorCell.start(-1), s = o.cellsInRect(
500
+ o.rectBetween(
501
+ this.$anchorCell.pos - r,
502
+ this.$headCell.pos - r
503
+ )
504
+ );
505
+ for (let i = 0; i < s.length; i++)
506
+ e(n.nodeAt(s[i]), r + s[i]);
507
+ }
508
+ // True if this selection goes all the way from the top to the
509
+ // bottom of the table.
510
+ isColSelection() {
511
+ const e = this.$anchorCell.index(-1), n = this.$headCell.index(-1);
512
+ if (Math.min(e, n) > 0)
513
+ return !1;
514
+ const o = e + this.$anchorCell.nodeAfter.attrs.rowspan, r = n + this.$headCell.nodeAfter.attrs.rowspan;
515
+ return Math.max(o, r) == this.$headCell.node(-1).childCount;
516
+ }
517
+ // Returns the smallest column selection that covers the given anchor
518
+ // and head cell.
519
+ static colSelection(e, n = e) {
520
+ const o = e.node(-1), r = M.get(o), s = e.start(-1), i = r.findCell(e.pos - s), l = r.findCell(n.pos - s), a = e.node(0);
521
+ return i.top <= l.top ? (i.top > 0 && (e = a.resolve(s + r.map[i.left])), l.bottom < r.height && (n = a.resolve(
522
+ s + r.map[r.width * (r.height - 1) + l.right - 1]
523
+ ))) : (l.top > 0 && (n = a.resolve(s + r.map[l.left])), i.bottom < r.height && (e = a.resolve(
524
+ s + r.map[r.width * (r.height - 1) + i.right - 1]
525
+ ))), new z(e, n);
526
+ }
527
+ // True if this selection goes all the way from the left to the
528
+ // right of the table.
529
+ isRowSelection() {
530
+ const e = this.$anchorCell.node(-1), n = M.get(e), o = this.$anchorCell.start(-1), r = n.colCount(this.$anchorCell.pos - o), s = n.colCount(this.$headCell.pos - o);
531
+ if (Math.min(r, s) > 0)
532
+ return !1;
533
+ const i = r + this.$anchorCell.nodeAfter.attrs.colspan, l = s + this.$headCell.nodeAfter.attrs.colspan;
534
+ return Math.max(i, l) == n.width;
535
+ }
536
+ eq(e) {
537
+ return e instanceof z && e.$anchorCell.pos == this.$anchorCell.pos && e.$headCell.pos == this.$headCell.pos;
538
+ }
539
+ // Returns the smallest row selection that covers the given anchor
540
+ // and head cell.
541
+ static rowSelection(e, n = e) {
542
+ const o = e.node(-1), r = M.get(o), s = e.start(-1), i = r.findCell(e.pos - s), l = r.findCell(n.pos - s), a = e.node(0);
543
+ return i.left <= l.left ? (i.left > 0 && (e = a.resolve(
544
+ s + r.map[i.top * r.width]
545
+ )), l.right < r.width && (n = a.resolve(
546
+ s + r.map[r.width * (l.top + 1) - 1]
547
+ ))) : (l.left > 0 && (n = a.resolve(s + r.map[l.top * r.width])), i.right < r.width && (e = a.resolve(
548
+ s + r.map[r.width * (i.top + 1) - 1]
549
+ ))), new z(e, n);
550
+ }
551
+ toJSON() {
552
+ return {
553
+ type: "cell",
554
+ anchor: this.$anchorCell.pos,
555
+ head: this.$headCell.pos
556
+ };
557
+ }
558
+ static fromJSON(e, n) {
559
+ return new z(e.resolve(n.anchor), e.resolve(n.head));
560
+ }
561
+ static create(e, n, o = n) {
562
+ return new z(e.resolve(n), e.resolve(o));
563
+ }
564
+ getBookmark() {
565
+ return new It(this.$anchorCell.pos, this.$headCell.pos);
566
+ }
567
+ };
568
+ y.prototype.visible = !1;
569
+ S.jsonID("cell", y);
570
+ var It = class Ze {
571
+ constructor(e, n) {
572
+ this.anchor = e, this.head = n;
573
+ }
574
+ map(e) {
575
+ return new Ze(e.map(this.anchor), e.map(this.head));
576
+ }
577
+ resolve(e) {
578
+ const n = e.resolve(this.anchor), o = e.resolve(this.head);
579
+ return n.parent.type.spec.tableRole == "row" && o.parent.type.spec.tableRole == "row" && n.index() < n.parent.childCount && o.index() < o.parent.childCount && ke(n, o) ? new y(n, o) : S.near(o, 1);
580
+ }
581
+ };
582
+ function Nt(t) {
583
+ if (!(t.selection instanceof y))
584
+ return null;
585
+ const e = [];
586
+ return t.selection.forEachCell((n, o) => {
587
+ e.push(
588
+ X.node(o, o + n.nodeSize, { class: "selectedCell" })
589
+ );
590
+ }), F.create(t.doc, e);
591
+ }
592
+ function Ot({ $from: t, $to: e }) {
593
+ if (t.pos == e.pos || t.pos < e.pos - 6)
594
+ return !1;
595
+ let n = t.pos, o = e.pos, r = t.depth;
596
+ for (; r >= 0 && !(t.after(r + 1) < t.end(r)); r--, n++)
597
+ ;
598
+ for (let s = e.depth; s >= 0 && !(e.before(s + 1) > e.start(s)); s--, o--)
599
+ ;
600
+ return n == o && /row|table/.test(t.node(r).type.spec.tableRole);
601
+ }
602
+ function Pt({ $from: t, $to: e }) {
603
+ let n, o;
604
+ for (let r = t.depth; r > 0; r--) {
605
+ const s = t.node(r);
606
+ if (s.type.spec.tableRole === "cell" || s.type.spec.tableRole === "header_cell") {
607
+ n = s;
608
+ break;
609
+ }
610
+ }
611
+ for (let r = e.depth; r > 0; r--) {
612
+ const s = e.node(r);
613
+ if (s.type.spec.tableRole === "cell" || s.type.spec.tableRole === "header_cell") {
614
+ o = s;
615
+ break;
616
+ }
617
+ }
618
+ return n !== o && e.parentOffset === 0;
619
+ }
620
+ function zt(t, e, n) {
621
+ const o = (e || t).selection, r = (e || t).doc;
622
+ let s, i;
623
+ if (o instanceof ue && (i = o.node.type.spec.tableRole)) {
624
+ if (i == "cell" || i == "header_cell")
625
+ s = y.create(r, o.from);
626
+ else if (i == "row") {
627
+ const l = r.resolve(o.from + 1);
628
+ s = y.rowSelection(l, l);
629
+ } else if (!n) {
630
+ const l = M.get(o.node), a = o.from + 1, c = a + l.map[l.width * l.height - 1];
631
+ s = y.create(r, a + 1, c);
632
+ }
633
+ } else o instanceof x && Ot(o) ? s = x.create(r, o.from) : o instanceof x && Pt(o) && (s = x.create(r, o.$from.start(), o.$from.end()));
634
+ return s && (e || (e = t.tr)).setSelection(s), e;
635
+ }
636
+ var $t = new D("fix-tables");
637
+ function Qe(t, e, n, o) {
638
+ const r = t.childCount, s = e.childCount;
639
+ e:
640
+ for (let i = 0, l = 0; i < s; i++) {
641
+ const a = e.child(i);
642
+ for (let c = l, d = Math.min(r, i + 3); c < d; c++)
643
+ if (t.child(c) == a) {
644
+ l = c + 1, n += a.nodeSize;
645
+ continue e;
646
+ }
647
+ o(a, n), l < r && t.child(l).sameMarkup(a) ? Qe(t.child(l), a, n + 1, o) : a.nodesBetween(0, a.content.size, o, n + 1), n += a.nodeSize;
648
+ }
649
+ }
650
+ function et(t, e) {
651
+ let n;
652
+ const o = (r, s) => {
653
+ r.type.spec.tableRole == "table" && (n = _t(t, r, s, n));
654
+ };
655
+ return e ? e.doc != t.doc && Qe(e.doc, t.doc, 0, o) : t.doc.descendants(o), n;
656
+ }
657
+ function _t(t, e, n, o) {
658
+ const r = M.get(e);
659
+ if (!r.problems)
660
+ return o;
661
+ o || (o = t.tr);
662
+ const s = [];
663
+ for (let a = 0; a < r.height; a++)
664
+ s.push(0);
665
+ for (let a = 0; a < r.problems.length; a++) {
666
+ const c = r.problems[a];
667
+ if (c.type == "collision") {
668
+ const d = e.nodeAt(c.pos);
669
+ if (!d)
670
+ continue;
671
+ const u = d.attrs;
672
+ for (let p = 0; p < u.rowspan; p++)
673
+ s[c.row + p] += c.n;
674
+ o.setNodeMarkup(
675
+ o.mapping.map(n + 1 + c.pos),
676
+ null,
677
+ q(u, u.colspan - c.n, c.n)
678
+ );
679
+ } else if (c.type == "missing")
680
+ s[c.row] += c.n;
681
+ else if (c.type == "overlong_rowspan") {
682
+ const d = e.nodeAt(c.pos);
683
+ if (!d)
684
+ continue;
685
+ o.setNodeMarkup(o.mapping.map(n + 1 + c.pos), null, {
686
+ ...d.attrs,
687
+ rowspan: d.attrs.rowspan - c.n
688
+ });
689
+ } else if (c.type == "colwidth mismatch") {
690
+ const d = e.nodeAt(c.pos);
691
+ if (!d)
692
+ continue;
693
+ o.setNodeMarkup(o.mapping.map(n + 1 + c.pos), null, {
694
+ ...d.attrs,
695
+ colwidth: c.colwidth
696
+ });
697
+ }
698
+ }
699
+ let i, l;
700
+ for (let a = 0; a < s.length; a++)
701
+ s[a] && (i == null && (i = a), l = a);
702
+ for (let a = 0, c = n + 1; a < r.height; a++) {
703
+ const d = e.child(a), u = c + d.nodeSize, p = s[a];
704
+ if (p > 0) {
705
+ let h = "cell";
706
+ d.firstChild && (h = d.firstChild.type.spec.tableRole);
707
+ const f = [];
708
+ for (let g = 0; g < p; g++) {
709
+ const w = T(t.schema)[h].createAndFill();
710
+ w && f.push(w);
711
+ }
712
+ const m = (a == 0 || i == a - 1) && l == a ? c + 1 : u - 1;
713
+ o.insert(o.mapping.map(m), f);
714
+ }
715
+ c = u;
716
+ }
717
+ return o.setMeta($t, { fixTables: !0 });
718
+ }
719
+ function O(t) {
720
+ const e = t.selection, n = pe(t), o = n.node(-1), r = n.start(-1), s = M.get(o);
721
+ return { ...e instanceof y ? s.rectBetween(
722
+ e.$anchorCell.pos - r,
723
+ e.$headCell.pos - r
724
+ ) : s.findCell(n.pos - r), tableStart: r, map: s, table: o };
725
+ }
726
+ function tt(t, { map: e, tableStart: n, table: o }, r) {
727
+ let s = r > 0 ? -1 : 0;
728
+ Et(e, o, r + s) && (s = r == 0 || r == e.width ? null : 0);
729
+ for (let i = 0; i < e.height; i++) {
730
+ const l = i * e.width + r;
731
+ if (r > 0 && r < e.width && e.map[l - 1] == e.map[l]) {
732
+ const a = e.map[l], c = o.nodeAt(a);
733
+ t.setNodeMarkup(
734
+ t.mapping.map(n + a),
735
+ null,
736
+ Ye(c.attrs, r - e.colCount(a))
737
+ ), i += c.attrs.rowspan - 1;
738
+ } else {
739
+ const a = s == null ? T(o.type.schema).cell : o.nodeAt(e.map[l + s]).type, c = e.positionAt(i, r, o);
740
+ t.insert(t.mapping.map(n + c), a.createAndFill());
741
+ }
742
+ }
743
+ return t;
744
+ }
745
+ function Bt(t, e) {
746
+ if (!E(t))
747
+ return !1;
748
+ if (e) {
749
+ const n = O(t);
750
+ e(tt(t.tr, n, n.left));
751
+ }
752
+ return !0;
753
+ }
754
+ function Dt(t, e) {
755
+ if (!E(t))
756
+ return !1;
757
+ if (e) {
758
+ const n = O(t);
759
+ e(tt(t.tr, n, n.right));
760
+ }
761
+ return !0;
762
+ }
763
+ function Wt(t, { map: e, table: n, tableStart: o }, r) {
764
+ const s = t.mapping.maps.length;
765
+ for (let i = 0; i < e.height; ) {
766
+ const l = i * e.width + r, a = e.map[l], c = n.nodeAt(a), d = c.attrs;
767
+ if (r > 0 && e.map[l - 1] == a || r < e.width - 1 && e.map[l + 1] == a)
768
+ t.setNodeMarkup(
769
+ t.mapping.slice(s).map(o + a),
770
+ null,
771
+ q(d, r - e.colCount(a))
772
+ );
773
+ else {
774
+ const u = t.mapping.slice(s).map(o + a);
775
+ t.delete(u, u + c.nodeSize);
776
+ }
777
+ i += d.rowspan;
778
+ }
779
+ }
780
+ function Vt(t, e) {
781
+ if (!E(t))
782
+ return !1;
783
+ if (e) {
784
+ const n = O(t), o = t.tr;
785
+ if (n.left == 0 && n.right == n.map.width)
786
+ return !1;
787
+ for (let r = n.right - 1; Wt(o, n, r), r != n.left; r--) {
788
+ const s = n.tableStart ? o.doc.nodeAt(n.tableStart - 1) : o.doc;
789
+ if (!s)
790
+ throw RangeError("No table found");
791
+ n.table = s, n.map = M.get(s);
792
+ }
793
+ e(o);
794
+ }
795
+ return !0;
796
+ }
797
+ function Ft(t, e, n) {
798
+ var o;
799
+ const r = T(e.type.schema).header_cell;
800
+ for (let s = 0; s < t.width; s++)
801
+ if (((o = e.nodeAt(t.map[s + n * t.width])) == null ? void 0 : o.type) != r)
802
+ return !1;
803
+ return !0;
804
+ }
805
+ function nt(t, { map: e, tableStart: n, table: o }, r) {
806
+ var s;
807
+ let i = n;
808
+ for (let c = 0; c < r; c++)
809
+ i += o.child(c).nodeSize;
810
+ const l = [];
811
+ let a = r > 0 ? -1 : 0;
812
+ Ft(e, o, r + a) && (a = r == 0 || r == e.height ? null : 0);
813
+ for (let c = 0, d = e.width * r; c < e.width; c++, d++)
814
+ if (r > 0 && r < e.height && e.map[d] == e.map[d - e.width]) {
815
+ const u = e.map[d], p = o.nodeAt(u).attrs;
816
+ t.setNodeMarkup(n + u, null, {
817
+ ...p,
818
+ rowspan: p.rowspan + 1
819
+ }), c += p.colspan - 1;
820
+ } else {
821
+ const u = a == null ? T(o.type.schema).cell : (s = o.nodeAt(e.map[d + a * e.width])) == null ? void 0 : s.type, p = u == null ? void 0 : u.createAndFill();
822
+ p && l.push(p);
823
+ }
824
+ return t.insert(i, T(o.type.schema).row.create(null, l)), t;
825
+ }
826
+ function Kt(t, e) {
827
+ if (!E(t))
828
+ return !1;
829
+ if (e) {
830
+ const n = O(t);
831
+ e(nt(t.tr, n, n.top));
832
+ }
833
+ return !0;
834
+ }
835
+ function jt(t, e) {
836
+ if (!E(t))
837
+ return !1;
838
+ if (e) {
839
+ const n = O(t);
840
+ e(nt(t.tr, n, n.bottom));
841
+ }
842
+ return !0;
843
+ }
844
+ function qt(t, { map: e, table: n, tableStart: o }, r) {
845
+ let s = 0;
846
+ for (let c = 0; c < r; c++)
847
+ s += n.child(c).nodeSize;
848
+ const i = s + n.child(r).nodeSize, l = t.mapping.maps.length;
849
+ t.delete(s + o, i + o);
850
+ const a = /* @__PURE__ */ new Set();
851
+ for (let c = 0, d = r * e.width; c < e.width; c++, d++) {
852
+ const u = e.map[d];
853
+ if (!a.has(u)) {
854
+ if (a.add(u), r > 0 && u == e.map[d - e.width]) {
855
+ const p = n.nodeAt(u).attrs;
856
+ t.setNodeMarkup(t.mapping.slice(l).map(u + o), null, {
857
+ ...p,
858
+ rowspan: p.rowspan - 1
859
+ }), c += p.colspan - 1;
860
+ } else if (r < e.height && u == e.map[d + e.width]) {
861
+ const p = n.nodeAt(u), h = p.attrs, f = p.type.create(
862
+ { ...h, rowspan: p.attrs.rowspan - 1 },
863
+ p.content
864
+ ), m = e.positionAt(r + 1, c, n);
865
+ t.insert(t.mapping.slice(l).map(o + m), f), c += h.colspan - 1;
866
+ }
867
+ }
868
+ }
869
+ }
870
+ function Xt(t, e) {
871
+ if (!E(t))
872
+ return !1;
873
+ if (e) {
874
+ const n = O(t), o = t.tr;
875
+ if (n.top == 0 && n.bottom == n.map.height)
876
+ return !1;
877
+ for (let r = n.bottom - 1; qt(o, n, r), r != n.top; r--) {
878
+ const s = n.tableStart ? o.doc.nodeAt(n.tableStart - 1) : o.doc;
879
+ if (!s)
880
+ throw RangeError("No table found");
881
+ n.table = s, n.map = M.get(n.table);
882
+ }
883
+ e(o);
884
+ }
885
+ return !0;
886
+ }
887
+ function Se(t) {
888
+ const e = t.content;
889
+ return e.childCount == 1 && e.child(0).isTextblock && e.child(0).childCount == 0;
890
+ }
891
+ function Gt({ width: t, height: e, map: n }, o) {
892
+ let r = o.top * t + o.left, s = r, i = (o.bottom - 1) * t + o.left, l = r + (o.right - o.left - 1);
893
+ for (let a = o.top; a < o.bottom; a++) {
894
+ if (o.left > 0 && n[s] == n[s - 1] || o.right < t && n[l] == n[l + 1])
895
+ return !0;
896
+ s += t, l += t;
897
+ }
898
+ for (let a = o.left; a < o.right; a++) {
899
+ if (o.top > 0 && n[r] == n[r - t] || o.bottom < e && n[i] == n[i + t])
900
+ return !0;
901
+ r++, i++;
902
+ }
903
+ return !1;
904
+ }
905
+ function xe(t, e) {
906
+ const n = t.selection;
907
+ if (!(n instanceof y) || n.$anchorCell.pos == n.$headCell.pos)
908
+ return !1;
909
+ const o = O(t), { map: r } = o;
910
+ if (Gt(r, o))
911
+ return !1;
912
+ if (e) {
913
+ const s = t.tr, i = {};
914
+ let l = R.empty, a, c;
915
+ for (let d = o.top; d < o.bottom; d++)
916
+ for (let u = o.left; u < o.right; u++) {
917
+ const p = r.map[d * r.width + u], h = o.table.nodeAt(p);
918
+ if (!(i[p] || !h))
919
+ if (i[p] = !0, a == null)
920
+ a = p, c = h;
921
+ else {
922
+ Se(h) || (l = l.append(h.content));
923
+ const f = s.mapping.map(p + o.tableStart);
924
+ s.delete(f, f + h.nodeSize);
925
+ }
926
+ }
927
+ if (a == null || c == null)
928
+ return !0;
929
+ if (s.setNodeMarkup(a + o.tableStart, null, {
930
+ ...Ye(
931
+ c.attrs,
932
+ c.attrs.colspan,
933
+ o.right - o.left - c.attrs.colspan
934
+ ),
935
+ rowspan: o.bottom - o.top
936
+ }), l.size) {
937
+ const d = a + 1 + c.content.size, u = Se(c) ? a + 1 : d;
938
+ s.replaceWith(u + o.tableStart, d + o.tableStart, l);
939
+ }
940
+ s.setSelection(
941
+ new y(s.doc.resolve(a + o.tableStart))
942
+ ), e(s);
943
+ }
944
+ return !0;
945
+ }
946
+ function Le(t, e) {
947
+ const n = T(t.schema);
948
+ return Jt(({ node: o }) => n[o.type.spec.tableRole])(t, e);
949
+ }
950
+ function Jt(t) {
951
+ return (e, n) => {
952
+ var o;
953
+ const r = e.selection;
954
+ let s, i;
955
+ if (r instanceof y) {
956
+ if (r.$anchorCell.pos != r.$headCell.pos)
957
+ return !1;
958
+ s = r.$anchorCell.nodeAfter, i = r.$anchorCell.pos;
959
+ } else {
960
+ if (s = Lt(r.$from), !s)
961
+ return !1;
962
+ i = (o = U(r.$from)) == null ? void 0 : o.pos;
963
+ }
964
+ if (s == null || i == null || s.attrs.colspan == 1 && s.attrs.rowspan == 1)
965
+ return !1;
966
+ if (n) {
967
+ let l = s.attrs;
968
+ const a = [], c = l.colwidth;
969
+ l.rowspan > 1 && (l = { ...l, rowspan: 1 }), l.colspan > 1 && (l = { ...l, colspan: 1 });
970
+ const d = O(e), u = e.tr;
971
+ for (let h = 0; h < d.right - d.left; h++)
972
+ a.push(
973
+ c ? {
974
+ ...l,
975
+ colwidth: c && c[h] ? [c[h]] : null
976
+ } : l
977
+ );
978
+ let p;
979
+ for (let h = d.top; h < d.bottom; h++) {
980
+ let f = d.map.positionAt(h, d.left, d.table);
981
+ h == d.top && (f += s.nodeSize);
982
+ for (let m = d.left, g = 0; m < d.right; m++, g++)
983
+ m == d.left && h == d.top || u.insert(
984
+ p = u.mapping.map(f + d.tableStart, 1),
985
+ t({ node: s, row: h, col: m }).createAndFill(a[g])
986
+ );
987
+ }
988
+ u.setNodeMarkup(
989
+ i,
990
+ t({ node: s, row: d.top, col: d.left }),
991
+ a[0]
992
+ ), r instanceof y && u.setSelection(
993
+ new y(
994
+ u.doc.resolve(r.$anchorCell.pos),
995
+ p ? u.doc.resolve(p) : void 0
996
+ )
997
+ ), n(u);
998
+ }
999
+ return !0;
1000
+ };
1001
+ }
1002
+ function Ut(t, e) {
1003
+ return function(n, o) {
1004
+ if (!E(n))
1005
+ return !1;
1006
+ const r = pe(n);
1007
+ if (r.nodeAfter.attrs[t] === e)
1008
+ return !1;
1009
+ if (o) {
1010
+ const s = n.tr;
1011
+ n.selection instanceof y ? n.selection.forEachCell((i, l) => {
1012
+ i.attrs[t] !== e && s.setNodeMarkup(l, null, {
1013
+ ...i.attrs,
1014
+ [t]: e
1015
+ });
1016
+ }) : s.setNodeMarkup(r.pos, null, {
1017
+ ...r.nodeAfter.attrs,
1018
+ [t]: e
1019
+ }), o(s);
1020
+ }
1021
+ return !0;
1022
+ };
1023
+ }
1024
+ function Yt(t) {
1025
+ return function(e, n) {
1026
+ if (!E(e))
1027
+ return !1;
1028
+ if (n) {
1029
+ const o = T(e.schema), r = O(e), s = e.tr, i = r.map.cellsInRect(
1030
+ t == "column" ? {
1031
+ left: r.left,
1032
+ top: 0,
1033
+ right: r.right,
1034
+ bottom: r.map.height
1035
+ } : t == "row" ? {
1036
+ left: 0,
1037
+ top: r.top,
1038
+ right: r.map.width,
1039
+ bottom: r.bottom
1040
+ } : r
1041
+ ), l = i.map((a) => r.table.nodeAt(a));
1042
+ for (let a = 0; a < i.length; a++)
1043
+ l[a].type == o.header_cell && s.setNodeMarkup(
1044
+ r.tableStart + i[a],
1045
+ o.cell,
1046
+ l[a].attrs
1047
+ );
1048
+ if (s.steps.length == 0)
1049
+ for (let a = 0; a < i.length; a++)
1050
+ s.setNodeMarkup(
1051
+ r.tableStart + i[a],
1052
+ o.header_cell,
1053
+ l[a].attrs
1054
+ );
1055
+ n(s);
1056
+ }
1057
+ return !0;
1058
+ };
1059
+ }
1060
+ function Re(t, e, n) {
1061
+ const o = e.map.cellsInRect({
1062
+ left: 0,
1063
+ top: 0,
1064
+ right: t == "row" ? e.map.width : 1,
1065
+ bottom: t == "column" ? e.map.height : 1
1066
+ });
1067
+ for (let r = 0; r < o.length; r++) {
1068
+ const s = e.table.nodeAt(o[r]);
1069
+ if (s && s.type !== n.header_cell)
1070
+ return !1;
1071
+ }
1072
+ return !0;
1073
+ }
1074
+ function Q(t, e) {
1075
+ return e = e || { useDeprecatedLogic: !1 }, e.useDeprecatedLogic ? Yt(t) : function(n, o) {
1076
+ if (!E(n))
1077
+ return !1;
1078
+ if (o) {
1079
+ const r = T(n.schema), s = O(n), i = n.tr, l = Re("row", s, r), a = Re(
1080
+ "column",
1081
+ s,
1082
+ r
1083
+ ), d = (t === "column" ? l : t === "row" ? a : !1) ? 1 : 0, u = t == "column" ? {
1084
+ left: 0,
1085
+ top: d,
1086
+ right: 1,
1087
+ bottom: s.map.height
1088
+ } : t == "row" ? {
1089
+ left: d,
1090
+ top: 0,
1091
+ right: s.map.width,
1092
+ bottom: 1
1093
+ } : s, p = t == "column" ? a ? r.cell : r.header_cell : t == "row" ? l ? r.cell : r.header_cell : r.cell;
1094
+ s.map.cellsInRect(u).forEach((h) => {
1095
+ const f = h + s.tableStart, m = i.doc.nodeAt(f);
1096
+ m && i.setNodeMarkup(f, p, m.attrs);
1097
+ }), o(i);
1098
+ }
1099
+ return !0;
1100
+ };
1101
+ }
1102
+ Q("row", {
1103
+ useDeprecatedLogic: !0
1104
+ });
1105
+ Q("column", {
1106
+ useDeprecatedLogic: !0
1107
+ });
1108
+ var Zt = Q("cell", {
1109
+ useDeprecatedLogic: !0
1110
+ });
1111
+ function Qt(t, e) {
1112
+ if (e < 0) {
1113
+ const n = t.nodeBefore;
1114
+ if (n)
1115
+ return t.pos - n.nodeSize;
1116
+ for (let o = t.index(-1) - 1, r = t.before(); o >= 0; o--) {
1117
+ const s = t.node(-1).child(o), i = s.lastChild;
1118
+ if (i)
1119
+ return r - 1 - i.nodeSize;
1120
+ r -= s.nodeSize;
1121
+ }
1122
+ } else {
1123
+ if (t.index() < t.parent.childCount - 1)
1124
+ return t.pos + t.nodeAfter.nodeSize;
1125
+ const n = t.node(-1);
1126
+ for (let o = t.indexAfter(-1), r = t.after(); o < n.childCount; o++) {
1127
+ const s = n.child(o);
1128
+ if (s.childCount)
1129
+ return r + 1;
1130
+ r += s.nodeSize;
1131
+ }
1132
+ }
1133
+ return null;
1134
+ }
1135
+ function He(t) {
1136
+ return function(e, n) {
1137
+ if (!E(e))
1138
+ return !1;
1139
+ const o = Qt(pe(e), t);
1140
+ if (o == null)
1141
+ return !1;
1142
+ if (n) {
1143
+ const r = e.doc.resolve(o);
1144
+ n(
1145
+ e.tr.setSelection(x.between(r, Ht(r))).scrollIntoView()
1146
+ );
1147
+ }
1148
+ return !0;
1149
+ };
1150
+ }
1151
+ function en(t, e) {
1152
+ const n = t.selection.$anchor;
1153
+ for (let o = n.depth; o > 0; o--)
1154
+ if (n.node(o).type.spec.tableRole == "table")
1155
+ return e && e(
1156
+ t.tr.delete(n.before(o), n.after(o)).scrollIntoView()
1157
+ ), !0;
1158
+ return !1;
1159
+ }
1160
+ function ne(t, e) {
1161
+ const n = t.selection;
1162
+ if (!(n instanceof y))
1163
+ return !1;
1164
+ if (e) {
1165
+ const o = t.tr, r = T(t.schema).cell.createAndFill().content;
1166
+ n.forEachCell((s, i) => {
1167
+ s.content.eq(r) || o.replace(
1168
+ o.mapping.map(i + 1),
1169
+ o.mapping.map(i + s.nodeSize - 1),
1170
+ new N(r, 0, 0)
1171
+ );
1172
+ }), o.docChanged && e(o);
1173
+ }
1174
+ return !0;
1175
+ }
1176
+ function tn(t) {
1177
+ if (!t.size)
1178
+ return null;
1179
+ let { content: e, openStart: n, openEnd: o } = t;
1180
+ for (; e.childCount == 1 && (n > 0 && o > 0 || e.child(0).type.spec.tableRole == "table"); )
1181
+ n--, o--, e = e.child(0).content;
1182
+ const r = e.child(0), s = r.type.spec.tableRole, i = r.type.schema, l = [];
1183
+ if (s == "row")
1184
+ for (let a = 0; a < e.childCount; a++) {
1185
+ let c = e.child(a).content;
1186
+ const d = a ? 0 : Math.max(0, n - 1), u = a < e.childCount - 1 ? 0 : Math.max(0, o - 1);
1187
+ (d || u) && (c = Me(
1188
+ T(i).row,
1189
+ new N(c, d, u)
1190
+ ).content), l.push(c);
1191
+ }
1192
+ else if (s == "cell" || s == "header_cell")
1193
+ l.push(
1194
+ n || o ? Me(
1195
+ T(i).row,
1196
+ new N(e, n, o)
1197
+ ).content : e
1198
+ );
1199
+ else
1200
+ return null;
1201
+ return nn(i, l);
1202
+ }
1203
+ function nn(t, e) {
1204
+ const n = [];
1205
+ for (let r = 0; r < e.length; r++) {
1206
+ const s = e[r];
1207
+ for (let i = s.childCount - 1; i >= 0; i--) {
1208
+ const { rowspan: l, colspan: a } = s.child(i).attrs;
1209
+ for (let c = r; c < r + l; c++)
1210
+ n[c] = (n[c] || 0) + a;
1211
+ }
1212
+ }
1213
+ let o = 0;
1214
+ for (let r = 0; r < n.length; r++)
1215
+ o = Math.max(o, n[r]);
1216
+ for (let r = 0; r < n.length; r++)
1217
+ if (r >= e.length && e.push(R.empty), n[r] < o) {
1218
+ const s = T(t).cell.createAndFill(), i = [];
1219
+ for (let l = n[r]; l < o; l++)
1220
+ i.push(s);
1221
+ e[r] = e[r].append(R.from(i));
1222
+ }
1223
+ return { height: e.length, width: o, rows: e };
1224
+ }
1225
+ function Me(t, e) {
1226
+ const n = t.createAndFill();
1227
+ return new ut(n).replace(0, n.content.size, e).doc;
1228
+ }
1229
+ function on({ width: t, height: e, rows: n }, o, r) {
1230
+ if (t != o) {
1231
+ const s = [], i = [];
1232
+ for (let l = 0; l < n.length; l++) {
1233
+ const a = n[l], c = [];
1234
+ for (let d = s[l] || 0, u = 0; d < o; u++) {
1235
+ let p = a.child(u % a.childCount);
1236
+ d + p.attrs.colspan > o && (p = p.type.createChecked(
1237
+ q(
1238
+ p.attrs,
1239
+ p.attrs.colspan,
1240
+ d + p.attrs.colspan - o
1241
+ ),
1242
+ p.content
1243
+ )), c.push(p), d += p.attrs.colspan;
1244
+ for (let h = 1; h < p.attrs.rowspan; h++)
1245
+ s[l + h] = (s[l + h] || 0) + p.attrs.colspan;
1246
+ }
1247
+ i.push(R.from(c));
1248
+ }
1249
+ n = i, t = o;
1250
+ }
1251
+ if (e != r) {
1252
+ const s = [];
1253
+ for (let i = 0, l = 0; i < r; i++, l++) {
1254
+ const a = [], c = n[l % e];
1255
+ for (let d = 0; d < c.childCount; d++) {
1256
+ let u = c.child(d);
1257
+ i + u.attrs.rowspan > r && (u = u.type.create(
1258
+ {
1259
+ ...u.attrs,
1260
+ rowspan: Math.max(1, r - u.attrs.rowspan)
1261
+ },
1262
+ u.content
1263
+ )), a.push(u);
1264
+ }
1265
+ s.push(R.from(a));
1266
+ }
1267
+ n = s, e = r;
1268
+ }
1269
+ return { width: t, height: e, rows: n };
1270
+ }
1271
+ function rn(t, e, n, o, r, s, i) {
1272
+ const l = t.doc.type.schema, a = T(l);
1273
+ let c, d;
1274
+ if (r > e.width)
1275
+ for (let u = 0, p = 0; u < e.height; u++) {
1276
+ const h = n.child(u);
1277
+ p += h.nodeSize;
1278
+ const f = [];
1279
+ let m;
1280
+ h.lastChild == null || h.lastChild.type == a.cell ? m = c || (c = a.cell.createAndFill()) : m = d || (d = a.header_cell.createAndFill());
1281
+ for (let g = e.width; g < r; g++)
1282
+ f.push(m);
1283
+ t.insert(t.mapping.slice(i).map(p - 1 + o), f);
1284
+ }
1285
+ if (s > e.height) {
1286
+ const u = [];
1287
+ for (let f = 0, m = (e.height - 1) * e.width; f < Math.max(e.width, r); f++) {
1288
+ const g = f >= e.width ? !1 : n.nodeAt(e.map[m + f]).type == a.header_cell;
1289
+ u.push(
1290
+ g ? d || (d = a.header_cell.createAndFill()) : c || (c = a.cell.createAndFill())
1291
+ );
1292
+ }
1293
+ const p = a.row.create(null, R.from(u)), h = [];
1294
+ for (let f = e.height; f < s; f++)
1295
+ h.push(p);
1296
+ t.insert(t.mapping.slice(i).map(o + n.nodeSize - 2), h);
1297
+ }
1298
+ return !!(c || d);
1299
+ }
1300
+ function Ee(t, e, n, o, r, s, i, l) {
1301
+ if (i == 0 || i == e.height)
1302
+ return !1;
1303
+ let a = !1;
1304
+ for (let c = r; c < s; c++) {
1305
+ const d = i * e.width + c, u = e.map[d];
1306
+ if (e.map[d - e.width] == u) {
1307
+ a = !0;
1308
+ const p = n.nodeAt(u), { top: h, left: f } = e.findCell(u);
1309
+ t.setNodeMarkup(t.mapping.slice(l).map(u + o), null, {
1310
+ ...p.attrs,
1311
+ rowspan: i - h
1312
+ }), t.insert(
1313
+ t.mapping.slice(l).map(e.positionAt(i, f, n)),
1314
+ p.type.createAndFill({
1315
+ ...p.attrs,
1316
+ rowspan: h + p.attrs.rowspan - i
1317
+ })
1318
+ ), c += p.attrs.colspan - 1;
1319
+ }
1320
+ }
1321
+ return a;
1322
+ }
1323
+ function Ie(t, e, n, o, r, s, i, l) {
1324
+ if (i == 0 || i == e.width)
1325
+ return !1;
1326
+ let a = !1;
1327
+ for (let c = r; c < s; c++) {
1328
+ const d = c * e.width + i, u = e.map[d];
1329
+ if (e.map[d - 1] == u) {
1330
+ a = !0;
1331
+ const p = n.nodeAt(u), h = e.colCount(u), f = t.mapping.slice(l).map(u + o);
1332
+ t.setNodeMarkup(
1333
+ f,
1334
+ null,
1335
+ q(
1336
+ p.attrs,
1337
+ i - h,
1338
+ p.attrs.colspan - (i - h)
1339
+ )
1340
+ ), t.insert(
1341
+ f + p.nodeSize,
1342
+ p.type.createAndFill(
1343
+ q(p.attrs, 0, i - h)
1344
+ )
1345
+ ), c += p.attrs.rowspan - 1;
1346
+ }
1347
+ }
1348
+ return a;
1349
+ }
1350
+ function Ne(t, e, n, o, r) {
1351
+ let s = n ? t.doc.nodeAt(n - 1) : t.doc;
1352
+ if (!s)
1353
+ throw new Error("No table found");
1354
+ let i = M.get(s);
1355
+ const { top: l, left: a } = o, c = a + r.width, d = l + r.height, u = t.tr;
1356
+ let p = 0;
1357
+ function h() {
1358
+ if (s = n ? u.doc.nodeAt(n - 1) : u.doc, !s)
1359
+ throw new Error("No table found");
1360
+ i = M.get(s), p = u.mapping.maps.length;
1361
+ }
1362
+ rn(u, i, s, n, c, d, p) && h(), Ee(u, i, s, n, a, c, l, p) && h(), Ee(u, i, s, n, a, c, d, p) && h(), Ie(u, i, s, n, l, d, a, p) && h(), Ie(u, i, s, n, l, d, c, p) && h();
1363
+ for (let f = l; f < d; f++) {
1364
+ const m = i.positionAt(f, a, s), g = i.positionAt(f, c, s);
1365
+ u.replace(
1366
+ u.mapping.slice(p).map(m + n),
1367
+ u.mapping.slice(p).map(g + n),
1368
+ new N(r.rows[f - l], 0, 0)
1369
+ );
1370
+ }
1371
+ h(), u.setSelection(
1372
+ new y(
1373
+ u.doc.resolve(n + i.positionAt(l, a, s)),
1374
+ u.doc.resolve(n + i.positionAt(d - 1, c - 1, s))
1375
+ )
1376
+ ), e(u);
1377
+ }
1378
+ var sn = Xe({
1379
+ ArrowLeft: oe("horiz", -1),
1380
+ ArrowRight: oe("horiz", 1),
1381
+ ArrowUp: oe("vert", -1),
1382
+ ArrowDown: oe("vert", 1),
1383
+ "Shift-ArrowLeft": re("horiz", -1),
1384
+ "Shift-ArrowRight": re("horiz", 1),
1385
+ "Shift-ArrowUp": re("vert", -1),
1386
+ "Shift-ArrowDown": re("vert", 1),
1387
+ Backspace: ne,
1388
+ "Mod-Backspace": ne,
1389
+ Delete: ne,
1390
+ "Mod-Delete": ne
1391
+ });
1392
+ function le(t, e, n) {
1393
+ return n.eq(t.selection) ? !1 : (e && e(t.tr.setSelection(n).scrollIntoView()), !0);
1394
+ }
1395
+ function oe(t, e) {
1396
+ return (n, o, r) => {
1397
+ if (!r)
1398
+ return !1;
1399
+ const s = n.selection;
1400
+ if (s instanceof y)
1401
+ return le(
1402
+ n,
1403
+ o,
1404
+ S.near(s.$headCell, e)
1405
+ );
1406
+ if (t != "horiz" && !s.empty)
1407
+ return !1;
1408
+ const i = ot(r, t, e);
1409
+ if (i == null)
1410
+ return !1;
1411
+ if (t == "horiz")
1412
+ return le(
1413
+ n,
1414
+ o,
1415
+ S.near(n.doc.resolve(s.head + e), e)
1416
+ );
1417
+ {
1418
+ const l = n.doc.resolve(i), a = Ue(l, t, e);
1419
+ let c;
1420
+ return a ? c = S.near(a, 1) : e < 0 ? c = S.near(n.doc.resolve(l.before(-1)), -1) : c = S.near(n.doc.resolve(l.after(-1)), 1), le(n, o, c);
1421
+ }
1422
+ };
1423
+ }
1424
+ function re(t, e) {
1425
+ return (n, o, r) => {
1426
+ if (!r)
1427
+ return !1;
1428
+ const s = n.selection;
1429
+ let i;
1430
+ if (s instanceof y)
1431
+ i = s;
1432
+ else {
1433
+ const a = ot(r, t, e);
1434
+ if (a == null)
1435
+ return !1;
1436
+ i = new y(n.doc.resolve(a));
1437
+ }
1438
+ const l = Ue(i.$headCell, t, e);
1439
+ return l ? le(
1440
+ n,
1441
+ o,
1442
+ new y(i.$anchorCell, l)
1443
+ ) : !1;
1444
+ };
1445
+ }
1446
+ function ln(t, e) {
1447
+ const n = t.state.doc, o = U(n.resolve(e));
1448
+ return o ? (t.dispatch(t.state.tr.setSelection(new y(o))), !0) : !1;
1449
+ }
1450
+ function an(t, e, n) {
1451
+ if (!E(t.state))
1452
+ return !1;
1453
+ let o = tn(n);
1454
+ const r = t.state.selection;
1455
+ if (r instanceof y) {
1456
+ o || (o = {
1457
+ width: 1,
1458
+ height: 1,
1459
+ rows: [
1460
+ R.from(
1461
+ Me(T(t.state.schema).cell, n)
1462
+ )
1463
+ ]
1464
+ });
1465
+ const s = r.$anchorCell.node(-1), i = r.$anchorCell.start(-1), l = M.get(s).rectBetween(
1466
+ r.$anchorCell.pos - i,
1467
+ r.$headCell.pos - i
1468
+ );
1469
+ return o = on(o, l.right - l.left, l.bottom - l.top), Ne(t.state, t.dispatch, i, l, o), !0;
1470
+ } else if (o) {
1471
+ const s = pe(t.state), i = s.start(-1);
1472
+ return Ne(
1473
+ t.state,
1474
+ t.dispatch,
1475
+ i,
1476
+ M.get(s.node(-1)).findCell(s.pos - i),
1477
+ o
1478
+ ), !0;
1479
+ } else
1480
+ return !1;
1481
+ }
1482
+ function cn(t, e) {
1483
+ var n;
1484
+ if (e.ctrlKey || e.metaKey)
1485
+ return;
1486
+ const o = Oe(t, e.target);
1487
+ let r;
1488
+ if (e.shiftKey && t.state.selection instanceof y)
1489
+ s(t.state.selection.$anchorCell, e), e.preventDefault();
1490
+ else if (e.shiftKey && o && (r = U(t.state.selection.$anchor)) != null && ((n = fe(t, e)) == null ? void 0 : n.pos) != r.pos)
1491
+ s(r, e), e.preventDefault();
1492
+ else if (!o)
1493
+ return;
1494
+ function s(a, c) {
1495
+ let d = fe(t, c);
1496
+ const u = _.getState(t.state) == null;
1497
+ if (!d || !ke(a, d))
1498
+ if (u)
1499
+ d = a;
1500
+ else
1501
+ return;
1502
+ const p = new y(a, d);
1503
+ if (u || !t.state.selection.eq(p)) {
1504
+ const h = t.state.tr.setSelection(p);
1505
+ u && h.setMeta(_, a.pos), t.dispatch(h);
1506
+ }
1507
+ }
1508
+ function i() {
1509
+ t.root.removeEventListener("mouseup", i), t.root.removeEventListener("dragstart", i), t.root.removeEventListener("mousemove", l), _.getState(t.state) != null && t.dispatch(t.state.tr.setMeta(_, -1));
1510
+ }
1511
+ function l(a) {
1512
+ const c = a, d = _.getState(t.state);
1513
+ let u;
1514
+ if (d != null)
1515
+ u = t.state.doc.resolve(d);
1516
+ else if (Oe(t, c.target) != o && (u = fe(t, e), !u))
1517
+ return i();
1518
+ u && s(u, c);
1519
+ }
1520
+ t.root.addEventListener("mouseup", i), t.root.addEventListener("dragstart", i), t.root.addEventListener("mousemove", l);
1521
+ }
1522
+ function ot(t, e, n) {
1523
+ if (!(t.state.selection instanceof x))
1524
+ return null;
1525
+ const { $head: o } = t.state.selection;
1526
+ for (let r = o.depth - 1; r >= 0; r--) {
1527
+ const s = o.node(r);
1528
+ if ((n < 0 ? o.index(r) : o.indexAfter(r)) != (n < 0 ? 0 : s.childCount))
1529
+ return null;
1530
+ if (s.type.spec.tableRole == "cell" || s.type.spec.tableRole == "header_cell") {
1531
+ const l = o.before(r), a = e == "vert" ? n > 0 ? "down" : "up" : n > 0 ? "right" : "left";
1532
+ return t.endOfTextblock(a) ? l : null;
1533
+ }
1534
+ }
1535
+ return null;
1536
+ }
1537
+ function Oe(t, e) {
1538
+ for (; e && e != t.dom; e = e.parentNode)
1539
+ if (e.nodeName == "TD" || e.nodeName == "TH")
1540
+ return e;
1541
+ return null;
1542
+ }
1543
+ function fe(t, e) {
1544
+ const n = t.posAtCoords({
1545
+ left: e.clientX,
1546
+ top: e.clientY
1547
+ });
1548
+ return n && n ? U(t.state.doc.resolve(n.pos)) : null;
1549
+ }
1550
+ var dn = class {
1551
+ constructor(e, n) {
1552
+ this.node = e, this.defaultCellMinWidth = n, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), this.table.style.setProperty(
1553
+ "--default-cell-min-width",
1554
+ `${n}px`
1555
+ ), this.colgroup = this.table.appendChild(document.createElement("colgroup")), ve(e, this.colgroup, this.table, n), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1556
+ }
1557
+ update(e) {
1558
+ return e.type != this.node.type ? !1 : (this.node = e, ve(
1559
+ e,
1560
+ this.colgroup,
1561
+ this.table,
1562
+ this.defaultCellMinWidth
1563
+ ), !0);
1564
+ }
1565
+ ignoreMutation(e) {
1566
+ return e.type == "attributes" && (e.target == this.table || this.colgroup.contains(e.target));
1567
+ }
1568
+ };
1569
+ function ve(t, e, n, o, r, s) {
1570
+ var i;
1571
+ let l = 0, a = !0, c = e.firstChild;
1572
+ const d = t.firstChild;
1573
+ if (d) {
1574
+ for (let u = 0, p = 0; u < d.childCount; u++) {
1575
+ const { colspan: h, colwidth: f } = d.child(u).attrs;
1576
+ for (let m = 0; m < h; m++, p++) {
1577
+ const g = r == p ? s : f && f[m], w = g ? g + "px" : "";
1578
+ if (l += g || o, g || (a = !1), c)
1579
+ c.style.width != w && (c.style.width = w), c = c.nextSibling;
1580
+ else {
1581
+ const b = document.createElement("col");
1582
+ b.style.width = w, e.appendChild(b);
1583
+ }
1584
+ }
1585
+ }
1586
+ for (; c; ) {
1587
+ const u = c.nextSibling;
1588
+ (i = c.parentNode) == null || i.removeChild(c), c = u;
1589
+ }
1590
+ a ? (n.style.width = l + "px", n.style.minWidth = "") : (n.style.width = "", n.style.minWidth = l + "px");
1591
+ }
1592
+ }
1593
+ var L = new D(
1594
+ "tableColumnResizing"
1595
+ );
1596
+ function un({
1597
+ handleWidth: t = 5,
1598
+ cellMinWidth: e = 25,
1599
+ defaultCellMinWidth: n = 100,
1600
+ View: o = dn,
1601
+ lastColumnResizable: r = !0
1602
+ } = {}) {
1603
+ const s = new B({
1604
+ key: L,
1605
+ state: {
1606
+ init(i, l) {
1607
+ var a, c;
1608
+ const d = (c = (a = s.spec) == null ? void 0 : a.props) == null ? void 0 : c.nodeViews, u = T(l.schema).table.name;
1609
+ return o && d && (d[u] = (p, h) => new o(p, n, h)), new pn(-1, !1);
1610
+ },
1611
+ apply(i, l) {
1612
+ return l.apply(i);
1613
+ }
1614
+ },
1615
+ props: {
1616
+ attributes: (i) => {
1617
+ const l = L.getState(i);
1618
+ return l && l.activeHandle > -1 ? { class: "resize-cursor" } : {};
1619
+ },
1620
+ handleDOMEvents: {
1621
+ mousemove: (i, l) => {
1622
+ hn(i, l, t, r);
1623
+ },
1624
+ mouseleave: (i) => {
1625
+ fn(i);
1626
+ },
1627
+ mousedown: (i, l) => {
1628
+ mn(i, l, e, n);
1629
+ }
1630
+ },
1631
+ decorations: (i) => {
1632
+ const l = L.getState(i);
1633
+ if (l && l.activeHandle > -1)
1634
+ return Cn(i, l.activeHandle);
1635
+ },
1636
+ nodeViews: {}
1637
+ }
1638
+ });
1639
+ return s;
1640
+ }
1641
+ var pn = class ae {
1642
+ constructor(e, n) {
1643
+ this.activeHandle = e, this.dragging = n;
1644
+ }
1645
+ apply(e) {
1646
+ const n = this, o = e.getMeta(L);
1647
+ if (o && o.setHandle != null)
1648
+ return new ae(o.setHandle, !1);
1649
+ if (o && o.setDragging !== void 0)
1650
+ return new ae(n.activeHandle, o.setDragging);
1651
+ if (n.activeHandle > -1 && e.docChanged) {
1652
+ let r = e.mapping.map(n.activeHandle, -1);
1653
+ return Ce(e.doc.resolve(r)) || (r = -1), new ae(r, n.dragging);
1654
+ }
1655
+ return n;
1656
+ }
1657
+ };
1658
+ function hn(t, e, n, o) {
1659
+ const r = L.getState(t.state);
1660
+ if (r && !r.dragging) {
1661
+ const s = bn(e.target);
1662
+ let i = -1;
1663
+ if (s) {
1664
+ const { left: l, right: a } = s.getBoundingClientRect();
1665
+ e.clientX - l <= n ? i = Pe(t, e, "left", n) : a - e.clientX <= n && (i = Pe(t, e, "right", n));
1666
+ }
1667
+ if (i != r.activeHandle) {
1668
+ if (!o && i !== -1) {
1669
+ const l = t.state.doc.resolve(i), a = l.node(-1), c = M.get(a), d = l.start(-1);
1670
+ if (c.colCount(l.pos - d) + l.nodeAfter.attrs.colspan - 1 == c.width - 1)
1671
+ return;
1672
+ }
1673
+ rt(t, i);
1674
+ }
1675
+ }
1676
+ }
1677
+ function fn(t) {
1678
+ const e = L.getState(t.state);
1679
+ e && e.activeHandle > -1 && !e.dragging && rt(t, -1);
1680
+ }
1681
+ function mn(t, e, n, o) {
1682
+ var r;
1683
+ const s = (r = t.dom.ownerDocument.defaultView) != null ? r : window, i = L.getState(t.state);
1684
+ if (!i || i.activeHandle == -1 || i.dragging)
1685
+ return !1;
1686
+ const l = t.state.doc.nodeAt(i.activeHandle), a = gn(t, i.activeHandle, l.attrs);
1687
+ t.dispatch(
1688
+ t.state.tr.setMeta(L, {
1689
+ setDragging: { startX: e.clientX, startWidth: a }
1690
+ })
1691
+ );
1692
+ function c(u) {
1693
+ s.removeEventListener("mouseup", c), s.removeEventListener("mousemove", d);
1694
+ const p = L.getState(t.state);
1695
+ p != null && p.dragging && (wn(
1696
+ t,
1697
+ p.activeHandle,
1698
+ ze(p.dragging, u, n)
1699
+ ), t.dispatch(
1700
+ t.state.tr.setMeta(L, { setDragging: null })
1701
+ ));
1702
+ }
1703
+ function d(u) {
1704
+ if (!u.which)
1705
+ return c(u);
1706
+ const p = L.getState(t.state);
1707
+ if (p && p.dragging) {
1708
+ const h = ze(p.dragging, u, n);
1709
+ $e(
1710
+ t,
1711
+ p.activeHandle,
1712
+ h,
1713
+ o
1714
+ );
1715
+ }
1716
+ }
1717
+ return $e(
1718
+ t,
1719
+ i.activeHandle,
1720
+ a,
1721
+ o
1722
+ ), s.addEventListener("mouseup", c), s.addEventListener("mousemove", d), e.preventDefault(), !0;
1723
+ }
1724
+ function gn(t, e, { colspan: n, colwidth: o }) {
1725
+ const r = o && o[o.length - 1];
1726
+ if (r)
1727
+ return r;
1728
+ const s = t.domAtPos(e);
1729
+ let l = s.node.childNodes[s.offset].offsetWidth, a = n;
1730
+ if (o)
1731
+ for (let c = 0; c < n; c++)
1732
+ o[c] && (l -= o[c], a--);
1733
+ return l / a;
1734
+ }
1735
+ function bn(t) {
1736
+ for (; t && t.nodeName != "TD" && t.nodeName != "TH"; )
1737
+ t = t.classList && t.classList.contains("ProseMirror") ? null : t.parentNode;
1738
+ return t;
1739
+ }
1740
+ function Pe(t, e, n, o) {
1741
+ const r = n == "right" ? -o : o, s = t.posAtCoords({
1742
+ left: e.clientX + r,
1743
+ top: e.clientY
1744
+ });
1745
+ if (!s)
1746
+ return -1;
1747
+ const { pos: i } = s, l = U(t.state.doc.resolve(i));
1748
+ if (!l)
1749
+ return -1;
1750
+ if (n == "right")
1751
+ return l.pos;
1752
+ const a = M.get(l.node(-1)), c = l.start(-1), d = a.map.indexOf(l.pos - c);
1753
+ return d % a.width == 0 ? -1 : c + a.map[d - 1];
1754
+ }
1755
+ function ze(t, e, n) {
1756
+ const o = e.clientX - t.startX;
1757
+ return Math.max(n, t.startWidth + o);
1758
+ }
1759
+ function rt(t, e) {
1760
+ t.dispatch(
1761
+ t.state.tr.setMeta(L, { setHandle: e })
1762
+ );
1763
+ }
1764
+ function wn(t, e, n) {
1765
+ const o = t.state.doc.resolve(e), r = o.node(-1), s = M.get(r), i = o.start(-1), l = s.colCount(o.pos - i) + o.nodeAfter.attrs.colspan - 1, a = t.state.tr;
1766
+ for (let c = 0; c < s.height; c++) {
1767
+ const d = c * s.width + l;
1768
+ if (c && s.map[d] == s.map[d - s.width])
1769
+ continue;
1770
+ const u = s.map[d], p = r.nodeAt(u).attrs, h = p.colspan == 1 ? 0 : l - s.colCount(u);
1771
+ if (p.colwidth && p.colwidth[h] == n)
1772
+ continue;
1773
+ const f = p.colwidth ? p.colwidth.slice() : yn(p.colspan);
1774
+ f[h] = n, a.setNodeMarkup(i + u, null, { ...p, colwidth: f });
1775
+ }
1776
+ a.docChanged && t.dispatch(a);
1777
+ }
1778
+ function $e(t, e, n, o) {
1779
+ const r = t.state.doc.resolve(e), s = r.node(-1), i = r.start(-1), l = M.get(s).colCount(r.pos - i) + r.nodeAfter.attrs.colspan - 1;
1780
+ let a = t.domAtPos(r.start(-1)).node;
1781
+ for (; a && a.nodeName != "TABLE"; )
1782
+ a = a.parentNode;
1783
+ a && ve(
1784
+ s,
1785
+ a.firstChild,
1786
+ a,
1787
+ o,
1788
+ l,
1789
+ n
1790
+ );
1791
+ }
1792
+ function yn(t) {
1793
+ return Array(t).fill(0);
1794
+ }
1795
+ function Cn(t, e) {
1796
+ var n;
1797
+ const o = [], r = t.doc.resolve(e), s = r.node(-1);
1798
+ if (!s)
1799
+ return F.empty;
1800
+ const i = M.get(s), l = r.start(-1), a = i.colCount(r.pos - l) + r.nodeAfter.attrs.colspan - 1;
1801
+ for (let c = 0; c < i.height; c++) {
1802
+ const d = a + c * i.width;
1803
+ if ((a == i.width - 1 || i.map[d] != i.map[d + 1]) && (c == 0 || i.map[d] != i.map[d - i.width])) {
1804
+ const u = i.map[d], p = l + u + s.nodeAt(u).nodeSize - 1, h = document.createElement("div");
1805
+ h.className = "column-resize-handle", (n = L.getState(t)) != null && n.dragging && o.push(
1806
+ X.node(
1807
+ l + u,
1808
+ l + u + s.nodeAt(u).nodeSize,
1809
+ {
1810
+ class: "column-resize-dragging"
1811
+ }
1812
+ )
1813
+ ), o.push(X.widget(p, h));
1814
+ }
1815
+ }
1816
+ return F.create(t.doc, o);
1817
+ }
1818
+ function Mn({
1819
+ allowTableNodeSelection: t = !1
1820
+ } = {}) {
1821
+ return new B({
1822
+ key: _,
1823
+ // This piece of state is used to remember when a mouse-drag
1824
+ // cell-selection is happening, so that it can continue even as
1825
+ // transactions (which might move its anchor cell) come in.
1826
+ state: {
1827
+ init() {
1828
+ return null;
1829
+ },
1830
+ apply(e, n) {
1831
+ const o = e.getMeta(_);
1832
+ if (o != null)
1833
+ return o == -1 ? null : o;
1834
+ if (n == null || !e.docChanged)
1835
+ return n;
1836
+ const { deleted: r, pos: s } = e.mapping.mapResult(n);
1837
+ return r ? null : s;
1838
+ }
1839
+ },
1840
+ props: {
1841
+ decorations: Nt,
1842
+ handleDOMEvents: {
1843
+ mousedown: cn
1844
+ },
1845
+ createSelectionBetween(e) {
1846
+ return _.getState(e.state) != null ? e.state.selection : null;
1847
+ },
1848
+ handleTripleClick: ln,
1849
+ handleKeyDown: sn,
1850
+ handlePaste: an
1851
+ },
1852
+ appendTransaction(e, n, o) {
1853
+ return zt(
1854
+ o,
1855
+ et(o, n),
1856
+ t
1857
+ );
1858
+ }
1859
+ });
1860
+ }
1861
+ function Ae(t, e) {
1862
+ return e ? ["width", `${Math.max(e, t)}px`] : ["min-width", `${t}px`];
1863
+ }
1864
+ function _e(t, e, n, o, r, s) {
1865
+ var i;
1866
+ let l = 0, a = !0, c = e.firstChild;
1867
+ const d = t.firstChild;
1868
+ if (d !== null)
1869
+ for (let u = 0, p = 0; u < d.childCount; u += 1) {
1870
+ const { colspan: h, colwidth: f } = d.child(u).attrs;
1871
+ for (let m = 0; m < h; m += 1, p += 1) {
1872
+ const g = r === p ? s : f && f[m], w = g ? `${g}px` : "";
1873
+ if (l += g || o, g || (a = !1), c) {
1874
+ if (c.style.width !== w) {
1875
+ const [b, P] = Ae(o, g);
1876
+ c.style.setProperty(b, P);
1877
+ }
1878
+ c = c.nextSibling;
1879
+ } else {
1880
+ const b = document.createElement("col"), [P, Y] = Ae(o, g);
1881
+ b.style.setProperty(P, Y), e.appendChild(b);
1882
+ }
1883
+ }
1884
+ }
1885
+ for (; c; ) {
1886
+ const u = c.nextSibling;
1887
+ (i = c.parentNode) === null || i === void 0 || i.removeChild(c), c = u;
1888
+ }
1889
+ a ? (n.style.width = `${l}px`, n.style.minWidth = "") : (n.style.width = "", n.style.minWidth = `${l}px`);
1890
+ }
1891
+ class vn {
1892
+ constructor(e, n) {
1893
+ this.node = e, this.cellMinWidth = n, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), this.colgroup = this.table.appendChild(document.createElement("colgroup")), _e(e, this.colgroup, this.table, n), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1894
+ }
1895
+ update(e) {
1896
+ return e.type !== this.node.type ? !1 : (this.node = e, _e(e, this.colgroup, this.table, this.cellMinWidth), !0);
1897
+ }
1898
+ ignoreMutation(e) {
1899
+ return e.type === "attributes" && (e.target === this.table || this.colgroup.contains(e.target));
1900
+ }
1901
+ }
1902
+ function An(t, e, n, o) {
1903
+ let r = 0, s = !0;
1904
+ const i = [], l = t.firstChild;
1905
+ if (!l)
1906
+ return {};
1907
+ for (let u = 0, p = 0; u < l.childCount; u += 1) {
1908
+ const { colspan: h, colwidth: f } = l.child(u).attrs;
1909
+ for (let m = 0; m < h; m += 1, p += 1) {
1910
+ const g = n === p ? o : f && f[m];
1911
+ r += g || e, g || (s = !1);
1912
+ const [w, b] = Ae(e, g);
1913
+ i.push([
1914
+ "col",
1915
+ { style: `${w}: ${b}` }
1916
+ ]);
1917
+ }
1918
+ }
1919
+ const a = s ? `${r}px` : "", c = s ? "" : `${r}px`;
1920
+ return { colgroup: ["colgroup", {}, ...i], tableWidth: a, tableMinWidth: c };
1921
+ }
1922
+ function Be(t, e) {
1923
+ return t.createAndFill();
1924
+ }
1925
+ function kn(t) {
1926
+ if (t.cached.tableNodeTypes)
1927
+ return t.cached.tableNodeTypes;
1928
+ const e = {};
1929
+ return Object.keys(t.nodes).forEach((n) => {
1930
+ const o = t.nodes[n];
1931
+ o.spec.tableRole && (e[o.spec.tableRole] = o);
1932
+ }), t.cached.tableNodeTypes = e, e;
1933
+ }
1934
+ function Tn(t, e, n, o, r) {
1935
+ const s = kn(t), i = [], l = [];
1936
+ for (let c = 0; c < n; c += 1) {
1937
+ const d = Be(s.cell);
1938
+ if (d && l.push(d), o) {
1939
+ const u = Be(s.header_cell);
1940
+ u && i.push(u);
1941
+ }
1942
+ }
1943
+ const a = [];
1944
+ for (let c = 0; c < e; c += 1)
1945
+ a.push(s.row.createChecked(null, o && c === 0 ? i : l));
1946
+ return s.table.createChecked(null, a);
1947
+ }
1948
+ function Sn(t) {
1949
+ return t instanceof y;
1950
+ }
1951
+ const se = ({ editor: t }) => {
1952
+ const { selection: e } = t.state;
1953
+ if (!Sn(e))
1954
+ return !1;
1955
+ let n = 0;
1956
+ const o = pt(e.ranges[0].$from, (s) => s.type.name === "table");
1957
+ return o == null || o.node.descendants((s) => {
1958
+ if (s.type.name === "table")
1959
+ return !1;
1960
+ ["tableCell", "tableHeader"].includes(s.type.name) && (n += 1);
1961
+ }), n === e.ranges.length ? (t.commands.deleteTable(), !0) : !1;
1962
+ }, xn = k.create({
1963
+ name: "table",
1964
+ // @ts-ignore
9
1965
  addOptions() {
10
1966
  return {
11
- emptyEditorClass: "is-editor-empty",
12
- emptyNodeClass: "is-empty",
13
- placeholder: "Write something …",
14
- showOnlyWhenEditable: !0,
15
- showOnlyCurrent: !0,
16
- includeChildren: !1
1967
+ HTMLAttributes: {},
1968
+ resizable: !1,
1969
+ handleWidth: 5,
1970
+ cellMinWidth: 25,
1971
+ // TODO: fix
1972
+ View: vn,
1973
+ lastColumnResizable: !0,
1974
+ allowTableNodeSelection: !1
17
1975
  };
18
1976
  },
19
- addProseMirrorPlugins() {
1977
+ content: "tableRow+",
1978
+ tableRole: "table",
1979
+ isolating: !0,
1980
+ group: "block",
1981
+ parseHTML() {
1982
+ return [{ tag: "table" }];
1983
+ },
1984
+ renderHTML({ node: t, HTMLAttributes: e }) {
1985
+ const { colgroup: n, tableWidth: o, tableMinWidth: r } = An(t, this.options.cellMinWidth);
20
1986
  return [
21
- new H({
22
- key: new P("placeholder"),
23
- props: {
24
- decorations: ({ doc: t, selection: e }) => {
25
- const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: r } = e, s = [];
26
- if (!n)
27
- return null;
28
- const i = this.editor.isEmpty;
29
- return t.descendants((o, a) => {
30
- const l = r >= a && r <= a + o.nodeSize, u = !o.isLeaf && ie(o);
31
- if ((l || !this.options.showOnlyCurrent) && u) {
32
- const p = [this.options.emptyNodeClass];
33
- i && p.push(this.options.emptyEditorClass);
34
- const d = F.node(a, a + o.nodeSize, {
35
- class: p.join(" "),
36
- "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
37
- editor: this.editor,
38
- node: o,
39
- pos: a,
40
- hasAnchor: l
41
- }) : this.options.placeholder
42
- });
43
- s.push(d);
44
- }
45
- return this.options.includeChildren;
46
- }), B.create(t, s);
47
- }
1987
+ "table",
1988
+ v(this.options.HTMLAttributes, e, {
1989
+ style: o ? `width: ${o}` : `min-width: ${r}`
1990
+ }),
1991
+ n,
1992
+ ["tbody", 0]
1993
+ ];
1994
+ },
1995
+ addCommands() {
1996
+ return {
1997
+ insertTable: ({ rows: t = 3, cols: e = 3, withHeaderRow: n = !0 } = {}) => ({ tr: o, dispatch: r, editor: s }) => {
1998
+ const i = Tn(s.schema, t, e, n);
1999
+ if (r) {
2000
+ const l = o.selection.from + 1;
2001
+ o.replaceSelectionWith(i).scrollIntoView().setSelection(x.near(o.doc.resolve(l)));
2002
+ }
2003
+ return !0;
2004
+ },
2005
+ addColumnBefore: () => ({ state: t, dispatch: e }) => Bt(t, e),
2006
+ addColumnAfter: () => ({ state: t, dispatch: e }) => Dt(t, e),
2007
+ deleteColumn: () => ({ state: t, dispatch: e }) => Vt(t, e),
2008
+ addRowBefore: () => ({ state: t, dispatch: e }) => Kt(t, e),
2009
+ addRowAfter: () => ({ state: t, dispatch: e }) => jt(t, e),
2010
+ deleteRow: () => ({ state: t, dispatch: e }) => Xt(t, e),
2011
+ deleteTable: () => ({ state: t, dispatch: e }) => en(t, e),
2012
+ mergeCells: () => ({ state: t, dispatch: e }) => xe(t, e),
2013
+ splitCell: () => ({ state: t, dispatch: e }) => Le(t, e),
2014
+ toggleHeaderColumn: () => ({ state: t, dispatch: e }) => Q("column")(t, e),
2015
+ toggleHeaderRow: () => ({ state: t, dispatch: e }) => Q("row")(t, e),
2016
+ toggleHeaderCell: () => ({ state: t, dispatch: e }) => Zt(t, e),
2017
+ mergeOrSplit: () => ({ state: t, dispatch: e }) => xe(t, e) ? !0 : Le(t, e),
2018
+ setCellAttribute: (t, e) => ({ state: n, dispatch: o }) => Ut(t, e)(n, o),
2019
+ goToNextCell: () => ({ state: t, dispatch: e }) => He(1)(t, e),
2020
+ goToPreviousCell: () => ({ state: t, dispatch: e }) => He(-1)(t, e),
2021
+ fixTables: () => ({ state: t, dispatch: e }) => (e && et(t), !0),
2022
+ setCellSelection: (t) => ({ tr: e, dispatch: n }) => {
2023
+ if (n) {
2024
+ const o = y.create(e.doc, t.anchorCell, t.headCell);
2025
+ e.setSelection(o);
48
2026
  }
2027
+ return !0;
2028
+ }
2029
+ };
2030
+ },
2031
+ addKeyboardShortcuts() {
2032
+ return {
2033
+ Tab: () => this.editor.commands.goToNextCell() ? !0 : this.editor.can().addRowAfter() ? this.editor.chain().addRowAfter().goToNextCell().run() : !1,
2034
+ "Shift-Tab": () => this.editor.commands.goToPreviousCell(),
2035
+ Backspace: se,
2036
+ "Mod-Backspace": se,
2037
+ Delete: se,
2038
+ "Mod-Delete": se
2039
+ };
2040
+ },
2041
+ addProseMirrorPlugins() {
2042
+ return [
2043
+ ...this.options.resizable && this.editor.isEditable ? [
2044
+ un({
2045
+ handleWidth: this.options.handleWidth,
2046
+ cellMinWidth: this.options.cellMinWidth,
2047
+ defaultCellMinWidth: this.options.cellMinWidth,
2048
+ View: this.options.View,
2049
+ lastColumnResizable: this.options.lastColumnResizable
2050
+ })
2051
+ ] : [],
2052
+ Mn({
2053
+ allowTableNodeSelection: this.options.allowTableNodeSelection
49
2054
  })
50
2055
  ];
2056
+ },
2057
+ extendNodeSchema(t) {
2058
+ const e = {
2059
+ name: t.name,
2060
+ options: t.options,
2061
+ storage: t.storage
2062
+ };
2063
+ return {
2064
+ tableRole: Ge(Je(t, "tableRole", e))
2065
+ };
51
2066
  }
52
- }), ve = /^\s*>\s$/, be = v.create({
2067
+ }), Ln = /^\s*>\s$/, Rn = k.create({
53
2068
  name: "blockquote",
54
2069
  addOptions() {
55
2070
  return {
@@ -65,7 +2080,7 @@ const ye = x.create({
65
2080
  ];
66
2081
  },
67
2082
  renderHTML({ HTMLAttributes: t }) {
68
- return ["blockquote", y(this.options.HTMLAttributes, t), 0];
2083
+ return ["blockquote", v(this.options.HTMLAttributes, t), 0];
69
2084
  },
70
2085
  addCommands() {
71
2086
  return {
@@ -81,13 +2096,13 @@ const ye = x.create({
81
2096
  },
82
2097
  addInputRules() {
83
2098
  return [
84
- E({
85
- find: ve,
2099
+ G({
2100
+ find: Ln,
86
2101
  type: this.type
87
2102
  })
88
2103
  ];
89
2104
  }
90
- }), Me = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, ke = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, Te = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, we = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, Ae = R.create({
2105
+ }), Hn = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, En = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, In = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, Nn = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, On = ee.create({
91
2106
  name: "bold",
92
2107
  addOptions() {
93
2108
  return {
@@ -114,7 +2129,7 @@ const ye = x.create({
114
2129
  ];
115
2130
  },
116
2131
  renderHTML({ HTMLAttributes: t }) {
117
- return ["strong", y(this.options.HTMLAttributes, t), 0];
2132
+ return ["strong", v(this.options.HTMLAttributes, t), 0];
118
2133
  },
119
2134
  addCommands() {
120
2135
  return {
@@ -131,29 +2146,29 @@ const ye = x.create({
131
2146
  },
132
2147
  addInputRules() {
133
2148
  return [
134
- A({
135
- find: Me,
2149
+ K({
2150
+ find: Hn,
136
2151
  type: this.type
137
2152
  }),
138
- A({
139
- find: Te,
2153
+ K({
2154
+ find: In,
140
2155
  type: this.type
141
2156
  })
142
2157
  ];
143
2158
  },
144
2159
  addPasteRules() {
145
2160
  return [
146
- C({
147
- find: ke,
2161
+ j({
2162
+ find: En,
148
2163
  type: this.type
149
2164
  }),
150
- C({
151
- find: we,
2165
+ j({
2166
+ find: Nn,
152
2167
  type: this.type
153
2168
  })
154
2169
  ];
155
2170
  }
156
- }), Ce = "listItem", q = "textStyle", J = /^\s*([-+*])\s$/, Le = v.create({
2171
+ }), Pn = "listItem", De = "textStyle", We = /^\s*([-+*])\s$/, zn = k.create({
157
2172
  name: "bulletList",
158
2173
  addOptions() {
159
2174
  return {
@@ -173,11 +2188,11 @@ const ye = x.create({
173
2188
  ];
174
2189
  },
175
2190
  renderHTML({ HTMLAttributes: t }) {
176
- return ["ul", y(this.options.HTMLAttributes, t), 0];
2191
+ return ["ul", v(this.options.HTMLAttributes, t), 0];
177
2192
  },
178
2193
  addCommands() {
179
2194
  return {
180
- toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Ce, this.editor.getAttributes(q)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
2195
+ toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Pn, this.editor.getAttributes(De)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
181
2196
  };
182
2197
  },
183
2198
  addKeyboardShortcuts() {
@@ -186,22 +2201,22 @@ const ye = x.create({
186
2201
  };
187
2202
  },
188
2203
  addInputRules() {
189
- let t = E({
190
- find: J,
2204
+ let t = G({
2205
+ find: We,
191
2206
  type: this.type
192
2207
  });
193
- return (this.options.keepMarks || this.options.keepAttributes) && (t = E({
194
- find: J,
2208
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = G({
2209
+ find: We,
195
2210
  type: this.type,
196
2211
  keepMarks: this.options.keepMarks,
197
2212
  keepAttributes: this.options.keepAttributes,
198
- getAttributes: () => this.editor.getAttributes(q),
2213
+ getAttributes: () => this.editor.getAttributes(De),
199
2214
  editor: this.editor
200
2215
  })), [
201
2216
  t
202
2217
  ];
203
2218
  }
204
- }), Ie = new RegExp("(?<!`)`([^`]+)`(?!`)"), xe = new RegExp("(?<!`)`([^`]+)`(?!`)", "g"), He = R.create({
2219
+ }), $n = new RegExp("(?<!`)`([^`]+)`(?!`)"), _n = new RegExp("(?<!`)`([^`]+)`(?!`)", "g"), Bn = ee.create({
205
2220
  name: "code",
206
2221
  addOptions() {
207
2222
  return {
@@ -217,7 +2232,7 @@ const ye = x.create({
217
2232
  ];
218
2233
  },
219
2234
  renderHTML({ HTMLAttributes: t }) {
220
- return ["code", y(this.options.HTMLAttributes, t), 0];
2235
+ return ["code", v(this.options.HTMLAttributes, t), 0];
221
2236
  },
222
2237
  addCommands() {
223
2238
  return {
@@ -233,21 +2248,21 @@ const ye = x.create({
233
2248
  },
234
2249
  addInputRules() {
235
2250
  return [
236
- A({
237
- find: Ie,
2251
+ K({
2252
+ find: $n,
238
2253
  type: this.type
239
2254
  })
240
2255
  ];
241
2256
  },
242
2257
  addPasteRules() {
243
2258
  return [
244
- C({
245
- find: xe,
2259
+ j({
2260
+ find: _n,
246
2261
  type: this.type
247
2262
  })
248
2263
  ];
249
2264
  }
250
- }), Se = /^```([a-z]+)?[\s\n]$/, Ee = /^~~~([a-z]+)?[\s\n]$/, Oe = v.create({
2265
+ }), Dn = /^```([a-z]+)?[\s\n]$/, Wn = /^~~~([a-z]+)?[\s\n]$/, Vn = k.create({
251
2266
  name: "codeBlock",
252
2267
  addOptions() {
253
2268
  return {
@@ -269,8 +2284,8 @@ const ye = x.create({
269
2284
  default: this.options.defaultLanguage,
270
2285
  parseHTML: (t) => {
271
2286
  var e;
272
- const { languageClassPrefix: n } = this.options, i = [...((e = t.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((o) => o.startsWith(n)).map((o) => o.replace(n, ""))[0];
273
- return i || null;
2287
+ const { languageClassPrefix: n } = this.options, s = [...((e = t.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((i) => i.startsWith(n)).map((i) => i.replace(n, ""))[0];
2288
+ return s || null;
274
2289
  },
275
2290
  rendered: !1
276
2291
  }
@@ -287,7 +2302,7 @@ const ye = x.create({
287
2302
  renderHTML({ node: t, HTMLAttributes: e }) {
288
2303
  return [
289
2304
  "pre",
290
- y(this.options.HTMLAttributes, e),
2305
+ v(this.options.HTMLAttributes, e),
291
2306
  [
292
2307
  "code",
293
2308
  {
@@ -315,37 +2330,37 @@ const ye = x.create({
315
2330
  Enter: ({ editor: t }) => {
316
2331
  if (!this.options.exitOnTripleEnter)
317
2332
  return !1;
318
- const { state: e } = t, { selection: n } = e, { $from: r, empty: s } = n;
319
- if (!s || r.parent.type !== this.type)
2333
+ const { state: e } = t, { selection: n } = e, { $from: o, empty: r } = n;
2334
+ if (!r || o.parent.type !== this.type)
320
2335
  return !1;
321
- const i = r.parentOffset === r.parent.nodeSize - 2, o = r.parent.textContent.endsWith(`
2336
+ const s = o.parentOffset === o.parent.nodeSize - 2, i = o.parent.textContent.endsWith(`
322
2337
 
323
2338
  `);
324
- return !i || !o ? !1 : t.chain().command(({ tr: a }) => (a.delete(r.pos - 2, r.pos), !0)).exitCode().run();
2339
+ return !s || !i ? !1 : t.chain().command(({ tr: l }) => (l.delete(o.pos - 2, o.pos), !0)).exitCode().run();
325
2340
  },
326
2341
  // exit node on arrow down
327
2342
  ArrowDown: ({ editor: t }) => {
328
2343
  if (!this.options.exitOnArrowDown)
329
2344
  return !1;
330
- const { state: e } = t, { selection: n, doc: r } = e, { $from: s, empty: i } = n;
331
- if (!i || s.parent.type !== this.type || !(s.parentOffset === s.parent.nodeSize - 2))
2345
+ const { state: e } = t, { selection: n, doc: o } = e, { $from: r, empty: s } = n;
2346
+ if (!s || r.parent.type !== this.type || !(r.parentOffset === r.parent.nodeSize - 2))
332
2347
  return !1;
333
- const a = s.after();
334
- return a === void 0 ? !1 : r.nodeAt(a) ? t.commands.command(({ tr: u }) => (u.setSelection(O.near(r.resolve(a))), !0)) : t.commands.exitCode();
2348
+ const l = r.after();
2349
+ return l === void 0 ? !1 : o.nodeAt(l) ? t.commands.command(({ tr: c }) => (c.setSelection(S.near(o.resolve(l))), !0)) : t.commands.exitCode();
335
2350
  }
336
2351
  };
337
2352
  },
338
2353
  addInputRules() {
339
2354
  return [
340
- V({
341
- find: Se,
2355
+ be({
2356
+ find: Dn,
342
2357
  type: this.type,
343
2358
  getAttributes: (t) => ({
344
2359
  language: t[1]
345
2360
  })
346
2361
  }),
347
- V({
348
- find: Ee,
2362
+ be({
2363
+ find: Wn,
349
2364
  type: this.type,
350
2365
  getAttributes: (t) => ({
351
2366
  language: t[1]
@@ -357,43 +2372,43 @@ const ye = x.create({
357
2372
  return [
358
2373
  // this plugin creates a code block for pasted content from VS Code
359
2374
  // we can also detect the copied code language
360
- new H({
361
- key: new P("codeBlockVSCodeHandler"),
2375
+ new B({
2376
+ key: new D("codeBlockVSCodeHandler"),
362
2377
  props: {
363
2378
  handlePaste: (t, e) => {
364
2379
  if (!e.clipboardData || this.editor.isActive(this.type.name))
365
2380
  return !1;
366
- const n = e.clipboardData.getData("text/plain"), r = e.clipboardData.getData("vscode-editor-data"), s = r ? JSON.parse(r) : void 0, i = s == null ? void 0 : s.mode;
367
- if (!n || !i)
2381
+ const n = e.clipboardData.getData("text/plain"), o = e.clipboardData.getData("vscode-editor-data"), r = o ? JSON.parse(o) : void 0, s = r == null ? void 0 : r.mode;
2382
+ if (!n || !s)
368
2383
  return !1;
369
- const { tr: o, schema: a } = t.state, l = a.text(n.replace(/\r\n?/g, `
2384
+ const { tr: i, schema: l } = t.state, a = l.text(n.replace(/\r\n?/g, `
370
2385
  `));
371
- return o.replaceSelectionWith(this.type.create({ language: i }, l)), o.selection.$from.parent.type !== this.type && o.setSelection(I.near(o.doc.resolve(Math.max(0, o.selection.from - 2)))), o.setMeta("paste", !0), t.dispatch(o), !0;
2386
+ return i.replaceSelectionWith(this.type.create({ language: s }, a)), i.selection.$from.parent.type !== this.type && i.setSelection(x.near(i.doc.resolve(Math.max(0, i.selection.from - 2)))), i.setMeta("paste", !0), t.dispatch(i), !0;
372
2387
  }
373
2388
  }
374
2389
  })
375
2390
  ];
376
2391
  }
377
- }), Pe = v.create({
2392
+ }), Fn = k.create({
378
2393
  name: "doc",
379
2394
  topNode: !0,
380
2395
  content: "block+"
381
2396
  });
382
- function Re(t = {}) {
383
- return new H({
2397
+ function Kn(t = {}) {
2398
+ return new B({
384
2399
  view(e) {
385
- return new _e(e, t);
2400
+ return new jn(e, t);
386
2401
  }
387
2402
  });
388
2403
  }
389
- class _e {
2404
+ class jn {
390
2405
  constructor(e, n) {
391
- var r;
392
- this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = n.width) !== null && r !== void 0 ? r : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((s) => {
393
- let i = (o) => {
394
- this[s](o);
2406
+ var o;
2407
+ this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (o = n.width) !== null && o !== void 0 ? o : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((r) => {
2408
+ let s = (i) => {
2409
+ this[r](i);
395
2410
  };
396
- return e.dom.addEventListener(s, i), { name: s, handler: i };
2411
+ return e.dom.addEventListener(r, s), { name: r, handler: s };
397
2412
  });
398
2413
  }
399
2414
  destroy() {
@@ -406,31 +2421,31 @@ class _e {
406
2421
  e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
407
2422
  }
408
2423
  updateOverlay() {
409
- let e = this.editorView.state.doc.resolve(this.cursorPos), n = !e.parent.inlineContent, r;
2424
+ let e = this.editorView.state.doc.resolve(this.cursorPos), n = !e.parent.inlineContent, o;
410
2425
  if (n) {
411
- let a = e.nodeBefore, l = e.nodeAfter;
412
- if (a || l) {
413
- let u = this.editorView.nodeDOM(this.cursorPos - (a ? a.nodeSize : 0));
414
- if (u) {
415
- let p = u.getBoundingClientRect(), d = a ? p.bottom : p.top;
416
- a && l && (d = (d + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2), r = { left: p.left, right: p.right, top: d - this.width / 2, bottom: d + this.width / 2 };
2426
+ let l = e.nodeBefore, a = e.nodeAfter;
2427
+ if (l || a) {
2428
+ let c = this.editorView.nodeDOM(this.cursorPos - (l ? l.nodeSize : 0));
2429
+ if (c) {
2430
+ let d = c.getBoundingClientRect(), u = l ? d.bottom : d.top;
2431
+ l && a && (u = (u + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2), o = { left: d.left, right: d.right, top: u - this.width / 2, bottom: u + this.width / 2 };
417
2432
  }
418
2433
  }
419
2434
  }
420
- if (!r) {
421
- let a = this.editorView.coordsAtPos(this.cursorPos);
422
- r = { left: a.left - this.width / 2, right: a.left + this.width / 2, top: a.top, bottom: a.bottom };
2435
+ if (!o) {
2436
+ let l = this.editorView.coordsAtPos(this.cursorPos);
2437
+ o = { left: l.left - this.width / 2, right: l.left + this.width / 2, top: l.top, bottom: l.bottom };
423
2438
  }
424
- let s = this.editorView.dom.offsetParent;
425
- this.element || (this.element = s.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", n), this.element.classList.toggle("prosemirror-dropcursor-inline", !n);
426
- let i, o;
427
- if (!s || s == document.body && getComputedStyle(s).position == "static")
428
- i = -pageXOffset, o = -pageYOffset;
2439
+ let r = this.editorView.dom.offsetParent;
2440
+ this.element || (this.element = r.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", n), this.element.classList.toggle("prosemirror-dropcursor-inline", !n);
2441
+ let s, i;
2442
+ if (!r || r == document.body && getComputedStyle(r).position == "static")
2443
+ s = -pageXOffset, i = -pageYOffset;
429
2444
  else {
430
- let a = s.getBoundingClientRect();
431
- i = a.left - s.scrollLeft, o = a.top - s.scrollTop;
2445
+ let l = r.getBoundingClientRect();
2446
+ s = l.left - r.scrollLeft, i = l.top - r.scrollTop;
432
2447
  }
433
- this.element.style.left = r.left - i + "px", this.element.style.top = r.top - o + "px", this.element.style.width = r.right - r.left + "px", this.element.style.height = r.bottom - r.top + "px";
2448
+ this.element.style.left = o.left - s + "px", this.element.style.top = o.top - i + "px", this.element.style.width = o.right - o.left + "px", this.element.style.height = o.bottom - o.top + "px";
434
2449
  }
435
2450
  scheduleRemoval(e) {
436
2451
  clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
@@ -438,14 +2453,14 @@ class _e {
438
2453
  dragover(e) {
439
2454
  if (!this.editorView.editable)
440
2455
  return;
441
- let n = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), s = r && r.type.spec.disableDropCursor, i = typeof s == "function" ? s(this.editorView, n, e) : s;
442
- if (n && !i) {
443
- let o = n.pos;
2456
+ let n = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), o = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), r = o && o.type.spec.disableDropCursor, s = typeof r == "function" ? r(this.editorView, n, e) : r;
2457
+ if (n && !s) {
2458
+ let i = n.pos;
444
2459
  if (this.editorView.dragging && this.editorView.dragging.slice) {
445
- let a = oe(this.editorView.state.doc, o, this.editorView.dragging.slice);
446
- a != null && (o = a);
2460
+ let l = ht(this.editorView.state.doc, i, this.editorView.dragging.slice);
2461
+ l != null && (i = l);
447
2462
  }
448
- this.setCursor(o), this.scheduleRemoval(5e3);
2463
+ this.setCursor(i), this.scheduleRemoval(5e3);
449
2464
  }
450
2465
  }
451
2466
  dragend() {
@@ -458,7 +2473,7 @@ class _e {
458
2473
  (e.target == this.editorView.dom || !this.editorView.dom.contains(e.relatedTarget)) && this.setCursor(null);
459
2474
  }
460
2475
  }
461
- const Ne = x.create({
2476
+ const qn = J.create({
462
2477
  name: "dropCursor",
463
2478
  addOptions() {
464
2479
  return {
@@ -469,11 +2484,11 @@ const Ne = x.create({
469
2484
  },
470
2485
  addProseMirrorPlugins() {
471
2486
  return [
472
- Re(this.options)
2487
+ Kn(this.options)
473
2488
  ];
474
2489
  }
475
2490
  });
476
- class h extends O {
2491
+ class C extends S {
477
2492
  /**
478
2493
  Create a gap cursor.
479
2494
  */
@@ -481,14 +2496,14 @@ class h extends O {
481
2496
  super(e, e);
482
2497
  }
483
2498
  map(e, n) {
484
- let r = e.resolve(n.map(this.head));
485
- return h.valid(r) ? new h(r) : O.near(r);
2499
+ let o = e.resolve(n.map(this.head));
2500
+ return C.valid(o) ? new C(o) : S.near(o);
486
2501
  }
487
2502
  content() {
488
- return Q.empty;
2503
+ return N.empty;
489
2504
  }
490
2505
  eq(e) {
491
- return e instanceof h && e.head == this.head;
2506
+ return e instanceof C && e.head == this.head;
492
2507
  }
493
2508
  toJSON() {
494
2509
  return { type: "gapcursor", pos: this.head };
@@ -499,178 +2514,178 @@ class h extends O {
499
2514
  static fromJSON(e, n) {
500
2515
  if (typeof n.pos != "number")
501
2516
  throw new RangeError("Invalid input for GapCursor.fromJSON");
502
- return new h(e.resolve(n.pos));
2517
+ return new C(e.resolve(n.pos));
503
2518
  }
504
2519
  /**
505
2520
  @internal
506
2521
  */
507
2522
  getBookmark() {
508
- return new j(this.anchor);
2523
+ return new Te(this.anchor);
509
2524
  }
510
2525
  /**
511
2526
  @internal
512
2527
  */
513
2528
  static valid(e) {
514
2529
  let n = e.parent;
515
- if (n.isTextblock || !Be(e) || !$e(e))
2530
+ if (n.isTextblock || !Xn(e) || !Gn(e))
516
2531
  return !1;
517
- let r = n.type.spec.allowGapCursor;
518
- if (r != null)
519
- return r;
520
- let s = n.contentMatchAt(e.index()).defaultType;
521
- return s && s.isTextblock;
2532
+ let o = n.type.spec.allowGapCursor;
2533
+ if (o != null)
2534
+ return o;
2535
+ let r = n.contentMatchAt(e.index()).defaultType;
2536
+ return r && r.isTextblock;
522
2537
  }
523
2538
  /**
524
2539
  @internal
525
2540
  */
526
- static findGapCursorFrom(e, n, r = !1) {
2541
+ static findGapCursorFrom(e, n, o = !1) {
527
2542
  e: for (; ; ) {
528
- if (!r && h.valid(e))
2543
+ if (!o && C.valid(e))
529
2544
  return e;
530
- let s = e.pos, i = null;
531
- for (let o = e.depth; ; o--) {
532
- let a = e.node(o);
533
- if (n > 0 ? e.indexAfter(o) < a.childCount : e.index(o) > 0) {
534
- i = a.child(n > 0 ? e.indexAfter(o) : e.index(o) - 1);
2545
+ let r = e.pos, s = null;
2546
+ for (let i = e.depth; ; i--) {
2547
+ let l = e.node(i);
2548
+ if (n > 0 ? e.indexAfter(i) < l.childCount : e.index(i) > 0) {
2549
+ s = l.child(n > 0 ? e.indexAfter(i) : e.index(i) - 1);
535
2550
  break;
536
- } else if (o == 0)
2551
+ } else if (i == 0)
537
2552
  return null;
538
- s += n;
539
- let l = e.doc.resolve(s);
540
- if (h.valid(l))
541
- return l;
2553
+ r += n;
2554
+ let a = e.doc.resolve(r);
2555
+ if (C.valid(a))
2556
+ return a;
542
2557
  }
543
2558
  for (; ; ) {
544
- let o = n > 0 ? i.firstChild : i.lastChild;
545
- if (!o) {
546
- if (i.isAtom && !i.isText && !W.isSelectable(i)) {
547
- e = e.doc.resolve(s + i.nodeSize * n), r = !1;
2559
+ let i = n > 0 ? s.firstChild : s.lastChild;
2560
+ if (!i) {
2561
+ if (s.isAtom && !s.isText && !ue.isSelectable(s)) {
2562
+ e = e.doc.resolve(r + s.nodeSize * n), o = !1;
548
2563
  continue e;
549
2564
  }
550
2565
  break;
551
2566
  }
552
- i = o, s += n;
553
- let a = e.doc.resolve(s);
554
- if (h.valid(a))
555
- return a;
2567
+ s = i, r += n;
2568
+ let l = e.doc.resolve(r);
2569
+ if (C.valid(l))
2570
+ return l;
556
2571
  }
557
2572
  return null;
558
2573
  }
559
2574
  }
560
2575
  }
561
- h.prototype.visible = !1;
562
- h.findFrom = h.findGapCursorFrom;
563
- O.jsonID("gapcursor", h);
564
- class j {
2576
+ C.prototype.visible = !1;
2577
+ C.findFrom = C.findGapCursorFrom;
2578
+ S.jsonID("gapcursor", C);
2579
+ class Te {
565
2580
  constructor(e) {
566
2581
  this.pos = e;
567
2582
  }
568
2583
  map(e) {
569
- return new j(e.map(this.pos));
2584
+ return new Te(e.map(this.pos));
570
2585
  }
571
2586
  resolve(e) {
572
2587
  let n = e.resolve(this.pos);
573
- return h.valid(n) ? new h(n) : O.near(n);
2588
+ return C.valid(n) ? new C(n) : S.near(n);
574
2589
  }
575
2590
  }
576
- function Be(t) {
2591
+ function Xn(t) {
577
2592
  for (let e = t.depth; e >= 0; e--) {
578
- let n = t.index(e), r = t.node(e);
2593
+ let n = t.index(e), o = t.node(e);
579
2594
  if (n == 0) {
580
- if (r.type.spec.isolating)
2595
+ if (o.type.spec.isolating)
581
2596
  return !0;
582
2597
  continue;
583
2598
  }
584
- for (let s = r.child(n - 1); ; s = s.lastChild) {
585
- if (s.childCount == 0 && !s.inlineContent || s.isAtom || s.type.spec.isolating)
2599
+ for (let r = o.child(n - 1); ; r = r.lastChild) {
2600
+ if (r.childCount == 0 && !r.inlineContent || r.isAtom || r.type.spec.isolating)
586
2601
  return !0;
587
- if (s.inlineContent)
2602
+ if (r.inlineContent)
588
2603
  return !1;
589
2604
  }
590
2605
  }
591
2606
  return !0;
592
2607
  }
593
- function $e(t) {
2608
+ function Gn(t) {
594
2609
  for (let e = t.depth; e >= 0; e--) {
595
- let n = t.indexAfter(e), r = t.node(e);
596
- if (n == r.childCount) {
597
- if (r.type.spec.isolating)
2610
+ let n = t.indexAfter(e), o = t.node(e);
2611
+ if (n == o.childCount) {
2612
+ if (o.type.spec.isolating)
598
2613
  return !0;
599
2614
  continue;
600
2615
  }
601
- for (let s = r.child(n); ; s = s.firstChild) {
602
- if (s.childCount == 0 && !s.inlineContent || s.isAtom || s.type.spec.isolating)
2616
+ for (let r = o.child(n); ; r = r.firstChild) {
2617
+ if (r.childCount == 0 && !r.inlineContent || r.isAtom || r.type.spec.isolating)
603
2618
  return !0;
604
- if (s.inlineContent)
2619
+ if (r.inlineContent)
605
2620
  return !1;
606
2621
  }
607
2622
  }
608
2623
  return !0;
609
2624
  }
610
- function De() {
611
- return new H({
2625
+ function Jn() {
2626
+ return new B({
612
2627
  props: {
613
- decorations: Fe,
2628
+ decorations: Qn,
614
2629
  createSelectionBetween(t, e, n) {
615
- return e.pos == n.pos && h.valid(n) ? new h(n) : null;
2630
+ return e.pos == n.pos && C.valid(n) ? new C(n) : null;
616
2631
  },
617
- handleClick: Ke,
618
- handleKeyDown: ze,
619
- handleDOMEvents: { beforeinput: Ve }
2632
+ handleClick: Yn,
2633
+ handleKeyDown: Un,
2634
+ handleDOMEvents: { beforeinput: Zn }
620
2635
  }
621
2636
  });
622
2637
  }
623
- const ze = ae({
624
- ArrowLeft: _("horiz", -1),
625
- ArrowRight: _("horiz", 1),
626
- ArrowUp: _("vert", -1),
627
- ArrowDown: _("vert", 1)
2638
+ const Un = Xe({
2639
+ ArrowLeft: ie("horiz", -1),
2640
+ ArrowRight: ie("horiz", 1),
2641
+ ArrowUp: ie("vert", -1),
2642
+ ArrowDown: ie("vert", 1)
628
2643
  });
629
- function _(t, e) {
2644
+ function ie(t, e) {
630
2645
  const n = t == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
631
- return function(r, s, i) {
632
- let o = r.selection, a = e > 0 ? o.$to : o.$from, l = o.empty;
633
- if (o instanceof I) {
634
- if (!i.endOfTextblock(n) || a.depth == 0)
2646
+ return function(o, r, s) {
2647
+ let i = o.selection, l = e > 0 ? i.$to : i.$from, a = i.empty;
2648
+ if (i instanceof x) {
2649
+ if (!s.endOfTextblock(n) || l.depth == 0)
635
2650
  return !1;
636
- l = !1, a = r.doc.resolve(e > 0 ? a.after() : a.before());
2651
+ a = !1, l = o.doc.resolve(e > 0 ? l.after() : l.before());
637
2652
  }
638
- let u = h.findGapCursorFrom(a, e, l);
639
- return u ? (s && s(r.tr.setSelection(new h(u))), !0) : !1;
2653
+ let c = C.findGapCursorFrom(l, e, a);
2654
+ return c ? (r && r(o.tr.setSelection(new C(c))), !0) : !1;
640
2655
  };
641
2656
  }
642
- function Ke(t, e, n) {
2657
+ function Yn(t, e, n) {
643
2658
  if (!t || !t.editable)
644
2659
  return !1;
645
- let r = t.state.doc.resolve(e);
646
- if (!h.valid(r))
2660
+ let o = t.state.doc.resolve(e);
2661
+ if (!C.valid(o))
647
2662
  return !1;
648
- let s = t.posAtCoords({ left: n.clientX, top: n.clientY });
649
- return s && s.inside > -1 && W.isSelectable(t.state.doc.nodeAt(s.inside)) ? !1 : (t.dispatch(t.state.tr.setSelection(new h(r))), !0);
2663
+ let r = t.posAtCoords({ left: n.clientX, top: n.clientY });
2664
+ return r && r.inside > -1 && ue.isSelectable(t.state.doc.nodeAt(r.inside)) ? !1 : (t.dispatch(t.state.tr.setSelection(new C(o))), !0);
650
2665
  }
651
- function Ve(t, e) {
652
- if (e.inputType != "insertCompositionText" || !(t.state.selection instanceof h))
2666
+ function Zn(t, e) {
2667
+ if (e.inputType != "insertCompositionText" || !(t.state.selection instanceof C))
653
2668
  return !1;
654
- let { $from: n } = t.state.selection, r = n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);
655
- if (!r)
2669
+ let { $from: n } = t.state.selection, o = n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);
2670
+ if (!o)
656
2671
  return !1;
657
- let s = G.empty;
658
- for (let o = r.length - 1; o >= 0; o--)
659
- s = G.from(r[o].createAndFill(null, s));
660
- let i = t.state.tr.replace(n.pos, n.pos, new Q(s, 0, 0));
661
- return i.setSelection(I.near(i.doc.resolve(n.pos + 1))), t.dispatch(i), !1;
662
- }
663
- function Fe(t) {
664
- if (!(t.selection instanceof h))
2672
+ let r = R.empty;
2673
+ for (let i = o.length - 1; i >= 0; i--)
2674
+ r = R.from(o[i].createAndFill(null, r));
2675
+ let s = t.state.tr.replace(n.pos, n.pos, new N(r, 0, 0));
2676
+ return s.setSelection(x.near(s.doc.resolve(n.pos + 1))), t.dispatch(s), !1;
2677
+ }
2678
+ function Qn(t) {
2679
+ if (!(t.selection instanceof C))
665
2680
  return null;
666
2681
  let e = document.createElement("div");
667
- return e.className = "ProseMirror-gapcursor", B.create(t.doc, [F.widget(t.selection.head, e, { key: "gapcursor" })]);
2682
+ return e.className = "ProseMirror-gapcursor", F.create(t.doc, [X.widget(t.selection.head, e, { key: "gapcursor" })]);
668
2683
  }
669
- const We = x.create({
2684
+ const eo = J.create({
670
2685
  name: "gapCursor",
671
2686
  addProseMirrorPlugins() {
672
2687
  return [
673
- De()
2688
+ Jn()
674
2689
  ];
675
2690
  },
676
2691
  extendNodeSchema(t) {
@@ -681,10 +2696,10 @@ const We = x.create({
681
2696
  storage: t.storage
682
2697
  };
683
2698
  return {
684
- allowGapCursor: (e = le(ue(t, "allowGapCursor", n))) !== null && e !== void 0 ? e : null
2699
+ allowGapCursor: (e = Ge(Je(t, "allowGapCursor", n))) !== null && e !== void 0 ? e : null
685
2700
  };
686
2701
  }
687
- }), je = v.create({
2702
+ }), to = k.create({
688
2703
  name: "hardBreak",
689
2704
  addOptions() {
690
2705
  return {
@@ -702,7 +2717,7 @@ const We = x.create({
702
2717
  ];
703
2718
  },
704
2719
  renderHTML({ HTMLAttributes: t }) {
705
- return ["br", y(this.options.HTMLAttributes, t)];
2720
+ return ["br", v(this.options.HTMLAttributes, t)];
706
2721
  },
707
2722
  renderText() {
708
2723
  return `
@@ -710,17 +2725,17 @@ const We = x.create({
710
2725
  },
711
2726
  addCommands() {
712
2727
  return {
713
- setHardBreak: () => ({ commands: t, chain: e, state: n, editor: r }) => t.first([
2728
+ setHardBreak: () => ({ commands: t, chain: e, state: n, editor: o }) => t.first([
714
2729
  () => t.exitCode(),
715
2730
  () => t.command(() => {
716
- const { selection: s, storedMarks: i } = n;
717
- if (s.$from.parent.type.spec.isolating)
2731
+ const { selection: r, storedMarks: s } = n;
2732
+ if (r.$from.parent.type.spec.isolating)
718
2733
  return !1;
719
- const { keepMarks: o } = this.options, { splittableMarks: a } = r.extensionManager, l = i || s.$to.parentOffset && s.$from.marks();
720
- return e().insertContent({ type: this.name }).command(({ tr: u, dispatch: p }) => {
721
- if (p && l && o) {
722
- const d = l.filter((c) => a.includes(c.type.name));
723
- u.ensureMarks(d);
2734
+ const { keepMarks: i } = this.options, { splittableMarks: l } = o.extensionManager, a = s || r.$to.parentOffset && r.$from.marks();
2735
+ return e().insertContent({ type: this.name }).command(({ tr: c, dispatch: d }) => {
2736
+ if (d && a && i) {
2737
+ const u = a.filter((p) => l.includes(p.type.name));
2738
+ c.ensureMarks(u);
724
2739
  }
725
2740
  return !0;
726
2741
  }).run();
@@ -734,7 +2749,7 @@ const We = x.create({
734
2749
  "Shift-Enter": () => this.editor.commands.setHardBreak()
735
2750
  };
736
2751
  }
737
- }), Ge = v.create({
2752
+ }), no = k.create({
738
2753
  name: "heading",
739
2754
  addOptions() {
740
2755
  return {
@@ -760,7 +2775,7 @@ const We = x.create({
760
2775
  }));
761
2776
  },
762
2777
  renderHTML({ node: t, HTMLAttributes: e }) {
763
- return [`h${this.options.levels.includes(t.attrs.level) ? t.attrs.level : this.options.levels[0]}`, y(this.options.HTMLAttributes, e), 0];
2778
+ return [`h${this.options.levels.includes(t.attrs.level) ? t.attrs.level : this.options.levels[0]}`, v(this.options.HTMLAttributes, e), 0];
764
2779
  },
765
2780
  addCommands() {
766
2781
  return {
@@ -775,7 +2790,7 @@ const We = x.create({
775
2790
  }), {});
776
2791
  },
777
2792
  addInputRules() {
778
- return this.options.levels.map((t) => V({
2793
+ return this.options.levels.map((t) => be({
779
2794
  find: new RegExp(`^(#{1,${t}})\\s$`),
780
2795
  type: this.type,
781
2796
  getAttributes: {
@@ -784,105 +2799,105 @@ const We = x.create({
784
2799
  }));
785
2800
  }
786
2801
  });
787
- var $ = 200, g = function() {
2802
+ var de = 200, A = function() {
788
2803
  };
789
- g.prototype.append = function(e) {
790
- return e.length ? (e = g.from(e), !this.length && e || e.length < $ && this.leafAppend(e) || this.length < $ && e.leafPrepend(this) || this.appendInner(e)) : this;
2804
+ A.prototype.append = function(e) {
2805
+ return e.length ? (e = A.from(e), !this.length && e || e.length < de && this.leafAppend(e) || this.length < de && e.leafPrepend(this) || this.appendInner(e)) : this;
791
2806
  };
792
- g.prototype.prepend = function(e) {
793
- return e.length ? g.from(e).append(this) : this;
2807
+ A.prototype.prepend = function(e) {
2808
+ return e.length ? A.from(e).append(this) : this;
794
2809
  };
795
- g.prototype.appendInner = function(e) {
796
- return new qe(this, e);
2810
+ A.prototype.appendInner = function(e) {
2811
+ return new oo(this, e);
797
2812
  };
798
- g.prototype.slice = function(e, n) {
799
- return e === void 0 && (e = 0), n === void 0 && (n = this.length), e >= n ? g.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, n));
2813
+ A.prototype.slice = function(e, n) {
2814
+ return e === void 0 && (e = 0), n === void 0 && (n = this.length), e >= n ? A.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, n));
800
2815
  };
801
- g.prototype.get = function(e) {
2816
+ A.prototype.get = function(e) {
802
2817
  if (!(e < 0 || e >= this.length))
803
2818
  return this.getInner(e);
804
2819
  };
805
- g.prototype.forEach = function(e, n, r) {
806
- n === void 0 && (n = 0), r === void 0 && (r = this.length), n <= r ? this.forEachInner(e, n, r, 0) : this.forEachInvertedInner(e, n, r, 0);
2820
+ A.prototype.forEach = function(e, n, o) {
2821
+ n === void 0 && (n = 0), o === void 0 && (o = this.length), n <= o ? this.forEachInner(e, n, o, 0) : this.forEachInvertedInner(e, n, o, 0);
807
2822
  };
808
- g.prototype.map = function(e, n, r) {
809
- n === void 0 && (n = 0), r === void 0 && (r = this.length);
810
- var s = [];
811
- return this.forEach(function(i, o) {
812
- return s.push(e(i, o));
813
- }, n, r), s;
2823
+ A.prototype.map = function(e, n, o) {
2824
+ n === void 0 && (n = 0), o === void 0 && (o = this.length);
2825
+ var r = [];
2826
+ return this.forEach(function(s, i) {
2827
+ return r.push(e(s, i));
2828
+ }, n, o), r;
814
2829
  };
815
- g.from = function(e) {
816
- return e instanceof g ? e : e && e.length ? new te(e) : g.empty;
2830
+ A.from = function(e) {
2831
+ return e instanceof A ? e : e && e.length ? new st(e) : A.empty;
817
2832
  };
818
- var te = /* @__PURE__ */ function(t) {
819
- function e(r) {
820
- t.call(this), this.values = r;
2833
+ var st = /* @__PURE__ */ function(t) {
2834
+ function e(o) {
2835
+ t.call(this), this.values = o;
821
2836
  }
822
2837
  t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e;
823
2838
  var n = { length: { configurable: !0 }, depth: { configurable: !0 } };
824
2839
  return e.prototype.flatten = function() {
825
2840
  return this.values;
826
- }, e.prototype.sliceInner = function(s, i) {
827
- return s == 0 && i == this.length ? this : new e(this.values.slice(s, i));
828
- }, e.prototype.getInner = function(s) {
829
- return this.values[s];
830
- }, e.prototype.forEachInner = function(s, i, o, a) {
831
- for (var l = i; l < o; l++)
832
- if (s(this.values[l], a + l) === !1)
2841
+ }, e.prototype.sliceInner = function(r, s) {
2842
+ return r == 0 && s == this.length ? this : new e(this.values.slice(r, s));
2843
+ }, e.prototype.getInner = function(r) {
2844
+ return this.values[r];
2845
+ }, e.prototype.forEachInner = function(r, s, i, l) {
2846
+ for (var a = s; a < i; a++)
2847
+ if (r(this.values[a], l + a) === !1)
833
2848
  return !1;
834
- }, e.prototype.forEachInvertedInner = function(s, i, o, a) {
835
- for (var l = i - 1; l >= o; l--)
836
- if (s(this.values[l], a + l) === !1)
2849
+ }, e.prototype.forEachInvertedInner = function(r, s, i, l) {
2850
+ for (var a = s - 1; a >= i; a--)
2851
+ if (r(this.values[a], l + a) === !1)
837
2852
  return !1;
838
- }, e.prototype.leafAppend = function(s) {
839
- if (this.length + s.length <= $)
840
- return new e(this.values.concat(s.flatten()));
841
- }, e.prototype.leafPrepend = function(s) {
842
- if (this.length + s.length <= $)
843
- return new e(s.flatten().concat(this.values));
2853
+ }, e.prototype.leafAppend = function(r) {
2854
+ if (this.length + r.length <= de)
2855
+ return new e(this.values.concat(r.flatten()));
2856
+ }, e.prototype.leafPrepend = function(r) {
2857
+ if (this.length + r.length <= de)
2858
+ return new e(r.flatten().concat(this.values));
844
2859
  }, n.length.get = function() {
845
2860
  return this.values.length;
846
2861
  }, n.depth.get = function() {
847
2862
  return 0;
848
2863
  }, Object.defineProperties(e.prototype, n), e;
849
- }(g);
850
- g.empty = new te([]);
851
- var qe = /* @__PURE__ */ function(t) {
852
- function e(n, r) {
853
- t.call(this), this.left = n, this.right = r, this.length = n.length + r.length, this.depth = Math.max(n.depth, r.depth) + 1;
2864
+ }(A);
2865
+ A.empty = new st([]);
2866
+ var oo = /* @__PURE__ */ function(t) {
2867
+ function e(n, o) {
2868
+ t.call(this), this.left = n, this.right = o, this.length = n.length + o.length, this.depth = Math.max(n.depth, o.depth) + 1;
854
2869
  }
855
2870
  return t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
856
2871
  return this.left.flatten().concat(this.right.flatten());
857
- }, e.prototype.getInner = function(r) {
858
- return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
859
- }, e.prototype.forEachInner = function(r, s, i, o) {
860
- var a = this.left.length;
861
- if (s < a && this.left.forEachInner(r, s, Math.min(i, a), o) === !1 || i > a && this.right.forEachInner(r, Math.max(s - a, 0), Math.min(this.length, i) - a, o + a) === !1)
2872
+ }, e.prototype.getInner = function(o) {
2873
+ return o < this.left.length ? this.left.get(o) : this.right.get(o - this.left.length);
2874
+ }, e.prototype.forEachInner = function(o, r, s, i) {
2875
+ var l = this.left.length;
2876
+ if (r < l && this.left.forEachInner(o, r, Math.min(s, l), i) === !1 || s > l && this.right.forEachInner(o, Math.max(r - l, 0), Math.min(this.length, s) - l, i + l) === !1)
862
2877
  return !1;
863
- }, e.prototype.forEachInvertedInner = function(r, s, i, o) {
864
- var a = this.left.length;
865
- if (s > a && this.right.forEachInvertedInner(r, s - a, Math.max(i, a) - a, o + a) === !1 || i < a && this.left.forEachInvertedInner(r, Math.min(s, a), i, o) === !1)
2878
+ }, e.prototype.forEachInvertedInner = function(o, r, s, i) {
2879
+ var l = this.left.length;
2880
+ if (r > l && this.right.forEachInvertedInner(o, r - l, Math.max(s, l) - l, i + l) === !1 || s < l && this.left.forEachInvertedInner(o, Math.min(r, l), s, i) === !1)
866
2881
  return !1;
867
- }, e.prototype.sliceInner = function(r, s) {
868
- if (r == 0 && s == this.length)
2882
+ }, e.prototype.sliceInner = function(o, r) {
2883
+ if (o == 0 && r == this.length)
869
2884
  return this;
870
- var i = this.left.length;
871
- return s <= i ? this.left.slice(r, s) : r >= i ? this.right.slice(r - i, s - i) : this.left.slice(r, i).append(this.right.slice(0, s - i));
872
- }, e.prototype.leafAppend = function(r) {
873
- var s = this.right.leafAppend(r);
874
- if (s)
875
- return new e(this.left, s);
876
- }, e.prototype.leafPrepend = function(r) {
877
- var s = this.left.leafPrepend(r);
878
- if (s)
879
- return new e(s, this.right);
880
- }, e.prototype.appendInner = function(r) {
881
- return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
2885
+ var s = this.left.length;
2886
+ return r <= s ? this.left.slice(o, r) : o >= s ? this.right.slice(o - s, r - s) : this.left.slice(o, s).append(this.right.slice(0, r - s));
2887
+ }, e.prototype.leafAppend = function(o) {
2888
+ var r = this.right.leafAppend(o);
2889
+ if (r)
2890
+ return new e(this.left, r);
2891
+ }, e.prototype.leafPrepend = function(o) {
2892
+ var r = this.left.leafPrepend(o);
2893
+ if (r)
2894
+ return new e(r, this.right);
2895
+ }, e.prototype.appendInner = function(o) {
2896
+ return this.left.depth >= Math.max(this.right.depth, o.depth) + 1 ? new e(this.left, new e(this.right, o)) : new e(this, o);
882
2897
  }, e;
883
- }(g);
884
- const Je = 500;
885
- class M {
2898
+ }(A);
2899
+ const ro = 500;
2900
+ class H {
886
2901
  constructor(e, n) {
887
2902
  this.items = e, this.eventCount = n;
888
2903
  }
@@ -891,49 +2906,49 @@ class M {
891
2906
  popEvent(e, n) {
892
2907
  if (this.eventCount == 0)
893
2908
  return null;
894
- let r = this.items.length;
895
- for (; ; r--)
896
- if (this.items.get(r - 1).selection) {
897
- --r;
2909
+ let o = this.items.length;
2910
+ for (; ; o--)
2911
+ if (this.items.get(o - 1).selection) {
2912
+ --o;
898
2913
  break;
899
2914
  }
900
- let s, i;
901
- n && (s = this.remapping(r, this.items.length), i = s.maps.length);
902
- let o = e.tr, a, l, u = [], p = [];
903
- return this.items.forEach((d, c) => {
904
- if (!d.step) {
905
- s || (s = this.remapping(r, c + 1), i = s.maps.length), i--, p.push(d);
2915
+ let r, s;
2916
+ n && (r = this.remapping(o, this.items.length), s = r.maps.length);
2917
+ let i = e.tr, l, a, c = [], d = [];
2918
+ return this.items.forEach((u, p) => {
2919
+ if (!u.step) {
2920
+ r || (r = this.remapping(o, p + 1), s = r.maps.length), s--, d.push(u);
906
2921
  return;
907
2922
  }
908
- if (s) {
909
- p.push(new k(d.map));
910
- let f = d.step.map(s.slice(i)), b;
911
- f && o.maybeStep(f).doc && (b = o.mapping.maps[o.mapping.maps.length - 1], u.push(new k(b, void 0, void 0, u.length + p.length))), i--, b && s.appendMap(b, i);
2923
+ if (r) {
2924
+ d.push(new I(u.map));
2925
+ let h = u.step.map(r.slice(s)), f;
2926
+ h && i.maybeStep(h).doc && (f = i.mapping.maps[i.mapping.maps.length - 1], c.push(new I(f, void 0, void 0, c.length + d.length))), s--, f && r.appendMap(f, s);
912
2927
  } else
913
- o.maybeStep(d.step);
914
- if (d.selection)
915
- return a = s ? d.selection.map(s.slice(i)) : d.selection, l = new M(this.items.slice(0, r).append(p.reverse().concat(u)), this.eventCount - 1), !1;
916
- }, this.items.length, 0), { remaining: l, transform: o, selection: a };
2928
+ i.maybeStep(u.step);
2929
+ if (u.selection)
2930
+ return l = r ? u.selection.map(r.slice(s)) : u.selection, a = new H(this.items.slice(0, o).append(d.reverse().concat(c)), this.eventCount - 1), !1;
2931
+ }, this.items.length, 0), { remaining: a, transform: i, selection: l };
917
2932
  }
918
2933
  // Create a new branch with the given transform added.
919
- addTransform(e, n, r, s) {
920
- let i = [], o = this.eventCount, a = this.items, l = !s && a.length ? a.get(a.length - 1) : null;
921
- for (let p = 0; p < e.steps.length; p++) {
922
- let d = e.steps[p].invert(e.docs[p]), c = new k(e.mapping.maps[p], d, n), f;
923
- (f = l && l.merge(c)) && (c = f, p ? i.pop() : a = a.slice(0, a.length - 1)), i.push(c), n && (o++, n = void 0), s || (l = c);
2934
+ addTransform(e, n, o, r) {
2935
+ let s = [], i = this.eventCount, l = this.items, a = !r && l.length ? l.get(l.length - 1) : null;
2936
+ for (let d = 0; d < e.steps.length; d++) {
2937
+ let u = e.steps[d].invert(e.docs[d]), p = new I(e.mapping.maps[d], u, n), h;
2938
+ (h = a && a.merge(p)) && (p = h, d ? s.pop() : l = l.slice(0, l.length - 1)), s.push(p), n && (i++, n = void 0), r || (a = p);
924
2939
  }
925
- let u = o - r.depth;
926
- return u > Xe && (a = Ue(a, u), o -= u), new M(a.append(i), o);
2940
+ let c = i - o.depth;
2941
+ return c > io && (l = so(l, c), i -= c), new H(l.append(s), i);
927
2942
  }
928
2943
  remapping(e, n) {
929
- let r = new de();
930
- return this.items.forEach((s, i) => {
931
- let o = s.mirrorOffset != null && i - s.mirrorOffset >= e ? r.maps.length - s.mirrorOffset : void 0;
932
- r.appendMap(s.map, o);
933
- }, e, n), r;
2944
+ let o = new ft();
2945
+ return this.items.forEach((r, s) => {
2946
+ let i = r.mirrorOffset != null && s - r.mirrorOffset >= e ? o.maps.length - r.mirrorOffset : void 0;
2947
+ o.appendMap(r.map, i);
2948
+ }, e, n), o;
934
2949
  }
935
2950
  addMaps(e) {
936
- return this.eventCount == 0 ? this : new M(this.items.append(e.map((n) => new k(n))), this.eventCount);
2951
+ return this.eventCount == 0 ? this : new H(this.items.append(e.map((n) => new I(n))), this.eventCount);
937
2952
  }
938
2953
  // When the collab module receives remote changes, the history has
939
2954
  // to know about those, so that it can adjust the steps that were
@@ -942,28 +2957,28 @@ class M {
942
2957
  rebased(e, n) {
943
2958
  if (!this.eventCount)
944
2959
  return this;
945
- let r = [], s = Math.max(0, this.items.length - n), i = e.mapping, o = e.steps.length, a = this.eventCount;
946
- this.items.forEach((c) => {
947
- c.selection && a--;
948
- }, s);
949
- let l = n;
950
- this.items.forEach((c) => {
951
- let f = i.getMirror(--l);
952
- if (f == null)
2960
+ let o = [], r = Math.max(0, this.items.length - n), s = e.mapping, i = e.steps.length, l = this.eventCount;
2961
+ this.items.forEach((p) => {
2962
+ p.selection && l--;
2963
+ }, r);
2964
+ let a = n;
2965
+ this.items.forEach((p) => {
2966
+ let h = s.getMirror(--a);
2967
+ if (h == null)
953
2968
  return;
954
- o = Math.min(o, f);
955
- let b = i.maps[f];
956
- if (c.step) {
957
- let S = e.steps[f].invert(e.docs[f]), L = c.selection && c.selection.map(i.slice(l + 1, f));
958
- L && a++, r.push(new k(b, S, L));
2969
+ i = Math.min(i, h);
2970
+ let f = s.maps[h];
2971
+ if (p.step) {
2972
+ let m = e.steps[h].invert(e.docs[h]), g = p.selection && p.selection.map(s.slice(a + 1, h));
2973
+ g && l++, o.push(new I(f, m, g));
959
2974
  } else
960
- r.push(new k(b));
961
- }, s);
962
- let u = [];
963
- for (let c = n; c < o; c++)
964
- u.push(new k(i.maps[c]));
965
- let p = this.items.slice(0, s).append(u).append(r), d = new M(p, a);
966
- return d.emptyItemCount() > Je && (d = d.compress(this.items.length - r.length)), d;
2975
+ o.push(new I(f));
2976
+ }, r);
2977
+ let c = [];
2978
+ for (let p = n; p < i; p++)
2979
+ c.push(new I(s.maps[p]));
2980
+ let d = this.items.slice(0, r).append(c).append(o), u = new H(d, l);
2981
+ return u.emptyItemCount() > ro && (u = u.compress(this.items.length - o.length)), u;
967
2982
  }
968
2983
  emptyItemCount() {
969
2984
  let e = 0;
@@ -978,149 +2993,149 @@ class M {
978
2993
  // because `rebased` relies on a clean, untouched set of items in
979
2994
  // order to associate old items with rebased steps.
980
2995
  compress(e = this.items.length) {
981
- let n = this.remapping(0, e), r = n.maps.length, s = [], i = 0;
982
- return this.items.forEach((o, a) => {
983
- if (a >= e)
984
- s.push(o), o.selection && i++;
985
- else if (o.step) {
986
- let l = o.step.map(n.slice(r)), u = l && l.getMap();
987
- if (r--, u && n.appendMap(u, r), l) {
988
- let p = o.selection && o.selection.map(n.slice(r));
989
- p && i++;
990
- let d = new k(u.invert(), l, p), c, f = s.length - 1;
991
- (c = s.length && s[f].merge(d)) ? s[f] = c : s.push(d);
2996
+ let n = this.remapping(0, e), o = n.maps.length, r = [], s = 0;
2997
+ return this.items.forEach((i, l) => {
2998
+ if (l >= e)
2999
+ r.push(i), i.selection && s++;
3000
+ else if (i.step) {
3001
+ let a = i.step.map(n.slice(o)), c = a && a.getMap();
3002
+ if (o--, c && n.appendMap(c, o), a) {
3003
+ let d = i.selection && i.selection.map(n.slice(o));
3004
+ d && s++;
3005
+ let u = new I(c.invert(), a, d), p, h = r.length - 1;
3006
+ (p = r.length && r[h].merge(u)) ? r[h] = p : r.push(u);
992
3007
  }
993
- } else o.map && r--;
994
- }, this.items.length, 0), new M(g.from(s.reverse()), i);
3008
+ } else i.map && o--;
3009
+ }, this.items.length, 0), new H(A.from(r.reverse()), s);
995
3010
  }
996
3011
  }
997
- M.empty = new M(g.empty, 0);
998
- function Ue(t, e) {
3012
+ H.empty = new H(A.empty, 0);
3013
+ function so(t, e) {
999
3014
  let n;
1000
- return t.forEach((r, s) => {
1001
- if (r.selection && e-- == 0)
1002
- return n = s, !1;
3015
+ return t.forEach((o, r) => {
3016
+ if (o.selection && e-- == 0)
3017
+ return n = r, !1;
1003
3018
  }), t.slice(n);
1004
3019
  }
1005
- class k {
1006
- constructor(e, n, r, s) {
1007
- this.map = e, this.step = n, this.selection = r, this.mirrorOffset = s;
3020
+ class I {
3021
+ constructor(e, n, o, r) {
3022
+ this.map = e, this.step = n, this.selection = o, this.mirrorOffset = r;
1008
3023
  }
1009
3024
  merge(e) {
1010
3025
  if (this.step && e.step && !e.selection) {
1011
3026
  let n = e.step.merge(this.step);
1012
3027
  if (n)
1013
- return new k(n.getMap().invert(), n, this.selection);
3028
+ return new I(n.getMap().invert(), n, this.selection);
1014
3029
  }
1015
3030
  }
1016
3031
  }
1017
- class T {
1018
- constructor(e, n, r, s, i) {
1019
- this.done = e, this.undone = n, this.prevRanges = r, this.prevTime = s, this.prevComposition = i;
3032
+ class $ {
3033
+ constructor(e, n, o, r, s) {
3034
+ this.done = e, this.undone = n, this.prevRanges = o, this.prevTime = r, this.prevComposition = s;
1020
3035
  }
1021
3036
  }
1022
- const Xe = 20;
1023
- function Ye(t, e, n, r) {
1024
- let s = n.getMeta(w), i;
1025
- if (s)
1026
- return s.historyState;
1027
- n.getMeta(et) && (t = new T(t.done, t.undone, null, 0, -1));
1028
- let o = n.getMeta("appendedTransaction");
3037
+ const io = 20;
3038
+ function lo(t, e, n, o) {
3039
+ let r = n.getMeta(V), s;
3040
+ if (r)
3041
+ return r.historyState;
3042
+ n.getMeta(uo) && (t = new $(t.done, t.undone, null, 0, -1));
3043
+ let i = n.getMeta("appendedTransaction");
1029
3044
  if (n.steps.length == 0)
1030
3045
  return t;
1031
- if (o && o.getMeta(w))
1032
- return o.getMeta(w).redo ? new T(t.done.addTransform(n, void 0, r, N(e)), t.undone, U(n.mapping.maps), t.prevTime, t.prevComposition) : new T(t.done, t.undone.addTransform(n, void 0, r, N(e)), null, t.prevTime, t.prevComposition);
1033
- if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
1034
- let a = n.getMeta("composition"), l = t.prevTime == 0 || !o && t.prevComposition != a && (t.prevTime < (n.time || 0) - r.newGroupDelay || !Ze(n, t.prevRanges)), u = o ? z(t.prevRanges, n.mapping) : U(n.mapping.maps);
1035
- return new T(t.done.addTransform(n, l ? e.selection.getBookmark() : void 0, r, N(e)), M.empty, u, n.time, a ?? t.prevComposition);
1036
- } else return (i = n.getMeta("rebased")) ? new T(t.done.rebased(n, i), t.undone.rebased(n, i), z(t.prevRanges, n.mapping), t.prevTime, t.prevComposition) : new T(t.done.addMaps(n.mapping.maps), t.undone.addMaps(n.mapping.maps), z(t.prevRanges, n.mapping), t.prevTime, t.prevComposition);
1037
- }
1038
- function Ze(t, e) {
3046
+ if (i && i.getMeta(V))
3047
+ return i.getMeta(V).redo ? new $(t.done.addTransform(n, void 0, o, ce(e)), t.undone, Ve(n.mapping.maps), t.prevTime, t.prevComposition) : new $(t.done, t.undone.addTransform(n, void 0, o, ce(e)), null, t.prevTime, t.prevComposition);
3048
+ if (n.getMeta("addToHistory") !== !1 && !(i && i.getMeta("addToHistory") === !1)) {
3049
+ let l = n.getMeta("composition"), a = t.prevTime == 0 || !i && t.prevComposition != l && (t.prevTime < (n.time || 0) - o.newGroupDelay || !ao(n, t.prevRanges)), c = i ? me(t.prevRanges, n.mapping) : Ve(n.mapping.maps);
3050
+ return new $(t.done.addTransform(n, a ? e.selection.getBookmark() : void 0, o, ce(e)), H.empty, c, n.time, l ?? t.prevComposition);
3051
+ } else return (s = n.getMeta("rebased")) ? new $(t.done.rebased(n, s), t.undone.rebased(n, s), me(t.prevRanges, n.mapping), t.prevTime, t.prevComposition) : new $(t.done.addMaps(n.mapping.maps), t.undone.addMaps(n.mapping.maps), me(t.prevRanges, n.mapping), t.prevTime, t.prevComposition);
3052
+ }
3053
+ function ao(t, e) {
1039
3054
  if (!e)
1040
3055
  return !1;
1041
3056
  if (!t.docChanged)
1042
3057
  return !0;
1043
3058
  let n = !1;
1044
- return t.mapping.maps[0].forEach((r, s) => {
1045
- for (let i = 0; i < e.length; i += 2)
1046
- r <= e[i + 1] && s >= e[i] && (n = !0);
3059
+ return t.mapping.maps[0].forEach((o, r) => {
3060
+ for (let s = 0; s < e.length; s += 2)
3061
+ o <= e[s + 1] && r >= e[s] && (n = !0);
1047
3062
  }), n;
1048
3063
  }
1049
- function U(t) {
3064
+ function Ve(t) {
1050
3065
  let e = [];
1051
3066
  for (let n = t.length - 1; n >= 0 && e.length == 0; n--)
1052
- t[n].forEach((r, s, i, o) => e.push(i, o));
3067
+ t[n].forEach((o, r, s, i) => e.push(s, i));
1053
3068
  return e;
1054
3069
  }
1055
- function z(t, e) {
3070
+ function me(t, e) {
1056
3071
  if (!t)
1057
3072
  return null;
1058
3073
  let n = [];
1059
- for (let r = 0; r < t.length; r += 2) {
1060
- let s = e.map(t[r], 1), i = e.map(t[r + 1], -1);
1061
- s <= i && n.push(s, i);
3074
+ for (let o = 0; o < t.length; o += 2) {
3075
+ let r = e.map(t[o], 1), s = e.map(t[o + 1], -1);
3076
+ r <= s && n.push(r, s);
1062
3077
  }
1063
3078
  return n;
1064
3079
  }
1065
- function Qe(t, e, n) {
1066
- let r = N(e), s = w.get(e).spec.config, i = (n ? t.undone : t.done).popEvent(e, r);
1067
- if (!i)
3080
+ function co(t, e, n) {
3081
+ let o = ce(e), r = V.get(e).spec.config, s = (n ? t.undone : t.done).popEvent(e, o);
3082
+ if (!s)
1068
3083
  return null;
1069
- let o = i.selection.resolve(i.transform.doc), a = (n ? t.done : t.undone).addTransform(i.transform, e.selection.getBookmark(), s, r), l = new T(n ? a : i.remaining, n ? i.remaining : a, null, 0, -1);
1070
- return i.transform.setSelection(o).setMeta(w, { redo: n, historyState: l });
3084
+ let i = s.selection.resolve(s.transform.doc), l = (n ? t.done : t.undone).addTransform(s.transform, e.selection.getBookmark(), r, o), a = new $(n ? l : s.remaining, n ? s.remaining : l, null, 0, -1);
3085
+ return s.transform.setSelection(i).setMeta(V, { redo: n, historyState: a });
1071
3086
  }
1072
- let K = !1, X = null;
1073
- function N(t) {
3087
+ let ge = !1, Fe = null;
3088
+ function ce(t) {
1074
3089
  let e = t.plugins;
1075
- if (X != e) {
1076
- K = !1, X = e;
3090
+ if (Fe != e) {
3091
+ ge = !1, Fe = e;
1077
3092
  for (let n = 0; n < e.length; n++)
1078
3093
  if (e[n].spec.historyPreserveItems) {
1079
- K = !0;
3094
+ ge = !0;
1080
3095
  break;
1081
3096
  }
1082
3097
  }
1083
- return K;
3098
+ return ge;
1084
3099
  }
1085
- const w = new P("history"), et = new P("closeHistory");
1086
- function tt(t = {}) {
3100
+ const V = new D("history"), uo = new D("closeHistory");
3101
+ function po(t = {}) {
1087
3102
  return t = {
1088
3103
  depth: t.depth || 100,
1089
3104
  newGroupDelay: t.newGroupDelay || 500
1090
- }, new H({
1091
- key: w,
3105
+ }, new B({
3106
+ key: V,
1092
3107
  state: {
1093
3108
  init() {
1094
- return new T(M.empty, M.empty, null, 0, -1);
3109
+ return new $(H.empty, H.empty, null, 0, -1);
1095
3110
  },
1096
- apply(e, n, r) {
1097
- return Ye(n, r, e, t);
3111
+ apply(e, n, o) {
3112
+ return lo(n, o, e, t);
1098
3113
  }
1099
3114
  },
1100
3115
  config: t,
1101
3116
  props: {
1102
3117
  handleDOMEvents: {
1103
3118
  beforeinput(e, n) {
1104
- let r = n.inputType, s = r == "historyUndo" ? re : r == "historyRedo" ? se : null;
1105
- return s ? (n.preventDefault(), s(e.state, e.dispatch)) : !1;
3119
+ let o = n.inputType, r = o == "historyUndo" ? lt : o == "historyRedo" ? at : null;
3120
+ return r ? (n.preventDefault(), r(e.state, e.dispatch)) : !1;
1106
3121
  }
1107
3122
  }
1108
3123
  }
1109
3124
  });
1110
3125
  }
1111
- function ne(t, e) {
1112
- return (n, r) => {
1113
- let s = w.getState(n);
1114
- if (!s || (t ? s.undone : s.done).eventCount == 0)
3126
+ function it(t, e) {
3127
+ return (n, o) => {
3128
+ let r = V.getState(n);
3129
+ if (!r || (t ? r.undone : r.done).eventCount == 0)
1115
3130
  return !1;
1116
- if (r) {
1117
- let i = Qe(s, n, t);
1118
- i && r(e ? i.scrollIntoView() : i);
3131
+ if (o) {
3132
+ let s = co(r, n, t);
3133
+ s && o(e ? s.scrollIntoView() : s);
1119
3134
  }
1120
3135
  return !0;
1121
3136
  };
1122
3137
  }
1123
- const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
3138
+ const lt = it(!1, !0), at = it(!0, !0), ho = J.create({
1124
3139
  name: "history",
1125
3140
  addOptions() {
1126
3141
  return {
@@ -1130,13 +3145,13 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1130
3145
  },
1131
3146
  addCommands() {
1132
3147
  return {
1133
- undo: () => ({ state: t, dispatch: e }) => re(t, e),
1134
- redo: () => ({ state: t, dispatch: e }) => se(t, e)
3148
+ undo: () => ({ state: t, dispatch: e }) => lt(t, e),
3149
+ redo: () => ({ state: t, dispatch: e }) => at(t, e)
1135
3150
  };
1136
3151
  },
1137
3152
  addProseMirrorPlugins() {
1138
3153
  return [
1139
- tt(this.options)
3154
+ po(this.options)
1140
3155
  ];
1141
3156
  },
1142
3157
  addKeyboardShortcuts() {
@@ -1149,7 +3164,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1149
3164
  "Shift-Mod-я": () => this.editor.commands.redo()
1150
3165
  };
1151
3166
  }
1152
- }), rt = v.create({
3167
+ }), fo = k.create({
1153
3168
  name: "horizontalRule",
1154
3169
  addOptions() {
1155
3170
  return {
@@ -1161,30 +3176,30 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1161
3176
  return [{ tag: "hr" }];
1162
3177
  },
1163
3178
  renderHTML({ HTMLAttributes: t }) {
1164
- return ["hr", y(this.options.HTMLAttributes, t)];
3179
+ return ["hr", v(this.options.HTMLAttributes, t)];
1165
3180
  },
1166
3181
  addCommands() {
1167
3182
  return {
1168
3183
  setHorizontalRule: () => ({ chain: t, state: e }) => {
1169
- const { selection: n } = e, { $from: r, $to: s } = n, i = t();
1170
- return r.parentOffset === 0 ? i.insertContentAt({
1171
- from: Math.max(r.pos - 1, 0),
1172
- to: s.pos
3184
+ const { selection: n } = e, { $from: o, $to: r } = n, s = t();
3185
+ return o.parentOffset === 0 ? s.insertContentAt({
3186
+ from: Math.max(o.pos - 1, 0),
3187
+ to: r.pos
1173
3188
  }, {
1174
3189
  type: this.name
1175
- }) : pe(n) ? i.insertContentAt(s.pos, {
3190
+ }) : mt(n) ? s.insertContentAt(r.pos, {
1176
3191
  type: this.name
1177
- }) : i.insertContent({ type: this.name }), i.command(({ tr: o, dispatch: a }) => {
1178
- var l;
1179
- if (a) {
1180
- const { $to: u } = o.selection, p = u.end();
1181
- if (u.nodeAfter)
1182
- u.nodeAfter.isTextblock ? o.setSelection(I.create(o.doc, u.pos + 1)) : u.nodeAfter.isBlock ? o.setSelection(W.create(o.doc, u.pos)) : o.setSelection(I.create(o.doc, u.pos));
3192
+ }) : s.insertContent({ type: this.name }), s.command(({ tr: i, dispatch: l }) => {
3193
+ var a;
3194
+ if (l) {
3195
+ const { $to: c } = i.selection, d = c.end();
3196
+ if (c.nodeAfter)
3197
+ c.nodeAfter.isTextblock ? i.setSelection(x.create(i.doc, c.pos + 1)) : c.nodeAfter.isBlock ? i.setSelection(ue.create(i.doc, c.pos)) : i.setSelection(x.create(i.doc, c.pos));
1183
3198
  else {
1184
- const d = (l = u.parent.type.contentMatch.defaultType) === null || l === void 0 ? void 0 : l.create();
1185
- d && (o.insert(p, d), o.setSelection(I.create(o.doc, p + 1)));
3199
+ const u = (a = c.parent.type.contentMatch.defaultType) === null || a === void 0 ? void 0 : a.create();
3200
+ u && (i.insert(d, u), i.setSelection(x.create(i.doc, d + 1)));
1186
3201
  }
1187
- o.scrollIntoView();
3202
+ i.scrollIntoView();
1188
3203
  }
1189
3204
  return !0;
1190
3205
  }).run();
@@ -1193,13 +3208,13 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1193
3208
  },
1194
3209
  addInputRules() {
1195
3210
  return [
1196
- ee({
3211
+ qe({
1197
3212
  find: /^(?:---|—-|___\s|\*\*\*\s)$/,
1198
3213
  type: this.type
1199
3214
  })
1200
3215
  ];
1201
3216
  }
1202
- }), st = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, it = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, ot = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, at = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, lt = R.create({
3217
+ }), mo = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, go = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, bo = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, wo = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, yo = ee.create({
1203
3218
  name: "italic",
1204
3219
  addOptions() {
1205
3220
  return {
@@ -1225,7 +3240,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1225
3240
  ];
1226
3241
  },
1227
3242
  renderHTML({ HTMLAttributes: t }) {
1228
- return ["em", y(this.options.HTMLAttributes, t), 0];
3243
+ return ["em", v(this.options.HTMLAttributes, t), 0];
1229
3244
  },
1230
3245
  addCommands() {
1231
3246
  return {
@@ -1242,29 +3257,29 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1242
3257
  },
1243
3258
  addInputRules() {
1244
3259
  return [
1245
- A({
1246
- find: st,
3260
+ K({
3261
+ find: mo,
1247
3262
  type: this.type
1248
3263
  }),
1249
- A({
1250
- find: ot,
3264
+ K({
3265
+ find: bo,
1251
3266
  type: this.type
1252
3267
  })
1253
3268
  ];
1254
3269
  },
1255
3270
  addPasteRules() {
1256
3271
  return [
1257
- C({
1258
- find: it,
3272
+ j({
3273
+ find: go,
1259
3274
  type: this.type
1260
3275
  }),
1261
- C({
1262
- find: at,
3276
+ j({
3277
+ find: wo,
1263
3278
  type: this.type
1264
3279
  })
1265
3280
  ];
1266
3281
  }
1267
- }), ut = v.create({
3282
+ }), Co = k.create({
1268
3283
  name: "listItem",
1269
3284
  addOptions() {
1270
3285
  return {
@@ -1283,7 +3298,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1283
3298
  ];
1284
3299
  },
1285
3300
  renderHTML({ HTMLAttributes: t }) {
1286
- return ["li", y(this.options.HTMLAttributes, t), 0];
3301
+ return ["li", v(this.options.HTMLAttributes, t), 0];
1287
3302
  },
1288
3303
  addKeyboardShortcuts() {
1289
3304
  return {
@@ -1292,7 +3307,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1292
3307
  "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
1293
3308
  };
1294
3309
  }
1295
- }), dt = "listItem", Y = "textStyle", Z = /^(\d+)\.\s$/, pt = v.create({
3310
+ }), Mo = "listItem", Ke = "textStyle", je = /^(\d+)\.\s$/, vo = k.create({
1296
3311
  name: "orderedList",
1297
3312
  addOptions() {
1298
3313
  return {
@@ -1327,11 +3342,11 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1327
3342
  },
1328
3343
  renderHTML({ HTMLAttributes: t }) {
1329
3344
  const { start: e, ...n } = t;
1330
- return e === 1 ? ["ol", y(this.options.HTMLAttributes, n), 0] : ["ol", y(this.options.HTMLAttributes, t), 0];
3345
+ return e === 1 ? ["ol", v(this.options.HTMLAttributes, n), 0] : ["ol", v(this.options.HTMLAttributes, t), 0];
1331
3346
  },
1332
3347
  addCommands() {
1333
3348
  return {
1334
- toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(dt, this.editor.getAttributes(Y)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
3349
+ toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Mo, this.editor.getAttributes(Ke)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
1335
3350
  };
1336
3351
  },
1337
3352
  addKeyboardShortcuts() {
@@ -1340,25 +3355,25 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1340
3355
  };
1341
3356
  },
1342
3357
  addInputRules() {
1343
- let t = E({
1344
- find: Z,
3358
+ let t = G({
3359
+ find: je,
1345
3360
  type: this.type,
1346
3361
  getAttributes: (e) => ({ start: +e[1] }),
1347
3362
  joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1]
1348
3363
  });
1349
- return (this.options.keepMarks || this.options.keepAttributes) && (t = E({
1350
- find: Z,
3364
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = G({
3365
+ find: je,
1351
3366
  type: this.type,
1352
3367
  keepMarks: this.options.keepMarks,
1353
3368
  keepAttributes: this.options.keepAttributes,
1354
- getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(Y) }),
3369
+ getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(Ke) }),
1355
3370
  joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1],
1356
3371
  editor: this.editor
1357
3372
  })), [
1358
3373
  t
1359
3374
  ];
1360
3375
  }
1361
- }), ct = v.create({
3376
+ }), Ao = k.create({
1362
3377
  name: "paragraph",
1363
3378
  priority: 1e3,
1364
3379
  addOptions() {
@@ -1374,7 +3389,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1374
3389
  ];
1375
3390
  },
1376
3391
  renderHTML({ HTMLAttributes: t }) {
1377
- return ["p", y(this.options.HTMLAttributes, t), 0];
3392
+ return ["p", v(this.options.HTMLAttributes, t), 0];
1378
3393
  },
1379
3394
  addCommands() {
1380
3395
  return {
@@ -1386,7 +3401,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1386
3401
  "Mod-Alt-0": () => this.editor.commands.setParagraph()
1387
3402
  };
1388
3403
  }
1389
- }), ht = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, ft = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, mt = R.create({
3404
+ }), ko = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, To = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, So = ee.create({
1390
3405
  name: "strike",
1391
3406
  addOptions() {
1392
3407
  return {
@@ -1412,7 +3427,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1412
3427
  ];
1413
3428
  },
1414
3429
  renderHTML({ HTMLAttributes: t }) {
1415
- return ["s", y(this.options.HTMLAttributes, t), 0];
3430
+ return ["s", v(this.options.HTMLAttributes, t), 0];
1416
3431
  },
1417
3432
  addCommands() {
1418
3433
  return {
@@ -1428,71 +3443,188 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1428
3443
  },
1429
3444
  addInputRules() {
1430
3445
  return [
1431
- A({
1432
- find: ht,
3446
+ K({
3447
+ find: ko,
1433
3448
  type: this.type
1434
3449
  })
1435
3450
  ];
1436
3451
  },
1437
3452
  addPasteRules() {
1438
3453
  return [
1439
- C({
1440
- find: ft,
3454
+ j({
3455
+ find: To,
1441
3456
  type: this.type
1442
3457
  })
1443
3458
  ];
1444
3459
  }
1445
- }), gt = v.create({
3460
+ }), xo = k.create({
1446
3461
  name: "text",
1447
3462
  group: "inline"
1448
- }), yt = x.create({
3463
+ }), Lo = J.create({
1449
3464
  name: "starterKit",
1450
3465
  addExtensions() {
1451
- var t, e, n, r, s, i, o, a, l, u, p, d, c, f, b, S, L, D;
1452
- const m = [];
1453
- return this.options.bold !== !1 && m.push(Ae.configure((t = this.options) === null || t === void 0 ? void 0 : t.bold)), this.options.blockquote !== !1 && m.push(be.configure((e = this.options) === null || e === void 0 ? void 0 : e.blockquote)), this.options.bulletList !== !1 && m.push(Le.configure((n = this.options) === null || n === void 0 ? void 0 : n.bulletList)), this.options.code !== !1 && m.push(He.configure((r = this.options) === null || r === void 0 ? void 0 : r.code)), this.options.codeBlock !== !1 && m.push(Oe.configure((s = this.options) === null || s === void 0 ? void 0 : s.codeBlock)), this.options.document !== !1 && m.push(Pe.configure((i = this.options) === null || i === void 0 ? void 0 : i.document)), this.options.dropcursor !== !1 && m.push(Ne.configure((o = this.options) === null || o === void 0 ? void 0 : o.dropcursor)), this.options.gapcursor !== !1 && m.push(We.configure((a = this.options) === null || a === void 0 ? void 0 : a.gapcursor)), this.options.hardBreak !== !1 && m.push(je.configure((l = this.options) === null || l === void 0 ? void 0 : l.hardBreak)), this.options.heading !== !1 && m.push(Ge.configure((u = this.options) === null || u === void 0 ? void 0 : u.heading)), this.options.history !== !1 && m.push(nt.configure((p = this.options) === null || p === void 0 ? void 0 : p.history)), this.options.horizontalRule !== !1 && m.push(rt.configure((d = this.options) === null || d === void 0 ? void 0 : d.horizontalRule)), this.options.italic !== !1 && m.push(lt.configure((c = this.options) === null || c === void 0 ? void 0 : c.italic)), this.options.listItem !== !1 && m.push(ut.configure((f = this.options) === null || f === void 0 ? void 0 : f.listItem)), this.options.orderedList !== !1 && m.push(pt.configure((b = this.options) === null || b === void 0 ? void 0 : b.orderedList)), this.options.paragraph !== !1 && m.push(ct.configure((S = this.options) === null || S === void 0 ? void 0 : S.paragraph)), this.options.strike !== !1 && m.push(mt.configure((L = this.options) === null || L === void 0 ? void 0 : L.strike)), this.options.text !== !1 && m.push(gt.configure((D = this.options) === null || D === void 0 ? void 0 : D.text)), m;
3466
+ var t, e, n, o, r, s, i, l, a, c, d, u, p, h, f, m, g, w;
3467
+ const b = [];
3468
+ return this.options.bold !== !1 && b.push(On.configure((t = this.options) === null || t === void 0 ? void 0 : t.bold)), this.options.blockquote !== !1 && b.push(Rn.configure((e = this.options) === null || e === void 0 ? void 0 : e.blockquote)), this.options.bulletList !== !1 && b.push(zn.configure((n = this.options) === null || n === void 0 ? void 0 : n.bulletList)), this.options.code !== !1 && b.push(Bn.configure((o = this.options) === null || o === void 0 ? void 0 : o.code)), this.options.codeBlock !== !1 && b.push(Vn.configure((r = this.options) === null || r === void 0 ? void 0 : r.codeBlock)), this.options.document !== !1 && b.push(Fn.configure((s = this.options) === null || s === void 0 ? void 0 : s.document)), this.options.dropcursor !== !1 && b.push(qn.configure((i = this.options) === null || i === void 0 ? void 0 : i.dropcursor)), this.options.gapcursor !== !1 && b.push(eo.configure((l = this.options) === null || l === void 0 ? void 0 : l.gapcursor)), this.options.hardBreak !== !1 && b.push(to.configure((a = this.options) === null || a === void 0 ? void 0 : a.hardBreak)), this.options.heading !== !1 && b.push(no.configure((c = this.options) === null || c === void 0 ? void 0 : c.heading)), this.options.history !== !1 && b.push(ho.configure((d = this.options) === null || d === void 0 ? void 0 : d.history)), this.options.horizontalRule !== !1 && b.push(fo.configure((u = this.options) === null || u === void 0 ? void 0 : u.horizontalRule)), this.options.italic !== !1 && b.push(yo.configure((p = this.options) === null || p === void 0 ? void 0 : p.italic)), this.options.listItem !== !1 && b.push(Co.configure((h = this.options) === null || h === void 0 ? void 0 : h.listItem)), this.options.orderedList !== !1 && b.push(vo.configure((f = this.options) === null || f === void 0 ? void 0 : f.orderedList)), this.options.paragraph !== !1 && b.push(Ao.configure((m = this.options) === null || m === void 0 ? void 0 : m.paragraph)), this.options.strike !== !1 && b.push(So.configure((g = this.options) === null || g === void 0 ? void 0 : g.strike)), this.options.text !== !1 && b.push(xo.configure((w = this.options) === null || w === void 0 ? void 0 : w.text)), b;
1454
3469
  }
1455
- }), vt = x.create({
1456
- name: "focus",
3470
+ }), Ro = /^\s*(\[([( |x])?\])\s$/, Ho = k.create({
3471
+ name: "taskItem",
1457
3472
  addOptions() {
1458
3473
  return {
1459
- className: "has-focus",
1460
- mode: "all"
3474
+ nested: !1,
3475
+ HTMLAttributes: {},
3476
+ taskListTypeName: "taskList"
1461
3477
  };
1462
3478
  },
1463
- addProseMirrorPlugins() {
3479
+ content() {
3480
+ return this.options.nested ? "paragraph block*" : "paragraph+";
3481
+ },
3482
+ defining: !0,
3483
+ addAttributes() {
3484
+ return {
3485
+ checked: {
3486
+ default: !1,
3487
+ keepOnSplit: !1,
3488
+ parseHTML: (t) => {
3489
+ const e = t.getAttribute("data-checked");
3490
+ return e === "" || e === "true";
3491
+ },
3492
+ renderHTML: (t) => ({
3493
+ "data-checked": t.checked
3494
+ })
3495
+ }
3496
+ };
3497
+ },
3498
+ parseHTML() {
1464
3499
  return [
1465
- new H({
1466
- key: new P("focus"),
1467
- props: {
1468
- decorations: ({ doc: t, selection: e }) => {
1469
- const { isEditable: n, isFocused: r } = this.editor, { anchor: s } = e, i = [];
1470
- if (!n || !r)
1471
- return B.create(t, []);
1472
- let o = 0;
1473
- this.options.mode === "deepest" && t.descendants((l, u) => {
1474
- if (l.isText)
1475
- return;
1476
- if (!(s >= u && s <= u + l.nodeSize - 1))
1477
- return !1;
1478
- o += 1;
1479
- });
1480
- let a = 0;
1481
- return t.descendants((l, u) => {
1482
- if (l.isText || !(s >= u && s <= u + l.nodeSize - 1))
1483
- return !1;
1484
- if (a += 1, this.options.mode === "deepest" && o - a > 0 || this.options.mode === "shallowest" && a > 1)
1485
- return this.options.mode === "deepest";
1486
- i.push(F.node(u, u + l.nodeSize, {
1487
- class: this.options.className
1488
- }));
1489
- }), B.create(t, i);
3500
+ {
3501
+ tag: `li[data-type="${this.name}"]`,
3502
+ priority: 51
3503
+ }
3504
+ ];
3505
+ },
3506
+ renderHTML({ node: t, HTMLAttributes: e }) {
3507
+ return [
3508
+ "li",
3509
+ v(this.options.HTMLAttributes, e, {
3510
+ "data-type": this.name
3511
+ }),
3512
+ [
3513
+ "label",
3514
+ [
3515
+ "input",
3516
+ {
3517
+ type: "checkbox",
3518
+ checked: t.attrs.checked ? "checked" : null
1490
3519
  }
3520
+ ],
3521
+ ["span"]
3522
+ ],
3523
+ ["div", 0]
3524
+ ];
3525
+ },
3526
+ addKeyboardShortcuts() {
3527
+ const t = {
3528
+ Enter: () => this.editor.commands.splitListItem(this.name),
3529
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
3530
+ };
3531
+ return this.options.nested ? {
3532
+ ...t,
3533
+ Tab: () => this.editor.commands.sinkListItem(this.name)
3534
+ } : t;
3535
+ },
3536
+ addNodeView() {
3537
+ return ({ node: t, HTMLAttributes: e, getPos: n, editor: o }) => {
3538
+ const r = document.createElement("li"), s = document.createElement("label"), i = document.createElement("span"), l = document.createElement("input"), a = document.createElement("div");
3539
+ return s.contentEditable = "false", l.type = "checkbox", l.addEventListener("mousedown", (c) => c.preventDefault()), l.addEventListener("change", (c) => {
3540
+ if (!o.isEditable && !this.options.onReadOnlyChecked) {
3541
+ l.checked = !l.checked;
3542
+ return;
1491
3543
  }
3544
+ const { checked: d } = c.target;
3545
+ o.isEditable && typeof n == "function" && o.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: u }) => {
3546
+ const p = n();
3547
+ if (typeof p != "number")
3548
+ return !1;
3549
+ const h = u.doc.nodeAt(p);
3550
+ return u.setNodeMarkup(p, void 0, {
3551
+ ...h == null ? void 0 : h.attrs,
3552
+ checked: d
3553
+ }), !0;
3554
+ }).run(), !o.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, d) || (l.checked = !l.checked));
3555
+ }), Object.entries(this.options.HTMLAttributes).forEach(([c, d]) => {
3556
+ r.setAttribute(c, d);
3557
+ }), r.dataset.checked = t.attrs.checked, l.checked = t.attrs.checked, s.append(l, i), r.append(s, a), Object.entries(e).forEach(([c, d]) => {
3558
+ r.setAttribute(c, d);
3559
+ }), {
3560
+ dom: r,
3561
+ contentDOM: a,
3562
+ update: (c) => c.type !== this.type ? !1 : (r.dataset.checked = c.attrs.checked, l.checked = c.attrs.checked, !0)
3563
+ };
3564
+ };
3565
+ },
3566
+ addInputRules() {
3567
+ return [
3568
+ G({
3569
+ find: Ro,
3570
+ type: this.type,
3571
+ getAttributes: (t) => ({
3572
+ checked: t[t.length - 1] === "x"
3573
+ })
1492
3574
  })
1493
3575
  ];
1494
3576
  }
1495
- }), bt = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, Mt = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, kt = R.create({
3577
+ }), Eo = k.create({
3578
+ name: "taskList",
3579
+ addOptions() {
3580
+ return {
3581
+ itemTypeName: "taskItem",
3582
+ HTMLAttributes: {}
3583
+ };
3584
+ },
3585
+ group: "block list",
3586
+ content() {
3587
+ return `${this.options.itemTypeName}+`;
3588
+ },
3589
+ parseHTML() {
3590
+ return [
3591
+ {
3592
+ tag: `ul[data-type="${this.name}"]`,
3593
+ priority: 51
3594
+ }
3595
+ ];
3596
+ },
3597
+ renderHTML({ HTMLAttributes: t }) {
3598
+ return ["ul", v(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
3599
+ },
3600
+ addCommands() {
3601
+ return {
3602
+ toggleTaskList: () => ({ commands: t }) => t.toggleList(this.name, this.options.itemTypeName)
3603
+ };
3604
+ },
3605
+ addKeyboardShortcuts() {
3606
+ return {
3607
+ "Mod-Shift-9": () => this.editor.commands.toggleTaskList()
3608
+ };
3609
+ }
3610
+ }), Io = k.create({
3611
+ name: "tableRow",
3612
+ addOptions() {
3613
+ return {
3614
+ HTMLAttributes: {}
3615
+ };
3616
+ },
3617
+ content: "(tableCell | tableHeader)*",
3618
+ tableRole: "row",
3619
+ parseHTML() {
3620
+ return [
3621
+ { tag: "tr" }
3622
+ ];
3623
+ },
3624
+ renderHTML({ HTMLAttributes: t }) {
3625
+ return ["tr", v(this.options.HTMLAttributes, t), 0];
3626
+ }
3627
+ }), No = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, Oo = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, Po = ee.create({
1496
3628
  name: "highlight",
1497
3629
  addOptions() {
1498
3630
  return {
@@ -1520,7 +3652,7 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1520
3652
  ];
1521
3653
  },
1522
3654
  renderHTML({ HTMLAttributes: t }) {
1523
- return ["mark", y(this.options.HTMLAttributes, t), 0];
3655
+ return ["mark", v(this.options.HTMLAttributes, t), 0];
1524
3656
  },
1525
3657
  addCommands() {
1526
3658
  return {
@@ -1536,87 +3668,157 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1536
3668
  },
1537
3669
  addInputRules() {
1538
3670
  return [
1539
- A({
1540
- find: bt,
3671
+ K({
3672
+ find: No,
1541
3673
  type: this.type
1542
3674
  })
1543
3675
  ];
1544
3676
  },
1545
3677
  addPasteRules() {
1546
3678
  return [
1547
- C({
1548
- find: Mt,
3679
+ j({
3680
+ find: Oo,
1549
3681
  type: this.type
1550
3682
  })
1551
3683
  ];
1552
3684
  }
1553
- }), Tt = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, wt = v.create({
1554
- name: "image",
3685
+ }), zo = k.create({
3686
+ name: "tableCell",
1555
3687
  addOptions() {
1556
3688
  return {
1557
- inline: !1,
1558
- allowBase64: !1,
1559
3689
  HTMLAttributes: {}
1560
3690
  };
1561
3691
  },
1562
- inline() {
1563
- return this.options.inline;
1564
- },
1565
- group() {
1566
- return this.options.inline ? "inline" : "block";
1567
- },
1568
- draggable: !0,
3692
+ content: "block+",
1569
3693
  addAttributes() {
1570
3694
  return {
1571
- src: {
1572
- default: null
3695
+ colspan: {
3696
+ default: 1
1573
3697
  },
1574
- alt: {
1575
- default: null
3698
+ rowspan: {
3699
+ default: 1
1576
3700
  },
1577
- title: {
1578
- default: null
3701
+ colwidth: {
3702
+ default: null,
3703
+ parseHTML: (t) => {
3704
+ const e = t.getAttribute("colwidth");
3705
+ return e ? e.split(",").map((o) => parseInt(o, 10)) : null;
3706
+ }
1579
3707
  }
1580
3708
  };
1581
3709
  },
3710
+ tableRole: "cell",
3711
+ isolating: !0,
1582
3712
  parseHTML() {
1583
3713
  return [
1584
- {
1585
- tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
1586
- }
3714
+ { tag: "td" }
1587
3715
  ];
1588
3716
  },
1589
3717
  renderHTML({ HTMLAttributes: t }) {
1590
- return ["img", y(this.options.HTMLAttributes, t)];
1591
- },
1592
- addCommands() {
3718
+ return ["td", v(this.options.HTMLAttributes, t), 0];
3719
+ }
3720
+ }), $o = J.create({
3721
+ name: "placeholder",
3722
+ addOptions() {
1593
3723
  return {
1594
- setImage: (t) => ({ commands: e }) => e.insertContent({
1595
- type: this.name,
1596
- attrs: t
1597
- })
3724
+ emptyEditorClass: "is-editor-empty",
3725
+ emptyNodeClass: "is-empty",
3726
+ placeholder: "Write something …",
3727
+ showOnlyWhenEditable: !0,
3728
+ showOnlyCurrent: !0,
3729
+ includeChildren: !1
1598
3730
  };
1599
3731
  },
1600
- addInputRules() {
3732
+ addProseMirrorPlugins() {
1601
3733
  return [
1602
- ee({
1603
- find: Tt,
1604
- type: this.type,
1605
- getAttributes: (t) => {
1606
- const [, , e, n, r] = t;
1607
- return { src: n, alt: e, title: r };
3734
+ new B({
3735
+ key: new D("placeholder"),
3736
+ props: {
3737
+ decorations: ({ doc: t, selection: e }) => {
3738
+ const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: o } = e, r = [];
3739
+ if (!n)
3740
+ return null;
3741
+ const s = this.editor.isEmpty;
3742
+ return t.descendants((i, l) => {
3743
+ const a = o >= l && o <= l + i.nodeSize, c = !i.isLeaf && gt(i);
3744
+ if ((a || !this.options.showOnlyCurrent) && c) {
3745
+ const d = [this.options.emptyNodeClass];
3746
+ s && d.push(this.options.emptyEditorClass);
3747
+ const u = X.node(l, l + i.nodeSize, {
3748
+ class: d.join(" "),
3749
+ "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
3750
+ editor: this.editor,
3751
+ node: i,
3752
+ pos: l,
3753
+ hasAnchor: a
3754
+ }) : this.options.placeholder
3755
+ });
3756
+ r.push(u);
3757
+ }
3758
+ return this.options.includeChildren;
3759
+ }), F.create(t, r);
3760
+ }
1608
3761
  }
1609
3762
  })
1610
3763
  ];
1611
3764
  }
1612
- }), St = (t) => [
1613
- yt.configure({
3765
+ }), _o = k.create({
3766
+ name: "tableHeader",
3767
+ addOptions() {
3768
+ return {
3769
+ HTMLAttributes: {}
3770
+ };
3771
+ },
3772
+ content: "block+",
3773
+ addAttributes() {
3774
+ return {
3775
+ colspan: {
3776
+ default: 1
3777
+ },
3778
+ rowspan: {
3779
+ default: 1
3780
+ },
3781
+ colwidth: {
3782
+ default: null,
3783
+ parseHTML: (t) => {
3784
+ const e = t.getAttribute("colwidth");
3785
+ return e ? e.split(",").map((o) => parseInt(o, 10)) : null;
3786
+ }
3787
+ }
3788
+ };
3789
+ },
3790
+ tableRole: "header_cell",
3791
+ isolating: !0,
3792
+ parseHTML() {
3793
+ return [
3794
+ { tag: "th" }
3795
+ ];
3796
+ },
3797
+ renderHTML({ HTMLAttributes: t }) {
3798
+ return ["th", v(this.options.HTMLAttributes, t), 0];
3799
+ }
3800
+ }), qo = (t) => [
3801
+ Lo.configure({
1614
3802
  dropcursor: {
1615
3803
  width: 4,
1616
3804
  color: "#ebf6fe"
1617
3805
  }
1618
3806
  }),
1619
- ye.configure({
3807
+ Eo.configure({
3808
+ HTMLAttributes: {
3809
+ class: "scribe-task-list"
3810
+ }
3811
+ }),
3812
+ Ho.configure({
3813
+ nested: !0
3814
+ }),
3815
+ xn.configure({
3816
+ resizable: !0
3817
+ }),
3818
+ Io,
3819
+ _o,
3820
+ zo,
3821
+ $o.configure({
1620
3822
  showOnlyWhenEditable: !0,
1621
3823
  includeChildren: !0,
1622
3824
  showOnlyCurrent: !1,
@@ -1624,17 +3826,17 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1624
3826
  emptyNodeClass: "is-node-empty",
1625
3827
  placeholder: ({ editor: e, node: n }) => e.isDestroyed ? "" : n.type.name === "heading" ? `Heading ${n.attrs.level}` : t.placeholderText || 'Type "/" for commands...'
1626
3828
  }),
1627
- vt.configure({ mode: "deepest", className: "has-focus" }),
1628
- ce.configure({
3829
+ Mt.configure({ mode: "deepest", className: "has-focus" }),
3830
+ bt.configure({
1629
3831
  slashSuggestion: {
1630
- items: he,
1631
- render: fe
3832
+ items: Ct,
3833
+ render: yt
1632
3834
  }
1633
3835
  }),
1634
- kt,
1635
- me,
1636
- ge,
1637
- wt.configure({
3836
+ Po,
3837
+ wt,
3838
+ ct,
3839
+ At.configure({
1638
3840
  inline: !0,
1639
3841
  HTMLAttributes: {
1640
3842
  class: "scribe-image-node"
@@ -1643,5 +3845,5 @@ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1643
3845
  })
1644
3846
  ];
1645
3847
  export {
1646
- St as initExtensions
3848
+ qo as initExtensions
1647
3849
  };