@lexical/table 0.20.1-nightly.20241128.0 → 0.20.1-nightly.20241129.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/LexicalTable.dev.js +50 -22
- package/LexicalTable.dev.mjs +51 -23
- package/LexicalTable.prod.js +73 -72
- package/LexicalTable.prod.mjs +1 -1
- package/LexicalTableSelectionHelpers.d.ts +2 -1
- package/package.json +4 -4
package/LexicalTable.dev.js
CHANGED
@@ -1756,8 +1756,8 @@ class TableObserver {
|
|
1756
1756
|
this.focusX = cellX;
|
1757
1757
|
this.focusY = cellY;
|
1758
1758
|
if (this.isHighlightingCells) {
|
1759
|
-
const focusTableCellNode =
|
1760
|
-
if (this.tableSelection != null && this.anchorCellNodeKey != null &&
|
1759
|
+
const focusTableCellNode = $getNearestTableCellInTableFromDOMNode(tableNode, cell.elem);
|
1760
|
+
if (this.tableSelection != null && this.anchorCellNodeKey != null && focusTableCellNode !== null) {
|
1761
1761
|
this.focusCellNodeKey = focusTableCellNode.getKey();
|
1762
1762
|
this.tableSelection = $createTableSelectionFrom(tableNode, this.$getAnchorTableCellOrThrow(), focusTableCellNode);
|
1763
1763
|
lexical.$setSelection(this.tableSelection);
|
@@ -1793,8 +1793,11 @@ class TableObserver {
|
|
1793
1793
|
this.anchorCell = cell;
|
1794
1794
|
this.anchorX = cell.x;
|
1795
1795
|
this.anchorY = cell.y;
|
1796
|
-
const
|
1797
|
-
|
1796
|
+
const {
|
1797
|
+
tableNode
|
1798
|
+
} = this.$lookup();
|
1799
|
+
const anchorTableCellNode = $getNearestTableCellInTableFromDOMNode(tableNode, cell.elem);
|
1800
|
+
if (anchorTableCellNode !== null) {
|
1798
1801
|
const anchorNodeKey = anchorTableCellNode.getKey();
|
1799
1802
|
this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : $createTableSelection();
|
1800
1803
|
this.anchorCellNodeKey = anchorNodeKey;
|
@@ -2191,12 +2194,11 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler) {
|
|
2191
2194
|
return false;
|
2192
2195
|
}
|
2193
2196
|
const tableCellNode = $findCellNode(selection.anchor.getNode());
|
2194
|
-
if (tableCellNode === null) {
|
2197
|
+
if (tableCellNode === null || !tableNode.is($findTableNode(tableCellNode))) {
|
2195
2198
|
return false;
|
2196
2199
|
}
|
2197
2200
|
stopEvent(event);
|
2198
|
-
|
2199
|
-
selectTableNodeInDirection(tableObserver, tableNode, currentCords.x, currentCords.y, !event.shiftKey ? 'forward' : 'backward');
|
2201
|
+
$selectAdjacentCell(tableCellNode, event.shiftKey ? 'previous' : 'next');
|
2200
2202
|
return true;
|
2201
2203
|
}, lexical.COMMAND_PRIORITY_CRITICAL));
|
2202
2204
|
}
|
@@ -2363,9 +2365,9 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler) {
|
|
2363
2365
|
const domSelection = lexical.getDOMSelection(editorWindow);
|
2364
2366
|
if (domSelection && domSelection.anchorNode && domSelection.focusNode) {
|
2365
2367
|
const focusNode = lexical.$getNearestNodeFromDOMNode(domSelection.focusNode);
|
2366
|
-
const isFocusOutside = focusNode && !tableNode.
|
2368
|
+
const isFocusOutside = focusNode && !tableNode.isParentOf(focusNode);
|
2367
2369
|
const anchorNode = lexical.$getNearestNodeFromDOMNode(domSelection.anchorNode);
|
2368
|
-
const isAnchorInside = anchorNode && tableNode.
|
2370
|
+
const isAnchorInside = anchorNode && tableNode.isParentOf(anchorNode);
|
2369
2371
|
if (isFocusOutside && isAnchorInside && domSelection.rangeCount > 0) {
|
2370
2372
|
const newSelection = lexical.$createRangeSelectionFromDom(domSelection, editor);
|
2371
2373
|
if (newSelection) {
|
@@ -2552,6 +2554,29 @@ function $removeHighlightStyleToTable(editor, tableObserver) {
|
|
2552
2554
|
}
|
2553
2555
|
});
|
2554
2556
|
}
|
2557
|
+
function $selectAdjacentCell(tableCellNode, direction) {
|
2558
|
+
const siblingMethod = direction === 'next' ? 'getNextSibling' : 'getPreviousSibling';
|
2559
|
+
const childMethod = direction === 'next' ? 'getFirstChild' : 'getLastChild';
|
2560
|
+
const sibling = tableCellNode[siblingMethod]();
|
2561
|
+
if (lexical.$isElementNode(sibling)) {
|
2562
|
+
return sibling.selectEnd();
|
2563
|
+
}
|
2564
|
+
const parentRow = utils.$findMatchingParent(tableCellNode, $isTableRowNode);
|
2565
|
+
if (!(parentRow !== null)) {
|
2566
|
+
throw Error(`selectAdjacentCell: Cell not in table row`);
|
2567
|
+
}
|
2568
|
+
for (let nextRow = parentRow[siblingMethod](); $isTableRowNode(nextRow); nextRow = nextRow[siblingMethod]()) {
|
2569
|
+
const child = nextRow[childMethod]();
|
2570
|
+
if (lexical.$isElementNode(child)) {
|
2571
|
+
return child.selectEnd();
|
2572
|
+
}
|
2573
|
+
}
|
2574
|
+
const parentTable = utils.$findMatchingParent(parentRow, $isTableNode);
|
2575
|
+
if (!(parentTable !== null)) {
|
2576
|
+
throw Error(`selectAdjacentCell: Row not in table`);
|
2577
|
+
}
|
2578
|
+
return direction === 'next' ? parentTable.selectNext() : parentTable.selectPrevious();
|
2579
|
+
}
|
2555
2580
|
const selectTableNodeInDirection = (tableObserver, tableNode, x, y, direction) => {
|
2556
2581
|
const isForward = direction === 'forward';
|
2557
2582
|
switch (direction) {
|
@@ -2806,8 +2831,8 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver) {
|
|
2806
2831
|
} else if (lexical.$isRootOrShadowRoot(focusNode)) {
|
2807
2832
|
const selectedNode = direction === 'up' ? selection.getNodes()[selection.getNodes().length - 1] : selection.getNodes()[0];
|
2808
2833
|
if (selectedNode) {
|
2809
|
-
const tableCellNode =
|
2810
|
-
if (tableCellNode
|
2834
|
+
const tableCellNode = $findParentTableCellNodeInTable(tableNode, selectedNode);
|
2835
|
+
if (tableCellNode !== null) {
|
2811
2836
|
const firstDescendant = tableNode.getFirstDescendant();
|
2812
2837
|
const lastDescendant = tableNode.getLastDescendant();
|
2813
2838
|
if (!firstDescendant || !lastDescendant) {
|
@@ -3086,6 +3111,9 @@ function $getObserverCellFromCellNodeOrThrow(tableObserver, tableCellNode) {
|
|
3086
3111
|
const currentCords = tableNode.getCordsFromCellNode(tableCellNode, tableObserver.table);
|
3087
3112
|
return tableNode.getDOMCellFromCordsOrThrow(currentCords.x, currentCords.y, tableObserver.table);
|
3088
3113
|
}
|
3114
|
+
function $getNearestTableCellInTableFromDOMNode(tableNode, startingDOM, editorState) {
|
3115
|
+
return $findParentTableCellNodeInTable(tableNode, lexical.$getNearestNodeFromDOMNode(startingDOM, editorState));
|
3116
|
+
}
|
3089
3117
|
|
3090
3118
|
/**
|
3091
3119
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
@@ -3261,21 +3289,21 @@ class TableNode extends lexical.ElementNode {
|
|
3261
3289
|
if (row == null) {
|
3262
3290
|
continue;
|
3263
3291
|
}
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3292
|
+
for (let x = 0; x < row.length; x++) {
|
3293
|
+
const cell = row[x];
|
3294
|
+
if (cell == null) {
|
3295
|
+
continue;
|
3267
3296
|
}
|
3268
3297
|
const {
|
3269
3298
|
elem
|
3270
3299
|
} = cell;
|
3271
|
-
const cellNode =
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
};
|
3300
|
+
const cellNode = $getNearestTableCellInTableFromDOMNode(this, elem);
|
3301
|
+
if (cellNode !== null && tableCellNode.is(cellNode)) {
|
3302
|
+
return {
|
3303
|
+
x,
|
3304
|
+
y
|
3305
|
+
};
|
3306
|
+
}
|
3279
3307
|
}
|
3280
3308
|
}
|
3281
3309
|
throw new Error('Cell not found in table.');
|
package/LexicalTable.dev.mjs
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
*/
|
8
8
|
|
9
9
|
import { addClassNamesToElement, $findMatchingParent, removeClassNamesFromElement, objectKlassEquals, isHTMLElement } from '@lexical/utils';
|
10
|
-
import { ElementNode, $createParagraphNode, $isElementNode, $isLineBreakNode, $isTextNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $createPoint, $isParagraphNode, $normalizeSelection__EXPERIMENTAL, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $getNodeByKey, $getEditor, $setSelection, SELECTION_CHANGE_COMMAND, getDOMSelection, $
|
10
|
+
import { ElementNode, $createParagraphNode, $isElementNode, $isLineBreakNode, $isTextNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $createPoint, $isParagraphNode, $normalizeSelection__EXPERIMENTAL, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $getNodeByKey, $getEditor, $setSelection, SELECTION_CHANGE_COMMAND, getDOMSelection, $createRangeSelection, $getRoot, COMMAND_PRIORITY_HIGH, KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_CRITICAL, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $getNearestNodeFromDOMNode, $createRangeSelectionFromDom, INSERT_PARAGRAPH_COMMAND, $isRootOrShadowRoot, $isDecoratorNode, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, setDOMUnmanaged } from 'lexical';
|
11
11
|
import { copyToClipboard, $getClipboardDataFromSelection } from '@lexical/clipboard';
|
12
12
|
|
13
13
|
/**
|
@@ -1754,8 +1754,8 @@ class TableObserver {
|
|
1754
1754
|
this.focusX = cellX;
|
1755
1755
|
this.focusY = cellY;
|
1756
1756
|
if (this.isHighlightingCells) {
|
1757
|
-
const focusTableCellNode = $
|
1758
|
-
if (this.tableSelection != null && this.anchorCellNodeKey != null &&
|
1757
|
+
const focusTableCellNode = $getNearestTableCellInTableFromDOMNode(tableNode, cell.elem);
|
1758
|
+
if (this.tableSelection != null && this.anchorCellNodeKey != null && focusTableCellNode !== null) {
|
1759
1759
|
this.focusCellNodeKey = focusTableCellNode.getKey();
|
1760
1760
|
this.tableSelection = $createTableSelectionFrom(tableNode, this.$getAnchorTableCellOrThrow(), focusTableCellNode);
|
1761
1761
|
$setSelection(this.tableSelection);
|
@@ -1791,8 +1791,11 @@ class TableObserver {
|
|
1791
1791
|
this.anchorCell = cell;
|
1792
1792
|
this.anchorX = cell.x;
|
1793
1793
|
this.anchorY = cell.y;
|
1794
|
-
const
|
1795
|
-
|
1794
|
+
const {
|
1795
|
+
tableNode
|
1796
|
+
} = this.$lookup();
|
1797
|
+
const anchorTableCellNode = $getNearestTableCellInTableFromDOMNode(tableNode, cell.elem);
|
1798
|
+
if (anchorTableCellNode !== null) {
|
1796
1799
|
const anchorNodeKey = anchorTableCellNode.getKey();
|
1797
1800
|
this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : $createTableSelection();
|
1798
1801
|
this.anchorCellNodeKey = anchorNodeKey;
|
@@ -2189,12 +2192,11 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler) {
|
|
2189
2192
|
return false;
|
2190
2193
|
}
|
2191
2194
|
const tableCellNode = $findCellNode(selection.anchor.getNode());
|
2192
|
-
if (tableCellNode === null) {
|
2195
|
+
if (tableCellNode === null || !tableNode.is($findTableNode(tableCellNode))) {
|
2193
2196
|
return false;
|
2194
2197
|
}
|
2195
2198
|
stopEvent(event);
|
2196
|
-
|
2197
|
-
selectTableNodeInDirection(tableObserver, tableNode, currentCords.x, currentCords.y, !event.shiftKey ? 'forward' : 'backward');
|
2199
|
+
$selectAdjacentCell(tableCellNode, event.shiftKey ? 'previous' : 'next');
|
2198
2200
|
return true;
|
2199
2201
|
}, COMMAND_PRIORITY_CRITICAL));
|
2200
2202
|
}
|
@@ -2361,9 +2363,9 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler) {
|
|
2361
2363
|
const domSelection = getDOMSelection(editorWindow);
|
2362
2364
|
if (domSelection && domSelection.anchorNode && domSelection.focusNode) {
|
2363
2365
|
const focusNode = $getNearestNodeFromDOMNode(domSelection.focusNode);
|
2364
|
-
const isFocusOutside = focusNode && !tableNode.
|
2366
|
+
const isFocusOutside = focusNode && !tableNode.isParentOf(focusNode);
|
2365
2367
|
const anchorNode = $getNearestNodeFromDOMNode(domSelection.anchorNode);
|
2366
|
-
const isAnchorInside = anchorNode && tableNode.
|
2368
|
+
const isAnchorInside = anchorNode && tableNode.isParentOf(anchorNode);
|
2367
2369
|
if (isFocusOutside && isAnchorInside && domSelection.rangeCount > 0) {
|
2368
2370
|
const newSelection = $createRangeSelectionFromDom(domSelection, editor);
|
2369
2371
|
if (newSelection) {
|
@@ -2550,6 +2552,29 @@ function $removeHighlightStyleToTable(editor, tableObserver) {
|
|
2550
2552
|
}
|
2551
2553
|
});
|
2552
2554
|
}
|
2555
|
+
function $selectAdjacentCell(tableCellNode, direction) {
|
2556
|
+
const siblingMethod = direction === 'next' ? 'getNextSibling' : 'getPreviousSibling';
|
2557
|
+
const childMethod = direction === 'next' ? 'getFirstChild' : 'getLastChild';
|
2558
|
+
const sibling = tableCellNode[siblingMethod]();
|
2559
|
+
if ($isElementNode(sibling)) {
|
2560
|
+
return sibling.selectEnd();
|
2561
|
+
}
|
2562
|
+
const parentRow = $findMatchingParent(tableCellNode, $isTableRowNode);
|
2563
|
+
if (!(parentRow !== null)) {
|
2564
|
+
throw Error(`selectAdjacentCell: Cell not in table row`);
|
2565
|
+
}
|
2566
|
+
for (let nextRow = parentRow[siblingMethod](); $isTableRowNode(nextRow); nextRow = nextRow[siblingMethod]()) {
|
2567
|
+
const child = nextRow[childMethod]();
|
2568
|
+
if ($isElementNode(child)) {
|
2569
|
+
return child.selectEnd();
|
2570
|
+
}
|
2571
|
+
}
|
2572
|
+
const parentTable = $findMatchingParent(parentRow, $isTableNode);
|
2573
|
+
if (!(parentTable !== null)) {
|
2574
|
+
throw Error(`selectAdjacentCell: Row not in table`);
|
2575
|
+
}
|
2576
|
+
return direction === 'next' ? parentTable.selectNext() : parentTable.selectPrevious();
|
2577
|
+
}
|
2553
2578
|
const selectTableNodeInDirection = (tableObserver, tableNode, x, y, direction) => {
|
2554
2579
|
const isForward = direction === 'forward';
|
2555
2580
|
switch (direction) {
|
@@ -2804,8 +2829,8 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver) {
|
|
2804
2829
|
} else if ($isRootOrShadowRoot(focusNode)) {
|
2805
2830
|
const selectedNode = direction === 'up' ? selection.getNodes()[selection.getNodes().length - 1] : selection.getNodes()[0];
|
2806
2831
|
if (selectedNode) {
|
2807
|
-
const tableCellNode = $
|
2808
|
-
if (tableCellNode
|
2832
|
+
const tableCellNode = $findParentTableCellNodeInTable(tableNode, selectedNode);
|
2833
|
+
if (tableCellNode !== null) {
|
2809
2834
|
const firstDescendant = tableNode.getFirstDescendant();
|
2810
2835
|
const lastDescendant = tableNode.getLastDescendant();
|
2811
2836
|
if (!firstDescendant || !lastDescendant) {
|
@@ -3084,6 +3109,9 @@ function $getObserverCellFromCellNodeOrThrow(tableObserver, tableCellNode) {
|
|
3084
3109
|
const currentCords = tableNode.getCordsFromCellNode(tableCellNode, tableObserver.table);
|
3085
3110
|
return tableNode.getDOMCellFromCordsOrThrow(currentCords.x, currentCords.y, tableObserver.table);
|
3086
3111
|
}
|
3112
|
+
function $getNearestTableCellInTableFromDOMNode(tableNode, startingDOM, editorState) {
|
3113
|
+
return $findParentTableCellNodeInTable(tableNode, $getNearestNodeFromDOMNode(startingDOM, editorState));
|
3114
|
+
}
|
3087
3115
|
|
3088
3116
|
/**
|
3089
3117
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
@@ -3259,21 +3287,21 @@ class TableNode extends ElementNode {
|
|
3259
3287
|
if (row == null) {
|
3260
3288
|
continue;
|
3261
3289
|
}
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3290
|
+
for (let x = 0; x < row.length; x++) {
|
3291
|
+
const cell = row[x];
|
3292
|
+
if (cell == null) {
|
3293
|
+
continue;
|
3265
3294
|
}
|
3266
3295
|
const {
|
3267
3296
|
elem
|
3268
3297
|
} = cell;
|
3269
|
-
const cellNode = $
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
};
|
3298
|
+
const cellNode = $getNearestTableCellInTableFromDOMNode(this, elem);
|
3299
|
+
if (cellNode !== null && tableCellNode.is(cellNode)) {
|
3300
|
+
return {
|
3301
|
+
x,
|
3302
|
+
y
|
3303
|
+
};
|
3304
|
+
}
|
3277
3305
|
}
|
3278
3306
|
}
|
3279
3307
|
throw new Error('Cell not found in table.');
|
package/LexicalTable.prod.js
CHANGED
@@ -6,67 +6,67 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
-
'use strict';var h=require("@lexical/utils"),w=require("lexical"),
|
10
|
-
class y extends w.ElementNode{static getType(){return"tablecell"}static clone(a){return new y(a.__headerState,a.__colSpan,a.__width,a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__rowSpan=a.__rowSpan;this.__backgroundColor=a.__backgroundColor}static importDOM(){return{td:()=>({conversion:
|
9
|
+
'use strict';var h=require("@lexical/utils"),w=require("lexical"),ba=require("@lexical/clipboard");let ca=/^(\d+(?:\.\d+)?)px$/,x={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
|
10
|
+
class y extends w.ElementNode{static getType(){return"tablecell"}static clone(a){return new y(a.__headerState,a.__colSpan,a.__width,a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__rowSpan=a.__rowSpan;this.__backgroundColor=a.__backgroundColor}static importDOM(){return{td:()=>({conversion:da,priority:0}),th:()=>({conversion:da,priority:0})}}static importJSON(a){let b=a.rowSpan||1;return A(a.headerState,a.colSpan||1,a.width||void 0).setRowSpan(b).setBackgroundColor(a.backgroundColor||null)}constructor(a=
|
11
11
|
x.NO_STATUS,b=1,c,d){super(d);this.__colSpan=b;this.__rowSpan=1;this.__headerState=a;this.__width=c;this.__backgroundColor=null}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);null!==this.__backgroundColor&&(b.style.backgroundColor=this.__backgroundColor);h.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){a=
|
12
12
|
super.exportDOM(a);if(a.element){let b=a.element;b.style.border="1px solid black";1<this.__colSpan&&(b.colSpan=this.__colSpan);1<this.__rowSpan&&(b.rowSpan=this.__rowSpan);b.style.width=`${this.getWidth()||75}px`;b.style.verticalAlign="top";b.style.textAlign="start";null===this.__backgroundColor&&this.hasHeader()&&(b.style.backgroundColor="#f2f3f5")}return a}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,
|
13
13
|
type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(a){let b=this.getWritable();b.__colSpan=a;return b}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(a){let b=this.getWritable();b.__rowSpan=a;return b}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a,b=x.BOTH){let c=this.getWritable();c.__headerState=a&b|c.__headerState&~b;return c}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){let b=this.getWritable();b.__width=
|
14
14
|
a;return b}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){let b=this.getWritable();b.__backgroundColor=a;return b}toggleHeaderStyle(a){let b=this.getWritable();b.__headerState=(b.__headerState&a)===a?b.__headerState-a:b.__headerState+a;return b}hasHeaderState(a){return(this.getHeaderStyles()&a)===a}hasHeader(){return this.getLatest().__headerState!==x.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||
|
15
15
|
a.__width!==this.__width||a.__colSpan!==this.__colSpan||a.__rowSpan!==this.__rowSpan||a.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
|
16
|
-
function
|
17
|
-
{if(C(q)&&!w.$isElementNode(n)){q=w.$createParagraphNode();if(w.$isLineBreakNode(n)&&"\n"===n.getTextContent())return null;w.$isTextNode(n)&&(d&&n.toggleFormat("bold"),e&&n.toggleFormat("strikethrough"),f&&n.toggleFormat("italic"),g&&n.toggleFormat("underline"));q.append(n);return q}return n},node:b}}function A(a,b=1,c){return w.$applyNodeReplacement(new y(a,b,c))}function C(a){return a instanceof y}let
|
16
|
+
function da(a){var b=a.nodeName.toLowerCase(),c=void 0;ca.test(a.style.width)&&(c=parseFloat(a.style.width));b=A("th"===b?x.ROW:x.NO_STATUS,a.colSpan,c);b.__rowSpan=a.rowSpan;c=a.style.backgroundColor;""!==c&&(b.__backgroundColor=c);a=a.style;c=(a&&a.textDecoration||"").split(" ");let d="700"===a.fontWeight||"bold"===a.fontWeight,e=c.includes("line-through"),f="italic"===a.fontStyle,g=c.includes("underline");return{after:n=>{0===n.length&&n.push(w.$createParagraphNode());return n},forChild:(n,q)=>
|
17
|
+
{if(C(q)&&!w.$isElementNode(n)){q=w.$createParagraphNode();if(w.$isLineBreakNode(n)&&"\n"===n.getTextContent())return null;w.$isTextNode(n)&&(d&&n.toggleFormat("bold"),e&&n.toggleFormat("strikethrough"),f&&n.toggleFormat("italic"),g&&n.toggleFormat("underline"));q.append(n);return q}return n},node:b}}function A(a,b=1,c){return w.$applyNodeReplacement(new y(a,b,c))}function C(a){return a instanceof y}let ea=w.createCommand("INSERT_TABLE_COMMAND");var E;
|
18
18
|
function F(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}E=F&&F.__esModule&&Object.prototype.hasOwnProperty.call(F,"default")?F["default"]:F;
|
19
|
-
let
|
20
|
-
class
|
21
|
-
a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function
|
22
|
-
function
|
23
|
-
let
|
24
|
-
function
|
19
|
+
let fa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,ha=fa&&"documentMode"in document?document.documentMode:null,ia=fa&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);fa&&"InputEvent"in window&&!ha?"getTargetRanges"in new window.InputEvent("input"):!1;
|
20
|
+
class ja extends w.ElementNode{static getType(){return"tablerow"}static clone(a){return new ja(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ka,priority:0})}}static importJSON(a){return I(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),...(this.getHeight()&&{height:this.getHeight()}),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);h.addClassNamesToElement(b,
|
21
|
+
a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function ka(a){let b=void 0;ca.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:I(b)}}function I(a){return w.$applyNodeReplacement(new ja(a))}function J(a){return a instanceof ja}
|
22
|
+
function la(a){a=h.$findMatchingParent(a,b=>J(b));if(J(a))return a;throw Error("Expected table cell to be inside of table row.");}function ma(a){a=h.$findMatchingParent(a,b=>K(b));if(K(a))return a;throw Error("Expected table cell to be inside of table.");}function na(a,b){let c=ma(a),{x:d,y:e}=c.getCordsFromCellNode(a,b);return{above:c.getCellNodeFromCords(d,e-1,b),below:c.getCellNodeFromCords(d,e+1,b),left:c.getCellNodeFromCords(d-1,e,b),right:c.getCellNodeFromCords(d+1,e,b)}}
|
23
|
+
let oa=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function M(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function pa(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function N(a,b,c){let [d,e,f]=qa(a,b,c);null===e&&E(207);null===f&&E(208);return[d,e,f]}
|
24
|
+
function qa(a,b,c){function d(q){let r=e[q];void 0===r&&(e[q]=r=[]);return r}let e=[],f=null,g=null;a=a.getChildren();for(let q=0;q<a.length;q++){var n=a[q];J(n)||E(209);for(let r=n.getFirstChild(),l=0;null!=r;r=r.getNextSibling()){C(r)||E(147);for(n=d(q);void 0!==n[l];)l++;n={cell:r,startColumn:l,startRow:q};let {__rowSpan:k,__colSpan:m}=r;for(let p=0;p<k&&!(q+p>=a.length);p++){let u=d(q+p);for(let t=0;t<m;t++)u[l+t]=n}null!==b&&null===f&&b.is(r)&&(f=n);null!==c&&null===g&&c.is(r)&&(g=n)}}return[e,
|
25
25
|
f,g]}function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,C),C(a)||E(148)):(a=h.$findMatchingParent(a.getNode(),C),C(a)||E(148)));let b=a.getParent();J(b)||E(149);let c=b.getParent();K(c)||E(210);return[a,b,c]}
|
26
|
-
function
|
26
|
+
function ra(a,b,c){function d(m){let {cell:p,startColumn:u,startRow:t}=m;e=Math.min(e,u);f=Math.min(f,t);g=Math.max(g,u+p.__colSpan-1);n=Math.max(n,t+p.__rowSpan-1)}let e=Math.min(b.startColumn,c.startColumn),f=Math.min(b.startRow,c.startRow),g=Math.max(b.startColumn+b.cell.__colSpan-1,c.startColumn+c.cell.__colSpan-1),n=Math.max(b.startRow+b.cell.__rowSpan-1,c.startRow+c.cell.__rowSpan-1);b=e;c=f;for(var q=e,r=f;e<b||f<c||g>q||n>r;){if(e<b){var l=r-c;--b;for(var k=0;k<=l;k++)d(a[c+k][b])}if(f<c)for(l=
|
27
27
|
q-b,--c,k=0;k<=l;k++)d(a[c][b+k]);if(g>q)for(l=r-c,q+=1,k=0;k<=l;k++)d(a[c+k][q]);if(n>r)for(l=q-b,r+=1,k=0;k<=l;k++)d(a[r][b+k])}return{maxColumn:g,maxRow:n,minColumn:e,minRow:f}}
|
28
|
-
function
|
29
|
-
function
|
30
|
-
class
|
31
|
-
a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus)}set(a,b,c){this.dirty=this.dirty||a!==this.tableKey||b!==this.anchor.key||c!==this.focus.key;this.tableKey=a;this.anchor.key=b;this.focus.key=c;this._cachedNodes=null}clone(){return new
|
32
|
-
0;this.getNodes().filter(C).forEach(c=>{c=c.getFirstChild();w.$isParagraphNode(c)&&(b|=c.getTextFormat())});return 0!==(b&w.TEXT_TYPE_TO_FORMAT[a])}insertNodes(a){let b=this.focus.getNode();w.$isElementNode(b)||E(151);w.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){let {anchorCell:a,focusCell:b}=
|
33
|
-
d.colSpan-1),g=Math.min(c.rowIndex,d.rowIndex);c=Math.max(c.rowIndex+c.rowSpan-1,d.rowIndex+d.rowSpan-1);return{fromX:Math.min(e,f),fromY:Math.min(g,c),toX:Math.max(e,f),toY:Math.max(g,c)}}getNodes(){if(!this.isValid())return[];var a=this._cachedNodes;if(null!==a)return a;let {anchorTable:b,anchorCell:c,focusCell:d}=
|
34
|
-
a.getKey(),d.getKey())),this.getNodes();let [e,f,g]=N(b,c,d),{minColumn:n,maxColumn:q,minRow:r,maxRow:l}=
|
35
|
-
a[c],e=d.__parent,f=(a[c+1]||{}).__parent;b+=d.getTextContent()+(f!==e?"\n":"\t")}return b}}function Q(a){return a instanceof
|
36
|
-
function
|
37
|
-
class
|
38
|
-
null;this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners");Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}$lookup(){return
|
28
|
+
function sa(a){let [b,,c]=P(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let f=Array(d);for(var g=0;g<d;g++)f[g]=Array(e);for(e=0;e<d;e++){g=a[e].getChildren();let n=0;for(let q=0;q<g.length;q++){for(;f[e][n];)n++;let r=g[q],l=r.__rowSpan||1,k=r.__colSpan||1;for(let m=0;m<l;m++)for(let p=0;p<k;p++)f[e+m][n+p]=r;if(b===r)return{colSpan:k,columnIndex:n,rowIndex:e,rowSpan:l};n+=k}}return null}
|
29
|
+
function ta(a){let [[b,c,d,e],[f,g,n,q]]=["anchor","focus"].map(r=>{const l=a[r].getNode(),k=h.$findMatchingParent(l,C);C(k)||E(238,r,l.getKey(),l.getType());const m=k.getParent();J(m)||E(239,r);const p=m.getParent();K(p)||E(240,r);return[l,k,m,p]});e.is(q)||E(241);return{anchorCell:c,anchorNode:b,anchorRow:d,anchorTable:e,focusCell:g,focusNode:f,focusRow:n,focusTable:q}}
|
30
|
+
class ua{constructor(a,b,c){this.anchor=b;this.focus=c;b._selection=this;c._selection=this;this._cachedNodes=null;this.dirty=!1;this.tableKey=a}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return Q(a)&&this.tableKey===
|
31
|
+
a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus)}set(a,b,c){this.dirty=this.dirty||a!==this.tableKey||b!==this.anchor.key||c!==this.focus.key;this.tableKey=a;this.anchor.key=b;this.focus.key=c;this._cachedNodes=null}clone(){return new ua(this.tableKey,w.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),w.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}hasFormat(a){let b=
|
32
|
+
0;this.getNodes().filter(C).forEach(c=>{c=c.getFirstChild();w.$isParagraphNode(c)&&(b|=c.getTextFormat())});return 0!==(b&w.TEXT_TYPE_TO_FORMAT[a])}insertNodes(a){let b=this.focus.getNode();w.$isElementNode(b)||E(151);w.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){let {anchorCell:a,focusCell:b}=ta(this);var c=sa(a);null===c&&E(153);let d=sa(b);null===d&&E(155);let e=Math.min(c.columnIndex,d.columnIndex),f=Math.max(c.columnIndex+c.colSpan-1,d.columnIndex+
|
33
|
+
d.colSpan-1),g=Math.min(c.rowIndex,d.rowIndex);c=Math.max(c.rowIndex+c.rowSpan-1,d.rowIndex+d.rowSpan-1);return{fromX:Math.min(e,f),fromY:Math.min(g,c),toX:Math.max(e,f),toY:Math.max(g,c)}}getNodes(){if(!this.isValid())return[];var a=this._cachedNodes;if(null!==a)return a;let {anchorTable:b,anchorCell:c,focusCell:d}=ta(this);a=d.getParents()[1];if(a!==b)return b.isParentOf(d)?(a=a.getParent(),null==a&&E(159),this.set(this.tableKey,d.getKey(),a.getKey())):(a=b.getParent(),null==a&&E(158),this.set(this.tableKey,
|
34
|
+
a.getKey(),d.getKey())),this.getNodes();let [e,f,g]=N(b,c,d),{minColumn:n,maxColumn:q,minRow:r,maxRow:l}=ra(e,f,g),k=new Map([[b.getKey(),b]]);a=null;for(let m=r;m<=l;m++)for(let p=n;p<=q;p++){let {cell:u}=e[m][p],t=u.getParent();J(t)||E(160);t!==a&&(k.set(t.getKey(),t),a=t);k.has(u.getKey())||va(u,v=>{k.set(v.getKey(),v)})}a=Array.from(k.values());w.isCurrentlyReadOnlyMode()||(this._cachedNodes=a);return a}getTextContent(){let a=this.getNodes().filter(c=>C(c)),b="";for(let c=0;c<a.length;c++){let d=
|
35
|
+
a[c],e=d.__parent,f=(a[c+1]||{}).__parent;b+=d.getTextContent()+(f!==e?"\n":"\t")}return b}}function Q(a){return a instanceof ua}function wa(){let a=w.$createPoint("root",0,"element"),b=w.$createPoint("root",0,"element");return new ua("root",a,b)}function va(a,b){a=[[a]];for(var c=a.at(-1);void 0!==c&&0<a.length;c=a.at(-1))c=c.pop(),void 0===c?a.pop():!1!==b(c)&&w.$isElementNode(c)&&a.push(c.getChildren())}
|
36
|
+
function xa(a,b=w.$getEditor()){let c=w.$getNodeByKey(a);K(c)||E(231,a);b=R(c,b.getElementByKey(a));null===b&&E(232,a);return{tableElement:b,tableNode:c}}
|
37
|
+
class ya{constructor(a,b){this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.table={columns:0,domRows:[],rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.shouldCheckSelection=this.isSelecting=this.hasHijackedSelectionStyles=!1;this.abortController=new AbortController;this.listenerOptions={signal:this.abortController.signal};this.nextFocus=
|
38
|
+
null;this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners");Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}$lookup(){return xa(this.tableNodeKey,this.editor)}trackTable(){let a=new MutationObserver(b=>{this.editor.getEditorState().read(()=>{let c=!1;for(let f=0;f<b.length;f++){const g=b[f].target.nodeName;if("TABLE"===g||"TBODY"===g||"THEAD"===g||"TR"===g){c=!0;break}}if(c){var {tableNode:d,tableElement:e}=
|
39
39
|
this.$lookup();this.table=S(d,e)}},{editor:this.editor})});this.editor.getEditorState().read(()=>{let {tableNode:b,tableElement:c}=this.$lookup();this.table=S(b,c);a.observe(c,{attributes:!0,childList:!0,subtree:!0})},{editor:this.editor})}$clearHighlight(){let a=this.editor;this.isHighlightingCells=!1;this.focusY=this.focusX=this.anchorY=this.anchorX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.tableSelection=null;this.hasHijackedSelectionStyles=!1;this.$enableHighlightStyle();
|
40
|
-
let {tableNode:b,tableElement:c}=this.$lookup(),d=S(b,c);
|
41
|
-
this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(a){if(null!==a){a.tableKey!==this.tableNodeKey&&E(233,a.tableKey,this.tableNodeKey);let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.$disableHighlightStyle();this.updateDOMSelection();
|
40
|
+
let {tableNode:b,tableElement:c}=this.$lookup(),d=S(b,c);za(a,d,null);null!==w.$getSelection()&&(w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){let a=this.editor,{tableElement:b}=this.$lookup();h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){let {tableElement:a}=this.$lookup();h.addClassNamesToElement(a,this.editor._config.theme.tableSelection);
|
41
|
+
this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(a){if(null!==a){a.tableKey!==this.tableNodeKey&&E(233,a.tableKey,this.tableNodeKey);let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.$disableHighlightStyle();this.updateDOMSelection();za(b,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return this.shouldCheckSelection?(this.shouldCheckSelection=!1,!0):!1}setNextFocus(a){this.nextFocus=
|
42
42
|
a}getAndClearNextFocus(){let {nextFocus:a}=this;null!==a&&(this.nextFocus=null);return a}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){let a=w.getDOMSelection(this.editor._window);a&&0<a.rangeCount&&a.removeAllRanges()}}$setFocusCellForSelection(a,b=!1){let c=this.editor,{tableNode:d}=this.$lookup();var e=a.x;let f=a.y;this.focusCell=a;if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==f||b))this.isHighlightingCells=!0,this.$disableHighlightStyle();else if(e===
|
43
|
-
this.focusX&&f===this.focusY)return!1;this.focusX=e;this.focusY=f;return this.isHighlightingCells&&(b=w.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&
|
44
|
-
void 0),
|
45
|
-
a.x;this.anchorY=a.y;a=w.$getNearestNodeFromDOMNode(a.elem);
|
46
|
-
c.formatText(a,n)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=w.$getNodeByKey(this.tableNodeKey);if(!K(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||E(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),w.$getRoot().selectStart()):(c.forEach(d=>{if(w.$isElementNode(d)){let e=w.$createParagraphNode(),f=
|
47
|
-
{g!==e&&g.remove()})}}),
|
43
|
+
this.focusX&&f===this.focusY)return!1;this.focusX=e;this.focusY=f;return this.isHighlightingCells&&(b=T(d,w.$getNearestNodeFromDOMNode(a.elem,void 0)),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==b)?(this.focusCellNodeKey=b.getKey(),a=this.$getAnchorTableCellOrThrow(),d.getKey(),a.getKey(),b.getKey(),e=w.$getSelection(),e=Q(e)?e.clone():wa(),e.set(d.getKey(),a.getKey(),b.getKey()),this.tableSelection=e,w.$setSelection(this.tableSelection),c.dispatchCommand(w.SELECTION_CHANGE_COMMAND,
|
44
|
+
void 0),za(c,this.table,this.tableSelection),!0):!1}$getAnchorTableCell(){return this.anchorCellNodeKey?w.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let a=this.$getAnchorTableCell();null===a&&E(234);return a}$getFocusTableCell(){return this.focusCellNodeKey?w.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let a=this.$getFocusTableCell();null===a&&E(235);return a}$setAnchorCellForSelection(a){this.isHighlightingCells=!1;this.anchorCell=a;this.anchorX=
|
45
|
+
a.x;this.anchorY=a.y;let {tableNode:b}=this.$lookup();a=T(b,w.$getNearestNodeFromDOMNode(a.elem,void 0));null!==a&&(a=a.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():wa(),this.anchorCellNodeKey=a)}$formatCells(a){let b=w.$getSelection();Q(b)||E(236);let c=w.$createRangeSelection(),d=c.anchor,e=c.focus,f=b.getNodes().filter(C);0<f.length||E(237);let g=f[0].getFirstChild(),n=w.$isParagraphNode(g)?g.getFormatFlags(a,null):null;f.forEach(q=>{d.set(q.getKey(),0,"element");
|
46
|
+
e.set(q.getKey(),q.getChildrenSize(),"element");c.formatText(a,n)});w.$setSelection(b);this.editor.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){let {editor:a}=this,b=w.$getNodeByKey(this.tableNodeKey);if(!K(b))throw Error("Expected TableNode.");var c=w.$getSelection();Q(c)||E(11);c=c.getNodes().filter(C);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),w.$getRoot().selectStart()):(c.forEach(d=>{if(w.$isElementNode(d)){let e=w.$createParagraphNode(),f=
|
47
|
+
w.$createTextNode();e.append(f);d.append(e);d.getChildren().forEach(g=>{g!==e&&g.remove()})}}),za(a,this.table,null),w.$setSelection(null),a.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))}}function R(a,b){if(!b)return b;a="TABLE"===b.nodeName?b:a.getDOMSlot(b).element;"TABLE"!==a.nodeName&&E(245,b.nodeName);return a}function T(a,b){for(let c=b,d=null;null!==c;c=c.getParent()){if(a.is(c))return d;C(c)&&(d=c)}return null}
|
48
48
|
let Aa=[[w.KEY_ARROW_DOWN_COMMAND,"down"],[w.KEY_ARROW_UP_COMMAND,"up"],[w.KEY_ARROW_LEFT_COMMAND,"backward"],[w.KEY_ARROW_RIGHT_COMMAND,"forward"]],Ba=[w.DELETE_WORD_COMMAND,w.DELETE_LINE_COMMAND,w.DELETE_CHARACTER_COMMAND],Ca=[w.KEY_BACKSPACE_COMMAND,w.KEY_DELETE_COMMAND];function Da(a,b){null!==Ea(a)&&E(205);a.__lexicalTableSelection=b}function Ea(a){return a.__lexicalTableSelection||null}
|
49
49
|
function Fa(a){for(;null!=a;){let b=a.nodeName;if("TD"===b||"TH"===b){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null}
|
50
50
|
function S(a,b){var c=R(a,b);a=[];b={columns:0,domRows:a,rows:0};var d=c.querySelector("tr");let e=c=0;for(a.length=0;null!=d;){var f=d.nodeName;if("TD"===f||"TH"===f){f=d;f={elem:f,hasBackgroundColor:""!==f.style.backgroundColor,highlighted:!1,x:c,y:e};d._cell=f;let g=a[e];void 0===g&&(g=a[e]=[]);g[c]=f}else if(f=d.firstChild,null!=f){d=f;continue}f=d.nextSibling;if(null!=f)c++,d=f;else if(f=d.parentNode,null!=f){d=f.nextSibling;if(null==d)break;e++;c=0}}b.columns=c+1;b.rows=e+1;return b}
|
51
|
-
function
|
51
|
+
function za(a,b,c){let d=new Set(c?c.getNodes():[]);Ga(b,(e,f)=>{let g=e.elem;d.has(f)?(e.highlighted=!0,Ha(a,e)):(e.highlighted=!1,Ia(a,e),g.getAttribute("style")||g.removeAttribute("style"))})}function Ga(a,b){({domRows:a}=a);for(let c=0;c<a.length;c++){let d=a[c];if(d)for(let e=0;e<d.length;e++){let f=d[e];if(!f)continue;let g=w.$getNearestNodeFromDOMNode(f.elem);null!==g&&b(f,g,{x:e,y:c})}}}function Ja(a,b){b.$disableHighlightStyle();Ga(b.table,c=>{c.highlighted=!0;Ha(a,c)})}
|
52
52
|
function Ka(a,b){b.$enableHighlightStyle();Ga(b.table,c=>{let d=c.elem;c.highlighted=!1;Ia(a,c);d.getAttribute("style")||d.removeAttribute("style")})}
|
53
53
|
let La=(a,b,c,d,e)=>{const f="forward"===e;switch(e){case "backward":case "forward":return c!==(f?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(f?1:-1),d,a.table),f?a.selectStart():a.selectEnd()):d!==(f?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(f?0:a.table.columns-1,d+(f?1:-1),a.table),f?a.selectStart():a.selectEnd()):f?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==d?b.getCellNodeFromCordsOrThrow(c,d-1,a.table).selectEnd():b.selectPrevious(),!0;case "down":return d!==
|
54
|
-
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}};function
|
55
|
-
function U(a,b,[c,d]){let e=b[d];a=a[e];void 0===a&&E(
|
56
|
-
function Pa(a,b,c,d,e){d=
|
57
|
-
"maxColumn"===D?1:v:"backward"===e?r-="minColumn"===D?1:z:"down"===e?d+="maxRow"===G?1:t:"up"===e&&(d-="minRow"===G?1:B);e=b[d];if(void 0===e)return!1;d=e[r];if(void 0===d)return!1;e=
|
54
|
+
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}};function Na(a,b){let c;if(b.startColumn===a.minColumn)c="minColumn";else if(b.startColumn+b.cell.__colSpan-1===a.maxColumn)c="maxColumn";else return null;if(b.startRow===a.minRow)a="minRow";else if(b.startRow+b.cell.__rowSpan-1===a.maxRow)a="maxRow";else return null;return[c,a]}function Oa([a,b]){return["minColumn"===a?"maxColumn":"minColumn","minRow"===b?"maxRow":"minRow"]}
|
55
|
+
function U(a,b,[c,d]){let e=b[d];a=a[e];void 0===a&&E(250,d,String(e));b=b[c];d=a[b];void 0===d&&E(250,c,String(b));return d}
|
56
|
+
function Pa(a,b,c,d,e){d=ra(b,c,d);let {minColumn:f,maxColumn:g,minRow:n,maxRow:q}=d;var r=1;let l=1,k=1,m=1;var p=b[n];let u=b[q];for(let O=f;O<=g;O++)r=Math.max(r,p[O].cell.__rowSpan),m=Math.max(m,u[O].cell.__rowSpan);for(p=n;p<=q;p++)l=Math.max(l,b[p][f].cell.__colSpan),k=Math.max(k,b[p][g].cell.__colSpan);let {topSpan:t,leftSpan:v,bottomSpan:B,rightSpan:z}={bottomSpan:m,leftSpan:l,rightSpan:k,topSpan:r};r=Na(d,c);null===r&&E(249,c.cell.getKey());let [D,G]=Oa(r);r=d[D];d=d[G];"forward"===e?r+=
|
57
|
+
"maxColumn"===D?1:v:"backward"===e?r-="minColumn"===D?1:z:"down"===e?d+="maxRow"===G?1:t:"up"===e&&(d-="minRow"===G?1:B);e=b[d];if(void 0===e)return!1;d=e[r];if(void 0===d)return!1;e=ra(b,c,d);(c=Na(e,c))?b=[U(b,e,c),U(b,e,Oa(c))]:(c=Na(e,d))?b=[U(b,e,Oa(c)),U(b,e,c)]:(c=["minColumn","minRow"],b=[U(b,e,c),U(b,e,Oa(c))]);let [H,L]=b;b=V(a,H.cell);c=V(a,L.cell);a.$setAnchorCellForSelection(b);a.$setFocusCellForSelection(c,!0);return!0}
|
58
58
|
function W(a,b){if(w.$isRangeSelection(a)||Q(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}function Ha(a,b){b=b.elem;a=a._config.theme;let c=w.$getNearestNodeFromDOMNode(b);C(c)||E(131);h.addClassNamesToElement(b,a.tableCellSelected)}function Ia(a,b){b=b.elem;let c=w.$getNearestNodeFromDOMNode(b);C(c)||E(131);h.removeClassNamesFromElement(b,a._config.theme.tableCellSelected)}function X(a){a=h.$findMatchingParent(a,C);return C(a)?a:null}
|
59
|
-
function
|
60
|
-
function Ra(a,b,c,d,e){if(("up"===c||"down"===c)&&Sa(a))return!1;var f=w.$getSelection();if(!W(f,d)){if(w.$isRangeSelection(f)){if("backward"===c){if(0<f.focus.offset)return!1;c=Qa(f.focus.getNode());if(!c)return!1;c=c.getPreviousSibling();if(!K(c))return!1;
|
61
|
-
h.$findMatchingParent(g,r=>K(r));C(e)&&(e=h.$findMatchingParent(e,K));if(e!==d||!e)return!1;d="down"===c?e.getNextSibling():e.getPreviousSibling();if(!d)return!1;e=0;"up"===c&&w.$isElementNode(d)&&(e=d.getChildrenSize());a=d;"up"===c&&w.$isElementNode(d)&&(a=(c=d.getLastChild())?c:d,e=w.$isTextNode(a)?a.getTextContentSize():0);c=f.clone();c.focus.set(a.getKey(),e,w.$isTextNode(a)?"text":"element");w.$setSelection(c);
|
62
|
-
1]:f.getNodes()[0])&&(
|
63
|
-
|
64
|
-
|
65
|
-
f
|
66
|
-
|
67
|
-
function
|
59
|
+
function Y(a){a=h.$findMatchingParent(a,K);return K(a)?a:null}function Qa(a){for(let b=a,c=a;null!==c;b=c,c=c.getParent())if(w.$isElementNode(c))if(c!==b&&c.getFirstChild()!==b)break;else if(!c.isInline())return c;return null}
|
60
|
+
function Ra(a,b,c,d,e){if(("up"===c||"down"===c)&&Sa(a))return!1;var f=w.$getSelection();if(!W(f,d)){if(w.$isRangeSelection(f)){if("backward"===c){if(0<f.focus.offset)return!1;c=Qa(f.focus.getNode());if(!c)return!1;c=c.getPreviousSibling();if(!K(c))return!1;Z(b);b.shiftKey?f.focus.set(c.getParentOrThrow().getKey(),c.getIndexWithinParent(),"element"):c.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c)){var g=f.focus.getNode();if(!f.isCollapsed()&&("up"===c&&!f.isBackward()||"down"===c&&f.isBackward())){e=
|
61
|
+
h.$findMatchingParent(g,r=>K(r));C(e)&&(e=h.$findMatchingParent(e,K));if(e!==d||!e)return!1;d="down"===c?e.getNextSibling():e.getPreviousSibling();if(!d)return!1;e=0;"up"===c&&w.$isElementNode(d)&&(e=d.getChildrenSize());a=d;"up"===c&&w.$isElementNode(d)&&(a=(c=d.getLastChild())?c:d,e=w.$isTextNode(a)?a.getTextContentSize():0);c=f.clone();c.focus.set(a.getKey(),e,w.$isTextNode(a)?"text":"element");w.$setSelection(c);Z(b);return!0}if(w.$isRootOrShadowRoot(g)){if((b="up"===c?f.getNodes()[f.getNodes().length-
|
62
|
+
1]:f.getNodes()[0])&&null!==T(d,b)){c=d.getFirstDescendant();b=d.getLastDescendant();if(!c||!b)return!1;[c]=P(c);[b]=P(b);c=d.getCordsFromCellNode(c,e.table);b=d.getCordsFromCellNode(b,e.table);c=d.getDOMCellFromCordsOrThrow(c.x,c.y,e.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,e.table);e.$setAnchorCellForSelection(c);e.$setFocusCellForSelection(b,!0);return!0}return!1}d=h.$findMatchingParent(g,r=>w.$isElementNode(r)&&!r.isInline());C(d)&&(d=h.$findMatchingParent(d,K));if(!d)return!1;d="down"===
|
63
|
+
c?d.getNextSibling():d.getPreviousSibling();if(K(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();a=d.getLastDescendant();if(!e||!a)return!1;[d]=P(e);[e]=P(a);f=f.clone();f.focus.set(("up"===c?d:e).getKey(),"up"===c?0:e.getChildrenSize(),"element");Z(b);w.$setSelection(f);return!0}}}"down"===c&&Ta(a)&&e.setShouldCheckSelection();return!1}if(w.$isRangeSelection(f)&&f.isCollapsed()){let {anchor:r,focus:l}=f;g=h.$findMatchingParent(r.getNode(),C);var n=h.$findMatchingParent(l.getNode(),C);if(!C(g)||
|
64
|
+
!g.is(n))return!1;n=Y(g);if(n!==d&&null!=n){var q=R(n,a.getElementByKey(n.getKey()));if(null!=q)return e.table=S(n,q),Ra(a,b,c,n,e)}if("backward"===c||"forward"===c){e=r.type;a=r.offset;n=r.getNode();if(!n)return!1;f=f.getNodes();return 1===f.length&&w.$isDecoratorNode(f[0])?!1:Ua(e,a,n,c)?Va(b,n,g,d,c):!1}f=a.getElementByKey(g.__key);n=a.getElementByKey(r.key);if(null==n||null==f)return!1;if("element"===r.type)f=n.getBoundingClientRect();else{f=w.getDOMSelection(a._window);if(null===f||0===f.rangeCount)return!1;
|
65
|
+
f=f.getRangeAt(0).getBoundingClientRect()}n="up"===c?g.getFirstChild():g.getLastChild();if(null==n)return!1;a=a.getElementByKey(n.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>f.top-f.height:f.bottom+f.height>a.bottom){Z(b);f=d.getCordsFromCellNode(g,e.table);if(b.shiftKey)b=d.getDOMCellFromCordsOrThrow(f.x,f.y,e.table),e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(b,!0);else return La(e,d,f.x,f.y,c);return!0}}else if(Q(f)){let {anchor:r,focus:l}=f;g=h.$findMatchingParent(r.getNode(),
|
66
|
+
C);n=h.$findMatchingParent(l.getNode(),C);[q]=f.getNodes();K(q)||E(251);a=R(q,a.getElementByKey(q.getKey()));if(!C(g)||!C(n)||!K(q)||null==a)return!1;e.$updateTableTableSelection(f);f=S(q,a);a=d.getCordsFromCellNode(g,f);f=d.getDOMCellFromCordsOrThrow(a.x,a.y,f);e.$setAnchorCellForSelection(f);Z(b);if(b.shiftKey){let [k,m,p]=N(d,g,n);return Pa(e,k,m,p,c)}n.selectEnd();return!0}return!1}function Z(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
|
67
|
+
function Sa(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Ua(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Wa(a,b,c,d)}
|
68
68
|
function Wa(a,b,c,d){let e=h.$findMatchingParent(c,f=>w.$isElementNode(f)&&!f.isInline());if(!e)return!1;b="backward"===d?0===b:b===c.getTextContentSize();return"text"===a&&b&&("backward"===d?null===e.getPreviousSibling():null===e.getNextSibling())}
|
69
|
-
function Va(a,b,c,d,e){let [f,g]=N(d,c,c);c=f[0][0];let n=f[f.length-1][f[0].length-1],{startColumn:q,startRow:r}=g;if("backward"===e?q!==c.startColumn||r!==c.startRow:q!==n.startColumn||r!==n.startRow)return!1;b=Xa(b,e,d);if(!b||K(b))return!1;
|
69
|
+
function Va(a,b,c,d,e){let [f,g]=N(d,c,c);c=f[0][0];let n=f[f.length-1][f[0].length-1],{startColumn:q,startRow:r}=g;if("backward"===e?q!==c.startColumn||r!==c.startRow:q!==n.startColumn||r!==n.startRow)return!1;b=Xa(b,e,d);if(!b||K(b))return!1;Z(a);"backward"===e?b.selectEnd():b.selectStart();return!0}
|
70
70
|
function Xa(a,b,c){if(a=h.$findMatchingParent(a,d=>w.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&K(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ya(a,b,c){let d=w.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()}
|
71
71
|
function Za(a,b,c){var d=c.getParent();if(d){var e=w.getDOMSelection(a._window);if(e&&(e=e.anchorNode,d=a.getElementByKey(d.getKey()),a=R(c,a.getElementByKey(c.getKey())),e&&d&&a&&d.contains(e)&&!a.contains(e)&&(b=h.$findMatchingParent(b.anchor.getNode(),r=>C(r))))&&(a=h.$findMatchingParent(b,r=>K(r)),K(a)&&a.is(c))){var [f,g]=N(c,b,b);c=f[0][0];b=f[f.length-1][f[0].length-1];var {startRow:n,startColumn:q}=g;if(n===c.startRow&&q===c.startColumn)return"first";if(n===b.startRow&&q===b.startColumn)return"last"}}}
|
72
72
|
function V(a,b){let {tableNode:c}=a.$lookup();b=c.getCordsFromCellNode(b,a.table);return c.getDOMCellFromCordsOrThrow(b.x,b.y,a.table)}function $a(a,b,c,d){if(a=a.querySelector("colgroup")){b=[];for(let e=0;e<c;e++){let f=document.createElement("col"),g=d&&d[e];g&&(f.style.width=`${g}px`);b.push(f)}a.replaceChildren(...b)}}
|
@@ -74,44 +74,45 @@ function ab(a,b,c){c?(h.addClassNamesToElement(a,b.theme.tableRowStriping),a.set
|
|
74
74
|
class cb extends w.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(a){let b=this.getWritable();b.__colWidths=a;return b}static clone(a){return new cb(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__colWidths=a.__colWidths;this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:db,priority:1})}}static importJSON(a){let b=eb();b.__rowStriping=a.rowStriping||!1;b.__colWidths=a.colWidths;return b}constructor(a){super(a);
|
75
75
|
this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}getDOMSlot(a){a="TABLE"!==a.nodeName&&a.querySelector("table")||a;"TABLE"!==a.nodeName&&E(229);return super.getDOMSlot(a).withAfter(a.querySelector("colgroup"))}createDOM(a,b){let c=document.createElement("table"),d=document.createElement("colgroup");c.appendChild(d);$a(c,a,this.getColumnCount(),this.getColWidths());w.setDOMUnmanaged(d);
|
76
76
|
h.addClassNamesToElement(c,a.theme.table);this.__rowStriping&&ab(c,a,!0);return Ta(b)?(b=document.createElement("div"),(a=a.theme.tableScrollableWrapper)?h.addClassNamesToElement(b,a):b.style.cssText="overflow-x: auto;",b.appendChild(c),b):c}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&ab(b,c,this.__rowStriping);$a(b,c,this.getColumnCount(),this.getColWidths());return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{b&&h.isHTMLElement(b)&&"TABLE"!==b.nodeName&&(b=b.querySelector("table"));
|
77
|
-
if(!b||!h.isHTMLElement(b))return null;let c=b.querySelectorAll(":scope > tr");if(0<c.length){let d=document.createElement("tbody");d.append(...c);b.append(d)}return b}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){
|
78
|
-
if(null==b)return null;a=b[a<b.length?a:b.length-1];return null==a?null:a}getDOMCellFromCordsOrThrow(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=w.$getNearestNodeFromDOMNode(a.elem);return C(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(a){this.getWritable().__rowStriping=
|
79
|
-
a}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let a=this.getFirstChild();if(!a)return 0;let b=0;a.getChildren().forEach(c=>{C(c)&&(b+=c.getColSpan())});return b}}function db(a){let b=eb();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);var c=a.querySelector(":scope > colgroup");if(c){a=[];for(let d of c.querySelectorAll(":scope > col")){c=d.style.width;if(!c||!
|
80
|
-
function eb(){return w.$applyNodeReplacement(new cb)}function K(a){return a instanceof cb}exports.$computeTableMap=N;exports.$computeTableMapSkipCellCheck=
|
81
|
-
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=eb();for(let f=0;f<a;f++){let g=I();for(let n=0;n<b;n++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===n&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===n&&(e|=x.COLUMN));e=A(e);let q=w.$createParagraphNode();q.append(w.$createTextNode());e.append(q);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=I;exports.$createTableSelection=
|
77
|
+
if(!b||!h.isHTMLElement(b))return null;let c=b.querySelectorAll(":scope > tr");if(0<c.length){let d=document.createElement("tbody");d.append(...c);b.append(d)}return b}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){let f=d[b];if(null!=f)for(let g=0;g<f.length;g++){var e=f[g];if(null!=e&&({elem:e}=e,e=T(this,w.$getNearestNodeFromDOMNode(e,void 0)),null!==e&&a.is(e)))return{x:g,y:b}}}throw Error("Cell not found in table.");}getDOMCellFromCords(a,
|
78
|
+
b,c){({domRows:c}=c);b=c[b];if(null==b)return null;a=b[a<b.length?a:b.length-1];return null==a?null:a}getDOMCellFromCordsOrThrow(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,c){a=this.getDOMCellFromCords(a,b,c);if(null==a)return null;a=w.$getNearestNodeFromDOMNode(a.elem);return C(a)?a:null}getCellNodeFromCordsOrThrow(a,b,c){a=this.getCellNodeFromCords(a,b,c);if(!a)throw Error("Node at cords not TableCellNode.");return a}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(a){this.getWritable().__rowStriping=
|
79
|
+
a}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){let a=this.getFirstChild();if(!a)return 0;let b=0;a.getChildren().forEach(c=>{C(c)&&(b+=c.getColSpan())});return b}}function db(a){let b=eb();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);var c=a.querySelector(":scope > colgroup");if(c){a=[];for(let d of c.querySelectorAll(":scope > col")){c=d.style.width;if(!c||!ca.test(c)){a=void 0;break}a.push(parseFloat(c))}a&&b.setColWidths(a)}return{node:b}}
|
80
|
+
function eb(){return w.$applyNodeReplacement(new cb)}function K(a){return a instanceof cb}exports.$computeTableMap=N;exports.$computeTableMapSkipCellCheck=qa;exports.$createTableCellNode=A;exports.$createTableNode=eb;
|
81
|
+
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=eb();for(let f=0;f<a;f++){let g=I();for(let n=0;n<b;n++){var e=x.NO_STATUS;"object"===typeof c?(0===f&&c.rows&&(e|=x.ROW),0===n&&c.columns&&(e|=x.COLUMN)):c&&(0===f&&(e|=x.ROW),0===n&&(e|=x.COLUMN));e=A(e);let q=w.$createParagraphNode();q.append(w.$createTextNode());e.append(q);g.append(e)}d.append(g)}return d};exports.$createTableRowNode=I;exports.$createTableSelection=wa;
|
82
82
|
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];if(J(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};
|
83
83
|
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);var [e]=P(a);let [f,g,n]=N(d,c,e);var {startColumn:q}=g;let {startRow:r,startColumn:l}=n;b=Math.min(q,l);var k=Math.max(q+c.__colSpan-1,l+e.__colSpan-1);a=k-b+1;if(f[0].length===k-b+1)d.selectPrevious(),d.remove();else{var m=f.length;for(let p=0;p<m;p++)for(let u=b;u<=k;u++){let {cell:t,startColumn:v}=f[p][u];v<b?u===b&&t.setColSpan(t.__colSpan-
|
84
84
|
Math.min(a,t.__colSpan-(b-v))):v+t.__colSpan-1>k?u===k&&t.setColSpan(t.__colSpan-(k-v+1)):t.remove()}k=f[r];e=q>l?k[q+c.__colSpan]:k[l+e.__colSpan];void 0!==e?({cell:q}=e,M(q)):({cell:q}=l<q?k[l-1]:k[q-1],M(q));if(q=d.getColWidths())q=[...q],q.splice(b,a),d.setColWidths(q)}};
|
85
85
|
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);let [b,c]=a.isBackward()?[a.focus.getNode(),a.anchor.getNode()]:[a.anchor.getNode(),a.focus.getNode()],[d,,e]=P(b);var [f]=P(c);let [g,n,q]=N(e,d,f);({startRow:a}=n);var {startRow:r}=q;f=r+f.__rowSpan-1;if(g.length===f-a+1)e.remove();else{r=g[0].length;var l=g[f+1],k=e.getChildAtIndex(f+1);for(let p=f;p>=a;p--){for(var m=r-1;0<=m;m--){let {cell:u,startRow:t,startColumn:v}=g[p][m];if(v===m&&
|
86
|
-
(p===a&&t<a&&u.setRowSpan(u.__rowSpan-(t-a)),t>=a&&t+u.__rowSpan-1>f))if(u.setRowSpan(u.__rowSpan-(f-t+1)),null===k&&E(122),0===m)
|
87
|
-
exports.$getTableAndElementByKey=
|
88
|
-
exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let r=0;r<f.length;r++){let l=f[r];if(J(l))for(let k=0;k<d;k++){var n=l.getChildren();if(b>=n.length||0>b)throw Error("Table column target index out of range");n=n[b];C(n)||E(12);let {left:m,right:p}=
|
86
|
+
(p===a&&t<a&&u.setRowSpan(u.__rowSpan-(t-a)),t>=a&&t+u.__rowSpan-1>f))if(u.setRowSpan(u.__rowSpan-(f-t+1)),null===k&&E(122),0===m)pa(k,u);else{let {cell:B}=l[m-1];B.insertAfter(u)}}m=e.getChildAtIndex(p);J(m)||E(206,String(p));m.remove()}void 0!==l?({cell:a}=l[0],M(a)):({cell:a}=g[a-1][0],M(a))}};exports.$findCellNode=X;exports.$findTableNode=Y;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());null===a&&E(230);return S(b,a)};exports.$getNodeTriplet=P;
|
87
|
+
exports.$getTableAndElementByKey=xa;exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>C(b));return C(a)?a:null};exports.$getTableCellNodeRect=sa;exports.$getTableColumnIndexFromTableCellNode=function(a){return la(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ma;exports.$getTableRowIndexFromTableCellNode=function(a){let b=la(a);return ma(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=la;
|
88
|
+
exports.$insertTableColumn=function(a,b,c=!0,d,e){let f=a.getChildren(),g=[];for(let r=0;r<f.length;r++){let l=f[r];if(J(l))for(let k=0;k<d;k++){var n=l.getChildren();if(b>=n.length||0>b)throw Error("Table column target index out of range");n=n[b];C(n)||E(12);let {left:m,right:p}=na(n,e);var q=x.NO_STATUS;if(m&&m.hasHeaderState(x.ROW)||p&&p.hasHeaderState(x.ROW))q|=x.ROW;q=A(q);q.append(w.$createParagraphNode());g.push({newTableCell:q,targetCell:n})}}g.forEach(({newTableCell:r,targetCell:l})=>{c?
|
89
89
|
l.insertAfter(r):l.insertBefore(r)});return a};
|
90
90
|
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=A(k).append(w.$createParagraphNode());null===r&&(r=k);return k}var c=w.$getSelection();w.$isRangeSelection(c)||Q(c)||E(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [e,,f]=P(c),[g,n,q]=N(f,e,d);d=g.length;c=a?Math.max(n.startColumn,q.startColumn):Math.min(n.startColumn,q.startColumn);a=a?c+e.__colSpan-1:c-1;c=f.getFirstChild();J(c)||E(120);let r=null;var l=c;a:for(c=0;c<d;c++){0!==c&&(l=l.getNextSibling(),
|
91
|
-
J(l)||E(121));let k=g[c],m=
|
92
|
-
exports.$insertTableRow=function(a,b,c=!0,d,e){var f=a.getChildren();if(b>=f.length||0>b)throw Error("Table row target index out of range");b=f[b];if(J(b))for(f=0;f<d;f++){let n=b.getChildren(),q=n.length,r=I();for(let l=0;l<q;l++){var g=n[l];C(g)||E(12);let {above:k,below:m}=
|
91
|
+
J(l)||E(121));let k=g[c],m=oa(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){pa(l,b(m));continue}let {cell:p,startColumn:u,startRow:t}=k[a];if(u+p.__colSpan-1<=a){let v=p,B=t,z=a;for(;B!==c&&1<v.__rowSpan;)if(z-=p.__colSpan,0<=z){let {cell:D,startRow:G}=k[z];v=D;B=G}else{l.append(b(m));continue a}v.insertAfter(b(m))}else p.setColSpan(p.__colSpan+1)}null!==r&&M(r);if(d=f.getColWidths())d=[...d],a=0>a?0:a,d.splice(a,0,d[a]),f.setColWidths(d);return r};
|
92
|
+
exports.$insertTableRow=function(a,b,c=!0,d,e){var f=a.getChildren();if(b>=f.length||0>b)throw Error("Table row target index out of range");b=f[b];if(J(b))for(f=0;f<d;f++){let n=b.getChildren(),q=n.length,r=I();for(let l=0;l<q;l++){var g=n[l];C(g)||E(12);let {above:k,below:m}=na(g,e);g=x.NO_STATUS;let p=k&&k.getWidth()||m&&m.getWidth()||void 0;if(k&&k.hasHeaderState(x.COLUMN)||m&&m.hasHeaderState(x.COLUMN))g|=x.COLUMN;g=A(g,1,p);g.append(w.$createParagraphNode());r.append(g)}c?b.insertAfter(r):b.insertBefore(r)}else throw Error("Row before insertion index does not exist.");
|
93
93
|
return a};
|
94
|
-
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=w.$getSelection();w.$isRangeSelection(b)||Q(b)||E(188);b=b.focus.getNode();let [c,,d]=P(b),[e,f]=N(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var n=e[a];g=I();for(var q=0;q<b;q++){let {cell:l,startRow:k}=n[q];if(k+l.__rowSpan-1<=a){var r=
|
95
|
-
a=I();for(q=0;q<b;q++){let {cell:l,startRow:k}=n[q];k===g?(r=
|
94
|
+
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=w.$getSelection();w.$isRangeSelection(b)||Q(b)||E(188);b=b.focus.getNode();let [c,,d]=P(b),[e,f]=N(d,c,c);b=e[0].length;var {startRow:g}=f;if(a){a=g+c.__rowSpan-1;var n=e[a];g=I();for(var q=0;q<b;q++){let {cell:l,startRow:k}=n[q];if(k+l.__rowSpan-1<=a){var r=oa(n[q].cell.__headerState,x.COLUMN);g.append(A(r).append(w.$createParagraphNode()))}else l.setRowSpan(l.__rowSpan+1)}b=d.getChildAtIndex(a);J(b)||E(145);b.insertAfter(g);b=g}else{n=e[g];
|
95
|
+
a=I();for(q=0;q<b;q++){let {cell:l,startRow:k}=n[q];k===g?(r=oa(n[q].cell.__headerState,x.COLUMN),a.append(A(r).append(w.$createParagraphNode()))):l.setRowSpan(l.__rowSpan+1)}b=d.getChildAtIndex(g);J(b)||E(145);b.insertBefore(a);b=a}return b};exports.$isScrollableTablesActive=Ta;exports.$isTableCellNode=C;exports.$isTableNode=K;exports.$isTableRowNode=J;exports.$isTableSelection=Q;
|
96
96
|
exports.$removeTableRowAtIndex=function(a,b){let c=a.getChildren();if(b>=c.length||0>b)throw Error("Expected table cell to be inside of table row.");c[b].remove();return a};
|
97
97
|
exports.$unmergeCell=function(){var a=w.$getSelection();w.$isRangeSelection(a)||Q(a)||E(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let e=b.__rowSpan;if(1!==a||1!==e){var [f,g]=N(d,b,b),{startColumn:n,startRow:q}=g,r=b.__headerState&x.COLUMN,l=Array.from({length:a},(v,B)=>{v=r;for(let z=0;0!==v&&z<f.length;z++)v&=f[z][B+n].cell.__headerState;return v}),k=b.__headerState&x.ROW,m=Array.from({length:e},(v,B)=>{v=k;for(let z=0;0!==v&&z<f[0].length;z++)v&=f[B+q][z].cell.__headerState;return v});
|
98
|
-
if(1<a){for(var p=1;p<a;p++)b.insertAfter(A(l[p]|m[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let v;for(p=1;p<e;p++){var u=q+p;let B=f[u];v=(v||c).getNextSibling();J(v)||E(125);var t=null;for(let z=0;z<n;z++){let D=B[z],G=D.cell;D.startRow===u&&(t=G);1<G.__colSpan&&(z+=G.__colSpan-1)}if(null===t)for(t=a-1;0<=t;t--)
|
99
|
-
exports.INSERT_TABLE_COMMAND=
|
100
|
-
exports.applyTableHandlers=function(a,b,c,d){let e=c.getRootElement(),f=c._window;null!==e&&null!==f||E(246);let g=new
|
98
|
+
if(1<a){for(var p=1;p<a;p++)b.insertAfter(A(l[p]|m[0]).append(w.$createParagraphNode()));b.setColSpan(1)}if(1<e){let v;for(p=1;p<e;p++){var u=q+p;let B=f[u];v=(v||c).getNextSibling();J(v)||E(125);var t=null;for(let z=0;z<n;z++){let D=B[z],G=D.cell;D.startRow===u&&(t=G);1<G.__colSpan&&(z+=G.__colSpan-1)}if(null===t)for(t=a-1;0<=t;t--)pa(v,A(l[t]|m[p]).append(w.$createParagraphNode()));else for(u=a-1;0<=u;u--)t.insertAfter(A(l[u]|m[p]).append(w.$createParagraphNode()))}b.setRowSpan(1)}}};
|
99
|
+
exports.INSERT_TABLE_COMMAND=ea;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=cb;exports.TableObserver=ya;exports.TableRowNode=ja;
|
100
|
+
exports.applyTableHandlers=function(a,b,c,d){let e=c.getRootElement(),f=c._window;null!==e&&null!==f||E(246);let g=new ya(c,a.getKey()),n=R(a,b);Da(n,g);g.listenersToRemove.add(()=>{Ea(n)===g&&delete n.__lexicalTableSelection});let q=()=>{if(!g.isSelecting){var l=()=>{g.isSelecting=!1;f.removeEventListener("mouseup",l);f.removeEventListener("mousemove",k)},k=m=>{if(1!==(m.buttons&1)&&g.isSelecting)g.isSelecting=!1,f.removeEventListener("mouseup",l),f.removeEventListener("mousemove",k);else{var p=
|
101
101
|
!n.contains(m.target),u=null;if(p)for(const t of document.elementsFromPoint(m.clientX,m.clientY)){if(u=n.contains(t)?Fa(t):null)break}else u=Fa(m.target);!u||null!==g.focusCell&&u.elem===g.focusCell.elem||(g.setNextFocus({focusCell:u,override:p}),c.dispatchCommand(w.SELECTION_CHANGE_COMMAND,void 0))}};g.isSelecting=!0;f.addEventListener("mouseup",l,g.listenerOptions);f.addEventListener("mousemove",k,g.listenerOptions)}};n.addEventListener("mousedown",l=>{if(0===l.button&&f){var k=Fa(l.target);null!==
|
102
|
-
k&&c.update(()=>{const m=w.$getPreviousSelection();if(
|
103
|
-
Q(k)&&k.tableKey===g.tableNodeKey&&e.contains(m)&&g.$clearHighlight()})},g.listenerOptions);for(let [l,k]of Aa)g.listenersToRemove.add(c.registerCommand(l,m=>Ra(c,m,k,a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,l=>{var k=w.$getSelection();return Q(k)&&(k=
|
104
|
-
|
102
|
+
k&&c.update(()=>{const m=w.$getPreviousSelection();if(ia&&l.shiftKey&&W(m,a)&&(w.$isRangeSelection(m)||Q(m))){const p=m.anchor.getNode(),u=T(a,m.anchor.getNode());u?(g.$setAnchorCellForSelection(V(g,u)),g.$setFocusCellForSelection(k),Z(l)):(a.isBefore(p)?a.selectStart():a.selectEnd()).anchor.set(m.anchor.key,m.anchor.offset,m.anchor.type)}else g.$setAnchorCellForSelection(k)});q()}},g.listenerOptions);f.addEventListener("mousedown",l=>{0===l.button&&c.update(()=>{const k=w.$getSelection(),m=l.target;
|
103
|
+
Q(k)&&k.tableKey===g.tableNodeKey&&e.contains(m)&&g.$clearHighlight()})},g.listenerOptions);for(let [l,k]of Aa)g.listenersToRemove.add(c.registerCommand(l,m=>Ra(c,m,k,a,g),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.KEY_ESCAPE_COMMAND,l=>{var k=w.$getSelection();return Q(k)&&(k=T(a,k.focus.getNode()),null!==k)?(Z(l),k.selectEnd(),!0):!1},w.COMMAND_PRIORITY_HIGH));b=l=>()=>{var k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))return g.$clearText(),!0;if(w.$isRangeSelection(k)){var m=
|
104
|
+
T(a,k.anchor.getNode());if(!C(m))return!1;var p=k.anchor.getNode();m=k.focus.getNode();p=a.isParentOf(p);m=a.isParentOf(m);if(p&&!m||m&&!p)return g.$clearText(),!0;m=(k=h.$findMatchingParent(k.anchor.getNode(),u=>w.$isElementNode(u)))&&h.$findMatchingParent(k,u=>w.$isElementNode(u)&&C(u.getParent()));if(!w.$isElementNode(m)||!w.$isElementNode(k))return!1;if(l===w.DELETE_LINE_COMMAND&&null===m.getPreviousSibling())return!0}return!1};for(let l of Ba)g.listenersToRemove.add(c.registerCommand(l,b(l),
|
105
105
|
w.COMMAND_PRIORITY_CRITICAL));let r=l=>{const k=w.$getSelection();if(!Q(k)&&!w.$isRangeSelection(k))return!1;const m=a.isParentOf(k.anchor.getNode()),p=a.isParentOf(k.focus.getNode());if(m!==p){l=m?"focus":"anchor";const {key:u,offset:t,type:v}=k[l];a[k[m?"anchor":"focus"].isBefore(k[l])?"selectPrevious":"selectNext"]()[l].set(u,t,v);return!1}return Q(k)?(l&&(l.preventDefault(),l.stopPropagation()),g.$clearText(),!0):!1};for(let l of Ca)g.listenersToRemove.add(c.registerCommand(l,r,w.COMMAND_PRIORITY_CRITICAL));
|
106
|
-
g.listenersToRemove.add(c.registerCommand(w.CUT_COMMAND,l=>{let k=w.$getSelection();if(k){if(!Q(k)&&!w.$isRangeSelection(k))return!1;void
|
106
|
+
g.listenersToRemove.add(c.registerCommand(w.CUT_COMMAND,l=>{let k=w.$getSelection();if(k){if(!Q(k)&&!w.$isRangeSelection(k))return!1;void ba.copyToClipboard(c,h.objectKlassEquals(l,ClipboardEvent)?l:null,ba.$getClipboardDataFromSelection(k));l=r(l);return w.$isRangeSelection(k)?(k.removeText(),!0):l}return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_TEXT_COMMAND,l=>{let k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))return g.$formatCells(l),!0;w.$isRangeSelection(k)&&
|
107
107
|
(l=h.$findMatchingParent(k.anchor.getNode(),m=>C(m)),C(l));return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FORMAT_ELEMENT_COMMAND,l=>{var k=w.$getSelection();if(!Q(k)||!W(k,a))return!1;var m=k.anchor.getNode();k=k.focus.getNode();if(!C(m)||!C(k))return!1;let [p,u,t]=N(a,m,k);m=Math.max(u.startRow+u.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);k=Math.max(u.startColumn+u.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1);var v=Math.min(u.startRow,t.startRow);let B=
|
108
108
|
Math.min(u.startColumn,t.startColumn),z=new Set;for(;v<=m;v++)for(let G=B;G<=k;G++){var D=p[v][G].cell;if(!z.has(D)){z.add(D);D.setFormat(l);D=D.getChildren();for(let H=0;H<D.length;H++){let L=D[H];w.$isElementNode(L)&&!L.isInline()&&L.setFormat(l)}}}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.CONTROLLED_TEXT_INSERTION_COMMAND,l=>{var k=w.$getSelection();if(!W(k,a))return!1;if(Q(k))g.$clearHighlight();else if(w.$isRangeSelection(k)){let m=h.$findMatchingParent(k.anchor.getNode(),
|
109
|
-
p=>C(p));if(!C(m))return!1;if("string"===typeof l&&(k=Za(c,k,a)))return Ya(k,a,[w.$createTextNode(l)]),!0}return!1},w.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(w.KEY_TAB_COMMAND,l=>{var k=w.$getSelection();if(!w.$isRangeSelection(k)||!k.isCollapsed()||!W(k,a))return!1;
|
110
|
-
()
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
109
|
+
p=>C(p));if(!C(m))return!1;if("string"===typeof l&&(k=Za(c,k,a)))return Ya(k,a,[w.$createTextNode(l)]),!0}return!1},w.COMMAND_PRIORITY_CRITICAL));d&&g.listenersToRemove.add(c.registerCommand(w.KEY_TAB_COMMAND,l=>{var k=w.$getSelection();if(!w.$isRangeSelection(k)||!k.isCollapsed()||!W(k,a))return!1;var m=X(k.anchor.getNode());if(null===m||!a.is(Y(m)))return!1;Z(l);a:{l=l.shiftKey?"previous":"next";k="next"===l?"getNextSibling":"getPreviousSibling";let u="next"===l?"getFirstChild":"getLastChild";var p=
|
110
|
+
m[k]();if(w.$isElementNode(p))p.selectEnd();else{m=h.$findMatchingParent(m,J);null===m&&E(247);for(p=m[k]();J(p);p=p[k]()){let t=p[u]();if(w.$isElementNode(t)){t.selectEnd();break a}}k=h.$findMatchingParent(m,K);null===k&&E(248);"next"===l?k.selectNext():k.selectPrevious()}}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.FOCUS_COMMAND,()=>a.isSelected(),w.COMMAND_PRIORITY_HIGH));g.listenersToRemove.add(c.registerCommand(w.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,
|
111
|
+
l=>{let {nodes:k,selection:m}=l;l=m.getStartEndPoints();var p=Q(m);p=w.$isRangeSelection(m)&&null!==h.$findMatchingParent(m.anchor.getNode(),H=>C(H))&&null!==h.$findMatchingParent(m.focus.getNode(),H=>C(H))||p;if(1!==k.length||!K(k[0])||!p||null===l)return!1;var [u]=l,t=k[0];l=t.getChildren();p=t.getFirstChildOrThrow().getChildrenSize();t=t.getChildrenSize();var v=h.$findMatchingParent(u.getNode(),H=>C(H)),B=v&&h.$findMatchingParent(v,H=>J(H)),z=B&&h.$findMatchingParent(B,H=>K(H));if(!C(v)||!J(B)||
|
112
|
+
!K(z))return!1;u=B.getIndexWithinParent();var D=Math.min(z.getChildrenSize()-1,u+t-1);t=v.getIndexWithinParent();v=Math.min(B.getChildrenSize()-1,t+p-1);p=Math.min(t,v);B=Math.min(u,D);t=Math.max(t,v);u=Math.max(u,D);z=z.getChildren();for(D=0;B<=u;B++){v=z[B];if(!J(v))return!1;var G=l[D];if(!J(G))return!1;v=v.getChildren();G=G.getChildren();let H=0;for(let L=p;L<=t;L++){let O=v[L];if(!C(O))return!1;let Ma=G[H];if(!C(Ma))return!1;let fb=O.getChildren();Ma.getChildren().forEach(aa=>{w.$isTextNode(aa)&&
|
113
|
+
w.$createParagraphNode().append(aa);O.append(aa)});fb.forEach(aa=>aa.remove());H++}D++}return!0},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.SELECTION_CHANGE_COMMAND,()=>{let l=w.$getSelection(),k=w.$getPreviousSelection();var m=g.getAndClearNextFocus();if(null!==m){({focusCell:m}=m);if(Q(l)&&l.tableKey===g.tableNodeKey){if(m.x===g.focusX&&m.y===g.focusY)return!1;g.$setFocusCellForSelection(m);return!0}if(m!==g.anchorCell&&W(l,a))return g.$setFocusCellForSelection(m),
|
114
|
+
!0}if(g.getAndClearShouldCheckSelection()&&w.$isRangeSelection(k)&&w.$isRangeSelection(l)&&l.isCollapsed()){var p=l.anchor.getNode();m=a.getFirstChild();p=X(p);if(null!==p&&J(m)){let v=m.getFirstChild();if(C(v)&&a.is(h.$findMatchingParent(p,B=>B.is(a)||B.is(v))))return v.selectStart(),!0}}if(w.$isRangeSelection(l)){let {anchor:v,focus:B}=l;p=v.getNode();m=B.getNode();var u=X(p),t=X(m);let z=!(!u||!a.is(Y(u))),D=!(!t||!a.is(Y(t)));p=z!==D;let G=z&&D;m=l.isBackward();p?(p=l.clone(),D?([t]=N(a,t,t),
|
115
|
+
u=t[0][0].cell,t=t[t.length-1].at(-1).cell,p.focus.set(m?u.getKey():t.getKey(),m?u.getChildrenSize():t.getChildrenSize(),"element")):z&&([t]=N(a,u,u),u=t[0][0].cell,t=t[t.length-1].at(-1).cell,p.anchor.set(m?t.getKey():u.getKey(),m?t.getChildrenSize():0,"element")),w.$setSelection(p),Ja(c,g)):G&&!u.is(t)&&(g.$setAnchorCellForSelection(V(g,u)),g.$setFocusCellForSelection(V(g,t),!0))}else l&&Q(l)&&l.is(k)&&l.tableKey===a.getKey()&&(m=w.getDOMSelection(f))&&m.anchorNode&&m.focusNode&&(p=(p=w.$getNearestNodeFromDOMNode(m.focusNode))&&
|
116
|
+
!a.isParentOf(p),u=(u=w.$getNearestNodeFromDOMNode(m.anchorNode))&&a.isParentOf(u),p&&u&&0<m.rangeCount&&(p=w.$createRangeSelectionFromDom(m,c)))&&(p.anchor.set(a.getKey(),l.isBackward()?a.getChildrenSize():0,"element"),m.removeAllRanges(),w.$setSelection(p));if(l&&!l.is(k)&&(Q(l)||Q(k))&&g.tableSelection&&!g.tableSelection.is(k))return Q(l)&&l.tableKey===g.tableNodeKey?g.$updateTableTableSelection(l):!Q(l)&&Q(k)&&k.tableKey===g.tableNodeKey&&g.$updateTableTableSelection(null),!1;g.hasHijackedSelectionStyles&&
|
117
|
+
!a.isSelected()?Ka(c,g):!g.hasHijackedSelectionStyles&&a.isSelected()&&Ja(c,g);return!1},w.COMMAND_PRIORITY_CRITICAL));g.listenersToRemove.add(c.registerCommand(w.INSERT_PARAGRAPH_COMMAND,()=>{var l=w.$getSelection();return w.$isRangeSelection(l)&&l.isCollapsed()&&W(l,a)?(l=Za(c,l,a))?(Ya(l,a),!0):!1:!1},w.COMMAND_PRIORITY_CRITICAL));return g};exports.getDOMCellFromTarget=Fa;exports.getTableElement=R;exports.getTableObserverFromTableElement=Ea;
|
118
|
+
exports.setScrollableTablesActive=function(a,b){b?bb.add(a):bb.delete(a)}
|
package/LexicalTable.prod.mjs
CHANGED
@@ -6,4 +6,4 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
|
9
|
-
import{addClassNamesToElement as e,$findMatchingParent as t,removeClassNamesFromElement as n,objectKlassEquals as o,isHTMLElement as r}from"@lexical/utils";import{ElementNode as l,$createParagraphNode as s,$isElementNode as i,$isLineBreakNode as c,$isTextNode as a,$applyNodeReplacement as u,createCommand as h,$createTextNode as d,$getSelection as g,$isRangeSelection as f,$createPoint as m,$isParagraphNode as p,$normalizeSelection__EXPERIMENTAL as C,isCurrentlyReadOnlyMode as S,TEXT_TYPE_TO_FORMAT as _,$getNodeByKey as w,$getEditor as b,$setSelection as y,SELECTION_CHANGE_COMMAND as N,getDOMSelection as x,$getNearestNodeFromDOMNode as T,$createRangeSelection as v,$getRoot as R,COMMAND_PRIORITY_HIGH as O,KEY_ESCAPE_COMMAND as F,COMMAND_PRIORITY_CRITICAL as k,CUT_COMMAND as K,FORMAT_TEXT_COMMAND as E,FORMAT_ELEMENT_COMMAND as M,CONTROLLED_TEXT_INSERTION_COMMAND as A,KEY_TAB_COMMAND as $,FOCUS_COMMAND as H,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as W,$getPreviousSelection as B,$createRangeSelectionFromDom as P,INSERT_PARAGRAPH_COMMAND as L,$isRootOrShadowRoot as D,$isDecoratorNode as I,KEY_ARROW_DOWN_COMMAND as U,KEY_ARROW_UP_COMMAND as z,KEY_ARROW_LEFT_COMMAND as Y,KEY_ARROW_RIGHT_COMMAND as X,DELETE_WORD_COMMAND as J,DELETE_LINE_COMMAND as j,DELETE_CHARACTER_COMMAND as q,KEY_BACKSPACE_COMMAND as V,KEY_DELETE_COMMAND as G,setDOMUnmanaged as Q}from"lexical";import{copyToClipboard as Z,$getClipboardDataFromSelection as ee}from"@lexical/clipboard";const te=/^(\d+(?:\.\d+)?)px$/,ne={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class oe extends l{static getType(){return"tablecell"}static clone(e){return new oe(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:re,priority:0}),th:e=>({conversion:re,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1;return le(e.headerState,t,e.width||void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor||null)}constructor(e=ne.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());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),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(t.element){const e=t.element;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="top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ne.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ne.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function re(e){const t=e,n=e.nodeName.toLowerCase();let o;te.test(t.style.width)&&(o=parseFloat(t.style.width));const r=le("th"===n?ne.ROW:ne.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const u=t.style,h=(u&&u.textDecoration||"").split(" "),d="700"===u.fontWeight||"bold"===u.fontWeight,g=h.includes("line-through"),f="italic"===u.fontStyle,m=h.includes("underline");return{after:e=>(0===e.length&&e.push(s()),e),forChild:(e,t)=>{if(se(t)&&!i(e)){const t=s();return c(e)&&"\n"===e.getTextContent()?null:(a(e)&&(d&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function le(e,t=1,n){return u(new oe(e,t,n))}function se(e){return e instanceof oe}const ie=h("INSERT_TABLE_COMMAND");function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ae=ce((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const ue="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,he=ue&&"documentMode"in document?document.documentMode:null,de=ue&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);ue&&"InputEvent"in window&&!he&&new window.InputEvent("input");class ge extends l{static getType(){return"tablerow"}static clone(e){return new ge(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:fe,priority:0})}}static importJSON(e){return me(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function fe(e){const t=e;let n;return te.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:me(n)}}function me(e){return u(new ge(e))}function pe(e){return e instanceof ge}function Ce(e,t,n=!0){const o=Et();for(let r=0;r<e;r++){const e=me();for(let o=0;o<t;o++){let t=ne.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ne.ROW),0===o&&n.columns&&(t|=ne.COLUMN)):n&&(0===r&&(t|=ne.ROW),0===o&&(t|=ne.COLUMN));const l=le(t),i=s();i.append(d()),l.append(i),e.append(l)}o.append(e)}return o}function Se(e){const n=t(e,(e=>se(e)));return se(n)?n:null}function _e(e){const n=t(e,(e=>pe(e)));if(pe(n))return n;throw new Error("Expected table cell to be inside of table row.")}function we(e){const n=t(e,(e=>Mt(e)));if(Mt(n))return n;throw new Error("Expected table cell to be inside of table.")}function be(e){const t=_e(e);return we(t).getChildren().findIndex((e=>e.is(t)))}function ye(e){return _e(e).getChildren().findIndex((t=>t.is(e)))}function Ne(e,t){const n=we(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function xe(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Te(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const i=l[t];if(!pe(i))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=i.getChildren(),t=e.length,o=me();for(let n=0;n<t;n++){const t=e[n];se(t)||ae(12);const{above:l,below:i}=Ne(t,r);let c=ne.NO_STATUS;const a=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(ne.COLUMN)||i&&i.hasHeaderState(ne.COLUMN))&&(c|=ne.COLUMN);const u=le(c,1,a);u.append(s()),o.append(u)}n?i.insertAfter(o):i.insertBefore(o)}return e}const ve=(e,t)=>e===ne.BOTH||e===t?t:ne.NO_STATUS;function Re(e=!0){const t=g();f(t)||Ue(t)||ae(188);const n=t.focus.getNode(),[o,,r]=Be(n),[l,i]=He(r,o,o),c=l[0].length,{startRow:a}=i;let u=null;if(e){const e=a+o.__rowSpan-1,t=l[e],n=me();for(let o=0;o<c;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=ve(e,ne.COLUMN);n.append(le(r).append(s()))}else r.setRowSpan(r.__rowSpan+1)}const i=r.getChildAtIndex(e);pe(i)||ae(145),i.insertAfter(n),u=n}else{const e=l[a],t=me();for(let n=0;n<c;n++){const{cell:o,startRow:r}=e[n];if(r===a){const o=e[n].cell.__headerState,r=ve(o,ne.COLUMN);t.append(le(r).append(s()))}else o.setRowSpan(o.__rowSpan+1)}const n=r.getChildAtIndex(a);pe(n)||ae(145),n.insertBefore(t),u=t}return u}function Oe(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(pe(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];se(o)||ae(12);const{left:l,right:c}=Ne(o,r);let a=ne.NO_STATUS;(l&&l.hasHeaderState(ne.ROW)||c&&c.hasHeaderState(ne.ROW))&&(a|=ne.ROW);const u=le(a);u.append(s()),i.push({newTableCell:u,targetCell:o})}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function Fe(e=!0){const t=g();f(t)||Ue(t)||ae(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Be(n),[l,,i]=Be(o),[c,a,u]=He(i,l,r),h=c.length,d=e?Math.max(a.startColumn,u.startColumn):Math.min(a.startColumn,u.startColumn),m=e?d+l.__colSpan-1:d-1,p=i.getFirstChild();pe(p)||ae(120);let C=null;function S(e=ne.NO_STATUS){const t=le(e).append(s());return null===C&&(C=t),t}let _=p;e:for(let e=0;e<h;e++){if(0!==e){const e=_.getNextSibling();pe(e)||ae(121),_=e}const t=c[e],n=t[m<0?0:m].cell.__headerState,o=ve(n,ne.ROW);if(m<0){Ae(_,S(o));continue}const{cell:r,startColumn:l,startRow:s}=t[m];if(l+r.__colSpan-1<=m){let n=r,l=s,i=m;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){_.append(S(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(S(o))}else r.setColSpan(r.__colSpan+1)}null!==C&&Me(C);const w=i.getColWidths();if(w){const e=[...w],t=m<0?0:m,n=e[t];e.splice(t,0,n),i.setColWidths(e)}return C}function ke(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(pe(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Ke(){const e=g();f(e)||Ue(e)||ae(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=Be(t),[l]=Be(n),[s,i,c]=He(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,m=s[h+1],p=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t&&(e===a&&o<a&&n.setRowSpan(n.__rowSpan-(o-a)),o>=a&&o+n.__rowSpan-1>h))if(n.setRowSpan(n.__rowSpan-(h-o+1)),null===p&&ae(122),0===t)Ae(p,n);else{const{cell:e}=m[t-1];e.insertAfter(n)}}const t=r.getChildAtIndex(e);pe(t)||ae(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];Me(e)}else{const e=s[a-1],{cell:t}=e[0];Me(t)}}function Ee(){const e=g();f(e)||Ue(e)||ae(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Be(t),[l]=Be(n),[s,i,c]=He(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),m=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),p=m-d+1;if(s[0].length===m-d+1)return r.selectPrevious(),void r.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=d;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const S=s[u],_=a>h?S[a+o.__colSpan]:S[h+l.__colSpan];if(void 0!==_){const{cell:e}=_;Me(e)}else{const e=h<a?S[h-1]:S[a-1],{cell:t}=e;Me(t)}const w=r.getColWidths();if(w){const e=[...w];e.splice(d,p),r.setColWidths(e)}}function Me(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ae(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function $e(){const e=g();f(e)||Ue(e)||ae(188);const t=e.anchor.getNode(),[n,o,r]=Be(t),l=n.__colSpan,i=n.__rowSpan;if(1===l&&1===i)return;const[c,a]=He(r,n,n),{startColumn:u,startRow:h}=a,d=n.__headerState&ne.COLUMN,m=Array.from({length:l},((e,t)=>{let n=d;for(let e=0;0!==n&&e<c.length;e++)n&=c[e][t+u].cell.__headerState;return n})),p=n.__headerState&ne.ROW,C=Array.from({length:i},((e,t)=>{let n=p;for(let e=0;0!==n&&e<c[0].length;e++)n&=c[t+h][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(le(m[e]|C[0]).append(s()));n.setColSpan(1)}if(i>1){let e;for(let t=1;t<i;t++){const n=h+t,r=c[n];e=(e||o).getNextSibling(),pe(e)||ae(125);let i=null;for(let e=0;e<u;e++){const t=r[e],o=t.cell;t.startRow===n&&(i=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===i)for(let n=l-1;n>=0;n--)Ae(e,le(m[n]|C[t]).append(s()));else for(let e=l-1;e>=0;e--)i.insertAfter(le(m[e]|C[t]).append(s()))}n.setRowSpan(1)}}function He(e,t,n){const[o,r,l]=We(e,t,n);return null===r&&ae(207),null===l&&ae(208),[o,r,l]}function We(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];pe(o)||ae(209);for(let c=o.getFirstChild(),a=0;null!=c;c=c.getNextSibling()){se(c)||ae(147);const o=s(e);for(;void 0!==o[a];)a++;const u={cell:c,startColumn:a,startRow:e},{__rowSpan:h,__colSpan:d}=c;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[a+e]=u}null!==t&&null===r&&t.is(c)&&(r=u),null!==n&&null===l&&n.is(c)&&(l=u)}}return[o,r,l]}function Be(e){let n;if(e instanceof oe)n=e;else if("__type"in e){const o=t(e,se);se(o)||ae(148),n=o}else{const o=t(e.getNode(),se);se(o)||ae(148),n=o}const o=n.getParent();pe(o)||ae(149);const r=o.getParent();return Mt(r)||ae(210),[n,o,r]}function Pe(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Le(e){const[t,,n]=Be(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function De(e){const[[n,o,r,l],[s,i,c,a]]=["anchor","focus"].map((n=>{const o=e[n].getNode(),r=t(o,se);se(r)||ae(238,n,o.getKey(),o.getType());const l=r.getParent();pe(l)||ae(239,n);const s=l.getParent();return Mt(s)||ae(240,n),[o,r,l,s]}));return l.is(a)||ae(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ie{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ue(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){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}clone(){return new Ie(this.tableKey,m(this.anchor.key,this.anchor.offset,this.anchor.type),m(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(se).forEach((e=>{const n=e.getFirstChild();p(n)&&(t|=n.getTextFormat())}));const n=_[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();i(t)||ae(151);C(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=De(this),n=Le(e);null===n&&ae(153);const o=Le(t);null===o&&ae(155);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);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=De(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&ae(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&ae(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=He(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Pe(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();pe(o)||ae(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||Ye(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return S()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>se(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ue(e){return e instanceof Ie}function ze(){const e=m("root",0,"element"),t=m("root",0,"element");return new Ie("root",e,t)}function Ye(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&i(o)&&n.push(o.getChildren())}}function Xe(e,t=b()){const n=w(e);Mt(n)||ae(231,e);const o=qe(n,t.getElementByKey(e));return null===o&&ae(232,e),{tableElement:o,tableNode:n}}class Je{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return Xe(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=rt(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=rt(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;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();const{tableNode:t,tableElement:n}=this.$lookup();lt(e,rt(t,n),null),null!==g()&&(y(null),e.dispatchCommand(N,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();n(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&ae(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),lt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=x(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=T(e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&se(t)&&o.is(St(t)))return this.focusCellNodeKey=t.getKey(),this.tableSelection=function(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=g(),r=Ue(o)?o.clone():ze();return r.set(e.getKey(),t.getKey(),n.getKey()),r}(o,this.$getAnchorTableCellOrThrow(),t),y(this.tableSelection),n.dispatchCommand(N,void 0),lt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?w(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&ae(234),e}$getFocusTableCell(){return this.focusCellNodeKey?w(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&ae(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const t=T(e.elem);if(se(t)){const e=t.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ze(),this.anchorCellNodeKey=e}}$formatCells(e){const t=g();Ue(t)||ae(236);const n=v(),o=n.anchor,r=n.focus,l=t.getNodes().filter(se);l.length>0||ae(237);const s=l[0].getFirstChild(),i=p(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),y(t),this.editor.dispatchCommand(N,void 0)}$clearText(){const{editor:e}=this,t=w(this.tableNodeKey);if(!Mt(t))throw new Error("Expected TableNode.");const n=g();Ue(n)||ae(11);const o=n.getNodes().filter(se);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(i(e)){const t=s(),n=d();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),lt(e,this.table,null),y(null),e.dispatchCommand(N,void 0);else{t.selectPrevious(),t.remove();R().selectStart()}}}const je="__lexicalTableSelection";function qe(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&ae(245,t.nodeName),n}function Ve(e){return e._window}function Ge(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;se(n)&&(o=n)}return null}const Qe=[[U,"down"],[z,"up"],[Y,"backward"],[X,"forward"]],Ze=[J,j,q],et=[V,G];function tt(e,n,r,l){const c=r.getRootElement(),u=Ve(r);null!==c&&null!==u||ae(246);const h=new Je(r,e.getKey()),m=qe(e,n);!function(e,t){null!==nt(e)&&ae(205);e[je]=t}(m,h),h.listenersToRemove.add((()=>function(e,t){nt(e)===t&&delete e[je]}(m,h)));m.addEventListener("mousedown",(t=>{if(0!==t.button)return;if(!u)return;const n=ot(t.target);null!==n&&r.update((()=>{const o=B();if(de&&t.shiftKey&>(o,e)&&(f(o)||Ue(o))){const r=o.anchor.getNode(),l=Ge(e,o.anchor.getNode());if(l)h.$setAnchorCellForSelection(Nt(h,l)),h.$setFocusCellForSelection(n),wt(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else h.$setAnchorCellForSelection(n)})),(()=>{if(h.isSelecting)return;const e=()=>{h.isSelecting=!1,u.removeEventListener("mouseup",e),u.removeEventListener("mousemove",t)},t=n=>{if(1&~n.buttons&&h.isSelecting)return h.isSelecting=!1,u.removeEventListener("mouseup",e),void u.removeEventListener("mousemove",t);const o=!m.contains(n.target);let l=null;if(o){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=m.contains(e)?ot(e):null,l)break}else l=ot(n.target);!l||null!==h.focusCell&&l.elem===h.focusCell.elem||(h.setNextFocus({focusCell:l,override:o}),r.dispatchCommand(N,void 0))};h.isSelecting=!0,u.addEventListener("mouseup",e,h.listenerOptions),u.addEventListener("mousemove",t,h.listenerOptions)})()}),h.listenerOptions);u.addEventListener("mousedown",(e=>{0===e.button&&r.update((()=>{const t=g(),n=e.target;Ue(t)&&t.tableKey===h.tableNodeKey&&c.contains(n)&&h.$clearHighlight()}))}),h.listenerOptions);for(const[t,n]of Qe)h.listenersToRemove.add(r.registerCommand(t,(t=>_t(r,t,n,e,h)),O));h.listenersToRemove.add(r.registerCommand(F,(t=>{const n=g();if(Ue(n)){const o=Ge(e,n.focus.getNode());if(null!==o)return wt(t),o.selectEnd(),!0}return!1}),O));const p=n=>()=>{const o=g();if(!gt(o,e))return!1;if(Ue(o))return h.$clearText(),!0;if(f(o)){if(!se(Ge(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),c=e.isParentOf(l);if(s&&!c||c&&!s)return h.$clearText(),!0;const a=t(o.anchor.getNode(),(e=>i(e))),u=a&&t(a,(e=>i(e)&&se(e.getParent())));if(!i(u)||!i(a))return!1;if(n===j&&null===u.getPreviousSibling())return!0}return!1};for(const e of Ze)h.listenersToRemove.add(r.registerCommand(e,p(e),k));const C=t=>{const n=g();if(!Ue(n)&&!f(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Ue(n)&&(t&&(t.preventDefault(),t.stopPropagation()),h.$clearText(),!0)};for(const e of et)h.listenersToRemove.add(r.registerCommand(e,C,k));return h.listenersToRemove.add(r.registerCommand(K,(e=>{const t=g();if(t){if(!Ue(t)&&!f(t))return!1;Z(r,o(e,ClipboardEvent)?e:null,ee(t));const n=C(e);return f(t)?(t.removeText(),!0):n}return!1}),k)),h.listenersToRemove.add(r.registerCommand(E,(n=>{const o=g();if(!gt(o,e))return!1;if(Ue(o))return h.$formatCells(n),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>se(e)));if(!se(e))return!1}return!1}),k)),h.listenersToRemove.add(r.registerCommand(M,(t=>{const n=g();if(!Ue(n)||!gt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!se(o)||!se(r))return!1;const[l,s,c]=He(e,o,r),a=Math.max(s.startRow+s.cell.__rowSpan-1,c.startRow+c.cell.__rowSpan-1),u=Math.max(s.startColumn+s.cell.__colSpan-1,c.startColumn+c.cell.__colSpan-1),h=Math.min(s.startRow,c.startRow),d=Math.min(s.startColumn,c.startColumn),f=new Set;for(let e=h;e<=a;e++)for(let n=d;n<=u;n++){const o=l[e][n].cell;if(f.has(o))continue;f.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];i(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),k)),h.listenersToRemove.add(r.registerCommand(A,(n=>{const o=g();if(!gt(o,e))return!1;if(Ue(o))return h.$clearHighlight(),!1;if(f(o)){const l=t(o.anchor.getNode(),(e=>se(e)));if(!se(l))return!1;if("string"==typeof n){const t=yt(r,o,e);if(t)return bt(t,e,[d(n)]),!0}}return!1}),k)),l&&h.listenersToRemove.add(r.registerCommand($,(t=>{const n=g();if(!f(n)||!n.isCollapsed()||!gt(n,e))return!1;const o=Ct(n.anchor.getNode());if(null===o)return!1;wt(t);const r=e.getCordsFromCellNode(o,h.table);return ct(h,e,r.x,r.y,t.shiftKey?"backward":"forward"),!0}),k)),h.listenersToRemove.add(r.registerCommand(H,(t=>e.isSelected()),O)),h.listenersToRemove.add(r.registerCommand(W,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=Ue(o),i=f(o)&&null!==t(o.anchor.getNode(),(e=>se(e)))&&null!==t(o.focus.getNode(),(e=>se(e)))||l;if(1!==n.length||!Mt(n[0])||!i||null===r)return!1;const[c]=r,u=n[0],h=u.getChildren(),d=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),m=t(c.getNode(),(e=>se(e))),p=m&&t(m,(e=>pe(e))),C=p&&t(p,(e=>Mt(e)));if(!se(m)||!pe(p)||!Mt(C))return!1;const S=p.getIndexWithinParent(),_=Math.min(C.getChildrenSize()-1,S+g-1),w=m.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,w+d-1),y=Math.min(w,b),N=Math.min(S,_),x=Math.max(w,b),T=Math.max(S,_),v=C.getChildren();let R=0;for(let e=N;e<=T;e++){const t=v[e];if(!pe(t))return!1;const n=h[R];if(!pe(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!se(t))return!1;const n=r[l];if(!se(n))return!1;const i=t.getChildren();n.getChildren().forEach((e=>{if(a(e)){s().append(e),t.append(e)}else t.append(e)})),i.forEach((e=>e.remove())),l++}R++}return!0}),k)),h.listenersToRemove.add(r.registerCommand(N,(()=>{const n=g(),o=B(),l=h.getAndClearNextFocus();if(null!==l){const{focusCell:t}=l;if(Ue(n)&&n.tableKey===h.tableNodeKey)return(t.x!==h.focusX||t.y!==h.focusY)&&(h.$setFocusCellForSelection(t),!0);if(t!==h.anchorCell&>(n,e))return h.$setFocusCellForSelection(t),!0}if(h.getAndClearShouldCheckSelection()&&f(o)&&f(n)&&n.isCollapsed()){const o=n.anchor.getNode(),r=e.getFirstChild(),l=Ct(o);if(null!==l&&pe(r)){const n=r.getFirstChild();if(se(n)&&e.is(t(l,(t=>t.is(e)||t.is(n)))))return n.selectStart(),!0}}if(f(n)){const{anchor:t,focus:o}=n,l=t.getNode(),s=o.getNode(),i=Ct(l),c=Ct(s),a=!(!i||!e.is(St(i))),u=!(!c||!e.is(St(c))),d=a!==u,g=a&&u,f=n.isBackward();if(d){const t=n.clone();if(u){const[n]=He(e,c,c),o=n[0][0].cell,r=n[n.length-1].at(-1).cell;t.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(a){const[n]=He(e,i,i),o=n[0][0].cell,r=n[n.length-1].at(-1).cell;t.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}y(t),it(r,h)}else g&&(i.is(c)||(h.$setAnchorCellForSelection(Nt(h,i)),h.$setFocusCellForSelection(Nt(h,c),!0)))}else if(n&&Ue(n)&&n.is(o)&&n.tableKey===e.getKey()){const t=x(u);if(t&&t.anchorNode&&t.focusNode){const o=T(t.focusNode),l=o&&!e.is(St(o)),s=T(t.anchorNode),i=s&&e.is(St(s));if(l&&i&&t.rangeCount>0){const o=P(t,r);o&&(o.anchor.set(e.getKey(),n.isBackward()?e.getChildrenSize():0,"element"),t.removeAllRanges(),y(o))}}}return n&&!n.is(o)&&(Ue(n)||Ue(o))&&h.tableSelection&&!h.tableSelection.is(o)?(Ue(n)&&n.tableKey===h.tableNodeKey?h.$updateTableTableSelection(n):!Ue(n)&&Ue(o)&&o.tableKey===h.tableNodeKey&&h.$updateTableTableSelection(null),!1):(h.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),st(t.table,(t=>{const n=t.elem;t.highlighted=!1,pt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(r,h):!h.hasHijackedSelectionStyles&&e.isSelected()&&it(r,h),!1)}),k)),h.listenersToRemove.add(r.registerCommand(L,(()=>{const t=g();if(!f(t)||!t.isCollapsed()||!gt(t,e))return!1;const n=yt(r,t,e);return!!n&&(bt(n,e),!0)}),k)),h}function nt(e){return e[je]||null}function ot(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function rt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=qe(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function lt(e,t,n){const o=new Set(n?n.getNodes():[]);st(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,mt(e,t)):(t.highlighted=!1,pt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function st(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=T(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function it(e,t){t.$disableHighlightStyle(),st(t.table,(t=>{t.highlighted=!0,mt(e,t)}))}const ct=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?ft(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?ft(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?ft(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?ft(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function at(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function ut([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function ht(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&ae(248,o,String(r));const s=t[n],i=l[s];return void 0===i&&ae(248,n,String(s)),i}function dt(e,t,n,o,r){const l=Pe(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);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);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=at(e,t);return null===n&&ae(247,t.cell.getKey()),n}(l,n),[d,g]=ut(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const C=p[f];if(void 0===C)return!1;const[S,_]=function(e,t,n){const o=Pe(e,t,n),r=at(o,t);if(r)return[ht(e,o,r),ht(e,o,ut(r))];const l=at(o,n);if(l)return[ht(e,o,ut(l)),ht(e,o,l)];const s=["minColumn","minRow"];return[ht(e,o,s),ht(e,o,ut(s))]}(t,n,C),w=Nt(e,S.cell),b=Nt(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function gt(e,t){if(f(e)||Ue(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function ft(e,t){t?e.selectStart():e.selectEnd()}function mt(t,n){const o=n.elem,r=t._config.theme;se(T(o))||ae(131),e(o,r.tableCellSelected)}function pt(e,t){const o=t.elem;se(T(o))||ae(131);const r=e._config.theme;n(o,r.tableCellSelected)}function Ct(e){const n=t(e,se);return se(n)?n:null}function St(e){const n=t(e,Mt);return Mt(n)?n:null}function _t(e,n,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=g();if(!gt(s,r)){if(f(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(i(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const t=e.getPreviousSibling();return!!Mt(t)&&(wt(n),n.shiftKey?s.focus.set(t.getParentOrThrow().getKey(),t.getIndexWithinParent(),"element"):t.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=t(e,(e=>Mt(e)));if(se(l)&&(l=t(l,Mt)),l!==r)return!1;if(!l)return!1;const c="down"===o?l.getNextSibling():l.getPreviousSibling();if(!c)return!1;let u=0;"up"===o&&i(c)&&(u=c.getChildrenSize());let h=c;if("up"===o&&i(c)){const e=c.getLastChild();h=e||c,u=a(h)?h.getTextContentSize():0}const d=s.clone();return d.focus.set(h.getKey(),u,a(h)?"text":"element"),y(d),wt(n),!0}if(D(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){const n=t(e,se);if(n&&r.isParentOf(n)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Be(e),[o]=Be(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);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=t(e,(e=>i(e)&&!e.isInline()));if(se(r)&&(r=t(r,Mt)),!r)return!1;const c="down"===o?r.getNextSibling():r.getPreviousSibling();if(Mt(c)&&l.tableNodeKey===c.getKey()){const e=c.getFirstDescendant(),t=c.getLastDescendant();if(!e||!t)return!1;const[r]=Be(e),[l]=Be(t),i=s.clone();return i.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),wt(n),y(i),!0}}}}return"down"===o&&Rt(e)&&l.setShouldCheckSelection(),!1}if(f(s)&&s.isCollapsed()){const{anchor:c,focus:a}=s,u=t(c.getNode(),se),h=t(a.getNode(),se);if(!se(u)||!u.is(h))return!1;const d=St(u);if(d!==r&&null!=d){const t=qe(d,e.getElementByKey(d.getKey()));if(null!=t)return l.table=rt(d,t),_t(e,n,o,d,l)}if("backward"===o||"forward"===o){const e=c.type,l=c.offset,a=c.getNode();if(!a)return!1;const h=s.getNodes();return(1!==h.length||!I(h[0]))&&(!!function(e,n,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,n,o,r){const l=t(o,(e=>i(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===n:n===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,n,o,r)}(e,l,a,o)&&function(e,n,o,r,l){const[s,c]=He(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,c,l))return!1;const a=function(e,n,o){const r=t(e,(e=>i(e)&&!e.isInline()));if(!r)return;const l="backward"===n?r.getPreviousSibling():r.getNextSibling();return l&&Mt(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,l,r);if(!a||Mt(a))return!1;wt(e),"backward"===l?a.selectEnd():a.selectStart();return!0}(n,a,u,r,o))}const g=e.getElementByKey(u.__key),f=e.getElementByKey(c.key);if(null==f||null==g)return!1;let m;if("element"===c.type)m=f.getBoundingClientRect();else{const t=x(Ve(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?u.getFirstChild():u.getLastChild();if(null==p)return!1;const C=e.getElementByKey(p.__key);if(null==C)return!1;const S=C.getBoundingClientRect();if("up"===o?S.top>m.top-m.height:m.bottom+m.height>S.bottom){wt(n);const e=r.getCordsFromCellNode(u,l.table);if(!n.shiftKey)return ct(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ue(s)){const{anchor:i,focus:c}=s,a=t(i.getNode(),se),u=t(c.getNode(),se),[h]=s.getNodes();Mt(h)||ae(249);const d=qe(h,e.getElementByKey(h.getKey()));if(!se(a)||!se(u)||!Mt(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=rt(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),wt(n),n.shiftKey){const[e,t,n]=He(r,a,u);return dt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function wt(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function bt(e,t,n){const o=s();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function yt(e,n,o){const r=o.getParent();if(!r)return;const l=x(Ve(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=qe(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=t(n.anchor.getNode(),(e=>se(e)));if(!a)return;const u=t(a,(e=>Mt(e)));if(!Mt(u)||!u.is(o))return;const[h,d]=He(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===g.startRow&&p===g.startColumn,S=m===f.startRow&&p===f.startColumn;return C?"first":S?"last":void 0}function Nt(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function xt(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Tt(t,o,r){r?(e(t,o.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(n(t,o.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}const vt=new WeakSet;function Rt(e=b()){return vt.has(e)}function Ot(e,t){t?vt.add(e):vt.delete(e)}class Ft extends l{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Ft(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Kt,priority:1})}}static importJSON(e){const t=Et();return t.__rowStriping=e.rowStriping||!1,t.__colWidths=e.colWidths,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&ae(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),xt(o,0,this.getColumnCount(),this.getColWidths()),Q(r),e(o,t.theme.table),this.__rowStriping&&Tt(o,t,!0),Rt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Tt(t,n,this.__rowStriping),xt(t,0,this.getColumnCount(),this.getColWidths()),!1}exportDOM(e){return{...super.exportDOM(e),after:e=>{if(e&&r(e)&&"TABLE"!==e.nodeName&&(e=e.querySelector("table")),!e||!r(e))return null;const t=e.querySelectorAll(":scope > tr");if(t.length>0){const n=document.createElement("tbody");n.append(...t),e.append(n)}return e}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null==n)continue;const r=n.findIndex((t=>{if(!t)return;const{elem:n}=t;return T(n)===e}));if(-1!==r)return{x:r,y:t}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=T(o.elem);return se(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){this.getWritable().__rowStriping=e}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{se(e)&&(t+=e.getColSpan())})),t}}function kt(e,t){const n=e.getElementByKey(t.getKey());return null===n&&ae(230),rt(t,n)}function Kt(e){const t=Et();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0);const n=e.querySelector(":scope > colgroup");if(n){let e=[];for(const t of n.querySelectorAll(":scope > col")){const n=t.style.width;if(!n||!te.test(n)){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{node:t}}function Et(){return u(new Ft)}function Mt(e){return e instanceof Ft}export{He as $computeTableMap,We as $computeTableMapSkipCellCheck,le as $createTableCellNode,Et as $createTableNode,Ce as $createTableNodeWithDimensions,me as $createTableRowNode,ze as $createTableSelection,ke as $deleteTableColumn,Ee as $deleteTableColumn__EXPERIMENTAL,Ke as $deleteTableRow__EXPERIMENTAL,Ct as $findCellNode,St as $findTableNode,kt as $getElementForTableNode,Be as $getNodeTriplet,Xe as $getTableAndElementByKey,Se as $getTableCellNodeFromLexicalNode,Le as $getTableCellNodeRect,ye as $getTableColumnIndexFromTableCellNode,we as $getTableNodeFromLexicalNodeOrThrow,be as $getTableRowIndexFromTableCellNode,_e as $getTableRowNodeFromTableCellNodeOrThrow,Oe as $insertTableColumn,Fe as $insertTableColumn__EXPERIMENTAL,Te as $insertTableRow,Re as $insertTableRow__EXPERIMENTAL,Rt as $isScrollableTablesActive,se as $isTableCellNode,Mt as $isTableNode,pe as $isTableRowNode,Ue as $isTableSelection,xe as $removeTableRowAtIndex,$e as $unmergeCell,ie as INSERT_TABLE_COMMAND,ne as TableCellHeaderStates,oe as TableCellNode,Ft as TableNode,Je as TableObserver,ge as TableRowNode,tt as applyTableHandlers,ot as getDOMCellFromTarget,qe as getTableElement,nt as getTableObserverFromTableElement,Ot as setScrollableTablesActive};
|
9
|
+
import{addClassNamesToElement as e,$findMatchingParent as t,removeClassNamesFromElement as n,objectKlassEquals as o,isHTMLElement as r}from"@lexical/utils";import{ElementNode as l,$createParagraphNode as s,$isElementNode as i,$isLineBreakNode as c,$isTextNode as a,$applyNodeReplacement as u,createCommand as h,$createTextNode as d,$getSelection as g,$isRangeSelection as f,$createPoint as m,$isParagraphNode as p,$normalizeSelection__EXPERIMENTAL as C,isCurrentlyReadOnlyMode as S,TEXT_TYPE_TO_FORMAT as _,$getNodeByKey as w,$getEditor as b,$setSelection as y,SELECTION_CHANGE_COMMAND as N,getDOMSelection as x,$createRangeSelection as v,$getRoot as T,COMMAND_PRIORITY_HIGH as R,KEY_ESCAPE_COMMAND as O,COMMAND_PRIORITY_CRITICAL as F,CUT_COMMAND as k,FORMAT_TEXT_COMMAND as K,FORMAT_ELEMENT_COMMAND as E,CONTROLLED_TEXT_INSERTION_COMMAND as M,KEY_TAB_COMMAND as A,FOCUS_COMMAND as $,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as P,$getPreviousSelection as H,$getNearestNodeFromDOMNode as W,$createRangeSelectionFromDom as B,INSERT_PARAGRAPH_COMMAND as L,$isRootOrShadowRoot as D,$isDecoratorNode as I,KEY_ARROW_DOWN_COMMAND as U,KEY_ARROW_UP_COMMAND as z,KEY_ARROW_LEFT_COMMAND as Y,KEY_ARROW_RIGHT_COMMAND as X,DELETE_WORD_COMMAND as J,DELETE_LINE_COMMAND as j,DELETE_CHARACTER_COMMAND as q,KEY_BACKSPACE_COMMAND as V,KEY_DELETE_COMMAND as G,setDOMUnmanaged as Q}from"lexical";import{copyToClipboard as Z,$getClipboardDataFromSelection as ee}from"@lexical/clipboard";const te=/^(\d+(?:\.\d+)?)px$/,ne={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class oe extends l{static getType(){return"tablecell"}static clone(e){return new oe(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:re,priority:0}),th:e=>({conversion:re,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1;return le(e.headerState,t,e.width||void 0).setRowSpan(n).setBackgroundColor(e.backgroundColor||null)}constructor(e=ne.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());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),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(t.element){const e=t.element;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="top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ne.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ne.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function re(e){const t=e,n=e.nodeName.toLowerCase();let o;te.test(t.style.width)&&(o=parseFloat(t.style.width));const r=le("th"===n?ne.ROW:ne.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const u=t.style,h=(u&&u.textDecoration||"").split(" "),d="700"===u.fontWeight||"bold"===u.fontWeight,g=h.includes("line-through"),f="italic"===u.fontStyle,m=h.includes("underline");return{after:e=>(0===e.length&&e.push(s()),e),forChild:(e,t)=>{if(se(t)&&!i(e)){const t=s();return c(e)&&"\n"===e.getTextContent()?null:(a(e)&&(d&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function le(e,t=1,n){return u(new oe(e,t,n))}function se(e){return e instanceof oe}const ie=h("INSERT_TABLE_COMMAND");function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ae=ce((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const ue="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,he=ue&&"documentMode"in document?document.documentMode:null,de=ue&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);ue&&"InputEvent"in window&&!he&&new window.InputEvent("input");class ge extends l{static getType(){return"tablerow"}static clone(e){return new ge(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:fe,priority:0})}}static importJSON(e){return me(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){return{...super.exportJSON(),...this.getHeight()&&{height:this.getHeight()},type:"tablerow",version:1}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}isShadowRoot(){return!0}setHeight(e){return this.getWritable().__height=e,this.__height}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function fe(e){const t=e;let n;return te.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:me(n)}}function me(e){return u(new ge(e))}function pe(e){return e instanceof ge}function Ce(e,t,n=!0){const o=Mt();for(let r=0;r<e;r++){const e=me();for(let o=0;o<t;o++){let t=ne.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ne.ROW),0===o&&n.columns&&(t|=ne.COLUMN)):n&&(0===r&&(t|=ne.ROW),0===o&&(t|=ne.COLUMN));const l=le(t),i=s();i.append(d()),l.append(i),e.append(l)}o.append(e)}return o}function Se(e){const n=t(e,(e=>se(e)));return se(n)?n:null}function _e(e){const n=t(e,(e=>pe(e)));if(pe(n))return n;throw new Error("Expected table cell to be inside of table row.")}function we(e){const n=t(e,(e=>At(e)));if(At(n))return n;throw new Error("Expected table cell to be inside of table.")}function be(e){const t=_e(e);return we(t).getChildren().findIndex((e=>e.is(t)))}function ye(e){return _e(e).getChildren().findIndex((t=>t.is(e)))}function Ne(e,t){const n=we(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function xe(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function ve(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const i=l[t];if(!pe(i))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=i.getChildren(),t=e.length,o=me();for(let n=0;n<t;n++){const t=e[n];se(t)||ae(12);const{above:l,below:i}=Ne(t,r);let c=ne.NO_STATUS;const a=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(ne.COLUMN)||i&&i.hasHeaderState(ne.COLUMN))&&(c|=ne.COLUMN);const u=le(c,1,a);u.append(s()),o.append(u)}n?i.insertAfter(o):i.insertBefore(o)}return e}const Te=(e,t)=>e===ne.BOTH||e===t?t:ne.NO_STATUS;function Re(e=!0){const t=g();f(t)||Ue(t)||ae(188);const n=t.focus.getNode(),[o,,r]=We(n),[l,i]=Pe(r,o,o),c=l[0].length,{startRow:a}=i;let u=null;if(e){const e=a+o.__rowSpan-1,t=l[e],n=me();for(let o=0;o<c;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Te(e,ne.COLUMN);n.append(le(r).append(s()))}else r.setRowSpan(r.__rowSpan+1)}const i=r.getChildAtIndex(e);pe(i)||ae(145),i.insertAfter(n),u=n}else{const e=l[a],t=me();for(let n=0;n<c;n++){const{cell:o,startRow:r}=e[n];if(r===a){const o=e[n].cell.__headerState,r=Te(o,ne.COLUMN);t.append(le(r).append(s()))}else o.setRowSpan(o.__rowSpan+1)}const n=r.getChildAtIndex(a);pe(n)||ae(145),n.insertBefore(t),u=t}return u}function Oe(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(pe(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];se(o)||ae(12);const{left:l,right:c}=Ne(o,r);let a=ne.NO_STATUS;(l&&l.hasHeaderState(ne.ROW)||c&&c.hasHeaderState(ne.ROW))&&(a|=ne.ROW);const u=le(a);u.append(s()),i.push({newTableCell:u,targetCell:o})}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function Fe(e=!0){const t=g();f(t)||Ue(t)||ae(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=We(n),[l,,i]=We(o),[c,a,u]=Pe(i,l,r),h=c.length,d=e?Math.max(a.startColumn,u.startColumn):Math.min(a.startColumn,u.startColumn),m=e?d+l.__colSpan-1:d-1,p=i.getFirstChild();pe(p)||ae(120);let C=null;function S(e=ne.NO_STATUS){const t=le(e).append(s());return null===C&&(C=t),t}let _=p;e:for(let e=0;e<h;e++){if(0!==e){const e=_.getNextSibling();pe(e)||ae(121),_=e}const t=c[e],n=t[m<0?0:m].cell.__headerState,o=Te(n,ne.ROW);if(m<0){Ae(_,S(o));continue}const{cell:r,startColumn:l,startRow:s}=t[m];if(l+r.__colSpan-1<=m){let n=r,l=s,i=m;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){_.append(S(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(S(o))}else r.setColSpan(r.__colSpan+1)}null!==C&&Me(C);const w=i.getColWidths();if(w){const e=[...w],t=m<0?0:m,n=e[t];e.splice(t,0,n),i.setColWidths(e)}return C}function ke(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(pe(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Ke(){const e=g();f(e)||Ue(e)||ae(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=We(t),[l]=We(n),[s,i,c]=Pe(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,m=s[h+1],p=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t&&(e===a&&o<a&&n.setRowSpan(n.__rowSpan-(o-a)),o>=a&&o+n.__rowSpan-1>h))if(n.setRowSpan(n.__rowSpan-(h-o+1)),null===p&&ae(122),0===t)Ae(p,n);else{const{cell:e}=m[t-1];e.insertAfter(n)}}const t=r.getChildAtIndex(e);pe(t)||ae(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];Me(e)}else{const e=s[a-1],{cell:t}=e[0];Me(t)}}function Ee(){const e=g();f(e)||Ue(e)||ae(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=We(t),[l]=We(n),[s,i,c]=Pe(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),m=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),p=m-d+1;if(s[0].length===m-d+1)return r.selectPrevious(),void r.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=d;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const S=s[u],_=a>h?S[a+o.__colSpan]:S[h+l.__colSpan];if(void 0!==_){const{cell:e}=_;Me(e)}else{const e=h<a?S[h-1]:S[a-1],{cell:t}=e;Me(t)}const w=r.getColWidths();if(w){const e=[...w];e.splice(d,p),r.setColWidths(e)}}function Me(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ae(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function $e(){const e=g();f(e)||Ue(e)||ae(188);const t=e.anchor.getNode(),[n,o,r]=We(t),l=n.__colSpan,i=n.__rowSpan;if(1===l&&1===i)return;const[c,a]=Pe(r,n,n),{startColumn:u,startRow:h}=a,d=n.__headerState&ne.COLUMN,m=Array.from({length:l},((e,t)=>{let n=d;for(let e=0;0!==n&&e<c.length;e++)n&=c[e][t+u].cell.__headerState;return n})),p=n.__headerState&ne.ROW,C=Array.from({length:i},((e,t)=>{let n=p;for(let e=0;0!==n&&e<c[0].length;e++)n&=c[t+h][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(le(m[e]|C[0]).append(s()));n.setColSpan(1)}if(i>1){let e;for(let t=1;t<i;t++){const n=h+t,r=c[n];e=(e||o).getNextSibling(),pe(e)||ae(125);let i=null;for(let e=0;e<u;e++){const t=r[e],o=t.cell;t.startRow===n&&(i=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===i)for(let n=l-1;n>=0;n--)Ae(e,le(m[n]|C[t]).append(s()));else for(let e=l-1;e>=0;e--)i.insertAfter(le(m[e]|C[t]).append(s()))}n.setRowSpan(1)}}function Pe(e,t,n){const[o,r,l]=He(e,t,n);return null===r&&ae(207),null===l&&ae(208),[o,r,l]}function He(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];pe(o)||ae(209);for(let c=o.getFirstChild(),a=0;null!=c;c=c.getNextSibling()){se(c)||ae(147);const o=s(e);for(;void 0!==o[a];)a++;const u={cell:c,startColumn:a,startRow:e},{__rowSpan:h,__colSpan:d}=c;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[a+e]=u}null!==t&&null===r&&t.is(c)&&(r=u),null!==n&&null===l&&n.is(c)&&(l=u)}}return[o,r,l]}function We(e){let n;if(e instanceof oe)n=e;else if("__type"in e){const o=t(e,se);se(o)||ae(148),n=o}else{const o=t(e.getNode(),se);se(o)||ae(148),n=o}const o=n.getParent();pe(o)||ae(149);const r=o.getParent();return At(r)||ae(210),[n,o,r]}function Be(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Le(e){const[t,,n]=We(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function De(e){const[[n,o,r,l],[s,i,c,a]]=["anchor","focus"].map((n=>{const o=e[n].getNode(),r=t(o,se);se(r)||ae(238,n,o.getKey(),o.getType());const l=r.getParent();pe(l)||ae(239,n);const s=l.getParent();return At(s)||ae(240,n),[o,r,l,s]}));return l.is(a)||ae(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ie{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ue(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){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}clone(){return new Ie(this.tableKey,m(this.anchor.key,this.anchor.offset,this.anchor.type),m(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(se).forEach((e=>{const n=e.getFirstChild();p(n)&&(t|=n.getTextFormat())}));const n=_[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();i(t)||ae(151);C(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=De(this),n=Le(e);null===n&&ae(153);const o=Le(t);null===o&&ae(155);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);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=De(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&ae(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&ae(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=Pe(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Be(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();pe(o)||ae(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||Ye(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return S()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>se(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ue(e){return e instanceof Ie}function ze(){const e=m("root",0,"element"),t=m("root",0,"element");return new Ie("root",e,t)}function Ye(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&i(o)&&n.push(o.getChildren())}}function Xe(e,t=b()){const n=w(e);At(n)||ae(231,e);const o=qe(n,t.getElementByKey(e));return null===o&&ae(232,e),{tableElement:o,tableNode:n}}class Je{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return Xe(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=rt(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=rt(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;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();const{tableNode:t,tableElement:n}=this.$lookup();lt(e,rt(t,n),null),null!==g()&&(y(null),e.dispatchCommand(N,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();n(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&ae(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),lt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=x(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=xt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=function(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=g(),r=Ue(o)?o.clone():ze();return r.set(e.getKey(),t.getKey(),n.getKey()),r}(o,this.$getAnchorTableCellOrThrow(),t),y(this.tableSelection),n.dispatchCommand(N,void 0),lt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?w(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&ae(234),e}$getFocusTableCell(){return this.focusCellNodeKey?w(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&ae(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=xt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():ze(),this.anchorCellNodeKey=e}}$formatCells(e){const t=g();Ue(t)||ae(236);const n=v(),o=n.anchor,r=n.focus,l=t.getNodes().filter(se);l.length>0||ae(237);const s=l[0].getFirstChild(),i=p(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),y(t),this.editor.dispatchCommand(N,void 0)}$clearText(){const{editor:e}=this,t=w(this.tableNodeKey);if(!At(t))throw new Error("Expected TableNode.");const n=g();Ue(n)||ae(11);const o=n.getNodes().filter(se);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(i(e)){const t=s(),n=d();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),lt(e,this.table,null),y(null),e.dispatchCommand(N,void 0);else{t.selectPrevious(),t.remove();T().selectStart()}}}const je="__lexicalTableSelection";function qe(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&ae(245,t.nodeName),n}function Ve(e){return e._window}function Ge(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;se(n)&&(o=n)}return null}const Qe=[[U,"down"],[z,"up"],[Y,"backward"],[X,"forward"]],Ze=[J,j,q],et=[V,G];function tt(e,n,r,l){const c=r.getRootElement(),u=Ve(r);null!==c&&null!==u||ae(246);const h=new Je(r,e.getKey()),m=qe(e,n);!function(e,t){null!==nt(e)&&ae(205);e[je]=t}(m,h),h.listenersToRemove.add((()=>function(e,t){nt(e)===t&&delete e[je]}(m,h)));m.addEventListener("mousedown",(t=>{if(0!==t.button)return;if(!u)return;const n=ot(t.target);null!==n&&r.update((()=>{const o=H();if(de&&t.shiftKey&>(o,e)&&(f(o)||Ue(o))){const r=o.anchor.getNode(),l=Ge(e,o.anchor.getNode());if(l)h.$setAnchorCellForSelection(Nt(h,l)),h.$setFocusCellForSelection(n),wt(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else h.$setAnchorCellForSelection(n)})),(()=>{if(h.isSelecting)return;const e=()=>{h.isSelecting=!1,u.removeEventListener("mouseup",e),u.removeEventListener("mousemove",t)},t=n=>{if(1&~n.buttons&&h.isSelecting)return h.isSelecting=!1,u.removeEventListener("mouseup",e),void u.removeEventListener("mousemove",t);const o=!m.contains(n.target);let l=null;if(o){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=m.contains(e)?ot(e):null,l)break}else l=ot(n.target);!l||null!==h.focusCell&&l.elem===h.focusCell.elem||(h.setNextFocus({focusCell:l,override:o}),r.dispatchCommand(N,void 0))};h.isSelecting=!0,u.addEventListener("mouseup",e,h.listenerOptions),u.addEventListener("mousemove",t,h.listenerOptions)})()}),h.listenerOptions);u.addEventListener("mousedown",(e=>{0===e.button&&r.update((()=>{const t=g(),n=e.target;Ue(t)&&t.tableKey===h.tableNodeKey&&c.contains(n)&&h.$clearHighlight()}))}),h.listenerOptions);for(const[t,n]of Qe)h.listenersToRemove.add(r.registerCommand(t,(t=>_t(r,t,n,e,h)),R));h.listenersToRemove.add(r.registerCommand(O,(t=>{const n=g();if(Ue(n)){const o=Ge(e,n.focus.getNode());if(null!==o)return wt(t),o.selectEnd(),!0}return!1}),R));const p=n=>()=>{const o=g();if(!gt(o,e))return!1;if(Ue(o))return h.$clearText(),!0;if(f(o)){if(!se(Ge(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),c=e.isParentOf(l);if(s&&!c||c&&!s)return h.$clearText(),!0;const a=t(o.anchor.getNode(),(e=>i(e))),u=a&&t(a,(e=>i(e)&&se(e.getParent())));if(!i(u)||!i(a))return!1;if(n===j&&null===u.getPreviousSibling())return!0}return!1};for(const e of Ze)h.listenersToRemove.add(r.registerCommand(e,p(e),F));const C=t=>{const n=g();if(!Ue(n)&&!f(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Ue(n)&&(t&&(t.preventDefault(),t.stopPropagation()),h.$clearText(),!0)};for(const e of et)h.listenersToRemove.add(r.registerCommand(e,C,F));return h.listenersToRemove.add(r.registerCommand(k,(e=>{const t=g();if(t){if(!Ue(t)&&!f(t))return!1;Z(r,o(e,ClipboardEvent)?e:null,ee(t));const n=C(e);return f(t)?(t.removeText(),!0):n}return!1}),F)),h.listenersToRemove.add(r.registerCommand(K,(n=>{const o=g();if(!gt(o,e))return!1;if(Ue(o))return h.$formatCells(n),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>se(e)));if(!se(e))return!1}return!1}),F)),h.listenersToRemove.add(r.registerCommand(E,(t=>{const n=g();if(!Ue(n)||!gt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!se(o)||!se(r))return!1;const[l,s,c]=Pe(e,o,r),a=Math.max(s.startRow+s.cell.__rowSpan-1,c.startRow+c.cell.__rowSpan-1),u=Math.max(s.startColumn+s.cell.__colSpan-1,c.startColumn+c.cell.__colSpan-1),h=Math.min(s.startRow,c.startRow),d=Math.min(s.startColumn,c.startColumn),f=new Set;for(let e=h;e<=a;e++)for(let n=d;n<=u;n++){const o=l[e][n].cell;if(f.has(o))continue;f.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];i(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),F)),h.listenersToRemove.add(r.registerCommand(M,(n=>{const o=g();if(!gt(o,e))return!1;if(Ue(o))return h.$clearHighlight(),!1;if(f(o)){const l=t(o.anchor.getNode(),(e=>se(e)));if(!se(l))return!1;if("string"==typeof n){const t=yt(r,o,e);if(t)return bt(t,e,[d(n)]),!0}}return!1}),F)),l&&h.listenersToRemove.add(r.registerCommand(A,(n=>{const o=g();if(!f(o)||!o.isCollapsed()||!gt(o,e))return!1;const r=Ct(o.anchor.getNode());return!(null===r||!e.is(St(r)))&&(wt(n),function(e,n){const o="next"===n?"getNextSibling":"getPreviousSibling",r="next"===n?"getFirstChild":"getLastChild",l=e[o]();if(i(l))return l.selectEnd();const s=t(e,pe);null===s&&ae(247);for(let e=s[o]();pe(e);e=e[o]()){const t=e[r]();if(i(t))return t.selectEnd()}const c=t(s,At);null===c&&ae(248);"next"===n?c.selectNext():c.selectPrevious()}(r,n.shiftKey?"previous":"next"),!0)}),F)),h.listenersToRemove.add(r.registerCommand($,(t=>e.isSelected()),R)),h.listenersToRemove.add(r.registerCommand(P,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=Ue(o),i=f(o)&&null!==t(o.anchor.getNode(),(e=>se(e)))&&null!==t(o.focus.getNode(),(e=>se(e)))||l;if(1!==n.length||!At(n[0])||!i||null===r)return!1;const[c]=r,u=n[0],h=u.getChildren(),d=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),m=t(c.getNode(),(e=>se(e))),p=m&&t(m,(e=>pe(e))),C=p&&t(p,(e=>At(e)));if(!se(m)||!pe(p)||!At(C))return!1;const S=p.getIndexWithinParent(),_=Math.min(C.getChildrenSize()-1,S+g-1),w=m.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,w+d-1),y=Math.min(w,b),N=Math.min(S,_),x=Math.max(w,b),v=Math.max(S,_),T=C.getChildren();let R=0;for(let e=N;e<=v;e++){const t=T[e];if(!pe(t))return!1;const n=h[R];if(!pe(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!se(t))return!1;const n=r[l];if(!se(n))return!1;const i=t.getChildren();n.getChildren().forEach((e=>{if(a(e)){s().append(e),t.append(e)}else t.append(e)})),i.forEach((e=>e.remove())),l++}R++}return!0}),F)),h.listenersToRemove.add(r.registerCommand(N,(()=>{const n=g(),o=H(),l=h.getAndClearNextFocus();if(null!==l){const{focusCell:t}=l;if(Ue(n)&&n.tableKey===h.tableNodeKey)return(t.x!==h.focusX||t.y!==h.focusY)&&(h.$setFocusCellForSelection(t),!0);if(t!==h.anchorCell&>(n,e))return h.$setFocusCellForSelection(t),!0}if(h.getAndClearShouldCheckSelection()&&f(o)&&f(n)&&n.isCollapsed()){const o=n.anchor.getNode(),r=e.getFirstChild(),l=Ct(o);if(null!==l&&pe(r)){const n=r.getFirstChild();if(se(n)&&e.is(t(l,(t=>t.is(e)||t.is(n)))))return n.selectStart(),!0}}if(f(n)){const{anchor:t,focus:o}=n,l=t.getNode(),s=o.getNode(),i=Ct(l),c=Ct(s),a=!(!i||!e.is(St(i))),u=!(!c||!e.is(St(c))),d=a!==u,g=a&&u,f=n.isBackward();if(d){const t=n.clone();if(u){const[n]=Pe(e,c,c),o=n[0][0].cell,r=n[n.length-1].at(-1).cell;t.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(a){const[n]=Pe(e,i,i),o=n[0][0].cell,r=n[n.length-1].at(-1).cell;t.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}y(t),it(r,h)}else g&&(i.is(c)||(h.$setAnchorCellForSelection(Nt(h,i)),h.$setFocusCellForSelection(Nt(h,c),!0)))}else if(n&&Ue(n)&&n.is(o)&&n.tableKey===e.getKey()){const t=x(u);if(t&&t.anchorNode&&t.focusNode){const o=W(t.focusNode),l=o&&!e.isParentOf(o),s=W(t.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&t.rangeCount>0){const o=B(t,r);o&&(o.anchor.set(e.getKey(),n.isBackward()?e.getChildrenSize():0,"element"),t.removeAllRanges(),y(o))}}}return n&&!n.is(o)&&(Ue(n)||Ue(o))&&h.tableSelection&&!h.tableSelection.is(o)?(Ue(n)&&n.tableKey===h.tableNodeKey?h.$updateTableTableSelection(n):!Ue(n)&&Ue(o)&&o.tableKey===h.tableNodeKey&&h.$updateTableTableSelection(null),!1):(h.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),st(t.table,(t=>{const n=t.elem;t.highlighted=!1,pt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(r,h):!h.hasHijackedSelectionStyles&&e.isSelected()&&it(r,h),!1)}),F)),h.listenersToRemove.add(r.registerCommand(L,(()=>{const t=g();if(!f(t)||!t.isCollapsed()||!gt(t,e))return!1;const n=yt(r,t,e);return!!n&&(bt(n,e),!0)}),F)),h}function nt(e){return e[je]||null}function ot(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function rt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=qe(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function lt(e,t,n){const o=new Set(n?n.getNodes():[]);st(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,mt(e,t)):(t.highlighted=!1,pt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function st(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=W(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function it(e,t){t.$disableHighlightStyle(),st(t.table,(t=>{t.highlighted=!0,mt(e,t)}))}const ct=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?ft(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?ft(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?ft(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?ft(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function at(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function ut([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function ht(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&ae(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&ae(250,n,String(s)),i}function dt(e,t,n,o,r){const l=Be(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);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);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=at(e,t);return null===n&&ae(249,t.cell.getKey()),n}(l,n),[d,g]=ut(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const C=p[f];if(void 0===C)return!1;const[S,_]=function(e,t,n){const o=Be(e,t,n),r=at(o,t);if(r)return[ht(e,o,r),ht(e,o,ut(r))];const l=at(o,n);if(l)return[ht(e,o,ut(l)),ht(e,o,l)];const s=["minColumn","minRow"];return[ht(e,o,s),ht(e,o,ut(s))]}(t,n,C),w=Nt(e,S.cell),b=Nt(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function gt(e,t){if(f(e)||Ue(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function ft(e,t){t?e.selectStart():e.selectEnd()}function mt(t,n){const o=n.elem,r=t._config.theme;se(W(o))||ae(131),e(o,r.tableCellSelected)}function pt(e,t){const o=t.elem;se(W(o))||ae(131);const r=e._config.theme;n(o,r.tableCellSelected)}function Ct(e){const n=t(e,se);return se(n)?n:null}function St(e){const n=t(e,At);return At(n)?n:null}function _t(e,n,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=g();if(!gt(s,r)){if(f(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(i(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const t=e.getPreviousSibling();return!!At(t)&&(wt(n),n.shiftKey?s.focus.set(t.getParentOrThrow().getKey(),t.getIndexWithinParent(),"element"):t.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=t(e,(e=>At(e)));if(se(l)&&(l=t(l,At)),l!==r)return!1;if(!l)return!1;const c="down"===o?l.getNextSibling():l.getPreviousSibling();if(!c)return!1;let u=0;"up"===o&&i(c)&&(u=c.getChildrenSize());let h=c;if("up"===o&&i(c)){const e=c.getLastChild();h=e||c,u=a(h)?h.getTextContentSize():0}const d=s.clone();return d.focus.set(h.getKey(),u,a(h)?"text":"element"),y(d),wt(n),!0}if(D(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==Ge(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=We(e),[o]=We(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);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=t(e,(e=>i(e)&&!e.isInline()));if(se(r)&&(r=t(r,At)),!r)return!1;const c="down"===o?r.getNextSibling():r.getPreviousSibling();if(At(c)&&l.tableNodeKey===c.getKey()){const e=c.getFirstDescendant(),t=c.getLastDescendant();if(!e||!t)return!1;const[r]=We(e),[l]=We(t),i=s.clone();return i.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),wt(n),y(i),!0}}}}return"down"===o&&Ot(e)&&l.setShouldCheckSelection(),!1}if(f(s)&&s.isCollapsed()){const{anchor:c,focus:a}=s,u=t(c.getNode(),se),h=t(a.getNode(),se);if(!se(u)||!u.is(h))return!1;const d=St(u);if(d!==r&&null!=d){const t=qe(d,e.getElementByKey(d.getKey()));if(null!=t)return l.table=rt(d,t),_t(e,n,o,d,l)}if("backward"===o||"forward"===o){const e=c.type,l=c.offset,a=c.getNode();if(!a)return!1;const h=s.getNodes();return(1!==h.length||!I(h[0]))&&(!!function(e,n,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,n,o,r){const l=t(o,(e=>i(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===n:n===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,n,o,r)}(e,l,a,o)&&function(e,n,o,r,l){const[s,c]=Pe(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,c,l))return!1;const a=function(e,n,o){const r=t(e,(e=>i(e)&&!e.isInline()));if(!r)return;const l="backward"===n?r.getPreviousSibling():r.getNextSibling();return l&&At(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,l,r);if(!a||At(a))return!1;wt(e),"backward"===l?a.selectEnd():a.selectStart();return!0}(n,a,u,r,o))}const g=e.getElementByKey(u.__key),f=e.getElementByKey(c.key);if(null==f||null==g)return!1;let m;if("element"===c.type)m=f.getBoundingClientRect();else{const t=x(Ve(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?u.getFirstChild():u.getLastChild();if(null==p)return!1;const C=e.getElementByKey(p.__key);if(null==C)return!1;const S=C.getBoundingClientRect();if("up"===o?S.top>m.top-m.height:m.bottom+m.height>S.bottom){wt(n);const e=r.getCordsFromCellNode(u,l.table);if(!n.shiftKey)return ct(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ue(s)){const{anchor:i,focus:c}=s,a=t(i.getNode(),se),u=t(c.getNode(),se),[h]=s.getNodes();At(h)||ae(251);const d=qe(h,e.getElementByKey(h.getKey()));if(!se(a)||!se(u)||!At(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=rt(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),wt(n),n.shiftKey){const[e,t,n]=Pe(r,a,u);return dt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function wt(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function bt(e,t,n){const o=s();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function yt(e,n,o){const r=o.getParent();if(!r)return;const l=x(Ve(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=qe(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=t(n.anchor.getNode(),(e=>se(e)));if(!a)return;const u=t(a,(e=>At(e)));if(!At(u)||!u.is(o))return;const[h,d]=Pe(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===g.startRow&&p===g.startColumn,S=m===f.startRow&&p===f.startColumn;return C?"first":S?"last":void 0}function Nt(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function xt(e,t,n){return Ge(e,W(t,n))}function vt(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Tt(t,o,r){r?(e(t,o.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(n(t,o.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}const Rt=new WeakSet;function Ot(e=b()){return Rt.has(e)}function Ft(e,t){t?Rt.add(e):Rt.delete(e)}class kt extends l{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new kt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Et,priority:1})}}static importJSON(e){const t=Mt();return t.__rowStriping=e.rowStriping||!1,t.__colWidths=e.colWidths,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&ae(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),vt(o,0,this.getColumnCount(),this.getColWidths()),Q(r),e(o,t.theme.table),this.__rowStriping&&Tt(o,t,!0),Ot(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Tt(t,n,this.__rowStriping),vt(t,0,this.getColumnCount(),this.getColWidths()),!1}exportDOM(e){return{...super.exportDOM(e),after:e=>{if(e&&r(e)&&"TABLE"!==e.nodeName&&(e=e.querySelector("table")),!e||!r(e))return null;const t=e.querySelectorAll(":scope > tr");if(t.length>0){const n=document.createElement("tbody");n.append(...t),e.append(n)}return e}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=xt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=W(o.elem);return se(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){this.getWritable().__rowStriping=e}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{se(e)&&(t+=e.getColSpan())})),t}}function Kt(e,t){const n=e.getElementByKey(t.getKey());return null===n&&ae(230),rt(t,n)}function Et(e){const t=Mt();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0);const n=e.querySelector(":scope > colgroup");if(n){let e=[];for(const t of n.querySelectorAll(":scope > col")){const n=t.style.width;if(!n||!te.test(n)){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{node:t}}function Mt(){return u(new kt)}function At(e){return e instanceof kt}export{Pe as $computeTableMap,He as $computeTableMapSkipCellCheck,le as $createTableCellNode,Mt as $createTableNode,Ce as $createTableNodeWithDimensions,me as $createTableRowNode,ze as $createTableSelection,ke as $deleteTableColumn,Ee as $deleteTableColumn__EXPERIMENTAL,Ke as $deleteTableRow__EXPERIMENTAL,Ct as $findCellNode,St as $findTableNode,Kt as $getElementForTableNode,We as $getNodeTriplet,Xe as $getTableAndElementByKey,Se as $getTableCellNodeFromLexicalNode,Le as $getTableCellNodeRect,ye as $getTableColumnIndexFromTableCellNode,we as $getTableNodeFromLexicalNodeOrThrow,be as $getTableRowIndexFromTableCellNode,_e as $getTableRowNodeFromTableCellNodeOrThrow,Oe as $insertTableColumn,Fe as $insertTableColumn__EXPERIMENTAL,ve as $insertTableRow,Re as $insertTableRow__EXPERIMENTAL,Ot as $isScrollableTablesActive,se as $isTableCellNode,At as $isTableNode,pe as $isTableRowNode,Ue as $isTableSelection,xe as $removeTableRowAtIndex,$e as $unmergeCell,ie as INSERT_TABLE_COMMAND,ne as TableCellHeaderStates,oe as TableCellNode,kt as TableNode,Je as TableObserver,ge as TableRowNode,tt as applyTableHandlers,ot as getDOMCellFromTarget,qe as getTableElement,nt as getTableObserverFromTableElement,Ft as setScrollableTablesActive};
|
@@ -8,7 +8,7 @@
|
|
8
8
|
import type { TableCellNode } from './LexicalTableCellNode';
|
9
9
|
import type { TableDOMCell } from './LexicalTableObserver';
|
10
10
|
import type { TableSelection } from './LexicalTableSelection';
|
11
|
-
import type { LexicalEditor, LexicalNode, RangeSelection } from 'lexical';
|
11
|
+
import type { EditorState, LexicalEditor, LexicalNode, RangeSelection } from 'lexical';
|
12
12
|
import { TableNode } from './LexicalTableNode';
|
13
13
|
import { TableDOMTable, TableObserver } from './LexicalTableObserver';
|
14
14
|
declare const LEXICAL_ELEMENT_KEY = "__lexicalTableSelection";
|
@@ -35,4 +35,5 @@ export declare function $removeHighlightStyleToTable(editor: LexicalEditor, tabl
|
|
35
35
|
export declare function $findCellNode(node: LexicalNode): null | TableCellNode;
|
36
36
|
export declare function $findTableNode(node: LexicalNode): null | TableNode;
|
37
37
|
export declare function $getObserverCellFromCellNodeOrThrow(tableObserver: TableObserver, tableCellNode: TableCellNode): TableDOMCell;
|
38
|
+
export declare function $getNearestTableCellInTableFromDOMNode(tableNode: TableNode, startingDOM: Node, editorState?: EditorState): TableCellNode | null;
|
38
39
|
export {};
|
package/package.json
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
"table"
|
9
9
|
],
|
10
10
|
"license": "MIT",
|
11
|
-
"version": "0.20.1-nightly.
|
11
|
+
"version": "0.20.1-nightly.20241129.0",
|
12
12
|
"main": "LexicalTable.js",
|
13
13
|
"types": "index.d.ts",
|
14
14
|
"dependencies": {
|
15
|
-
"@lexical/clipboard": "0.20.1-nightly.
|
16
|
-
"@lexical/utils": "0.20.1-nightly.
|
17
|
-
"lexical": "0.20.1-nightly.
|
15
|
+
"@lexical/clipboard": "0.20.1-nightly.20241129.0",
|
16
|
+
"@lexical/utils": "0.20.1-nightly.20241129.0",
|
17
|
+
"lexical": "0.20.1-nightly.20241129.0"
|
18
18
|
},
|
19
19
|
"repository": {
|
20
20
|
"type": "git",
|