@uva-glass/component-library 1.62.12 → 1.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LexicalClipboard.prod-C6LsK5E6.js +311 -0
- package/dist/LexicalClipboard.prod-C6LsK5E6.js.map +1 -0
- package/dist/LexicalTable.prod-DqzrJuYr.js +1221 -0
- package/dist/LexicalTable.prod-DqzrJuYr.js.map +1 -0
- package/dist/{LexicalUtils.prod-DlLRWqta.js → LexicalUtils.prod-BTFNWAMw.js} +33 -42
- package/dist/{LexicalUtils.prod-DlLRWqta.js.map → LexicalUtils.prod-BTFNWAMw.js.map} +1 -1
- package/dist/{TablePlugin-B3ZkyOU_.js → TablePlugin-BLzR0g93.js} +58 -55
- package/dist/{TablePlugin-B3ZkyOU_.js.map → TablePlugin-BLzR0g93.js.map} +1 -1
- package/dist/assets/AccordionCard.css +1 -0
- package/dist/components/AccordionCard/AccordionCard.d.ts +10 -0
- package/dist/components/AccordionCard/AccordionCard.js +58 -0
- package/dist/components/AccordionCard/AccordionCard.js.map +1 -0
- package/dist/components/AccordionCard/AccordionCard.stories.d.ts +5 -0
- package/dist/components/AccordionCard/AccordionCard.stories.js +33 -0
- package/dist/components/AccordionCard/AccordionCard.stories.js.map +1 -0
- package/dist/components/AccordionCard/index.d.ts +1 -0
- package/dist/components/AccordionCard/index.js +5 -0
- package/dist/components/AccordionCard/index.js.map +1 -0
- package/dist/components/CheckboxTree/CheckboxTree.js +24 -20
- package/dist/components/CheckboxTree/CheckboxTree.js.map +1 -1
- package/dist/components/FormInput/FormInput.js +15 -11
- package/dist/components/FormInput/FormInput.js.map +1 -1
- package/dist/components/InputField/InputField.stories.js +16 -12
- package/dist/components/InputField/InputField.stories.js.map +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 +6 -2
- package/dist/components/MultiSelect/components/MultiSelectHeader.js.map +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/PeriodSelector/PeriodSelector.js +22 -18
- package/dist/components/PeriodSelector/PeriodSelector.js.map +1 -1
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +20 -16
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js.map +1 -1
- package/dist/components/RteEditor/EditorHeader/EditorHeader.js +7 -3
- package/dist/components/RteEditor/EditorHeader/EditorHeader.js.map +1 -1
- package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +16 -16
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +19 -16
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +7 -3
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js.map +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +100 -98
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +36 -36
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +31 -0
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js.map +1 -0
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/index.d.ts +1 -0
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/index.js +5 -0
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/index.js.map +1 -0
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +6 -2
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js.map +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +7 -4
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js.map +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +12 -12
- package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +36 -36
- package/dist/components/RteEditor/Plugins/index.js +1 -1
- package/dist/components/RteEditor/RteEditor.js +361 -358
- package/dist/components/RteEditor/RteEditor.js.map +1 -1
- package/dist/components/RteEditor/helpers.js +27 -27
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +98 -96
- package/dist/components/index.js.map +1 -1
- package/dist/helpers-B-pdj8pq.js +168 -0
- package/dist/{helpers-CC9_diXm.js.map → helpers-B-pdj8pq.js.map} +1 -1
- package/dist/index.js +98 -96
- package/dist/index.js.map +1 -1
- package/package.json +13 -16
- package/dist/Lexical.prod-DOTdxgeo.js +0 -4072
- package/dist/Lexical.prod-DOTdxgeo.js.map +0 -1
- package/dist/LexicalLink.prod-Cqa5Im8X.js +0 -208
- package/dist/LexicalLink.prod-Cqa5Im8X.js.map +0 -1
- package/dist/LexicalList.prod-DlqzsJTH.js +0 -564
- package/dist/LexicalList.prod-DlqzsJTH.js.map +0 -1
- package/dist/LexicalTable.prod-BKz2StgB.js +0 -1525
- package/dist/LexicalTable.prod-BKz2StgB.js.map +0 -1
- package/dist/helpers-CC9_diXm.js +0 -168
|
@@ -0,0 +1,1221 @@
|
|
|
1
|
+
import { $ as ie, t as y, U as Ye, i as Qe } from "./LexicalUtils.prod-BTFNWAMw.js";
|
|
2
|
+
import { createCommand as et, ElementNode as we, $createParagraphNode as ee, $isElementNode as D, $isLineBreakNode as tt, $isTextNode as de, $applyNodeReplacement as be, $createTextNode as ye, isHTMLElement as nt, $getNearestNodeFromDOMNode as z, $getSelection as k, KEY_ARROW_DOWN_COMMAND as ot, COMMAND_PRIORITY_HIGH as V, KEY_ARROW_UP_COMMAND as rt, KEY_ARROW_LEFT_COMMAND as st, KEY_ARROW_RIGHT_COMMAND as lt, KEY_ESCAPE_COMMAND as it, DELETE_WORD_COMMAND as at, DELETE_LINE_COMMAND as Ke, DELETE_CHARACTER_COMMAND as ct, $isRangeSelection as P, COMMAND_PRIORITY_CRITICAL as B, KEY_BACKSPACE_COMMAND as ut, KEY_DELETE_COMMAND as ht, CUT_COMMAND as dt, FORMAT_TEXT_COMMAND as gt, FORMAT_ELEMENT_COMMAND as ft, CONTROLLED_TEXT_INSERTION_COMMAND as mt, KEY_TAB_COMMAND as pt, FOCUS_COMMAND as Ct, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as _t, SELECTION_CHANGE_COMMAND as ne, $getPreviousSelection as St, $setSelection as j, $createRangeSelectionFromDom as wt, INSERT_PARAGRAPH_COMMAND as bt, $isRootOrShadowRoot as yt, $isDecoratorNode as Nt, $getNodeByKey as se, $createRangeSelection as Tt, $isParagraphNode as Ue, $getRoot as Et, TEXT_TYPE_TO_FORMAT as Ot, $normalizeSelection__EXPERIMENTAL as Mt, isCurrentlyReadOnlyMode as xt, $createPoint as Fe } from "lexical";
|
|
3
|
+
import { O as vt, b as Rt } from "./LexicalClipboard.prod-C6LsK5E6.js";
|
|
4
|
+
const Ne = /^(\d+(?:\.\d+)?)px$/, W = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
|
|
5
|
+
class ae extends we {
|
|
6
|
+
static getType() {
|
|
7
|
+
return "tablecell";
|
|
8
|
+
}
|
|
9
|
+
static clone(e) {
|
|
10
|
+
return new ae(e.__headerState, e.__colSpan, e.__width, e.__key);
|
|
11
|
+
}
|
|
12
|
+
afterCloneFrom(e) {
|
|
13
|
+
super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor;
|
|
14
|
+
}
|
|
15
|
+
static importDOM() {
|
|
16
|
+
return { td: (e) => ({ conversion: Ae, priority: 0 }), th: (e) => ({ conversion: Ae, priority: 0 }) };
|
|
17
|
+
}
|
|
18
|
+
static importJSON(e) {
|
|
19
|
+
const t = e.colSpan || 1, n = e.rowSpan || 1;
|
|
20
|
+
return Te(e.headerState, t, e.width || void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor || null);
|
|
21
|
+
}
|
|
22
|
+
constructor(e = W.NO_STATUS, t = 1, n, s) {
|
|
23
|
+
super(s), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = n, this.__backgroundColor = null;
|
|
24
|
+
}
|
|
25
|
+
createDOM(e) {
|
|
26
|
+
const t = document.createElement(this.getTag());
|
|
27
|
+
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(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
|
|
28
|
+
}
|
|
29
|
+
exportDOM(e) {
|
|
30
|
+
const { element: t } = super.exportDOM(e);
|
|
31
|
+
if (t) {
|
|
32
|
+
const n = t;
|
|
33
|
+
n.style.border = "1px solid black", this.__colSpan > 1 && (n.colSpan = this.__colSpan), this.__rowSpan > 1 && (n.rowSpan = this.__rowSpan), n.style.width = `${this.getWidth() || 75}px`, n.style.verticalAlign = "top", n.style.textAlign = "start";
|
|
34
|
+
const s = this.getBackgroundColor();
|
|
35
|
+
s !== null ? n.style.backgroundColor = s : this.hasHeader() && (n.style.backgroundColor = "#f2f3f5");
|
|
36
|
+
}
|
|
37
|
+
return { element: t };
|
|
38
|
+
}
|
|
39
|
+
exportJSON() {
|
|
40
|
+
return { ...super.exportJSON(), backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, type: "tablecell", width: this.getWidth() };
|
|
41
|
+
}
|
|
42
|
+
getColSpan() {
|
|
43
|
+
return this.getLatest().__colSpan;
|
|
44
|
+
}
|
|
45
|
+
setColSpan(e) {
|
|
46
|
+
const t = this.getWritable();
|
|
47
|
+
return t.__colSpan = e, t;
|
|
48
|
+
}
|
|
49
|
+
getRowSpan() {
|
|
50
|
+
return this.getLatest().__rowSpan;
|
|
51
|
+
}
|
|
52
|
+
setRowSpan(e) {
|
|
53
|
+
const t = this.getWritable();
|
|
54
|
+
return t.__rowSpan = e, t;
|
|
55
|
+
}
|
|
56
|
+
getTag() {
|
|
57
|
+
return this.hasHeader() ? "th" : "td";
|
|
58
|
+
}
|
|
59
|
+
setHeaderStyles(e, t = W.BOTH) {
|
|
60
|
+
const n = this.getWritable();
|
|
61
|
+
return n.__headerState = e & t | n.__headerState & ~t, n;
|
|
62
|
+
}
|
|
63
|
+
getHeaderStyles() {
|
|
64
|
+
return this.getLatest().__headerState;
|
|
65
|
+
}
|
|
66
|
+
setWidth(e) {
|
|
67
|
+
const t = this.getWritable();
|
|
68
|
+
return t.__width = e, t;
|
|
69
|
+
}
|
|
70
|
+
getWidth() {
|
|
71
|
+
return this.getLatest().__width;
|
|
72
|
+
}
|
|
73
|
+
getBackgroundColor() {
|
|
74
|
+
return this.getLatest().__backgroundColor;
|
|
75
|
+
}
|
|
76
|
+
setBackgroundColor(e) {
|
|
77
|
+
const t = this.getWritable();
|
|
78
|
+
return t.__backgroundColor = e, t;
|
|
79
|
+
}
|
|
80
|
+
toggleHeaderStyle(e) {
|
|
81
|
+
const t = this.getWritable();
|
|
82
|
+
return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
|
|
83
|
+
}
|
|
84
|
+
hasHeaderState(e) {
|
|
85
|
+
return (this.getHeaderStyles() & e) === e;
|
|
86
|
+
}
|
|
87
|
+
hasHeader() {
|
|
88
|
+
return this.getLatest().__headerState !== W.NO_STATUS;
|
|
89
|
+
}
|
|
90
|
+
updateDOM(e) {
|
|
91
|
+
return e.__headerState !== this.__headerState || e.__width !== this.__width || e.__colSpan !== this.__colSpan || e.__rowSpan !== this.__rowSpan || e.__backgroundColor !== this.__backgroundColor;
|
|
92
|
+
}
|
|
93
|
+
isShadowRoot() {
|
|
94
|
+
return !0;
|
|
95
|
+
}
|
|
96
|
+
collapseAtStart() {
|
|
97
|
+
return !0;
|
|
98
|
+
}
|
|
99
|
+
canBeEmpty() {
|
|
100
|
+
return !1;
|
|
101
|
+
}
|
|
102
|
+
canIndent() {
|
|
103
|
+
return !1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function Ae(r) {
|
|
107
|
+
const e = r, t = r.nodeName.toLowerCase();
|
|
108
|
+
let n;
|
|
109
|
+
Ne.test(e.style.width) && (n = parseFloat(e.style.width));
|
|
110
|
+
const s = Te(t === "th" ? W.ROW : W.NO_STATUS, e.colSpan, n);
|
|
111
|
+
s.__rowSpan = e.rowSpan;
|
|
112
|
+
const o = e.style.backgroundColor;
|
|
113
|
+
o !== "" && (s.__backgroundColor = o);
|
|
114
|
+
const c = e.style, u = (c && c.textDecoration || "").split(" "), h = c.fontWeight === "700" || c.fontWeight === "bold", g = u.includes("line-through"), l = c.fontStyle === "italic", i = u.includes("underline");
|
|
115
|
+
return { after: (a) => (a.length === 0 && a.push(ee()), a), forChild: (a, d) => {
|
|
116
|
+
if (f(d) && !D(a)) {
|
|
117
|
+
const S = ee();
|
|
118
|
+
return tt(a) && a.getTextContent() === `
|
|
119
|
+
` ? null : (de(a) && (h && a.toggleFormat("bold"), g && a.toggleFormat("strikethrough"), l && a.toggleFormat("italic"), i && a.toggleFormat("underline")), S.append(a), S);
|
|
120
|
+
}
|
|
121
|
+
return a;
|
|
122
|
+
}, node: s };
|
|
123
|
+
}
|
|
124
|
+
function Te(r, e = 1, t) {
|
|
125
|
+
return be(new ae(r, e, t));
|
|
126
|
+
}
|
|
127
|
+
function f(r) {
|
|
128
|
+
return r instanceof ae;
|
|
129
|
+
}
|
|
130
|
+
const Yt = et("INSERT_TABLE_COMMAND");
|
|
131
|
+
function Kt(r) {
|
|
132
|
+
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
133
|
+
}
|
|
134
|
+
var T = Kt(function(r) {
|
|
135
|
+
const e = new URLSearchParams();
|
|
136
|
+
e.append("code", r);
|
|
137
|
+
for (let t = 1; t < arguments.length; t++) e.append("v", arguments[t]);
|
|
138
|
+
throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
|
|
139
|
+
});
|
|
140
|
+
const Ft = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
|
|
141
|
+
class ge extends we {
|
|
142
|
+
static getType() {
|
|
143
|
+
return "tablerow";
|
|
144
|
+
}
|
|
145
|
+
static clone(e) {
|
|
146
|
+
return new ge(e.__height, e.__key);
|
|
147
|
+
}
|
|
148
|
+
static importDOM() {
|
|
149
|
+
return { tr: (e) => ({ conversion: At, priority: 0 }) };
|
|
150
|
+
}
|
|
151
|
+
static importJSON(e) {
|
|
152
|
+
return Ee(e.height);
|
|
153
|
+
}
|
|
154
|
+
constructor(e, t) {
|
|
155
|
+
super(t), this.__height = e;
|
|
156
|
+
}
|
|
157
|
+
exportJSON() {
|
|
158
|
+
return { ...super.exportJSON(), ...this.getHeight() && { height: this.getHeight() }, type: "tablerow", version: 1 };
|
|
159
|
+
}
|
|
160
|
+
createDOM(e) {
|
|
161
|
+
const t = document.createElement("tr");
|
|
162
|
+
return this.__height && (t.style.height = `${this.__height}px`), ie(t, e.theme.tableRow), t;
|
|
163
|
+
}
|
|
164
|
+
isShadowRoot() {
|
|
165
|
+
return !0;
|
|
166
|
+
}
|
|
167
|
+
setHeight(e) {
|
|
168
|
+
return this.getWritable().__height = e, this.__height;
|
|
169
|
+
}
|
|
170
|
+
getHeight() {
|
|
171
|
+
return this.getLatest().__height;
|
|
172
|
+
}
|
|
173
|
+
updateDOM(e) {
|
|
174
|
+
return e.__height !== this.__height;
|
|
175
|
+
}
|
|
176
|
+
canBeEmpty() {
|
|
177
|
+
return !1;
|
|
178
|
+
}
|
|
179
|
+
canIndent() {
|
|
180
|
+
return !1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function At(r) {
|
|
184
|
+
const e = r;
|
|
185
|
+
let t;
|
|
186
|
+
return Ne.test(e.style.height) && (t = parseFloat(e.style.height)), { node: Ee(t) };
|
|
187
|
+
}
|
|
188
|
+
function Ee(r) {
|
|
189
|
+
return be(new ge(r));
|
|
190
|
+
}
|
|
191
|
+
function I(r) {
|
|
192
|
+
return r instanceof ge;
|
|
193
|
+
}
|
|
194
|
+
function Ut(r, e, t = !0) {
|
|
195
|
+
const n = Me();
|
|
196
|
+
for (let s = 0; s < r; s++) {
|
|
197
|
+
const o = Ee();
|
|
198
|
+
for (let c = 0; c < e; c++) {
|
|
199
|
+
let u = W.NO_STATUS;
|
|
200
|
+
typeof t == "object" ? (s === 0 && t.rows && (u |= W.ROW), c === 0 && t.columns && (u |= W.COLUMN)) : t && (s === 0 && (u |= W.ROW), c === 0 && (u |= W.COLUMN));
|
|
201
|
+
const h = Te(u), g = ee();
|
|
202
|
+
g.append(ye()), h.append(g), o.append(h);
|
|
203
|
+
}
|
|
204
|
+
n.append(o);
|
|
205
|
+
}
|
|
206
|
+
return n;
|
|
207
|
+
}
|
|
208
|
+
function zt(r) {
|
|
209
|
+
const e = y(r, (t) => f(t));
|
|
210
|
+
return f(e) ? e : null;
|
|
211
|
+
}
|
|
212
|
+
function ze(r) {
|
|
213
|
+
const e = y(r, (t) => I(t));
|
|
214
|
+
if (I(e)) return e;
|
|
215
|
+
throw new Error("Expected table cell to be inside of table row.");
|
|
216
|
+
}
|
|
217
|
+
function Dt(r) {
|
|
218
|
+
const e = y(r, (t) => O(t));
|
|
219
|
+
if (O(e)) return e;
|
|
220
|
+
throw new Error("Expected table cell to be inside of table.");
|
|
221
|
+
}
|
|
222
|
+
function Xt(r) {
|
|
223
|
+
const e = ze(r);
|
|
224
|
+
return Dt(e).getChildren().findIndex((t) => t.is(e));
|
|
225
|
+
}
|
|
226
|
+
function Jt(r) {
|
|
227
|
+
return ze(r).getChildren().findIndex((e) => e.is(r));
|
|
228
|
+
}
|
|
229
|
+
function jt(r, e) {
|
|
230
|
+
const t = r.getChildren();
|
|
231
|
+
for (let n = 0; n < t.length; n++) {
|
|
232
|
+
const s = t[n];
|
|
233
|
+
if (I(s)) {
|
|
234
|
+
const o = s.getChildren();
|
|
235
|
+
if (e >= o.length || e < 0) throw new Error("Table column target index out of range");
|
|
236
|
+
o[e].remove();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return r;
|
|
240
|
+
}
|
|
241
|
+
function Q(r, e, t) {
|
|
242
|
+
const [n, s, o] = kt(r, e, t);
|
|
243
|
+
return s === null && T(207), o === null && T(208), [n, s, o];
|
|
244
|
+
}
|
|
245
|
+
function kt(r, e, t) {
|
|
246
|
+
const n = [];
|
|
247
|
+
let s = null, o = null;
|
|
248
|
+
function c(h) {
|
|
249
|
+
let g = n[h];
|
|
250
|
+
return g === void 0 && (n[h] = g = []), g;
|
|
251
|
+
}
|
|
252
|
+
const u = r.getChildren();
|
|
253
|
+
for (let h = 0; h < u.length; h++) {
|
|
254
|
+
const g = u[h];
|
|
255
|
+
I(g) || T(209);
|
|
256
|
+
for (let l = g.getFirstChild(), i = 0; l != null; l = l.getNextSibling()) {
|
|
257
|
+
f(l) || T(147);
|
|
258
|
+
const a = c(h);
|
|
259
|
+
for (; a[i] !== void 0; ) i++;
|
|
260
|
+
const d = { cell: l, startColumn: i, startRow: h }, { __rowSpan: S, __colSpan: w } = l;
|
|
261
|
+
for (let C = 0; C < S && !(h + C >= u.length); C++) {
|
|
262
|
+
const m = c(h + C);
|
|
263
|
+
for (let N = 0; N < w; N++) m[i + N] = d;
|
|
264
|
+
}
|
|
265
|
+
e !== null && s === null && e.is(l) && (s = d), t !== null && o === null && t.is(l) && (o = d);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return [n, s, o];
|
|
269
|
+
}
|
|
270
|
+
function oe(r) {
|
|
271
|
+
let e;
|
|
272
|
+
if (r instanceof ae) e = r;
|
|
273
|
+
else if ("__type" in r) {
|
|
274
|
+
const s = y(r, f);
|
|
275
|
+
f(s) || T(148), e = s;
|
|
276
|
+
} else {
|
|
277
|
+
const s = y(r.getNode(), f);
|
|
278
|
+
f(s) || T(148), e = s;
|
|
279
|
+
}
|
|
280
|
+
const t = e.getParent();
|
|
281
|
+
I(t) || T(149);
|
|
282
|
+
const n = t.getParent();
|
|
283
|
+
return O(n) || T(210), [e, t, n];
|
|
284
|
+
}
|
|
285
|
+
function De(r) {
|
|
286
|
+
const [e, , t] = oe(r), n = t.getChildren(), s = n.length, o = n[0].getChildren().length, c = new Array(s);
|
|
287
|
+
for (let u = 0; u < s; u++) c[u] = new Array(o);
|
|
288
|
+
for (let u = 0; u < s; u++) {
|
|
289
|
+
const h = n[u].getChildren();
|
|
290
|
+
let g = 0;
|
|
291
|
+
for (let l = 0; l < h.length; l++) {
|
|
292
|
+
for (; c[u][g]; ) g++;
|
|
293
|
+
const i = h[l], a = i.__rowSpan || 1, d = i.__colSpan || 1;
|
|
294
|
+
for (let S = 0; S < a; S++) for (let w = 0; w < d; w++) c[u + S][g + w] = i;
|
|
295
|
+
if (e === i) return { colSpan: d, columnIndex: g, rowIndex: u, rowSpan: a };
|
|
296
|
+
g += d;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
class fe {
|
|
302
|
+
constructor(e, t, n) {
|
|
303
|
+
this.anchor = t, this.focus = n, t._selection = this, n._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
|
|
304
|
+
}
|
|
305
|
+
getStartEndPoints() {
|
|
306
|
+
return [this.anchor, this.focus];
|
|
307
|
+
}
|
|
308
|
+
isBackward() {
|
|
309
|
+
return this.focus.isBefore(this.anchor);
|
|
310
|
+
}
|
|
311
|
+
getCachedNodes() {
|
|
312
|
+
return this._cachedNodes;
|
|
313
|
+
}
|
|
314
|
+
setCachedNodes(e) {
|
|
315
|
+
this._cachedNodes = e;
|
|
316
|
+
}
|
|
317
|
+
is(e) {
|
|
318
|
+
return !!v(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
|
|
319
|
+
}
|
|
320
|
+
set(e, t, n) {
|
|
321
|
+
this.dirty = !0, this.tableKey = e, this.anchor.key = t, this.focus.key = n, this._cachedNodes = null;
|
|
322
|
+
}
|
|
323
|
+
clone() {
|
|
324
|
+
return new fe(this.tableKey, this.anchor, this.focus);
|
|
325
|
+
}
|
|
326
|
+
isCollapsed() {
|
|
327
|
+
return !1;
|
|
328
|
+
}
|
|
329
|
+
extract() {
|
|
330
|
+
return this.getNodes();
|
|
331
|
+
}
|
|
332
|
+
insertRawText(e) {
|
|
333
|
+
}
|
|
334
|
+
insertText() {
|
|
335
|
+
}
|
|
336
|
+
hasFormat(e) {
|
|
337
|
+
let t = 0;
|
|
338
|
+
this.getNodes().filter(f).forEach((s) => {
|
|
339
|
+
const o = s.getFirstChild();
|
|
340
|
+
Ue(o) && (t |= o.getTextFormat());
|
|
341
|
+
});
|
|
342
|
+
const n = Ot[e];
|
|
343
|
+
return !!(t & n);
|
|
344
|
+
}
|
|
345
|
+
insertNodes(e) {
|
|
346
|
+
const t = this.focus.getNode();
|
|
347
|
+
D(t) || T(151), Mt(t.select(0, t.getChildrenSize())).insertNodes(e);
|
|
348
|
+
}
|
|
349
|
+
getShape() {
|
|
350
|
+
const e = se(this.anchor.key);
|
|
351
|
+
f(e) || T(152);
|
|
352
|
+
const t = De(e);
|
|
353
|
+
t === null && T(153);
|
|
354
|
+
const n = se(this.focus.key);
|
|
355
|
+
f(n) || T(154);
|
|
356
|
+
const s = De(n);
|
|
357
|
+
s === null && T(155);
|
|
358
|
+
const o = Math.min(t.columnIndex, s.columnIndex), c = Math.max(t.columnIndex + t.colSpan - 1, s.columnIndex + s.colSpan - 1), u = Math.min(t.rowIndex, s.rowIndex), h = Math.max(t.rowIndex + t.rowSpan - 1, s.rowIndex + s.rowSpan - 1);
|
|
359
|
+
return { fromX: Math.min(o, c), fromY: Math.min(u, h), toX: Math.max(o, c), toY: Math.max(u, h) };
|
|
360
|
+
}
|
|
361
|
+
getNodes() {
|
|
362
|
+
const e = this._cachedNodes;
|
|
363
|
+
if (e !== null) return e;
|
|
364
|
+
const t = this.anchor.getNode(), n = this.focus.getNode(), s = y(t, f), o = y(n, f);
|
|
365
|
+
f(s) || T(152), f(o) || T(154);
|
|
366
|
+
const c = s.getParent();
|
|
367
|
+
I(c) || T(156);
|
|
368
|
+
const u = c.getParent();
|
|
369
|
+
O(u) || T(157);
|
|
370
|
+
const h = o.getParents()[1];
|
|
371
|
+
if (h !== u) {
|
|
372
|
+
if (u.isParentOf(o)) {
|
|
373
|
+
const _ = h.getParent();
|
|
374
|
+
_ == null && T(159), this.set(this.tableKey, o.getKey(), _.getKey());
|
|
375
|
+
} else {
|
|
376
|
+
const _ = u.getParent();
|
|
377
|
+
_ == null && T(158), this.set(this.tableKey, _.getKey(), o.getKey());
|
|
378
|
+
}
|
|
379
|
+
return this.getNodes();
|
|
380
|
+
}
|
|
381
|
+
const [g, l, i] = Q(u, s, o);
|
|
382
|
+
let a = Math.min(l.startColumn, i.startColumn), d = Math.min(l.startRow, i.startRow), S = Math.max(l.startColumn + l.cell.__colSpan - 1, i.startColumn + i.cell.__colSpan - 1), w = Math.max(l.startRow + l.cell.__rowSpan - 1, i.startRow + i.cell.__rowSpan - 1), C = a, m = d, N = a, M = d;
|
|
383
|
+
function R(_) {
|
|
384
|
+
const { cell: b, startColumn: p, startRow: A } = _;
|
|
385
|
+
a = Math.min(a, p), d = Math.min(d, A), S = Math.max(S, p + b.__colSpan - 1), w = Math.max(w, A + b.__rowSpan - 1);
|
|
386
|
+
}
|
|
387
|
+
for (; a < C || d < m || S > N || w > M; ) {
|
|
388
|
+
if (a < C) {
|
|
389
|
+
const _ = M - m, b = C - 1;
|
|
390
|
+
for (let p = 0; p <= _; p++) R(g[m + p][b]);
|
|
391
|
+
C = b;
|
|
392
|
+
}
|
|
393
|
+
if (d < m) {
|
|
394
|
+
const _ = N - C, b = m - 1;
|
|
395
|
+
for (let p = 0; p <= _; p++) R(g[b][C + p]);
|
|
396
|
+
m = b;
|
|
397
|
+
}
|
|
398
|
+
if (S > N) {
|
|
399
|
+
const _ = M - m, b = N + 1;
|
|
400
|
+
for (let p = 0; p <= _; p++) R(g[m + p][b]);
|
|
401
|
+
N = b;
|
|
402
|
+
}
|
|
403
|
+
if (w > M) {
|
|
404
|
+
const _ = N - C, b = M + 1;
|
|
405
|
+
for (let p = 0; p <= _; p++) R(g[b][C + p]);
|
|
406
|
+
M = b;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const K = /* @__PURE__ */ new Map([[u.getKey(), u]]);
|
|
410
|
+
let E = null;
|
|
411
|
+
for (let _ = d; _ <= w; _++) for (let b = a; b <= S; b++) {
|
|
412
|
+
const { cell: p } = g[_][b], A = p.getParent();
|
|
413
|
+
I(A) || T(160), A !== E && K.set(A.getKey(), A), K.set(p.getKey(), p);
|
|
414
|
+
for (const L of Pt(p)) K.set(L.getKey(), L);
|
|
415
|
+
E = A;
|
|
416
|
+
}
|
|
417
|
+
const x = Array.from(K.values());
|
|
418
|
+
return xt() || (this._cachedNodes = x), x;
|
|
419
|
+
}
|
|
420
|
+
getTextContent() {
|
|
421
|
+
const e = this.getNodes().filter((n) => f(n));
|
|
422
|
+
let t = "";
|
|
423
|
+
for (let n = 0; n < e.length; n++) {
|
|
424
|
+
const s = e[n], o = s.__parent, c = (e[n + 1] || {}).__parent;
|
|
425
|
+
t += s.getTextContent() + (c !== o ? `
|
|
426
|
+
` : " ");
|
|
427
|
+
}
|
|
428
|
+
return t;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function v(r) {
|
|
432
|
+
return r instanceof fe;
|
|
433
|
+
}
|
|
434
|
+
function ke() {
|
|
435
|
+
const r = Fe("root", 0, "element"), e = Fe("root", 0, "element");
|
|
436
|
+
return new fe("root", r, e);
|
|
437
|
+
}
|
|
438
|
+
function Pt(r) {
|
|
439
|
+
const e = [], t = [r];
|
|
440
|
+
for (; t.length > 0; ) {
|
|
441
|
+
const n = t.pop();
|
|
442
|
+
n === void 0 && T(112), D(n) && t.unshift(...n.getChildren()), n !== r && e.push(n);
|
|
443
|
+
}
|
|
444
|
+
return e;
|
|
445
|
+
}
|
|
446
|
+
class Lt {
|
|
447
|
+
constructor(e, t) {
|
|
448
|
+
this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = t, this.editor = e, this.table = { columns: 0, domRows: [], rows: 0 }, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.trackTable(), this.isSelecting = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal };
|
|
449
|
+
}
|
|
450
|
+
getTable() {
|
|
451
|
+
return this.table;
|
|
452
|
+
}
|
|
453
|
+
removeListeners() {
|
|
454
|
+
this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
|
|
455
|
+
}
|
|
456
|
+
trackTable() {
|
|
457
|
+
const e = new MutationObserver((t) => {
|
|
458
|
+
this.editor.update(() => {
|
|
459
|
+
let n = !1;
|
|
460
|
+
for (let o = 0; o < t.length; o++) {
|
|
461
|
+
const c = t[o].target.nodeName;
|
|
462
|
+
if (c === "TABLE" || c === "TBODY" || c === "THEAD" || c === "TR") {
|
|
463
|
+
n = !0;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (!n) return;
|
|
468
|
+
const s = this.editor.getElementByKey(this.tableNodeKey);
|
|
469
|
+
if (!s) throw new Error("Expected to find TableElement in DOM");
|
|
470
|
+
this.table = le(s);
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
this.editor.update(() => {
|
|
474
|
+
const t = this.editor.getElementByKey(this.tableNodeKey);
|
|
475
|
+
if (!t) throw new Error("Expected to find TableElement in DOM");
|
|
476
|
+
this.table = le(t), e.observe(t, { attributes: !0, childList: !0, subtree: !0 });
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
clearHighlight() {
|
|
480
|
+
const e = this.editor;
|
|
481
|
+
this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.enableHighlightStyle(), e.update(() => {
|
|
482
|
+
if (!O(se(this.tableNodeKey))) throw new Error("Expected TableNode.");
|
|
483
|
+
const t = e.getElementByKey(this.tableNodeKey);
|
|
484
|
+
if (!t) throw new Error("Expected to find TableElement in DOM");
|
|
485
|
+
const n = le(t);
|
|
486
|
+
ue(e, n, null), j(null), e.dispatchCommand(ne, void 0);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
enableHighlightStyle() {
|
|
490
|
+
const e = this.editor;
|
|
491
|
+
e.update(() => {
|
|
492
|
+
const t = e.getElementByKey(this.tableNodeKey);
|
|
493
|
+
if (!t) throw new Error("Expected to find TableElement in DOM");
|
|
494
|
+
Ye(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
disableHighlightStyle() {
|
|
498
|
+
const e = this.editor;
|
|
499
|
+
e.update(() => {
|
|
500
|
+
const t = e.getElementByKey(this.tableNodeKey);
|
|
501
|
+
if (!t) throw new Error("Expected to find TableElement in DOM");
|
|
502
|
+
ie(t, e._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
updateTableTableSelection(e) {
|
|
506
|
+
if (e !== null && e.tableKey === this.tableNodeKey) {
|
|
507
|
+
const t = this.editor;
|
|
508
|
+
this.tableSelection = e, this.isHighlightingCells = !0, this.disableHighlightStyle(), ue(t, this.table, this.tableSelection);
|
|
509
|
+
} else e == null ? this.clearHighlight() : (this.tableNodeKey = e.tableKey, this.updateTableTableSelection(e));
|
|
510
|
+
}
|
|
511
|
+
setFocusCellForSelection(e, t = !1) {
|
|
512
|
+
const n = this.editor;
|
|
513
|
+
n.update(() => {
|
|
514
|
+
const s = se(this.tableNodeKey);
|
|
515
|
+
if (!O(s)) throw new Error("Expected TableNode.");
|
|
516
|
+
if (!n.getElementByKey(this.tableNodeKey)) throw new Error("Expected to find TableElement in DOM");
|
|
517
|
+
const o = e.x, c = e.y;
|
|
518
|
+
if (this.focusCell = e, this.anchorCell !== null) {
|
|
519
|
+
const u = Xe(n._window);
|
|
520
|
+
u && u.setBaseAndExtent(this.anchorCell.elem, 0, this.focusCell.elem, 0);
|
|
521
|
+
}
|
|
522
|
+
if (this.isHighlightingCells || this.anchorX === o && this.anchorY === c && !t) {
|
|
523
|
+
if (o === this.focusX && c === this.focusY) return;
|
|
524
|
+
} else this.isHighlightingCells = !0, this.disableHighlightStyle();
|
|
525
|
+
if (this.focusX = o, this.focusY = c, this.isHighlightingCells) {
|
|
526
|
+
const u = z(e.elem);
|
|
527
|
+
if (this.tableSelection != null && this.anchorCellNodeKey != null && f(u) && s.is(Z(u))) {
|
|
528
|
+
const h = u.getKey();
|
|
529
|
+
this.tableSelection = this.tableSelection.clone() || ke(), this.focusCellNodeKey = h, this.tableSelection.set(this.tableNodeKey, this.anchorCellNodeKey, this.focusCellNodeKey), j(this.tableSelection), n.dispatchCommand(ne, void 0), ue(n, this.table, this.tableSelection);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
setAnchorCellForSelection(e) {
|
|
535
|
+
this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y, this.editor.update(() => {
|
|
536
|
+
const t = z(e.elem);
|
|
537
|
+
if (f(t)) {
|
|
538
|
+
const n = t.getKey();
|
|
539
|
+
this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : ke(), this.anchorCellNodeKey = n;
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
formatCells(e) {
|
|
544
|
+
this.editor.update(() => {
|
|
545
|
+
const t = k();
|
|
546
|
+
v(t) || T(11);
|
|
547
|
+
const n = Tt(), s = n.anchor, o = n.focus, c = t.getNodes().filter(f), u = c[0].getFirstChild(), h = Ue(u) ? u.getFormatFlags(e, null) : null;
|
|
548
|
+
c.forEach((g) => {
|
|
549
|
+
s.set(g.getKey(), 0, "element"), o.set(g.getKey(), g.getChildrenSize(), "element"), n.formatText(e, h);
|
|
550
|
+
}), j(t), this.editor.dispatchCommand(ne, void 0);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
clearText() {
|
|
554
|
+
const e = this.editor;
|
|
555
|
+
e.update(() => {
|
|
556
|
+
const t = se(this.tableNodeKey);
|
|
557
|
+
if (!O(t)) throw new Error("Expected TableNode.");
|
|
558
|
+
const n = k();
|
|
559
|
+
v(n) || T(11);
|
|
560
|
+
const s = n.getNodes().filter(f);
|
|
561
|
+
s.length !== this.table.columns * this.table.rows ? (s.forEach((o) => {
|
|
562
|
+
if (D(o)) {
|
|
563
|
+
const c = ee(), u = ye();
|
|
564
|
+
c.append(u), o.append(c), o.getChildren().forEach((h) => {
|
|
565
|
+
h !== c && h.remove();
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}), ue(e, this.table, null), j(null), e.dispatchCommand(ne, void 0)) : (t.selectPrevious(), t.remove(), Et().selectStart());
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const Se = "__lexicalTableSelection", Xe = (r) => Ft ? (r || window).getSelection() : null;
|
|
573
|
+
function qt(r, e, t, n) {
|
|
574
|
+
const s = t.getRootElement();
|
|
575
|
+
if (s === null) throw new Error("No root element.");
|
|
576
|
+
const o = new Lt(t, r.getKey()), c = t._window || window;
|
|
577
|
+
(function(l, i) {
|
|
578
|
+
Pe(l) !== null && T(205), l[Se] = i;
|
|
579
|
+
})(e, o), o.listenersToRemove.add(() => function(l, i) {
|
|
580
|
+
Pe(l) === i && delete l[Se];
|
|
581
|
+
}(e, o));
|
|
582
|
+
const u = () => {
|
|
583
|
+
const l = () => {
|
|
584
|
+
o.isSelecting = !1, c.removeEventListener("mouseup", l), c.removeEventListener("mousemove", i);
|
|
585
|
+
}, i = (a) => {
|
|
586
|
+
setTimeout(() => {
|
|
587
|
+
if (1 & ~a.buttons && o.isSelecting) return o.isSelecting = !1, c.removeEventListener("mouseup", l), void c.removeEventListener("mousemove", i);
|
|
588
|
+
const d = Le(a.target);
|
|
589
|
+
d === null || o.anchorX === d.x && o.anchorY === d.y || (a.preventDefault(), o.setFocusCellForSelection(d));
|
|
590
|
+
}, 0);
|
|
591
|
+
};
|
|
592
|
+
return { onMouseMove: i, onMouseUp: l };
|
|
593
|
+
};
|
|
594
|
+
e.addEventListener("mousedown", (l) => {
|
|
595
|
+
setTimeout(() => {
|
|
596
|
+
if (l.button !== 0 || !c) return;
|
|
597
|
+
const i = Le(l.target);
|
|
598
|
+
i !== null && (U(l), o.setAnchorCellForSelection(i));
|
|
599
|
+
const { onMouseUp: a, onMouseMove: d } = u();
|
|
600
|
+
o.isSelecting = !0, c.addEventListener("mouseup", a, o.listenerOptions), c.addEventListener("mousemove", d, o.listenerOptions);
|
|
601
|
+
}, 0);
|
|
602
|
+
}, o.listenerOptions), c.addEventListener("mousedown", (l) => {
|
|
603
|
+
l.button === 0 && t.update(() => {
|
|
604
|
+
const i = k(), a = l.target;
|
|
605
|
+
v(i) && i.tableKey === o.tableNodeKey && s.contains(a) && o.clearHighlight();
|
|
606
|
+
});
|
|
607
|
+
}, o.listenerOptions), o.listenersToRemove.add(t.registerCommand(ot, (l) => re(t, l, "down", r, o), V)), o.listenersToRemove.add(t.registerCommand(rt, (l) => re(t, l, "up", r, o), V)), o.listenersToRemove.add(t.registerCommand(st, (l) => re(t, l, "backward", r, o), V)), o.listenersToRemove.add(t.registerCommand(lt, (l) => re(t, l, "forward", r, o), V)), o.listenersToRemove.add(t.registerCommand(it, (l) => {
|
|
608
|
+
const i = k();
|
|
609
|
+
if (v(i)) {
|
|
610
|
+
const a = y(i.focus.getNode(), f);
|
|
611
|
+
if (f(a)) return U(l), a.selectEnd(), !0;
|
|
612
|
+
}
|
|
613
|
+
return !1;
|
|
614
|
+
}, V)), [at, Ke, ct].forEach((l) => {
|
|
615
|
+
o.listenersToRemove.add(t.registerCommand(l, /* @__PURE__ */ ((i) => () => {
|
|
616
|
+
const a = k();
|
|
617
|
+
if (!q(a, r)) return !1;
|
|
618
|
+
if (v(a)) return o.clearText(), !0;
|
|
619
|
+
if (P(a)) {
|
|
620
|
+
const d = y(a.anchor.getNode(), (R) => f(R));
|
|
621
|
+
if (!f(d)) return !1;
|
|
622
|
+
const S = a.anchor.getNode(), w = a.focus.getNode(), C = r.isParentOf(S), m = r.isParentOf(w);
|
|
623
|
+
if (C && !m || m && !C) return o.clearText(), !0;
|
|
624
|
+
const N = y(a.anchor.getNode(), (R) => D(R)), M = N && y(N, (R) => D(R) && f(R.getParent()));
|
|
625
|
+
if (!D(M) || !D(N)) return !1;
|
|
626
|
+
if (i === Ke && M.getPreviousSibling() === null) return !0;
|
|
627
|
+
}
|
|
628
|
+
return !1;
|
|
629
|
+
})(l), B));
|
|
630
|
+
});
|
|
631
|
+
const h = (l) => {
|
|
632
|
+
const i = k();
|
|
633
|
+
if (!v(i) && !P(i)) return !1;
|
|
634
|
+
const a = r.isParentOf(i.anchor.getNode());
|
|
635
|
+
if (a !== r.isParentOf(i.focus.getNode())) {
|
|
636
|
+
const d = a ? "anchor" : "focus", S = a ? "focus" : "anchor", { key: w, offset: C, type: m } = i[S];
|
|
637
|
+
return r[i[d].isBefore(i[S]) ? "selectPrevious" : "selectNext"]()[S].set(w, C, m), !1;
|
|
638
|
+
}
|
|
639
|
+
return !!v(i) && (l && (l.preventDefault(), l.stopPropagation()), o.clearText(), !0);
|
|
640
|
+
};
|
|
641
|
+
function g(l) {
|
|
642
|
+
const i = r.getCordsFromCellNode(l, o.table);
|
|
643
|
+
return r.getDOMCellFromCordsOrThrow(i.x, i.y, o.table);
|
|
644
|
+
}
|
|
645
|
+
return o.listenersToRemove.add(t.registerCommand(ut, h, B)), o.listenersToRemove.add(t.registerCommand(ht, h, B)), o.listenersToRemove.add(t.registerCommand(dt, (l) => {
|
|
646
|
+
const i = k();
|
|
647
|
+
if (i) {
|
|
648
|
+
if (!v(i) && !P(i)) return !1;
|
|
649
|
+
vt(t, Qe(l, ClipboardEvent) ? l : null, Rt(i));
|
|
650
|
+
const a = h(l);
|
|
651
|
+
return P(i) ? (i.removeText(), !0) : a;
|
|
652
|
+
}
|
|
653
|
+
return !1;
|
|
654
|
+
}, B)), o.listenersToRemove.add(t.registerCommand(gt, (l) => {
|
|
655
|
+
const i = k();
|
|
656
|
+
if (!q(i, r)) return !1;
|
|
657
|
+
if (v(i)) return o.formatCells(l), !0;
|
|
658
|
+
if (P(i)) {
|
|
659
|
+
const a = y(i.anchor.getNode(), (d) => f(d));
|
|
660
|
+
if (!f(a)) return !1;
|
|
661
|
+
}
|
|
662
|
+
return !1;
|
|
663
|
+
}, B)), o.listenersToRemove.add(t.registerCommand(ft, (l) => {
|
|
664
|
+
const i = k();
|
|
665
|
+
if (!v(i) || !q(i, r)) return !1;
|
|
666
|
+
const a = i.anchor.getNode(), d = i.focus.getNode();
|
|
667
|
+
if (!f(a) || !f(d)) return !1;
|
|
668
|
+
const [S, w, C] = Q(r, a, d), m = Math.max(w.startRow, C.startRow), N = Math.max(w.startColumn, C.startColumn), M = Math.min(w.startRow, C.startRow), R = Math.min(w.startColumn, C.startColumn);
|
|
669
|
+
for (let K = M; K <= m; K++) for (let E = R; E <= N; E++) {
|
|
670
|
+
const x = S[K][E].cell;
|
|
671
|
+
x.setFormat(l);
|
|
672
|
+
const _ = x.getChildren();
|
|
673
|
+
for (let b = 0; b < _.length; b++) {
|
|
674
|
+
const p = _[b];
|
|
675
|
+
D(p) && !p.isInline() && p.setFormat(l);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return !0;
|
|
679
|
+
}, B)), o.listenersToRemove.add(t.registerCommand(mt, (l) => {
|
|
680
|
+
const i = k();
|
|
681
|
+
if (!q(i, r)) return !1;
|
|
682
|
+
if (v(i)) return o.clearHighlight(), !1;
|
|
683
|
+
if (P(i)) {
|
|
684
|
+
const a = y(i.anchor.getNode(), (d) => f(d));
|
|
685
|
+
if (!f(a)) return !1;
|
|
686
|
+
if (typeof l == "string") {
|
|
687
|
+
const d = Ie(t, i, r);
|
|
688
|
+
if (d) return Be(d, r, [ye(l)]), !0;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return !1;
|
|
692
|
+
}, B)), n && o.listenersToRemove.add(t.registerCommand(pt, (l) => {
|
|
693
|
+
const i = k();
|
|
694
|
+
if (!P(i) || !i.isCollapsed() || !q(i, r)) return !1;
|
|
695
|
+
const a = _e(i.anchor.getNode());
|
|
696
|
+
if (a === null) return !1;
|
|
697
|
+
U(l);
|
|
698
|
+
const d = r.getCordsFromCellNode(a, o.table);
|
|
699
|
+
return Je(o, r, d.x, d.y, l.shiftKey ? "backward" : "forward"), !0;
|
|
700
|
+
}, B)), o.listenersToRemove.add(t.registerCommand(Ct, (l) => r.isSelected(), V)), o.listenersToRemove.add(t.registerCommand(_t, (l) => {
|
|
701
|
+
const { nodes: i, selection: a } = l, d = a.getStartEndPoints(), S = v(a), w = P(a) && y(a.anchor.getNode(), (F) => f(F)) !== null && y(a.focus.getNode(), (F) => f(F)) !== null || S;
|
|
702
|
+
if (i.length !== 1 || !O(i[0]) || !w || d === null) return !1;
|
|
703
|
+
const [C] = d, m = i[0], N = m.getChildren(), M = m.getFirstChildOrThrow().getChildrenSize(), R = m.getChildrenSize(), K = y(C.getNode(), (F) => f(F)), E = K && y(K, (F) => I(F)), x = E && y(E, (F) => O(F));
|
|
704
|
+
if (!f(K) || !I(E) || !O(x)) return !1;
|
|
705
|
+
const _ = E.getIndexWithinParent(), b = Math.min(x.getChildrenSize() - 1, _ + R - 1), p = K.getIndexWithinParent(), A = Math.min(E.getChildrenSize() - 1, p + M - 1), L = Math.min(p, A), H = Math.min(_, b), X = Math.max(p, A), $ = Math.max(_, b), J = x.getChildren();
|
|
706
|
+
let Y = 0;
|
|
707
|
+
for (let F = H; F <= $; F++) {
|
|
708
|
+
const te = J[F];
|
|
709
|
+
if (!I(te)) return !1;
|
|
710
|
+
const xe = N[Y];
|
|
711
|
+
if (!I(xe)) return !1;
|
|
712
|
+
const Ge = te.getChildren(), Ve = xe.getChildren();
|
|
713
|
+
let ve = 0;
|
|
714
|
+
for (let pe = L; pe <= X; pe++) {
|
|
715
|
+
const ce = Ge[pe];
|
|
716
|
+
if (!f(ce)) return !1;
|
|
717
|
+
const Re = Ve[ve];
|
|
718
|
+
if (!f(Re)) return !1;
|
|
719
|
+
const Ze = ce.getChildren();
|
|
720
|
+
Re.getChildren().forEach((G) => {
|
|
721
|
+
de(G) && ee().append(G), ce.append(G);
|
|
722
|
+
}), Ze.forEach((G) => G.remove()), ve++;
|
|
723
|
+
}
|
|
724
|
+
Y++;
|
|
725
|
+
}
|
|
726
|
+
return !0;
|
|
727
|
+
}, B)), o.listenersToRemove.add(t.registerCommand(ne, () => {
|
|
728
|
+
const l = k(), i = St();
|
|
729
|
+
if (P(l)) {
|
|
730
|
+
const { anchor: a, focus: d } = l, S = a.getNode(), w = d.getNode(), C = _e(S), m = _e(w), N = !(!C || !r.is(Z(C))), M = !(!m || !r.is(Z(m))), R = N !== M, K = N && M, E = l.isBackward();
|
|
731
|
+
if (R) {
|
|
732
|
+
const x = l.clone();
|
|
733
|
+
if (M) {
|
|
734
|
+
const [_] = Q(r, m, m), b = _[0][0].cell, p = _[_.length - 1].at(-1).cell;
|
|
735
|
+
x.focus.set(E ? b.getKey() : p.getKey(), E ? b.getChildrenSize() : p.getChildrenSize(), "element");
|
|
736
|
+
} else if (N) {
|
|
737
|
+
const [_] = Q(r, C, C), b = _[0][0].cell, p = _[_.length - 1].at(-1).cell;
|
|
738
|
+
x.anchor.set(E ? p.getKey() : b.getKey(), E ? p.getChildrenSize() : 0, "element");
|
|
739
|
+
}
|
|
740
|
+
j(x), He(t, o);
|
|
741
|
+
} else K && (C.is(m) || (o.setAnchorCellForSelection(g(C)), o.setFocusCellForSelection(g(m), !0), o.isSelecting || setTimeout(() => {
|
|
742
|
+
const { onMouseUp: x, onMouseMove: _ } = u();
|
|
743
|
+
o.isSelecting = !0, c.addEventListener("mouseup", x), c.addEventListener("mousemove", _);
|
|
744
|
+
}, 0)));
|
|
745
|
+
} else if (l && v(l) && l.is(i) && l.tableKey === r.getKey()) {
|
|
746
|
+
const a = Xe(t._window);
|
|
747
|
+
if (a && a.anchorNode && a.focusNode) {
|
|
748
|
+
const d = z(a.focusNode), S = d && !r.is(Z(d)), w = z(a.anchorNode), C = w && r.is(Z(w));
|
|
749
|
+
if (S && C && a.rangeCount > 0) {
|
|
750
|
+
const m = wt(a, t);
|
|
751
|
+
m && (m.anchor.set(r.getKey(), l.isBackward() ? r.getChildrenSize() : 0, "element"), a.removeAllRanges(), j(m));
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return l && !l.is(i) && (v(l) || v(i)) && o.tableSelection && !o.tableSelection.is(i) ? (v(l) && l.tableKey === o.tableNodeKey ? o.updateTableTableSelection(l) : !v(l) && v(i) && i.tableKey === o.tableNodeKey && o.updateTableTableSelection(null), !1) : (o.hasHijackedSelectionStyles && !r.isSelected() ? function(a, d) {
|
|
756
|
+
d.enableHighlightStyle(), Oe(d.table, (S) => {
|
|
757
|
+
const w = S.elem;
|
|
758
|
+
S.highlighted = !1, qe(a, S), w.getAttribute("style") || w.removeAttribute("style");
|
|
759
|
+
});
|
|
760
|
+
}(t, o) : !o.hasHijackedSelectionStyles && r.isSelected() && He(t, o), !1);
|
|
761
|
+
}, B)), o.listenersToRemove.add(t.registerCommand(bt, () => {
|
|
762
|
+
const l = k();
|
|
763
|
+
if (!P(l) || !l.isCollapsed() || !q(l, r)) return !1;
|
|
764
|
+
const i = Ie(t, l, r);
|
|
765
|
+
return !!i && (Be(i, r), !0);
|
|
766
|
+
}, B)), o;
|
|
767
|
+
}
|
|
768
|
+
function Pe(r) {
|
|
769
|
+
return r[Se] || null;
|
|
770
|
+
}
|
|
771
|
+
function Le(r) {
|
|
772
|
+
let e = r;
|
|
773
|
+
for (; e != null; ) {
|
|
774
|
+
const t = e.nodeName;
|
|
775
|
+
if (t === "TD" || t === "TH") {
|
|
776
|
+
const n = e._cell;
|
|
777
|
+
return n === void 0 ? null : n;
|
|
778
|
+
}
|
|
779
|
+
e = e.parentNode;
|
|
780
|
+
}
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
function le(r) {
|
|
784
|
+
const e = [], t = { columns: 0, domRows: e, rows: 0 };
|
|
785
|
+
let n = r.querySelector("tr"), s = 0, o = 0;
|
|
786
|
+
for (e.length = 0; n != null; ) {
|
|
787
|
+
const c = n.nodeName;
|
|
788
|
+
if (c === "TD" || c === "TH") {
|
|
789
|
+
const g = { elem: n, hasBackgroundColor: n.style.backgroundColor !== "", highlighted: !1, x: s, y: o };
|
|
790
|
+
n._cell = g;
|
|
791
|
+
let l = e[o];
|
|
792
|
+
l === void 0 && (l = e[o] = []), l[s] = g;
|
|
793
|
+
} else {
|
|
794
|
+
const g = n.firstChild;
|
|
795
|
+
if (g != null) {
|
|
796
|
+
n = g;
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
const u = n.nextSibling;
|
|
801
|
+
if (u != null) {
|
|
802
|
+
s++, n = u;
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
const h = n.parentNode;
|
|
806
|
+
if (h != null) {
|
|
807
|
+
const g = h.nextSibling;
|
|
808
|
+
if (g == null) break;
|
|
809
|
+
o++, s = 0, n = g;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return t.columns = s + 1, t.rows = o + 1, t;
|
|
813
|
+
}
|
|
814
|
+
function ue(r, e, t) {
|
|
815
|
+
const n = new Set(t ? t.getNodes() : []);
|
|
816
|
+
Oe(e, (s, o) => {
|
|
817
|
+
const c = s.elem;
|
|
818
|
+
n.has(o) ? (s.highlighted = !0, je(r, s)) : (s.highlighted = !1, qe(r, s), c.getAttribute("style") || c.removeAttribute("style"));
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
function Oe(r, e) {
|
|
822
|
+
const { domRows: t } = r;
|
|
823
|
+
for (let n = 0; n < t.length; n++) {
|
|
824
|
+
const s = t[n];
|
|
825
|
+
if (s) for (let o = 0; o < s.length; o++) {
|
|
826
|
+
const c = s[o];
|
|
827
|
+
if (!c) continue;
|
|
828
|
+
const u = z(c.elem);
|
|
829
|
+
u !== null && e(c, u, { x: o, y: n });
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function He(r, e) {
|
|
834
|
+
e.disableHighlightStyle(), Oe(e.table, (t) => {
|
|
835
|
+
t.highlighted = !0, je(r, t);
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
const Je = (r, e, t, n, s) => {
|
|
839
|
+
const o = s === "forward";
|
|
840
|
+
switch (s) {
|
|
841
|
+
case "backward":
|
|
842
|
+
case "forward":
|
|
843
|
+
return t !== (o ? r.table.columns - 1 : 0) ? he(e.getCellNodeFromCordsOrThrow(t + (o ? 1 : -1), n, r.table), o) : n !== (o ? r.table.rows - 1 : 0) ? he(e.getCellNodeFromCordsOrThrow(o ? 0 : r.table.columns - 1, n + (o ? 1 : -1), r.table), o) : o ? e.selectNext() : e.selectPrevious(), !0;
|
|
844
|
+
case "up":
|
|
845
|
+
return n !== 0 ? he(e.getCellNodeFromCordsOrThrow(t, n - 1, r.table), !1) : e.selectPrevious(), !0;
|
|
846
|
+
case "down":
|
|
847
|
+
return n !== r.table.rows - 1 ? he(e.getCellNodeFromCordsOrThrow(t, n + 1, r.table), !0) : e.selectNext(), !0;
|
|
848
|
+
default:
|
|
849
|
+
return !1;
|
|
850
|
+
}
|
|
851
|
+
}, Ht = (r, e, t, n, s) => {
|
|
852
|
+
const o = s === "forward";
|
|
853
|
+
switch (s) {
|
|
854
|
+
case "backward":
|
|
855
|
+
case "forward":
|
|
856
|
+
return t !== (o ? r.table.columns - 1 : 0) && r.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t + (o ? 1 : -1), n, r.table)), !0;
|
|
857
|
+
case "up":
|
|
858
|
+
return n !== 0 && (r.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t, n - 1, r.table)), !0);
|
|
859
|
+
case "down":
|
|
860
|
+
return n !== r.table.rows - 1 && (r.setFocusCellForSelection(e.getDOMCellFromCordsOrThrow(t, n + 1, r.table)), !0);
|
|
861
|
+
default:
|
|
862
|
+
return !1;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
function q(r, e) {
|
|
866
|
+
if (P(r) || v(r)) {
|
|
867
|
+
const t = e.isParentOf(r.anchor.getNode()), n = e.isParentOf(r.focus.getNode());
|
|
868
|
+
return t && n;
|
|
869
|
+
}
|
|
870
|
+
return !1;
|
|
871
|
+
}
|
|
872
|
+
function he(r, e) {
|
|
873
|
+
e ? r.selectStart() : r.selectEnd();
|
|
874
|
+
}
|
|
875
|
+
const Ce = "172,206,247";
|
|
876
|
+
function je(r, e) {
|
|
877
|
+
const t = e.elem, n = z(t);
|
|
878
|
+
f(n) || T(131), n.getBackgroundColor() === null ? t.style.setProperty("background-color", `rgb(${Ce})`) : t.style.setProperty("background-image", `linear-gradient(to right, rgba(${Ce},0.85), rgba(${Ce},0.85))`), t.style.setProperty("caret-color", "transparent");
|
|
879
|
+
}
|
|
880
|
+
function qe(r, e) {
|
|
881
|
+
const t = e.elem, n = z(t);
|
|
882
|
+
f(n) || T(131), n.getBackgroundColor() === null && t.style.removeProperty("background-color"), t.style.removeProperty("background-image"), t.style.removeProperty("caret-color");
|
|
883
|
+
}
|
|
884
|
+
function _e(r) {
|
|
885
|
+
const e = y(r, f);
|
|
886
|
+
return f(e) ? e : null;
|
|
887
|
+
}
|
|
888
|
+
function Z(r) {
|
|
889
|
+
const e = y(r, O);
|
|
890
|
+
return O(e) ? e : null;
|
|
891
|
+
}
|
|
892
|
+
function re(r, e, t, n, s) {
|
|
893
|
+
if ((t === "up" || t === "down") && function(c) {
|
|
894
|
+
const u = c.getRootElement();
|
|
895
|
+
return u ? u.hasAttribute("aria-controls") && u.getAttribute("aria-controls") === "typeahead-menu" : !1;
|
|
896
|
+
}(r)) return !1;
|
|
897
|
+
const o = k();
|
|
898
|
+
if (!q(o, n)) {
|
|
899
|
+
if (P(o)) {
|
|
900
|
+
if (o.isCollapsed() && t === "backward") {
|
|
901
|
+
const c = o.anchor.type, u = o.anchor.offset;
|
|
902
|
+
if (c !== "element" && (c !== "text" || u !== 0)) return !1;
|
|
903
|
+
const h = o.anchor.getNode();
|
|
904
|
+
if (!h) return !1;
|
|
905
|
+
const g = y(h, (i) => D(i) && !i.isInline());
|
|
906
|
+
if (!g) return !1;
|
|
907
|
+
const l = g.getPreviousSibling();
|
|
908
|
+
return !(!l || !O(l)) && (U(e), l.selectEnd(), !0);
|
|
909
|
+
}
|
|
910
|
+
if (e.shiftKey && (t === "up" || t === "down")) {
|
|
911
|
+
const c = o.focus.getNode();
|
|
912
|
+
if (!o.isCollapsed() && (t === "up" && !o.isBackward() || t === "down" && o.isBackward())) {
|
|
913
|
+
let u = y(c, (a) => O(a));
|
|
914
|
+
if (f(u) && (u = y(u, O)), u !== n || !u) return !1;
|
|
915
|
+
const h = t === "down" ? u.getNextSibling() : u.getPreviousSibling();
|
|
916
|
+
if (!h) return !1;
|
|
917
|
+
let g = 0;
|
|
918
|
+
t === "up" && D(h) && (g = h.getChildrenSize());
|
|
919
|
+
let l = h;
|
|
920
|
+
t === "up" && D(h) && (l = h.getLastChild() || h, g = de(l) ? l.getTextContentSize() : 0);
|
|
921
|
+
const i = o.clone();
|
|
922
|
+
return i.focus.set(l.getKey(), g, de(l) ? "text" : "element"), j(i), U(e), !0;
|
|
923
|
+
}
|
|
924
|
+
if (yt(c)) {
|
|
925
|
+
const u = t === "up" ? o.getNodes()[o.getNodes().length - 1] : o.getNodes()[0];
|
|
926
|
+
if (u) {
|
|
927
|
+
const h = y(u, f);
|
|
928
|
+
if (h && n.isParentOf(h)) {
|
|
929
|
+
const g = n.getFirstDescendant(), l = n.getLastDescendant();
|
|
930
|
+
if (!g || !l) return !1;
|
|
931
|
+
const [i] = oe(g), [a] = oe(l), d = n.getCordsFromCellNode(i, s.table), S = n.getCordsFromCellNode(a, s.table), w = n.getDOMCellFromCordsOrThrow(d.x, d.y, s.table), C = n.getDOMCellFromCordsOrThrow(S.x, S.y, s.table);
|
|
932
|
+
return s.setAnchorCellForSelection(w), s.setFocusCellForSelection(C, !0), !0;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return !1;
|
|
936
|
+
}
|
|
937
|
+
{
|
|
938
|
+
let u = y(c, (g) => D(g) && !g.isInline());
|
|
939
|
+
if (f(u) && (u = y(u, O)), !u) return !1;
|
|
940
|
+
const h = t === "down" ? u.getNextSibling() : u.getPreviousSibling();
|
|
941
|
+
if (O(h) && s.tableNodeKey === h.getKey()) {
|
|
942
|
+
const g = h.getFirstDescendant(), l = h.getLastDescendant();
|
|
943
|
+
if (!g || !l) return !1;
|
|
944
|
+
const [i] = oe(g), [a] = oe(l), d = o.clone();
|
|
945
|
+
return d.focus.set((t === "up" ? i : a).getKey(), t === "up" ? 0 : a.getChildrenSize(), "element"), U(e), j(d), !0;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return !1;
|
|
951
|
+
}
|
|
952
|
+
if (P(o) && o.isCollapsed()) {
|
|
953
|
+
const { anchor: c, focus: u } = o, h = y(c.getNode(), f), g = y(u.getNode(), f);
|
|
954
|
+
if (!f(h) || !h.is(g)) return !1;
|
|
955
|
+
const l = Z(h);
|
|
956
|
+
if (l !== n && l != null) {
|
|
957
|
+
const m = r.getElementByKey(l.getKey());
|
|
958
|
+
if (m != null) return s.table = le(m), re(r, e, t, l, s);
|
|
959
|
+
}
|
|
960
|
+
if (t === "backward" || t === "forward") {
|
|
961
|
+
const m = c.type, N = c.offset, M = c.getNode();
|
|
962
|
+
if (!M) return !1;
|
|
963
|
+
const R = o.getNodes();
|
|
964
|
+
return (R.length !== 1 || !Nt(R[0])) && !!function(K, E, x, _) {
|
|
965
|
+
return function(b, p, A) {
|
|
966
|
+
return b === "element" && (A === "backward" ? p.getPreviousSibling() === null : p.getNextSibling() === null);
|
|
967
|
+
}(K, x, _) || function(b, p, A, L) {
|
|
968
|
+
const H = y(A, ($) => D($) && !$.isInline());
|
|
969
|
+
if (!H) return !1;
|
|
970
|
+
const X = L === "backward" ? p === 0 : p === A.getTextContentSize();
|
|
971
|
+
return b === "text" && X && (L === "backward" ? H.getPreviousSibling() === null : H.getNextSibling() === null);
|
|
972
|
+
}(K, E, x, _);
|
|
973
|
+
}(m, N, M, t) && function(K, E, x, _) {
|
|
974
|
+
const b = y(E, f);
|
|
975
|
+
if (!f(b)) return !1;
|
|
976
|
+
const [p, A] = Q(x, b, b);
|
|
977
|
+
if (!function(H, X, $) {
|
|
978
|
+
const J = H[0][0], Y = H[H.length - 1][H[0].length - 1], { startColumn: F, startRow: te } = X;
|
|
979
|
+
return $ === "backward" ? F === J.startColumn && te === J.startRow : F === Y.startColumn && te === Y.startRow;
|
|
980
|
+
}(p, A, _)) return !1;
|
|
981
|
+
const L = function(H, X, $) {
|
|
982
|
+
const J = y(H, (F) => D(F) && !F.isInline());
|
|
983
|
+
if (!J) return;
|
|
984
|
+
const Y = X === "backward" ? J.getPreviousSibling() : J.getNextSibling();
|
|
985
|
+
return Y && O(Y) ? Y : X === "backward" ? $.getPreviousSibling() : $.getNextSibling();
|
|
986
|
+
}(E, _, x);
|
|
987
|
+
return !L || O(L) ? !1 : (U(K), _ === "backward" ? L.selectEnd() : L.selectStart(), !0);
|
|
988
|
+
}(e, M, n, t);
|
|
989
|
+
}
|
|
990
|
+
const i = r.getElementByKey(h.__key), a = r.getElementByKey(c.key);
|
|
991
|
+
if (a == null || i == null) return !1;
|
|
992
|
+
let d;
|
|
993
|
+
if (c.type === "element") d = a.getBoundingClientRect();
|
|
994
|
+
else {
|
|
995
|
+
const m = window.getSelection();
|
|
996
|
+
if (m === null || m.rangeCount === 0) return !1;
|
|
997
|
+
d = m.getRangeAt(0).getBoundingClientRect();
|
|
998
|
+
}
|
|
999
|
+
const S = t === "up" ? h.getFirstChild() : h.getLastChild();
|
|
1000
|
+
if (S == null) return !1;
|
|
1001
|
+
const w = r.getElementByKey(S.__key);
|
|
1002
|
+
if (w == null) return !1;
|
|
1003
|
+
const C = w.getBoundingClientRect();
|
|
1004
|
+
if (t === "up" ? C.top > d.top - d.height : d.bottom + d.height > C.bottom) {
|
|
1005
|
+
U(e);
|
|
1006
|
+
const m = n.getCordsFromCellNode(h, s.table);
|
|
1007
|
+
if (!e.shiftKey) return Je(s, n, m.x, m.y, t);
|
|
1008
|
+
{
|
|
1009
|
+
const N = n.getDOMCellFromCordsOrThrow(m.x, m.y, s.table);
|
|
1010
|
+
s.setAnchorCellForSelection(N), s.setFocusCellForSelection(N, !0);
|
|
1011
|
+
}
|
|
1012
|
+
return !0;
|
|
1013
|
+
}
|
|
1014
|
+
} else if (v(o)) {
|
|
1015
|
+
const { anchor: c, focus: u } = o, h = y(c.getNode(), f), g = y(u.getNode(), f), [l] = o.getNodes(), i = r.getElementByKey(l.getKey());
|
|
1016
|
+
if (!f(h) || !f(g) || !O(l) || i == null) return !1;
|
|
1017
|
+
s.updateTableTableSelection(o);
|
|
1018
|
+
const a = le(i), d = n.getCordsFromCellNode(h, a), S = n.getDOMCellFromCordsOrThrow(d.x, d.y, a);
|
|
1019
|
+
if (s.setAnchorCellForSelection(S), U(e), e.shiftKey) {
|
|
1020
|
+
const w = n.getCordsFromCellNode(g, a);
|
|
1021
|
+
return Ht(s, l, w.x, w.y, t);
|
|
1022
|
+
}
|
|
1023
|
+
return g.selectEnd(), !0;
|
|
1024
|
+
}
|
|
1025
|
+
return !1;
|
|
1026
|
+
}
|
|
1027
|
+
function U(r) {
|
|
1028
|
+
r.preventDefault(), r.stopImmediatePropagation(), r.stopPropagation();
|
|
1029
|
+
}
|
|
1030
|
+
function Be(r, e, t) {
|
|
1031
|
+
const n = ee();
|
|
1032
|
+
r === "first" ? e.insertBefore(n) : e.insertAfter(n), n.append(...t || []), n.selectEnd();
|
|
1033
|
+
}
|
|
1034
|
+
function Ie(r, e, t) {
|
|
1035
|
+
const n = t.getParent();
|
|
1036
|
+
if (!n) return;
|
|
1037
|
+
const s = r.getElementByKey(n.getKey());
|
|
1038
|
+
if (!s) return;
|
|
1039
|
+
const o = window.getSelection();
|
|
1040
|
+
if (!o || o.anchorNode !== s) return;
|
|
1041
|
+
const c = y(e.anchor.getNode(), (C) => f(C));
|
|
1042
|
+
if (!c) return;
|
|
1043
|
+
const u = y(c, (C) => O(C));
|
|
1044
|
+
if (!O(u) || !u.is(t)) return;
|
|
1045
|
+
const [h, g] = Q(t, c, c), l = h[0][0], i = h[h.length - 1][h[0].length - 1], { startRow: a, startColumn: d } = g, S = a === l.startRow && d === l.startColumn, w = a === i.startRow && d === i.startColumn;
|
|
1046
|
+
return S ? "first" : w ? "last" : void 0;
|
|
1047
|
+
}
|
|
1048
|
+
function We(r, e, t, n) {
|
|
1049
|
+
const s = r.querySelector("colgroup");
|
|
1050
|
+
if (!s) return;
|
|
1051
|
+
const o = [];
|
|
1052
|
+
for (let c = 0; c < t; c++) {
|
|
1053
|
+
const u = document.createElement("col"), h = n && n[c];
|
|
1054
|
+
h && (u.style.width = `${h}px`), o.push(u);
|
|
1055
|
+
}
|
|
1056
|
+
s.replaceChildren(...o);
|
|
1057
|
+
}
|
|
1058
|
+
function $e(r, e, t) {
|
|
1059
|
+
t ? (ie(r, e.theme.tableRowStriping), r.setAttribute("data-lexical-row-striping", "true")) : (Ye(r, e.theme.tableRowStriping), r.removeAttribute("data-lexical-row-striping"));
|
|
1060
|
+
}
|
|
1061
|
+
class me extends we {
|
|
1062
|
+
static getType() {
|
|
1063
|
+
return "table";
|
|
1064
|
+
}
|
|
1065
|
+
getColWidths() {
|
|
1066
|
+
return this.getLatest().__colWidths;
|
|
1067
|
+
}
|
|
1068
|
+
setColWidths(e) {
|
|
1069
|
+
const t = this.getWritable();
|
|
1070
|
+
return t.__colWidths = e, t;
|
|
1071
|
+
}
|
|
1072
|
+
static clone(e) {
|
|
1073
|
+
return new me(e.__key);
|
|
1074
|
+
}
|
|
1075
|
+
afterCloneFrom(e) {
|
|
1076
|
+
super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping;
|
|
1077
|
+
}
|
|
1078
|
+
static importDOM() {
|
|
1079
|
+
return { table: (e) => ({ conversion: Bt, priority: 1 }) };
|
|
1080
|
+
}
|
|
1081
|
+
static importJSON(e) {
|
|
1082
|
+
const t = Me();
|
|
1083
|
+
return t.__rowStriping = e.rowStriping || !1, t.__colWidths = e.colWidths, t;
|
|
1084
|
+
}
|
|
1085
|
+
constructor(e) {
|
|
1086
|
+
super(e), this.__rowStriping = !1;
|
|
1087
|
+
}
|
|
1088
|
+
exportJSON() {
|
|
1089
|
+
return { ...super.exportJSON(), colWidths: this.getColWidths(), rowStriping: this.__rowStriping ? this.__rowStriping : void 0, type: "table", version: 1 };
|
|
1090
|
+
}
|
|
1091
|
+
createDOM(e, t) {
|
|
1092
|
+
const n = document.createElement("table"), s = document.createElement("colgroup");
|
|
1093
|
+
return n.appendChild(s), We(n, 0, this.getColumnCount(), this.getColWidths()), ie(n, e.theme.table), this.__rowStriping && $e(n, e, !0), n;
|
|
1094
|
+
}
|
|
1095
|
+
updateDOM(e, t, n) {
|
|
1096
|
+
return e.__rowStriping !== this.__rowStriping && $e(t, n, this.__rowStriping), We(t, 0, this.getColumnCount(), this.getColWidths()), !1;
|
|
1097
|
+
}
|
|
1098
|
+
exportDOM(e) {
|
|
1099
|
+
return { ...super.exportDOM(e), after: (t) => {
|
|
1100
|
+
if (t) {
|
|
1101
|
+
const n = t.cloneNode(), s = document.createElement("colgroup"), o = document.createElement("tbody");
|
|
1102
|
+
if (nt(t)) {
|
|
1103
|
+
const c = t.querySelectorAll("col");
|
|
1104
|
+
s.append(...c);
|
|
1105
|
+
const u = t.querySelectorAll("tr");
|
|
1106
|
+
o.append(...u);
|
|
1107
|
+
}
|
|
1108
|
+
return n.replaceChildren(s, o), n;
|
|
1109
|
+
}
|
|
1110
|
+
} };
|
|
1111
|
+
}
|
|
1112
|
+
canBeEmpty() {
|
|
1113
|
+
return !1;
|
|
1114
|
+
}
|
|
1115
|
+
isShadowRoot() {
|
|
1116
|
+
return !0;
|
|
1117
|
+
}
|
|
1118
|
+
getCordsFromCellNode(e, t) {
|
|
1119
|
+
const { rows: n, domRows: s } = t;
|
|
1120
|
+
for (let o = 0; o < n; o++) {
|
|
1121
|
+
const c = s[o];
|
|
1122
|
+
if (c == null) continue;
|
|
1123
|
+
const u = c.findIndex((h) => {
|
|
1124
|
+
if (!h) return;
|
|
1125
|
+
const { elem: g } = h;
|
|
1126
|
+
return z(g) === e;
|
|
1127
|
+
});
|
|
1128
|
+
if (u !== -1) return { x: u, y: o };
|
|
1129
|
+
}
|
|
1130
|
+
throw new Error("Cell not found in table.");
|
|
1131
|
+
}
|
|
1132
|
+
getDOMCellFromCords(e, t, n) {
|
|
1133
|
+
const { domRows: s } = n, o = s[t];
|
|
1134
|
+
if (o == null) return null;
|
|
1135
|
+
const c = o[e < o.length ? e : o.length - 1];
|
|
1136
|
+
return c ?? null;
|
|
1137
|
+
}
|
|
1138
|
+
getDOMCellFromCordsOrThrow(e, t, n) {
|
|
1139
|
+
const s = this.getDOMCellFromCords(e, t, n);
|
|
1140
|
+
if (!s) throw new Error("Cell not found at cords.");
|
|
1141
|
+
return s;
|
|
1142
|
+
}
|
|
1143
|
+
getCellNodeFromCords(e, t, n) {
|
|
1144
|
+
const s = this.getDOMCellFromCords(e, t, n);
|
|
1145
|
+
if (s == null) return null;
|
|
1146
|
+
const o = z(s.elem);
|
|
1147
|
+
return f(o) ? o : null;
|
|
1148
|
+
}
|
|
1149
|
+
getCellNodeFromCordsOrThrow(e, t, n) {
|
|
1150
|
+
const s = this.getCellNodeFromCords(e, t, n);
|
|
1151
|
+
if (!s) throw new Error("Node at cords not TableCellNode.");
|
|
1152
|
+
return s;
|
|
1153
|
+
}
|
|
1154
|
+
getRowStriping() {
|
|
1155
|
+
return !!this.getLatest().__rowStriping;
|
|
1156
|
+
}
|
|
1157
|
+
setRowStriping(e) {
|
|
1158
|
+
this.getWritable().__rowStriping = e;
|
|
1159
|
+
}
|
|
1160
|
+
canSelectBefore() {
|
|
1161
|
+
return !0;
|
|
1162
|
+
}
|
|
1163
|
+
canIndent() {
|
|
1164
|
+
return !1;
|
|
1165
|
+
}
|
|
1166
|
+
getColumnCount() {
|
|
1167
|
+
const e = this.getFirstChild();
|
|
1168
|
+
if (!e) return 0;
|
|
1169
|
+
let t = 0;
|
|
1170
|
+
return e.getChildren().forEach((n) => {
|
|
1171
|
+
f(n) && (t += n.getColSpan());
|
|
1172
|
+
}), t;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function Bt(r) {
|
|
1176
|
+
const e = Me();
|
|
1177
|
+
r.hasAttribute("data-lexical-row-striping") && e.setRowStriping(!0);
|
|
1178
|
+
const t = r.querySelector(":scope > colgroup");
|
|
1179
|
+
if (t) {
|
|
1180
|
+
let n = [];
|
|
1181
|
+
for (const s of t.querySelectorAll(":scope > col")) {
|
|
1182
|
+
const o = s.style.width;
|
|
1183
|
+
if (!o || !Ne.test(o)) {
|
|
1184
|
+
n = void 0;
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
n.push(parseFloat(o));
|
|
1188
|
+
}
|
|
1189
|
+
n && e.setColWidths(n);
|
|
1190
|
+
}
|
|
1191
|
+
return { node: e };
|
|
1192
|
+
}
|
|
1193
|
+
function Me() {
|
|
1194
|
+
return be(new me());
|
|
1195
|
+
}
|
|
1196
|
+
function O(r) {
|
|
1197
|
+
return r instanceof me;
|
|
1198
|
+
}
|
|
1199
|
+
export {
|
|
1200
|
+
Jt as C,
|
|
1201
|
+
Q as F,
|
|
1202
|
+
kt as K,
|
|
1203
|
+
jt as T,
|
|
1204
|
+
qt as U,
|
|
1205
|
+
Ee as a,
|
|
1206
|
+
O as b,
|
|
1207
|
+
ge as c,
|
|
1208
|
+
Ut as d,
|
|
1209
|
+
ae as e,
|
|
1210
|
+
ze as f,
|
|
1211
|
+
zt as g,
|
|
1212
|
+
I as h,
|
|
1213
|
+
oe as k,
|
|
1214
|
+
Xt as m,
|
|
1215
|
+
Te as n,
|
|
1216
|
+
f as o,
|
|
1217
|
+
Dt as p,
|
|
1218
|
+
Yt as r,
|
|
1219
|
+
me as u
|
|
1220
|
+
};
|
|
1221
|
+
//# sourceMappingURL=LexicalTable.prod-DqzrJuYr.js.map
|