@uva-glass/component-library 1.62.9 → 1.62.10

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