@mx-space/cli 0.13.1 → 0.13.2

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 (58) hide show
  1. package/README.md +59 -0
  2. package/ROADMAP.md +10 -7
  3. package/dist/{Lexical.dev-By5dOKBN.mjs → Lexical.dev-BsbWMhb3.mjs} +2265 -429
  4. package/dist/{Lexical.node-fXM8Jp7p.mjs → Lexical.node-DnR_u_Ke.mjs} +47 -10
  5. package/dist/Lexical.prod-B7L8eVsO.mjs +6816 -0
  6. package/dist/{LexicalClipboard.dev--HxGoSkO.mjs → LexicalClipboard.dev-BGSFbuTA.mjs} +131 -39
  7. package/dist/{LexicalClipboard.node-C3mRbrmW.mjs → LexicalClipboard.node-CUD_tpWb.mjs} +2 -2
  8. package/dist/LexicalClipboard.prod-DQXfRt3h.mjs +429 -0
  9. package/dist/{LexicalCodeCore.dev-DjSrd4A4.mjs → LexicalCodeCore.dev-B9lK_GSN.mjs} +81 -67
  10. package/dist/LexicalCodeCore.prod-CNWMPXhg.mjs +651 -0
  11. package/dist/LexicalDragon.dev-DRm2bGZ1.mjs +186 -0
  12. package/dist/{LexicalDragon.node-BVhw4C7s.mjs → LexicalDragon.node-d8gPruly.mjs} +3 -2
  13. package/dist/LexicalDragon.prod-ey3uKDJF.mjs +121 -0
  14. package/dist/{LexicalExtension.dev-BPNyvGqe.mjs → LexicalExtension.dev-CXtOJb83.mjs} +349 -35
  15. package/dist/{LexicalExtension.node-BVlcrgOx.mjs → LexicalExtension.node-CMsupJZs.mjs} +9 -4
  16. package/dist/{LexicalExtension.prod-DFKbiNt-.mjs → LexicalExtension.prod-BCLGhzcg.mjs} +477 -328
  17. package/dist/{LexicalHeadless.dev-B-cj7Pr5.mjs → LexicalHeadless.dev-yVDOBd64.mjs} +2 -2
  18. package/dist/{LexicalHeadless.prod-Byp1vNzT.mjs → LexicalHeadless.prod-B8qauuEA.mjs} +2 -2
  19. package/dist/{LexicalHtml.dev-prBAwszN.mjs → LexicalHtml.dev-3rdckXIU.mjs} +323 -265
  20. package/dist/{LexicalHtml.node-BvNF96jZ.mjs → LexicalHtml.node-DagZUjQ_.mjs} +6 -4
  21. package/dist/{LexicalHtml.prod-Sz3CW1ht.mjs → LexicalHtml.prod-B5AQaJDb.mjs} +354 -352
  22. package/dist/{LexicalLink.dev-NySTYhVR.mjs → LexicalLink.dev-CspSwLNB.mjs} +69 -58
  23. package/dist/{LexicalLink.prod-BuCM8gts.mjs → LexicalLink.prod-Da-ZW6H5.mjs} +210 -211
  24. package/dist/{LexicalList.dev-DIMOvSFD.mjs → LexicalList.dev-CNXmV6v8.mjs} +246 -198
  25. package/dist/LexicalList.prod-DgQzj4v9.mjs +944 -0
  26. package/dist/{LexicalMarkdown.dev-C7aylvCG.mjs → LexicalMarkdown.dev-0XURdo96.mjs} +129 -37
  27. package/dist/LexicalMarkdown.prod-qUsIQfJx.mjs +932 -0
  28. package/dist/{LexicalRichText.dev-DfICq6lU.mjs → LexicalRichText.dev-BqsEA7I9.mjs} +151 -122
  29. package/dist/{LexicalRichText.node-Bg9jND3Q.mjs → LexicalRichText.node-D73RR0Ck.mjs} +8 -11
  30. package/dist/LexicalRichText.prod-4Atyd7OR.mjs +538 -0
  31. package/dist/{LexicalSelection.dev-DGjj12wW.mjs → LexicalSelection.dev-DK5xfxKP.mjs} +10 -9
  32. package/dist/{LexicalSelection.node-BU5L4193.mjs → LexicalSelection.node-pyZyrANz.mjs} +4 -4
  33. package/dist/{LexicalSelection.prod-D-PwRbyK.mjs → LexicalSelection.prod-C5GrCbDC.mjs} +144 -146
  34. package/dist/{LexicalTable.dev-ChP7cugd.mjs → LexicalTable.dev-DiR_4rdI.mjs} +184 -119
  35. package/dist/LexicalTable.prod-Cbc5EasT.mjs +2336 -0
  36. package/dist/{LexicalUtils.dev-BiFU3789.mjs → LexicalUtils.dev-jhPjn1vQ.mjs} +375 -35
  37. package/dist/{LexicalUtils.node-j3Llm7Y3.mjs → LexicalUtils.node-Ck74ludK.mjs} +24 -12
  38. package/dist/LexicalUtils.prod-nuTBxnk_.mjs +504 -0
  39. package/dist/bin/mxs.mjs +1 -1
  40. package/dist/esm-BumPuCXw.mjs +2 -0
  41. package/dist/{esm-DFrz5rIo.mjs → esm-DupC6TTP.mjs} +214 -179
  42. package/dist/index.d.mts +46 -17
  43. package/dist/index.mjs +1 -1
  44. package/dist/{mxs-DXpzbUf4.mjs → mxs-BgAyMQdq.mjs} +8384 -6209
  45. package/package.json +17 -17
  46. package/skills/commands-ai.md +115 -0
  47. package/skills/overview.md +1 -0
  48. package/dist/Lexical.prod-BlCvXPGa.mjs +0 -6088
  49. package/dist/LexicalClipboard.prod-DNJzFMcT.mjs +0 -371
  50. package/dist/LexicalCodeCore.prod-DTDShkR3.mjs +0 -642
  51. package/dist/LexicalDragon.dev-DwprRH0z.mjs +0 -88
  52. package/dist/LexicalDragon.prod-nh4J-8vn.mjs +0 -59
  53. package/dist/LexicalList.prod-MVqfA6Vo.mjs +0 -925
  54. package/dist/LexicalMarkdown.prod-CfQSM406.mjs +0 -868
  55. package/dist/LexicalRichText.prod-GsFzCK-o.mjs +0 -550
  56. package/dist/LexicalTable.prod-Bpr9YRXp.mjs +0 -2311
  57. package/dist/LexicalUtils.prod-DCvrA78p.mjs +0 -373
  58. package/dist/esm-DXO9Afik.mjs +0 -2
@@ -1,2311 +0,0 @@
1
- import { f as namedSignals, l as effect, p as signal } from "./LexicalExtension.node-BVlcrgOx.mjs";
2
- import { $ as $isElementNode, $t as ElementNode, An as KEY_ARROW_UP_COMMAND, Bt as COMMAND_PRIORITY_LOW, Cn as IS_STRIKETHROUGH, Cr as isHTMLTableRowElement, Ct as $setPointFromCaret, Dn as KEY_ARROW_DOWN_COMMAND, En as IS_UNDERLINE, F as $getEditor, H as $getRoot, Ht as CONTROLLED_TEXT_INSERTION_COMMAND, In as KEY_TAB_COMMAND, Jn as SELECT_ALL_COMMAND, Jt as DELETE_WORD_COMMAND, Kn as SELECTION_CHANGE_COMMAND, Kt as DELETE_CHARACTER_COMMAND, L as $getNearestNodeFromDOMNode, Mn as KEY_DELETE_COMMAND, Mr as setDOMStyleFromCSS, Nr as setDOMUnmanaged, On as KEY_ARROW_LEFT_COMMAND, Pn as KEY_ESCAPE_COMMAND, Pt as CLICK_COMMAND, Qn as TEXT_TYPE_TO_FORMAT, R as $getNodeByKey, Rt as COMMAND_PRIORITY_EDITOR, S as $getAdjacentChildCaret, Sr as isHTMLElement, U as $getSelection, V as $getPreviousSelection, W as $getSiblingCaret, Wt as CUT_COMMAND, X as $isChildCaret, _ as $createTextNode, b as $fullReconcile, cn as INSERT_PARAGRAPH_COMMAND, cr as defineExtension, ct as $isRootNode, en as FOCUS_COMMAND, et as $isExtendableTextPointCaret, f as $createParagraphNode, ft as $isTextNode, gr as isCurrentlyReadOnlyMode, gt as $normalizeSelection__EXPERIMENTAL, h as $createRangeSelectionFromDom, hn as IS_BOLD, ht as $normalizeCaret, ir as createCommand, it as $isLineBreakNode, jn as KEY_BACKSPACE_COMMAND, jr as safeCast, k as $getChildCaret, kn as KEY_ARROW_RIGHT_COMMAND, lr as getDOMSelection, lt as $isRootOrShadowRoot, m as $createRangeSelection, n as $applyNodeReplacement, nn as FORMAT_TEXT_COMMAND, ot as $isParagraphNode, p as $createPoint, qn as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, qt as DELETE_LINE_COMMAND, r as $caretFromPoint, rr as configExtension, st as $isRangeSelection, tn as FORMAT_ELEMENT_COMMAND, tt as $isInlineElementOrDecoratorNode, ut as $isSiblingCaret, v as $extendCaretToRange, vn as IS_FIREFOX, vr as isDOMNode, wt as $setSelection, xn as IS_ITALIC, z as $getNodeByKeyOrThrow, zt as COMMAND_PRIORITY_HIGH } from "./Lexical.node-fXM8Jp7p.mjs";
3
- import { a as CoreImportExtension, d as ImportTextStyle, f as contextValue, g as sel, o as DOMImportExtension, p as defineImportRule, u as ImportTextFormat } from "./LexicalHtml.node-BvNF96jZ.mjs";
4
- import { _ as removeClassNamesFromElement, c as $insertNodeToNearestRoot, d as addClassNamesToElement, g as objectKlassEquals, h as mergeRegister, m as isHTMLElement$1, n as $dfs, r as $findMatchingParent, s as $insertFirst, t as $descendantsMatching, u as $unwrapAndFilterDescendants } from "./LexicalUtils.node-j3Llm7Y3.mjs";
5
- import { o as copyToClipboard, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-C3mRbrmW.mjs";
6
- //#region ../../node_modules/.pnpm/@lexical+table@0.45.0/node_modules/@lexical/table/dist/LexicalTable.prod.mjs
7
- /**
8
- * Copyright (c) Meta Platforms, Inc. and affiliates.
9
- *
10
- * This source code is licensed under the MIT license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- */
14
- const Je = /^(\d+(?:\.\d+)?)px$/, Xe = {
15
- BOTH: 3,
16
- COLUMN: 2,
17
- NO_STATUS: 0,
18
- ROW: 1
19
- };
20
- var Ye = class Ye extends ElementNode {
21
- __colSpan;
22
- __rowSpan;
23
- __headerState;
24
- __width;
25
- __backgroundColor;
26
- __verticalAlign;
27
- static getType() {
28
- return "tablecell";
29
- }
30
- static clone(e) {
31
- return new Ye(e.__headerState, e.__colSpan, e.__width, e.__key);
32
- }
33
- afterCloneFrom(e) {
34
- super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign, this.__colSpan = e.__colSpan, this.__headerState = e.__headerState, this.__width = e.__width;
35
- }
36
- static importDOM() {
37
- return {
38
- td: (e) => ({
39
- conversion: je,
40
- priority: 0
41
- }),
42
- th: (e) => ({
43
- conversion: je,
44
- priority: 0
45
- })
46
- };
47
- }
48
- static importJSON(e) {
49
- return Ve().updateFromJSON(e);
50
- }
51
- updateFromJSON(e) {
52
- 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);
53
- }
54
- constructor(e = Xe.NO_STATUS, t = 1, n, o) {
55
- super(o), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = n, this.__backgroundColor = null, this.__verticalAlign = void 0;
56
- }
57
- createDOM(t) {
58
- const n = document.createElement(this.getTag());
59
- return this.__width && (n.style.width = `${this.__width}px`), this.__colSpan > 1 && (n.colSpan = this.__colSpan), this.__rowSpan > 1 && (n.rowSpan = this.__rowSpan), null !== this.__backgroundColor && (n.style.backgroundColor = this.__backgroundColor), qe(this.__verticalAlign) && (n.style.verticalAlign = this.__verticalAlign), addClassNamesToElement(n, t.theme.tableCell, this.hasHeader() && t.theme.tableCellHeader), n;
60
- }
61
- exportDOM(e) {
62
- const t = super.exportDOM(e);
63
- if (isHTMLElement(t.element)) {
64
- const e = t.element;
65
- e.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), e.style.border = "1px solid black", this.__colSpan > 1 && (e.colSpan = this.__colSpan), this.__rowSpan > 1 && (e.rowSpan = this.__rowSpan), e.style.width = `${this.getWidth() || 75}px`, e.style.verticalAlign = this.getVerticalAlign() || "top", e.style.textAlign = "start", null === this.__backgroundColor && this.hasHeader() && (e.style.backgroundColor = "#f2f3f5");
66
- }
67
- return t;
68
- }
69
- exportJSON() {
70
- return {
71
- ...super.exportJSON(),
72
- ...qe(this.__verticalAlign) && { verticalAlign: this.__verticalAlign },
73
- backgroundColor: this.getBackgroundColor(),
74
- colSpan: this.__colSpan,
75
- headerState: this.__headerState,
76
- rowSpan: this.__rowSpan,
77
- width: this.getWidth()
78
- };
79
- }
80
- getColSpan() {
81
- return this.getLatest().__colSpan;
82
- }
83
- setColSpan(e) {
84
- const t = this.getWritable();
85
- return t.__colSpan = e, t;
86
- }
87
- getRowSpan() {
88
- return this.getLatest().__rowSpan;
89
- }
90
- setRowSpan(e) {
91
- const t = this.getWritable();
92
- return t.__rowSpan = e, t;
93
- }
94
- getTag() {
95
- return this.hasHeader() ? "th" : "td";
96
- }
97
- setHeaderStyles(e, t = Xe.BOTH) {
98
- const n = this.getWritable();
99
- return n.__headerState = e & t | n.__headerState & ~t, n;
100
- }
101
- getHeaderStyles() {
102
- return this.getLatest().__headerState;
103
- }
104
- setWidth(e) {
105
- const t = this.getWritable();
106
- return t.__width = e, t;
107
- }
108
- getWidth() {
109
- return this.getLatest().__width;
110
- }
111
- getBackgroundColor() {
112
- return this.getLatest().__backgroundColor;
113
- }
114
- setBackgroundColor(e) {
115
- const t = this.getWritable();
116
- return t.__backgroundColor = e, t;
117
- }
118
- getVerticalAlign() {
119
- return this.getLatest().__verticalAlign;
120
- }
121
- setVerticalAlign(e) {
122
- const t = this.getWritable();
123
- return t.__verticalAlign = e || void 0, t;
124
- }
125
- toggleHeaderStyle(e) {
126
- const t = this.getWritable();
127
- return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
128
- }
129
- hasHeaderState(e) {
130
- return (this.getHeaderStyles() & e) === e;
131
- }
132
- hasHeader() {
133
- return this.getLatest().__headerState !== Xe.NO_STATUS;
134
- }
135
- updateDOM(e) {
136
- 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;
137
- }
138
- isShadowRoot() {
139
- return !0;
140
- }
141
- collapseAtStart() {
142
- return !0;
143
- }
144
- canBeEmpty() {
145
- return !1;
146
- }
147
- canIndent() {
148
- return !1;
149
- }
150
- };
151
- function qe(e) {
152
- return "middle" === e || "bottom" === e;
153
- }
154
- function je(e) {
155
- const t = e, n = e.nodeName.toLowerCase();
156
- let o;
157
- Je.test(t.style.width) && (o = parseFloat(t.style.width));
158
- let r = Xe.NO_STATUS;
159
- if ("th" === n) {
160
- const e = t.getAttribute("scope");
161
- if ("col" === e) r = Xe.COLUMN;
162
- else if ("row" === e) r = Xe.ROW;
163
- else {
164
- const e = t.parentElement, n = isHTMLElement(e) && "tr" === e.nodeName.toLowerCase() && isHTMLElement(e.parentElement) && ("thead" === e.parentElement.nodeName.toLowerCase() || 0 === e.rowIndex), o = 0 === t.cellIndex;
165
- n && (r |= Xe.ROW), o && (r |= Xe.COLUMN), r === Xe.NO_STATUS && (r = Xe.ROW);
166
- }
167
- }
168
- const l = Ve(r, t.colSpan, o);
169
- l.__rowSpan = t.rowSpan;
170
- const s = t.style.backgroundColor;
171
- "" !== s && (l.__backgroundColor = s);
172
- const i = t.style.verticalAlign;
173
- qe(i) && (l.__verticalAlign = i);
174
- const c = t.style, a = (c && c.textDecoration || "").split(" "), u = "700" === c.fontWeight || "bold" === c.fontWeight, h = a.includes("line-through"), C = "italic" === c.fontStyle, _ = a.includes("underline"), S = c.color;
175
- return {
176
- after: (e) => {
177
- const t = [];
178
- let n = null;
179
- const o = () => {
180
- if (n) {
181
- const e = n.getFirstChild();
182
- $isLineBreakNode(e) && 1 === n.getChildrenSize() && e.remove();
183
- }
184
- };
185
- for (const r of e) if ($isInlineElementOrDecoratorNode(r) || $isTextNode(r) || $isLineBreakNode(r)) {
186
- if ($isTextNode(r) && (u && r.toggleFormat("bold"), h && r.toggleFormat("strikethrough"), C && r.toggleFormat("italic"), _ && r.toggleFormat("underline"), S)) {
187
- const e = r.getStyle();
188
- e.includes("color:") || r.setStyle(e + `color: ${S};`);
189
- }
190
- n ? n.append(r) : (n = $createParagraphNode().append(r), t.push(n));
191
- } else t.push(r), o(), n = null;
192
- return o(), 0 === t.length && t.push($createParagraphNode()), t;
193
- },
194
- node: l
195
- };
196
- }
197
- function Ve(e = Xe.NO_STATUS, t = 1, n) {
198
- return $applyNodeReplacement(new Ye(e, t, n));
199
- }
200
- function Ge(e) {
201
- return e instanceof Ye;
202
- }
203
- const Qe = createCommand("INSERT_TABLE_COMMAND");
204
- function Ze(e, ...t) {
205
- const n = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
206
- o.append("code", e);
207
- for (const e of t) o.append("v", e);
208
- throw n.search = o.toString(), Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
209
- }
210
- var et = class et extends ElementNode {
211
- __height;
212
- static getType() {
213
- return "tablerow";
214
- }
215
- static clone(e) {
216
- return new et(e.__height, e.__key);
217
- }
218
- afterCloneFrom(e) {
219
- super.afterCloneFrom(e), this.__height = e.__height;
220
- }
221
- static importDOM() {
222
- return { tr: (e) => ({
223
- conversion: tt,
224
- priority: 0
225
- }) };
226
- }
227
- static importJSON(e) {
228
- return nt().updateFromJSON(e);
229
- }
230
- updateFromJSON(e) {
231
- return super.updateFromJSON(e).setHeight(e.height);
232
- }
233
- constructor(e, t) {
234
- super(t), this.__height = e;
235
- }
236
- exportJSON() {
237
- const e = this.getHeight();
238
- return {
239
- ...super.exportJSON(),
240
- ...void 0 === e ? void 0 : { height: e }
241
- };
242
- }
243
- createDOM(t) {
244
- const n = document.createElement("tr");
245
- return this.__height && (n.style.height = `${this.__height}px`), addClassNamesToElement(n, t.theme.tableRow), n;
246
- }
247
- extractWithChild(e, t, n) {
248
- return "html" === n;
249
- }
250
- isShadowRoot() {
251
- return !0;
252
- }
253
- setHeight(e) {
254
- const t = this.getWritable();
255
- return t.__height = e, t;
256
- }
257
- getHeight() {
258
- return this.getLatest().__height;
259
- }
260
- updateDOM(e) {
261
- return e.__height !== this.__height;
262
- }
263
- canBeEmpty() {
264
- return !1;
265
- }
266
- canIndent() {
267
- return !1;
268
- }
269
- };
270
- function tt(e) {
271
- const n = e;
272
- let o;
273
- return Je.test(n.style.height) && (o = parseFloat(n.style.height)), {
274
- after: (e) => $descendantsMatching(e, Ge),
275
- node: nt(o)
276
- };
277
- }
278
- function nt(e) {
279
- return $applyNodeReplacement(new et(e));
280
- }
281
- function ot(e) {
282
- return e instanceof et;
283
- }
284
- function rt(e, t, n = !0) {
285
- const o = Hn();
286
- for (let r = 0; r < e; r++) {
287
- const e = nt();
288
- for (let o = 0; o < t; o++) {
289
- let t = Xe.NO_STATUS;
290
- "object" == typeof n ? (0 === r && n.rows && (t |= Xe.ROW), 0 === o && n.columns && (t |= Xe.COLUMN)) : n && (0 === r && (t |= Xe.ROW), 0 === o && (t |= Xe.COLUMN));
291
- const l = Ve(t), s = $createParagraphNode();
292
- s.append($createTextNode()), l.append(s), e.append(l);
293
- }
294
- o.append(e);
295
- }
296
- return o;
297
- }
298
- function lt(e) {
299
- const t = $findMatchingParent(e, (e) => Ge(e));
300
- return Ge(t) ? t : null;
301
- }
302
- function st(e) {
303
- const t = $findMatchingParent(e, (e) => ot(e));
304
- if (ot(t)) return t;
305
- throw new Error("Expected table cell to be inside of table row.");
306
- }
307
- function it(e) {
308
- const t = $findMatchingParent(e, (e) => Bn(e));
309
- if (Bn(t)) return t;
310
- throw new Error("Expected table cell to be inside of table.");
311
- }
312
- function ct(e) {
313
- const t = st(e);
314
- return it(t).getChildren().findIndex((e) => e.is(t));
315
- }
316
- function at(e) {
317
- return st(e).getChildren().findIndex((t) => t.is(e));
318
- }
319
- function ut(e, t) {
320
- const n = it(e), { x: o, y: r } = n.getCordsFromCellNode(e, t);
321
- return {
322
- above: n.getCellNodeFromCords(o, r - 1, t),
323
- below: n.getCellNodeFromCords(o, r + 1, t),
324
- left: n.getCellNodeFromCords(o - 1, r, t),
325
- right: n.getCellNodeFromCords(o + 1, r, t)
326
- };
327
- }
328
- function ht(e, t) {
329
- const n = e.getChildren();
330
- if (t >= n.length || t < 0) throw new Error("Expected table cell to be inside of table row.");
331
- return n[t].remove(), e;
332
- }
333
- function dt(e, t, n = !0, o, r) {
334
- const l = e.getChildren();
335
- if (t >= l.length || t < 0) throw new Error("Table row target index out of range");
336
- const s = l[t];
337
- if (!ot(s)) throw new Error("Row before insertion index does not exist.");
338
- for (let e = 0; e < o; e++) {
339
- const e = s.getChildren(), t = e.length, o = nt();
340
- for (let n = 0; n < t; n++) {
341
- const t = e[n];
342
- Ge(t) || Ze(12);
343
- const { above: l, below: s } = ut(t, r);
344
- let i = Xe.NO_STATUS;
345
- const c = l && l.getWidth() || s && s.getWidth() || void 0;
346
- (l && l.hasHeaderState(Xe.COLUMN) || s && s.hasHeaderState(Xe.COLUMN)) && (i |= Xe.COLUMN);
347
- const a = Ve(i, 1, c);
348
- a.append($createParagraphNode()), o.append(a);
349
- }
350
- n ? s.insertAfter(o) : s.insertBefore(o);
351
- }
352
- return e;
353
- }
354
- const ft = (e, t) => e === Xe.BOTH || e === t ? t : Xe.NO_STATUS;
355
- function gt(e = !0) {
356
- const t = $getSelection();
357
- $isRangeSelection(t) || Pt(t) || Ze(188);
358
- const n = t.anchor.getNode(), o = t.focus.getNode(), [r] = Mt(n), [l, , s] = Mt(o), [, i, c] = Et(s, l, r), { startRow: a } = c, { startRow: u } = i;
359
- return e ? pt(a + r.__rowSpan > u + l.__rowSpan ? r : l, !0) : pt(u < a ? l : r, !1);
360
- }
361
- const mt = gt;
362
- function pt(e, t = !0) {
363
- const [, , n] = Mt(e), [o, r] = Et(n, e, e), l = o[0].length, { startRow: s } = r;
364
- let i = null;
365
- if (t) {
366
- const t = s + e.__rowSpan - 1, r = o[t], c = nt();
367
- for (let e = 0; e < l; e++) {
368
- const { cell: n, startRow: o } = r[e];
369
- if (o + n.__rowSpan - 1 <= t) {
370
- const t = r[e].cell.__headerState, n = ft(t, Xe.COLUMN);
371
- c.append(Ve(n).append($createParagraphNode()));
372
- } else n.setRowSpan(n.__rowSpan + 1);
373
- }
374
- const a = n.getChildAtIndex(t);
375
- ot(a) || Ze(256), a.insertAfter(c), i = c;
376
- } else {
377
- const e = s, t = o[e], r = nt();
378
- for (let n = 0; n < l; n++) {
379
- const { cell: o, startRow: l } = t[n];
380
- if (l === e) {
381
- const e = t[n].cell.__headerState, o = ft(e, Xe.COLUMN);
382
- r.append(Ve(o).append($createParagraphNode()));
383
- } else o.setRowSpan(o.__rowSpan + 1);
384
- }
385
- const c = n.getChildAtIndex(e);
386
- ot(c) || Ze(257), c.insertBefore(r), i = r;
387
- }
388
- return i;
389
- }
390
- function Ct(e, t, n = !0, o, r) {
391
- const l = e.getChildren(), s = [];
392
- for (let e = 0; e < l.length; e++) {
393
- const n = l[e];
394
- if (ot(n)) for (let e = 0; e < o; e++) {
395
- const e = n.getChildren();
396
- if (t >= e.length || t < 0) throw new Error("Table column target index out of range");
397
- const o = e[t];
398
- Ge(o) || Ze(12);
399
- const { left: l, right: i } = ut(o, r);
400
- let c = Xe.NO_STATUS;
401
- (l && l.hasHeaderState(Xe.ROW) || i && i.hasHeaderState(Xe.ROW)) && (c |= Xe.ROW);
402
- const a = Ve(c);
403
- a.append($createParagraphNode()), s.push({
404
- newTableCell: a,
405
- targetCell: o
406
- });
407
- }
408
- }
409
- return s.forEach(({ newTableCell: e, targetCell: t }) => {
410
- n ? t.insertAfter(e) : t.insertBefore(e);
411
- }), e;
412
- }
413
- function _t(e = !0) {
414
- const t = $getSelection();
415
- $isRangeSelection(t) || Pt(t) || Ze(188);
416
- const n = t.anchor.getNode(), o = t.focus.getNode(), [r] = Mt(n), [l, , s] = Mt(o), [, i, c] = Et(s, l, r), { startColumn: a } = c, { startColumn: u } = i;
417
- return e ? bt(a + r.__colSpan > u + l.__colSpan ? r : l, !0) : bt(u < a ? l : r, !1);
418
- }
419
- const St = _t;
420
- function bt(e, t = !0, n = !0) {
421
- const [, , o] = Mt(e), [r, l] = Et(o, e, e), s = r.length, { startColumn: i } = l, c = t ? i + e.__colSpan - 1 : i - 1, a = o.getFirstChild();
422
- ot(a) || Ze(120);
423
- let u = null;
424
- function h(e = Xe.NO_STATUS) {
425
- const t = Ve(e).append($createParagraphNode());
426
- return null === u && (u = t), t;
427
- }
428
- let d = a;
429
- e: for (let e = 0; e < s; e++) {
430
- if (0 !== e) {
431
- const e = d.getNextSibling();
432
- ot(e) || Ze(121), d = e;
433
- }
434
- const t = r[e], n = t[c < 0 ? 0 : c].cell.__headerState, o = ft(n, Xe.ROW);
435
- if (c < 0) {
436
- Ft(d, h(o));
437
- continue;
438
- }
439
- const { cell: l, startColumn: s, startRow: i } = t[c];
440
- if (s + l.__colSpan - 1 <= c) {
441
- let n = l, r = i, s = c;
442
- for (; r !== e && n.__rowSpan > 1;) {
443
- if (s -= l.__colSpan, !(s >= 0)) {
444
- d.append(h(o));
445
- continue e;
446
- }
447
- {
448
- const { cell: e, startRow: o } = t[s];
449
- n = e, r = o;
450
- }
451
- }
452
- n.insertAfter(h(o));
453
- } else l.setColSpan(l.__colSpan + 1);
454
- }
455
- null !== u && n && Tt(u);
456
- const f = o.getColWidths();
457
- if (f) {
458
- const e = [...f], t = c < 0 ? 0 : c, n = e[t];
459
- e.splice(t, 0, n), o.setColWidths(e);
460
- }
461
- return u;
462
- }
463
- function wt(e, t) {
464
- const n = e.getChildren();
465
- for (let e = 0; e < n.length; e++) {
466
- const o = n[e];
467
- if (ot(o)) {
468
- const e = o.getChildren();
469
- if (t >= e.length || t < 0) throw new Error("Table column target index out of range");
470
- e[t].remove();
471
- }
472
- }
473
- return e;
474
- }
475
- function yt() {
476
- const e = $getSelection();
477
- $isRangeSelection(e) || Pt(e) || Ze(188);
478
- const [t, n] = e.isBackward() ? [e.focus.getNode(), e.anchor.getNode()] : [e.anchor.getNode(), e.focus.getNode()], [o, , r] = Mt(t), [l] = Mt(n), [s, i, c] = Et(r, o, l), { startRow: a } = i, { startRow: u } = c, h = u + l.__rowSpan - 1;
479
- if (s.length === h - a + 1) return void r.remove();
480
- const d = s[0].length, f = s[h + 1], g = r.getChildAtIndex(h + 1);
481
- for (let e = h; e >= a; e--) {
482
- for (let t = d - 1; t >= 0; t--) {
483
- const { cell: n, startRow: o, startColumn: r } = s[e][t];
484
- if (r === t) {
485
- if (o < a || o + n.__rowSpan - 1 > h) {
486
- const e = Math.max(o, a), t = Math.min(n.__rowSpan + o - 1, h), r = e <= t ? t - e + 1 : 0;
487
- n.setRowSpan(n.__rowSpan - r);
488
- }
489
- if (o >= a && o + n.__rowSpan - 1 > h && e === h) {
490
- null === g && Ze(122);
491
- let o = null;
492
- for (let n = 0; n < t; n++) {
493
- const t = f[n], r = t.cell;
494
- t.startRow === e + 1 && (o = r), r.__colSpan > 1 && (n += r.__colSpan - 1);
495
- }
496
- null === o ? Ft(g, n) : o.insertAfter(n);
497
- }
498
- }
499
- }
500
- const t = r.getChildAtIndex(e);
501
- ot(t) || Ze(206, String(e)), t.remove();
502
- }
503
- if (void 0 !== f) {
504
- const { cell: e } = f[0];
505
- Tt(e);
506
- } else {
507
- const { cell: t } = s[a - 1][0];
508
- Tt(t);
509
- }
510
- }
511
- const Nt = yt;
512
- function vt() {
513
- const e = $getSelection();
514
- $isRangeSelection(e) || Pt(e) || Ze(188);
515
- const t = e.anchor.getNode(), n = e.focus.getNode(), [o, , r] = Mt(t), [l] = Mt(n), [s, i, c] = Et(r, o, l), { startColumn: a } = i, { startRow: u, startColumn: h } = c, d = Math.min(a, h), f = Math.max(a + o.__colSpan - 1, h + l.__colSpan - 1), g = f - d + 1;
516
- if (s[0].length === f - d + 1) return r.selectPrevious(), void r.remove();
517
- const m = s.length;
518
- for (let e = 0; e < m; e++) for (let t = d; t <= f; t++) {
519
- const { cell: n, startColumn: o } = s[e][t];
520
- if (o < d) {
521
- if (t === d) {
522
- const e = d - o;
523
- n.setColSpan(n.__colSpan - Math.min(g, n.__colSpan - e));
524
- }
525
- } else if (o + n.__colSpan - 1 > f) {
526
- if (t === f) {
527
- const e = f - o + 1;
528
- n.setColSpan(n.__colSpan - e);
529
- }
530
- } else n.remove();
531
- }
532
- const p = s[u], C = a > h ? p[a + o.__colSpan] : p[h + l.__colSpan];
533
- if (void 0 !== C) {
534
- const { cell: e } = C;
535
- Tt(e);
536
- } else {
537
- const { cell: t } = h < a ? p[h - 1] : p[a - 1];
538
- Tt(t);
539
- }
540
- const _ = r.getColWidths();
541
- if (_) {
542
- const e = [..._];
543
- e.splice(d, g), r.setColWidths(e);
544
- }
545
- }
546
- const xt = vt;
547
- function Tt(e) {
548
- const t = e.getFirstDescendant();
549
- null == t ? e.selectStart() : t.getParentOrThrow().selectStart();
550
- }
551
- function Ft(e, t) {
552
- const n = e.getFirstChild();
553
- null !== n ? n.insertBefore(t) : e.append(t);
554
- }
555
- function Rt(e) {
556
- if (0 === e.length) return null;
557
- const [n] = kt(it(e[0]), null, null);
558
- let o = Infinity, r = -Infinity, l = Infinity, s = -Infinity;
559
- const i = /* @__PURE__ */ new Set();
560
- for (const t of n) for (const n of t) {
561
- if (!n || !n.cell) continue;
562
- const t = n.cell.getKey();
563
- if (!i.has(t) && e.some((e) => e.is(n.cell))) {
564
- i.add(t);
565
- const e = n.startRow, c = n.startColumn, a = n.cell.__rowSpan || 1, u = n.cell.__colSpan || 1;
566
- o = Math.min(o, e), r = Math.max(r, e + a - 1), l = Math.min(l, c), s = Math.max(s, c + u - 1);
567
- }
568
- }
569
- if (o === Infinity || l === Infinity) return null;
570
- const c = r - o + 1, a = s - l + 1, u = n[o][l];
571
- if (!u.cell) return null;
572
- const h = u.cell;
573
- h.setColSpan(a), h.setRowSpan(c);
574
- const d = new Set([h.getKey()]);
575
- for (let e = o; e <= r; e++) for (let t = l; t <= s; t++) {
576
- const o = n[e][t];
577
- if (!o.cell) continue;
578
- const r = o.cell, l = r.getKey();
579
- if (!d.has(l)) {
580
- d.add(l);
581
- Ot(r) || h.append(...r.getChildren()), r.remove();
582
- }
583
- }
584
- return 0 === h.getChildrenSize() && h.append($createParagraphNode()), h;
585
- }
586
- function Ot(e) {
587
- if (1 !== e.getChildrenSize()) return !1;
588
- const t = e.getFirstChildOrThrow();
589
- return !(!$isParagraphNode(t) || !t.isEmpty());
590
- }
591
- function At() {
592
- const e = $getSelection();
593
- $isRangeSelection(e) || Pt(e) || Ze(188);
594
- const o = $findMatchingParent(e.anchor.getNode(), Ge);
595
- return Ge(o) || Ze(148), Kt(o);
596
- }
597
- function Kt(e) {
598
- const [t, n, o] = Mt(e), r = t.__colSpan, l = t.__rowSpan;
599
- if (1 === r && 1 === l) return;
600
- const [s, i] = Et(o, t, t), { startColumn: c, startRow: a } = i, u = t.__headerState & Xe.COLUMN, h = Array.from({ length: r }, (e, t) => {
601
- let n = u;
602
- for (let e = 0; 0 !== n && e < s.length; e++) n &= s[e][t + c].cell.__headerState;
603
- return n;
604
- }), d = t.__headerState & Xe.ROW, f = Array.from({ length: l }, (e, t) => {
605
- let n = d;
606
- for (let e = 0; 0 !== n && e < s[0].length; e++) n &= s[t + a][e].cell.__headerState;
607
- return n;
608
- });
609
- if (r > 1) {
610
- for (let e = 1; e < r; e++) t.insertAfter(Ve(h[e] | f[0]).append($createParagraphNode()));
611
- t.setColSpan(1);
612
- }
613
- if (l > 1) {
614
- let e;
615
- for (let t = 1; t < l; t++) {
616
- const o = a + t, l = s[o];
617
- e = (e || n).getNextSibling(), ot(e) || Ze(125);
618
- let i = null;
619
- for (let e = 0; e < c; e++) {
620
- const t = l[e], n = t.cell;
621
- t.startRow === o && (i = n), n.__colSpan > 1 && (e += n.__colSpan - 1);
622
- }
623
- if (null === i) for (let n = r - 1; n >= 0; n--) Ft(e, Ve(h[n] | f[t]).append($createParagraphNode()));
624
- else for (let e = r - 1; e >= 0; e--) i.insertAfter(Ve(h[e] | f[t]).append($createParagraphNode()));
625
- }
626
- t.setRowSpan(1);
627
- }
628
- }
629
- function Et(e, t, n) {
630
- const [o, r, l] = kt(e, t, n);
631
- return null === r && Ze(207), null === l && Ze(208), [
632
- o,
633
- r,
634
- l
635
- ];
636
- }
637
- function kt(e, t, n) {
638
- const o = [];
639
- let r = null, l = null;
640
- function s(e) {
641
- let t = o[e];
642
- return void 0 === t && (o[e] = t = []), t;
643
- }
644
- const i = e.getChildren();
645
- for (let e = 0; e < i.length; e++) {
646
- const o = i[e];
647
- ot(o) || Ze(209);
648
- const c = s(e);
649
- for (let a = o.getFirstChild(), u = 0; null != a; a = a.getNextSibling()) {
650
- for (Ge(a) || Ze(147); void 0 !== c[u];) u++;
651
- const o = {
652
- cell: a,
653
- startColumn: u,
654
- startRow: e
655
- }, { __rowSpan: h, __colSpan: d } = a;
656
- for (let t = 0; t < h && !(e + t >= i.length); t++) {
657
- const n = s(e + t);
658
- for (let e = 0; e < d; e++) n[u + e] = o;
659
- }
660
- null !== t && null === r && t.is(a) && (r = o), null !== n && null === l && n.is(a) && (l = o);
661
- }
662
- }
663
- return [
664
- o,
665
- r,
666
- l
667
- ];
668
- }
669
- function Mt(e) {
670
- let t;
671
- if (e instanceof Ye) t = e;
672
- else if ("__type" in e) {
673
- const o = $findMatchingParent(e, Ge);
674
- Ge(o) || Ze(148), t = o;
675
- } else {
676
- const o = $findMatchingParent(e.getNode(), Ge);
677
- Ge(o) || Ze(148), t = o;
678
- }
679
- const o = t.getParent();
680
- ot(o) || Ze(149);
681
- const r = o.getParent();
682
- return Bn(r) || Ze(210), [
683
- t,
684
- o,
685
- r
686
- ];
687
- }
688
- function $t(e, t, n) {
689
- let o, r = Math.min(t.startColumn, n.startColumn), l = Math.min(t.startRow, n.startRow), s = Math.max(t.startColumn + t.cell.__colSpan - 1, n.startColumn + n.cell.__colSpan - 1), i = Math.max(t.startRow + t.cell.__rowSpan - 1, n.startRow + n.cell.__rowSpan - 1);
690
- do {
691
- o = !1;
692
- for (let t = 0; t < e.length; t++) for (let n = 0; n < e[0].length; n++) {
693
- const c = e[t][n];
694
- if (!c) continue;
695
- const a = c.startColumn + c.cell.__colSpan - 1, u = c.startRow + c.cell.__rowSpan - 1, h = c.startColumn <= s && a >= r, d = c.startRow <= i && u >= l;
696
- if (h && d) {
697
- const e = Math.min(r, c.startColumn), t = Math.max(s, a), n = Math.min(l, c.startRow), h = Math.max(i, u);
698
- e === r && t === s && n === l && h === i || (r = e, s = t, l = n, i = h, o = !0);
699
- }
700
- }
701
- } while (o);
702
- return {
703
- maxColumn: s,
704
- maxRow: i,
705
- minColumn: r,
706
- minRow: l
707
- };
708
- }
709
- function Wt(e) {
710
- const t = e.getChildren();
711
- let n = null;
712
- for (const e of t) {
713
- if (!ot(e)) return !1;
714
- if (null === n && (n = e.getChildrenSize()), e.getChildrenSize() !== n) return !1;
715
- const t = e.getChildren();
716
- for (const e of t) if (!Ge(e) || 1 !== e.getRowSpan() || 1 !== e.getColSpan()) return !1;
717
- }
718
- return (n || 0) > 0;
719
- }
720
- function zt(e, t, n) {
721
- if (t === n) return;
722
- const o = e.getColumnCount();
723
- if (t < 0 || t >= o || n < 0 || n >= o) return;
724
- if (!Wt(e)) return;
725
- e.getChildren().filter(ot).forEach((e) => {
726
- const o = e.getChildren(), [r] = o.splice(t, 1);
727
- o.splice(n, 0, r), e.splice(0, o.length, o);
728
- });
729
- const r = e.getColWidths();
730
- if (r && r.length === o) {
731
- const o = [...r], [l] = o.splice(t, 1);
732
- o.splice(n, 0, l), e.setColWidths(o);
733
- }
734
- }
735
- function Lt(e) {
736
- const [t, , n] = Mt(e), o = n.getChildren(), r = o.length, l = o[0].getChildren().length, s = new Array(r);
737
- for (let e = 0; e < r; e++) s[e] = new Array(l);
738
- for (let e = 0; e < r; e++) {
739
- const n = o[e].getChildren();
740
- let r = 0;
741
- for (let o = 0; o < n.length; o++) {
742
- for (; s[e][r];) r++;
743
- const l = n[o], i = l.__rowSpan || 1, c = l.__colSpan || 1;
744
- for (let t = 0; t < i; t++) for (let n = 0; n < c; n++) s[e + t][r + n] = l;
745
- if (t === l) return {
746
- colSpan: c,
747
- columnIndex: r,
748
- rowIndex: e,
749
- rowSpan: i
750
- };
751
- r += c;
752
- }
753
- }
754
- return null;
755
- }
756
- function Ht(e) {
757
- const [[t, o, r, l], [s, i, c, a]] = ["anchor", "focus"].map((t) => {
758
- const o = e[t].getNode(), r = $findMatchingParent(o, Ge);
759
- Ge(r) || Ze(238, t, o.getKey(), o.getType());
760
- const l = r.getParent();
761
- ot(l) || Ze(239, t);
762
- const s = l.getParent();
763
- return Bn(s) || Ze(240, t), [
764
- o,
765
- r,
766
- l,
767
- s
768
- ];
769
- });
770
- return l.is(a) || Ze(241), {
771
- anchorCell: o,
772
- anchorNode: t,
773
- anchorRow: r,
774
- anchorTable: l,
775
- focusCell: i,
776
- focusNode: s,
777
- focusRow: c,
778
- focusTable: a
779
- };
780
- }
781
- var Bt = class Bt {
782
- tableKey;
783
- anchor;
784
- focus;
785
- _cachedNodes;
786
- dirty;
787
- constructor(e, t, n) {
788
- this.anchor = t, this.focus = n, t._selection = this, n._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
789
- }
790
- getStartEndPoints() {
791
- return [this.anchor, this.focus];
792
- }
793
- isValid() {
794
- if ("root" === this.tableKey || "root" === this.anchor.key || "element" !== this.anchor.type || "root" === this.focus.key || "element" !== this.focus.type) return !1;
795
- const e = $getNodeByKey(this.tableKey), t = $getNodeByKey(this.anchor.key), n = $getNodeByKey(this.focus.key);
796
- return null !== e && null !== t && null !== n;
797
- }
798
- isBackward() {
799
- return this.focus.isBefore(this.anchor);
800
- }
801
- getCachedNodes() {
802
- return this._cachedNodes;
803
- }
804
- setCachedNodes(e) {
805
- this._cachedNodes = e;
806
- }
807
- is(e) {
808
- return Pt(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
809
- }
810
- set(e, t, n) {
811
- this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || n !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = n, this._cachedNodes = null;
812
- }
813
- clone() {
814
- return new Bt(this.tableKey, $createPoint(this.anchor.key, this.anchor.offset, this.anchor.type), $createPoint(this.focus.key, this.focus.offset, this.focus.type));
815
- }
816
- isCollapsed() {
817
- return !1;
818
- }
819
- extract() {
820
- return this.getNodes();
821
- }
822
- insertRawText(e) {}
823
- insertText() {}
824
- hasFormat(e) {
825
- let t = 0;
826
- this.getNodes().filter(Ge).forEach((e) => {
827
- const n = e.getFirstChild();
828
- $isParagraphNode(n) && (t |= n.getTextFormat());
829
- });
830
- const n = TEXT_TYPE_TO_FORMAT[e];
831
- return 0 !== (t & n);
832
- }
833
- insertNodes(e) {
834
- const t = this.focus.getNode();
835
- $isElementNode(t) || Ze(151);
836
- $normalizeSelection__EXPERIMENTAL(t.select(0, t.getChildrenSize())).insertNodes(e);
837
- }
838
- getShape() {
839
- const { anchorCell: e, focusCell: t } = Ht(this), n = Lt(e);
840
- null === n && Ze(153);
841
- const o = Lt(t);
842
- null === o && Ze(155);
843
- const r = Math.min(n.columnIndex, o.columnIndex), l = Math.max(n.columnIndex + n.colSpan - 1, o.columnIndex + o.colSpan - 1), s = Math.min(n.rowIndex, o.rowIndex), i = Math.max(n.rowIndex + n.rowSpan - 1, o.rowIndex + o.rowSpan - 1);
844
- return {
845
- fromX: Math.min(r, l),
846
- fromY: Math.min(s, i),
847
- toX: Math.max(r, l),
848
- toY: Math.max(s, i)
849
- };
850
- }
851
- getNodes() {
852
- if (!this.isValid()) return [];
853
- const e = this._cachedNodes;
854
- if (null !== e) return e;
855
- const { anchorTable: t, anchorCell: n, focusCell: o } = Ht(this), r = o.getParents()[1];
856
- if (r !== t) {
857
- if (t.isParentOf(o)) {
858
- const e = r.getParent();
859
- e ?? Ze(159), this.set(this.tableKey, o.getKey(), e.getKey());
860
- } else {
861
- const e = t.getParent();
862
- e ?? Ze(158), this.set(this.tableKey, e.getKey(), o.getKey());
863
- }
864
- return this.getNodes();
865
- }
866
- const [l, s, i] = Et(t, n, o), { minColumn: c, maxColumn: a, minRow: u, maxRow: h } = $t(l, s, i), d = new Map([[t.getKey(), t]]);
867
- let f = null;
868
- for (let e = u; e <= h; e++) for (let t = c; t <= a; t++) {
869
- const { cell: n } = l[e][t], o = n.getParent();
870
- ot(o) || Ze(160), o !== f && (d.set(o.getKey(), o), f = o), d.has(n.getKey()) || Ut(n, (e) => {
871
- d.set(e.getKey(), e);
872
- });
873
- }
874
- const g = Array.from(d.values());
875
- return isCurrentlyReadOnlyMode() || (this._cachedNodes = g), g;
876
- }
877
- getTextContent() {
878
- const e = this.getNodes().filter((e) => Ge(e));
879
- let t = "";
880
- for (let n = 0; n < e.length; n++) {
881
- const o = e[n], r = o.__parent, l = (e[n + 1] || {}).__parent;
882
- t += o.getTextContent() + (l !== r ? "\n" : " ");
883
- }
884
- return t;
885
- }
886
- };
887
- function Pt(e) {
888
- return e instanceof Bt;
889
- }
890
- function Dt() {
891
- return new Bt("root", $createPoint("root", 0, "element"), $createPoint("root", 0, "element"));
892
- }
893
- function It(e, t, n) {
894
- e.getKey(), t.getKey(), n.getKey();
895
- const o = $getSelection(), r = Pt(o) ? o.clone() : Dt();
896
- return r.set(e.getKey(), t.getKey(), n.getKey()), r;
897
- }
898
- function Ut(e, t) {
899
- const n = [[e]];
900
- for (let e = n.at(-1); void 0 !== e && n.length > 0; e = n.at(-1)) {
901
- const o = e.pop();
902
- void 0 === o ? n.pop() : !1 !== t(o) && $isElementNode(o) && n.push(o.getChildren());
903
- }
904
- }
905
- function Jt(e, t = $getEditor()) {
906
- const n = $getNodeByKey(e);
907
- Bn(n) || Ze(231, e);
908
- const o = Vt(n, t.getElementByKey(e));
909
- return null === o && Ze(232, e), {
910
- tableElement: o,
911
- tableNode: n
912
- };
913
- }
914
- var Xt = class {
915
- observers;
916
- nextFocus;
917
- shouldCheckSelectionForTable;
918
- constructor() {
919
- this.observers = /* @__PURE__ */ new Map(), this.nextFocus = null, this.shouldCheckSelectionForTable = null;
920
- }
921
- setNextFocus(e) {
922
- this.nextFocus = e;
923
- }
924
- getAndClearNextFocus() {
925
- const { nextFocus: e } = this;
926
- return null !== e && (this.nextFocus = null), e;
927
- }
928
- setShouldCheckSelectionForTable(e) {
929
- this.shouldCheckSelectionForTable = e;
930
- }
931
- getAndClearShouldCheckSelectionForTable() {
932
- const { shouldCheckSelectionForTable: e } = this;
933
- return e ? (this.shouldCheckSelectionForTable = null, e) : null;
934
- }
935
- };
936
- var Yt = class {
937
- focusX;
938
- focusY;
939
- listenersToRemove;
940
- table;
941
- isHighlightingCells;
942
- anchorX;
943
- anchorY;
944
- tableNodeKey;
945
- anchorCell;
946
- focusCell;
947
- anchorCellNodeKey;
948
- focusCellNodeKey;
949
- editor;
950
- tableSelection;
951
- hasHijackedSelectionStyles;
952
- isSelecting;
953
- pointerType;
954
- abortController;
955
- listenerOptions;
956
- constructor(e, t) {
957
- 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 = {
958
- columns: 0,
959
- domRows: [],
960
- rows: 0
961
- }, 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.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.trackTable();
962
- }
963
- getTable() {
964
- return this.table;
965
- }
966
- removeListeners() {
967
- this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
968
- }
969
- $lookup() {
970
- return Jt(this.tableNodeKey, this.editor);
971
- }
972
- trackTable() {
973
- const e = new MutationObserver((e) => {
974
- this.editor.getEditorState().read(() => {
975
- let t = !1;
976
- for (let n = 0; n < e.length; n++) {
977
- const o = e[n].target.nodeName;
978
- if ("TABLE" === o || "TBODY" === o || "THEAD" === o || "TR" === o) {
979
- t = !0;
980
- break;
981
- }
982
- }
983
- if (!t) return;
984
- const { tableNode: n, tableElement: o } = this.$lookup();
985
- this.table = un(n, o);
986
- }, { editor: this.editor });
987
- });
988
- this.editor.getEditorState().read(() => {
989
- const { tableNode: t, tableElement: n } = this.$lookup();
990
- this.table = un(t, n), e.observe(n, {
991
- attributes: !0,
992
- childList: !0,
993
- subtree: !0
994
- });
995
- }, { editor: this.editor });
996
- }
997
- $clearHighlight(e = !0) {
998
- const t = this.editor;
999
- 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();
1000
- const { tableNode: n, tableElement: o } = this.$lookup();
1001
- hn(t, un(n, o), null), e && null !== $getSelection() && ($setSelection(null), t.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0));
1002
- }
1003
- $enableHighlightStyle() {
1004
- const e = this.editor, { tableElement: t } = this.$lookup();
1005
- removeClassNamesFromElement(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
1006
- }
1007
- $disableHighlightStyle() {
1008
- const { tableElement: t } = this.$lookup();
1009
- addClassNamesToElement(t, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
1010
- }
1011
- $updateTableTableSelection(e) {
1012
- if (null !== e) {
1013
- e.tableKey !== this.tableNodeKey && Ze(233, e.tableKey, this.tableNodeKey);
1014
- const t = this.editor;
1015
- this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), hn(t, this.table, this.tableSelection);
1016
- } else this.$clearHighlight();
1017
- }
1018
- updateDOMSelection() {
1019
- if (null !== this.anchorCell && null !== this.focusCell) {
1020
- const e = getDOMSelection(this.editor._window);
1021
- e && e.rangeCount > 0 && e.removeAllRanges();
1022
- }
1023
- }
1024
- $setFocusCellForSelection(e, t = !1) {
1025
- const n = this.editor, { tableNode: o } = this.$lookup(), r = e.x, l = e.y;
1026
- if (this.focusCell = e, !this.isHighlightingCells) (t || this.anchorX !== r || this.anchorY !== l || null != this.tableSelection && null != this.anchorCellNodeKey) && (this.isHighlightingCells = !0, this.$disableHighlightStyle());
1027
- if (-1 !== this.focusX && -1 !== this.focusY && r === this.focusX && l === this.focusY) return !1;
1028
- if (this.focusX = r, this.focusY = l, this.isHighlightingCells) {
1029
- const s = An(o, e.elem);
1030
- if (null != this.tableSelection && null != this.anchorCellNodeKey) {
1031
- let e = s;
1032
- if (null === e && t && (e = o.getCellNodeFromCords(r, l, this.table)), null !== e) {
1033
- const t = this.$getAnchorTableCellOrThrow();
1034
- return this.focusCellNodeKey = e.getKey(), this.tableSelection = It(o, t, e), $setSelection(this.tableSelection), n.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0), hn(n, this.table, this.tableSelection), !0;
1035
- }
1036
- }
1037
- }
1038
- return !1;
1039
- }
1040
- $getAnchorTableCell() {
1041
- return this.anchorCellNodeKey ? $getNodeByKey(this.anchorCellNodeKey) : null;
1042
- }
1043
- $getAnchorTableCellOrThrow() {
1044
- const e = this.$getAnchorTableCell();
1045
- return null === e && Ze(234), e;
1046
- }
1047
- $getFocusTableCell() {
1048
- return this.focusCellNodeKey ? $getNodeByKey(this.focusCellNodeKey) : null;
1049
- }
1050
- $getFocusTableCellOrThrow() {
1051
- const e = this.$getFocusTableCell();
1052
- return null === e && Ze(235), e;
1053
- }
1054
- $setAnchorCellForSelection(e) {
1055
- this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y, this.focusX = -1, this.focusY = -1, this.focusCell = null, this.focusCellNodeKey = null;
1056
- const { tableNode: t } = this.$lookup(), n = An(t, e.elem);
1057
- if (null !== n) {
1058
- const e = n.getKey();
1059
- null != this.tableSelection ? (this.tableSelection = this.tableSelection.clone(), this.tableSelection.set(t.getKey(), e, e)) : this.tableSelection = It(t, n, n), this.anchorCellNodeKey = e;
1060
- }
1061
- }
1062
- $formatCells(e) {
1063
- const t = $getSelection();
1064
- Pt(t) || Ze(236);
1065
- const n = $createRangeSelection(), o = n.anchor, r = n.focus, l = t.getNodes().filter(Ge);
1066
- l.length > 0 || Ze(237);
1067
- const s = l[0].getFirstChild(), i = $isParagraphNode(s) ? s.getFormatFlags(e, null) : null;
1068
- l.forEach((t) => {
1069
- o.set(t.getKey(), 0, "element"), r.set(t.getKey(), t.getChildrenSize(), "element"), n.formatText(e, i);
1070
- }), $setSelection(t), this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
1071
- }
1072
- $clearText() {
1073
- const { editor: e } = this, t = $getNodeByKey(this.tableNodeKey);
1074
- if (!Bn(t)) throw new Error("Expected TableNode.");
1075
- const n = $getSelection();
1076
- Pt(n) || Ze(253);
1077
- const o = n.getNodes().filter(Ge), r = t.getFirstChild(), l = t.getLastChild();
1078
- if (o.length > 0 && null !== r && null !== l && ot(r) && ot(l) && o[0] === r.getFirstChild() && o[o.length - 1] === l.getLastChild()) {
1079
- t.selectPrevious();
1080
- const n = t.getParent();
1081
- t.remove(), $isRootNode(n) && n.isEmpty() && e.dispatchCommand(INSERT_PARAGRAPH_COMMAND, void 0);
1082
- return;
1083
- }
1084
- o.forEach((e) => {
1085
- if ($isElementNode(e)) {
1086
- const t = $createParagraphNode(), n = $createTextNode();
1087
- t.append(n), e.append(t), e.getChildren().forEach((e) => {
1088
- e !== t && e.remove();
1089
- });
1090
- }
1091
- }), hn(e, this.table, null), $setSelection(null), e.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
1092
- }
1093
- };
1094
- const qt = "__lexicalTableSelection";
1095
- function jt(e) {
1096
- return isHTMLElement(e) && "TABLE" === e.nodeName;
1097
- }
1098
- function Vt(e, t) {
1099
- if (!t) return t;
1100
- const n = jt(t) ? t : t.querySelector("table");
1101
- return jt(n) || Ze(341, e.constructor.name, e.getType(), e.getKey(), t.nodeName), n;
1102
- }
1103
- function Gt(e) {
1104
- return e._window;
1105
- }
1106
- function Qt(e, t) {
1107
- for (let n = t, o = null; null !== n; n = n.getParent()) {
1108
- if (e.is(n)) return o;
1109
- Ge(n) && (o = n);
1110
- }
1111
- return null;
1112
- }
1113
- const Zt = [
1114
- [KEY_ARROW_DOWN_COMMAND, "down"],
1115
- [KEY_ARROW_UP_COMMAND, "up"],
1116
- [KEY_ARROW_LEFT_COMMAND, "backward"],
1117
- [KEY_ARROW_RIGHT_COMMAND, "forward"]
1118
- ], en = [
1119
- DELETE_WORD_COMMAND,
1120
- DELETE_LINE_COMMAND,
1121
- DELETE_CHARACTER_COMMAND
1122
- ], tn = [KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND];
1123
- function nn(e, t) {
1124
- return e.registerRootListener((n) => {
1125
- if (null === n) return;
1126
- const o = e._window;
1127
- if (null === o) return;
1128
- const r = (o) => {
1129
- const r = o.target;
1130
- if (0 !== o.button || !isDOMNode(r) || !n.contains(r)) return;
1131
- const l = function(e) {
1132
- const t = cn(e);
1133
- if (null === t) return null;
1134
- let n = t.elem;
1135
- for (; null != n;) {
1136
- if ("TABLE" === n.nodeName && qt in n && n[qt]) return {
1137
- cellElement: t,
1138
- tableElement: n,
1139
- tableObserver: n[qt]
1140
- };
1141
- n = n.parentNode;
1142
- }
1143
- return null;
1144
- }(r);
1145
- e.update(() => {
1146
- if (Pt($getSelection())) {
1147
- for (const [e] of t.observers.values()) e.$clearHighlight(!1);
1148
- $setSelection(null), e.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
1149
- }
1150
- if (!l) return;
1151
- const { tableObserver: n, tableElement: r, cellElement: s } = l;
1152
- (function(e, t, n, o, r, l) {
1153
- const s = e._window;
1154
- if (!s) return;
1155
- const i = (t) => {
1156
- if (r.isSelecting) return;
1157
- r.isSelecting = !0, null !== t && null === r.anchorCell && e.update(() => {
1158
- r.$setAnchorCellForSelection(t);
1159
- });
1160
- const n = () => {
1161
- r.isSelecting = !1, s.removeEventListener("pointerup", n), s.removeEventListener("pointermove", i);
1162
- }, i = (t) => {
1163
- if (!((e) => !(1 & ~e.buttons))(t) && r.isSelecting) return r.isSelecting = !1, s.removeEventListener("pointerup", n), void s.removeEventListener("pointermove", i);
1164
- if (!isDOMNode(t.target)) return;
1165
- let c = null;
1166
- const a = !(IS_FIREFOX || o.contains(t.target));
1167
- if (a) c = an(o, t.target);
1168
- else for (const e of document.elementsFromPoint(t.clientX, t.clientY)) if (c = an(o, e), c) break;
1169
- if (c) {
1170
- const t = c;
1171
- null === r.anchorCell && e.update(() => {
1172
- r.$setAnchorCellForSelection(t);
1173
- }), null !== r.focusCell && c.elem === r.focusCell.elem || (l.setNextFocus({
1174
- focusCell: c,
1175
- override: a,
1176
- tableKey: r.tableNodeKey
1177
- }), e.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0));
1178
- }
1179
- };
1180
- s.addEventListener("pointerup", n, r.listenerOptions), s.addEventListener("pointermove", i, r.listenerOptions);
1181
- };
1182
- r.pointerType = t.pointerType;
1183
- const c = $getNodeByKeyOrThrow(r.tableNodeKey), a = $getPreviousSelection();
1184
- if (IS_FIREFOX && t.shiftKey && _n(a, c) && ($isRangeSelection(a) || Pt(a))) {
1185
- const e = a.anchor.getNode(), o = Qt(c, a.anchor.getNode());
1186
- if (o) r.$setAnchorCellForSelection(On(r, o)), r.$setFocusCellForSelection(n), Tn(t);
1187
- else (c.isBefore(e) ? c.selectStart() : c.selectEnd()).anchor.set(a.anchor.key, a.anchor.offset, a.anchor.type);
1188
- } else "touch" !== t.pointerType && r.$setAnchorCellForSelection(n);
1189
- i(n);
1190
- })(e, o, s, r, n, t);
1191
- });
1192
- };
1193
- return o.addEventListener("pointerdown", r), () => {
1194
- o.removeEventListener("pointerdown", r);
1195
- };
1196
- });
1197
- }
1198
- function on(e, t, o, l, s) {
1199
- const i = o.getRootElement(), c = Gt(o);
1200
- null !== i && null !== c || Ze(246);
1201
- const a = new Yt(o, e.getKey()), u = Vt(e, t);
1202
- (function(e, t) {
1203
- null !== sn(e) && Ze(205);
1204
- e[qt] = t;
1205
- })(u, a), a.listenersToRemove.add(() => function(e, t) {
1206
- sn(e) === t && delete e[qt];
1207
- }(u, a));
1208
- const h = (e) => {
1209
- if (e.detail >= 3 && isDOMNode(e.target)) null !== cn(e.target) && e.preventDefault();
1210
- };
1211
- u.addEventListener("mousedown", h, a.listenerOptions), a.listenersToRemove.add(() => {
1212
- u.removeEventListener("mousedown", h);
1213
- });
1214
- for (const [t, n] of Zt) a.listenersToRemove.add(o.registerCommand(t, (t) => xn(o, t, n, e, a, s), COMMAND_PRIORITY_HIGH));
1215
- a.listenersToRemove.add(o.registerCommand(KEY_ESCAPE_COMMAND, (t) => {
1216
- const n = $getSelection();
1217
- if (Pt(n)) {
1218
- const o = Qt(e, n.focus.getNode());
1219
- if (null !== o) return Tn(t), o.selectEnd(), !0;
1220
- }
1221
- return !1;
1222
- }, COMMAND_PRIORITY_HIGH));
1223
- const d = (t) => () => {
1224
- const o = $getSelection();
1225
- if (!_n(o, e)) return !1;
1226
- if (Pt(o)) return a.$clearText(), !0;
1227
- if ($isRangeSelection(o)) {
1228
- if (!Ge(Qt(e, o.anchor.getNode()))) return !1;
1229
- const r = o.anchor.getNode(), l = o.focus.getNode(), s = e.isParentOf(r), i = e.isParentOf(l);
1230
- if (s && !i || i && !s) return a.$clearText(), !0;
1231
- const c = $findMatchingParent(o.anchor.getNode(), (e) => $isElementNode(e)), u = c && $findMatchingParent(c, (e) => $isElementNode(e) && Ge(e.getParent()));
1232
- if (!$isElementNode(u) || !$isElementNode(c)) return !1;
1233
- if (t === DELETE_LINE_COMMAND && null === u.getPreviousSibling()) return !0;
1234
- }
1235
- return !1;
1236
- };
1237
- for (const e of en) a.listenersToRemove.add(o.registerCommand(e, d(e), COMMAND_PRIORITY_HIGH));
1238
- const f = (t) => {
1239
- const n = $getSelection();
1240
- if (!Pt(n) && !$isRangeSelection(n)) return !1;
1241
- const o = e.isParentOf(n.anchor.getNode());
1242
- if (o !== e.isParentOf(n.focus.getNode())) {
1243
- const t = o ? "anchor" : "focus", r = o ? "focus" : "anchor", { key: l, offset: s, type: i } = n[r];
1244
- return e[n[t].isBefore(n[r]) ? "selectPrevious" : "selectNext"]()[r].set(l, s, i), !1;
1245
- }
1246
- return !!_n(n, e) && !!Pt(n) && (t && (t.preventDefault(), t.stopPropagation()), a.$clearText(), !0);
1247
- };
1248
- for (const e of tn) a.listenersToRemove.add(o.registerCommand(e, f, COMMAND_PRIORITY_HIGH));
1249
- return a.listenersToRemove.add(o.registerCommand(CUT_COMMAND, (e) => {
1250
- const t = $getSelection();
1251
- if (t) {
1252
- if (!Pt(t) && !$isRangeSelection(t)) return !1;
1253
- copyToClipboard(o, objectKlassEquals(e, ClipboardEvent) ? e : null, $getClipboardDataFromSelection(t));
1254
- const n = f(e);
1255
- return $isRangeSelection(t) ? (t.removeText(), !0) : n;
1256
- }
1257
- return !1;
1258
- }, COMMAND_PRIORITY_HIGH)), a.listenersToRemove.add(o.registerCommand(FORMAT_TEXT_COMMAND, (t) => {
1259
- const o = $getSelection();
1260
- if (!_n(o, e)) return !1;
1261
- if (Pt(o)) return a.$formatCells(t), !0;
1262
- if ($isRangeSelection(o)) {
1263
- if (!Ge($findMatchingParent(o.anchor.getNode(), (e) => Ge(e)))) return !1;
1264
- }
1265
- return !1;
1266
- }, COMMAND_PRIORITY_HIGH)), a.listenersToRemove.add(o.registerCommand(FORMAT_ELEMENT_COMMAND, (t) => {
1267
- const n = $getSelection();
1268
- if (!Pt(n) || !_n(n, e)) return !1;
1269
- const o = n.anchor.getNode(), r = n.focus.getNode();
1270
- if (!Ge(o) || !Ge(r)) return !1;
1271
- if (function(e, t) {
1272
- if (Pt(e)) {
1273
- const n = e.anchor.getNode(), o = e.focus.getNode();
1274
- if (t && n && o) {
1275
- const [e] = Et(t, n, o);
1276
- return n.getKey() === e[0][0].cell.getKey() && o.getKey() === e[e.length - 1].at(-1).cell.getKey();
1277
- }
1278
- }
1279
- return !1;
1280
- }(n, e)) return e.setFormat(t), !0;
1281
- const [l, s, i] = Et(e, o, r), c = Math.max(s.startRow + s.cell.__rowSpan - 1, i.startRow + i.cell.__rowSpan - 1), a = Math.max(s.startColumn + s.cell.__colSpan - 1, i.startColumn + i.cell.__colSpan - 1), u = Math.min(s.startRow, i.startRow), h = Math.min(s.startColumn, i.startColumn), d = /* @__PURE__ */ new Set();
1282
- for (let e = u; e <= c; e++) for (let n = h; n <= a; n++) {
1283
- const o = l[e][n].cell;
1284
- if (d.has(o)) continue;
1285
- d.add(o), o.setFormat(t);
1286
- const r = o.getChildren();
1287
- for (let e = 0; e < r.length; e++) {
1288
- const n = r[e];
1289
- $isElementNode(n) && !n.isInline() && n.setFormat(t);
1290
- }
1291
- }
1292
- return !0;
1293
- }, COMMAND_PRIORITY_HIGH)), a.listenersToRemove.add(o.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND, (t) => {
1294
- const r = $getSelection();
1295
- if (!_n(r, e)) return !1;
1296
- if (Pt(r)) return a.$clearHighlight(), !1;
1297
- if ($isRangeSelection(r)) {
1298
- if (!Ge($findMatchingParent(r.anchor.getNode(), (e) => Ge(e)))) return !1;
1299
- if ("string" == typeof t) {
1300
- const n = Rn(o, r, e);
1301
- if (n) return Fn(n, e, [$createTextNode(t)]), !0;
1302
- }
1303
- }
1304
- return !1;
1305
- }, COMMAND_PRIORITY_HIGH)), l && a.listenersToRemove.add(o.registerCommand(KEY_TAB_COMMAND, (t) => {
1306
- const o = $getSelection();
1307
- if (!$isRangeSelection(o) || !o.isCollapsed() || !_n(o, e)) return !1;
1308
- const r = yn(o.anchor.getNode());
1309
- return !(null === r || !e.is(Nn(r))) && (Tn(t), function(e, t) {
1310
- const o = "next" === t ? "getNextSibling" : "getPreviousSibling", r = "next" === t ? "getFirstChild" : "getLastChild", l = e[o]();
1311
- if ($isElementNode(l)) return l.selectEnd();
1312
- const s = $findMatchingParent(e, ot);
1313
- null === s && Ze(247);
1314
- for (let e = s[o](); ot(e); e = e[o]()) {
1315
- const t = e[r]();
1316
- if ($isElementNode(t)) return t.selectEnd();
1317
- }
1318
- const i = $findMatchingParent(s, Bn);
1319
- null === i && Ze(248);
1320
- "next" === t ? i.selectNext() : i.selectPrevious();
1321
- }(r, t.shiftKey ? "previous" : "next"), !0);
1322
- }, COMMAND_PRIORITY_HIGH)), a.listenersToRemove.add(o.registerCommand(FOCUS_COMMAND, (t) => e.isSelected(), COMMAND_PRIORITY_HIGH)), a.listenersToRemove.add(o.registerCommand(INSERT_PARAGRAPH_COMMAND, () => {
1323
- const t = $getSelection();
1324
- if (!$isRangeSelection(t) || !t.isCollapsed() || !_n(t, e)) return !1;
1325
- const n = Rn(o, t, e);
1326
- return !!n && (Fn(n, e), !0);
1327
- }, COMMAND_PRIORITY_HIGH)), a;
1328
- }
1329
- function rn(e, t) {
1330
- const o = $getSelection(), r = $getPreviousSelection(), l = e.getAndClearNextFocus();
1331
- if (null !== l) {
1332
- const { tableKey: t, focusCell: n } = l, r = e.observers.get(t);
1333
- r || Ze(335, t);
1334
- const [s] = r;
1335
- if (Pt(o) && o.tableKey === s.tableNodeKey) return (n.x !== s.focusX || n.y !== s.focusY) && (s.$setFocusCellForSelection(n), !0);
1336
- if (null !== s.anchorCell && null !== s.anchorCellNodeKey && n.elem !== s.anchorCell.elem && null !== s.tableSelection) return s.$setFocusCellForSelection(n, !0), !0;
1337
- }
1338
- const s = e.getAndClearShouldCheckSelectionForTable();
1339
- if (s && $isRangeSelection(r) && $isRangeSelection(o) && o.isCollapsed()) {
1340
- const e = $getNodeByKeyOrThrow(s), t = o.anchor.getNode(), r = e.getFirstChild(), l = yn(t);
1341
- if (null !== l && ot(r)) {
1342
- const t = r.getFirstChild();
1343
- if (Ge(t) && e.is($findMatchingParent(l, (n) => n.is(e) || n.is(t)))) return t.selectStart(), !0;
1344
- }
1345
- }
1346
- Pt(o) && function(e, t) {
1347
- const n = Gt(e), o = $getPreviousSelection();
1348
- if (!t.is(o)) return;
1349
- const r = $getNodeByKeyOrThrow(t.tableKey), l = getDOMSelection(n);
1350
- if (l && l.anchorNode && l.focusNode) {
1351
- const n = $getNearestNodeFromDOMNode(l.focusNode), o = n && !r.isParentOf(n), s = $getNearestNodeFromDOMNode(l.anchorNode), i = s && r.isParentOf(s);
1352
- if (o && i && l.rangeCount > 0) {
1353
- const n = $createRangeSelectionFromDom(l, e);
1354
- n && (n.anchor.set(r.getKey(), t.isBackward() ? r.getChildrenSize() : 0, "element"), l.removeAllRanges(), $setSelection(n));
1355
- }
1356
- }
1357
- }(t, o), $isRangeSelection(o) && function(e, t) {
1358
- const n = $getPreviousSelection(), { anchor: o, focus: r } = e, l = o.getNode(), s = r.getNode(), i = yn(l), c = yn(s), a = i ? Nn(i) : null, u = c ? Nn(c) : null, h = e.isBackward(), d = i && c && a && u && a.is(u), f = u && (!a || a.isParentOf(u)), g = a && (!u || u.isParentOf(a));
1359
- if (f) {
1360
- const t = e.clone(), [n] = Et(u, c, c), o = n[0][0].cell, r = n[n.length - 1].at(-1).cell;
1361
- t.focus.set(h ? o.getKey() : r.getKey(), h ? 0 : r.getChildrenSize(), "element"), $setSelection(t);
1362
- } else if (g) {
1363
- const t = e.clone(), [n] = Et(a, i, i), o = n[0][0].cell, r = n[n.length - 1].at(-1).cell;
1364
- t.anchor.set(h ? r.getKey() : o.getKey(), h ? r.getChildrenSize() : 0, "element"), $setSelection(t);
1365
- } else if (d) {
1366
- const o = t.observers.get(a.getKey());
1367
- o || Ze(335, a.getKey());
1368
- const [r] = o;
1369
- if (i.is(c) || (r.$setAnchorCellForSelection(On(r, i)), r.$setFocusCellForSelection(On(r, c), !0)), "touch" === r.pointerType && r.isSelecting && e.isCollapsed() && $isRangeSelection(n) && n.isCollapsed()) {
1370
- const e = yn(n.anchor.getNode());
1371
- e && !e.is(c) && (r.$setAnchorCellForSelection(On(r, e)), r.$setFocusCellForSelection(On(r, c), !0), r.pointerType = null);
1372
- }
1373
- }
1374
- }(o, e);
1375
- const i = Array.from(e.observers.entries()).map(([e, [t]]) => ({
1376
- tableNode: $getNodeByKeyOrThrow(e),
1377
- tableObserver: t
1378
- }));
1379
- for (const { tableNode: e, tableObserver: n } of i) ln(t, e, n);
1380
- return !1;
1381
- }
1382
- function ln(e, t, n) {
1383
- const o = $getSelection(), r = $getPreviousSelection();
1384
- o && !o.is(r) && (Pt(o) || Pt(r)) && n.tableSelection && !n.tableSelection.is(r) && (Pt(o) && o.tableKey === n.tableNodeKey ? n.$updateTableTableSelection(o) : !Pt(o) && Pt(r) && r.tableKey === n.tableNodeKey && n.$updateTableTableSelection(null)), n.hasHijackedSelectionStyles && !t.isSelected() ? function(e, t) {
1385
- t.$enableHighlightStyle(), dn(t.table, (t) => {
1386
- const n = t.elem;
1387
- t.highlighted = !1, wn(e, t), n.getAttribute("style") || n.removeAttribute("style");
1388
- });
1389
- }(e, n) : !n.hasHijackedSelectionStyles && t.isSelected() && function(e, t) {
1390
- t.$disableHighlightStyle(), dn(t.table, (t) => {
1391
- t.highlighted = !0, bn(e, t);
1392
- });
1393
- }(e, n);
1394
- }
1395
- function sn(e) {
1396
- return e[qt] || null;
1397
- }
1398
- function cn(e) {
1399
- let t = e;
1400
- for (; null != t;) {
1401
- const e = t.nodeName;
1402
- if ("TD" === e || "TH" === e) {
1403
- const e = t._cell;
1404
- return void 0 === e ? null : e;
1405
- }
1406
- t = t.parentNode;
1407
- }
1408
- return null;
1409
- }
1410
- function an(e, t) {
1411
- if (!e.contains(t)) return null;
1412
- let n = null;
1413
- for (let o = t; null != o; o = o.parentNode) {
1414
- if (o === e) return n;
1415
- const t = o.nodeName;
1416
- "TD" !== t && "TH" !== t || (n = o._cell || null);
1417
- }
1418
- return null;
1419
- }
1420
- function un(e, t) {
1421
- const n = [], o = {
1422
- columns: 0,
1423
- domRows: n,
1424
- rows: 0
1425
- };
1426
- let r = Vt(e, t).querySelector("tr"), l = 0, s = 0;
1427
- for (n.length = 0; null != r;) {
1428
- const e = r.nodeName;
1429
- if ("TD" === e || "TH" === e) {
1430
- const e = {
1431
- elem: r,
1432
- hasBackgroundColor: "" !== r.style.backgroundColor,
1433
- highlighted: !1,
1434
- x: l,
1435
- y: s
1436
- };
1437
- r._cell = e;
1438
- let t = n[s];
1439
- void 0 === t && (t = n[s] = []), t[l] = e;
1440
- } else {
1441
- const e = r.firstChild;
1442
- if (null != e) {
1443
- r = e;
1444
- continue;
1445
- }
1446
- }
1447
- const t = r.nextSibling;
1448
- if (null != t) {
1449
- l++, r = t;
1450
- continue;
1451
- }
1452
- const o = r.parentNode;
1453
- if (null != o) {
1454
- const e = o.nextSibling;
1455
- if (null == e) break;
1456
- s++, l = 0, r = e;
1457
- }
1458
- }
1459
- return o.columns = l + 1, o.rows = s + 1, o;
1460
- }
1461
- function hn(e, t, n) {
1462
- const o = new Set(n ? n.getNodes() : []);
1463
- dn(t, (t, n) => {
1464
- const r = t.elem;
1465
- o.has(n) ? (t.highlighted = !0, bn(e, t)) : (t.highlighted = !1, wn(e, t), r.getAttribute("style") || r.removeAttribute("style"));
1466
- });
1467
- }
1468
- function dn(e, t) {
1469
- const { domRows: n } = e;
1470
- for (let e = 0; e < n.length; e++) {
1471
- const o = n[e];
1472
- if (o) for (let n = 0; n < o.length; n++) {
1473
- const r = o[n];
1474
- if (!r) continue;
1475
- const l = $getNearestNodeFromDOMNode(r.elem);
1476
- null !== l && t(r, l, {
1477
- x: n,
1478
- y: e
1479
- });
1480
- }
1481
- }
1482
- }
1483
- const fn = (e, t, n, o, r) => {
1484
- const l = "forward" === r;
1485
- switch (r) {
1486
- case "backward":
1487
- case "forward": return n !== (l ? e.table.columns - 1 : 0) ? Sn(t.getCellNodeFromCordsOrThrow(n + (l ? 1 : -1), o, e.table), l) : o !== (l ? e.table.rows - 1 : 0) ? Sn(t.getCellNodeFromCordsOrThrow(l ? 0 : e.table.columns - 1, o + (l ? 1 : -1), e.table), l) : l ? t.selectNext() : t.selectPrevious(), !0;
1488
- case "up": return 0 !== o ? Sn(t.getCellNodeFromCordsOrThrow(n, o - 1, e.table), !1) : t.selectPrevious(), !0;
1489
- case "down": return o !== e.table.rows - 1 ? Sn(t.getCellNodeFromCordsOrThrow(n, o + 1, e.table), !0) : t.selectNext(), !0;
1490
- default: return !1;
1491
- }
1492
- };
1493
- function gn(e, t) {
1494
- let n, o;
1495
- if (t.startColumn === e.minColumn) n = "minColumn";
1496
- else {
1497
- if (t.startColumn + t.cell.__colSpan - 1 !== e.maxColumn) return null;
1498
- n = "maxColumn";
1499
- }
1500
- if (t.startRow === e.minRow) o = "minRow";
1501
- else {
1502
- if (t.startRow + t.cell.__rowSpan - 1 !== e.maxRow) return null;
1503
- o = "maxRow";
1504
- }
1505
- return [n, o];
1506
- }
1507
- function mn([e, t]) {
1508
- return ["minColumn" === e ? "maxColumn" : "minColumn", "minRow" === t ? "maxRow" : "minRow"];
1509
- }
1510
- function pn(e, t, [n, o]) {
1511
- const r = t[o], l = e[r];
1512
- void 0 === l && Ze(250, o, String(r));
1513
- const s = t[n], i = l[s];
1514
- return void 0 === i && Ze(250, n, String(s)), i;
1515
- }
1516
- function Cn(e, t, n, o, r) {
1517
- const l = $t(t, n, o), { topSpan: i, leftSpan: c, bottomSpan: a, rightSpan: u } = function(e, t) {
1518
- const { minColumn: n, maxColumn: o, minRow: r, maxRow: l } = t;
1519
- let s = 1, i = 1, c = 1, a = 1;
1520
- const u = e[r], h = e[l];
1521
- for (let e = n; e <= o; e++) s = Math.max(s, u[e].cell.__rowSpan), a = Math.max(a, h[e].cell.__rowSpan);
1522
- for (let t = r; t <= l; t++) i = Math.max(i, e[t][n].cell.__colSpan), c = Math.max(c, e[t][o].cell.__colSpan);
1523
- return {
1524
- bottomSpan: a,
1525
- leftSpan: i,
1526
- rightSpan: c,
1527
- topSpan: s
1528
- };
1529
- }(t, l), [d, f] = mn(function(e, t) {
1530
- const n = gn(e, t);
1531
- return null === n && Ze(249, t.cell.getKey()), n;
1532
- }(l, n));
1533
- let g = l[d], m = l[f];
1534
- "forward" === r ? g += "maxColumn" === d ? 1 : c : "backward" === r ? g -= "minColumn" === d ? 1 : u : "down" === r ? m += "maxRow" === f ? 1 : i : "up" === r && (m -= "minRow" === f ? 1 : a);
1535
- const p = t[m];
1536
- if (void 0 === p) return !1;
1537
- const C = p[g];
1538
- if (void 0 === C) return !1;
1539
- const [_, S] = function(e, t, n) {
1540
- const o = $t(e, t, n), r = gn(o, t);
1541
- if (r) return [pn(e, o, r), pn(e, o, mn(r))];
1542
- const l = gn(o, n);
1543
- if (l) return [pn(e, o, mn(l)), pn(e, o, l)];
1544
- const s = ["minColumn", "minRow"];
1545
- return [pn(e, o, s), pn(e, o, mn(s))];
1546
- }(t, n, C), b = On(e, _.cell), w = On(e, S.cell);
1547
- return e.$setAnchorCellForSelection(b), e.$setFocusCellForSelection(w, !0), !0;
1548
- }
1549
- function _n(e, t) {
1550
- if ($isRangeSelection(e) || Pt(e)) {
1551
- const n = t.isParentOf(e.anchor.getNode()), o = t.isParentOf(e.focus.getNode());
1552
- return n && o;
1553
- }
1554
- return !1;
1555
- }
1556
- function Sn(e, t) {
1557
- t ? e.selectStart() : e.selectEnd();
1558
- }
1559
- function bn(t, n) {
1560
- const o = n.elem, r = t._config.theme;
1561
- Ge($getNearestNodeFromDOMNode(o)) || Ze(131), addClassNamesToElement(o, r.tableCellSelected);
1562
- }
1563
- function wn(e, t) {
1564
- const n = t.elem;
1565
- Ge($getNearestNodeFromDOMNode(n)) || Ze(131);
1566
- const r = e._config.theme;
1567
- removeClassNamesFromElement(n, r.tableCellSelected);
1568
- }
1569
- function yn(e) {
1570
- const t = $findMatchingParent(e, Ge);
1571
- return Ge(t) ? t : null;
1572
- }
1573
- function Nn(e) {
1574
- const t = $findMatchingParent(e, Bn);
1575
- return Bn(t) ? t : null;
1576
- }
1577
- function vn(e, t, o, r, l, s, i) {
1578
- const c = $caretFromPoint(o.focus, l ? "previous" : "next");
1579
- if ($isExtendableTextPointCaret(c)) return !1;
1580
- let a = c;
1581
- for (const e of $extendCaretToRange(c).iterNodeCarets("shadowRoot")) {
1582
- if (!$isSiblingCaret(e) || !$isElementNode(e.origin)) return !1;
1583
- a = e;
1584
- }
1585
- const u = a.getParentAtCaret();
1586
- if (!Ge(u)) return !1;
1587
- const h = u, d = function(e) {
1588
- for (const t of $extendCaretToRange(e).iterNodeCarets("root")) {
1589
- const { origin: n } = t;
1590
- if (Ge(n)) {
1591
- if ($isChildCaret(t)) return $getChildCaret(n, e.direction);
1592
- } else if (!ot(n)) break;
1593
- }
1594
- return null;
1595
- }($getSiblingCaret(h, a.direction)), f = $findMatchingParent(h, Bn);
1596
- if (!f || !f.is(s)) return !1;
1597
- const g = e.getElementByKey(h.getKey()), m = cn(g);
1598
- if (!g || !m) return !1;
1599
- if (i.table = zn(e, f), d) if ("extend" === r) {
1600
- const t = cn(e.getElementByKey(d.origin.getKey()));
1601
- if (!t) return !1;
1602
- i.$setAnchorCellForSelection(m), i.$setFocusCellForSelection(t, !0);
1603
- } else {
1604
- const e = $normalizeCaret(d);
1605
- $setPointFromCaret(o.anchor, e), $setPointFromCaret(o.focus, e);
1606
- }
1607
- else if ("extend" === r) i.$setAnchorCellForSelection(m), i.$setFocusCellForSelection(m, !0);
1608
- else {
1609
- const e = function(e) {
1610
- const t = $getAdjacentChildCaret(e);
1611
- return $isChildCaret(t) ? $normalizeCaret(t) : e;
1612
- }($getSiblingCaret(f, c.direction));
1613
- $setPointFromCaret(o.anchor, e), $setPointFromCaret(o.focus, e);
1614
- }
1615
- return Tn(t), !0;
1616
- }
1617
- function xn(e, t, o, r, l, s) {
1618
- if (("up" === o || "down" === o) && function(e) {
1619
- const t = e.getRootElement();
1620
- if (!t) return !1;
1621
- return t.hasAttribute("aria-controls") && "typeahead-menu" === t.getAttribute("aria-controls");
1622
- }(e)) return !1;
1623
- const i = $getSelection();
1624
- if (!_n(i, r)) {
1625
- if ($isRangeSelection(i)) {
1626
- if ("backward" === o) {
1627
- if (i.focus.offset > 0) return !1;
1628
- const e = function(e) {
1629
- for (let t = e, n = e; null !== n; t = n, n = n.getParent()) if ($isElementNode(n)) {
1630
- if (n !== t && n.getFirstChild() !== t) return null;
1631
- if (!n.isInline()) return n;
1632
- }
1633
- return null;
1634
- }(i.focus.getNode());
1635
- if (!e) return !1;
1636
- const n = e.getPreviousSibling();
1637
- return !!Bn(n) && (Tn(t), t.shiftKey ? i.focus.set(n.getParentOrThrow().getKey(), n.getIndexWithinParent(), "element") : n.selectEnd(), !0);
1638
- }
1639
- if (t.shiftKey && ("up" === o || "down" === o)) {
1640
- const e = i.focus.getNode();
1641
- if (!i.isCollapsed() && ("up" === o && !i.isBackward() || "down" === o && i.isBackward())) {
1642
- let l = $findMatchingParent(e, (e) => Bn(e));
1643
- if (Ge(l) && (l = $findMatchingParent(l, Bn)), l !== r) return !1;
1644
- if (!l) return !1;
1645
- const s = "down" === o ? l.getNextSibling() : l.getPreviousSibling();
1646
- if (!s) return !1;
1647
- let c = 0;
1648
- "up" === o && $isElementNode(s) && (c = s.getChildrenSize());
1649
- let a = s;
1650
- if ("up" === o && $isElementNode(s)) a = s.getLastChild() || s, c = $isTextNode(a) ? a.getTextContentSize() : 0;
1651
- const u = i.clone();
1652
- return u.focus.set(a.getKey(), c, $isTextNode(a) ? "text" : "element"), $setSelection(u), Tn(t), !0;
1653
- }
1654
- if ($isRootOrShadowRoot(e)) {
1655
- const e = "up" === o ? i.getNodes()[i.getNodes().length - 1] : i.getNodes()[0];
1656
- if (e) {
1657
- if (null !== Qt(r, e)) {
1658
- const e = r.getFirstDescendant(), t = r.getLastDescendant();
1659
- if (!e || !t) return !1;
1660
- const [n] = Mt(e), [o] = Mt(t), s = r.getCordsFromCellNode(n, l.table), i = r.getCordsFromCellNode(o, l.table), c = r.getDOMCellFromCordsOrThrow(s.x, s.y, l.table), a = r.getDOMCellFromCordsOrThrow(i.x, i.y, l.table);
1661
- return l.$setAnchorCellForSelection(c), l.$setFocusCellForSelection(a, !0), !0;
1662
- }
1663
- }
1664
- return !1;
1665
- }
1666
- {
1667
- let r = $findMatchingParent(e, (e) => $isElementNode(e) && !e.isInline());
1668
- if (Ge(r) && (r = $findMatchingParent(r, Bn)), !r) return !1;
1669
- const s = "down" === o ? r.getNextSibling() : r.getPreviousSibling();
1670
- if (Bn(s) && l.tableNodeKey === s.getKey()) {
1671
- const e = s.getFirstDescendant(), n = s.getLastDescendant();
1672
- if (!e || !n) return !1;
1673
- const [r] = Mt(e), [l] = Mt(n), c = i.clone();
1674
- return c.focus.set(("up" === o ? r : l).getKey(), "up" === o ? 0 : l.getChildrenSize(), "element"), Tn(t), $setSelection(c), !0;
1675
- }
1676
- }
1677
- }
1678
- }
1679
- return "down" === o && Mn(e) && s.setShouldCheckSelectionForTable(r.getKey()), !1;
1680
- }
1681
- if ($isRangeSelection(i)) {
1682
- if ("backward" === o || "forward" === o) return vn(e, t, i, t.shiftKey ? "extend" : "move", "backward" === o, r, l);
1683
- if (i.isCollapsed()) {
1684
- const { anchor: c, focus: a } = i, u = $findMatchingParent(c.getNode(), Ge), h = $findMatchingParent(a.getNode(), Ge);
1685
- if (!Ge(u) || !u.is(h)) return !1;
1686
- const d = Nn(u);
1687
- if (d !== r && null != d) {
1688
- const n = Vt(d, e.getElementByKey(d.getKey()));
1689
- if (null != n) return l.table = un(d, n), xn(e, t, o, d, l, s);
1690
- }
1691
- const f = e.getElementByKey(u.__key), g = e.getElementByKey(c.key);
1692
- if (null == g || null == f) return !1;
1693
- let m;
1694
- if ("element" === c.type) m = g.getBoundingClientRect();
1695
- else {
1696
- const t = getDOMSelection(Gt(e));
1697
- if (null === t || 0 === t.rangeCount) return !1;
1698
- m = t.getRangeAt(0).getBoundingClientRect();
1699
- }
1700
- const p = "up" === o ? u.getFirstChild() : u.getLastChild();
1701
- if (null == p) return !1;
1702
- const C = e.getElementByKey(p.__key);
1703
- if (null == C) return !1;
1704
- const _ = C.getBoundingClientRect();
1705
- if ("up" === o ? _.top > m.top - m.height : m.bottom + m.height > _.bottom) {
1706
- Tn(t);
1707
- const e = r.getCordsFromCellNode(u, l.table);
1708
- if (!t.shiftKey) return fn(l, r, e.x, e.y, o);
1709
- {
1710
- const t = r.getDOMCellFromCordsOrThrow(e.x, e.y, l.table);
1711
- l.$setAnchorCellForSelection(t), l.$setFocusCellForSelection(t, !0);
1712
- }
1713
- return !0;
1714
- }
1715
- }
1716
- } else if (Pt(i)) {
1717
- const { anchor: s, focus: c, tableKey: a } = i;
1718
- if (a !== r.getKey()) return !1;
1719
- const u = $findMatchingParent(s.getNode(), Ge), h = $findMatchingParent(c.getNode(), Ge), [d] = i.getNodes();
1720
- Bn(d) || Ze(251);
1721
- const f = Vt(d, e.getElementByKey(d.getKey()));
1722
- if (!Ge(u) || !Ge(h) || !Bn(d) || null == f) return !1;
1723
- l.$updateTableTableSelection(i);
1724
- const g = un(d, f), m = r.getCordsFromCellNode(u, g), p = r.getDOMCellFromCordsOrThrow(m.x, m.y, g);
1725
- if (l.$setAnchorCellForSelection(p), Tn(t), t.shiftKey) {
1726
- const [e, t, n] = Et(r, u, h);
1727
- return Cn(l, e, t, n, o);
1728
- }
1729
- return h.selectEnd(), !0;
1730
- }
1731
- return !1;
1732
- }
1733
- function Tn(e) {
1734
- e.preventDefault(), e.stopImmediatePropagation(), e.stopPropagation();
1735
- }
1736
- function Fn(e, t, n) {
1737
- const o = $createParagraphNode();
1738
- "first" === e ? t.insertBefore(o) : t.insertAfter(o), o.append(...n || []), o.selectEnd();
1739
- }
1740
- function Rn(e, t, o) {
1741
- const r = o.getParent();
1742
- if (!r) return;
1743
- const l = getDOMSelection(Gt(e));
1744
- if (!l) return;
1745
- const s = l.anchorNode, i = e.getElementByKey(r.getKey()), c = Vt(o, e.getElementByKey(o.getKey()));
1746
- if (!s || !i || !c || !i.contains(s) || c.contains(s)) return;
1747
- const a = $findMatchingParent(t.anchor.getNode(), (e) => Ge(e));
1748
- if (!a) return;
1749
- const u = $findMatchingParent(a, (e) => Bn(e));
1750
- if (!Bn(u) || !u.is(o)) return;
1751
- const [h, d] = Et(o, a, a), f = h[0][0], g = h[h.length - 1][h[0].length - 1], { startRow: m, startColumn: p } = d, C = m === f.startRow && p === f.startColumn, _ = m === g.startRow && p === g.startColumn;
1752
- return C ? "first" : _ ? "last" : void 0;
1753
- }
1754
- function On(e, t) {
1755
- const { tableNode: n } = e.$lookup(), o = n.getCordsFromCellNode(t, e.table);
1756
- return n.getDOMCellFromCordsOrThrow(o.x, o.y, e.table);
1757
- }
1758
- function An(e, t, n) {
1759
- return Qt(e, $getNearestNodeFromDOMNode(t, n));
1760
- }
1761
- function Kn(e, t, n) {
1762
- const o = e.querySelector("colgroup");
1763
- if (!o) return;
1764
- const r = [];
1765
- for (let e = 0; e < t; e++) {
1766
- const t = document.createElement("col"), o = n && n[e];
1767
- o && (t.style.width = `${o}px`), r.push(t);
1768
- }
1769
- o.replaceChildren(...r);
1770
- }
1771
- function En(t, n, r) {
1772
- if (!n.theme.tableAlignment) return;
1773
- const l = [], s = [];
1774
- for (const e of ["center", "right"]) {
1775
- const t = n.theme.tableAlignment[e];
1776
- t && (e === r ? s : l).push(t);
1777
- }
1778
- removeClassNamesFromElement(t, ...l), addClassNamesToElement(t, ...s);
1779
- }
1780
- const kn = /* @__PURE__ */ new WeakSet();
1781
- function Mn(e = $getEditor()) {
1782
- return kn.has(e);
1783
- }
1784
- function $n(e, t) {
1785
- t ? kn.add(e) : kn.delete(e);
1786
- }
1787
- var Wn = class Wn extends ElementNode {
1788
- __rowStriping;
1789
- __frozenColumnCount;
1790
- __frozenRowCount;
1791
- __colWidths;
1792
- static getType() {
1793
- return "table";
1794
- }
1795
- getColWidths() {
1796
- return this.getLatest().__colWidths;
1797
- }
1798
- setColWidths(e) {
1799
- const t = this.getWritable();
1800
- return t.__colWidths = e, t;
1801
- }
1802
- static clone(e) {
1803
- return new Wn(e.__key);
1804
- }
1805
- afterCloneFrom(e) {
1806
- super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping, this.__frozenColumnCount = e.__frozenColumnCount, this.__frozenRowCount = e.__frozenRowCount;
1807
- }
1808
- static importDOM() {
1809
- return { table: (e) => ({
1810
- conversion: Ln,
1811
- priority: 1
1812
- }) };
1813
- }
1814
- static importJSON(e) {
1815
- return Hn().updateFromJSON(e);
1816
- }
1817
- updateFromJSON(e) {
1818
- return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setFrozenColumns(e.frozenColumnCount || 0).setFrozenRows(e.frozenRowCount || 0).setColWidths(e.colWidths);
1819
- }
1820
- constructor(e) {
1821
- super(e), this.__rowStriping = !1, this.__frozenColumnCount = 0, this.__frozenRowCount = 0, this.__colWidths = void 0;
1822
- }
1823
- exportJSON() {
1824
- return {
1825
- ...super.exportJSON(),
1826
- colWidths: this.getColWidths(),
1827
- frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : void 0,
1828
- frozenRowCount: this.__frozenRowCount ? this.__frozenRowCount : void 0,
1829
- rowStriping: this.__rowStriping ? this.__rowStriping : void 0
1830
- };
1831
- }
1832
- extractWithChild(e, t, n) {
1833
- return "html" === n;
1834
- }
1835
- getDOMSlot(e) {
1836
- const t = jt(e) ? e : e.querySelector("table");
1837
- return jt(t) || Ze(229), super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"));
1838
- }
1839
- createDOM(t, n) {
1840
- const o = document.createElement("table");
1841
- this.__style && setDOMStyleFromCSS(o.style, this.__style);
1842
- const r = document.createElement("colgroup");
1843
- if (o.appendChild(r), setDOMUnmanaged(r), addClassNamesToElement(o, t.theme.table), this.updateTableElement(null, o, t), Mn(n)) {
1844
- const n = document.createElement("div"), r = t.theme.tableScrollableWrapper;
1845
- return r ? addClassNamesToElement(n, r) : n.style.overflowX = "auto", n.appendChild(o), this.updateTableWrapper(null, n, o, t), n;
1846
- }
1847
- return o;
1848
- }
1849
- updateTableWrapper(t, n, r, l) {
1850
- this.__frozenColumnCount !== (t ? t.__frozenColumnCount : 0) && function(t, n, r, l) {
1851
- l > 0 ? (addClassNamesToElement(t, r.theme.tableFrozenColumn), n.setAttribute("data-lexical-frozen-column", "true")) : (removeClassNamesFromElement(t, r.theme.tableFrozenColumn), n.removeAttribute("data-lexical-frozen-column"));
1852
- }(n, r, l, this.__frozenColumnCount), this.__frozenRowCount !== (t ? t.__frozenRowCount : 0) && function(t, n, r, l) {
1853
- l > 0 ? (addClassNamesToElement(t, r.theme.tableFrozenRow), n.setAttribute("data-lexical-frozen-row", "true")) : (removeClassNamesFromElement(t, r.theme.tableFrozenRow), n.removeAttribute("data-lexical-frozen-row"));
1854
- }(n, r, l, this.__frozenRowCount);
1855
- }
1856
- updateTableElement(t, n, r) {
1857
- this.__style !== (t ? t.__style : "") && setDOMStyleFromCSS(n.style, this.__style, t ? t.__style : ""), this.__rowStriping !== (!!t && t.__rowStriping) && function(t, n, r) {
1858
- r ? (addClassNamesToElement(t, n.theme.tableRowStriping), t.setAttribute("data-lexical-row-striping", "true")) : (removeClassNamesFromElement(t, n.theme.tableRowStriping), t.removeAttribute("data-lexical-row-striping"));
1859
- }(n, r, this.__rowStriping);
1860
- const l = t ? t.getColumnCount() : 0, s = t ? t.__colWidths : void 0;
1861
- this.getColumnCount() === l && this.getColWidths() === s || Kn(n, this.getColumnCount(), this.getColWidths()), En(n, r, this.getFormatType());
1862
- }
1863
- updateDOM(e, t, n) {
1864
- const o = Vt(this, t);
1865
- return t === o === Mn() || (isHTMLElement$1(r = t) && "DIV" === r.nodeName && this.updateTableWrapper(e, t, o, n), this.updateTableElement(e, o, n), !1);
1866
- var r;
1867
- }
1868
- scaleDOMColWidths(e, t) {
1869
- const n = this.getColWidths();
1870
- if (!n) return;
1871
- Kn(Vt(this, e), this.getColumnCount(), n.map((e) => e * t));
1872
- }
1873
- exportDOM(e) {
1874
- const t = super.exportDOM(e), { element: n } = t;
1875
- return {
1876
- after: (n) => {
1877
- if (t.after && (n = t.after(n)), !jt(n) && isHTMLElement$1(n) && (n = n.querySelector("table")), !jt(n)) return null;
1878
- En(n, e._config, this.getFormatType());
1879
- const [o] = kt(this, null, null), r = /* @__PURE__ */ new Map();
1880
- for (const e of o) for (const t of e) {
1881
- const e = t.cell.getKey();
1882
- r.has(e) || r.set(e, {
1883
- colSpan: t.cell.getColSpan(),
1884
- startColumn: t.startColumn
1885
- });
1886
- }
1887
- const s = /* @__PURE__ */ new Set();
1888
- for (const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
1889
- const t = e.getAttribute("data-temporary-table-cell-lexical-key");
1890
- if (t) {
1891
- const n = r.get(t);
1892
- if (e.removeAttribute("data-temporary-table-cell-lexical-key"), n) {
1893
- r.delete(t);
1894
- for (let e = 0; e < n.colSpan; e++) s.add(e + n.startColumn);
1895
- }
1896
- }
1897
- }
1898
- const i = n.querySelector(":scope > colgroup");
1899
- if (i) {
1900
- const e = Array.from(n.querySelectorAll(":scope > colgroup > col")).filter((e, t) => s.has(t));
1901
- i.replaceChildren(...e);
1902
- }
1903
- const c = n.querySelectorAll(":scope > tr");
1904
- if (c.length > 0) {
1905
- const e = document.createElement("tbody");
1906
- for (const t of c) e.appendChild(t);
1907
- n.append(e);
1908
- }
1909
- return n;
1910
- },
1911
- element: !jt(n) && isHTMLElement$1(n) ? n.querySelector("table") : n
1912
- };
1913
- }
1914
- canBeEmpty() {
1915
- return !1;
1916
- }
1917
- isShadowRoot() {
1918
- return !0;
1919
- }
1920
- getCordsFromCellNode(e, t) {
1921
- const { rows: n, domRows: o } = t;
1922
- for (let t = 0; t < n; t++) {
1923
- const n = o[t];
1924
- if (null != n) for (let o = 0; o < n.length; o++) {
1925
- const r = n[o];
1926
- if (null == r) continue;
1927
- const { elem: l } = r, s = An(this, l);
1928
- if (null !== s && e.is(s)) return {
1929
- x: o,
1930
- y: t
1931
- };
1932
- }
1933
- }
1934
- throw new Error("Cell not found in table.");
1935
- }
1936
- getDOMCellFromCords(e, t, n) {
1937
- const { domRows: o } = n, r = o[t];
1938
- if (null == r) return null;
1939
- const l = r[e < r.length ? e : r.length - 1];
1940
- return null == l ? null : l;
1941
- }
1942
- getDOMCellFromCordsOrThrow(e, t, n) {
1943
- const o = this.getDOMCellFromCords(e, t, n);
1944
- if (!o) throw new Error("Cell not found at cords.");
1945
- return o;
1946
- }
1947
- getCellNodeFromCords(e, t, n) {
1948
- const o = this.getDOMCellFromCords(e, t, n);
1949
- if (null == o) return null;
1950
- const r = $getNearestNodeFromDOMNode(o.elem);
1951
- return Ge(r) ? r : null;
1952
- }
1953
- getCellNodeFromCordsOrThrow(e, t, n) {
1954
- const o = this.getCellNodeFromCords(e, t, n);
1955
- if (!o) throw new Error("Node at cords not TableCellNode.");
1956
- return o;
1957
- }
1958
- getRowStriping() {
1959
- return Boolean(this.getLatest().__rowStriping);
1960
- }
1961
- setRowStriping(e) {
1962
- const t = this.getWritable();
1963
- return t.__rowStriping = e, t;
1964
- }
1965
- setFrozenColumns(e) {
1966
- const t = this.getWritable();
1967
- return t.__frozenColumnCount = e, t;
1968
- }
1969
- getFrozenColumns() {
1970
- return this.getLatest().__frozenColumnCount;
1971
- }
1972
- setFrozenRows(e) {
1973
- const t = this.getWritable();
1974
- return t.__frozenRowCount = e, t;
1975
- }
1976
- getFrozenRows() {
1977
- return this.getLatest().__frozenRowCount;
1978
- }
1979
- canSelectBefore() {
1980
- return !0;
1981
- }
1982
- canIndent() {
1983
- return !1;
1984
- }
1985
- getColumnCount() {
1986
- const e = this.getFirstChild();
1987
- if (!e) return 0;
1988
- let t = 0;
1989
- return e.getChildren().forEach((e) => {
1990
- Ge(e) && (t += e.getColSpan());
1991
- }), t;
1992
- }
1993
- };
1994
- function zn(e, t) {
1995
- const n = e.getElementByKey(t.getKey());
1996
- return null === n && Ze(230), un(t, n);
1997
- }
1998
- function Ln(e) {
1999
- const n = Hn();
2000
- e.hasAttribute("data-lexical-row-striping") && n.setRowStriping(!0), e.hasAttribute("data-lexical-frozen-column") && n.setFrozenColumns(1), e.hasAttribute("data-lexical-frozen-row") && n.setFrozenRows(1);
2001
- const o = e.querySelector(":scope > colgroup");
2002
- if (o) {
2003
- let e = [];
2004
- for (const t of o.querySelectorAll(":scope > col")) {
2005
- let n = t.style.width || "";
2006
- if (!Je.test(n) && (n = t.getAttribute("width") || "", !/^\d+$/.test(n))) {
2007
- e = void 0;
2008
- break;
2009
- }
2010
- e.push(parseFloat(n));
2011
- }
2012
- e && n.setColWidths(e);
2013
- }
2014
- return {
2015
- after: (e) => $descendantsMatching(e, ot),
2016
- node: n
2017
- };
2018
- }
2019
- function Hn() {
2020
- return $applyNodeReplacement(new Wn());
2021
- }
2022
- function Bn(e) {
2023
- return e instanceof Wn;
2024
- }
2025
- function Pn(e) {
2026
- ot(e.getParent()) ? e.isEmpty() && e.append($createParagraphNode()) : e.remove();
2027
- }
2028
- function Dn(e) {
2029
- Bn(e.getParent()) ? $unwrapAndFilterDescendants(e, Ge) : e.remove();
2030
- }
2031
- function In(e) {
2032
- $unwrapAndFilterDescendants(e, ot);
2033
- const [t] = kt(e, null, null), n = t.reduce((e, t) => Math.max(e, t.length), 0), o = e.getChildren();
2034
- for (let e = 0; e < t.length; ++e) {
2035
- const r = o[e];
2036
- if (!r) continue;
2037
- ot(r) || Ze(254, r.constructor.name, r.getType());
2038
- const l = t[e].reduce((e, t) => t ? 1 + e : e, 0);
2039
- if (l !== n) for (let e = l; e < n; ++e) {
2040
- const e = Ve();
2041
- e.append($createParagraphNode()), r.append(e);
2042
- }
2043
- }
2044
- const r = e.getColWidths(), l = e.getColumnCount();
2045
- if (r && r.length !== l) {
2046
- let t;
2047
- if (l < r.length) t = r.slice(0, l);
2048
- else if (r.length > 0) {
2049
- const e = r[r.length - 1];
2050
- t = [...r, ...Array(l - r.length).fill(e)];
2051
- }
2052
- e.setColWidths(t);
2053
- }
2054
- }
2055
- function Un(e) {
2056
- if (e.detail < 3 || !isDOMNode(e.target)) return !1;
2057
- const t = $getNearestNodeFromDOMNode(e.target);
2058
- if (null === t) return !1;
2059
- const o = $findMatchingParent(t, (e) => $isElementNode(e) && !e.isInline());
2060
- if (null === o) return !1;
2061
- return !!Ge(o.getParent()) && (o.select(0), !0);
2062
- }
2063
- function Jn() {
2064
- const e = $getSelection();
2065
- if (!$isRangeSelection(e)) return !1;
2066
- const t = Nn(e.anchor.getNode());
2067
- if (null === t) return !1;
2068
- const n = $getRoot();
2069
- if (!n.is(t.getParent()) || 1 !== n.getChildrenSize()) return !1;
2070
- const [o] = kt(t, null, null);
2071
- if (0 === o.length || 0 === o[0].length) return !1;
2072
- const r = o[0][0];
2073
- if (!r || !r.cell) return !1;
2074
- const l = o[o.length - 1], s = l[l.length - 1];
2075
- if (!s || !s.cell) return !1;
2076
- return $setSelection(It(t, r.cell, s.cell)), !0;
2077
- }
2078
- function Xn(e) {
2079
- return e.registerNodeTransform(Ye, (e) => {
2080
- if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
2081
- const [, , t] = Mt(e), [n] = Et(t, e, e), o = n.length, r = n[0].length;
2082
- let l = t.getFirstChild();
2083
- ot(l) || Ze(175);
2084
- const i = [];
2085
- for (let e = 0; e < o; e++) {
2086
- 0 !== e && (l = l.getNextSibling(), ot(l) || Ze(175));
2087
- let t = null;
2088
- for (let o = 0; o < r; o++) {
2089
- const r = n[e][o], c = r.cell;
2090
- if (r.startRow === e && r.startColumn === o) t = c, i.push(c);
2091
- else if (c.getColSpan() > 1 || c.getRowSpan() > 1) {
2092
- Ge(c) || Ze(176);
2093
- const e = Ve(c.__headerState);
2094
- null !== t ? t.insertAfter(e) : $insertFirst(l, e);
2095
- }
2096
- }
2097
- }
2098
- for (const e of i) e.setColSpan(1), e.setRowSpan(1);
2099
- }
2100
- });
2101
- }
2102
- function Yn(e, t = !0) {
2103
- const n = new Xt(), o = (o, r, l) => {
2104
- const s = Vt(o, l), i = on(o, s, e, t, n);
2105
- n.observers.set(r, [i, s]);
2106
- };
2107
- return mergeRegister(nn(e, n), e.registerCommand(SELECTION_CHANGE_COMMAND, () => rn(n, e), COMMAND_PRIORITY_HIGH), e.registerMutationListener(Wn, (t) => {
2108
- e.getEditorState().read(() => {
2109
- for (const [e, r] of t) {
2110
- const t = n.observers.get(e);
2111
- if ("created" === r || "updated" === r) {
2112
- const { tableNode: r, tableElement: l } = Jt(e);
2113
- void 0 === t ? o(r, e, l) : l !== t[1] && (t[0].removeListeners(), n.observers.delete(e), o(r, e, l));
2114
- } else "destroyed" === r && void 0 !== t && (t[0].removeListeners(), n.observers.delete(e));
2115
- }
2116
- }, { editor: e });
2117
- }, { skipInitialization: !1 }), () => {
2118
- for (const [, [e]] of n.observers) e.removeListeners();
2119
- });
2120
- }
2121
- function qn(e, t) {
2122
- e.hasNodes([Wn]) || Ze(255);
2123
- const { hasNestedTables: o = signal(!1) } = t ?? {};
2124
- return mergeRegister(e.registerCommand(Qe, (e) => function({ rows: e, columns: t, includeHeaders: n }, o) {
2125
- const r = $getSelection() || $getPreviousSelection();
2126
- if (!r || !$isRangeSelection(r)) return !1;
2127
- if (!o && Nn(r.anchor.getNode())) return !1;
2128
- const l = rt(Number(e), Number(t), n);
2129
- $insertNodeToNearestRoot(l);
2130
- const s = l.getFirstDescendant();
2131
- return $isTextNode(s) && s.select(), !0;
2132
- }(e, o.peek()), COMMAND_PRIORITY_EDITOR), e.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, (t, r) => e === r && function(e, t) {
2133
- const { nodes: o, selection: r } = e;
2134
- if (!o.some((e) => Bn(e) || $dfs(e).some((e) => Bn(e.node)))) return !1;
2135
- const l = Pt(r), s = $isRangeSelection(r);
2136
- if (!(s && null !== $findMatchingParent(r.anchor.getNode(), (e) => Ge(e)) && null !== $findMatchingParent(r.focus.getNode(), (e) => Ge(e)) || l)) return !1;
2137
- if (1 === o.length && Bn(o[0])) return function(e, t) {
2138
- const o = t.getStartEndPoints(), r = Pt(t);
2139
- if (null === o) return !1;
2140
- const [l, s] = o, [i, c, a] = Mt(l), u = $findMatchingParent(s.getNode(), (e) => Ge(e));
2141
- if (!(Ge(i) && Ge(u) && ot(c) && Bn(a))) return !1;
2142
- const [h, d, f] = Et(a, i, u), [m] = kt(e, null, null), C = h.length, _ = C > 0 ? h[0].length : 0;
2143
- let S = d.startRow, b = d.startColumn, w = m.length, y = w > 0 ? m[0].length : 0;
2144
- if (r) {
2145
- const e = $t(h, d, f), t = e.maxRow - e.minRow + 1, n = e.maxColumn - e.minColumn + 1;
2146
- S = e.minRow, b = e.minColumn, w = Math.min(w, t), y = Math.min(y, n);
2147
- }
2148
- let N = !1;
2149
- const v = Math.min(C, S + w) - 1, x = Math.min(_, b + y) - 1, T = /* @__PURE__ */ new Set();
2150
- for (let e = S; e <= v; e++) for (let t = b; t <= x; t++) {
2151
- const n = h[e][t];
2152
- T.has(n.cell.getKey()) || 1 === n.cell.__rowSpan && 1 === n.cell.__colSpan || (Kt(n.cell), T.add(n.cell.getKey()), N = !0);
2153
- }
2154
- let [F] = kt(a.getWritable(), null, null);
2155
- const R = w - C + S;
2156
- for (let e = 0; e < R; e++) pt(F[C - 1][0].cell);
2157
- const O = y - _ + b;
2158
- for (let e = 0; e < O; e++) bt(F[0][_ - 1].cell, !0, !1);
2159
- [F] = kt(a.getWritable(), null, null);
2160
- for (let e = S; e < S + w; e++) for (let t = b; t < b + y; t++) {
2161
- const n = e - S, o = t - b, r = m[n][o];
2162
- if (r.startRow !== n || r.startColumn !== o) continue;
2163
- const l = r.cell;
2164
- if (1 !== l.__rowSpan || 1 !== l.__colSpan) {
2165
- const n = [], o = Math.min(e + l.__rowSpan, S + w) - 1, r = Math.min(t + l.__colSpan, b + y) - 1;
2166
- for (let l = e; l <= o; l++) for (let e = t; e <= r; e++) {
2167
- const t = F[l][e];
2168
- n.push(t.cell);
2169
- }
2170
- Rt(n), N = !0;
2171
- }
2172
- const { cell: s } = F[e][t], i = l.getBackgroundColor();
2173
- null != i && s.setBackgroundColor(i);
2174
- const c = s.getChildren();
2175
- l.getChildren().forEach((e) => {
2176
- if ($isTextNode(e)) $createParagraphNode().append(e), s.append(e);
2177
- else s.append(e);
2178
- }), c.forEach((e) => e.remove());
2179
- }
2180
- if (r && N) {
2181
- const [e] = kt(a.getWritable(), null, null);
2182
- e[d.startRow][d.startColumn].cell.selectEnd();
2183
- }
2184
- return !0;
2185
- }(o[0], r);
2186
- if (s && t.peek() && !function(e) {
2187
- if (Pt(e) && !e.focus.getNode().is(e.anchor.getNode())) return !0;
2188
- if ($isRangeSelection(e) && Ge(e.anchor.getNode()) && !e.anchor.getNode().is(e.focus.getNode())) return !0;
2189
- return !1;
2190
- }(r)) return !1;
2191
- return !0;
2192
- }(t, o), COMMAND_PRIORITY_EDITOR), e.registerCommand(SELECT_ALL_COMMAND, Jn, COMMAND_PRIORITY_LOW), e.registerCommand(CLICK_COMMAND, Un, COMMAND_PRIORITY_EDITOR), e.registerNodeTransform(Wn, In), e.registerNodeTransform(et, Dn), e.registerNodeTransform(Ye, Pn));
2193
- }
2194
- const jn = defineExtension({
2195
- build: (e, t, n) => namedSignals(t),
2196
- config: safeCast({
2197
- hasCellBackgroundColor: !0,
2198
- hasCellMerge: !0,
2199
- hasHorizontalScroll: !0,
2200
- hasNestedTables: !1,
2201
- hasTabHandler: !0
2202
- }),
2203
- name: "@lexical/table/Table",
2204
- nodes: () => [
2205
- Wn,
2206
- et,
2207
- Ye
2208
- ],
2209
- register(e, t, n) {
2210
- const o = n.getOutput();
2211
- return mergeRegister(effect(() => {
2212
- const t = o.hasHorizontalScroll.value;
2213
- Mn(e) !== t && ($n(e, t), e.update($fullReconcile));
2214
- }), qn(e, o), effect(() => Yn(e, o.hasTabHandler.value)), effect(() => o.hasCellMerge.value ? void 0 : Xn(e)), effect(() => o.hasCellBackgroundColor.value ? void 0 : e.registerNodeTransform(Ye, (e) => {
2215
- null !== e.getBackgroundColor() && e.setBackgroundColor(null);
2216
- })));
2217
- }
2218
- });
2219
- function Vn(e) {
2220
- const t = [];
2221
- let n = null;
2222
- const o = () => {
2223
- if (null !== n) {
2224
- const e = n.getFirstChild();
2225
- $isLineBreakNode(e) && 1 === n.getChildrenSize() && e.remove();
2226
- }
2227
- };
2228
- for (const r of e) $isInlineElementOrDecoratorNode(r) || $isTextNode(r) || $isLineBreakNode(r) ? null !== n ? n.append(r) : (n = $createParagraphNode().append(r), t.push(n)) : (o(), t.push(r), n = null);
2229
- return o(), 0 === t.length && t.push($createParagraphNode()), t;
2230
- }
2231
- const Gn = {
2232
- $accepts: ot,
2233
- $packageRun: (e) => e.every(Ge) ? [nt().splice(0, 0, e)] : [],
2234
- name: "TableSchema"
2235
- }, Qn = {
2236
- $accepts: Ge,
2237
- name: "TableRowSchema"
2238
- }, Zn = [
2239
- defineImportRule({
2240
- $import: (e, n) => {
2241
- const o = Hn();
2242
- n.hasAttribute("data-lexical-row-striping") && o.setRowStriping(!0), n.hasAttribute("data-lexical-frozen-column") && o.setFrozenColumns(1), n.hasAttribute("data-lexical-frozen-row") && o.setFrozenRows(1);
2243
- const r = n.querySelector(":scope > colgroup");
2244
- if (r) {
2245
- let e = [];
2246
- for (const t of r.querySelectorAll(":scope > col")) {
2247
- let n = t.style.width || "";
2248
- if (!Je.test(n) && (n = t.getAttribute("width") || "", !/^\d+$/.test(n))) {
2249
- e = void 0;
2250
- break;
2251
- }
2252
- e.push(parseFloat(n));
2253
- }
2254
- e && o.setColWidths(e);
2255
- }
2256
- return [o.splice(0, 0, $descendantsMatching(e.$importChildren(n), ot))];
2257
- },
2258
- match: sel.tag("table"),
2259
- name: "@lexical/table/table"
2260
- }),
2261
- defineImportRule({
2262
- $import: (e, n) => [nt(Je.test(n.style.height) ? parseFloat(n.style.height) : void 0).splice(0, 0, $descendantsMatching(e.$importChildren(n), Ge))],
2263
- match: sel.tag("tr"),
2264
- name: "@lexical/table/tr"
2265
- }),
2266
- defineImportRule({
2267
- $import: (e, t) => {
2268
- const n = "TH" === t.nodeName, o = Je.test(t.style.width) ? parseFloat(t.style.width) : void 0;
2269
- let r = Xe.NO_STATUS;
2270
- if (n) {
2271
- const e = t.getAttribute("scope");
2272
- if ("col" === e) r = Xe.COLUMN;
2273
- else if ("row" === e) r = Xe.ROW;
2274
- else {
2275
- const e = t.parentElement, n = isHTMLTableRowElement(e) && (e.parentElement && "THEAD" === e.parentElement.nodeName || 0 === e.rowIndex), o = 0 === t.cellIndex;
2276
- n && (r |= Xe.ROW), o && (r |= Xe.COLUMN), r === Xe.NO_STATUS && (r = Xe.ROW);
2277
- }
2278
- }
2279
- const l = Ve(r, t.colSpan, o);
2280
- l.__rowSpan = t.rowSpan;
2281
- const s = t.style.backgroundColor;
2282
- "" !== s && (l.__backgroundColor = s);
2283
- const i = t.style.verticalAlign;
2284
- (function(e) {
2285
- return "middle" === e || "bottom" === e;
2286
- })(i) && (l.__verticalAlign = i);
2287
- const c = e.get(ImportTextFormat), a = c | function(e) {
2288
- let t = 0;
2289
- const n = e.fontWeight;
2290
- "700" !== n && "bold" !== n || (t |= IS_BOLD), "italic" === e.fontStyle && (t |= IS_ITALIC);
2291
- const o = (e.textDecoration || "").split(" ");
2292
- return o.includes("underline") && (t |= IS_UNDERLINE), o.includes("line-through") && (t |= IS_STRIKETHROUGH), t;
2293
- }(t.style), u = e.get(ImportTextStyle), h = t.style.color, d = h ? {
2294
- ...u,
2295
- color: h
2296
- } : u, f = [];
2297
- return a !== c && f.push(contextValue(ImportTextFormat, a)), d !== u && f.push(contextValue(ImportTextStyle, d)), [l.splice(0, 0, Vn(e.$importChildren(t, { context: f })))];
2298
- },
2299
- match: sel.tag("td", "th"),
2300
- name: "@lexical/table/cell"
2301
- })
2302
- ], eo = defineExtension({
2303
- dependencies: [
2304
- CoreImportExtension,
2305
- jn,
2306
- configExtension(DOMImportExtension, { rules: Zn })
2307
- ],
2308
- name: "@lexical/table/Import"
2309
- });
2310
- //#endregion
2311
- export { Et as $computeTableMap, kt as $computeTableMapSkipCellCheck, Ve as $createTableCellNode, Hn as $createTableNode, rt as $createTableNodeWithDimensions, nt as $createTableRowNode, Dt as $createTableSelection, It as $createTableSelectionFrom, wt as $deleteTableColumn, vt as $deleteTableColumnAtSelection, xt as $deleteTableColumn__EXPERIMENTAL, yt as $deleteTableRowAtSelection, Nt as $deleteTableRow__EXPERIMENTAL, yn as $findCellNode, Nn as $findTableNode, zn as $getElementForTableNode, Mt as $getNodeTriplet, Jt as $getTableAndElementByKey, lt as $getTableCellNodeFromLexicalNode, Lt as $getTableCellNodeRect, at as $getTableColumnIndexFromTableCellNode, it as $getTableNodeFromLexicalNodeOrThrow, ct as $getTableRowIndexFromTableCellNode, st as $getTableRowNodeFromTableCellNodeOrThrow, Ct as $insertTableColumn, _t as $insertTableColumnAtSelection, St as $insertTableColumn__EXPERIMENTAL, dt as $insertTableRow, gt as $insertTableRowAtSelection, mt as $insertTableRow__EXPERIMENTAL, Mn as $isScrollableTablesActive, Wt as $isSimpleTable, Ge as $isTableCellNode, Bn as $isTableNode, ot as $isTableRowNode, Pt as $isTableSelection, Rt as $mergeCells, zt as $moveTableColumn, ht as $removeTableRowAtIndex, At as $unmergeCell, Qe as INSERT_TABLE_COMMAND, Xe as TableCellHeaderStates, Ye as TableCellNode, jn as TableExtension, eo as TableImportExtension, Zn as TableImportRules, Wn as TableNode, Yt as TableObserver, et as TableRowNode, Qn as TableRowSchema, Gn as TableSchema, on as applyTableHandlers, cn as getDOMCellFromTarget, Vt as getTableElement, sn as getTableObserverFromTableElement, Xn as registerTableCellUnmergeTransform, qn as registerTablePlugin, Yn as registerTableSelectionObserver, $n as setScrollableTablesActive };