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