@uva-glass/component-library 3.42.3 → 3.42.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/{Lexical.prod-qYl_ifJ6.js → Lexical.prod-nXWuyOKD.js} +1299 -1322
  2. package/dist/Lexical.prod-nXWuyOKD.js.map +1 -0
  3. package/dist/{LexicalClipboard.prod-DIGbXq4v.js → LexicalClipboard.prod-BP8LNbol.js} +104 -104
  4. package/dist/LexicalClipboard.prod-BP8LNbol.js.map +1 -0
  5. package/dist/{LexicalLink.prod-ZZwC5ABn.js → LexicalLink.prod-Brzpgs_K.js} +51 -51
  6. package/dist/{LexicalLink.prod-ZZwC5ABn.js.map → LexicalLink.prod-Brzpgs_K.js.map} +1 -1
  7. package/dist/{LexicalList.prod-UurCu6DK.js → LexicalList.prod-D6IAptR7.js} +53 -53
  8. package/dist/{LexicalList.prod-UurCu6DK.js.map → LexicalList.prod-D6IAptR7.js.map} +1 -1
  9. package/dist/LexicalSelection.prod-ZvNRDI9l.js +119 -0
  10. package/dist/LexicalSelection.prod-ZvNRDI9l.js.map +1 -0
  11. package/dist/LexicalTable.prod-DJktN6jF.js +1763 -0
  12. package/dist/LexicalTable.prod-DJktN6jF.js.map +1 -0
  13. package/dist/{LexicalUtils.prod-C3To3vrm.js → LexicalUtils.prod-Ckfw0Hjt.js} +34 -34
  14. package/dist/{LexicalUtils.prod-C3To3vrm.js.map → LexicalUtils.prod-Ckfw0Hjt.js.map} +1 -1
  15. package/dist/{TableCellResizerPlugin-B9MT1fxA.js → TableCellResizerPlugin-DFzNK-ve.js} +32 -32
  16. package/dist/{TableCellResizerPlugin-B9MT1fxA.js.map → TableCellResizerPlugin-DFzNK-ve.js.map} +1 -1
  17. package/dist/{TablePlugin-FQQwnq2m.js → TablePlugin-CAoOq8iA.js} +52 -52
  18. package/dist/{TablePlugin-FQQwnq2m.js.map → TablePlugin-CAoOq8iA.js.map} +1 -1
  19. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  20. package/dist/components/FormInput/FormInput.js +1 -1
  21. package/dist/components/InputField/InputField.stories.js +1 -1
  22. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  23. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  24. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  25. package/dist/components/MultiSelect/index.js +1 -1
  26. package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
  27. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
  28. package/dist/components/RadioTabSelector/RadioTabSelector.js +1 -1
  29. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  30. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +6 -6
  31. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +6 -6
  32. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
  33. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
  34. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +35 -35
  35. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  36. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +27 -27
  37. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +5 -5
  38. package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.js +4 -4
  39. package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/index.js +1 -1
  40. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  41. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +4 -4
  42. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +7 -7
  43. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  44. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +18 -18
  45. package/dist/components/RteEditor/Plugins/index.js +2 -2
  46. package/dist/components/RteEditor/RteEditor.js +233 -233
  47. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  48. package/dist/components/RteEditor/helpers.js +32 -33
  49. package/dist/components/RteEditor/helpers.js.map +1 -1
  50. package/dist/components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js +16 -16
  51. package/dist/components/index.js +1 -1
  52. package/dist/{helpers-D3SODeVc.js → helpers-mE437H2Y.js} +38 -38
  53. package/dist/{helpers-D3SODeVc.js.map → helpers-mE437H2Y.js.map} +1 -1
  54. package/dist/index.js +1 -1
  55. package/package.json +6 -6
  56. package/dist/Lexical.prod-qYl_ifJ6.js.map +0 -1
  57. package/dist/LexicalClipboard.prod-DIGbXq4v.js.map +0 -1
  58. package/dist/LexicalSelection.prod-DXruZeFN.js +0 -103
  59. package/dist/LexicalSelection.prod-DXruZeFN.js.map +0 -1
  60. package/dist/LexicalTable.prod-COFf1Spn.js +0 -1763
  61. package/dist/LexicalTable.prod-COFf1Spn.js.map +0 -1
@@ -1,1763 +0,0 @@
1
- import { w as T, r as G, i as ge, _ as Rt, j as Vt, b as jt, T as Ft, S as Qt, L as Gt } from "./LexicalUtils.prod-C3To3vrm.js";
2
- import { m as tt, k as Ne, P as L, _ as M, g as nt, e as Zt, s as _e, h as dt, B as U, i as ot, j as en, l as Ot, T as re, n as Ee, W as rt, x as D, E as tn, Q as nn, U as on, p as rn, J as De, r as Kt, d as ln, t as ye, F as Ue, S as Ae, u as sn, D as an, w as cn, z as un, A as Ie, K as hn, C as dn, G as At, H as fn, V as j, L as gn, N as mn, R as pn, X as _n, Y as Cn, Z as Sn, a0 as wn, a1 as bn, a2 as fe, M as ne, a3 as Me, a4 as yn, a as Et, a5 as Nn, a6 as vn, f as xn, a7 as Tn, a8 as Rn, a9 as ft, aa as Fn, ab as gt, o as On, ac as mt, O as pt, v as Re, ad as Kn } from "./Lexical.prod-qYl_ifJ6.js";
3
- import { F as An, J as En } from "./LexicalClipboard.prod-DIGbXq4v.js";
4
- const lt = /^(\d+(?:\.\d+)?)px$/, W = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
5
- class ce extends tt {
6
- static getType() {
7
- return "tablecell";
8
- }
9
- static clone(e) {
10
- return new ce(e.__headerState, e.__colSpan, e.__width, e.__key);
11
- }
12
- afterCloneFrom(e) {
13
- super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign;
14
- }
15
- static importDOM() {
16
- return { td: (e) => ({ conversion: _t, priority: 0 }), th: (e) => ({ conversion: _t, priority: 0 }) };
17
- }
18
- static importJSON(e) {
19
- return X().updateFromJSON(e);
20
- }
21
- updateFromJSON(e) {
22
- return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan || 1).setRowSpan(e.rowSpan || 1).setWidth(e.width || void 0).setBackgroundColor(e.backgroundColor || null).setVerticalAlign(e.verticalAlign || void 0);
23
- }
24
- constructor(e = W.NO_STATUS, t = 1, o, r) {
25
- super(r), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = o, this.__backgroundColor = null, this.__verticalAlign = void 0;
26
- }
27
- createDOM(e) {
28
- const t = document.createElement(this.getTag());
29
- return this.__width && (t.style.width = `${this.__width}px`), this.__colSpan > 1 && (t.colSpan = this.__colSpan), this.__rowSpan > 1 && (t.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (t.style.backgroundColor = this.__backgroundColor), Ye(this.__verticalAlign) && (t.style.verticalAlign = this.__verticalAlign), G(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
30
- }
31
- exportDOM(e) {
32
- const t = super.exportDOM(e);
33
- if (Ne(t.element)) {
34
- const o = t.element;
35
- o.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), o.style.border = "1px solid black", this.__colSpan > 1 && (o.colSpan = this.__colSpan), this.__rowSpan > 1 && (o.rowSpan = this.__rowSpan), o.style.width = `${this.getWidth() || 75}px`, o.style.verticalAlign = this.getVerticalAlign() || "top", o.style.textAlign = "start", this.__backgroundColor === null && this.hasHeader() && (o.style.backgroundColor = "#f2f3f5");
36
- }
37
- return t;
38
- }
39
- exportJSON() {
40
- return { ...super.exportJSON(), ...Ye(this.__verticalAlign) && { verticalAlign: this.__verticalAlign }, backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, width: this.getWidth() };
41
- }
42
- getColSpan() {
43
- return this.getLatest().__colSpan;
44
- }
45
- setColSpan(e) {
46
- const t = this.getWritable();
47
- return t.__colSpan = e, t;
48
- }
49
- getRowSpan() {
50
- return this.getLatest().__rowSpan;
51
- }
52
- setRowSpan(e) {
53
- const t = this.getWritable();
54
- return t.__rowSpan = e, t;
55
- }
56
- getTag() {
57
- return this.hasHeader() ? "th" : "td";
58
- }
59
- setHeaderStyles(e, t = W.BOTH) {
60
- const o = this.getWritable();
61
- return o.__headerState = e & t | o.__headerState & ~t, o;
62
- }
63
- getHeaderStyles() {
64
- return this.getLatest().__headerState;
65
- }
66
- setWidth(e) {
67
- const t = this.getWritable();
68
- return t.__width = e, t;
69
- }
70
- getWidth() {
71
- return this.getLatest().__width;
72
- }
73
- getBackgroundColor() {
74
- return this.getLatest().__backgroundColor;
75
- }
76
- setBackgroundColor(e) {
77
- const t = this.getWritable();
78
- return t.__backgroundColor = e, t;
79
- }
80
- getVerticalAlign() {
81
- return this.getLatest().__verticalAlign;
82
- }
83
- setVerticalAlign(e) {
84
- const t = this.getWritable();
85
- return t.__verticalAlign = e || void 0, t;
86
- }
87
- toggleHeaderStyle(e) {
88
- const t = this.getWritable();
89
- return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
90
- }
91
- hasHeaderState(e) {
92
- return (this.getHeaderStyles() & e) === e;
93
- }
94
- hasHeader() {
95
- return this.getLatest().__headerState !== W.NO_STATUS;
96
- }
97
- updateDOM(e) {
98
- return e.__headerState !== this.__headerState || e.__width !== this.__width || e.__colSpan !== this.__colSpan || e.__rowSpan !== this.__rowSpan || e.__backgroundColor !== this.__backgroundColor || e.__verticalAlign !== this.__verticalAlign;
99
- }
100
- isShadowRoot() {
101
- return !0;
102
- }
103
- collapseAtStart() {
104
- return !0;
105
- }
106
- canBeEmpty() {
107
- return !1;
108
- }
109
- canIndent() {
110
- return !1;
111
- }
112
- }
113
- function Ye(n) {
114
- return n === "middle" || n === "bottom";
115
- }
116
- function _t(n) {
117
- const e = n, t = n.nodeName.toLowerCase();
118
- let o;
119
- lt.test(e.style.width) && (o = parseFloat(e.style.width));
120
- const r = X(t === "th" ? W.ROW : W.NO_STATUS, e.colSpan, o);
121
- r.__rowSpan = e.rowSpan;
122
- const s = e.style.backgroundColor;
123
- s !== "" && (r.__backgroundColor = s);
124
- const l = e.style.verticalAlign;
125
- Ye(l) && (r.__verticalAlign = l);
126
- const i = e.style, u = (i && i.textDecoration || "").split(" "), f = i.fontWeight === "700" || i.fontWeight === "bold", h = u.includes("line-through"), p = i.fontStyle === "italic", _ = u.includes("underline");
127
- return { after: (a) => {
128
- const c = [];
129
- let g = null;
130
- const d = () => {
131
- if (g) {
132
- const m = g.getFirstChild();
133
- dt(m) && g.getChildrenSize() === 1 && m.remove();
134
- }
135
- };
136
- for (const m of a) Zt(m) || _e(m) || dt(m) ? (_e(m) && (f && m.toggleFormat("bold"), h && m.toggleFormat("strikethrough"), p && m.toggleFormat("italic"), _ && m.toggleFormat("underline")), g ? g.append(m) : (g = U().append(m), c.push(g))) : (c.push(m), d(), g = null);
137
- return d(), c.length === 0 && c.push(U()), c;
138
- }, node: r };
139
- }
140
- function X(n = W.NO_STATUS, e = 1, t) {
141
- return nt(new ce(n, e, t));
142
- }
143
- function b(n) {
144
- return n instanceof ce;
145
- }
146
- const kn = ln("INSERT_TABLE_COMMAND");
147
- function w(n, ...e) {
148
- const t = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
149
- o.append("code", n);
150
- for (const r of e) o.append("v", r);
151
- throw t.search = o.toString(), Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
152
- }
153
- class Te extends tt {
154
- static getType() {
155
- return "tablerow";
156
- }
157
- static clone(e) {
158
- return new Te(e.__height, e.__key);
159
- }
160
- static importDOM() {
161
- return { tr: (e) => ({ conversion: $n, priority: 0 }) };
162
- }
163
- static importJSON(e) {
164
- return xe().updateFromJSON(e);
165
- }
166
- updateFromJSON(e) {
167
- return super.updateFromJSON(e).setHeight(e.height);
168
- }
169
- constructor(e, t) {
170
- super(t), this.__height = e;
171
- }
172
- exportJSON() {
173
- const e = this.getHeight();
174
- return { ...super.exportJSON(), ...e === void 0 ? void 0 : { height: e } };
175
- }
176
- createDOM(e) {
177
- const t = document.createElement("tr");
178
- return this.__height && (t.style.height = `${this.__height}px`), G(t, e.theme.tableRow), t;
179
- }
180
- extractWithChild(e, t, o) {
181
- return o === "html";
182
- }
183
- isShadowRoot() {
184
- return !0;
185
- }
186
- setHeight(e) {
187
- const t = this.getWritable();
188
- return t.__height = e, t;
189
- }
190
- getHeight() {
191
- return this.getLatest().__height;
192
- }
193
- updateDOM(e) {
194
- return e.__height !== this.__height;
195
- }
196
- canBeEmpty() {
197
- return !1;
198
- }
199
- canIndent() {
200
- return !1;
201
- }
202
- }
203
- function $n(n) {
204
- const e = n;
205
- let t;
206
- return lt.test(e.style.height) && (t = parseFloat(e.style.height)), { after: (o) => Rt(o, b), node: xe(t) };
207
- }
208
- function xe(n) {
209
- return nt(new Te(n));
210
- }
211
- function k(n) {
212
- return n instanceof Te;
213
- }
214
- const st = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, Mn = st && "documentMode" in document ? document.documentMode : null, Ct = st && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
215
- function zn(n, e, t = !0) {
216
- const o = ct();
217
- for (let r = 0; r < n; r++) {
218
- const s = xe();
219
- for (let l = 0; l < e; l++) {
220
- let i = W.NO_STATUS;
221
- typeof t == "object" ? (r === 0 && t.rows && (i |= W.ROW), l === 0 && t.columns && (i |= W.COLUMN)) : t && (r === 0 && (i |= W.ROW), l === 0 && (i |= W.COLUMN));
222
- const u = X(i), f = U();
223
- f.append(ot()), u.append(f), s.append(u);
224
- }
225
- o.append(s);
226
- }
227
- return o;
228
- }
229
- function io(n) {
230
- const e = T(n, ((t) => b(t)));
231
- return b(e) ? e : null;
232
- }
233
- function kt(n) {
234
- const e = T(n, ((t) => k(t)));
235
- if (k(e)) return e;
236
- throw new Error("Expected table cell to be inside of table row.");
237
- }
238
- function $t(n) {
239
- const e = T(n, ((t) => $(t)));
240
- if ($(e)) return e;
241
- throw new Error("Expected table cell to be inside of table.");
242
- }
243
- function ao(n) {
244
- const e = kt(n);
245
- return $t(e).getChildren().findIndex(((t) => t.is(e)));
246
- }
247
- function co(n) {
248
- return kt(n).getChildren().findIndex(((e) => e.is(n)));
249
- }
250
- st && "InputEvent" in window && !Mn && new window.InputEvent("input");
251
- const Xe = (n, e) => n === W.BOTH || n === e ? e : W.NO_STATUS;
252
- function uo(n = !0) {
253
- const e = L();
254
- M(e) || O(e) || w(188);
255
- const t = e.anchor.getNode(), o = e.focus.getNode(), [r] = I(t), [s, , l] = I(o), [, i, u] = J(l, s, r), { startRow: f } = u, { startRow: h } = i;
256
- return n ? qe(f + r.__rowSpan > h + s.__rowSpan ? r : s, !0) : qe(h < f ? s : r, !1);
257
- }
258
- function qe(n, e = !0) {
259
- const [, , t] = I(n), [o, r] = J(t, n, n), s = o[0].length, { startRow: l } = r;
260
- let i = null;
261
- if (e) {
262
- const u = l + n.__rowSpan - 1, f = o[u], h = xe();
263
- for (let _ = 0; _ < s; _++) {
264
- const { cell: a, startRow: c } = f[_];
265
- if (c + a.__rowSpan - 1 <= u) {
266
- const g = f[_].cell.__headerState, d = Xe(g, W.COLUMN);
267
- h.append(X(d).append(U()));
268
- } else a.setRowSpan(a.__rowSpan + 1);
269
- }
270
- const p = t.getChildAtIndex(u);
271
- k(p) || w(256), p.insertAfter(h), i = h;
272
- } else {
273
- const u = l, f = o[u], h = xe();
274
- for (let _ = 0; _ < s; _++) {
275
- const { cell: a, startRow: c } = f[_];
276
- if (c === u) {
277
- const g = f[_].cell.__headerState, d = Xe(g, W.COLUMN);
278
- h.append(X(d).append(U()));
279
- } else a.setRowSpan(a.__rowSpan + 1);
280
- }
281
- const p = t.getChildAtIndex(u);
282
- k(p) || w(257), p.insertBefore(h), i = h;
283
- }
284
- return i;
285
- }
286
- function ho(n = !0) {
287
- const e = L();
288
- M(e) || O(e) || w(188);
289
- const t = e.anchor.getNode(), o = e.focus.getNode(), [r] = I(t), [s, , l] = I(o), [, i, u] = J(l, s, r), { startColumn: f } = u, { startColumn: h } = i;
290
- return n ? Ve(f + r.__colSpan > h + s.__colSpan ? r : s, !0) : Ve(h < f ? s : r, !1);
291
- }
292
- function Ve(n, e = !0, t = !0) {
293
- const [, , o] = I(n), [r, s] = J(o, n, n), l = r.length, { startColumn: i } = s, u = e ? i + n.__colSpan - 1 : i - 1, f = o.getFirstChild();
294
- k(f) || w(120);
295
- let h = null;
296
- function p(c = W.NO_STATUS) {
297
- const g = X(c).append(U());
298
- return h === null && (h = g), g;
299
- }
300
- let _ = f;
301
- e: for (let c = 0; c < l; c++) {
302
- if (c !== 0) {
303
- const y = _.getNextSibling();
304
- k(y) || w(121), _ = y;
305
- }
306
- const g = r[c], d = g[u < 0 ? 0 : u].cell.__headerState, m = Xe(d, W.ROW);
307
- if (u < 0) {
308
- Mt(_, p(m));
309
- continue;
310
- }
311
- const { cell: C, startColumn: S, startRow: N } = g[u];
312
- if (S + C.__colSpan - 1 <= u) {
313
- let y = C, v = N, R = u;
314
- for (; v !== c && y.__rowSpan > 1; ) {
315
- if (R -= C.__colSpan, !(R >= 0)) {
316
- _.append(p(m));
317
- continue e;
318
- }
319
- {
320
- const { cell: E, startRow: A } = g[R];
321
- y = E, v = A;
322
- }
323
- }
324
- y.insertAfter(p(m));
325
- } else C.setColSpan(C.__colSpan + 1);
326
- }
327
- h !== null && t && je(h);
328
- const a = o.getColWidths();
329
- if (a) {
330
- const c = [...a], g = u < 0 ? 0 : u, d = c[g];
331
- c.splice(g, 0, d), o.setColWidths(c);
332
- }
333
- return h;
334
- }
335
- function fo() {
336
- const n = L();
337
- M(n) || O(n) || w(188);
338
- const e = n.anchor.getNode(), t = n.focus.getNode(), [o, , r] = I(e), [s] = I(t), [l, i, u] = J(r, o, s), { startColumn: f } = i, { startRow: h, startColumn: p } = u, _ = Math.min(f, p), a = Math.max(f + o.__colSpan - 1, p + s.__colSpan - 1), c = a - _ + 1;
339
- if (l[0].length === a - _ + 1) return r.selectPrevious(), void r.remove();
340
- const g = l.length;
341
- for (let S = 0; S < g; S++) for (let N = _; N <= a; N++) {
342
- const { cell: y, startColumn: v } = l[S][N];
343
- if (v < _) {
344
- if (N === _) {
345
- const R = _ - v;
346
- y.setColSpan(y.__colSpan - Math.min(c, y.__colSpan - R));
347
- }
348
- } else if (v + y.__colSpan - 1 > a) {
349
- if (N === a) {
350
- const R = a - v + 1;
351
- y.setColSpan(y.__colSpan - R);
352
- }
353
- } else y.remove();
354
- }
355
- const d = l[h], m = f > p ? d[f + o.__colSpan] : d[p + s.__colSpan];
356
- if (m !== void 0) {
357
- const { cell: S } = m;
358
- je(S);
359
- } else {
360
- const S = p < f ? d[p - 1] : d[f - 1], { cell: N } = S;
361
- je(N);
362
- }
363
- const C = r.getColWidths();
364
- if (C) {
365
- const S = [...C];
366
- S.splice(_, c), r.setColWidths(S);
367
- }
368
- }
369
- function je(n) {
370
- const e = n.getFirstDescendant();
371
- e == null ? n.selectStart() : e.getParentOrThrow().selectStart();
372
- }
373
- function Mt(n, e) {
374
- const t = n.getFirstChild();
375
- t !== null ? t.insertBefore(e) : n.append(e);
376
- }
377
- function Ln(n) {
378
- if (n.length === 0) return null;
379
- const e = $t(n[0]), [t] = oe(e, null, null);
380
- let o = 1 / 0, r = -1 / 0, s = 1 / 0, l = -1 / 0;
381
- const i = /* @__PURE__ */ new Set();
382
- for (const a of t) for (const c of a) {
383
- if (!c || !c.cell) continue;
384
- const g = c.cell.getKey();
385
- if (!i.has(g) && n.some(((d) => d.is(c.cell)))) {
386
- i.add(g);
387
- const d = c.startRow, m = c.startColumn, C = c.cell.__rowSpan || 1, S = c.cell.__colSpan || 1;
388
- o = Math.min(o, d), r = Math.max(r, d + C - 1), s = Math.min(s, m), l = Math.max(l, m + S - 1);
389
- }
390
- }
391
- if (o === 1 / 0 || s === 1 / 0) return null;
392
- const u = r - o + 1, f = l - s + 1, h = t[o][s];
393
- if (!h.cell) return null;
394
- const p = h.cell;
395
- p.setColSpan(f), p.setRowSpan(u);
396
- const _ = /* @__PURE__ */ new Set([p.getKey()]);
397
- for (let a = o; a <= r; a++) for (let c = s; c <= l; c++) {
398
- const g = t[a][c];
399
- if (!g.cell) continue;
400
- const d = g.cell, m = d.getKey();
401
- _.has(m) || (_.add(m), Wn(d) || p.append(...d.getChildren()), d.remove());
402
- }
403
- return p.getChildrenSize() === 0 && p.append(U()), p;
404
- }
405
- function Wn(n) {
406
- if (n.getChildrenSize() !== 1) return !1;
407
- const e = n.getFirstChildOrThrow();
408
- return !(!rt(e) || !e.isEmpty());
409
- }
410
- function Pn(n) {
411
- const [e, t, o] = I(n), r = e.__colSpan, s = e.__rowSpan;
412
- if (r === 1 && s === 1) return;
413
- const [l, i] = J(o, e, e), { startColumn: u, startRow: f } = i, h = e.__headerState & W.COLUMN, p = Array.from({ length: r }, ((c, g) => {
414
- let d = h;
415
- for (let m = 0; d !== 0 && m < l.length; m++) d &= l[m][g + u].cell.__headerState;
416
- return d;
417
- })), _ = e.__headerState & W.ROW, a = Array.from({ length: s }, ((c, g) => {
418
- let d = _;
419
- for (let m = 0; d !== 0 && m < l[0].length; m++) d &= l[g + f][m].cell.__headerState;
420
- return d;
421
- }));
422
- if (r > 1) {
423
- for (let c = 1; c < r; c++) e.insertAfter(X(p[c] | a[0]).append(U()));
424
- e.setColSpan(1);
425
- }
426
- if (s > 1) {
427
- let c;
428
- for (let g = 1; g < s; g++) {
429
- const d = f + g, m = l[d];
430
- c = (c || t).getNextSibling(), k(c) || w(125);
431
- let C = null;
432
- for (let S = 0; S < u; S++) {
433
- const N = m[S], y = N.cell;
434
- N.startRow === d && (C = y), y.__colSpan > 1 && (S += y.__colSpan - 1);
435
- }
436
- if (C === null) for (let S = r - 1; S >= 0; S--) Mt(c, X(p[S] | a[g]).append(U()));
437
- else for (let S = r - 1; S >= 0; S--) C.insertAfter(X(p[S] | a[g]).append(U()));
438
- }
439
- e.setRowSpan(1);
440
- }
441
- }
442
- function J(n, e, t) {
443
- const [o, r, s] = oe(n, e, t);
444
- return r === null && w(207), s === null && w(208), [o, r, s];
445
- }
446
- function oe(n, e, t) {
447
- const o = [];
448
- let r = null, s = null;
449
- function l(u) {
450
- let f = o[u];
451
- return f === void 0 && (o[u] = f = []), f;
452
- }
453
- const i = n.getChildren();
454
- for (let u = 0; u < i.length; u++) {
455
- const f = i[u];
456
- k(f) || w(209);
457
- const h = l(u);
458
- for (let p = f.getFirstChild(), _ = 0; p != null; p = p.getNextSibling()) {
459
- for (b(p) || w(147); h[_] !== void 0; ) _++;
460
- const a = { cell: p, startColumn: _, startRow: u }, { __rowSpan: c, __colSpan: g } = p;
461
- for (let d = 0; d < c && !(u + d >= i.length); d++) {
462
- const m = l(u + d);
463
- for (let C = 0; C < g; C++) m[_ + C] = a;
464
- }
465
- e !== null && r === null && e.is(p) && (r = a), t !== null && s === null && t.is(p) && (s = a);
466
- }
467
- }
468
- return [o, r, s];
469
- }
470
- function I(n) {
471
- let e;
472
- if (n instanceof ce) e = n;
473
- else if ("__type" in n) {
474
- const r = T(n, b);
475
- b(r) || w(148), e = r;
476
- } else {
477
- const r = T(n.getNode(), b);
478
- b(r) || w(148), e = r;
479
- }
480
- const t = e.getParent();
481
- k(t) || w(149);
482
- const o = t.getParent();
483
- return $(o) || w(210), [e, t, o];
484
- }
485
- function ke(n, e, t) {
486
- let o, r = Math.min(e.startColumn, t.startColumn), s = Math.min(e.startRow, t.startRow), l = Math.max(e.startColumn + e.cell.__colSpan - 1, t.startColumn + t.cell.__colSpan - 1), i = Math.max(e.startRow + e.cell.__rowSpan - 1, t.startRow + t.cell.__rowSpan - 1);
487
- do {
488
- o = !1;
489
- for (let u = 0; u < n.length; u++) for (let f = 0; f < n[0].length; f++) {
490
- const h = n[u][f];
491
- if (!h) continue;
492
- const p = h.startColumn + h.cell.__colSpan - 1, _ = h.startRow + h.cell.__rowSpan - 1, a = h.startColumn <= l && p >= r, c = h.startRow <= i && _ >= s;
493
- if (a && c) {
494
- const g = Math.min(r, h.startColumn), d = Math.max(l, p), m = Math.min(s, h.startRow), C = Math.max(i, _);
495
- g === r && d === l && m === s && C === i || (r = g, l = d, s = m, i = C, o = !0);
496
- }
497
- }
498
- } while (o);
499
- return { maxColumn: l, maxRow: i, minColumn: r, minRow: s };
500
- }
501
- function St(n) {
502
- const [e, , t] = I(n), o = t.getChildren(), r = o.length, s = o[0].getChildren().length, l = new Array(r);
503
- for (let i = 0; i < r; i++) l[i] = new Array(s);
504
- for (let i = 0; i < r; i++) {
505
- const u = o[i].getChildren();
506
- let f = 0;
507
- for (let h = 0; h < u.length; h++) {
508
- for (; l[i][f]; ) f++;
509
- const p = u[h], _ = p.__rowSpan || 1, a = p.__colSpan || 1;
510
- for (let c = 0; c < _; c++) for (let g = 0; g < a; g++) l[i + c][f + g] = p;
511
- if (e === p) return { colSpan: a, columnIndex: f, rowIndex: i, rowSpan: _ };
512
- f += a;
513
- }
514
- }
515
- return null;
516
- }
517
- function wt(n) {
518
- const [[e, t, o, r], [s, l, i, u]] = ["anchor", "focus"].map(((f) => {
519
- const h = n[f].getNode(), p = T(h, b);
520
- b(p) || w(238, f, h.getKey(), h.getType());
521
- const _ = p.getParent();
522
- k(_) || w(239, f);
523
- const a = _.getParent();
524
- return $(a) || w(240, f), [h, p, _, a];
525
- }));
526
- return r.is(u) || w(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: r, focusCell: l, focusNode: s, focusRow: i, focusTable: u };
527
- }
528
- class ze {
529
- constructor(e, t, o) {
530
- this.anchor = t, this.focus = o, t._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
531
- }
532
- getStartEndPoints() {
533
- return [this.anchor, this.focus];
534
- }
535
- isValid() {
536
- return this.tableKey !== "root" && this.anchor.key !== "root" && this.anchor.type === "element" && this.focus.key !== "root" && this.focus.type === "element";
537
- }
538
- isBackward() {
539
- return this.focus.isBefore(this.anchor);
540
- }
541
- getCachedNodes() {
542
- return this._cachedNodes;
543
- }
544
- setCachedNodes(e) {
545
- this._cachedNodes = e;
546
- }
547
- is(e) {
548
- return O(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
549
- }
550
- set(e, t, o) {
551
- this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || o !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = o, this._cachedNodes = null;
552
- }
553
- clone() {
554
- return new ze(this.tableKey, Ee(this.anchor.key, this.anchor.offset, this.anchor.type), Ee(this.focus.key, this.focus.offset, this.focus.type));
555
- }
556
- isCollapsed() {
557
- return !1;
558
- }
559
- extract() {
560
- return this.getNodes();
561
- }
562
- insertRawText(e) {
563
- }
564
- insertText() {
565
- }
566
- hasFormat(e) {
567
- let t = 0;
568
- this.getNodes().filter(b).forEach(((r) => {
569
- const s = r.getFirstChild();
570
- rt(s) && (t |= s.getTextFormat());
571
- }));
572
- const o = on[e];
573
- return !!(t & o);
574
- }
575
- insertNodes(e) {
576
- const t = this.focus.getNode();
577
- D(t) || w(151), tn(t.select(0, t.getChildrenSize())).insertNodes(e);
578
- }
579
- getShape() {
580
- const { anchorCell: e, focusCell: t } = wt(this), o = St(e);
581
- o === null && w(153);
582
- const r = St(t);
583
- r === null && w(155);
584
- const s = Math.min(o.columnIndex, r.columnIndex), l = Math.max(o.columnIndex + o.colSpan - 1, r.columnIndex + r.colSpan - 1), i = Math.min(o.rowIndex, r.rowIndex), u = Math.max(o.rowIndex + o.rowSpan - 1, r.rowIndex + r.rowSpan - 1);
585
- return { fromX: Math.min(s, l), fromY: Math.min(i, u), toX: Math.max(s, l), toY: Math.max(i, u) };
586
- }
587
- getNodes() {
588
- if (!this.isValid()) return [];
589
- const e = this._cachedNodes;
590
- if (e !== null) return e;
591
- const { anchorTable: t, anchorCell: o, focusCell: r } = wt(this), s = r.getParents()[1];
592
- if (s !== t) {
593
- if (t.isParentOf(r)) {
594
- const d = s.getParent();
595
- d == null && w(159), this.set(this.tableKey, r.getKey(), d.getKey());
596
- } else {
597
- const d = t.getParent();
598
- d == null && w(158), this.set(this.tableKey, d.getKey(), r.getKey());
599
- }
600
- return this.getNodes();
601
- }
602
- const [l, i, u] = J(t, o, r), { minColumn: f, maxColumn: h, minRow: p, maxRow: _ } = ke(l, i, u), a = /* @__PURE__ */ new Map([[t.getKey(), t]]);
603
- let c = null;
604
- for (let d = p; d <= _; d++) for (let m = f; m <= h; m++) {
605
- const { cell: C } = l[d][m], S = C.getParent();
606
- k(S) || w(160), S !== c && (a.set(S.getKey(), S), c = S), a.has(C.getKey()) || Bn(C, ((N) => {
607
- a.set(N.getKey(), N);
608
- }));
609
- }
610
- const g = Array.from(a.values());
611
- return nn() || (this._cachedNodes = g), g;
612
- }
613
- getTextContent() {
614
- const e = this.getNodes().filter(((o) => b(o)));
615
- let t = "";
616
- for (let o = 0; o < e.length; o++) {
617
- const r = e[o], s = r.__parent, l = (e[o + 1] || {}).__parent;
618
- t += r.getTextContent() + (l !== s ? `
619
- ` : " ");
620
- }
621
- return t;
622
- }
623
- }
624
- function O(n) {
625
- return n instanceof ze;
626
- }
627
- function zt() {
628
- const n = Ee("root", 0, "element"), e = Ee("root", 0, "element");
629
- return new ze("root", n, e);
630
- }
631
- function Hn(n, e, t) {
632
- n.getKey(), e.getKey(), t.getKey();
633
- const o = L(), r = O(o) ? o.clone() : zt();
634
- return r.set(n.getKey(), e.getKey(), t.getKey()), r;
635
- }
636
- function Bn(n, e) {
637
- const t = [[n]];
638
- for (let o = t.at(-1); o !== void 0 && t.length > 0; o = t.at(-1)) {
639
- const r = o.pop();
640
- r === void 0 ? t.pop() : e(r) !== !1 && D(r) && t.push(r.getChildren());
641
- }
642
- }
643
- function Lt(n, e = Ot()) {
644
- const t = Ae(n);
645
- $(t) || w(231, n);
646
- const o = ie(t, e.getElementByKey(n));
647
- return o === null && w(232, n), { tableElement: o, tableNode: t };
648
- }
649
- class Dn {
650
- constructor(e, t) {
651
- this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = t, this.editor = e, this.table = { columns: 0, domRows: [], rows: 0 }, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.isSelecting = !1, this.pointerType = null, this.shouldCheckSelection = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.nextFocus = null, this.trackTable();
652
- }
653
- getTable() {
654
- return this.table;
655
- }
656
- removeListeners() {
657
- this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach(((e) => e())), this.listenersToRemove.clear();
658
- }
659
- $lookup() {
660
- return Lt(this.tableNodeKey, this.editor);
661
- }
662
- trackTable() {
663
- const e = new MutationObserver(((t) => {
664
- this.editor.getEditorState().read((() => {
665
- let o = !1;
666
- for (let l = 0; l < t.length; l++) {
667
- const i = t[l].target.nodeName;
668
- if (i === "TABLE" || i === "TBODY" || i === "THEAD" || i === "TR") {
669
- o = !0;
670
- break;
671
- }
672
- }
673
- if (!o) return;
674
- const { tableNode: r, tableElement: s } = this.$lookup();
675
- this.table = me(r, s);
676
- }), { editor: this.editor });
677
- }));
678
- this.editor.getEditorState().read((() => {
679
- const { tableNode: t, tableElement: o } = this.$lookup();
680
- this.table = me(t, o), e.observe(o, { attributes: !0, childList: !0, subtree: !0 });
681
- }), { editor: this.editor });
682
- }
683
- $clearHighlight() {
684
- const e = this.editor;
685
- this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.$enableHighlightStyle();
686
- const { tableNode: t, tableElement: o } = this.$lookup();
687
- Fe(e, me(t, o), null), L() !== null && (ne(null), e.dispatchCommand(fe, void 0));
688
- }
689
- $enableHighlightStyle() {
690
- const e = this.editor, { tableElement: t } = this.$lookup();
691
- ge(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
692
- }
693
- $disableHighlightStyle() {
694
- const { tableElement: e } = this.$lookup();
695
- G(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
696
- }
697
- $updateTableTableSelection(e) {
698
- if (e !== null) {
699
- e.tableKey !== this.tableNodeKey && w(233, e.tableKey, this.tableNodeKey);
700
- const t = this.editor;
701
- this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), Fe(t, this.table, this.tableSelection);
702
- } else this.$clearHighlight();
703
- }
704
- setShouldCheckSelection() {
705
- this.shouldCheckSelection = !0;
706
- }
707
- getAndClearShouldCheckSelection() {
708
- return !!this.shouldCheckSelection && (this.shouldCheckSelection = !1, !0);
709
- }
710
- setNextFocus(e) {
711
- this.nextFocus = e;
712
- }
713
- getAndClearNextFocus() {
714
- const { nextFocus: e } = this;
715
- return e !== null && (this.nextFocus = null), e;
716
- }
717
- updateDOMSelection() {
718
- if (this.anchorCell !== null && this.focusCell !== null) {
719
- const e = Me(this.editor._window);
720
- e && e.rangeCount > 0 && e.removeAllRanges();
721
- }
722
- }
723
- $setFocusCellForSelection(e, t = !1) {
724
- const o = this.editor, { tableNode: r } = this.$lookup(), s = e.x, l = e.y;
725
- if (this.focusCell = e, this.isHighlightingCells || this.anchorX === s && this.anchorY === l && !t) {
726
- if (s === this.focusX && l === this.focusY) return !1;
727
- } else this.isHighlightingCells = !0, this.$disableHighlightStyle();
728
- if (this.focusX = s, this.focusY = l, this.isHighlightingCells) {
729
- const i = Ge(r, e.elem);
730
- if (this.tableSelection != null && this.anchorCellNodeKey != null && i !== null) return this.focusCellNodeKey = i.getKey(), this.tableSelection = Hn(r, this.$getAnchorTableCellOrThrow(), i), ne(this.tableSelection), o.dispatchCommand(fe, void 0), Fe(o, this.table, this.tableSelection), !0;
731
- }
732
- return !1;
733
- }
734
- $getAnchorTableCell() {
735
- return this.anchorCellNodeKey ? Ae(this.anchorCellNodeKey) : null;
736
- }
737
- $getAnchorTableCellOrThrow() {
738
- const e = this.$getAnchorTableCell();
739
- return e === null && w(234), e;
740
- }
741
- $getFocusTableCell() {
742
- return this.focusCellNodeKey ? Ae(this.focusCellNodeKey) : null;
743
- }
744
- $getFocusTableCellOrThrow() {
745
- const e = this.$getFocusTableCell();
746
- return e === null && w(235), e;
747
- }
748
- $setAnchorCellForSelection(e) {
749
- this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y;
750
- const { tableNode: t } = this.$lookup(), o = Ge(t, e.elem);
751
- if (o !== null) {
752
- const r = o.getKey();
753
- this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : zt(), this.anchorCellNodeKey = r;
754
- }
755
- }
756
- $formatCells(e) {
757
- const t = L();
758
- O(t) || w(236);
759
- const o = Nn(), r = o.anchor, s = o.focus, l = t.getNodes().filter(b);
760
- l.length > 0 || w(237);
761
- const i = l[0].getFirstChild(), u = rt(i) ? i.getFormatFlags(e, null) : null;
762
- l.forEach(((f) => {
763
- r.set(f.getKey(), 0, "element"), s.set(f.getKey(), f.getChildrenSize(), "element"), o.formatText(e, u);
764
- })), ne(t), this.editor.dispatchCommand(fe, void 0);
765
- }
766
- $clearText() {
767
- const { editor: e } = this, t = Ae(this.tableNodeKey);
768
- if (!$(t)) throw new Error("Expected TableNode.");
769
- const o = L();
770
- O(o) || w(253);
771
- const r = o.getNodes().filter(b), s = t.getFirstChild(), l = t.getLastChild();
772
- if (r.length > 0 && s !== null && l !== null && k(s) && k(l) && r[0] === s.getFirstChild() && r[r.length - 1] === l.getLastChild()) {
773
- t.selectPrevious();
774
- const i = t.getParent();
775
- return t.remove(), void (vn(i) && i.isEmpty() && e.dispatchCommand(Et, void 0));
776
- }
777
- r.forEach(((i) => {
778
- if (D(i)) {
779
- const u = U(), f = ot();
780
- u.append(f), i.append(u), i.getChildren().forEach(((h) => {
781
- h !== u && h.remove();
782
- }));
783
- }
784
- })), Fe(e, this.table, null), ne(null), e.dispatchCommand(fe, void 0);
785
- }
786
- }
787
- const Qe = "__lexicalTableSelection", In = (n) => !(1 & ~n.buttons);
788
- function de(n) {
789
- return Ne(n) && n.nodeName === "TABLE";
790
- }
791
- function ie(n, e) {
792
- if (!e) return e;
793
- const t = de(e) ? e : n.getDOMSlot(e).element;
794
- return t.nodeName !== "TABLE" && w(245, e.nodeName), t;
795
- }
796
- function it(n) {
797
- return n._window;
798
- }
799
- function ve(n, e) {
800
- for (let t = e, o = null; t !== null; t = t.getParent()) {
801
- if (n.is(t)) return o;
802
- b(t) && (o = t);
803
- }
804
- return null;
805
- }
806
- const Jn = [[sn, "down"], [an, "up"], [cn, "backward"], [un, "forward"]], Un = [dn, At, fn], Yn = [gn, mn];
807
- function Xn(n, e, t, o) {
808
- const r = t.getRootElement(), s = it(t);
809
- r !== null && s !== null || w(246);
810
- const l = new Dn(t, n.getKey()), i = ie(n, e);
811
- (function(a, c) {
812
- bt(a) !== null && w(205), a[Qe] = c;
813
- })(i, l), l.listenersToRemove.add((() => (function(a, c) {
814
- bt(a) === c && delete a[Qe];
815
- })(i, l)));
816
- const u = (a) => {
817
- if (l.pointerType = a.pointerType, a.button !== 0 || !ye(a.target) || !s) return;
818
- const c = $e(a.target);
819
- c !== null && t.update((() => {
820
- const g = Ue();
821
- if (Ct && a.shiftKey && Q(g, n) && (M(g) || O(g))) {
822
- const d = g.anchor.getNode(), m = ve(n, g.anchor.getNode());
823
- m ? (l.$setAnchorCellForSelection(se(l, m)), l.$setFocusCellForSelection(c), ee(a)) : (n.isBefore(d) ? n.selectStart() : n.selectEnd()).anchor.set(g.anchor.key, g.anchor.offset, g.anchor.type);
824
- } else a.pointerType !== "touch" && l.$setAnchorCellForSelection(c);
825
- })), (() => {
826
- if (l.isSelecting) return;
827
- const g = () => {
828
- l.isSelecting = !1, s.removeEventListener("pointerup", g), s.removeEventListener("pointermove", d);
829
- }, d = (m) => {
830
- if (!In(m) && l.isSelecting) return l.isSelecting = !1, s.removeEventListener("pointerup", g), void s.removeEventListener("pointermove", d);
831
- if (!ye(m.target)) return;
832
- let C = null;
833
- const S = !(Ct || i.contains(m.target));
834
- if (S) C = yt(i, m.target);
835
- else for (const N of document.elementsFromPoint(m.clientX, m.clientY)) if (C = yt(i, N), C) break;
836
- !C || l.focusCell !== null && C.elem === l.focusCell.elem || (l.setNextFocus({ focusCell: C, override: S }), t.dispatchCommand(fe, void 0));
837
- };
838
- l.isSelecting = !0, s.addEventListener("pointerup", g, l.listenerOptions), s.addEventListener("pointermove", d, l.listenerOptions);
839
- })();
840
- };
841
- i.addEventListener("pointerdown", u, l.listenerOptions), l.listenersToRemove.add((() => {
842
- i.removeEventListener("pointerdown", u);
843
- }));
844
- const f = (a) => {
845
- a.detail >= 3 && ye(a.target) && $e(a.target) !== null && a.preventDefault();
846
- };
847
- i.addEventListener("mousedown", f, l.listenerOptions), l.listenersToRemove.add((() => {
848
- i.removeEventListener("mousedown", f);
849
- }));
850
- const h = (a) => {
851
- const c = a.target;
852
- a.button === 0 && ye(c) && t.update((() => {
853
- const g = L();
854
- O(g) && g.tableKey === l.tableNodeKey && r.contains(c) && l.$clearHighlight();
855
- }));
856
- };
857
- s.addEventListener("pointerdown", h, l.listenerOptions), l.listenersToRemove.add((() => {
858
- s.removeEventListener("pointerdown", h);
859
- }));
860
- for (const [a, c] of Jn) l.listenersToRemove.add(t.registerCommand(a, ((g) => Ht(t, g, c, n, l)), Ie));
861
- l.listenersToRemove.add(t.registerCommand(hn, ((a) => {
862
- const c = L();
863
- if (O(c)) {
864
- const g = ve(n, c.focus.getNode());
865
- if (g !== null) return ee(a), g.selectEnd(), !0;
866
- }
867
- return !1;
868
- }), Ie));
869
- const p = (a) => () => {
870
- const c = L();
871
- if (!Q(c, n)) return !1;
872
- if (O(c)) return l.$clearText(), !0;
873
- if (M(c)) {
874
- if (!b(ve(n, c.anchor.getNode()))) return !1;
875
- const g = c.anchor.getNode(), d = c.focus.getNode(), m = n.isParentOf(g), C = n.isParentOf(d);
876
- if (m && !C || C && !m) return l.$clearText(), !0;
877
- const S = T(c.anchor.getNode(), ((y) => D(y))), N = S && T(S, ((y) => D(y) && b(y.getParent())));
878
- if (!D(N) || !D(S)) return !1;
879
- if (a === At && N.getPreviousSibling() === null) return !0;
880
- }
881
- return !1;
882
- };
883
- for (const a of Un) l.listenersToRemove.add(t.registerCommand(a, p(a), j));
884
- const _ = (a) => {
885
- const c = L();
886
- if (!O(c) && !M(c)) return !1;
887
- const g = n.isParentOf(c.anchor.getNode());
888
- if (g !== n.isParentOf(c.focus.getNode())) {
889
- const d = g ? "anchor" : "focus", m = g ? "focus" : "anchor", { key: C, offset: S, type: N } = c[m];
890
- return n[c[d].isBefore(c[m]) ? "selectPrevious" : "selectNext"]()[m].set(C, S, N), !1;
891
- }
892
- return !!Q(c, n) && !!O(c) && (a && (a.preventDefault(), a.stopPropagation()), l.$clearText(), !0);
893
- };
894
- for (const a of Yn) l.listenersToRemove.add(t.registerCommand(a, _, j));
895
- return l.listenersToRemove.add(t.registerCommand(pn, ((a) => {
896
- const c = L();
897
- if (c) {
898
- if (!O(c) && !M(c)) return !1;
899
- An(t, Gt(a, ClipboardEvent) ? a : null, En(c));
900
- const g = _(a);
901
- return M(c) ? (c.removeText(), !0) : g;
902
- }
903
- return !1;
904
- }), j)), l.listenersToRemove.add(t.registerCommand(_n, ((a) => {
905
- const c = L();
906
- if (!Q(c, n)) return !1;
907
- if (O(c)) return l.$formatCells(a), !0;
908
- if (M(c)) {
909
- const g = T(c.anchor.getNode(), ((d) => b(d)));
910
- if (!b(g)) return !1;
911
- }
912
- return !1;
913
- }), j)), l.listenersToRemove.add(t.registerCommand(Cn, ((a) => {
914
- const c = L();
915
- if (!O(c) || !Q(c, n)) return !1;
916
- const g = c.anchor.getNode(), d = c.focus.getNode();
917
- if (!b(g) || !b(d)) return !1;
918
- if ((function(A, z) {
919
- if (O(A)) {
920
- const F = A.anchor.getNode(), K = A.focus.getNode();
921
- if (z && F && K) {
922
- const [P] = J(z, F, K);
923
- return F.getKey() === P[0][0].cell.getKey() && K.getKey() === P[P.length - 1].at(-1).cell.getKey();
924
- }
925
- }
926
- return !1;
927
- })(c, n)) return n.setFormat(a), !0;
928
- const [m, C, S] = J(n, g, d), N = Math.max(C.startRow + C.cell.__rowSpan - 1, S.startRow + S.cell.__rowSpan - 1), y = Math.max(C.startColumn + C.cell.__colSpan - 1, S.startColumn + S.cell.__colSpan - 1), v = Math.min(C.startRow, S.startRow), R = Math.min(C.startColumn, S.startColumn), E = /* @__PURE__ */ new Set();
929
- for (let A = v; A <= N; A++) for (let z = R; z <= y; z++) {
930
- const F = m[A][z].cell;
931
- if (E.has(F)) continue;
932
- E.add(F), F.setFormat(a);
933
- const K = F.getChildren();
934
- for (let P = 0; P < K.length; P++) {
935
- const B = K[P];
936
- D(B) && !B.isInline() && B.setFormat(a);
937
- }
938
- }
939
- return !0;
940
- }), j)), l.listenersToRemove.add(t.registerCommand(Sn, ((a) => {
941
- const c = L();
942
- if (!Q(c, n)) return !1;
943
- if (O(c)) return l.$clearHighlight(), !1;
944
- if (M(c)) {
945
- const g = T(c.anchor.getNode(), ((d) => b(d)));
946
- if (!b(g)) return !1;
947
- if (typeof a == "string") {
948
- const d = xt(t, c, n);
949
- if (d) return vt(d, n, [ot(a)]), !0;
950
- }
951
- }
952
- return !1;
953
- }), j)), o && l.listenersToRemove.add(t.registerCommand(wn, ((a) => {
954
- const c = L();
955
- if (!M(c) || !c.isCollapsed() || !Q(c, n)) return !1;
956
- const g = be(c.anchor.getNode());
957
- return !(g === null || !n.is(pe(g))) && (ee(a), (function(d, m) {
958
- const C = m === "next" ? "getNextSibling" : "getPreviousSibling", S = m === "next" ? "getFirstChild" : "getLastChild", N = d[C]();
959
- if (D(N)) return N.selectEnd();
960
- const y = T(d, k);
961
- y === null && w(247);
962
- for (let R = y[C](); k(R); R = R[C]()) {
963
- const E = R[S]();
964
- if (D(E)) return E.selectEnd();
965
- }
966
- const v = T(y, $);
967
- v === null && w(248), m === "next" ? v.selectNext() : v.selectPrevious();
968
- })(g, a.shiftKey ? "previous" : "next"), !0);
969
- }), j)), l.listenersToRemove.add(t.registerCommand(bn, ((a) => n.isSelected()), Ie)), l.listenersToRemove.add(t.registerCommand(Kt, ((a, c) => {
970
- if (t !== c) return !1;
971
- const { nodes: g, selection: d } = a, m = d.getStartEndPoints(), C = O(d), S = M(d) && T(d.anchor.getNode(), ((x) => b(x))) !== null && T(d.focus.getNode(), ((x) => b(x))) !== null || C;
972
- if (g.length !== 1 || !$(g[0]) || !S || m === null) return !1;
973
- const [N, y] = m, [v, R, E] = I(N), A = T(y.getNode(), ((x) => b(x)));
974
- if (!(b(v) && b(A) && k(R) && $(E))) return !1;
975
- const z = g[0], [F, K, P] = J(E, v, A), [B] = oe(z, null, null), te = F.length, Ce = te > 0 ? F[0].length : 0;
976
- let q = K.startRow, H = K.startColumn, le = B.length, ue = le > 0 ? B[0].length : 0;
977
- if (C) {
978
- const x = ke(F, K, P), Y = x.maxRow - x.minRow + 1, V = x.maxColumn - x.minColumn + 1;
979
- q = x.minRow, H = x.minColumn, le = Math.min(le, Y), ue = Math.min(ue, V);
980
- }
981
- let Le = !1;
982
- const Bt = Math.min(te, q + le) - 1, Dt = Math.min(Ce, H + ue) - 1, ut = /* @__PURE__ */ new Set();
983
- for (let x = q; x <= Bt; x++) for (let Y = H; Y <= Dt; Y++) {
984
- const V = F[x][Y];
985
- ut.has(V.cell.getKey()) || V.cell.__rowSpan === 1 && V.cell.__colSpan === 1 || (Pn(V.cell), ut.add(V.cell.getKey()), Le = !0);
986
- }
987
- let [Se] = oe(E.getWritable(), null, null);
988
- const It = le - te + q;
989
- for (let x = 0; x < It; x++)
990
- qe(Se[te - 1][0].cell);
991
- const Jt = ue - Ce + H;
992
- for (let x = 0; x < Jt; x++)
993
- Ve(Se[0][Ce - 1].cell, !0, !1);
994
- [Se] = oe(E.getWritable(), null, null);
995
- for (let x = q; x < q + le; x++) for (let Y = H; Y < H + ue; Y++) {
996
- const V = x - q, ht = Y - H, We = B[V][ht];
997
- if (We.startRow !== V || We.startColumn !== ht) continue;
998
- const we = We.cell;
999
- if (we.__rowSpan !== 1 || we.__colSpan !== 1) {
1000
- const Z = [], Yt = Math.min(x + we.__rowSpan, q + le) - 1, Xt = Math.min(Y + we.__colSpan, H + ue) - 1;
1001
- for (let He = x; He <= Yt; He++) for (let Be = Y; Be <= Xt; Be++) {
1002
- const qt = Se[He][Be];
1003
- Z.push(qt.cell);
1004
- }
1005
- Ln(Z), Le = !0;
1006
- }
1007
- const { cell: Pe } = Se[x][Y], Ut = Pe.getChildren();
1008
- we.getChildren().forEach(((Z) => {
1009
- _e(Z) && U().append(Z), Pe.append(Z);
1010
- })), Ut.forEach(((Z) => Z.remove()));
1011
- }
1012
- if (C && Le) {
1013
- const [x] = oe(E.getWritable(), null, null);
1014
- x[K.startRow][K.startColumn].cell.selectEnd();
1015
- }
1016
- return !0;
1017
- }), j)), l.listenersToRemove.add(t.registerCommand(fe, (() => {
1018
- const a = L(), c = Ue(), g = l.getAndClearNextFocus();
1019
- if (g !== null) {
1020
- const { focusCell: d } = g;
1021
- if (O(a) && a.tableKey === l.tableNodeKey) return (d.x !== l.focusX || d.y !== l.focusY) && (l.$setFocusCellForSelection(d), !0);
1022
- if (d !== l.anchorCell && Q(a, n)) return l.$setFocusCellForSelection(d), !0;
1023
- }
1024
- if (l.getAndClearShouldCheckSelection() && M(c) && M(a) && a.isCollapsed()) {
1025
- const d = a.anchor.getNode(), m = n.getFirstChild(), C = be(d);
1026
- if (C !== null && k(m)) {
1027
- const S = m.getFirstChild();
1028
- if (b(S) && n.is(T(C, ((N) => N.is(n) || N.is(S))))) return S.selectStart(), !0;
1029
- }
1030
- }
1031
- if (M(a)) {
1032
- const { anchor: d, focus: m } = a, C = d.getNode(), S = m.getNode(), N = be(C), y = be(S), v = !(!N || !n.is(pe(N))), R = !(!y || !n.is(pe(y))), E = v !== R, A = v && R, z = a.isBackward();
1033
- if (E) {
1034
- const F = a.clone();
1035
- if (R) {
1036
- const [K] = J(n, y, y), P = K[0][0].cell, B = K[K.length - 1].at(-1).cell;
1037
- F.focus.set(z ? P.getKey() : B.getKey(), z ? P.getChildrenSize() : B.getChildrenSize(), "element");
1038
- } else if (v) {
1039
- const [K] = J(n, N, N), P = K[0][0].cell, B = K[K.length - 1].at(-1).cell;
1040
- F.anchor.set(z ? B.getKey() : P.getKey(), z ? B.getChildrenSize() : 0, "element");
1041
- }
1042
- ne(F), Nt(t, l);
1043
- } else if (A && (N.is(y) || (l.$setAnchorCellForSelection(se(l, N)), l.$setFocusCellForSelection(se(l, y), !0)), l.pointerType === "touch" && l.isSelecting && a.isCollapsed() && M(c) && c.isCollapsed())) {
1044
- const F = be(c.anchor.getNode());
1045
- F && !F.is(y) && (l.$setAnchorCellForSelection(se(l, F)), l.$setFocusCellForSelection(se(l, y), !0), l.pointerType = null);
1046
- }
1047
- } else if (a && O(a) && a.is(c) && a.tableKey === n.getKey()) {
1048
- const d = Me(s);
1049
- if (d && d.anchorNode && d.focusNode) {
1050
- const m = re(d.focusNode), C = m && !n.isParentOf(m), S = re(d.anchorNode), N = S && n.isParentOf(S);
1051
- if (C && N && d.rangeCount > 0) {
1052
- const y = yn(d, t);
1053
- y && (y.anchor.set(n.getKey(), a.isBackward() ? n.getChildrenSize() : 0, "element"), d.removeAllRanges(), ne(y));
1054
- }
1055
- }
1056
- }
1057
- return a && !a.is(c) && (O(a) || O(c)) && l.tableSelection && !l.tableSelection.is(c) ? (O(a) && a.tableKey === l.tableNodeKey ? l.$updateTableTableSelection(a) : !O(a) && O(c) && c.tableKey === l.tableNodeKey && l.$updateTableTableSelection(null), !1) : (l.hasHijackedSelectionStyles && !n.isSelected() ? (function(d, m) {
1058
- m.$enableHighlightStyle(), at(m.table, ((C) => {
1059
- const S = C.elem;
1060
- C.highlighted = !1, Pt(d, C), S.getAttribute("style") || S.removeAttribute("style");
1061
- }));
1062
- })(t, l) : !l.hasHijackedSelectionStyles && n.isSelected() && Nt(t, l), !1);
1063
- }), j)), l.listenersToRemove.add(t.registerCommand(Et, (() => {
1064
- const a = L();
1065
- if (!M(a) || !a.isCollapsed() || !Q(a, n)) return !1;
1066
- const c = xt(t, a, n);
1067
- return !!c && (vt(c, n), !0);
1068
- }), j)), l;
1069
- }
1070
- function bt(n) {
1071
- return n[Qe] || null;
1072
- }
1073
- function $e(n) {
1074
- let e = n;
1075
- for (; e != null; ) {
1076
- const t = e.nodeName;
1077
- if (t === "TD" || t === "TH") {
1078
- const o = e._cell;
1079
- return o === void 0 ? null : o;
1080
- }
1081
- e = e.parentNode;
1082
- }
1083
- return null;
1084
- }
1085
- function yt(n, e) {
1086
- if (!n.contains(e)) return null;
1087
- let t = null;
1088
- for (let o = e; o != null; o = o.parentNode) {
1089
- if (o === n) return t;
1090
- const r = o.nodeName;
1091
- r !== "TD" && r !== "TH" || (t = o._cell || null);
1092
- }
1093
- return null;
1094
- }
1095
- function me(n, e) {
1096
- const t = [], o = { columns: 0, domRows: t, rows: 0 };
1097
- let r = ie(n, e).querySelector("tr"), s = 0, l = 0;
1098
- for (t.length = 0; r != null; ) {
1099
- const i = r.nodeName;
1100
- if (i === "TD" || i === "TH") {
1101
- const h = { elem: r, hasBackgroundColor: r.style.backgroundColor !== "", highlighted: !1, x: s, y: l };
1102
- r._cell = h;
1103
- let p = t[l];
1104
- p === void 0 && (p = t[l] = []), p[s] = h;
1105
- } else {
1106
- const h = r.firstChild;
1107
- if (h != null) {
1108
- r = h;
1109
- continue;
1110
- }
1111
- }
1112
- const u = r.nextSibling;
1113
- if (u != null) {
1114
- s++, r = u;
1115
- continue;
1116
- }
1117
- const f = r.parentNode;
1118
- if (f != null) {
1119
- const h = f.nextSibling;
1120
- if (h == null) break;
1121
- l++, s = 0, r = h;
1122
- }
1123
- }
1124
- return o.columns = s + 1, o.rows = l + 1, o;
1125
- }
1126
- function Fe(n, e, t) {
1127
- const o = new Set(t ? t.getNodes() : []);
1128
- at(e, ((r, s) => {
1129
- const l = r.elem;
1130
- o.has(s) ? (r.highlighted = !0, Wt(n, r)) : (r.highlighted = !1, Pt(n, r), l.getAttribute("style") || l.removeAttribute("style"));
1131
- }));
1132
- }
1133
- function at(n, e) {
1134
- const { domRows: t } = n;
1135
- for (let o = 0; o < t.length; o++) {
1136
- const r = t[o];
1137
- if (r) for (let s = 0; s < r.length; s++) {
1138
- const l = r[s];
1139
- if (!l) continue;
1140
- const i = re(l.elem);
1141
- i !== null && e(l, i, { x: s, y: o });
1142
- }
1143
- }
1144
- }
1145
- function Nt(n, e) {
1146
- e.$disableHighlightStyle(), at(e.table, ((t) => {
1147
- t.highlighted = !0, Wt(n, t);
1148
- }));
1149
- }
1150
- const qn = (n, e, t, o, r) => {
1151
- const s = r === "forward";
1152
- switch (r) {
1153
- case "backward":
1154
- case "forward":
1155
- return t !== (s ? n.table.columns - 1 : 0) ? Ke(e.getCellNodeFromCordsOrThrow(t + (s ? 1 : -1), o, n.table), s) : o !== (s ? n.table.rows - 1 : 0) ? Ke(e.getCellNodeFromCordsOrThrow(s ? 0 : n.table.columns - 1, o + (s ? 1 : -1), n.table), s) : s ? e.selectNext() : e.selectPrevious(), !0;
1156
- case "up":
1157
- return o !== 0 ? Ke(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0;
1158
- case "down":
1159
- return o !== n.table.rows - 1 ? Ke(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0;
1160
- default:
1161
- return !1;
1162
- }
1163
- };
1164
- function Je(n, e) {
1165
- let t, o;
1166
- if (e.startColumn === n.minColumn) t = "minColumn";
1167
- else {
1168
- if (e.startColumn + e.cell.__colSpan - 1 !== n.maxColumn) return null;
1169
- t = "maxColumn";
1170
- }
1171
- if (e.startRow === n.minRow) o = "minRow";
1172
- else {
1173
- if (e.startRow + e.cell.__rowSpan - 1 !== n.maxRow) return null;
1174
- o = "maxRow";
1175
- }
1176
- return [t, o];
1177
- }
1178
- function Oe([n, e]) {
1179
- return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"];
1180
- }
1181
- function he(n, e, [t, o]) {
1182
- const r = e[o], s = n[r];
1183
- s === void 0 && w(250, o, String(r));
1184
- const l = e[t], i = s[l];
1185
- return i === void 0 && w(250, t, String(l)), i;
1186
- }
1187
- function Vn(n, e, t, o, r) {
1188
- const s = ke(e, t, o), l = (function(v, R) {
1189
- const { minColumn: E, maxColumn: A, minRow: z, maxRow: F } = R;
1190
- let K = 1, P = 1, B = 1, te = 1;
1191
- const Ce = v[z], q = v[F];
1192
- for (let H = E; H <= A; H++) K = Math.max(K, Ce[H].cell.__rowSpan), te = Math.max(te, q[H].cell.__rowSpan);
1193
- for (let H = z; H <= F; H++) P = Math.max(P, v[H][E].cell.__colSpan), B = Math.max(B, v[H][A].cell.__colSpan);
1194
- return { bottomSpan: te, leftSpan: P, rightSpan: B, topSpan: K };
1195
- })(e, s), { topSpan: i, leftSpan: u, bottomSpan: f, rightSpan: h } = l, p = (function(v, R) {
1196
- const E = Je(v, R);
1197
- return E === null && w(249, R.cell.getKey()), E;
1198
- })(s, t), [_, a] = Oe(p);
1199
- let c = s[_], g = s[a];
1200
- r === "forward" ? c += _ === "maxColumn" ? 1 : u : r === "backward" ? c -= _ === "minColumn" ? 1 : h : r === "down" ? g += a === "maxRow" ? 1 : i : r === "up" && (g -= a === "minRow" ? 1 : f);
1201
- const d = e[g];
1202
- if (d === void 0) return !1;
1203
- const m = d[c];
1204
- if (m === void 0) return !1;
1205
- const [C, S] = (function(v, R, E) {
1206
- const A = ke(v, R, E), z = Je(A, R);
1207
- if (z) return [he(v, A, z), he(v, A, Oe(z))];
1208
- const F = Je(A, E);
1209
- if (F) return [he(v, A, Oe(F)), he(v, A, F)];
1210
- const K = ["minColumn", "minRow"];
1211
- return [he(v, A, K), he(v, A, Oe(K))];
1212
- })(e, t, m), N = se(n, C.cell), y = se(n, S.cell);
1213
- return n.$setAnchorCellForSelection(N), n.$setFocusCellForSelection(y, !0), !0;
1214
- }
1215
- function Q(n, e) {
1216
- if (M(n) || O(n)) {
1217
- const t = e.isParentOf(n.anchor.getNode()), o = e.isParentOf(n.focus.getNode());
1218
- return t && o;
1219
- }
1220
- return !1;
1221
- }
1222
- function Ke(n, e) {
1223
- e ? n.selectStart() : n.selectEnd();
1224
- }
1225
- function Wt(n, e) {
1226
- const t = e.elem, o = n._config.theme;
1227
- b(re(t)) || w(131), G(t, o.tableCellSelected);
1228
- }
1229
- function Pt(n, e) {
1230
- const t = e.elem;
1231
- b(re(t)) || w(131);
1232
- const o = n._config.theme;
1233
- ge(t, o.tableCellSelected);
1234
- }
1235
- function be(n) {
1236
- const e = T(n, b);
1237
- return b(e) ? e : null;
1238
- }
1239
- function pe(n) {
1240
- const e = T(n, $);
1241
- return $(e) ? e : null;
1242
- }
1243
- function jn(n, e, t, o, r, s, l) {
1244
- const i = Tn(t.focus, r ? "previous" : "next");
1245
- if (Rn(i)) return !1;
1246
- let u = i;
1247
- for (const d of ft(i).iterNodeCarets("shadowRoot")) {
1248
- if (!Fn(d) || !D(d.origin)) return !1;
1249
- u = d;
1250
- }
1251
- const f = u.getParentAtCaret();
1252
- if (!b(f)) return !1;
1253
- const h = f, p = (function(d) {
1254
- for (const m of ft(d).iterNodeCarets("root")) {
1255
- const { origin: C } = m;
1256
- if (b(C)) {
1257
- if (gt(m)) return On(C, d.direction);
1258
- } else if (!k(C)) break;
1259
- }
1260
- return null;
1261
- })(mt(h, u.direction)), _ = T(h, $);
1262
- if (!_ || !_.is(s)) return !1;
1263
- const a = n.getElementByKey(h.getKey()), c = $e(a);
1264
- if (!a || !c) return !1;
1265
- const g = Qn(n, _);
1266
- if (l.table = g, p) if (o === "extend") {
1267
- const d = $e(n.getElementByKey(p.origin.getKey()));
1268
- if (!d) return !1;
1269
- l.$setAnchorCellForSelection(c), l.$setFocusCellForSelection(d, !0);
1270
- } else {
1271
- const d = pt(p);
1272
- Re(t.anchor, d), Re(t.focus, d);
1273
- }
1274
- else if (o === "extend") l.$setAnchorCellForSelection(c), l.$setFocusCellForSelection(c, !0);
1275
- else {
1276
- const d = (function(m) {
1277
- const C = Kn(m);
1278
- return gt(C) ? pt(C) : m;
1279
- })(mt(_, i.direction));
1280
- Re(t.anchor, d), Re(t.focus, d);
1281
- }
1282
- return ee(e), !0;
1283
- }
1284
- function Ht(n, e, t, o, r) {
1285
- if ((t === "up" || t === "down") && (function(l) {
1286
- const i = l.getRootElement();
1287
- return i ? i.hasAttribute("aria-controls") && i.getAttribute("aria-controls") === "typeahead-menu" : !1;
1288
- })(n)) return !1;
1289
- const s = L();
1290
- if (!Q(s, o)) {
1291
- if (M(s)) {
1292
- if (t === "backward") {
1293
- if (s.focus.offset > 0) return !1;
1294
- const l = (function(u) {
1295
- for (let f = u, h = u; h !== null; f = h, h = h.getParent()) if (D(h)) {
1296
- if (h !== f && h.getFirstChild() !== f) return null;
1297
- if (!h.isInline()) return h;
1298
- }
1299
- return null;
1300
- })(s.focus.getNode());
1301
- if (!l) return !1;
1302
- const i = l.getPreviousSibling();
1303
- return !!$(i) && (ee(e), e.shiftKey ? s.focus.set(i.getParentOrThrow().getKey(), i.getIndexWithinParent(), "element") : i.selectEnd(), !0);
1304
- }
1305
- if (e.shiftKey && (t === "up" || t === "down")) {
1306
- const l = s.focus.getNode();
1307
- if (!s.isCollapsed() && (t === "up" && !s.isBackward() || t === "down" && s.isBackward())) {
1308
- let i = T(l, ((_) => $(_)));
1309
- if (b(i) && (i = T(i, $)), i !== o || !i) return !1;
1310
- const u = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
1311
- if (!u) return !1;
1312
- let f = 0;
1313
- t === "up" && D(u) && (f = u.getChildrenSize());
1314
- let h = u;
1315
- t === "up" && D(u) && (h = u.getLastChild() || u, f = _e(h) ? h.getTextContentSize() : 0);
1316
- const p = s.clone();
1317
- return p.focus.set(h.getKey(), f, _e(h) ? "text" : "element"), ne(p), ee(e), !0;
1318
- }
1319
- if (xn(l)) {
1320
- const i = t === "up" ? s.getNodes()[s.getNodes().length - 1] : s.getNodes()[0];
1321
- if (i && ve(o, i) !== null) {
1322
- const u = o.getFirstDescendant(), f = o.getLastDescendant();
1323
- if (!u || !f) return !1;
1324
- const [h] = I(u), [p] = I(f), _ = o.getCordsFromCellNode(h, r.table), a = o.getCordsFromCellNode(p, r.table), c = o.getDOMCellFromCordsOrThrow(_.x, _.y, r.table), g = o.getDOMCellFromCordsOrThrow(a.x, a.y, r.table);
1325
- return r.$setAnchorCellForSelection(c), r.$setFocusCellForSelection(g, !0), !0;
1326
- }
1327
- return !1;
1328
- }
1329
- {
1330
- let i = T(l, ((f) => D(f) && !f.isInline()));
1331
- if (b(i) && (i = T(i, $)), !i) return !1;
1332
- const u = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
1333
- if ($(u) && r.tableNodeKey === u.getKey()) {
1334
- const f = u.getFirstDescendant(), h = u.getLastDescendant();
1335
- if (!f || !h) return !1;
1336
- const [p] = I(f), [_] = I(h), a = s.clone();
1337
- return a.focus.set((t === "up" ? p : _).getKey(), t === "up" ? 0 : _.getChildrenSize(), "element"), ee(e), ne(a), !0;
1338
- }
1339
- }
1340
- }
1341
- }
1342
- return t === "down" && et(n) && r.setShouldCheckSelection(), !1;
1343
- }
1344
- if (M(s)) {
1345
- if (t === "backward" || t === "forward")
1346
- return jn(n, e, s, e.shiftKey ? "extend" : "move", t === "backward", o, r);
1347
- if (s.isCollapsed()) {
1348
- const { anchor: l, focus: i } = s, u = T(l.getNode(), b), f = T(i.getNode(), b);
1349
- if (!b(u) || !u.is(f)) return !1;
1350
- const h = pe(u);
1351
- if (h !== o && h != null) {
1352
- const m = ie(h, n.getElementByKey(h.getKey()));
1353
- if (m != null) return r.table = me(h, m), Ht(n, e, t, h, r);
1354
- }
1355
- const p = n.getElementByKey(u.__key), _ = n.getElementByKey(l.key);
1356
- if (_ == null || p == null) return !1;
1357
- let a;
1358
- if (l.type === "element") a = _.getBoundingClientRect();
1359
- else {
1360
- const m = Me(it(n));
1361
- if (m === null || m.rangeCount === 0) return !1;
1362
- a = m.getRangeAt(0).getBoundingClientRect();
1363
- }
1364
- const c = t === "up" ? u.getFirstChild() : u.getLastChild();
1365
- if (c == null) return !1;
1366
- const g = n.getElementByKey(c.__key);
1367
- if (g == null) return !1;
1368
- const d = g.getBoundingClientRect();
1369
- if (t === "up" ? d.top > a.top - a.height : a.bottom + a.height > d.bottom) {
1370
- ee(e);
1371
- const m = o.getCordsFromCellNode(u, r.table);
1372
- if (!e.shiftKey) return qn(r, o, m.x, m.y, t);
1373
- {
1374
- const C = o.getDOMCellFromCordsOrThrow(m.x, m.y, r.table);
1375
- r.$setAnchorCellForSelection(C), r.$setFocusCellForSelection(C, !0);
1376
- }
1377
- return !0;
1378
- }
1379
- }
1380
- } else if (O(s)) {
1381
- const { anchor: l, focus: i } = s, u = T(l.getNode(), b), f = T(i.getNode(), b), [h] = s.getNodes();
1382
- $(h) || w(251);
1383
- const p = ie(h, n.getElementByKey(h.getKey()));
1384
- if (!b(u) || !b(f) || !$(h) || p == null) return !1;
1385
- r.$updateTableTableSelection(s);
1386
- const _ = me(h, p), a = o.getCordsFromCellNode(u, _), c = o.getDOMCellFromCordsOrThrow(a.x, a.y, _);
1387
- if (r.$setAnchorCellForSelection(c), ee(e), e.shiftKey) {
1388
- const [g, d, m] = J(o, u, f);
1389
- return Vn(r, g, d, m, t);
1390
- }
1391
- return f.selectEnd(), !0;
1392
- }
1393
- return !1;
1394
- }
1395
- function ee(n) {
1396
- n.preventDefault(), n.stopImmediatePropagation(), n.stopPropagation();
1397
- }
1398
- function vt(n, e, t) {
1399
- const o = U();
1400
- n === "first" ? e.insertBefore(o) : e.insertAfter(o), o.append(...t || []), o.selectEnd();
1401
- }
1402
- function xt(n, e, t) {
1403
- const o = t.getParent();
1404
- if (!o) return;
1405
- const r = Me(it(n));
1406
- if (!r) return;
1407
- const s = r.anchorNode, l = n.getElementByKey(o.getKey()), i = ie(t, n.getElementByKey(t.getKey()));
1408
- if (!s || !l || !i || !l.contains(s) || i.contains(s)) return;
1409
- const u = T(e.anchor.getNode(), ((C) => b(C)));
1410
- if (!u) return;
1411
- const f = T(u, ((C) => $(C)));
1412
- if (!$(f) || !f.is(t)) return;
1413
- const [h, p] = J(t, u, u), _ = h[0][0], a = h[h.length - 1][h[0].length - 1], { startRow: c, startColumn: g } = p, d = c === _.startRow && g === _.startColumn, m = c === a.startRow && g === a.startColumn;
1414
- return d ? "first" : m ? "last" : void 0;
1415
- }
1416
- function se(n, e) {
1417
- const { tableNode: t } = n.$lookup(), o = t.getCordsFromCellNode(e, n.table);
1418
- return t.getDOMCellFromCordsOrThrow(o.x, o.y, n.table);
1419
- }
1420
- function Ge(n, e, t) {
1421
- return ve(n, re(e, t));
1422
- }
1423
- function Tt(n, e, t) {
1424
- if (!e.theme.tableAlignment) return;
1425
- const o = [], r = [];
1426
- for (const s of ["center", "right"]) {
1427
- const l = e.theme.tableAlignment[s];
1428
- l && (s === t ? r : o).push(l);
1429
- }
1430
- ge(n, ...o), G(n, ...r);
1431
- }
1432
- const Ze = /* @__PURE__ */ new WeakSet();
1433
- function et(n = Ot()) {
1434
- return Ze.has(n);
1435
- }
1436
- function go(n, e) {
1437
- e ? Ze.add(n) : Ze.delete(n);
1438
- }
1439
- class ae extends tt {
1440
- static getType() {
1441
- return "table";
1442
- }
1443
- getColWidths() {
1444
- return this.getLatest().__colWidths;
1445
- }
1446
- setColWidths(e) {
1447
- const t = this.getWritable();
1448
- return t.__colWidths = e, t;
1449
- }
1450
- static clone(e) {
1451
- return new ae(e.__key);
1452
- }
1453
- afterCloneFrom(e) {
1454
- super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping, this.__frozenColumnCount = e.__frozenColumnCount, this.__frozenRowCount = e.__frozenRowCount;
1455
- }
1456
- static importDOM() {
1457
- return { table: (e) => ({ conversion: Gn, priority: 1 }) };
1458
- }
1459
- static importJSON(e) {
1460
- return ct().updateFromJSON(e);
1461
- }
1462
- updateFromJSON(e) {
1463
- return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setFrozenColumns(e.frozenColumnCount || 0).setFrozenRows(e.frozenRowCount || 0).setColWidths(e.colWidths);
1464
- }
1465
- constructor(e) {
1466
- super(e), this.__rowStriping = !1, this.__frozenColumnCount = 0, this.__frozenRowCount = 0;
1467
- }
1468
- exportJSON() {
1469
- return { ...super.exportJSON(), colWidths: this.getColWidths(), frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : void 0, frozenRowCount: this.__frozenRowCount ? this.__frozenRowCount : void 0, rowStriping: this.__rowStriping ? this.__rowStriping : void 0 };
1470
- }
1471
- extractWithChild(e, t, o) {
1472
- return o === "html";
1473
- }
1474
- getDOMSlot(e) {
1475
- const t = de(e) ? e : e.querySelector("table");
1476
- return de(t) || w(229), super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"));
1477
- }
1478
- createDOM(e, t) {
1479
- const o = document.createElement("table");
1480
- this.__style && (o.style.cssText = this.__style);
1481
- const r = document.createElement("colgroup");
1482
- if (o.appendChild(r), en(r), G(o, e.theme.table), this.updateTableElement(null, o, e), et(t)) {
1483
- const s = document.createElement("div"), l = e.theme.tableScrollableWrapper;
1484
- return l ? G(s, l) : s.style.cssText = "overflow-x: auto;", s.appendChild(o), this.updateTableWrapper(null, s, o, e), s;
1485
- }
1486
- return o;
1487
- }
1488
- updateTableWrapper(e, t, o, r) {
1489
- this.__frozenColumnCount !== (e ? e.__frozenColumnCount : 0) && (function(s, l, i, u) {
1490
- u > 0 ? (G(s, i.theme.tableFrozenColumn), l.setAttribute("data-lexical-frozen-column", "true")) : (ge(s, i.theme.tableFrozenColumn), l.removeAttribute("data-lexical-frozen-column"));
1491
- })(t, o, r, this.__frozenColumnCount), this.__frozenRowCount !== (e ? e.__frozenRowCount : 0) && (function(s, l, i, u) {
1492
- u > 0 ? (G(s, i.theme.tableFrozenRow), l.setAttribute("data-lexical-frozen-row", "true")) : (ge(s, i.theme.tableFrozenRow), l.removeAttribute("data-lexical-frozen-row"));
1493
- })(t, o, r, this.__frozenRowCount);
1494
- }
1495
- updateTableElement(e, t, o) {
1496
- this.__style !== (e ? e.__style : "") && (t.style.cssText = this.__style), this.__rowStriping !== (!!e && e.__rowStriping) && (function(r, s, l) {
1497
- l ? (G(r, s.theme.tableRowStriping), r.setAttribute("data-lexical-row-striping", "true")) : (ge(r, s.theme.tableRowStriping), r.removeAttribute("data-lexical-row-striping"));
1498
- })(t, o, this.__rowStriping), (function(r, s, l, i) {
1499
- const u = r.querySelector("colgroup");
1500
- if (!u) return;
1501
- const f = [];
1502
- for (let h = 0; h < l; h++) {
1503
- const p = document.createElement("col"), _ = i && i[h];
1504
- _ && (p.style.width = `${_}px`), f.push(p);
1505
- }
1506
- u.replaceChildren(...f);
1507
- })(t, 0, this.getColumnCount(), this.getColWidths()), Tt(t, o, this.getFormatType());
1508
- }
1509
- updateDOM(e, t, o) {
1510
- const r = this.getDOMSlot(t).element;
1511
- return t === r === et() || (Ne(s = t) && s.nodeName === "DIV" && this.updateTableWrapper(e, t, r, o), this.updateTableElement(e, r, o), !1);
1512
- var s;
1513
- }
1514
- exportDOM(e) {
1515
- const t = super.exportDOM(e), { element: o } = t;
1516
- return { after: (r) => {
1517
- if (t.after && (r = t.after(r)), !de(r) && Ne(r) && (r = r.querySelector("table")), !de(r)) return null;
1518
- Tt(r, e._config, this.getFormatType());
1519
- const [s] = oe(this, null, null), l = /* @__PURE__ */ new Map();
1520
- for (const h of s) for (const p of h) {
1521
- const _ = p.cell.getKey();
1522
- l.has(_) || l.set(_, { colSpan: p.cell.getColSpan(), startColumn: p.startColumn });
1523
- }
1524
- const i = /* @__PURE__ */ new Set();
1525
- for (const h of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
1526
- const p = h.getAttribute("data-temporary-table-cell-lexical-key");
1527
- if (p) {
1528
- const _ = l.get(p);
1529
- if (h.removeAttribute("data-temporary-table-cell-lexical-key"), _) {
1530
- l.delete(p);
1531
- for (let a = 0; a < _.colSpan; a++) i.add(a + _.startColumn);
1532
- }
1533
- }
1534
- }
1535
- const u = r.querySelector(":scope > colgroup");
1536
- if (u) {
1537
- const h = Array.from(r.querySelectorAll(":scope > colgroup > col")).filter(((p, _) => i.has(_)));
1538
- u.replaceChildren(...h);
1539
- }
1540
- const f = r.querySelectorAll(":scope > tr");
1541
- if (f.length > 0) {
1542
- const h = document.createElement("tbody");
1543
- for (const p of f) h.appendChild(p);
1544
- r.append(h);
1545
- }
1546
- return r;
1547
- }, element: !de(o) && Ne(o) ? o.querySelector("table") : o };
1548
- }
1549
- canBeEmpty() {
1550
- return !1;
1551
- }
1552
- isShadowRoot() {
1553
- return !0;
1554
- }
1555
- getCordsFromCellNode(e, t) {
1556
- const { rows: o, domRows: r } = t;
1557
- for (let s = 0; s < o; s++) {
1558
- const l = r[s];
1559
- if (l != null) for (let i = 0; i < l.length; i++) {
1560
- const u = l[i];
1561
- if (u == null) continue;
1562
- const { elem: f } = u, h = Ge(this, f);
1563
- if (h !== null && e.is(h)) return { x: i, y: s };
1564
- }
1565
- }
1566
- throw new Error("Cell not found in table.");
1567
- }
1568
- getDOMCellFromCords(e, t, o) {
1569
- const { domRows: r } = o, s = r[t];
1570
- if (s == null) return null;
1571
- const l = s[e < s.length ? e : s.length - 1];
1572
- return l ?? null;
1573
- }
1574
- getDOMCellFromCordsOrThrow(e, t, o) {
1575
- const r = this.getDOMCellFromCords(e, t, o);
1576
- if (!r) throw new Error("Cell not found at cords.");
1577
- return r;
1578
- }
1579
- getCellNodeFromCords(e, t, o) {
1580
- const r = this.getDOMCellFromCords(e, t, o);
1581
- if (r == null) return null;
1582
- const s = re(r.elem);
1583
- return b(s) ? s : null;
1584
- }
1585
- getCellNodeFromCordsOrThrow(e, t, o) {
1586
- const r = this.getCellNodeFromCords(e, t, o);
1587
- if (!r) throw new Error("Node at cords not TableCellNode.");
1588
- return r;
1589
- }
1590
- getRowStriping() {
1591
- return !!this.getLatest().__rowStriping;
1592
- }
1593
- setRowStriping(e) {
1594
- const t = this.getWritable();
1595
- return t.__rowStriping = e, t;
1596
- }
1597
- setFrozenColumns(e) {
1598
- const t = this.getWritable();
1599
- return t.__frozenColumnCount = e, t;
1600
- }
1601
- getFrozenColumns() {
1602
- return this.getLatest().__frozenColumnCount;
1603
- }
1604
- setFrozenRows(e) {
1605
- const t = this.getWritable();
1606
- return t.__frozenRowCount = e, t;
1607
- }
1608
- getFrozenRows() {
1609
- return this.getLatest().__frozenRowCount;
1610
- }
1611
- canSelectBefore() {
1612
- return !0;
1613
- }
1614
- canIndent() {
1615
- return !1;
1616
- }
1617
- getColumnCount() {
1618
- const e = this.getFirstChild();
1619
- if (!e) return 0;
1620
- let t = 0;
1621
- return e.getChildren().forEach(((o) => {
1622
- b(o) && (t += o.getColSpan());
1623
- })), t;
1624
- }
1625
- }
1626
- function Qn(n, e) {
1627
- const t = n.getElementByKey(e.getKey());
1628
- return t === null && w(230), me(e, t);
1629
- }
1630
- function Gn(n) {
1631
- const e = ct();
1632
- n.hasAttribute("data-lexical-row-striping") && e.setRowStriping(!0), n.hasAttribute("data-lexical-frozen-column") && e.setFrozenColumns(1), n.hasAttribute("data-lexical-frozen-row") && e.setFrozenRows(1);
1633
- const t = n.querySelector(":scope > colgroup");
1634
- if (t) {
1635
- let o = [];
1636
- for (const r of t.querySelectorAll(":scope > col")) {
1637
- let s = r.style.width || "";
1638
- if (!lt.test(s) && (s = r.getAttribute("width") || "", !/^\d+$/.test(s))) {
1639
- o = void 0;
1640
- break;
1641
- }
1642
- o.push(parseFloat(s));
1643
- }
1644
- o && e.setColWidths(o);
1645
- }
1646
- return { after: (o) => Rt(o, k), node: e };
1647
- }
1648
- function ct() {
1649
- return nt(new ae());
1650
- }
1651
- function $(n) {
1652
- return n instanceof ae;
1653
- }
1654
- function Zn({ rows: n, columns: e, includeHeaders: t }) {
1655
- const o = L() || Ue();
1656
- if (!o || !M(o) || pe(o.anchor.getNode())) return !1;
1657
- const r = zn(Number(n), Number(e), t);
1658
- Qt(r);
1659
- const s = r.getFirstDescendant();
1660
- return _e(s) && s.select(), !0;
1661
- }
1662
- function eo(n) {
1663
- k(n.getParent()) ? n.isEmpty() && n.append(U()) : n.remove();
1664
- }
1665
- function to(n) {
1666
- $(n.getParent()) ? Ft(n, b) : n.remove();
1667
- }
1668
- function no(n) {
1669
- Ft(n, k);
1670
- const [e] = oe(n, null, null), t = e.reduce(((r, s) => Math.max(r, s.length)), 0), o = n.getChildren();
1671
- for (let r = 0; r < e.length; ++r) {
1672
- const s = o[r];
1673
- if (!s) continue;
1674
- k(s) || w(254, s.constructor.name, s.getType());
1675
- const l = e[r].reduce(((i, u) => u ? 1 + i : i), 0);
1676
- if (l !== t) for (let i = l; i < t; ++i) {
1677
- const u = X();
1678
- u.append(U()), s.append(u);
1679
- }
1680
- }
1681
- }
1682
- function oo(n) {
1683
- if (n.detail < 3 || !ye(n.target)) return !1;
1684
- const e = re(n.target);
1685
- if (e === null) return !1;
1686
- const t = T(e, ((o) => D(o) && !o.isInline()));
1687
- return t === null ? !1 : !!b(t.getParent()) && (t.select(0), !0);
1688
- }
1689
- function mo(n) {
1690
- return n.registerNodeTransform(ce, ((e) => {
1691
- if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
1692
- const [, , t] = I(e), [o] = J(t, e, e), r = o.length, s = o[0].length;
1693
- let l = t.getFirstChild();
1694
- k(l) || w(175);
1695
- const i = [];
1696
- for (let u = 0; u < r; u++) {
1697
- u !== 0 && (l = l.getNextSibling(), k(l) || w(175));
1698
- let f = null;
1699
- for (let h = 0; h < s; h++) {
1700
- const p = o[u][h], _ = p.cell;
1701
- if (p.startRow === u && p.startColumn === h) f = _, i.push(_);
1702
- else if (_.getColSpan() > 1 || _.getRowSpan() > 1) {
1703
- b(_) || w(176);
1704
- const a = X(_.__headerState);
1705
- f !== null ? f.insertAfter(a) : jt(l, a);
1706
- }
1707
- }
1708
- }
1709
- for (const u of i) u.setColSpan(1), u.setRowSpan(1);
1710
- }
1711
- }));
1712
- }
1713
- function po(n, e = !0) {
1714
- const t = /* @__PURE__ */ new Map(), o = (s, l, i) => {
1715
- const u = ie(s, i), f = Xn(s, u, n, e);
1716
- t.set(l, [f, u]);
1717
- }, r = n.registerMutationListener(ae, ((s) => {
1718
- n.getEditorState().read((() => {
1719
- for (const [l, i] of s) {
1720
- const u = t.get(l);
1721
- if (i === "created" || i === "updated") {
1722
- const { tableNode: f, tableElement: h } = Lt(l);
1723
- u === void 0 ? o(f, l, h) : h !== u[1] && (u[0].removeListeners(), t.delete(l), o(f, l, h));
1724
- } else i === "destroyed" && u !== void 0 && (u[0].removeListeners(), t.delete(l));
1725
- }
1726
- }), { editor: n });
1727
- }), { skipInitialization: !1 });
1728
- return () => {
1729
- r();
1730
- for (const [, [s]] of t) s.removeListeners();
1731
- };
1732
- }
1733
- function _o(n) {
1734
- return n.hasNodes([ae]) || w(255), Vt(n.registerCommand(kn, Zn, De), n.registerCommand(Kt, (({ nodes: e, selection: t }, o) => n !== o || !M(t) ? !1 : pe(t.anchor.getNode()) !== null && e.some($)), De), n.registerCommand(rn, oo, De), n.registerNodeTransform(ae, no), n.registerNodeTransform(Te, to), n.registerNodeTransform(ce, eo));
1735
- }
1736
- export {
1737
- co as B,
1738
- k as E,
1739
- $t as H,
1740
- xe as K,
1741
- zn as L,
1742
- $e as M,
1743
- Te as O,
1744
- ao as P,
1745
- b as R,
1746
- mo as S,
1747
- pe as V,
1748
- io as W,
1749
- uo as Y,
1750
- ho as a,
1751
- ae as b,
1752
- ie as c,
1753
- go as d,
1754
- _o as e,
1755
- oe as h,
1756
- fo as n,
1757
- et as s,
1758
- X as v,
1759
- po as w,
1760
- ce as y,
1761
- kt as z
1762
- };
1763
- //# sourceMappingURL=LexicalTable.prod-COFf1Spn.js.map