@uva-glass/component-library 1.55.1 → 1.56.0

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