@uva-glass/component-library 3.53.12 → 3.53.14

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