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