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