@lexical/table 0.17.2-nightly.20240830.0 → 0.17.2-nightly.20240902.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 +65 -14
- package/LexicalTable.dev.mjs +65 -14
- package/LexicalTable.prod.js +84 -82
- package/LexicalTable.prod.mjs +1 -1
- package/LexicalTableNode.d.ts +14 -7
- package/LexicalTableObserver.d.ts +4 -0
- package/LexicalTableSelectionHelpers.d.ts +4 -1
- package/package.json +4 -4
package/LexicalTable.dev.js
CHANGED
@@ -1357,12 +1357,18 @@ class TableObserver {
|
|
1357
1357
|
this.hasHijackedSelectionStyles = false;
|
1358
1358
|
this.trackTable();
|
1359
1359
|
this.isSelecting = false;
|
1360
|
+
this.abortController = new AbortController();
|
1361
|
+
this.listenerOptions = {
|
1362
|
+
signal: this.abortController.signal
|
1363
|
+
};
|
1360
1364
|
}
|
1361
1365
|
getTable() {
|
1362
1366
|
return this.table;
|
1363
1367
|
}
|
1364
1368
|
removeListeners() {
|
1369
|
+
this.abortController.abort('removeListeners');
|
1365
1370
|
Array.from(this.listenersToRemove).forEach(removeListener => removeListener());
|
1371
|
+
this.listenersToRemove.clear();
|
1366
1372
|
}
|
1367
1373
|
trackTable() {
|
1368
1374
|
const observer = new MutationObserver(records => {
|
@@ -1608,6 +1614,7 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1608
1614
|
const tableObserver = new TableObserver(editor, tableNode.getKey());
|
1609
1615
|
const editorWindow = editor._window || window;
|
1610
1616
|
attachTableObserverToTableElement(tableElement, tableObserver);
|
1617
|
+
tableObserver.listenersToRemove.add(() => deatatchTableObserverFromTableElement(tableElement, tableObserver));
|
1611
1618
|
const createMouseHandlers = () => {
|
1612
1619
|
const onMouseUp = () => {
|
1613
1620
|
tableObserver.isSelecting = false;
|
@@ -1631,11 +1638,11 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1631
1638
|
}, 0);
|
1632
1639
|
};
|
1633
1640
|
return {
|
1634
|
-
onMouseMove
|
1635
|
-
onMouseUp
|
1641
|
+
onMouseMove,
|
1642
|
+
onMouseUp
|
1636
1643
|
};
|
1637
1644
|
};
|
1638
|
-
|
1645
|
+
const onMouseDown = event => {
|
1639
1646
|
setTimeout(() => {
|
1640
1647
|
if (event.button !== 0) {
|
1641
1648
|
return;
|
@@ -1653,10 +1660,11 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1653
1660
|
onMouseMove
|
1654
1661
|
} = createMouseHandlers();
|
1655
1662
|
tableObserver.isSelecting = true;
|
1656
|
-
editorWindow.addEventListener('mouseup', onMouseUp);
|
1657
|
-
editorWindow.addEventListener('mousemove', onMouseMove);
|
1663
|
+
editorWindow.addEventListener('mouseup', onMouseUp, tableObserver.listenerOptions);
|
1664
|
+
editorWindow.addEventListener('mousemove', onMouseMove, tableObserver.listenerOptions);
|
1658
1665
|
}, 0);
|
1659
|
-
}
|
1666
|
+
};
|
1667
|
+
tableElement.addEventListener('mousedown', onMouseDown, tableObserver.listenerOptions);
|
1660
1668
|
|
1661
1669
|
// Clear selection when clicking outside of dom.
|
1662
1670
|
const mouseDownCallback = event => {
|
@@ -1671,8 +1679,7 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1671
1679
|
}
|
1672
1680
|
});
|
1673
1681
|
};
|
1674
|
-
editorWindow.addEventListener('mousedown', mouseDownCallback);
|
1675
|
-
tableObserver.listenersToRemove.add(() => editorWindow.removeEventListener('mousedown', mouseDownCallback));
|
1682
|
+
editorWindow.addEventListener('mousedown', mouseDownCallback, tableObserver.listenerOptions);
|
1676
1683
|
tableObserver.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, event => $handleArrowKey(editor, event, 'down', tableNode, tableObserver), lexical.COMMAND_PRIORITY_HIGH));
|
1677
1684
|
tableObserver.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, event => $handleArrowKey(editor, event, 'up', tableNode, tableObserver), lexical.COMMAND_PRIORITY_HIGH));
|
1678
1685
|
tableObserver.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, event => $handleArrowKey(editor, event, 'backward', tableNode, tableObserver), lexical.COMMAND_PRIORITY_HIGH));
|
@@ -2034,11 +2041,19 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
2034
2041
|
}, lexical.COMMAND_PRIORITY_CRITICAL));
|
2035
2042
|
return tableObserver;
|
2036
2043
|
}
|
2044
|
+
function deatatchTableObserverFromTableElement(tableElement, tableObserver) {
|
2045
|
+
if (getTableObserverFromTableElement(tableElement) === tableObserver) {
|
2046
|
+
delete tableElement[LEXICAL_ELEMENT_KEY];
|
2047
|
+
}
|
2048
|
+
}
|
2037
2049
|
function attachTableObserverToTableElement(tableElement, tableObserver) {
|
2050
|
+
if (!(getTableObserverFromTableElement(tableElement) === null)) {
|
2051
|
+
throw Error(`tableElement already has an attached TableObserver`);
|
2052
|
+
}
|
2038
2053
|
tableElement[LEXICAL_ELEMENT_KEY] = tableObserver;
|
2039
2054
|
}
|
2040
2055
|
function getTableObserverFromTableElement(tableElement) {
|
2041
|
-
return tableElement[LEXICAL_ELEMENT_KEY];
|
2056
|
+
return tableElement[LEXICAL_ELEMENT_KEY] || null;
|
2042
2057
|
}
|
2043
2058
|
function getDOMCellFromTarget(node) {
|
2044
2059
|
let currentNode = node;
|
@@ -2586,14 +2601,30 @@ function $getTableEdgeCursorPosition(editor, selection, tableNode) {
|
|
2586
2601
|
*
|
2587
2602
|
*/
|
2588
2603
|
|
2604
|
+
function setRowStriping(dom, config, rowStriping) {
|
2605
|
+
if (rowStriping) {
|
2606
|
+
utils.addClassNamesToElement(dom, config.theme.tableRowStriping);
|
2607
|
+
dom.setAttribute('data-lexical-row-striping', 'true');
|
2608
|
+
} else {
|
2609
|
+
utils.removeClassNamesFromElement(dom, config.theme.tableRowStriping);
|
2610
|
+
dom.removeAttribute('data-lexical-row-striping');
|
2611
|
+
}
|
2612
|
+
}
|
2613
|
+
|
2589
2614
|
/** @noInheritDoc */
|
2590
2615
|
class TableNode extends lexical.ElementNode {
|
2616
|
+
/** @internal */
|
2617
|
+
|
2591
2618
|
static getType() {
|
2592
2619
|
return 'table';
|
2593
2620
|
}
|
2594
2621
|
static clone(node) {
|
2595
2622
|
return new TableNode(node.__key);
|
2596
2623
|
}
|
2624
|
+
afterCloneFrom(prevNode) {
|
2625
|
+
super.afterCloneFrom(prevNode);
|
2626
|
+
this.__rowStriping = prevNode.__rowStriping;
|
2627
|
+
}
|
2597
2628
|
static importDOM() {
|
2598
2629
|
return {
|
2599
2630
|
table: _node => ({
|
@@ -2602,15 +2633,19 @@ class TableNode extends lexical.ElementNode {
|
|
2602
2633
|
})
|
2603
2634
|
};
|
2604
2635
|
}
|
2605
|
-
static importJSON(
|
2606
|
-
|
2636
|
+
static importJSON(serializedNode) {
|
2637
|
+
const tableNode = $createTableNode();
|
2638
|
+
tableNode.__rowStriping = serializedNode.rowStriping || false;
|
2639
|
+
return tableNode;
|
2607
2640
|
}
|
2608
2641
|
constructor(key) {
|
2609
2642
|
super(key);
|
2643
|
+
this.__rowStriping = false;
|
2610
2644
|
}
|
2611
2645
|
exportJSON() {
|
2612
2646
|
return {
|
2613
2647
|
...super.exportJSON(),
|
2648
|
+
rowStriping: this.__rowStriping ? this.__rowStriping : undefined,
|
2614
2649
|
type: 'table',
|
2615
2650
|
version: 1
|
2616
2651
|
};
|
@@ -2618,9 +2653,15 @@ class TableNode extends lexical.ElementNode {
|
|
2618
2653
|
createDOM(config, editor) {
|
2619
2654
|
const tableElement = document.createElement('table');
|
2620
2655
|
utils.addClassNamesToElement(tableElement, config.theme.table);
|
2656
|
+
if (this.__rowStriping) {
|
2657
|
+
setRowStriping(tableElement, config, true);
|
2658
|
+
}
|
2621
2659
|
return tableElement;
|
2622
2660
|
}
|
2623
|
-
updateDOM() {
|
2661
|
+
updateDOM(prevNode, dom, config) {
|
2662
|
+
if (prevNode.__rowStriping !== this.__rowStriping) {
|
2663
|
+
setRowStriping(dom, config, this.__rowStriping);
|
2664
|
+
}
|
2624
2665
|
return false;
|
2625
2666
|
}
|
2626
2667
|
exportDOM(editor) {
|
@@ -2724,6 +2765,12 @@ class TableNode extends lexical.ElementNode {
|
|
2724
2765
|
}
|
2725
2766
|
return node;
|
2726
2767
|
}
|
2768
|
+
getRowStriping() {
|
2769
|
+
return Boolean(this.getLatest().__rowStriping);
|
2770
|
+
}
|
2771
|
+
setRowStriping(newRowStriping) {
|
2772
|
+
this.getWritable().__rowStriping = newRowStriping;
|
2773
|
+
}
|
2727
2774
|
canSelectBefore() {
|
2728
2775
|
return true;
|
2729
2776
|
}
|
@@ -2738,9 +2785,13 @@ function $getElementForTableNode(editor, tableNode) {
|
|
2738
2785
|
}
|
2739
2786
|
return getTable(tableElement);
|
2740
2787
|
}
|
2741
|
-
function $convertTableElement(
|
2788
|
+
function $convertTableElement(domNode) {
|
2789
|
+
const tableNode = $createTableNode();
|
2790
|
+
if (domNode.hasAttribute('data-lexical-row-striping')) {
|
2791
|
+
tableNode.setRowStriping(true);
|
2792
|
+
}
|
2742
2793
|
return {
|
2743
|
-
node:
|
2794
|
+
node: tableNode
|
2744
2795
|
};
|
2745
2796
|
}
|
2746
2797
|
function $createTableNode() {
|
package/LexicalTable.dev.mjs
CHANGED
@@ -1355,12 +1355,18 @@ class TableObserver {
|
|
1355
1355
|
this.hasHijackedSelectionStyles = false;
|
1356
1356
|
this.trackTable();
|
1357
1357
|
this.isSelecting = false;
|
1358
|
+
this.abortController = new AbortController();
|
1359
|
+
this.listenerOptions = {
|
1360
|
+
signal: this.abortController.signal
|
1361
|
+
};
|
1358
1362
|
}
|
1359
1363
|
getTable() {
|
1360
1364
|
return this.table;
|
1361
1365
|
}
|
1362
1366
|
removeListeners() {
|
1367
|
+
this.abortController.abort('removeListeners');
|
1363
1368
|
Array.from(this.listenersToRemove).forEach(removeListener => removeListener());
|
1369
|
+
this.listenersToRemove.clear();
|
1364
1370
|
}
|
1365
1371
|
trackTable() {
|
1366
1372
|
const observer = new MutationObserver(records => {
|
@@ -1606,6 +1612,7 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1606
1612
|
const tableObserver = new TableObserver(editor, tableNode.getKey());
|
1607
1613
|
const editorWindow = editor._window || window;
|
1608
1614
|
attachTableObserverToTableElement(tableElement, tableObserver);
|
1615
|
+
tableObserver.listenersToRemove.add(() => deatatchTableObserverFromTableElement(tableElement, tableObserver));
|
1609
1616
|
const createMouseHandlers = () => {
|
1610
1617
|
const onMouseUp = () => {
|
1611
1618
|
tableObserver.isSelecting = false;
|
@@ -1629,11 +1636,11 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1629
1636
|
}, 0);
|
1630
1637
|
};
|
1631
1638
|
return {
|
1632
|
-
onMouseMove
|
1633
|
-
onMouseUp
|
1639
|
+
onMouseMove,
|
1640
|
+
onMouseUp
|
1634
1641
|
};
|
1635
1642
|
};
|
1636
|
-
|
1643
|
+
const onMouseDown = event => {
|
1637
1644
|
setTimeout(() => {
|
1638
1645
|
if (event.button !== 0) {
|
1639
1646
|
return;
|
@@ -1651,10 +1658,11 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1651
1658
|
onMouseMove
|
1652
1659
|
} = createMouseHandlers();
|
1653
1660
|
tableObserver.isSelecting = true;
|
1654
|
-
editorWindow.addEventListener('mouseup', onMouseUp);
|
1655
|
-
editorWindow.addEventListener('mousemove', onMouseMove);
|
1661
|
+
editorWindow.addEventListener('mouseup', onMouseUp, tableObserver.listenerOptions);
|
1662
|
+
editorWindow.addEventListener('mousemove', onMouseMove, tableObserver.listenerOptions);
|
1656
1663
|
}, 0);
|
1657
|
-
}
|
1664
|
+
};
|
1665
|
+
tableElement.addEventListener('mousedown', onMouseDown, tableObserver.listenerOptions);
|
1658
1666
|
|
1659
1667
|
// Clear selection when clicking outside of dom.
|
1660
1668
|
const mouseDownCallback = event => {
|
@@ -1669,8 +1677,7 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
1669
1677
|
}
|
1670
1678
|
});
|
1671
1679
|
};
|
1672
|
-
editorWindow.addEventListener('mousedown', mouseDownCallback);
|
1673
|
-
tableObserver.listenersToRemove.add(() => editorWindow.removeEventListener('mousedown', mouseDownCallback));
|
1680
|
+
editorWindow.addEventListener('mousedown', mouseDownCallback, tableObserver.listenerOptions);
|
1674
1681
|
tableObserver.listenersToRemove.add(editor.registerCommand(KEY_ARROW_DOWN_COMMAND, event => $handleArrowKey(editor, event, 'down', tableNode, tableObserver), COMMAND_PRIORITY_HIGH));
|
1675
1682
|
tableObserver.listenersToRemove.add(editor.registerCommand(KEY_ARROW_UP_COMMAND, event => $handleArrowKey(editor, event, 'up', tableNode, tableObserver), COMMAND_PRIORITY_HIGH));
|
1676
1683
|
tableObserver.listenersToRemove.add(editor.registerCommand(KEY_ARROW_LEFT_COMMAND, event => $handleArrowKey(editor, event, 'backward', tableNode, tableObserver), COMMAND_PRIORITY_HIGH));
|
@@ -2032,11 +2039,19 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
|
|
2032
2039
|
}, COMMAND_PRIORITY_CRITICAL));
|
2033
2040
|
return tableObserver;
|
2034
2041
|
}
|
2042
|
+
function deatatchTableObserverFromTableElement(tableElement, tableObserver) {
|
2043
|
+
if (getTableObserverFromTableElement(tableElement) === tableObserver) {
|
2044
|
+
delete tableElement[LEXICAL_ELEMENT_KEY];
|
2045
|
+
}
|
2046
|
+
}
|
2035
2047
|
function attachTableObserverToTableElement(tableElement, tableObserver) {
|
2048
|
+
if (!(getTableObserverFromTableElement(tableElement) === null)) {
|
2049
|
+
throw Error(`tableElement already has an attached TableObserver`);
|
2050
|
+
}
|
2036
2051
|
tableElement[LEXICAL_ELEMENT_KEY] = tableObserver;
|
2037
2052
|
}
|
2038
2053
|
function getTableObserverFromTableElement(tableElement) {
|
2039
|
-
return tableElement[LEXICAL_ELEMENT_KEY];
|
2054
|
+
return tableElement[LEXICAL_ELEMENT_KEY] || null;
|
2040
2055
|
}
|
2041
2056
|
function getDOMCellFromTarget(node) {
|
2042
2057
|
let currentNode = node;
|
@@ -2584,14 +2599,30 @@ function $getTableEdgeCursorPosition(editor, selection, tableNode) {
|
|
2584
2599
|
*
|
2585
2600
|
*/
|
2586
2601
|
|
2602
|
+
function setRowStriping(dom, config, rowStriping) {
|
2603
|
+
if (rowStriping) {
|
2604
|
+
addClassNamesToElement(dom, config.theme.tableRowStriping);
|
2605
|
+
dom.setAttribute('data-lexical-row-striping', 'true');
|
2606
|
+
} else {
|
2607
|
+
removeClassNamesFromElement(dom, config.theme.tableRowStriping);
|
2608
|
+
dom.removeAttribute('data-lexical-row-striping');
|
2609
|
+
}
|
2610
|
+
}
|
2611
|
+
|
2587
2612
|
/** @noInheritDoc */
|
2588
2613
|
class TableNode extends ElementNode {
|
2614
|
+
/** @internal */
|
2615
|
+
|
2589
2616
|
static getType() {
|
2590
2617
|
return 'table';
|
2591
2618
|
}
|
2592
2619
|
static clone(node) {
|
2593
2620
|
return new TableNode(node.__key);
|
2594
2621
|
}
|
2622
|
+
afterCloneFrom(prevNode) {
|
2623
|
+
super.afterCloneFrom(prevNode);
|
2624
|
+
this.__rowStriping = prevNode.__rowStriping;
|
2625
|
+
}
|
2595
2626
|
static importDOM() {
|
2596
2627
|
return {
|
2597
2628
|
table: _node => ({
|
@@ -2600,15 +2631,19 @@ class TableNode extends ElementNode {
|
|
2600
2631
|
})
|
2601
2632
|
};
|
2602
2633
|
}
|
2603
|
-
static importJSON(
|
2604
|
-
|
2634
|
+
static importJSON(serializedNode) {
|
2635
|
+
const tableNode = $createTableNode();
|
2636
|
+
tableNode.__rowStriping = serializedNode.rowStriping || false;
|
2637
|
+
return tableNode;
|
2605
2638
|
}
|
2606
2639
|
constructor(key) {
|
2607
2640
|
super(key);
|
2641
|
+
this.__rowStriping = false;
|
2608
2642
|
}
|
2609
2643
|
exportJSON() {
|
2610
2644
|
return {
|
2611
2645
|
...super.exportJSON(),
|
2646
|
+
rowStriping: this.__rowStriping ? this.__rowStriping : undefined,
|
2612
2647
|
type: 'table',
|
2613
2648
|
version: 1
|
2614
2649
|
};
|
@@ -2616,9 +2651,15 @@ class TableNode extends ElementNode {
|
|
2616
2651
|
createDOM(config, editor) {
|
2617
2652
|
const tableElement = document.createElement('table');
|
2618
2653
|
addClassNamesToElement(tableElement, config.theme.table);
|
2654
|
+
if (this.__rowStriping) {
|
2655
|
+
setRowStriping(tableElement, config, true);
|
2656
|
+
}
|
2619
2657
|
return tableElement;
|
2620
2658
|
}
|
2621
|
-
updateDOM() {
|
2659
|
+
updateDOM(prevNode, dom, config) {
|
2660
|
+
if (prevNode.__rowStriping !== this.__rowStriping) {
|
2661
|
+
setRowStriping(dom, config, this.__rowStriping);
|
2662
|
+
}
|
2622
2663
|
return false;
|
2623
2664
|
}
|
2624
2665
|
exportDOM(editor) {
|
@@ -2722,6 +2763,12 @@ class TableNode extends ElementNode {
|
|
2722
2763
|
}
|
2723
2764
|
return node;
|
2724
2765
|
}
|
2766
|
+
getRowStriping() {
|
2767
|
+
return Boolean(this.getLatest().__rowStriping);
|
2768
|
+
}
|
2769
|
+
setRowStriping(newRowStriping) {
|
2770
|
+
this.getWritable().__rowStriping = newRowStriping;
|
2771
|
+
}
|
2725
2772
|
canSelectBefore() {
|
2726
2773
|
return true;
|
2727
2774
|
}
|
@@ -2736,9 +2783,13 @@ function $getElementForTableNode(editor, tableNode) {
|
|
2736
2783
|
}
|
2737
2784
|
return getTable(tableElement);
|
2738
2785
|
}
|
2739
|
-
function $convertTableElement(
|
2786
|
+
function $convertTableElement(domNode) {
|
2787
|
+
const tableNode = $createTableNode();
|
2788
|
+
if (domNode.hasAttribute('data-lexical-row-striping')) {
|
2789
|
+
tableNode.setRowStriping(true);
|
2790
|
+
}
|
2740
2791
|
return {
|
2741
|
-
node:
|
2792
|
+
node: tableNode
|
2742
2793
|
};
|
2743
2794
|
}
|
2744
2795
|
function $createTableNode() {
|
package/LexicalTable.prod.js
CHANGED
@@ -7,91 +7,93 @@
|
|
7
7
|
*/
|
8
8
|
|
9
9
|
'use strict';var h=require("@lexical/utils"),u=require("lexical"),aa=require("@lexical/clipboard");let ba=/^(\d+(?:\.\d+)?)px$/,x={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
|
10
|
-
class y extends u.ElementNode{static getType(){return"tablecell"}static clone(a){let b=new y(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=
|
10
|
+
class y extends u.ElementNode{static getType(){return"tablecell"}static clone(a){let b=new y(a.__headerState,a.__colSpan,a.__width,a.__key);b.__rowSpan=a.__rowSpan;b.__backgroundColor=a.__backgroundColor;return b}static importDOM(){return{td:()=>({conversion:ca,priority:0}),th:()=>({conversion:ca,priority:0})}}static importJSON(a){let b=a.rowSpan||1,c=z(a.headerState,a.colSpan||1,a.width||void 0);c.__rowSpan=b;c.__backgroundColor=a.backgroundColor||null;return c}constructor(a=x.NO_STATUS,b=1,c,d){super(d);
|
11
11
|
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){({element:a}=super.exportDOM(a));
|
12
12
|
if(a){a.style.border="1px solid black";1<this.__colSpan&&(a.colSpan=this.__colSpan);1<this.__rowSpan&&(a.rowSpan=this.__rowSpan);a.style.width=`${this.getWidth()||75}px`;a.style.verticalAlign="top";a.style.textAlign="start";let b=this.getBackgroundColor();null!==b?a.style.backgroundColor=b:this.hasHeader()&&(a.style.backgroundColor="#f2f3f5")}return{element:a}}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,
|
13
13
|
rowSpan:this.__rowSpan,type:"tablecell",width:this.getWidth()}}getColSpan(){return this.__colSpan}setColSpan(a){this.getWritable().__colSpan=a;return this}getRowSpan(){return this.__rowSpan}setRowSpan(a){this.getWritable().__rowSpan=a;return this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(a){this.getWritable().__headerState=a;return this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(a){this.getWritable().__width=a;return this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(a){this.getWritable().__backgroundColor=
|
14
14
|
a}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||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}}
|
15
|
-
function ca(a){var b=a.nodeName.toLowerCase(),c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=
|
16
|
-
!u.$isElementNode(m)){q=u.$createParagraphNode();if(u.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;u.$isTextNode(m)&&(d&&m.toggleFormat("bold"),e&&m.toggleFormat("strikethrough"),
|
17
|
-
class
|
18
|
-
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 ea(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:
|
15
|
+
function ca(a){var b=a.nodeName.toLowerCase(),c=void 0;ba.test(a.style.width)&&(c=parseFloat(a.style.width));b=z("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.textDecoration.split(" ");let d="700"===a.fontWeight||"bold"===a.fontWeight,e=c.includes("line-through"),g="italic"===a.fontStyle,f=c.includes("underline");return{after:m=>{0===m.length&&m.push(u.$createParagraphNode());return m},forChild:(m,q)=>{if(A(q)&&
|
16
|
+
!u.$isElementNode(m)){q=u.$createParagraphNode();if(u.$isLineBreakNode(m)&&"\n"===m.getTextContent())return null;u.$isTextNode(m)&&(d&&m.toggleFormat("bold"),e&&m.toggleFormat("strikethrough"),g&&m.toggleFormat("italic"),f&&m.toggleFormat("underline"));q.append(m);return q}return m},node:b}}function z(a,b=1,c){return u.$applyNodeReplacement(new y(a,b,c))}function A(a){return a instanceof y}let da=u.createCommand("INSERT_TABLE_COMMAND");
|
17
|
+
class C extends u.ElementNode{static getType(){return"tablerow"}static clone(a){return new C(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:ea,priority:0})}}static importJSON(a){return D(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,
|
18
|
+
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 ea(a){let b=void 0;ba.test(a.style.height)&&(b=parseFloat(a.style.height));return{node:D(b)}}function D(a){return u.$applyNodeReplacement(new C(a))}function H(a){return a instanceof C}var J;
|
19
19
|
function K(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.");}J=K&&K.__esModule&&Object.prototype.hasOwnProperty.call(K,"default")?K["default"]:K;let fa="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
|
20
|
-
function ha(a){a=h.$findMatchingParent(a,b=>
|
21
|
-
let ka=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function
|
22
|
-
function oa(a,b,c){let d=[],e=null,
|
23
|
-
function
|
24
|
-
function pa(a){let [b,,c]=
|
25
|
-
class qa{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]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return
|
26
|
-
this._cachedNodes=null}clone(){return new qa(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}insertNodes(a){let b=this.focus.getNode();u.$isElementNode(b)||J(151);u.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=u.$getNodeByKey(this.anchor.key);
|
27
|
-
c.columnIndex);let d=Math.max(a.columnIndex,c.columnIndex),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex,c.rowIndex);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(
|
28
|
-
|
29
|
-
|
30
|
-
this.getNodes().filter(c=>
|
31
|
-
class ta{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.hasHijackedSelectionStyles=!1;this.trackTable();this.isSelecting=!1}getTable(){return this.table}removeListeners(){
|
32
|
-
new MutationObserver(b=>{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.table=
|
33
|
-
subtree:!0})})}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();a.update(()=>{var b=u.$getNodeByKey(this.tableNodeKey);if(!
|
34
|
-
b,null);u.$setSelection(null);a.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
|
35
|
-
h.addClassNamesToElement(b,a._config.theme.tableSelection);this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();
|
36
|
-
if(!
|
37
|
-
e;this.focusY=
|
38
|
-
!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=u.$getNearestNodeFromDOMNode(a.elem);
|
39
|
-
"element"),c.formatText(a))});u.$setSelection(b);this.editor.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=u.$getNodeByKey(this.tableNodeKey);if(!
|
40
|
-
e.append(
|
41
|
-
function
|
42
|
-
function
|
43
|
-
function
|
44
|
-
let
|
45
|
-
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}},
|
46
|
-
d+1,a.table)),!0):!1;default:return!1}};function
|
47
|
-
function
|
48
|
-
function
|
49
|
-
function
|
50
|
-
|
51
|
-
d.getPreviousSibling();if(
|
52
|
-
if(null!=q)return e.table=
|
53
|
-
if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>
|
54
|
-
a.getElementByKey(
|
55
|
-
function
|
56
|
-
function
|
57
|
-
function
|
58
|
-
function
|
59
|
-
function
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
b
|
64
|
-
|
65
|
-
|
66
|
-
exports.$
|
67
|
-
|
68
|
-
exports.$
|
69
|
-
|
70
|
-
exports.$
|
71
|
-
|
72
|
-
|
73
|
-
exports.$
|
74
|
-
|
75
|
-
exports.$
|
20
|
+
function ha(a){a=h.$findMatchingParent(a,b=>H(b));if(H(a))return a;throw Error("Expected table cell to be inside of table row.");}function ia(a){a=h.$findMatchingParent(a,b=>M(b));if(M(a))return a;throw Error("Expected table cell to be inside of table.");}function ja(a,b){let c=ia(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)}}
|
21
|
+
let ka=(a,b)=>a===x.BOTH||a===b?b:x.NO_STATUS;function N(a){let b=a.getFirstDescendant();null==b?a.selectStart():b.getParentOrThrow().selectStart()}function la(a,b){let c=a.getFirstChild();null!==c?c.insertBefore(b):a.append(b)}function O(a,b,c){let [d,e,g]=oa(a,b,c);null===e&&J(110);null===g&&J(111);return[d,e,g]}
|
22
|
+
function oa(a,b,c){let d=[],e=null,g=null;a=a.getChildren();for(let t=0;t<a.length;t++){var f=a[t];H(f)||J(146);var m=f.getChildren();f=0;for(let k of m){for(A(k)||J(147);void 0!==d[t]&&void 0!==d[t][f];)f++;m=t;var q=f,p=k;let l={cell:p,startColumn:q,startRow:m},n=p.__rowSpan,r=p.__colSpan;for(let v=0;v<n;v++){void 0===d[m+v]&&(d[m+v]=[]);for(let w=0;w<r;w++)d[m+v][q+w]=l}null!==b&&b.is(p)&&(e=l);null!==c&&c.is(p)&&(g=l);f+=k.__colSpan}}return[d,e,g]}
|
23
|
+
function P(a){a instanceof y||("__type"in a?(a=h.$findMatchingParent(a,A),A(a)||J(148)):(a=h.$findMatchingParent(a.getNode(),A),A(a)||J(148)));let b=a.getParent();H(b)||J(149);let c=b.getParent();M(c)||J(150);return[a,b,c]}
|
24
|
+
function pa(a){let [b,,c]=P(a);a=c.getChildren();let d=a.length;var e=a[0].getChildren().length;let g=Array(d);for(var f=0;f<d;f++)g[f]=Array(e);for(e=0;e<d;e++){f=a[e].getChildren();let m=0;for(let q=0;q<f.length;q++){for(;g[e][m];)m++;let p=f[q],t=p.__rowSpan||1,k=p.__colSpan||1;for(let l=0;l<t;l++)for(let n=0;n<k;n++)g[e+l][m+n]=p;if(b===p)return{colSpan:k,columnIndex:m,rowIndex:e,rowSpan:t};m+=k}}return null}
|
25
|
+
class qa{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]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(a){this._cachedNodes=a}is(a){return Q(a)?this.tableKey===a.tableKey&&this.anchor.is(a.anchor)&&this.focus.is(a.focus):!1}set(a,b,c){this.dirty=!0;this.tableKey=a;this.anchor.key=b;this.focus.key=c;
|
26
|
+
this._cachedNodes=null}clone(){return new qa(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(){}insertText(){}insertNodes(a){let b=this.focus.getNode();u.$isElementNode(b)||J(151);u.$normalizeSelection__EXPERIMENTAL(b.select(0,b.getChildrenSize())).insertNodes(a)}getShape(){var a=u.$getNodeByKey(this.anchor.key);A(a)||J(152);a=pa(a);null===a&&J(153);var b=u.$getNodeByKey(this.focus.key);A(b)||J(154);let c=pa(b);null===c&&J(155);b=Math.min(a.columnIndex,
|
27
|
+
c.columnIndex);let d=Math.max(a.columnIndex,c.columnIndex),e=Math.min(a.rowIndex,c.rowIndex);a=Math.max(a.rowIndex,c.rowIndex);return{fromX:Math.min(b,d),fromY:Math.min(e,a),toX:Math.max(b,d),toY:Math.max(e,a)}}getNodes(){function a(v){let {cell:w,startColumn:B,startRow:E}=v;q=Math.min(q,B);p=Math.min(p,E);t=Math.max(t,B+w.__colSpan-1);k=Math.max(k,E+w.__rowSpan-1)}var b=this._cachedNodes;if(null!==b)return b;var c=this.anchor.getNode();b=this.focus.getNode();var d=h.$findMatchingParent(c,A);c=h.$findMatchingParent(b,
|
28
|
+
A);A(d)||J(152);A(c)||J(154);b=d.getParent();H(b)||J(156);b=b.getParent();M(b)||J(157);var e=c.getParents()[1];if(e!==b)return b.isParentOf(c)?(b=e.getParent(),null==b&&J(159),this.set(this.tableKey,c.getKey(),b.getKey())):(b=b.getParent(),null==b&&J(158),this.set(this.tableKey,b.getKey(),c.getKey())),this.getNodes();let [g,f,m]=O(b,d,c),q=Math.min(f.startColumn,m.startColumn),p=Math.min(f.startRow,m.startRow),t=Math.max(f.startColumn+f.cell.__colSpan-1,m.startColumn+m.cell.__colSpan-1),k=Math.max(f.startRow+
|
29
|
+
f.cell.__rowSpan-1,m.startRow+m.cell.__rowSpan-1);c=q;d=p;e=q;for(var l=p;q<c||p<d||t>e||k>l;){if(q<c){var n=l-d;--c;for(var r=0;r<=n;r++)a(g[d+r][c])}if(p<d)for(n=e-c,--d,r=0;r<=n;r++)a(g[d][c+r]);if(t>e)for(n=l-d,e+=1,r=0;r<=n;r++)a(g[d+r][e]);if(k>l)for(n=e-c,l+=1,r=0;r<=n;r++)a(g[l][c+r])}b=[b];c=null;for(d=p;d<=k;d++)for(e=q;e<=t;e++)({cell:l}=g[d][e]),n=l.getParent(),H(n)||J(160),n!==c&&b.push(n),b.push(l,...ra(l)),c=n;u.isCurrentlyReadOnlyMode()||(this._cachedNodes=b);return b}getTextContent(){let a=
|
30
|
+
this.getNodes().filter(c=>A(c)),b="";for(let c=0;c<a.length;c++){let d=a[c],e=d.__parent,g=(a[c+1]||{}).__parent;b+=d.getTextContent()+(g!==e?"\n":"\t")}return b}}function Q(a){return a instanceof qa}function sa(){let a=u.$createPoint("root",0,"element"),b=u.$createPoint("root",0,"element");return new qa("root",a,b)}function ra(a){let b=[],c=[a];for(;0<c.length;){let d=c.pop();void 0===d&&J(112);u.$isElementNode(d)&&c.unshift(...d.getChildren());d!==a&&b.push(d)}return b}
|
31
|
+
class ta{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.hasHijackedSelectionStyles=!1;this.trackTable();this.isSelecting=!1;this.abortController=new AbortController;this.listenerOptions={signal:this.abortController.signal}}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners");
|
32
|
+
Array.from(this.listenersToRemove).forEach(a=>a());this.listenersToRemove.clear()}trackTable(){let a=new MutationObserver(b=>{this.editor.update(()=>{var c=!1;for(let d=0;d<b.length;d++){const e=b[d].target.nodeName;if("TABLE"===e||"TBODY"===e||"THEAD"===e||"TR"===e){c=!0;break}}if(c){c=this.editor.getElementByKey(this.tableNodeKey);if(!c)throw Error("Expected to find TableElement in DOM");this.table=R(c)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
|
33
|
+
this.table=R(b);a.observe(b,{attributes:!0,childList:!0,subtree:!0})})}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();a.update(()=>{var b=u.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
|
34
|
+
b=R(b);S(a,b,null);u.$setSelection(null);a.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}enableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");h.removeClassNamesFromElement(b,a._config.theme.tableSelection);b.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){let a=this.editor;a.update(()=>{let b=a.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");
|
35
|
+
h.addClassNamesToElement(b,a._config.theme.tableSelection);this.hasHijackedSelectionStyles=!0})}updateTableTableSelection(a){if(null!==a&&a.tableKey===this.tableNodeKey){let b=this.editor;this.tableSelection=a;this.isHighlightingCells=!0;this.disableHighlightStyle();S(b,this.table,this.tableSelection)}else null==a?this.clearHighlight():(this.tableNodeKey=a.tableKey,this.updateTableTableSelection(a))}setFocusCellForSelection(a,b=!1){let c=this.editor;c.update(()=>{var d=u.$getNodeByKey(this.tableNodeKey);
|
36
|
+
if(!M(d))throw Error("Expected TableNode.");if(!c.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");var e=a.x;let g=a.y;this.focusCell=a;if(null!==this.anchorCell){let f=fa?(c._window||window).getSelection():null;f&&f.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(!this.isHighlightingCells&&(this.anchorX!==e||this.anchorY!==g||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.focusX&&g===this.focusY)return;this.focusX=
|
37
|
+
e;this.focusY=g;this.isHighlightingCells&&(e=u.$getNearestNodeFromDOMNode(a.elem),null!=this.tableSelection&&null!=this.anchorCellNodeKey&&A(e)&&d.is(T(e))&&(d=e.getKey(),this.tableSelection=this.tableSelection.clone()||sa(),this.focusCellNodeKey=d,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),u.$setSelection(this.tableSelection),c.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0),S(c,this.table,this.tableSelection)))})}setAnchorCellForSelection(a){this.isHighlightingCells=
|
38
|
+
!1;this.anchorCell=a;this.anchorX=a.x;this.anchorY=a.y;this.editor.update(()=>{var b=u.$getNearestNodeFromDOMNode(a.elem);A(b)&&(b=b.getKey(),this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():sa(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=u.$getSelection();Q(b)||J(11);let c=u.$createRangeSelection(),d=c.anchor,e=c.focus;b.getNodes().forEach(g=>{A(g)&&0!==g.getTextContentSize()&&(d.set(g.getKey(),0,"element"),e.set(g.getKey(),g.getChildrenSize(),
|
39
|
+
"element"),c.formatText(a))});u.$setSelection(b);this.editor.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){let a=this.editor;a.update(()=>{let b=u.$getNodeByKey(this.tableNodeKey);if(!M(b))throw Error("Expected TableNode.");var c=u.$getSelection();Q(c)||J(11);c=c.getNodes().filter(A);c.length===this.table.columns*this.table.rows?(b.selectPrevious(),b.remove(),u.$getRoot().selectStart()):(c.forEach(d=>{if(u.$isElementNode(d)){let e=u.$createParagraphNode(),g=u.$createTextNode();
|
40
|
+
e.append(g);d.append(e);d.getChildren().forEach(f=>{f!==e&&f.remove()})}}),S(a,this.table,null),u.$setSelection(null),a.dispatchCommand(u.SELECTION_CHANGE_COMMAND,void 0))})}}function ua(a,b){null!==va(a)&&J(200);a.__lexicalTableSelection=b}function va(a){return a.__lexicalTableSelection||null}function wa(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}
|
41
|
+
function R(a){let b=[],c={columns:0,domRows:b,rows:0};var d=a.firstChild;let e=a=0;for(b.length=0;null!=d;){var g=d.nodeName;if("TD"===g||"TH"===g){g=d;g={elem:g,hasBackgroundColor:""!==g.style.backgroundColor,highlighted:!1,x:a,y:e};d._cell=g;let f=b[e];void 0===f&&(f=b[e]=[]);f[a]=g}else if(g=d.firstChild,null!=g){d=g;continue}g=d.nextSibling;if(null!=g)a++,d=g;else if(g=d.parentNode,null!=g){d=g.nextSibling;if(null==d)break;e++;a=0}}c.columns=a+1;c.rows=e+1;return c}
|
42
|
+
function S(a,b,c){let d=new Set(c?c.getNodes():[]);xa(b,(e,g)=>{let f=e.elem;d.has(g)?(e.highlighted=!0,ya(a,e)):(e.highlighted=!1,za(a,e),f.getAttribute("style")||f.removeAttribute("style"))})}function xa(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 g=d[e];if(!g)continue;let f=u.$getNearestNodeFromDOMNode(g.elem);null!==f&&b(g,f,{x:e,y:c})}}}function Aa(a,b){b.disableHighlightStyle();xa(b.table,c=>{c.highlighted=!0;ya(a,c)})}
|
43
|
+
function Ba(a,b){b.enableHighlightStyle();xa(b.table,c=>{let d=c.elem;c.highlighted=!1;za(a,c);d.getAttribute("style")||d.removeAttribute("style")})}
|
44
|
+
let Da=(a,b,c,d,e)=>{const g="forward"===e;switch(e){case "backward":case "forward":return c!==(g?a.table.columns-1:0)?(a=b.getCellNodeFromCordsOrThrow(c+(g?1:-1),d,a.table),g?a.selectStart():a.selectEnd()):d!==(g?a.table.rows-1:0)?(a=b.getCellNodeFromCordsOrThrow(g?0:a.table.columns-1,d+(g?1:-1),a.table),g?a.selectStart():a.selectEnd()):g?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!==
|
45
|
+
a.table.rows-1?b.getCellNodeFromCordsOrThrow(c,d+1,a.table).selectStart():b.selectNext(),!0;default:return!1}},Ea=(a,b,c,d,e)=>{const g="forward"===e;switch(e){case "backward":case "forward":return c!==(g?a.table.columns-1:0)&&a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c+(g?1:-1),d,a.table)),!0;case "up":return 0!==d?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,d-1,a.table)),!0):!1;case "down":return d!==a.table.rows-1?(a.setFocusCellForSelection(b.getDOMCellFromCordsOrThrow(c,
|
46
|
+
d+1,a.table)),!0):!1;default:return!1}};function U(a,b){if(u.$isRangeSelection(a)||Q(a)){let c=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return c&&a}return!1}
|
47
|
+
function ya(a,b){a=b.elem;b=u.$getNearestNodeFromDOMNode(a);A(b)||J(131);null===b.getBackgroundColor()?a.style.setProperty("background-color","rgb(172,206,247)"):a.style.setProperty("background-image","linear-gradient(to right, rgba(172,206,247,0.85), rgba(172,206,247,0.85))");a.style.setProperty("caret-color","transparent")}
|
48
|
+
function za(a,b){a=b.elem;b=u.$getNearestNodeFromDOMNode(a);A(b)||J(131);null===b.getBackgroundColor()&&a.style.removeProperty("background-color");a.style.removeProperty("background-image");a.style.removeProperty("caret-color")}function W(a){a=h.$findMatchingParent(a,A);return A(a)?a:null}function T(a){a=h.$findMatchingParent(a,M);return M(a)?a:null}
|
49
|
+
function X(a,b,c,d,e){if(("up"===c||"down"===c)&&Fa(a))return!1;var g=u.$getSelection();if(!U(g,d)){if(u.$isRangeSelection(g)){if(g.isCollapsed()&&"backward"===c){e=g.anchor.type;d=g.anchor.offset;if("element"!==e&&("text"!==e||0!==d))return!1;e=g.anchor.getNode();if(!e)return!1;e=h.$findMatchingParent(e,p=>u.$isElementNode(p)&&!p.isInline());if(!e)return!1;e=e.getPreviousSibling();if(!e||!M(e))return!1;Y(b);e.selectEnd();return!0}if(b.shiftKey&&("up"===c||"down"===c))if(b=g.focus.getNode(),u.$isRootOrShadowRoot(b)){if((c=
|
50
|
+
g.getNodes()[0])&&(c=h.$findMatchingParent(c,A))&&d.isParentOf(c)){b=d.getFirstDescendant();c=d.getLastDescendant();if(!b||!c)return!1;[b]=P(b);[c]=P(c);b=d.getCordsFromCellNode(b,e.table);c=d.getCordsFromCellNode(c,e.table);b=d.getDOMCellFromCordsOrThrow(b.x,b.y,e.table);d=d.getDOMCellFromCordsOrThrow(c.x,c.y,e.table);e.setAnchorCellForSelection(b);e.setFocusCellForSelection(d,!0);return!0}}else{d=h.$findMatchingParent(b,p=>u.$isElementNode(p)&&!p.isInline());if(!d)return!1;d="down"===c?d.getNextSibling():
|
51
|
+
d.getPreviousSibling();if(M(d)&&e.tableNodeKey===d.getKey()){e=d.getFirstDescendant();d=d.getLastDescendant();if(!e||!d)return!1;[e]=P(e);[d]=P(d);b=g.clone();b.focus.set(("up"===c?e:d).getKey(),"up"===c?0:d.getChildrenSize(),"element");u.$setSelection(b);return!0}}}return!1}if(u.$isRangeSelection(g)&&g.isCollapsed()){let {anchor:p,focus:t}=g;var f=h.$findMatchingParent(p.getNode(),A),m=h.$findMatchingParent(t.getNode(),A);if(!A(f)||!f.is(m))return!1;m=T(f);if(m!==d&&null!=m){var q=a.getElementByKey(m.getKey());
|
52
|
+
if(null!=q)return e.table=R(q),X(a,b,c,m,e)}if("backward"===c||"forward"===c){e=p.type;a=p.offset;f=p.getNode();if(!f)return!1;g=g.getNodes();return 1===g.length&&u.$isDecoratorNode(g[0])?!1:Ga(e,a,f,c)?Ha(b,f,d,c):!1}g=a.getElementByKey(f.__key);m=a.getElementByKey(p.key);if(null==m||null==g)return!1;if("element"===p.type)g=m.getBoundingClientRect();else{g=window.getSelection();if(null===g||0===g.rangeCount)return!1;g=g.getRangeAt(0).getBoundingClientRect()}m="up"===c?f.getFirstChild():f.getLastChild();
|
53
|
+
if(null==m)return!1;a=a.getElementByKey(m.__key);if(null==a)return!1;a=a.getBoundingClientRect();if("up"===c?a.top>g.top-g.height:g.bottom+g.height>a.bottom){Y(b);g=d.getCordsFromCellNode(f,e.table);if(b.shiftKey)d=d.getDOMCellFromCordsOrThrow(g.x,g.y,e.table),e.setAnchorCellForSelection(d),e.setFocusCellForSelection(d,!0);else return Da(e,d,g.x,g.y,c);return!0}}else if(Q(g)){let {anchor:p,focus:t}=g;q=h.$findMatchingParent(p.getNode(),A);m=h.$findMatchingParent(t.getNode(),A);[f]=g.getNodes();a=
|
54
|
+
a.getElementByKey(f.getKey());if(!A(q)||!A(m)||!M(f)||null==a)return!1;e.updateTableTableSelection(g);g=R(a);a=d.getCordsFromCellNode(q,g);a=d.getDOMCellFromCordsOrThrow(a.x,a.y,g);e.setAnchorCellForSelection(a);Y(b);if(b.shiftKey)return d=d.getCordsFromCellNode(m,g),Ea(e,f,d.x,d.y,c);m.selectEnd();return!0}return!1}function Y(a){a.preventDefault();a.stopImmediatePropagation();a.stopPropagation()}
|
55
|
+
function Fa(a){return(a=a.getRootElement())?a.hasAttribute("aria-controls")&&"typeahead-menu"===a.getAttribute("aria-controls"):!1}function Ga(a,b,c,d){return"element"===a&&("backward"===d?null===c.getPreviousSibling():null===c.getNextSibling())||Ia(a,b,c,d)}
|
56
|
+
function Ia(a,b,c,d){let e=h.$findMatchingParent(c,g=>u.$isElementNode(g)&&!g.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())}
|
57
|
+
function Ha(a,b,c,d){var e=h.$findMatchingParent(b,A);if(!A(e))return!1;let [g,f]=O(c,e,e);e=g[0][0];let m=g[g.length-1][g[0].length-1],{startColumn:q,startRow:p}=f;if("backward"===d?q!==e.startColumn||p!==e.startRow:q!==m.startColumn||p!==m.startRow)return!1;b=Ja(b,d,c);if(!b||M(b))return!1;Y(a);"backward"===d?b.selectEnd():b.selectStart();return!0}
|
58
|
+
function Ja(a,b,c){if(a=h.$findMatchingParent(a,d=>u.$isElementNode(d)&&!d.isInline()))return(a="backward"===b?a.getPreviousSibling():a.getNextSibling())&&M(a)?a:"backward"===b?c.getPreviousSibling():c.getNextSibling()}function Ka(a,b,c){let d=u.$createParagraphNode();"first"===a?b.insertBefore(d):b.insertAfter(d);d.append(...(c||[]));d.selectEnd()}
|
59
|
+
function La(a,b,c){var d=c.getParent();if(d&&(a=a.getElementByKey(d.getKey()))&&(d=window.getSelection())&&d.anchorNode===a&&(b=h.$findMatchingParent(b.anchor.getNode(),q=>A(q)))&&(a=h.$findMatchingParent(b,q=>M(q)),M(a)&&a.is(c))){var [e,g]=O(c,b,b);c=e[0][0];b=e[e.length-1][e[0].length-1];var {startRow:f,startColumn:m}=g;if(f===c.startRow&&m===c.startColumn)return"first";if(f===b.startRow&&m===b.startColumn)return"last"}}
|
60
|
+
function Ma(a,b,c){c?(h.addClassNamesToElement(a,b.theme.tableRowStriping),a.setAttribute("data-lexical-row-striping","true")):(h.removeClassNamesFromElement(a,b.theme.tableRowStriping),a.removeAttribute("data-lexical-row-striping"))}
|
61
|
+
class Z extends u.ElementNode{static getType(){return"table"}static clone(a){return new Z(a.__key)}afterCloneFrom(a){super.afterCloneFrom(a);this.__rowStriping=a.__rowStriping}static importDOM(){return{table:()=>({conversion:Na,priority:1})}}static importJSON(a){let b=Oa();b.__rowStriping=a.rowStriping||!1;return b}constructor(a){super(a);this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}createDOM(a){let b=
|
62
|
+
document.createElement("table");h.addClassNamesToElement(b,a.theme.table);this.__rowStriping&&Ma(b,a,!0);return b}updateDOM(a,b,c){a.__rowStriping!==this.__rowStriping&&Ma(b,c,this.__rowStriping);return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let c=b.cloneNode(),d=document.createElement("colgroup"),e=document.createElement("tbody");h.isHTMLElement(b)&&e.append(...b.children);b=this.getFirstChildOrThrow();if(!H(b))throw Error("Expected to find row node.");b=b.getChildrenSize();
|
63
|
+
for(let g=0;g<b;g++){let f=document.createElement("col");d.append(f)}c.replaceChildren(d,e);return c}}}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:c,domRows:d}=b;for(b=0;b<c;b++){var e=d[b];if(null!=e&&(e=e.findIndex(g=>{if(g)return{elem:g}=g,u.$getNearestNodeFromDOMNode(g)===a}),-1!==e))return{x:e,y:b}}throw Error("Cell not found in table.");}getDOMCellFromCords(a,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?
|
64
|
+
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=u.$getNearestNodeFromDOMNode(a.elem);return A(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=
|
65
|
+
a}canSelectBefore(){return!0}canIndent(){return!1}}function Na(a){let b=Oa();a.hasAttribute("data-lexical-row-striping")&&b.setRowStriping(!0);return{node:b}}function Oa(){return u.$applyNodeReplacement(new Z)}function M(a){return a instanceof Z}exports.$computeTableMap=O;exports.$computeTableMapSkipCellCheck=oa;exports.$createTableCellNode=z;exports.$createTableNode=Oa;
|
66
|
+
exports.$createTableNodeWithDimensions=function(a,b,c=!0){let d=Oa();for(let g=0;g<a;g++){let f=D();for(let m=0;m<b;m++){var e=x.NO_STATUS;"object"===typeof c?(0===g&&c.rows&&(e|=x.ROW),0===m&&c.columns&&(e|=x.COLUMN)):c&&(0===g&&(e|=x.ROW),0===m&&(e|=x.COLUMN));e=z(e);let q=u.$createParagraphNode();q.append(u.$createTextNode());e.append(q);f.append(e)}d.append(f)}return d};exports.$createTableRowNode=D;exports.$createTableSelection=sa;
|
67
|
+
exports.$deleteTableColumn=function(a,b){let c=a.getChildren();for(let e=0;e<c.length;e++){var d=c[e];if(H(d)){d=d.getChildren();if(b>=d.length||0>b)throw Error("Table column target index out of range");d[b].remove()}}return a};
|
68
|
+
exports.$deleteTableColumn__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||Q(a)||J(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);[a]=P(a);let [e,g,f]=O(d,c,a);({startColumn:b}=g);let {startRow:m,startColumn:q}=f;var p=Math.min(b,q);let t=Math.max(b+c.__colSpan-1,q+a.__colSpan-1),k=t-p+1;if(e[0].length===t-p+1)d.selectPrevious(),d.remove();else{var l=e.length;for(let n=0;n<l;n++)for(let r=p;r<=t;r++){let {cell:v,startColumn:w}=e[n][r];w<p?r===p&&v.setColSpan(v.__colSpan-
|
69
|
+
Math.min(k,v.__colSpan-(p-w))):w+v.__colSpan-1>t?r===t&&v.setColSpan(v.__colSpan-(t-w+1)):v.remove()}p=e[m];a=b>q?p[b+c.__colSpan]:p[q+a.__colSpan];void 0!==a?({cell:b}=a,N(b)):({cell:b}=q<b?p[q-1]:p[b-1],N(b))}};
|
70
|
+
exports.$deleteTableRow__EXPERIMENTAL=function(){var a=u.$getSelection();u.$isRangeSelection(a)||Q(a)||J(188);var b=a.anchor.getNode();a=a.focus.getNode();let [c,,d]=P(b);[a]=P(a);let [e,g,f]=O(d,c,a);({startRow:b}=g);var {startRow:m}=f;a=m+a.__rowSpan-1;if(e.length===a-b+1)d.remove();else{m=e[0].length;var q=e[a+1],p=d.getChildAtIndex(a+1);for(let k=a;k>=b;k--){for(var t=m-1;0<=t;t--){let {cell:l,startRow:n,startColumn:r}=e[k][t];if(r===t&&(k===b&&n<b&&l.setRowSpan(l.__rowSpan-(n-b)),n>=b&&n+l.__rowSpan-
|
71
|
+
1>a))if(l.setRowSpan(l.__rowSpan-(a-n+1)),null===p&&J(122),0===t)la(p,l);else{let {cell:v}=q[t-1];v.insertAfter(l)}}t=d.getChildAtIndex(k);H(t)||J(123,String(k));t.remove()}void 0!==q?({cell:b}=q[0],N(b)):({cell:b}=e[b-1][0],N(b))}};exports.$findCellNode=W;exports.$findTableNode=T;exports.$getElementForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return R(a)};exports.$getNodeTriplet=P;
|
72
|
+
exports.$getTableCellNodeFromLexicalNode=function(a){a=h.$findMatchingParent(a,b=>A(b));return A(a)?a:null};exports.$getTableCellNodeRect=pa;exports.$getTableColumnIndexFromTableCellNode=function(a){return ha(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=ia;exports.$getTableRowIndexFromTableCellNode=function(a){let b=ha(a);return ia(b).getChildren().findIndex(c=>c.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=ha;
|
73
|
+
exports.$insertTableColumn=function(a,b,c=!0,d,e){let g=a.getChildren(),f=[];for(let p=0;p<g.length;p++){let t=g[p];if(H(t))for(let k=0;k<d;k++){var m=t.getChildren();if(b>=m.length||0>b)throw Error("Table column target index out of range");m=m[b];A(m)||J(12);let {left:l,right:n}=ja(m,e);var q=x.NO_STATUS;if(l&&l.hasHeaderState(x.ROW)||n&&n.hasHeaderState(x.ROW))q|=x.ROW;q=z(q);q.append(u.$createParagraphNode());f.push({newTableCell:q,targetCell:m})}}f.forEach(({newTableCell:p,targetCell:t})=>{c?
|
74
|
+
t.insertAfter(p):t.insertBefore(p)});return a};
|
75
|
+
exports.$insertTableColumn__EXPERIMENTAL=function(a=!0){function b(k=x.NO_STATUS){k=z(k).append(u.$createParagraphNode());null===p&&(p=k);return k}var c=u.$getSelection();u.$isRangeSelection(c)||Q(c)||J(188);var d=c.anchor.getNode();c=c.focus.getNode();[d]=P(d);let [e,,g]=P(c),[f,m,q]=O(g,e,d);d=f.length;c=a?Math.max(m.startColumn,q.startColumn):Math.min(m.startColumn,q.startColumn);a=a?c+e.__colSpan-1:c-1;c=g.getFirstChild();H(c)||J(120);let p=null;var t=c;a:for(c=0;c<d;c++){0!==c&&(t=t.getNextSibling(),
|
76
|
+
H(t)||J(121));let k=f[c],l=ka(k[0>a?0:a].cell.__headerState,x.ROW);if(0>a){la(t,b(l));continue}let {cell:n,startColumn:r,startRow:v}=k[a];if(r+n.__colSpan-1<=a){let w=n,B=v,E=a;for(;B!==c&&1<w.__rowSpan;)if(E-=n.__colSpan,0<=E){let {cell:G,startRow:I}=k[E];w=G;B=I}else{t.append(b(l));continue a}w.insertAfter(b(l))}else n.setColSpan(n.__colSpan+1)}null!==p&&N(p)};
|
77
|
+
exports.$insertTableRow=function(a,b,c=!0,d,e){var g=a.getChildren();if(b>=g.length||0>b)throw Error("Table row target index out of range");b=g[b];if(H(b))for(g=0;g<d;g++){let m=b.getChildren(),q=m.length,p=D();for(let t=0;t<q;t++){var f=m[t];A(f)||J(12);let {above:k,below:l}=ja(f,e);f=x.NO_STATUS;let n=k&&k.getWidth()||l&&l.getWidth()||void 0;if(k&&k.hasHeaderState(x.COLUMN)||l&&l.hasHeaderState(x.COLUMN))f|=x.COLUMN;f=z(f,1,n);f.append(u.$createParagraphNode());p.append(f)}c?b.insertAfter(p):b.insertBefore(p)}else throw Error("Row before insertion index does not exist.");
|
76
78
|
return a};
|
77
|
-
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=u.$getSelection();u.$isRangeSelection(b)||
|
78
|
-
a=
|
79
|
-
exports.$unmergeCell=function(){var a=u.$getSelection();u.$isRangeSelection(a)||
|
80
|
-
1)}if(null===m)for(m=0;m<a;m++)la(
|
81
|
-
exports.applyTableHandlers=function(a,b,c,d){function e(k){k=a.getCordsFromCellNode(k,
|
82
|
-
k),m.removeEventListener("mousemove",l);else{var
|
83
|
-
{const l=u.$getSelection(),n=k.target;
|
84
|
-
k=>
|
85
|
-
h.$findMatchingParent(l.anchor.getNode(),v=>
|
86
|
-
u.DELETE_CHARACTER_COMMAND].forEach(k=>{
|
87
|
-
|
88
|
-
k=>{let l=u.$getSelection();if(!
|
89
|
-
|
90
|
-
|
91
|
-
()=>a.isSelected(),u.COMMAND_PRIORITY_HIGH));
|
92
|
-
F=>
|
93
|
-
let
|
94
|
-
|
95
|
-
(
|
96
|
-
!
|
97
|
-
exports.getTableObserverFromTableElement=
|
79
|
+
exports.$insertTableRow__EXPERIMENTAL=function(a=!0){var b=u.$getSelection();u.$isRangeSelection(b)||Q(b)||J(188);b=b.focus.getNode();let [c,,d]=P(b),[e,g]=O(d,c,c);b=e[0].length;var {startRow:f}=g;if(a){a=f+c.__rowSpan-1;var m=e[a];f=D();for(var q=0;q<b;q++){let {cell:t,startRow:k}=m[q];if(k+t.__rowSpan-1<=a){var p=ka(m[q].cell.__headerState,x.COLUMN);f.append(z(p).append(u.$createParagraphNode()))}else t.setRowSpan(t.__rowSpan+1)}b=d.getChildAtIndex(a);H(b)||J(145);b.insertAfter(f)}else{m=e[f];
|
80
|
+
a=D();for(q=0;q<b;q++){let {cell:t,startRow:k}=m[q];k===f?(p=ka(m[q].cell.__headerState,x.COLUMN),a.append(z(p).append(u.$createParagraphNode()))):t.setRowSpan(t.__rowSpan+1)}b=d.getChildAtIndex(f);H(b)||J(145);b.insertBefore(a)}};exports.$isTableCellNode=A;exports.$isTableNode=M;exports.$isTableRowNode=H;exports.$isTableSelection=Q;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};
|
81
|
+
exports.$unmergeCell=function(){var a=u.$getSelection();u.$isRangeSelection(a)||Q(a)||J(188);a=a.anchor.getNode();let [b,c,d]=P(a);a=b.__colSpan;let e=b.__rowSpan;if(1<a){for(var g=1;g<a;g++)b.insertAfter(z(x.NO_STATUS).append(u.$createParagraphNode()));b.setColSpan(1)}if(1<e){let [q,p]=O(d,b,b),{startColumn:t,startRow:k}=p,l;for(g=1;g<e;g++){var f=k+g;let n=q[f];l=(l||c).getNextSibling();H(l)||J(125);var m=null;for(let r=0;r<t;r++){let v=n[r],w=v.cell;v.startRow===f&&(m=w);1<w.__colSpan&&(r+=w.__colSpan-
|
82
|
+
1)}if(null===m)for(m=0;m<a;m++)la(l,z(x.NO_STATUS).append(u.$createParagraphNode()));else for(f=0;f<a;f++)m.insertAfter(z(x.NO_STATUS).append(u.$createParagraphNode()))}b.setRowSpan(1)}};exports.INSERT_TABLE_COMMAND=da;exports.TableCellHeaderStates=x;exports.TableCellNode=y;exports.TableNode=Z;exports.TableObserver=ta;exports.TableRowNode=C;
|
83
|
+
exports.applyTableHandlers=function(a,b,c,d){function e(k){k=a.getCordsFromCellNode(k,f.table);return a.getDOMCellFromCordsOrThrow(k.x,k.y,f.table)}let g=c.getRootElement();if(null===g)throw Error("No root element.");let f=new ta(c,a.getKey()),m=c._window||window;ua(b,f);f.listenersToRemove.add(()=>{var k=f;va(b)===k&&delete b.__lexicalTableSelection});let q=()=>{const k=()=>{f.isSelecting=!1;m.removeEventListener("mouseup",k);m.removeEventListener("mousemove",l)},l=n=>{setTimeout(()=>{if(1!==(n.buttons&
|
84
|
+
1)&&f.isSelecting)f.isSelecting=!1,m.removeEventListener("mouseup",k),m.removeEventListener("mousemove",l);else{var r=wa(n.target);null===r||f.anchorX===r.x&&f.anchorY===r.y||(n.preventDefault(),f.setFocusCellForSelection(r))}},0)};return{onMouseMove:l,onMouseUp:k}};b.addEventListener("mousedown",k=>{setTimeout(()=>{if(0===k.button&&m){var l=wa(k.target);null!==l&&(Y(k),f.setAnchorCellForSelection(l));var {onMouseUp:n,onMouseMove:r}=q();f.isSelecting=!0;m.addEventListener("mouseup",n,f.listenerOptions);
|
85
|
+
m.addEventListener("mousemove",r,f.listenerOptions)}},0)},f.listenerOptions);m.addEventListener("mousedown",k=>{0===k.button&&c.update(()=>{const l=u.$getSelection(),n=k.target;Q(l)&&l.tableKey===f.tableNodeKey&&g.contains(n)&&f.clearHighlight()})},f.listenerOptions);f.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_DOWN_COMMAND,k=>X(c,k,"down",a,f),u.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_UP_COMMAND,k=>X(c,k,"up",a,f),u.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_LEFT_COMMAND,
|
86
|
+
k=>X(c,k,"backward",a,f),u.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(u.KEY_ARROW_RIGHT_COMMAND,k=>X(c,k,"forward",a,f),u.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(u.KEY_ESCAPE_COMMAND,k=>{var l=u.$getSelection();return Q(l)&&(l=h.$findMatchingParent(l.focus.getNode(),A),A(l))?(Y(k),l.selectEnd(),!0):!1},u.COMMAND_PRIORITY_HIGH));let p=k=>()=>{var l=u.$getSelection();if(!U(l,a))return!1;if(Q(l))return f.clearText(),!0;if(u.$isRangeSelection(l)){var n=
|
87
|
+
h.$findMatchingParent(l.anchor.getNode(),v=>A(v));if(!A(n))return!1;var r=l.anchor.getNode();n=l.focus.getNode();r=a.isParentOf(r);n=a.isParentOf(n);if(r&&!n||n&&!r)return f.clearText(),!0;n=(l=h.$findMatchingParent(l.anchor.getNode(),v=>u.$isElementNode(v)))&&h.$findMatchingParent(l,v=>u.$isElementNode(v)&&A(v.getParent()));if(!u.$isElementNode(n)||!u.$isElementNode(l))return!1;if(k===u.DELETE_LINE_COMMAND&&null===n.getPreviousSibling())return!0}return!1};[u.DELETE_WORD_COMMAND,u.DELETE_LINE_COMMAND,
|
88
|
+
u.DELETE_CHARACTER_COMMAND].forEach(k=>{f.listenersToRemove.add(c.registerCommand(k,p(k),u.COMMAND_PRIORITY_CRITICAL))});let t=k=>{const l=u.$getSelection();if(!U(l,a)){if(k=l?l.getNodes():null)if(k=k.find(n=>M(n)&&n.getKey()===f.tableNodeKey),M(k)){if(!k.getParent())return!1;k.remove()}return!1}if(Q(l))return k&&(k.preventDefault(),k.stopPropagation()),f.clearText(),!0;u.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1};f.listenersToRemove.add(c.registerCommand(u.KEY_BACKSPACE_COMMAND,
|
89
|
+
t,u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.KEY_DELETE_COMMAND,t,u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.CUT_COMMAND,k=>{let l=u.$getSelection();if(l){if(!Q(l)&&!u.$isRangeSelection(l))return!1;void aa.copyToClipboard(c,h.objectKlassEquals(k,ClipboardEvent)?k:null,aa.$getClipboardDataFromSelection(l));k=t(k);u.$isRangeSelection(l)&&l.removeText();return k}return!1},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.FORMAT_TEXT_COMMAND,
|
90
|
+
k=>{let l=u.$getSelection();if(!U(l,a))return!1;if(Q(l))return f.formatCells(k),!0;u.$isRangeSelection(l)&&(k=h.$findMatchingParent(l.anchor.getNode(),n=>A(n)),A(k));return!1},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.FORMAT_ELEMENT_COMMAND,k=>{var l=u.$getSelection();if(!Q(l)||!U(l,a))return!1;var n=l.anchor.getNode();l=l.focus.getNode();if(!A(n)||!A(l))return!1;let [r,v,w]=O(a,n,l);n=Math.max(v.startRow,w.startRow);l=Math.max(v.startColumn,w.startColumn);var B=Math.min(v.startRow,
|
91
|
+
w.startRow);let E=Math.min(v.startColumn,w.startColumn);for(;B<=n;B++)for(let I=E;I<=l;I++){var G=r[B][I].cell;G.setFormat(k);G=G.getChildren();for(let L=0;L<G.length;L++){let F=G[L];u.$isElementNode(F)&&!F.isInline()&&F.setFormat(k)}}return!0},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.CONTROLLED_TEXT_INSERTION_COMMAND,k=>{var l=u.$getSelection();if(!U(l,a))return!1;if(Q(l))f.clearHighlight();else if(u.$isRangeSelection(l)){let n=h.$findMatchingParent(l.anchor.getNode(),
|
92
|
+
r=>A(r));if(!A(n))return!1;if("string"===typeof k&&(l=La(c,l,a)))return Ka(l,a,[u.$createTextNode(k)]),!0}return!1},u.COMMAND_PRIORITY_CRITICAL));d&&f.listenersToRemove.add(c.registerCommand(u.KEY_TAB_COMMAND,k=>{var l=u.$getSelection();if(!u.$isRangeSelection(l)||!l.isCollapsed()||!U(l,a))return!1;l=W(l.anchor.getNode());if(null===l)return!1;Y(k);l=a.getCordsFromCellNode(l,f.table);Da(f,a,l.x,l.y,k.shiftKey?"backward":"forward");return!0},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.FOCUS_COMMAND,
|
93
|
+
()=>a.isSelected(),u.COMMAND_PRIORITY_HIGH));f.listenersToRemove.add(c.registerCommand(u.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,k=>{let {nodes:l,selection:n}=k;k=n.getStartEndPoints();var r=Q(n);r=u.$isRangeSelection(n)&&null!==h.$findMatchingParent(n.anchor.getNode(),F=>A(F))&&null!==h.$findMatchingParent(n.focus.getNode(),F=>A(F))||r;if(1!==l.length||!M(l[0])||!r||null===k)return!1;var [v]=k,w=l[0];k=w.getChildren();r=w.getFirstChildOrThrow().getChildrenSize();w=w.getChildrenSize();var B=h.$findMatchingParent(v.getNode(),
|
94
|
+
F=>A(F)),E=B&&h.$findMatchingParent(B,F=>H(F)),G=E&&h.$findMatchingParent(E,F=>M(F));if(!A(B)||!H(E)||!M(G))return!1;v=E.getIndexWithinParent();var I=Math.min(G.getChildrenSize()-1,v+w-1);w=B.getIndexWithinParent();B=Math.min(E.getChildrenSize()-1,w+r-1);r=Math.min(w,B);E=Math.min(v,I);w=Math.max(w,B);v=Math.max(v,I);G=G.getChildren();for(I=0;E<=v;E++){B=G[E];if(!H(B))return!1;var L=k[I];if(!H(L))return!1;B=B.getChildren();L=L.getChildren();let F=0;for(let ma=r;ma<=w;ma++){let na=B[ma];if(!A(na))return!1;
|
95
|
+
let Ca=L[F];if(!A(Ca))return!1;let Pa=na.getChildren();Ca.getChildren().forEach(V=>{u.$isTextNode(V)&&u.$createParagraphNode().append(V);na.append(V)});Pa.forEach(V=>V.remove());F++}I++}return!0},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.SELECTION_CHANGE_COMMAND,()=>{let k=u.$getSelection(),l=u.$getPreviousSelection();if(u.$isRangeSelection(k)){let {anchor:B,focus:E}=k;var n=B.getNode(),r=E.getNode();n=W(n);var v=W(r);r=!(!n||!a.is(T(n)));var w=!(!v||!a.is(T(v)));let G=
|
96
|
+
r!==w,I=r&&w;r=k.isBackward();G?(n=k.clone(),w&&([w]=O(a,v,v),v=w[0][0].cell,w=w[w.length-1].at(-1).cell,n.focus.set(r?v.getKey():w.getKey(),r?v.getChildrenSize():w.getChildrenSize(),"element")),u.$setSelection(n),Aa(c,f)):I&&!n.is(v)&&(f.setAnchorCellForSelection(e(n)),f.setFocusCellForSelection(e(v),!0),f.isSelecting||setTimeout(()=>{let {onMouseUp:L,onMouseMove:F}=q();f.isSelecting=!0;m.addEventListener("mouseup",L);m.addEventListener("mousemove",F)},0))}else k&&Q(k)&&k.is(l)&&k.tableKey===a.getKey()&&
|
97
|
+
(r=fa?(c._window||window).getSelection():null)&&r.anchorNode&&r.focusNode&&(n=(n=u.$getNearestNodeFromDOMNode(r.focusNode))&&!a.is(T(n)),v=(v=u.$getNearestNodeFromDOMNode(r.anchorNode))&&a.is(T(v)),n&&v&&0<r.rangeCount&&(n=u.$createRangeSelectionFromDom(r,c)))&&(n.anchor.set(a.getKey(),k.isBackward()?a.getChildrenSize():0,"element"),r.removeAllRanges(),u.$setSelection(n));if(k&&!k.is(l)&&(Q(k)||Q(l))&&f.tableSelection&&!f.tableSelection.is(l))return Q(k)&&k.tableKey===f.tableNodeKey?f.updateTableTableSelection(k):
|
98
|
+
!Q(k)&&Q(l)&&l.tableKey===f.tableNodeKey&&f.updateTableTableSelection(null),!1;f.hasHijackedSelectionStyles&&!a.isSelected()?Ba(c,f):!f.hasHijackedSelectionStyles&&a.isSelected()&&Aa(c,f);return!1},u.COMMAND_PRIORITY_CRITICAL));f.listenersToRemove.add(c.registerCommand(u.INSERT_PARAGRAPH_COMMAND,()=>{var k=u.$getSelection();return u.$isRangeSelection(k)&&k.isCollapsed()&&U(k,a)?(k=La(c,k,a))?(Ka(k,a),!0):!1:!1},u.COMMAND_PRIORITY_CRITICAL));return f};exports.getDOMCellFromTarget=wa;
|
99
|
+
exports.getTableObserverFromTableElement=va
|
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 d,createCommand as u,$createTextNode as h,$getSelection as g,$isRangeSelection as f,$createPoint as m,$normalizeSelection__EXPERIMENTAL as p,$getNodeByKey as C,isCurrentlyReadOnlyMode as S,$setSelection as _,SELECTION_CHANGE_COMMAND as w,$getNearestNodeFromDOMNode as b,$createRangeSelection as y,$getRoot as N,KEY_ARROW_DOWN_COMMAND as T,COMMAND_PRIORITY_HIGH as x,KEY_ARROW_UP_COMMAND as v,KEY_ARROW_LEFT_COMMAND as E,KEY_ARROW_RIGHT_COMMAND as O,KEY_ESCAPE_COMMAND as M,DELETE_WORD_COMMAND as R,DELETE_LINE_COMMAND as K,DELETE_CHARACTER_COMMAND as F,COMMAND_PRIORITY_CRITICAL as k,KEY_BACKSPACE_COMMAND as A,KEY_DELETE_COMMAND as H,CUT_COMMAND as D,FORMAT_TEXT_COMMAND as P,FORMAT_ELEMENT_COMMAND as B,CONTROLLED_TEXT_INSERTION_COMMAND as L,KEY_TAB_COMMAND as I,FOCUS_COMMAND as W,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as U,$getPreviousSelection as z,$createRangeSelectionFromDom as Y,INSERT_PARAGRAPH_COMMAND as X,$isRootOrShadowRoot as J,$isDecoratorNode as $}from"lexical";import{copyToClipboard as j,$getClipboardDataFromSelection as q}from"@lexical/clipboard";const G=/^(\d+(?:\.\d+)?)px$/,Q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class V extends l{static getType(){return"tablecell"}static clone(e){const t=new V(e.__headerState,e.__colSpan,e.__width,e.__key);return t.__rowSpan=e.__rowSpan,t.__backgroundColor=e.__backgroundColor,t}static importDOM(){return{td:e=>({conversion:Z,priority:0}),th:e=>({conversion:Z,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1,o=ee(e.headerState,t,e.width||void 0);return o.__rowSpan=n,o.__backgroundColor=e.backgroundColor||null,o}constructor(e=Q.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{element:t}=super.exportDOM(e);if(t){const e=t;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";const n=this.getBackgroundColor();null!==n?e.style.backgroundColor=n:this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return{element: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.__colSpan}setColSpan(e){return this.getWritable().__colSpan=e,this}getRowSpan(){return this.__rowSpan}setRowSpan(e){return this.getWritable().__rowSpan=e,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e){return this.getWritable().__headerState=e,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){return this.getWritable().__width=e,this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){this.getWritable().__backgroundColor=e}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!==Q.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 Z(e){const t=e,n=e.nodeName.toLowerCase();let o;G.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ee("th"===n?Q.ROW:Q.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const d=t.style,u=d.textDecoration.split(" "),h="700"===d.fontWeight||"bold"===d.fontWeight,g=u.includes("line-through"),f="italic"===d.fontStyle,m=u.includes("underline");return{after:e=>(0===e.length&&e.push(s()),e),forChild:(e,t)=>{if(te(t)&&!i(e)){const t=s();return c(e)&&"\n"===e.getTextContent()?null:(a(e)&&(h&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ee(e,t=1,n){return d(new V(e,t,n))}function te(e){return e instanceof V}const ne=u("INSERT_TABLE_COMMAND");class oe extends l{static getType(){return"tablerow"}static clone(e){return new oe(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:re,priority:0})}}static importJSON(e){return le(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 re(e){const t=e;let n;return G.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:le(n)}}function le(e){return d(new oe(e))}function se(e){return e instanceof oe}function ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce=ie((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 ae="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function de(e,t,n=!0){const o=at();for(let r=0;r<e;r++){const e=le();for(let o=0;o<t;o++){let t=Q.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=Q.ROW),0===o&&n.columns&&(t|=Q.COLUMN)):n&&(0===r&&(t|=Q.ROW),0===o&&(t|=Q.COLUMN));const l=ee(t),i=s();i.append(h()),l.append(i),e.append(l)}o.append(e)}return o}function ue(e){const n=t(e,(e=>te(e)));return te(n)?n:null}function he(e){const n=t(e,(e=>se(e)));if(se(n))return n;throw new Error("Expected table cell to be inside of table row.")}function ge(e){const n=t(e,(e=>dt(e)));if(dt(n))return n;throw new Error("Expected table cell to be inside of table.")}function fe(e){const t=he(e);return ge(t).getChildren().findIndex((e=>e.is(t)))}function me(e){return he(e).getChildren().findIndex((t=>t.is(e)))}function pe(e,t){const n=ge(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 Ce(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 Se(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(!se(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=le();for(let n=0;n<t;n++){const t=e[n];te(t)||ce(12);const{above:l,below:i}=pe(t,r);let c=Q.NO_STATUS;const a=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(Q.COLUMN)||i&&i.hasHeaderState(Q.COLUMN))&&(c|=Q.COLUMN);const d=ee(c,1,a);d.append(s()),o.append(d)}n?i.insertAfter(o):i.insertBefore(o)}return e}const _e=(e,t)=>e===Q.BOTH||e===t?t:Q.NO_STATUS;function we(e=!0){const t=g();f(t)||Ae(t)||ce(188);const n=t.focus.getNode(),[o,,r]=Ke(n),[l,i]=Me(r,o,o),c=l[0].length,{startRow:a}=i;if(e){const e=a+o.__rowSpan-1,t=l[e],n=le();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=_e(e,Q.COLUMN);n.append(ee(r).append(s()))}else r.setRowSpan(r.__rowSpan+1)}const i=r.getChildAtIndex(e);se(i)||ce(145),i.insertAfter(n)}else{const e=l[a],t=le();for(let n=0;n<c;n++){const{cell:o,startRow:r}=e[n];if(r===a){const o=e[n].cell.__headerState,r=_e(o,Q.COLUMN);t.append(ee(r).append(s()))}else o.setRowSpan(o.__rowSpan+1)}const n=r.getChildAtIndex(a);se(n)||ce(145),n.insertBefore(t)}}function be(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(se(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];te(o)||ce(12);const{left:l,right:c}=pe(o,r);let a=Q.NO_STATUS;(l&&l.hasHeaderState(Q.ROW)||c&&c.hasHeaderState(Q.ROW))&&(a|=Q.ROW);const d=ee(a);d.append(s()),i.push({newTableCell:d,targetCell:o})}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function ye(e=!0){const t=g();f(t)||Ae(t)||ce(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ke(n),[l,,i]=Ke(o),[c,a,d]=Me(i,l,r),u=c.length,h=e?Math.max(a.startColumn,d.startColumn):Math.min(a.startColumn,d.startColumn),m=e?h+l.__colSpan-1:h-1,p=i.getFirstChild();se(p)||ce(120);let C=null;function S(e=Q.NO_STATUS){const t=ee(e).append(s());return null===C&&(C=t),t}let _=p;e:for(let e=0;e<u;e++){if(0!==e){const e=_.getNextSibling();se(e)||ce(121),_=e}const t=c[e],n=t[m<0?0:m].cell.__headerState,o=_e(n,Q.ROW);if(m<0){Ee(_,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&&ve(C)}function Ne(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(se(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 Te(){const e=g();f(e)||Ae(e)||ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,c]=Me(r,o,l),{startRow:a}=i,{startRow:d}=c,u=d+l.__rowSpan-1;if(s.length===u-a+1)return void r.remove();const h=s[0].length,m=s[u+1],p=r.getChildAtIndex(u+1);for(let e=u;e>=a;e--){for(let t=h-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>u))if(n.setRowSpan(n.__rowSpan-(u-o+1)),null===p&&ce(122),0===t)Ee(p,n);else{const{cell:e}=m[t-1];e.insertAfter(n)}}const t=r.getChildAtIndex(e);se(t)||ce(123,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];ve(e)}else{const e=s[a-1],{cell:t}=e[0];ve(t)}}function xe(){const e=g();f(e)||Ae(e)||ce(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,c]=Me(r,o,l),{startColumn:a}=i,{startRow:d,startColumn:u}=c,h=Math.min(a,u),m=Math.max(a+o.__colSpan-1,u+l.__colSpan-1),p=m-h+1;if(s[0].length===m-h+1)return r.selectPrevious(),void r.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=h;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<h){if(t===h){const e=h-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[d],_=a>u?S[a+o.__colSpan]:S[u+l.__colSpan];if(void 0!==_){const{cell:e}=_;ve(e)}else{const e=u<a?S[u-1]:S[a-1],{cell:t}=e;ve(t)}}function ve(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ee(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Oe(){const e=g();f(e)||Ae(e)||ce(188);const t=e.anchor.getNode(),[n,o,r]=Ke(t),l=n.__colSpan,i=n.__rowSpan;if(l>1){for(let e=1;e<l;e++)n.insertAfter(ee(Q.NO_STATUS).append(s()));n.setColSpan(1)}if(i>1){const[e,t]=Me(r,n,n),{startColumn:c,startRow:a}=t;let d;for(let t=1;t<i;t++){const n=a+t,r=e[n];d=(d||o).getNextSibling(),se(d)||ce(125);let i=null;for(let e=0;e<c;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 e=0;e<l;e++)Ee(d,ee(Q.NO_STATUS).append(s()));else for(let e=0;e<l;e++)i.insertAfter(ee(Q.NO_STATUS).append(s()))}n.setRowSpan(1)}}function Me(e,t,n){const[o,r,l]=Re(e,t,n);return null===r&&ce(110),null===l&&ce(111),[o,r,l]}function Re(e,t,n){const o=[];let r=null,l=null;function s(e,s,i){const c={cell:i,startColumn:s,startRow:e},a=i.__rowSpan,d=i.__colSpan;for(let t=0;t<a;t++){void 0===o[e+t]&&(o[e+t]=[]);for(let n=0;n<d;n++)o[e+t][s+n]=c}null!==t&&t.is(i)&&(r=c),null!==n&&n.is(i)&&(l=c)}function i(e,t){return void 0===o[e]||void 0===o[e][t]}const c=e.getChildren();for(let e=0;e<c.length;e++){const t=c[e];se(t)||ce(146);const n=t.getChildren();let o=0;for(const t of n){for(te(t)||ce(147);!i(e,o);)o++;s(e,o,t),o+=t.__colSpan}}return[o,r,l]}function Ke(e){let n;if(e instanceof V)n=e;else if("__type"in e){const o=t(e,te);te(o)||ce(148),n=o}else{const o=t(e.getNode(),te);te(o)||ce(148),n=o}const o=n.getParent();se(o)||ce(149);const r=o.getParent();return dt(r)||ce(150),[n,o,r]}function Fe(e){const[t,,n]=Ke(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}class ke{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]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!Ae(e)&&(this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus))}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new ke(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.focus.getNode();i(t)||ce(151);p(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const e=C(this.anchor.key);te(e)||ce(152);const t=Fe(e);null===t&&ce(153);const n=C(this.focus.key);te(n)||ce(154);const o=Fe(n);null===o&&ce(155);const r=Math.min(t.columnIndex,o.columnIndex),l=Math.max(t.columnIndex,o.columnIndex),s=Math.min(t.rowIndex,o.rowIndex),i=Math.max(t.rowIndex,o.rowIndex);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){const e=this._cachedNodes;if(null!==e)return e;const n=this.anchor.getNode(),o=this.focus.getNode(),r=t(n,te),l=t(o,te);te(r)||ce(152),te(l)||ce(154);const s=r.getParent();se(s)||ce(156);const i=s.getParent();dt(i)||ce(157);const c=l.getParents()[1];if(c!==i){if(i.isParentOf(l)){const e=c.getParent();null==e&&ce(159),this.set(this.tableKey,l.getKey(),e.getKey())}else{const e=i.getParent();null==e&&ce(158),this.set(this.tableKey,e.getKey(),l.getKey())}return this.getNodes()}const[a,d,u]=Me(i,r,l);let h=Math.min(d.startColumn,u.startColumn),g=Math.min(d.startRow,u.startRow),f=Math.max(d.startColumn+d.cell.__colSpan-1,u.startColumn+u.cell.__colSpan-1),m=Math.max(d.startRow+d.cell.__rowSpan-1,u.startRow+u.cell.__rowSpan-1),p=h,C=g,_=h,w=g;function b(e){const{cell:t,startColumn:n,startRow:o}=e;h=Math.min(h,n),g=Math.min(g,o),f=Math.max(f,n+t.__colSpan-1),m=Math.max(m,o+t.__rowSpan-1)}for(;h<p||g<C||f>_||m>w;){if(h<p){const e=w-C,t=p-1;for(let n=0;n<=e;n++)b(a[C+n][t]);p=t}if(g<C){const e=_-p,t=C-1;for(let n=0;n<=e;n++)b(a[t][p+n]);C=t}if(f>_){const e=w-C,t=_+1;for(let n=0;n<=e;n++)b(a[C+n][t]);_=t}if(m>w){const e=_-p,t=w+1;for(let n=0;n<=e;n++)b(a[t][p+n]);w=t}}const y=[i];let N=null;for(let e=g;e<=m;e++)for(let t=h;t<=f;t++){const{cell:n}=a[e][t],o=n.getParent();se(o)||ce(160),o!==N&&y.push(o),y.push(n,...De(n)),N=o}return S()||(this._cachedNodes=y),y}getTextContent(){const e=this.getNodes().filter((e=>te(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 Ae(e){return e instanceof ke}function He(){const e=m("root",0,"element"),t=m("root",0,"element");return new ke("root",e,t)}function De(e){const t=[],n=[e];for(;n.length>0;){const o=n.pop();void 0===o&&ce(112),i(o)&&n.unshift(...o.getChildren()),o!==e&&t.push(o)}return t}class Pe{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.trackTable(),this.isSelecting=!1}getTable(){return this.table}removeListeners(){Array.from(this.listenersToRemove).forEach((e=>e()))}trackTable(){const e=new MutationObserver((e=>{this.editor.update((()=>{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 n=this.editor.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");this.table=ze(n)}))}));this.editor.update((()=>{const t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=ze(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})}))}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(),e.update((()=>{if(!dt(C(this.tableNodeKey)))throw new Error("Expected TableNode.");const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");const n=ze(t);Ye(e,n,null),_(null),e.dispatchCommand(w,void 0)}))}enableHighlightStyle(){const e=this.editor;e.update((()=>{const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");n(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}))}disableHighlightStyle(){const t=this.editor;t.update((()=>{const n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");e(n,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}))}updateTableTableSelection(e){if(null!==e&&e.tableKey===this.tableNodeKey){const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Ye(t,this.table,this.tableSelection)}else null==e?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){const n=this.editor;n.update((()=>{const o=C(this.tableNodeKey);if(!dt(o))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");const r=e.x,l=e.y;if(this.focusCell=e,null!==this.anchorCell){const e=Le(n._window);e&&e.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return}else this.isHighlightingCells=!0,this.disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=b(e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&te(t)&&o.is(tt(t))){const e=t.getKey();this.tableSelection=this.tableSelection.clone()||He(),this.focusCellNodeKey=e,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),_(this.tableSelection),n.dispatchCommand(w,void 0),Ye(n,this.table,this.tableSelection)}}}))}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update((()=>{const t=b(e.elem);if(te(t)){const e=t.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():He(),this.anchorCellNodeKey=e}}))}formatCells(e){this.editor.update((()=>{const t=g();Ae(t)||ce(11);const n=y(),o=n.anchor,r=n.focus;t.getNodes().forEach((t=>{te(t)&&0!==t.getTextContentSize()&&(o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e))})),_(t),this.editor.dispatchCommand(w,void 0)}))}clearText(){const e=this.editor;e.update((()=>{const t=C(this.tableNodeKey);if(!dt(t))throw new Error("Expected TableNode.");const n=g();Ae(n)||ce(11);const o=n.getNodes().filter(te);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(i(e)){const t=s(),n=h();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),Ye(e,this.table,null),_(null),e.dispatchCommand(w,void 0);else{t.selectPrevious(),t.remove();N().selectStart()}}))}}const Be="__lexicalTableSelection",Le=e=>ae?(e||window).getSelection():null;function Ie(e,n,r,l){const c=r.getRootElement();if(null===c)throw new Error("No root element.");const d=new Pe(r,e.getKey()),u=r._window||window;!function(e,t){e[Be]=t}(n,d);const m=()=>{const e=()=>{d.isSelecting=!1,u.removeEventListener("mouseup",e),u.removeEventListener("mousemove",t)},t=n=>{setTimeout((()=>{if(1&~n.buttons&&d.isSelecting)return d.isSelecting=!1,u.removeEventListener("mouseup",e),void u.removeEventListener("mousemove",t);const o=Ue(n.target);null===o||d.anchorX===o.x&&d.anchorY===o.y||(n.preventDefault(),d.setFocusCellForSelection(o))}),0)};return{onMouseMove:t,onMouseUp:e}};n.addEventListener("mousedown",(e=>{setTimeout((()=>{if(0!==e.button)return;if(!u)return;const t=Ue(e.target);null!==t&&(ot(e),d.setAnchorCellForSelection(t));const{onMouseUp:n,onMouseMove:o}=m();d.isSelecting=!0,u.addEventListener("mouseup",n),u.addEventListener("mousemove",o)}),0)}));const p=e=>{0===e.button&&r.update((()=>{const t=g(),n=e.target;Ae(t)&&t.tableKey===d.tableNodeKey&&c.contains(n)&&d.clearHighlight()}))};u.addEventListener("mousedown",p),d.listenersToRemove.add((()=>u.removeEventListener("mousedown",p))),d.listenersToRemove.add(r.registerCommand(T,(t=>nt(r,t,"down",e,d)),x)),d.listenersToRemove.add(r.registerCommand(v,(t=>nt(r,t,"up",e,d)),x)),d.listenersToRemove.add(r.registerCommand(E,(t=>nt(r,t,"backward",e,d)),x)),d.listenersToRemove.add(r.registerCommand(O,(t=>nt(r,t,"forward",e,d)),x)),d.listenersToRemove.add(r.registerCommand(M,(e=>{const n=g();if(Ae(n)){const o=t(n.focus.getNode(),te);if(te(o))return ot(e),o.selectEnd(),!0}return!1}),x));[R,K,F].forEach((n=>{d.listenersToRemove.add(r.registerCommand(n,(n=>()=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return d.clearText(),!0;if(f(o)){const r=t(o.anchor.getNode(),(e=>te(e)));if(!te(r))return!1;const l=o.anchor.getNode(),s=o.focus.getNode(),c=e.isParentOf(l),a=e.isParentOf(s);if(c&&!a||a&&!c)return d.clearText(),!0;const u=t(o.anchor.getNode(),(e=>i(e))),h=u&&t(u,(e=>i(e)&&te(e.getParent())));if(!i(h)||!i(u))return!1;if(n===K&&null===h.getPreviousSibling())return!0}return!1})(n),k))}));const C=n=>{const o=g();if(!qe(o,e)){const e=o?o.getNodes():null;if(e){const t=e.find((e=>dt(e)&&e.getKey()===d.tableNodeKey));if(dt(t)){if(!t.getParent())return!1;t.remove()}}return!1}if(Ae(o))return n&&(n.preventDefault(),n.stopPropagation()),d.clearText(),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>te(e)));if(!te(e))return!1}return!1};function S(t){const n=e.getCordsFromCellNode(t,d.table);return e.getDOMCellFromCordsOrThrow(n.x,n.y,d.table)}return d.listenersToRemove.add(r.registerCommand(A,C,k)),d.listenersToRemove.add(r.registerCommand(H,C,k)),d.listenersToRemove.add(r.registerCommand(D,(e=>{const t=g();if(t){if(!Ae(t)&&!f(t))return!1;j(r,o(e,ClipboardEvent)?e:null,q(t));const n=C(e);return f(t)&&t.removeText(),n}return!1}),k)),d.listenersToRemove.add(r.registerCommand(P,(n=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return d.formatCells(n),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>te(e)));if(!te(e))return!1}return!1}),k)),d.listenersToRemove.add(r.registerCommand(B,(t=>{const n=g();if(!Ae(n)||!qe(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!te(o)||!te(r))return!1;const[l,s,c]=Me(e,o,r),a=Math.max(s.startRow,c.startRow),d=Math.max(s.startColumn,c.startColumn),u=Math.min(s.startRow,c.startRow),h=Math.min(s.startColumn,c.startColumn);for(let e=u;e<=a;e++)for(let n=h;n<=d;n++){const o=l[e][n].cell;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)),d.listenersToRemove.add(r.registerCommand(L,(n=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return d.clearHighlight(),!1;if(f(o)){const l=t(o.anchor.getNode(),(e=>te(e)));if(!te(l))return!1;if("string"==typeof n){const t=lt(r,o,e);if(t)return rt(t,e,[h(n)]),!0}}return!1}),k)),l&&d.listenersToRemove.add(r.registerCommand(I,(t=>{const n=g();if(!f(n)||!n.isCollapsed()||!qe(n,e))return!1;const o=et(n.anchor.getNode());if(null===o)return!1;ot(t);const r=e.getCordsFromCellNode(o,d.table);return $e(d,e,r.x,r.y,t.shiftKey?"backward":"forward"),!0}),k)),d.listenersToRemove.add(r.registerCommand(W,(t=>e.isSelected()),x)),d.listenersToRemove.add(r.registerCommand(U,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=Ae(o),i=f(o)&&null!==t(o.anchor.getNode(),(e=>te(e)))&&null!==t(o.focus.getNode(),(e=>te(e)))||l;if(1!==n.length||!dt(n[0])||!i||null===r)return!1;const[c]=r,d=n[0],u=d.getChildren(),h=d.getFirstChildOrThrow().getChildrenSize(),g=d.getChildrenSize(),m=t(c.getNode(),(e=>te(e))),p=m&&t(m,(e=>se(e))),C=p&&t(p,(e=>dt(e)));if(!te(m)||!se(p)||!dt(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+h-1),y=Math.min(w,b),N=Math.min(S,_),T=Math.max(w,b),x=Math.max(S,_),v=C.getChildren();let E=0;for(let e=N;e<=x;e++){const t=v[e];if(!se(t))return!1;const n=u[E];if(!se(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=T;e++){const t=o[e];if(!te(t))return!1;const n=r[l];if(!te(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++}E++}return!0}),k)),d.listenersToRemove.add(r.registerCommand(w,(()=>{const t=g(),n=z();if(f(t)){const{anchor:n,focus:o}=t,l=n.getNode(),s=o.getNode(),i=et(l),c=et(s),a=!(!i||!e.is(tt(i))),h=!(!c||!e.is(tt(c))),g=a!==h,f=a&&h,p=t.isBackward();if(g){const n=t.clone();if(h){const[t]=Me(e,c,c),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(p?o.getKey():r.getKey(),p?o.getChildrenSize():r.getChildrenSize(),"element")}_(n),Je(r,d)}else f&&(i.is(c)||(d.setAnchorCellForSelection(S(i)),d.setFocusCellForSelection(S(c),!0),d.isSelecting||setTimeout((()=>{const{onMouseUp:e,onMouseMove:t}=m();d.isSelecting=!0,u.addEventListener("mouseup",e),u.addEventListener("mousemove",t)}),0)))}else if(t&&Ae(t)&&t.is(n)&&t.tableKey===e.getKey()){const n=Le(r._window);if(n&&n.anchorNode&&n.focusNode){const o=b(n.focusNode),l=o&&!e.is(tt(o)),s=b(n.anchorNode),i=s&&e.is(tt(s));if(l&&i&&n.rangeCount>0){const o=Y(n,r);o&&(o.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),_(o))}}}return t&&!t.is(n)&&(Ae(t)||Ae(n))&&d.tableSelection&&!d.tableSelection.is(n)?(Ae(t)&&t.tableKey===d.tableNodeKey?d.updateTableTableSelection(t):!Ae(t)&&Ae(n)&&n.tableKey===d.tableNodeKey&&d.updateTableTableSelection(null),!1):(d.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.enableHighlightStyle(),Xe(t.table,(t=>{const n=t.elem;t.highlighted=!1,Ze(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(r,d):!d.hasHijackedSelectionStyles&&e.isSelected()&&Je(r,d),!1)}),k)),d.listenersToRemove.add(r.registerCommand(X,(()=>{const t=g();if(!f(t)||!t.isCollapsed()||!qe(t,e))return!1;const n=lt(r,t,e);return!!n&&(rt(n,e),!0)}),k)),d}function We(e){return e[Be]}function Ue(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 ze(e){const t=[],n={columns:0,domRows:t,rows:0};let o=e.firstChild,r=0,l=0;for(t.length=0;null!=o;){const e=o.nodeName;if("TD"===e||"TH"===e){const e={elem:o,hasBackgroundColor:""!==o.style.backgroundColor,highlighted:!1,x:r,y:l};o._cell=e;let n=t[l];void 0===n&&(n=t[l]=[]),n[r]=e}else{const e=o.firstChild;if(null!=e){o=e;continue}}const n=o.nextSibling;if(null!=n){r++,o=n;continue}const s=o.parentNode;if(null!=s){const e=s.nextSibling;if(null==e)break;l++,r=0,o=e}}return n.columns=r+1,n.rows=l+1,n}function Ye(e,t,n){const o=new Set(n?n.getNodes():[]);Xe(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,Ve(e,t)):(t.highlighted=!1,Ze(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Xe(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=b(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function Je(e,t){t.disableHighlightStyle(),Xe(t.table,(t=>{t.highlighted=!0,Ve(e,t)}))}const $e=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Ge(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Ge(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?Ge(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Ge(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}},je=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)&&e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n+(l?1:-1),o,e.table)),!0;case"up":return 0!==o&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o-1,e.table)),!0);case"down":return o!==e.table.rows-1&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o+1,e.table)),!0);default:return!1}};function qe(e,t){if(f(e)||Ae(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Ge(e,t){t?e.selectStart():e.selectEnd()}const Qe="172,206,247";function Ve(e,t){const n=t.elem,o=b(n);te(o)||ce(131);null===o.getBackgroundColor()?n.style.setProperty("background-color",`rgb(${Qe})`):n.style.setProperty("background-image",`linear-gradient(to right, rgba(${Qe},0.85), rgba(${Qe},0.85))`),n.style.setProperty("caret-color","transparent")}function Ze(e,t){const n=t.elem,o=b(n);te(o)||ce(131);null===o.getBackgroundColor()&&n.style.removeProperty("background-color"),n.style.removeProperty("background-image"),n.style.removeProperty("caret-color")}function et(e){const n=t(e,te);return te(n)?n:null}function tt(e){const n=t(e,dt);return dt(n)?n:null}function nt(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(!qe(s,r)){if(f(s)){if(s.isCollapsed()&&"backward"===o){const e=s.anchor.type,o=s.anchor.offset;if("element"!==e&&("text"!==e||0!==o))return!1;const r=s.anchor.getNode();if(!r)return!1;const l=t(r,(e=>i(e)&&!e.isInline()));if(!l)return!1;const c=l.getPreviousSibling();return!(!c||!dt(c))&&(ot(n),c.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(J(e)){const e=s.getNodes()[0];if(e){const n=t(e,te);if(n&&r.isParentOf(n)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ke(e),[o]=Ke(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}{const n=t(e,(e=>i(e)&&!e.isInline()));if(!n)return!1;const r="down"===o?n.getNextSibling():n.getPreviousSibling();if(dt(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ke(e),[l]=Ke(t),i=s.clone();return i.focus.set(("up"===o?n:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),_(i),!0}}}}return!1}if(f(s)&&s.isCollapsed()){const{anchor:c,focus:a}=s,d=t(c.getNode(),te),u=t(a.getNode(),te);if(!te(d)||!d.is(u))return!1;const h=tt(d);if(h!==r&&null!=h){const t=e.getElementByKey(h.getKey());if(null!=t)return l.table=ze(t),nt(e,n,o,h,l)}if("backward"===o||"forward"===o){const e=c.type,l=c.offset,a=c.getNode();if(!a)return!1;const d=s.getNodes();return(1!==d.length||!$(d[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){const l=t(n,te);if(!te(l))return!1;const[s,c]=Me(o,l,l);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,r))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&&dt(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,r,o);if(!a||dt(a))return!1;ot(e),"backward"===r?a.selectEnd():a.selectStart();return!0}(n,a,r,o))}const g=e.getElementByKey(d.__key),f=e.getElementByKey(c.key);if(null==f||null==g)return!1;let m;if("element"===c.type)m=f.getBoundingClientRect();else{const e=window.getSelection();if(null===e||0===e.rangeCount)return!1;m=e.getRangeAt(0).getBoundingClientRect()}const p="up"===o?d.getFirstChild():d.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){ot(n);const e=r.getCordsFromCellNode(d,l.table);if(!n.shiftKey)return $e(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(Ae(s)){const{anchor:i,focus:c}=s,a=t(i.getNode(),te),d=t(c.getNode(),te),[u]=s.getNodes(),h=e.getElementByKey(u.getKey());if(!te(a)||!te(d)||!dt(u)||null==h)return!1;l.updateTableTableSelection(s);const g=ze(h),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.setAnchorCellForSelection(m),ot(n),n.shiftKey){const e=r.getCordsFromCellNode(d,g);return je(l,u,e.x,e.y,o)}return d.selectEnd(),!0}return!1}function ot(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function rt(e,t,n){const o=s();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function lt(e,n,o){const r=o.getParent();if(!r)return;const l=e.getElementByKey(r.getKey());if(!l)return;const s=window.getSelection();if(!s||s.anchorNode!==l)return;const i=t(n.anchor.getNode(),(e=>te(e)));if(!i)return;const c=t(i,(e=>dt(e)));if(!dt(c)||!c.is(o))return;const[a,d]=Me(o,i,i),u=a[0][0],h=a[a.length-1][a[0].length-1],{startRow:g,startColumn:f}=d,m=g===u.startRow&&f===u.startColumn,p=g===h.startRow&&f===h.startColumn;return m?"first":p?"last":void 0}class st extends l{static getType(){return"table"}static clone(e){return new st(e.__key)}static importDOM(){return{table:e=>({conversion:ct,priority:1})}}static importJSON(e){return at()}constructor(e){super(e)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(t,n){const o=document.createElement("table");return e(o,t.theme.table),o}updateDOM(){return!1}exportDOM(e){return{...super.exportDOM(e),after:e=>{if(e){const t=e.cloneNode(),n=document.createElement("colgroup"),o=document.createElement("tbody");r(e)&&o.append(...e.children);const l=this.getFirstChildOrThrow();if(!se(l))throw new Error("Expected to find row node.");const s=l.getChildrenSize();for(let e=0;e<s;e++){const e=document.createElement("col");n.append(e)}return t.replaceChildren(n,o),t}}}}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 b(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=b(o.elem);return te(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}canSelectBefore(){return!0}canIndent(){return!1}}function it(e,t){const n=e.getElementByKey(t.getKey());if(null==n)throw new Error("Table Element Not Found");return ze(n)}function ct(e){return{node:at()}}function at(){return d(new st)}function dt(e){return e instanceof st}export{Me as $computeTableMap,Re as $computeTableMapSkipCellCheck,ee as $createTableCellNode,at as $createTableNode,de as $createTableNodeWithDimensions,le as $createTableRowNode,He as $createTableSelection,Ne as $deleteTableColumn,xe as $deleteTableColumn__EXPERIMENTAL,Te as $deleteTableRow__EXPERIMENTAL,et as $findCellNode,tt as $findTableNode,it as $getElementForTableNode,Ke as $getNodeTriplet,ue as $getTableCellNodeFromLexicalNode,Fe as $getTableCellNodeRect,me as $getTableColumnIndexFromTableCellNode,ge as $getTableNodeFromLexicalNodeOrThrow,fe as $getTableRowIndexFromTableCellNode,he as $getTableRowNodeFromTableCellNodeOrThrow,be as $insertTableColumn,ye as $insertTableColumn__EXPERIMENTAL,Se as $insertTableRow,we as $insertTableRow__EXPERIMENTAL,te as $isTableCellNode,dt as $isTableNode,se as $isTableRowNode,Ae as $isTableSelection,Ce as $removeTableRowAtIndex,Oe as $unmergeCell,ne as INSERT_TABLE_COMMAND,Q as TableCellHeaderStates,V as TableCellNode,st as TableNode,Pe as TableObserver,oe as TableRowNode,Ie as applyTableHandlers,Ue as getDOMCellFromTarget,We as getTableObserverFromTableElement};
|
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 a,$isTextNode as c,$applyNodeReplacement as d,createCommand as u,$createTextNode as h,$getSelection as g,$isRangeSelection as f,$createPoint as m,$normalizeSelection__EXPERIMENTAL as p,$getNodeByKey as _,isCurrentlyReadOnlyMode as S,$setSelection as w,SELECTION_CHANGE_COMMAND as C,$getNearestNodeFromDOMNode as b,$createRangeSelection as y,$getRoot as N,KEY_ARROW_DOWN_COMMAND as T,COMMAND_PRIORITY_HIGH as x,KEY_ARROW_UP_COMMAND as v,KEY_ARROW_LEFT_COMMAND as O,KEY_ARROW_RIGHT_COMMAND as E,KEY_ESCAPE_COMMAND as R,DELETE_WORD_COMMAND as M,DELETE_LINE_COMMAND as K,DELETE_CHARACTER_COMMAND as F,COMMAND_PRIORITY_CRITICAL as k,KEY_BACKSPACE_COMMAND as A,KEY_DELETE_COMMAND as H,CUT_COMMAND as D,FORMAT_TEXT_COMMAND as P,FORMAT_ELEMENT_COMMAND as B,CONTROLLED_TEXT_INSERTION_COMMAND as L,KEY_TAB_COMMAND as I,FOCUS_COMMAND as W,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as U,$getPreviousSelection as z,$createRangeSelectionFromDom as Y,INSERT_PARAGRAPH_COMMAND as X,$isRootOrShadowRoot as J,$isDecoratorNode as $}from"lexical";import{copyToClipboard as j,$getClipboardDataFromSelection as q}from"@lexical/clipboard";const G=/^(\d+(?:\.\d+)?)px$/,Q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class V extends l{static getType(){return"tablecell"}static clone(e){const t=new V(e.__headerState,e.__colSpan,e.__width,e.__key);return t.__rowSpan=e.__rowSpan,t.__backgroundColor=e.__backgroundColor,t}static importDOM(){return{td:e=>({conversion:Z,priority:0}),th:e=>({conversion:Z,priority:0})}}static importJSON(e){const t=e.colSpan||1,n=e.rowSpan||1,o=ee(e.headerState,t,e.width||void 0);return o.__rowSpan=n,o.__backgroundColor=e.backgroundColor||null,o}constructor(e=Q.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{element:t}=super.exportDOM(e);if(t){const e=t;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";const n=this.getBackgroundColor();null!==n?e.style.backgroundColor=n:this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return{element: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.__colSpan}setColSpan(e){return this.getWritable().__colSpan=e,this}getRowSpan(){return this.__rowSpan}setRowSpan(e){return this.getWritable().__rowSpan=e,this}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e){return this.getWritable().__headerState=e,this.__headerState}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){return this.getWritable().__width=e,this.__width}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){this.getWritable().__backgroundColor=e}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!==Q.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 Z(e){const t=e,n=e.nodeName.toLowerCase();let o;G.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ee("th"===n?Q.ROW:Q.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const d=t.style,u=d.textDecoration.split(" "),h="700"===d.fontWeight||"bold"===d.fontWeight,g=u.includes("line-through"),f="italic"===d.fontStyle,m=u.includes("underline");return{after:e=>(0===e.length&&e.push(s()),e),forChild:(e,t)=>{if(te(t)&&!i(e)){const t=s();return a(e)&&"\n"===e.getTextContent()?null:(c(e)&&(h&&e.toggleFormat("bold"),g&&e.toggleFormat("strikethrough"),f&&e.toggleFormat("italic"),m&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ee(e,t=1,n){return d(new V(e,t,n))}function te(e){return e instanceof V}const ne=u("INSERT_TABLE_COMMAND");class oe extends l{static getType(){return"tablerow"}static clone(e){return new oe(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:re,priority:0})}}static importJSON(e){return le(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 re(e){const t=e;let n;return G.test(t.style.height)&&(n=parseFloat(t.style.height)),{node:le(n)}}function le(e){return d(new oe(e))}function se(e){return e instanceof oe}function ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ae=ie((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 ce="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function de(e,t,n=!0){const o=dt();for(let r=0;r<e;r++){const e=le();for(let o=0;o<t;o++){let t=Q.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=Q.ROW),0===o&&n.columns&&(t|=Q.COLUMN)):n&&(0===r&&(t|=Q.ROW),0===o&&(t|=Q.COLUMN));const l=ee(t),i=s();i.append(h()),l.append(i),e.append(l)}o.append(e)}return o}function ue(e){const n=t(e,(e=>te(e)));return te(n)?n:null}function he(e){const n=t(e,(e=>se(e)));if(se(n))return n;throw new Error("Expected table cell to be inside of table row.")}function ge(e){const n=t(e,(e=>ut(e)));if(ut(n))return n;throw new Error("Expected table cell to be inside of table.")}function fe(e){const t=he(e);return ge(t).getChildren().findIndex((e=>e.is(t)))}function me(e){return he(e).getChildren().findIndex((t=>t.is(e)))}function pe(e,t){const n=ge(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 _e(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 Se(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(!se(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=le();for(let n=0;n<t;n++){const t=e[n];te(t)||ae(12);const{above:l,below:i}=pe(t,r);let a=Q.NO_STATUS;const c=l&&l.getWidth()||i&&i.getWidth()||void 0;(l&&l.hasHeaderState(Q.COLUMN)||i&&i.hasHeaderState(Q.COLUMN))&&(a|=Q.COLUMN);const d=ee(a,1,c);d.append(s()),o.append(d)}n?i.insertAfter(o):i.insertBefore(o)}return e}const we=(e,t)=>e===Q.BOTH||e===t?t:Q.NO_STATUS;function Ce(e=!0){const t=g();f(t)||Ae(t)||ae(188);const n=t.focus.getNode(),[o,,r]=Ke(n),[l,i]=Re(r,o,o),a=l[0].length,{startRow:c}=i;if(e){const e=c+o.__rowSpan-1,t=l[e],n=le();for(let o=0;o<a;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=we(e,Q.COLUMN);n.append(ee(r).append(s()))}else r.setRowSpan(r.__rowSpan+1)}const i=r.getChildAtIndex(e);se(i)||ae(145),i.insertAfter(n)}else{const e=l[c],t=le();for(let n=0;n<a;n++){const{cell:o,startRow:r}=e[n];if(r===c){const o=e[n].cell.__headerState,r=we(o,Q.COLUMN);t.append(ee(r).append(s()))}else o.setRowSpan(o.__rowSpan+1)}const n=r.getChildAtIndex(c);se(n)||ae(145),n.insertBefore(t)}}function be(e,t,n=!0,o,r){const l=e.getChildren(),i=[];for(let e=0;e<l.length;e++){const n=l[e];if(se(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];te(o)||ae(12);const{left:l,right:a}=pe(o,r);let c=Q.NO_STATUS;(l&&l.hasHeaderState(Q.ROW)||a&&a.hasHeaderState(Q.ROW))&&(c|=Q.ROW);const d=ee(c);d.append(s()),i.push({newTableCell:d,targetCell:o})}}return i.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function ye(e=!0){const t=g();f(t)||Ae(t)||ae(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ke(n),[l,,i]=Ke(o),[a,c,d]=Re(i,l,r),u=a.length,h=e?Math.max(c.startColumn,d.startColumn):Math.min(c.startColumn,d.startColumn),m=e?h+l.__colSpan-1:h-1,p=i.getFirstChild();se(p)||ae(120);let _=null;function S(e=Q.NO_STATUS){const t=ee(e).append(s());return null===_&&(_=t),t}let w=p;e:for(let e=0;e<u;e++){if(0!==e){const e=w.getNextSibling();se(e)||ae(121),w=e}const t=a[e],n=t[m<0?0:m].cell.__headerState,o=we(n,Q.ROW);if(m<0){Oe(w,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)){w.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!==_&&ve(_)}function Ne(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(se(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 Te(){const e=g();f(e)||Ae(e)||ae(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,a]=Re(r,o,l),{startRow:c}=i,{startRow:d}=a,u=d+l.__rowSpan-1;if(s.length===u-c+1)return void r.remove();const h=s[0].length,m=s[u+1],p=r.getChildAtIndex(u+1);for(let e=u;e>=c;e--){for(let t=h-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t&&(e===c&&o<c&&n.setRowSpan(n.__rowSpan-(o-c)),o>=c&&o+n.__rowSpan-1>u))if(n.setRowSpan(n.__rowSpan-(u-o+1)),null===p&&ae(122),0===t)Oe(p,n);else{const{cell:e}=m[t-1];e.insertAfter(n)}}const t=r.getChildAtIndex(e);se(t)||ae(123,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];ve(e)}else{const e=s[c-1],{cell:t}=e[0];ve(t)}}function xe(){const e=g();f(e)||Ae(e)||ae(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ke(t),[l]=Ke(n),[s,i,a]=Re(r,o,l),{startColumn:c}=i,{startRow:d,startColumn:u}=a,h=Math.min(c,u),m=Math.max(c+o.__colSpan-1,u+l.__colSpan-1),p=m-h+1;if(s[0].length===m-h+1)return r.selectPrevious(),void r.remove();const _=s.length;for(let e=0;e<_;e++)for(let t=h;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<h){if(t===h){const e=h-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[d],w=c>u?S[c+o.__colSpan]:S[u+l.__colSpan];if(void 0!==w){const{cell:e}=w;ve(e)}else{const e=u<c?S[u-1]:S[c-1],{cell:t}=e;ve(t)}}function ve(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Oe(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ee(){const e=g();f(e)||Ae(e)||ae(188);const t=e.anchor.getNode(),[n,o,r]=Ke(t),l=n.__colSpan,i=n.__rowSpan;if(l>1){for(let e=1;e<l;e++)n.insertAfter(ee(Q.NO_STATUS).append(s()));n.setColSpan(1)}if(i>1){const[e,t]=Re(r,n,n),{startColumn:a,startRow:c}=t;let d;for(let t=1;t<i;t++){const n=c+t,r=e[n];d=(d||o).getNextSibling(),se(d)||ae(125);let i=null;for(let e=0;e<a;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 e=0;e<l;e++)Oe(d,ee(Q.NO_STATUS).append(s()));else for(let e=0;e<l;e++)i.insertAfter(ee(Q.NO_STATUS).append(s()))}n.setRowSpan(1)}}function Re(e,t,n){const[o,r,l]=Me(e,t,n);return null===r&&ae(110),null===l&&ae(111),[o,r,l]}function Me(e,t,n){const o=[];let r=null,l=null;function s(e,s,i){const a={cell:i,startColumn:s,startRow:e},c=i.__rowSpan,d=i.__colSpan;for(let t=0;t<c;t++){void 0===o[e+t]&&(o[e+t]=[]);for(let n=0;n<d;n++)o[e+t][s+n]=a}null!==t&&t.is(i)&&(r=a),null!==n&&n.is(i)&&(l=a)}function i(e,t){return void 0===o[e]||void 0===o[e][t]}const a=e.getChildren();for(let e=0;e<a.length;e++){const t=a[e];se(t)||ae(146);const n=t.getChildren();let o=0;for(const t of n){for(te(t)||ae(147);!i(e,o);)o++;s(e,o,t),o+=t.__colSpan}}return[o,r,l]}function Ke(e){let n;if(e instanceof V)n=e;else if("__type"in e){const o=t(e,te);te(o)||ae(148),n=o}else{const o=t(e.getNode(),te);te(o)||ae(148),n=o}const o=n.getParent();se(o)||ae(149);const r=o.getParent();return ut(r)||ae(150),[n,o,r]}function Fe(e){const[t,,n]=Ke(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,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}class ke{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]}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!Ae(e)&&(this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus))}set(e,t,n){this.dirty=!0,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new ke(this.tableKey,this.anchor,this.focus)}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.focus.getNode();i(t)||ae(151);p(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const e=_(this.anchor.key);te(e)||ae(152);const t=Fe(e);null===t&&ae(153);const n=_(this.focus.key);te(n)||ae(154);const o=Fe(n);null===o&&ae(155);const r=Math.min(t.columnIndex,o.columnIndex),l=Math.max(t.columnIndex,o.columnIndex),s=Math.min(t.rowIndex,o.rowIndex),i=Math.max(t.rowIndex,o.rowIndex);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){const e=this._cachedNodes;if(null!==e)return e;const n=this.anchor.getNode(),o=this.focus.getNode(),r=t(n,te),l=t(o,te);te(r)||ae(152),te(l)||ae(154);const s=r.getParent();se(s)||ae(156);const i=s.getParent();ut(i)||ae(157);const a=l.getParents()[1];if(a!==i){if(i.isParentOf(l)){const e=a.getParent();null==e&&ae(159),this.set(this.tableKey,l.getKey(),e.getKey())}else{const e=i.getParent();null==e&&ae(158),this.set(this.tableKey,e.getKey(),l.getKey())}return this.getNodes()}const[c,d,u]=Re(i,r,l);let h=Math.min(d.startColumn,u.startColumn),g=Math.min(d.startRow,u.startRow),f=Math.max(d.startColumn+d.cell.__colSpan-1,u.startColumn+u.cell.__colSpan-1),m=Math.max(d.startRow+d.cell.__rowSpan-1,u.startRow+u.cell.__rowSpan-1),p=h,_=g,w=h,C=g;function b(e){const{cell:t,startColumn:n,startRow:o}=e;h=Math.min(h,n),g=Math.min(g,o),f=Math.max(f,n+t.__colSpan-1),m=Math.max(m,o+t.__rowSpan-1)}for(;h<p||g<_||f>w||m>C;){if(h<p){const e=C-_,t=p-1;for(let n=0;n<=e;n++)b(c[_+n][t]);p=t}if(g<_){const e=w-p,t=_-1;for(let n=0;n<=e;n++)b(c[t][p+n]);_=t}if(f>w){const e=C-_,t=w+1;for(let n=0;n<=e;n++)b(c[_+n][t]);w=t}if(m>C){const e=w-p,t=C+1;for(let n=0;n<=e;n++)b(c[t][p+n]);C=t}}const y=[i];let N=null;for(let e=g;e<=m;e++)for(let t=h;t<=f;t++){const{cell:n}=c[e][t],o=n.getParent();se(o)||ae(160),o!==N&&y.push(o),y.push(n,...De(n)),N=o}return S()||(this._cachedNodes=y),y}getTextContent(){const e=this.getNodes().filter((e=>te(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 Ae(e){return e instanceof ke}function He(){const e=m("root",0,"element"),t=m("root",0,"element");return new ke("root",e,t)}function De(e){const t=[],n=[e];for(;n.length>0;){const o=n.pop();void 0===o&&ae(112),i(o)&&n.unshift(...o.getChildren()),o!==e&&t.push(o)}return t}class Pe{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.trackTable(),this.isSelecting=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal}}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}trackTable(){const e=new MutationObserver((e=>{this.editor.update((()=>{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 n=this.editor.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");this.table=ze(n)}))}));this.editor.update((()=>{const t=this.editor.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");this.table=ze(t),e.observe(t,{attributes:!0,childList:!0,subtree:!0})}))}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(),e.update((()=>{if(!ut(_(this.tableNodeKey)))throw new Error("Expected TableNode.");const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");const n=ze(t);Ye(e,n,null),w(null),e.dispatchCommand(C,void 0)}))}enableHighlightStyle(){const e=this.editor;e.update((()=>{const t=e.getElementByKey(this.tableNodeKey);if(!t)throw new Error("Expected to find TableElement in DOM");n(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}))}disableHighlightStyle(){const t=this.editor;t.update((()=>{const n=t.getElementByKey(this.tableNodeKey);if(!n)throw new Error("Expected to find TableElement in DOM");e(n,t._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}))}updateTableTableSelection(e){if(null!==e&&e.tableKey===this.tableNodeKey){const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.disableHighlightStyle(),Ye(t,this.table,this.tableSelection)}else null==e?this.clearHighlight():(this.tableNodeKey=e.tableKey,this.updateTableTableSelection(e))}setFocusCellForSelection(e,t=!1){const n=this.editor;n.update((()=>{const o=_(this.tableNodeKey);if(!ut(o))throw new Error("Expected TableNode.");if(!n.getElementByKey(this.tableNodeKey))throw new Error("Expected to find TableElement in DOM");const r=e.x,l=e.y;if(this.focusCell=e,null!==this.anchorCell){const e=Le(n._window);e&&e.setBaseAndExtent(this.anchorCell.elem,0,this.focusCell.elem,0)}if(this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return}else this.isHighlightingCells=!0,this.disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=b(e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&te(t)&&o.is(tt(t))){const e=t.getKey();this.tableSelection=this.tableSelection.clone()||He(),this.focusCellNodeKey=e,this.tableSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),w(this.tableSelection),n.dispatchCommand(C,void 0),Ye(n,this.table,this.tableSelection)}}}))}setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.editor.update((()=>{const t=b(e.elem);if(te(t)){const e=t.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():He(),this.anchorCellNodeKey=e}}))}formatCells(e){this.editor.update((()=>{const t=g();Ae(t)||ae(11);const n=y(),o=n.anchor,r=n.focus;t.getNodes().forEach((t=>{te(t)&&0!==t.getTextContentSize()&&(o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e))})),w(t),this.editor.dispatchCommand(C,void 0)}))}clearText(){const e=this.editor;e.update((()=>{const t=_(this.tableNodeKey);if(!ut(t))throw new Error("Expected TableNode.");const n=g();Ae(n)||ae(11);const o=n.getNodes().filter(te);if(o.length!==this.table.columns*this.table.rows)o.forEach((e=>{if(i(e)){const t=s(),n=h();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),Ye(e,this.table,null),w(null),e.dispatchCommand(C,void 0);else{t.selectPrevious(),t.remove();N().selectStart()}}))}}const Be="__lexicalTableSelection",Le=e=>ce?(e||window).getSelection():null;function Ie(e,n,r,l){const a=r.getRootElement();if(null===a)throw new Error("No root element.");const d=new Pe(r,e.getKey()),u=r._window||window;!function(e,t){null!==We(e)&&ae(200);e[Be]=t}(n,d),d.listenersToRemove.add((()=>function(e,t){We(e)===t&&delete e[Be]}(n,d)));const m=()=>{const e=()=>{d.isSelecting=!1,u.removeEventListener("mouseup",e),u.removeEventListener("mousemove",t)},t=n=>{setTimeout((()=>{if(1&~n.buttons&&d.isSelecting)return d.isSelecting=!1,u.removeEventListener("mouseup",e),void u.removeEventListener("mousemove",t);const o=Ue(n.target);null===o||d.anchorX===o.x&&d.anchorY===o.y||(n.preventDefault(),d.setFocusCellForSelection(o))}),0)};return{onMouseMove:t,onMouseUp:e}};n.addEventListener("mousedown",(e=>{setTimeout((()=>{if(0!==e.button)return;if(!u)return;const t=Ue(e.target);null!==t&&(ot(e),d.setAnchorCellForSelection(t));const{onMouseUp:n,onMouseMove:o}=m();d.isSelecting=!0,u.addEventListener("mouseup",n,d.listenerOptions),u.addEventListener("mousemove",o,d.listenerOptions)}),0)}),d.listenerOptions);u.addEventListener("mousedown",(e=>{0===e.button&&r.update((()=>{const t=g(),n=e.target;Ae(t)&&t.tableKey===d.tableNodeKey&&a.contains(n)&&d.clearHighlight()}))}),d.listenerOptions),d.listenersToRemove.add(r.registerCommand(T,(t=>nt(r,t,"down",e,d)),x)),d.listenersToRemove.add(r.registerCommand(v,(t=>nt(r,t,"up",e,d)),x)),d.listenersToRemove.add(r.registerCommand(O,(t=>nt(r,t,"backward",e,d)),x)),d.listenersToRemove.add(r.registerCommand(E,(t=>nt(r,t,"forward",e,d)),x)),d.listenersToRemove.add(r.registerCommand(R,(e=>{const n=g();if(Ae(n)){const o=t(n.focus.getNode(),te);if(te(o))return ot(e),o.selectEnd(),!0}return!1}),x));[M,K,F].forEach((n=>{d.listenersToRemove.add(r.registerCommand(n,(n=>()=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return d.clearText(),!0;if(f(o)){const r=t(o.anchor.getNode(),(e=>te(e)));if(!te(r))return!1;const l=o.anchor.getNode(),s=o.focus.getNode(),a=e.isParentOf(l),c=e.isParentOf(s);if(a&&!c||c&&!a)return d.clearText(),!0;const u=t(o.anchor.getNode(),(e=>i(e))),h=u&&t(u,(e=>i(e)&&te(e.getParent())));if(!i(h)||!i(u))return!1;if(n===K&&null===h.getPreviousSibling())return!0}return!1})(n),k))}));const p=n=>{const o=g();if(!qe(o,e)){const e=o?o.getNodes():null;if(e){const t=e.find((e=>ut(e)&&e.getKey()===d.tableNodeKey));if(ut(t)){if(!t.getParent())return!1;t.remove()}}return!1}if(Ae(o))return n&&(n.preventDefault(),n.stopPropagation()),d.clearText(),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>te(e)));if(!te(e))return!1}return!1};function _(t){const n=e.getCordsFromCellNode(t,d.table);return e.getDOMCellFromCordsOrThrow(n.x,n.y,d.table)}return d.listenersToRemove.add(r.registerCommand(A,p,k)),d.listenersToRemove.add(r.registerCommand(H,p,k)),d.listenersToRemove.add(r.registerCommand(D,(e=>{const t=g();if(t){if(!Ae(t)&&!f(t))return!1;j(r,o(e,ClipboardEvent)?e:null,q(t));const n=p(e);return f(t)&&t.removeText(),n}return!1}),k)),d.listenersToRemove.add(r.registerCommand(P,(n=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return d.formatCells(n),!0;if(f(o)){const e=t(o.anchor.getNode(),(e=>te(e)));if(!te(e))return!1}return!1}),k)),d.listenersToRemove.add(r.registerCommand(B,(t=>{const n=g();if(!Ae(n)||!qe(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!te(o)||!te(r))return!1;const[l,s,a]=Re(e,o,r),c=Math.max(s.startRow,a.startRow),d=Math.max(s.startColumn,a.startColumn),u=Math.min(s.startRow,a.startRow),h=Math.min(s.startColumn,a.startColumn);for(let e=u;e<=c;e++)for(let n=h;n<=d;n++){const o=l[e][n].cell;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)),d.listenersToRemove.add(r.registerCommand(L,(n=>{const o=g();if(!qe(o,e))return!1;if(Ae(o))return d.clearHighlight(),!1;if(f(o)){const l=t(o.anchor.getNode(),(e=>te(e)));if(!te(l))return!1;if("string"==typeof n){const t=lt(r,o,e);if(t)return rt(t,e,[h(n)]),!0}}return!1}),k)),l&&d.listenersToRemove.add(r.registerCommand(I,(t=>{const n=g();if(!f(n)||!n.isCollapsed()||!qe(n,e))return!1;const o=et(n.anchor.getNode());if(null===o)return!1;ot(t);const r=e.getCordsFromCellNode(o,d.table);return $e(d,e,r.x,r.y,t.shiftKey?"backward":"forward"),!0}),k)),d.listenersToRemove.add(r.registerCommand(W,(t=>e.isSelected()),x)),d.listenersToRemove.add(r.registerCommand(U,(e=>{const{nodes:n,selection:o}=e,r=o.getStartEndPoints(),l=Ae(o),i=f(o)&&null!==t(o.anchor.getNode(),(e=>te(e)))&&null!==t(o.focus.getNode(),(e=>te(e)))||l;if(1!==n.length||!ut(n[0])||!i||null===r)return!1;const[a]=r,d=n[0],u=d.getChildren(),h=d.getFirstChildOrThrow().getChildrenSize(),g=d.getChildrenSize(),m=t(a.getNode(),(e=>te(e))),p=m&&t(m,(e=>se(e))),_=p&&t(p,(e=>ut(e)));if(!te(m)||!se(p)||!ut(_))return!1;const S=p.getIndexWithinParent(),w=Math.min(_.getChildrenSize()-1,S+g-1),C=m.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,C+h-1),y=Math.min(C,b),N=Math.min(S,w),T=Math.max(C,b),x=Math.max(S,w),v=_.getChildren();let O=0;for(let e=N;e<=x;e++){const t=v[e];if(!se(t))return!1;const n=u[O];if(!se(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=T;e++){const t=o[e];if(!te(t))return!1;const n=r[l];if(!te(n))return!1;const i=t.getChildren();n.getChildren().forEach((e=>{if(c(e)){s().append(e),t.append(e)}else t.append(e)})),i.forEach((e=>e.remove())),l++}O++}return!0}),k)),d.listenersToRemove.add(r.registerCommand(C,(()=>{const t=g(),n=z();if(f(t)){const{anchor:n,focus:o}=t,l=n.getNode(),s=o.getNode(),i=et(l),a=et(s),c=!(!i||!e.is(tt(i))),h=!(!a||!e.is(tt(a))),g=c!==h,f=c&&h,p=t.isBackward();if(g){const n=t.clone();if(h){const[t]=Re(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(p?o.getKey():r.getKey(),p?o.getChildrenSize():r.getChildrenSize(),"element")}w(n),Je(r,d)}else f&&(i.is(a)||(d.setAnchorCellForSelection(_(i)),d.setFocusCellForSelection(_(a),!0),d.isSelecting||setTimeout((()=>{const{onMouseUp:e,onMouseMove:t}=m();d.isSelecting=!0,u.addEventListener("mouseup",e),u.addEventListener("mousemove",t)}),0)))}else if(t&&Ae(t)&&t.is(n)&&t.tableKey===e.getKey()){const n=Le(r._window);if(n&&n.anchorNode&&n.focusNode){const o=b(n.focusNode),l=o&&!e.is(tt(o)),s=b(n.anchorNode),i=s&&e.is(tt(s));if(l&&i&&n.rangeCount>0){const o=Y(n,r);o&&(o.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),w(o))}}}return t&&!t.is(n)&&(Ae(t)||Ae(n))&&d.tableSelection&&!d.tableSelection.is(n)?(Ae(t)&&t.tableKey===d.tableNodeKey?d.updateTableTableSelection(t):!Ae(t)&&Ae(n)&&n.tableKey===d.tableNodeKey&&d.updateTableTableSelection(null),!1):(d.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.enableHighlightStyle(),Xe(t.table,(t=>{const n=t.elem;t.highlighted=!1,Ze(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(r,d):!d.hasHijackedSelectionStyles&&e.isSelected()&&Je(r,d),!1)}),k)),d.listenersToRemove.add(r.registerCommand(X,(()=>{const t=g();if(!f(t)||!t.isCollapsed()||!qe(t,e))return!1;const n=lt(r,t,e);return!!n&&(rt(n,e),!0)}),k)),d}function We(e){return e[Be]||null}function Ue(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 ze(e){const t=[],n={columns:0,domRows:t,rows:0};let o=e.firstChild,r=0,l=0;for(t.length=0;null!=o;){const e=o.nodeName;if("TD"===e||"TH"===e){const e={elem:o,hasBackgroundColor:""!==o.style.backgroundColor,highlighted:!1,x:r,y:l};o._cell=e;let n=t[l];void 0===n&&(n=t[l]=[]),n[r]=e}else{const e=o.firstChild;if(null!=e){o=e;continue}}const n=o.nextSibling;if(null!=n){r++,o=n;continue}const s=o.parentNode;if(null!=s){const e=s.nextSibling;if(null==e)break;l++,r=0,o=e}}return n.columns=r+1,n.rows=l+1,n}function Ye(e,t,n){const o=new Set(n?n.getNodes():[]);Xe(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,Ve(e,t)):(t.highlighted=!1,Ze(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Xe(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=b(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function Je(e,t){t.disableHighlightStyle(),Xe(t.table,(t=>{t.highlighted=!0,Ve(e,t)}))}const $e=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Ge(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Ge(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?Ge(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Ge(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}},je=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)&&e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n+(l?1:-1),o,e.table)),!0;case"up":return 0!==o&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o-1,e.table)),!0);case"down":return o!==e.table.rows-1&&(e.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(n,o+1,e.table)),!0);default:return!1}};function qe(e,t){if(f(e)||Ae(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Ge(e,t){t?e.selectStart():e.selectEnd()}const Qe="172,206,247";function Ve(e,t){const n=t.elem,o=b(n);te(o)||ae(131);null===o.getBackgroundColor()?n.style.setProperty("background-color",`rgb(${Qe})`):n.style.setProperty("background-image",`linear-gradient(to right, rgba(${Qe},0.85), rgba(${Qe},0.85))`),n.style.setProperty("caret-color","transparent")}function Ze(e,t){const n=t.elem,o=b(n);te(o)||ae(131);null===o.getBackgroundColor()&&n.style.removeProperty("background-color"),n.style.removeProperty("background-image"),n.style.removeProperty("caret-color")}function et(e){const n=t(e,te);return te(n)?n:null}function tt(e){const n=t(e,ut);return ut(n)?n:null}function nt(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(!qe(s,r)){if(f(s)){if(s.isCollapsed()&&"backward"===o){const e=s.anchor.type,o=s.anchor.offset;if("element"!==e&&("text"!==e||0!==o))return!1;const r=s.anchor.getNode();if(!r)return!1;const l=t(r,(e=>i(e)&&!e.isInline()));if(!l)return!1;const a=l.getPreviousSibling();return!(!a||!ut(a))&&(ot(n),a.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(J(e)){const e=s.getNodes()[0];if(e){const n=t(e,te);if(n&&r.isParentOf(n)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ke(e),[o]=Ke(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),a=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),c=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.setAnchorCellForSelection(a),l.setFocusCellForSelection(c,!0),!0}}return!1}{const n=t(e,(e=>i(e)&&!e.isInline()));if(!n)return!1;const r="down"===o?n.getNextSibling():n.getPreviousSibling();if(ut(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ke(e),[l]=Ke(t),i=s.clone();return i.focus.set(("up"===o?n:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),w(i),!0}}}}return!1}if(f(s)&&s.isCollapsed()){const{anchor:a,focus:c}=s,d=t(a.getNode(),te),u=t(c.getNode(),te);if(!te(d)||!d.is(u))return!1;const h=tt(d);if(h!==r&&null!=h){const t=e.getElementByKey(h.getKey());if(null!=t)return l.table=ze(t),nt(e,n,o,h,l)}if("backward"===o||"forward"===o){const e=a.type,l=a.offset,c=a.getNode();if(!c)return!1;const d=s.getNodes();return(1!==d.length||!$(d[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,c,o)&&function(e,n,o,r){const l=t(n,te);if(!te(l))return!1;const[s,a]=Re(o,l,l);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,a,r))return!1;const c=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&&ut(l)?l:"backward"===n?o.getPreviousSibling():o.getNextSibling()}(n,r,o);if(!c||ut(c))return!1;ot(e),"backward"===r?c.selectEnd():c.selectStart();return!0}(n,c,r,o))}const g=e.getElementByKey(d.__key),f=e.getElementByKey(a.key);if(null==f||null==g)return!1;let m;if("element"===a.type)m=f.getBoundingClientRect();else{const e=window.getSelection();if(null===e||0===e.rangeCount)return!1;m=e.getRangeAt(0).getBoundingClientRect()}const p="up"===o?d.getFirstChild():d.getLastChild();if(null==p)return!1;const _=e.getElementByKey(p.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===o?S.top>m.top-m.height:m.bottom+m.height>S.bottom){ot(n);const e=r.getCordsFromCellNode(d,l.table);if(!n.shiftKey)return $e(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(Ae(s)){const{anchor:i,focus:a}=s,c=t(i.getNode(),te),d=t(a.getNode(),te),[u]=s.getNodes(),h=e.getElementByKey(u.getKey());if(!te(c)||!te(d)||!ut(u)||null==h)return!1;l.updateTableTableSelection(s);const g=ze(h),f=r.getCordsFromCellNode(c,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.setAnchorCellForSelection(m),ot(n),n.shiftKey){const e=r.getCordsFromCellNode(d,g);return je(l,u,e.x,e.y,o)}return d.selectEnd(),!0}return!1}function ot(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function rt(e,t,n){const o=s();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function lt(e,n,o){const r=o.getParent();if(!r)return;const l=e.getElementByKey(r.getKey());if(!l)return;const s=window.getSelection();if(!s||s.anchorNode!==l)return;const i=t(n.anchor.getNode(),(e=>te(e)));if(!i)return;const a=t(i,(e=>ut(e)));if(!ut(a)||!a.is(o))return;const[c,d]=Re(o,i,i),u=c[0][0],h=c[c.length-1][c[0].length-1],{startRow:g,startColumn:f}=d,m=g===u.startRow&&f===u.startColumn,p=g===h.startRow&&f===h.startColumn;return m?"first":p?"last":void 0}function st(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"))}class it extends l{static getType(){return"table"}static clone(e){return new it(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:ct,priority:1})}}static importJSON(e){const t=dt();return t.__rowStriping=e.rowStriping||!1,t}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),rowStriping:this.__rowStriping?this.__rowStriping:void 0,type:"table",version:1}}createDOM(t,n){const o=document.createElement("table");return e(o,t.theme.table),this.__rowStriping&&st(o,t,!0),o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&st(t,n,this.__rowStriping),!1}exportDOM(e){return{...super.exportDOM(e),after:e=>{if(e){const t=e.cloneNode(),n=document.createElement("colgroup"),o=document.createElement("tbody");r(e)&&o.append(...e.children);const l=this.getFirstChildOrThrow();if(!se(l))throw new Error("Expected to find row node.");const s=l.getChildrenSize();for(let e=0;e<s;e++){const e=document.createElement("col");n.append(e)}return t.replaceChildren(n,o),t}}}}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 b(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=b(o.elem);return te(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}}function at(e,t){const n=e.getElementByKey(t.getKey());if(null==n)throw new Error("Table Element Not Found");return ze(n)}function ct(e){const t=dt();return e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),{node:t}}function dt(){return d(new it)}function ut(e){return e instanceof it}export{Re as $computeTableMap,Me as $computeTableMapSkipCellCheck,ee as $createTableCellNode,dt as $createTableNode,de as $createTableNodeWithDimensions,le as $createTableRowNode,He as $createTableSelection,Ne as $deleteTableColumn,xe as $deleteTableColumn__EXPERIMENTAL,Te as $deleteTableRow__EXPERIMENTAL,et as $findCellNode,tt as $findTableNode,at as $getElementForTableNode,Ke as $getNodeTriplet,ue as $getTableCellNodeFromLexicalNode,Fe as $getTableCellNodeRect,me as $getTableColumnIndexFromTableCellNode,ge as $getTableNodeFromLexicalNodeOrThrow,fe as $getTableRowIndexFromTableCellNode,he as $getTableRowNodeFromTableCellNodeOrThrow,be as $insertTableColumn,ye as $insertTableColumn__EXPERIMENTAL,Se as $insertTableRow,Ce as $insertTableRow__EXPERIMENTAL,te as $isTableCellNode,ut as $isTableNode,se as $isTableRowNode,Ae as $isTableSelection,_e as $removeTableRowAtIndex,Ee as $unmergeCell,ne as INSERT_TABLE_COMMAND,Q as TableCellHeaderStates,V as TableCellNode,it as TableNode,Pe as TableObserver,oe as TableRowNode,Ie as applyTableHandlers,Ue as getDOMCellFromTarget,We as getTableObserverFromTableElement};
|
package/LexicalTableNode.d.ts
CHANGED
@@ -5,21 +5,26 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
import type {
|
9
|
-
import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
|
8
|
+
import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
|
10
9
|
import { ElementNode } from 'lexical';
|
10
|
+
import { TableCellNode } from './LexicalTableCellNode';
|
11
11
|
import { TableDOMCell, TableDOMTable } from './LexicalTableObserver';
|
12
|
-
export type SerializedTableNode =
|
12
|
+
export type SerializedTableNode = Spread<{
|
13
|
+
rowStriping?: boolean;
|
14
|
+
}, SerializedElementNode>;
|
13
15
|
/** @noInheritDoc */
|
14
16
|
export declare class TableNode extends ElementNode {
|
17
|
+
/** @internal */
|
18
|
+
__rowStriping: boolean;
|
15
19
|
static getType(): string;
|
16
20
|
static clone(node: TableNode): TableNode;
|
21
|
+
afterCloneFrom(prevNode: this): void;
|
17
22
|
static importDOM(): DOMConversionMap | null;
|
18
|
-
static importJSON(
|
23
|
+
static importJSON(serializedNode: SerializedTableNode): TableNode;
|
19
24
|
constructor(key?: NodeKey);
|
20
|
-
exportJSON():
|
25
|
+
exportJSON(): SerializedTableNode;
|
21
26
|
createDOM(config: EditorConfig, editor?: LexicalEditor): HTMLElement;
|
22
|
-
updateDOM(): boolean;
|
27
|
+
updateDOM(prevNode: TableNode, dom: HTMLElement, config: EditorConfig): boolean;
|
23
28
|
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
24
29
|
canBeEmpty(): false;
|
25
30
|
isShadowRoot(): boolean;
|
@@ -31,10 +36,12 @@ export declare class TableNode extends ElementNode {
|
|
31
36
|
getDOMCellFromCordsOrThrow(x: number, y: number, table: TableDOMTable): TableDOMCell;
|
32
37
|
getCellNodeFromCords(x: number, y: number, table: TableDOMTable): null | TableCellNode;
|
33
38
|
getCellNodeFromCordsOrThrow(x: number, y: number, table: TableDOMTable): TableCellNode;
|
39
|
+
getRowStriping(): boolean;
|
40
|
+
setRowStriping(newRowStriping: boolean): void;
|
34
41
|
canSelectBefore(): true;
|
35
42
|
canIndent(): false;
|
36
43
|
}
|
37
44
|
export declare function $getElementForTableNode(editor: LexicalEditor, tableNode: TableNode): TableDOMTable;
|
38
|
-
export declare function $convertTableElement(
|
45
|
+
export declare function $convertTableElement(domNode: HTMLElement): DOMConversionOutput;
|
39
46
|
export declare function $createTableNode(): TableNode;
|
40
47
|
export declare function $isTableNode(node: LexicalNode | null | undefined): node is TableNode;
|
@@ -37,6 +37,10 @@ export declare class TableObserver {
|
|
37
37
|
tableSelection: TableSelection | null;
|
38
38
|
hasHijackedSelectionStyles: boolean;
|
39
39
|
isSelecting: boolean;
|
40
|
+
abortController: AbortController;
|
41
|
+
listenerOptions: {
|
42
|
+
signal: AbortSignal;
|
43
|
+
};
|
40
44
|
constructor(editor: LexicalEditor, tableNodeKey: string);
|
41
45
|
getTable(): TableDOMTable;
|
42
46
|
removeListeners(): void;
|
@@ -14,7 +14,10 @@ import { TableDOMTable, TableObserver } from './LexicalTableObserver';
|
|
14
14
|
declare const LEXICAL_ELEMENT_KEY = "__lexicalTableSelection";
|
15
15
|
export declare const getDOMSelection: (targetWindow: Window | null) => Selection | null;
|
16
16
|
export declare function applyTableHandlers(tableNode: TableNode, tableElement: HTMLTableElementWithWithTableSelectionState, editor: LexicalEditor, hasTabHandler: boolean): TableObserver;
|
17
|
-
export type HTMLTableElementWithWithTableSelectionState = HTMLTableElement &
|
17
|
+
export type HTMLTableElementWithWithTableSelectionState = HTMLTableElement & {
|
18
|
+
[LEXICAL_ELEMENT_KEY]?: TableObserver | undefined;
|
19
|
+
};
|
20
|
+
export declare function deatatchTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableObserver: TableObserver): void;
|
18
21
|
export declare function attachTableObserverToTableElement(tableElement: HTMLTableElementWithWithTableSelectionState, tableObserver: TableObserver): void;
|
19
22
|
export declare function getTableObserverFromTableElement(tableElement: HTMLTableElementWithWithTableSelectionState): TableObserver | null;
|
20
23
|
export declare function getDOMCellFromTarget(node: Node): TableDOMCell | null;
|
package/package.json
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
"table"
|
9
9
|
],
|
10
10
|
"license": "MIT",
|
11
|
-
"version": "0.17.2-nightly.
|
11
|
+
"version": "0.17.2-nightly.20240902.0",
|
12
12
|
"main": "LexicalTable.js",
|
13
13
|
"types": "index.d.ts",
|
14
14
|
"dependencies": {
|
15
|
-
"@lexical/clipboard": "0.17.2-nightly.
|
16
|
-
"@lexical/utils": "0.17.2-nightly.
|
17
|
-
"lexical": "0.17.2-nightly.
|
15
|
+
"@lexical/clipboard": "0.17.2-nightly.20240902.0",
|
16
|
+
"@lexical/utils": "0.17.2-nightly.20240902.0",
|
17
|
+
"lexical": "0.17.2-nightly.20240902.0"
|
18
18
|
},
|
19
19
|
"repository": {
|
20
20
|
"type": "git",
|