@clevertask/scribe 0.0.2 → 0.0.4

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