@lexical/table 0.4.1 → 0.5.1-next.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.
@@ -24,7 +24,7 @@ const TableCellHeaderStates = {
24
24
  };
25
25
 
26
26
  /** @noInheritDoc */
27
- class TableCellNode extends lexical.GridCellNode {
27
+ class TableCellNode extends lexical.DEPRECATED_GridCellNode {
28
28
  /** @internal */
29
29
 
30
30
  /** @internal */
@@ -150,6 +150,10 @@ class TableCellNode extends lexical.GridCellNode {
150
150
  return prevNode.__headerState !== this.__headerState || prevNode.__width !== this.__width;
151
151
  }
152
152
 
153
+ isShadowRoot() {
154
+ return true;
155
+ }
156
+
153
157
  collapseAtStart() {
154
158
  return true;
155
159
  }
@@ -200,7 +204,7 @@ function $isTableCellNode(node) {
200
204
  */
201
205
 
202
206
  /** @noInheritDoc */
203
- class TableRowNode extends lexical.GridRowNode {
207
+ class TableRowNode extends lexical.DEPRECATED_GridRowNode {
204
208
  /** @internal */
205
209
  static getType() {
206
210
  return 'tablerow';
@@ -246,6 +250,10 @@ class TableRowNode extends lexical.GridRowNode {
246
250
  return element;
247
251
  }
248
252
 
253
+ isShadowRoot() {
254
+ return true;
255
+ }
256
+
249
257
  setHeight(height) {
250
258
  const self = this.getWritable();
251
259
  self.__height = height;
@@ -297,7 +305,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
297
305
  * LICENSE file in the root directory of this source tree.
298
306
  *
299
307
  */
300
- const getSelection = () => window.getSelection();
308
+
309
+ const getSelection = () => CAN_USE_DOM ? window.getSelection() : null;
301
310
 
302
311
  var getDOMSelection = getSelection;
303
312
 
@@ -470,23 +479,14 @@ class TableSelection {
470
479
  }
471
480
 
472
481
  updateTableGridSelection(selection) {
473
- if (selection != null) {
482
+ if (selection != null && selection.gridKey === this.tableNodeKey) {
474
483
  this.gridSelection = selection;
475
484
  this.isHighlightingCells = true;
476
485
  this.disableHighlightStyle();
477
- const anchorElement = this.editor.getElementByKey(selection.anchor.key);
478
- const focusElement = this.editor.getElementByKey(selection.focus.key);
479
-
480
- if (anchorElement && focusElement) {
481
- const domSelection = getDOMSelection();
482
-
483
- if (domSelection) {
484
- domSelection.setBaseAndExtent(anchorElement, 0, focusElement, 0);
485
- }
486
- }
487
-
488
486
  $updateDOMForSelection(this.grid, this.gridSelection);
489
- } else {
487
+ }
488
+
489
+ if (selection == null) {
490
490
  this.clearHighlight();
491
491
  }
492
492
  }
@@ -508,12 +508,12 @@ class TableSelection {
508
508
  const cellX = cell.x;
509
509
  const cellY = cell.y;
510
510
  this.focusCell = cell;
511
- const domSelection = getDOMSelection();
512
511
 
513
512
  if (this.anchorCell !== null) {
514
- // Collapse the selection
513
+ const domSelection = getDOMSelection(); // Collapse the selection
514
+
515
515
  if (domSelection) {
516
- domSelection.setBaseAndExtent(this.anchorCell.elem, 0, cell.elem, 0);
516
+ domSelection.setBaseAndExtent(this.anchorCell.elem, 0, this.anchorCell.elem, 0);
517
517
  }
518
518
  }
519
519
 
@@ -532,7 +532,7 @@ class TableSelection {
532
532
 
533
533
  if (this.gridSelection != null && this.anchorCellNodeKey != null && $isTableCellNode(focusTableCellNode)) {
534
534
  const focusNodeKey = focusTableCellNode.getKey();
535
- this.gridSelection = lexical.$createGridSelection();
535
+ this.gridSelection = lexical.DEPRECATED_$createGridSelection();
536
536
  this.focusCellNodeKey = focusNodeKey;
537
537
  this.gridSelection.set(this.tableNodeKey, this.anchorCellNodeKey, this.focusCellNodeKey);
538
538
  lexical.$setSelection(this.gridSelection);
@@ -545,20 +545,22 @@ class TableSelection {
545
545
 
546
546
  setAnchorCellForSelection(cell) {
547
547
  this.editor.update(() => {
548
- this.anchorCell = cell;
549
- this.startX = cell.x;
550
- this.startY = cell.y;
551
- const domSelection = getDOMSelection();
548
+ if (this.anchorCell === cell && this.isHighlightingCells) {
549
+ const domSelection = getDOMSelection(); // Collapse the selection
552
550
 
553
- if (domSelection) {
554
- domSelection.setBaseAndExtent(cell.elem, 0, cell.elem, 0);
551
+ if (domSelection) {
552
+ domSelection.setBaseAndExtent(cell.elem, 0, cell.elem, 0);
553
+ }
555
554
  }
556
555
 
556
+ this.anchorCell = cell;
557
+ this.startX = cell.x;
558
+ this.startY = cell.y;
557
559
  const anchorTableCellNode = lexical.$getNearestNodeFromDOMNode(cell.elem);
558
560
 
559
561
  if ($isTableCellNode(anchorTableCellNode)) {
560
562
  const anchorNodeKey = anchorTableCellNode.getKey();
561
- this.gridSelection = lexical.$createGridSelection();
563
+ this.gridSelection = lexical.DEPRECATED_$createGridSelection();
562
564
  this.anchorCellNodeKey = anchorNodeKey;
563
565
  }
564
566
  });
@@ -568,7 +570,7 @@ class TableSelection {
568
570
  this.editor.update(() => {
569
571
  const selection = lexical.$getSelection();
570
572
 
571
- if (!lexical.$isGridSelection(selection)) {
573
+ if (!lexical.DEPRECATED_$isGridSelection(selection)) {
572
574
  {
573
575
  throw Error(`Expected grid selection`);
574
576
  }
@@ -599,7 +601,7 @@ class TableSelection {
599
601
 
600
602
  const selection = lexical.$getSelection();
601
603
 
602
- if (!lexical.$isGridSelection(selection)) {
604
+ if (!lexical.DEPRECATED_$isGridSelection(selection)) {
603
605
  {
604
606
  throw Error(`Expected grid selection`);
605
607
  }
@@ -611,7 +613,8 @@ class TableSelection {
611
613
  tableNode.selectPrevious(); // Delete entire table
612
614
 
613
615
  tableNode.remove();
614
- this.clearHighlight();
616
+ const rootNode = lexical.$getRoot();
617
+ rootNode.selectStart();
615
618
  return;
616
619
  }
617
620
 
@@ -677,13 +680,10 @@ function applyTableHandlers(tableNode, tableElement, editor) {
677
680
  const cell = getCellFromTarget(event.target);
678
681
 
679
682
  if (cell !== null) {
683
+ event.preventDefault();
684
+ event.stopPropagation();
685
+ event.stopImmediatePropagation();
680
686
  tableSelection.setAnchorCellForSelection(cell);
681
- document.addEventListener('mouseup', () => {
682
- isMouseDown = false;
683
- }, {
684
- capture: true,
685
- once: true
686
- });
687
687
  }
688
688
  }, 0);
689
689
  }); // This is adjusting the focus of the selection.
@@ -709,11 +709,6 @@ function applyTableHandlers(tableNode, tableElement, editor) {
709
709
  }
710
710
  }
711
711
  }
712
- });
713
- tableElement.addEventListener('mouseup', () => {
714
- if (isMouseDown) {
715
- isMouseDown = false;
716
- }
717
712
  }); // Select entire table at this point, when grid selection is ready.
718
713
 
719
714
  tableElement.addEventListener('mouseleave', () => {
@@ -732,7 +727,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
732
727
  editor.update(() => {
733
728
  const selection = lexical.$getSelection();
734
729
 
735
- if (lexical.$isGridSelection(selection) && selection.gridKey === tableSelection.tableNodeKey && rootElement.contains(event.target)) {
730
+ if (lexical.DEPRECATED_$isGridSelection(selection) && selection.gridKey === tableSelection.tableNodeKey && rootElement.contains(event.target)) {
736
731
  return tableSelection.clearHighlight();
737
732
  }
738
733
  });
@@ -741,12 +736,19 @@ function applyTableHandlers(tableNode, tableElement, editor) {
741
736
  window.addEventListener('mousedown', mouseDownCallback);
742
737
  tableSelection.listenersToRemove.add(() => window.removeEventListener('mousedown', mouseDownCallback));
743
738
 
744
- const mouseUpCallback = () => {
745
- isMouseDown = false;
739
+ const mouseUpCallback = event => {
740
+ if (isMouseDown) {
741
+ event.preventDefault();
742
+ event.stopPropagation();
743
+ event.stopImmediatePropagation();
744
+ isMouseDown = false;
745
+ }
746
746
  };
747
747
 
748
748
  window.addEventListener('mouseup', mouseUpCallback);
749
749
  tableSelection.listenersToRemove.add(() => window.removeEventListener('mouseup', mouseUpCallback));
750
+ tableSelection.listenersToRemove.add(() => tableElement.addEventListener('mouseup', mouseUpCallback));
751
+ tableSelection.listenersToRemove.add(() => tableElement.removeEventListener('mouseup', mouseUpCallback));
750
752
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, event => {
751
753
  const selection = lexical.$getSelection();
752
754
 
@@ -787,7 +789,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
787
789
  return selectGridNodeInDirection(tableSelection, tableNode, currentCords.x, currentCords.y, direction);
788
790
  }
789
791
  }
790
- } else if (lexical.$isGridSelection(selection) && event.shiftKey) {
792
+ } else if (lexical.DEPRECATED_$isGridSelection(selection) && event.shiftKey) {
791
793
  const tableCellNode = selection.focus.getNode();
792
794
 
793
795
  if (!$isTableCellNode(tableCellNode)) {
@@ -802,7 +804,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
802
804
  }
803
805
 
804
806
  return false;
805
- }, lexical.COMMAND_PRIORITY_CRITICAL));
807
+ }, lexical.COMMAND_PRIORITY_HIGH));
806
808
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, event => {
807
809
  const selection = lexical.$getSelection();
808
810
 
@@ -843,7 +845,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
843
845
  return selectGridNodeInDirection(tableSelection, tableNode, currentCords.x, currentCords.y, direction);
844
846
  }
845
847
  }
846
- } else if (lexical.$isGridSelection(selection) && event.shiftKey) {
848
+ } else if (lexical.DEPRECATED_$isGridSelection(selection) && event.shiftKey) {
847
849
  const tableCellNode = selection.focus.getNode();
848
850
 
849
851
  if (!$isTableCellNode(tableCellNode)) {
@@ -858,7 +860,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
858
860
  }
859
861
 
860
862
  return false;
861
- }, lexical.COMMAND_PRIORITY_CRITICAL));
863
+ }, lexical.COMMAND_PRIORITY_HIGH));
862
864
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, event => {
863
865
  const selection = lexical.$getSelection();
864
866
 
@@ -896,7 +898,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
896
898
  return selectGridNodeInDirection(tableSelection, tableNode, currentCords.x, currentCords.y, direction);
897
899
  }
898
900
  }
899
- } else if (lexical.$isGridSelection(selection) && event.shiftKey) {
901
+ } else if (lexical.DEPRECATED_$isGridSelection(selection) && event.shiftKey) {
900
902
  const tableCellNode = selection.focus.getNode();
901
903
 
902
904
  if (!$isTableCellNode(tableCellNode)) {
@@ -911,7 +913,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
911
913
  }
912
914
 
913
915
  return false;
914
- }, lexical.COMMAND_PRIORITY_CRITICAL));
916
+ }, lexical.COMMAND_PRIORITY_HIGH));
915
917
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_ARROW_RIGHT_COMMAND, event => {
916
918
  const selection = lexical.$getSelection();
917
919
 
@@ -949,7 +951,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
949
951
  return selectGridNodeInDirection(tableSelection, tableNode, currentCords.x, currentCords.y, direction);
950
952
  }
951
953
  }
952
- } else if (lexical.$isGridSelection(selection) && event.shiftKey) {
954
+ } else if (lexical.DEPRECATED_$isGridSelection(selection) && event.shiftKey) {
953
955
  const tableCellNode = selection.focus.getNode();
954
956
 
955
957
  if (!$isTableCellNode(tableCellNode)) {
@@ -964,15 +966,16 @@ function applyTableHandlers(tableNode, tableElement, editor) {
964
966
  }
965
967
 
966
968
  return false;
967
- }, lexical.COMMAND_PRIORITY_CRITICAL));
968
- tableSelection.listenersToRemove.add(editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, () => {
969
+ }, lexical.COMMAND_PRIORITY_HIGH));
970
+
971
+ const deleteTextHandler = command => () => {
969
972
  const selection = lexical.$getSelection();
970
973
 
971
974
  if (!$isSelectionInTable(selection, tableNode)) {
972
975
  return false;
973
976
  }
974
977
 
975
- if (lexical.$isGridSelection(selection)) {
978
+ if (lexical.DEPRECATED_$isGridSelection(selection)) {
976
979
  tableSelection.clearText();
977
980
  return true;
978
981
  } else if (lexical.$isRangeSelection(selection)) {
@@ -982,27 +985,68 @@ function applyTableHandlers(tableNode, tableElement, editor) {
982
985
  return false;
983
986
  }
984
987
 
985
- const paragraphNode = utils.$findMatchingParent(selection.anchor.getNode(), n => lexical.$isParagraphNode(n));
988
+ const anchorNode = selection.anchor.getNode();
989
+ const focusNode = selection.focus.getNode();
990
+ const isAnchorInside = tableNode.isParentOf(anchorNode);
991
+ const isFocusInside = tableNode.isParentOf(focusNode);
992
+ const selectionContainsPartialTable = isAnchorInside && !isFocusInside || isFocusInside && !isAnchorInside;
986
993
 
987
- if (!lexical.$isParagraphNode(paragraphNode)) {
994
+ if (selectionContainsPartialTable) {
995
+ tableSelection.clearText();
996
+ return true;
997
+ }
998
+
999
+ const parentElementNode = utils.$findMatchingParent(selection.anchor.getNode(), n => lexical.$isElementNode(n) && $isTableCellNode(n.getParent()));
1000
+ const nearestElementNode = utils.$findMatchingParent(selection.anchor.getNode(), n => lexical.$isElementNode(n));
1001
+
1002
+ if (!lexical.$isElementNode(parentElementNode) || !lexical.$isElementNode(nearestElementNode)) {
988
1003
  return false;
989
1004
  }
990
1005
 
991
- if (selection.isCollapsed() && selection.anchor.offset === 0 && paragraphNode.getPreviousSiblings().length === 0) {
1006
+ const clearCell = () => {
1007
+ const newParagraphNode = lexical.$createParagraphNode();
1008
+ const textNode = lexical.$createTextNode();
1009
+ newParagraphNode.append(textNode);
1010
+ tableCellNode.append(newParagraphNode);
1011
+ tableCellNode.getChildren().forEach(child => {
1012
+ if (child !== newParagraphNode) {
1013
+ child.remove();
1014
+ }
1015
+ });
1016
+ };
1017
+
1018
+ if (command === lexical.DELETE_LINE_COMMAND && parentElementNode.getPreviousSibling() === null) {
1019
+ clearCell();
992
1020
  return true;
993
1021
  }
1022
+
1023
+ if (command === lexical.DELETE_CHARACTER_COMMAND || command === lexical.DELETE_WORD_COMMAND) {
1024
+ if (selection.isCollapsed() && selection.anchor.offset === 0 && parentElementNode === nearestElementNode && parentElementNode.getPreviousSibling() === null) {
1025
+ return true;
1026
+ }
1027
+
1028
+ if (!lexical.$isParagraphNode(parentElementNode) && parentElementNode.getTextContentSize() === 0) {
1029
+ clearCell();
1030
+ return true;
1031
+ }
1032
+ }
994
1033
  }
995
1034
 
996
1035
  return false;
997
- }, lexical.COMMAND_PRIORITY_CRITICAL));
998
- tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {
1036
+ };
1037
+
1038
+ [lexical.DELETE_WORD_COMMAND, lexical.DELETE_LINE_COMMAND, lexical.DELETE_CHARACTER_COMMAND].forEach(command => {
1039
+ tableSelection.listenersToRemove.add(editor.registerCommand(command, deleteTextHandler(command), lexical.COMMAND_PRIORITY_CRITICAL));
1040
+ });
1041
+
1042
+ const deleteCellHandler = event => {
999
1043
  const selection = lexical.$getSelection();
1000
1044
 
1001
1045
  if (!$isSelectionInTable(selection, tableNode)) {
1002
1046
  return false;
1003
1047
  }
1004
1048
 
1005
- if (lexical.$isGridSelection(selection)) {
1049
+ if (lexical.DEPRECATED_$isGridSelection(selection)) {
1006
1050
  event.preventDefault();
1007
1051
  event.stopPropagation();
1008
1052
  tableSelection.clearText();
@@ -1016,7 +1060,10 @@ function applyTableHandlers(tableNode, tableElement, editor) {
1016
1060
  }
1017
1061
 
1018
1062
  return false;
1019
- }, lexical.COMMAND_PRIORITY_CRITICAL));
1063
+ };
1064
+
1065
+ tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, deleteCellHandler, lexical.COMMAND_PRIORITY_CRITICAL));
1066
+ tableSelection.listenersToRemove.add(editor.registerCommand(lexical.KEY_DELETE_COMMAND, deleteCellHandler, lexical.COMMAND_PRIORITY_CRITICAL));
1020
1067
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.FORMAT_TEXT_COMMAND, payload => {
1021
1068
  const selection = lexical.$getSelection();
1022
1069
 
@@ -1024,7 +1071,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
1024
1071
  return false;
1025
1072
  }
1026
1073
 
1027
- if (lexical.$isGridSelection(selection)) {
1074
+ if (lexical.DEPRECATED_$isGridSelection(selection)) {
1028
1075
  tableSelection.formatCells(payload);
1029
1076
  return true;
1030
1077
  } else if (lexical.$isRangeSelection(selection)) {
@@ -1044,7 +1091,7 @@ function applyTableHandlers(tableNode, tableElement, editor) {
1044
1091
  return false;
1045
1092
  }
1046
1093
 
1047
- if (lexical.$isGridSelection(selection)) {
1094
+ if (lexical.DEPRECATED_$isGridSelection(selection)) {
1048
1095
  tableSelection.clearHighlight();
1049
1096
  return false;
1050
1097
  } else if (lexical.$isRangeSelection(selection)) {
@@ -1080,41 +1127,63 @@ function applyTableHandlers(tableNode, tableElement, editor) {
1080
1127
  }
1081
1128
 
1082
1129
  return false;
1083
- }, lexical.COMMAND_PRIORITY_CRITICAL));
1130
+ }, lexical.COMMAND_PRIORITY_HIGH));
1084
1131
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.FOCUS_COMMAND, payload => {
1085
1132
  return tableNode.isSelected();
1086
- }, lexical.COMMAND_PRIORITY_CRITICAL));
1133
+ }, lexical.COMMAND_PRIORITY_HIGH));
1087
1134
  tableSelection.listenersToRemove.add(editor.registerCommand(lexical.SELECTION_CHANGE_COMMAND, payload => {
1088
1135
  const selection = lexical.$getSelection();
1089
1136
  const prevSelection = lexical.$getPreviousSelection();
1090
1137
 
1091
- if (selection !== prevSelection && (lexical.$isGridSelection(selection) || lexical.$isGridSelection(prevSelection)) && tableSelection.gridSelection !== selection) {
1092
- tableSelection.updateTableGridSelection(lexical.$isGridSelection(selection) && tableNode.isSelected() ? selection : null);
1093
- return false;
1094
- }
1095
-
1096
1138
  if (selection && lexical.$isRangeSelection(selection) && !selection.isCollapsed()) {
1097
1139
  const anchorNode = selection.anchor.getNode();
1098
1140
  const focusNode = selection.focus.getNode();
1099
1141
  const isAnchorInside = tableNode.isParentOf(anchorNode);
1100
1142
  const isFocusInside = tableNode.isParentOf(focusNode);
1101
- const containsPartialTable = isAnchorInside && !isFocusInside || isFocusInside && !isAnchorInside;
1143
+ const selectionContainsPartialTable = isAnchorInside && !isFocusInside || isFocusInside && !isAnchorInside;
1144
+ const selectionIsInsideTable = isAnchorInside && isFocusInside && !tableNode.isSelected();
1102
1145
 
1103
- if (containsPartialTable) {
1146
+ if (selectionContainsPartialTable) {
1104
1147
  const isBackward = selection.isBackward();
1105
1148
  const modifiedSelection = lexical.$createRangeSelection();
1106
- const tableIndex = tableNode.getIndexWithinParent();
1107
- const parentKey = tableNode.getParentOrThrow().getKey();
1108
- modifiedSelection.anchor.set(selection.anchor.key, selection.anchor.offset, selection.anchor.type); // Set selection to before or after table on the root node.
1109
-
1110
- modifiedSelection.focus.set(parentKey, isBackward ? tableIndex - 1 : tableIndex + 1, 'element');
1149
+ const tableKey = tableNode.getKey();
1150
+ modifiedSelection.anchor.set(selection.anchor.key, selection.anchor.offset, selection.anchor.type);
1151
+ modifiedSelection.focus.set(tableKey, isBackward ? 0 : tableNode.getChildrenSize(), 'element');
1111
1152
  isRangeSelectionHijacked = true;
1112
1153
  lexical.$setSelection(modifiedSelection);
1113
1154
  $addHighlightStyleToTable(tableSelection);
1114
1155
  return true;
1156
+ } else if (selectionIsInsideTable) {
1157
+ const {
1158
+ grid
1159
+ } = tableSelection;
1160
+
1161
+ if (selection.getNodes().filter($isTableCellNode).length === grid.rows * grid.columns) {
1162
+ const gridSelection = lexical.DEPRECATED_$createGridSelection();
1163
+ const tableKey = tableNode.getKey();
1164
+ const firstCell = tableNode.getFirstChildOrThrow().getFirstChild();
1165
+ const lastCell = tableNode.getLastChildOrThrow().getLastChild();
1166
+
1167
+ if (firstCell != null && lastCell != null) {
1168
+ gridSelection.set(tableKey, firstCell.getKey(), lastCell.getKey());
1169
+ lexical.$setSelection(gridSelection);
1170
+ tableSelection.updateTableGridSelection(gridSelection);
1171
+ return true;
1172
+ }
1173
+ }
1115
1174
  }
1116
1175
  }
1117
1176
 
1177
+ if (selection && !selection.is(prevSelection) && (lexical.DEPRECATED_$isGridSelection(selection) || lexical.DEPRECATED_$isGridSelection(prevSelection)) && tableSelection.gridSelection && !tableSelection.gridSelection.is(prevSelection)) {
1178
+ if (lexical.DEPRECATED_$isGridSelection(selection) && selection.gridKey === tableSelection.tableNodeKey) {
1179
+ tableSelection.updateTableGridSelection(selection);
1180
+ } else if (!lexical.DEPRECATED_$isGridSelection(selection) && lexical.DEPRECATED_$isGridSelection(prevSelection) && prevSelection.gridKey === tableSelection.tableNodeKey) {
1181
+ tableSelection.updateTableGridSelection(null);
1182
+ }
1183
+
1184
+ return false;
1185
+ }
1186
+
1118
1187
  if (tableSelection.hasHijackedSelectionStyles && !tableNode.isSelected()) {
1119
1188
  $removeHighlightStyleToTable(tableSelection);
1120
1189
  isRangeSelectionHijacked = false;
@@ -1365,7 +1434,7 @@ const adjustFocusNodeInDirection = (tableSelection, tableNode, x, y, direction)
1365
1434
  };
1366
1435
 
1367
1436
  function $isSelectionInTable(selection, tableNode) {
1368
- if (lexical.$isRangeSelection(selection) || lexical.$isGridSelection(selection)) {
1437
+ if (lexical.$isRangeSelection(selection) || lexical.DEPRECATED_$isGridSelection(selection)) {
1369
1438
  const isAnchorInside = tableNode.isParentOf(selection.anchor.getNode());
1370
1439
  const isFocusInside = tableNode.isParentOf(selection.focus.getNode());
1371
1440
  return isAnchorInside && isFocusInside;
@@ -1393,7 +1462,7 @@ function selectTableCellNode(tableCell) {
1393
1462
  */
1394
1463
 
1395
1464
  /** @noInheritDoc */
1396
- class TableNode extends lexical.GridNode {
1465
+ class TableNode extends lexical.DEPRECATED_GridNode {
1397
1466
  /** @internal */
1398
1467
  static getType() {
1399
1468
  return 'table';
@@ -1407,7 +1476,7 @@ class TableNode extends lexical.GridNode {
1407
1476
  return {
1408
1477
  table: _node => ({
1409
1478
  conversion: convertTableElement,
1410
- priority: 0
1479
+ priority: 1
1411
1480
  })
1412
1481
  };
1413
1482
  }
@@ -1473,6 +1542,10 @@ class TableNode extends lexical.GridNode {
1473
1542
  return false;
1474
1543
  }
1475
1544
 
1545
+ isShadowRoot() {
1546
+ return true;
1547
+ }
1548
+
1476
1549
  getCordsFromCellNode(tableCellNode, grid) {
1477
1550
  const {
1478
1551
  rows,
@@ -1732,7 +1805,7 @@ function $insertTableRow(tableNode, targetIndex, shouldInsertAfter = true, rowCo
1732
1805
 
1733
1806
  return tableNode;
1734
1807
  }
1735
- function $insertTableColumn(tableNode, targetIndex, shouldInsertAfter = true, columnCount) {
1808
+ function $insertTableColumn(tableNode, targetIndex, shouldInsertAfter = true, columnCount, grid) {
1736
1809
  const tableRows = tableNode.getChildren();
1737
1810
 
1738
1811
  for (let r = 0; r < tableRows.length; r++) {
@@ -1740,14 +1813,6 @@ function $insertTableColumn(tableNode, targetIndex, shouldInsertAfter = true, co
1740
1813
 
1741
1814
  if ($isTableRowNode(currentTableRowNode)) {
1742
1815
  for (let c = 0; c < columnCount; c++) {
1743
- let headerState = TableCellHeaderStates.NO_STATUS;
1744
-
1745
- if (r === 0) {
1746
- headerState |= TableCellHeaderStates.ROW;
1747
- }
1748
-
1749
- const newTableCell = $createTableCellNode(headerState);
1750
- newTableCell.append(lexical.$createParagraphNode());
1751
1816
  const tableRowChildren = currentTableRowNode.getChildren();
1752
1817
 
1753
1818
  if (targetIndex >= tableRowChildren.length || targetIndex < 0) {
@@ -1756,6 +1821,23 @@ function $insertTableColumn(tableNode, targetIndex, shouldInsertAfter = true, co
1756
1821
 
1757
1822
  const targetCell = tableRowChildren[targetIndex];
1758
1823
 
1824
+ if (!$isTableCellNode(targetCell)) {
1825
+ throw Error(`Expected table cell`);
1826
+ }
1827
+
1828
+ const {
1829
+ left,
1830
+ right
1831
+ } = $getTableCellSiblingsFromTableCellNode(targetCell, grid);
1832
+ let headerState = TableCellHeaderStates.NO_STATUS;
1833
+
1834
+ if (left && left.hasHeaderState(TableCellHeaderStates.ROW) || right && right.hasHeaderState(TableCellHeaderStates.ROW)) {
1835
+ headerState |= TableCellHeaderStates.ROW;
1836
+ }
1837
+
1838
+ const newTableCell = $createTableCellNode(headerState);
1839
+ newTableCell.append(lexical.$createParagraphNode());
1840
+
1759
1841
  if (shouldInsertAfter) {
1760
1842
  targetCell.insertAfter(newTableCell);
1761
1843
  } else {
@@ -1788,7 +1870,7 @@ function $deleteTableColumn(tableNode, targetIndex) {
1788
1870
  }
1789
1871
 
1790
1872
  /** @module @lexical/table */
1791
- const INSERT_TABLE_COMMAND = lexical.createCommand();
1873
+ const INSERT_TABLE_COMMAND = lexical.createCommand('INSERT_TABLE_COMMAND');
1792
1874
 
1793
1875
  exports.$createTableCellNode = $createTableCellNode;
1794
1876
  exports.$createTableNode = $createTableNode;
@@ -204,6 +204,7 @@ declare export function $insertTableColumn(
204
204
  targetIndex: number,
205
205
  shouldInsertAfter?: boolean,
206
206
  columnCount: number,
207
+ grid: Grid,
207
208
  ): TableNode;
208
209
 
209
210
  declare export function $deleteTableColumn(
@@ -4,56 +4,60 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var f=require("lexical"),p=require("@lexical/utils");let q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
8
- class t extends f.GridCellNode{static getType(){return"tablecell"}static clone(a){return new t(a.__headerState,a.__colSpan,a.__width,a.__key)}static importDOM(){return{td:()=>({conversion:w,priority:0}),th:()=>({conversion:w,priority:0})}}static importJSON(a){return x(a.headerState,a.colSpan,a.width||void 0)}constructor(a=q.NO_STATUS,b=1,d,k){super(b,k);this.__headerState=a;this.__width=d}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);p.addClassNamesToElement(b,
9
- a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));if(a){let b=this.getParentOrThrow().getChildrenSize();a.style.border="1px solid black";a.style.width=`${this.getWidth()||Math.max(90,700/b)}px`;a.style.verticalAlign="top";a.style.textAlign="start";this.hasHeader()&&(a.style.backgroundColor="#f2f3f5")}return{element:a}}exportJSON(){return{...super.exportJSON(),colSpan:super.__colSpan,headerState:this.__headerState,type:"tablecell",width:this.getWidth()}}getTag(){return this.hasHeader()?
10
- "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}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!==q.NO_STATUS}updateDOM(a){return a.__headerState!==
11
- this.__headerState||a.__width!==this.__width}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function w(a){a=a.nodeName.toLowerCase();return{forChild:(b,d)=>{if(y(d)&&!f.$isElementNode(b)){d=f.$createParagraphNode();if(f.$isLineBreakNode(b)&&"\n"===b.getTextContent())return null;d.append(b);return d}return b},node:x("th"===a?q.ROW:q.NO_STATUS)}}function x(a,b=1,d){return new t(a,b,d)}function y(a){return a instanceof t}
12
- class z extends f.GridRowNode{static getType(){return"tablerow"}static clone(a){return new z(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:A,priority:0})}}static importJSON(a){return B(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);p.addClassNamesToElement(b,a.theme.tableRow);return b}setHeight(a){this.getWritable().__height=
13
- a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function A(){return{node:B()}}function B(a){return new z(a)}function C(a){return a instanceof z}function D(a){throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?code=${a} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
14
- if("undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement){let a=document.createElement("style");a.innerHTML="\n table.disable-selection {\n -webkit-touch-callout: none;\n -webkit-user-select: none; \n -khtml-user-select: none; \n -moz-user-select: none; \n -ms-user-select: none; \n user-select: none;\n }\n \n .disable-selection span::selection{\n background-color: transparent;\n }\n .disable-selection br::selection{\n background-color: transparent;\n }\n ";
15
- document.body&&document.body.append(a)}
16
- class E{constructor(a,b){this.isHighlightingCells=!1;this.currentY=this.currentX=this.startY=this.startX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.grid={cells:[],columns:0,rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTableGrid()}getGrid(){return this.grid}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTableGrid(){let a=new MutationObserver(b=>
17
- {this.editor.update(()=>{var d=!1;for(let k=0;k<b.length;k++){const c=b[k].target.nodeName;if("TABLE"===c||"TR"===c){d=!0;break}}if(d){d=this.editor.getElementByKey(this.tableNodeKey);if(!d)throw Error("Expected to find TableElement in DOM");this.grid=F(d)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.grid=F(b);a.observe(b,{childList:!0,subtree:!0})})}clearHighlight(){this.editor.update(()=>{var a=f.$getNodeByKey(this.tableNodeKey);
18
- if(!G(a))throw Error("Expected TableNode.");a=this.editor.getElementByKey(this.tableNodeKey);if(!a)throw Error("Expected to find TableElement in DOM");a=F(a);this.isHighlightingCells=!1;this.currentY=this.currentX=this.startY=this.startX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null;this.hasHijackedSelectionStyles=!1;H(a,null);f.$setSelection(null);this.editor.dispatchCommand(f.SELECTION_CHANGE_COMMAND,void 0);this.enableHighlightStyle()})}enableHighlightStyle(){this.editor.update(()=>
19
- {let a=this.editor.getElementByKey(this.tableNodeKey);if(!a)throw Error("Expected to find TableElement in DOM");a.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){this.editor.update(()=>{let a=this.editor.getElementByKey(this.tableNodeKey);if(!a)throw Error("Expected to find TableElement in DOM");a.classList.add("disable-selection");this.hasHijackedSelectionStyles=!0})}updateTableGridSelection(a){if(null!=a){this.gridSelection=a;this.isHighlightingCells=
20
- !0;this.disableHighlightStyle();let b=this.editor.getElementByKey(a.anchor.key);a=this.editor.getElementByKey(a.focus.key);if(b&&a){let d=window.getSelection();d&&d.setBaseAndExtent(b,0,a,0)}H(this.grid,this.gridSelection)}else this.clearHighlight()}adjustFocusCellForSelection(a,b=!1){this.editor.update(()=>{var d=f.$getNodeByKey(this.tableNodeKey);if(!G(d))throw Error("Expected TableNode.");if(!this.editor.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");d=a.x;
21
- let k=a.y;this.focusCell=a;let c=window.getSelection();null!==this.anchorCell&&c&&c.setBaseAndExtent(this.anchorCell.elem,0,a.elem,0);if(!this.isHighlightingCells&&(this.startX!==d||this.startY!==k||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(d===this.currentX&&k===this.currentY)return;this.currentX=d;this.currentY=k;this.isHighlightingCells&&(d=f.$getNearestNodeFromDOMNode(a.elem),null!=this.gridSelection&&null!=this.anchorCellNodeKey&&y(d)&&(d=d.getKey(),this.gridSelection=
22
- f.$createGridSelection(),this.focusCellNodeKey=d,this.gridSelection.set(this.tableNodeKey,this.anchorCellNodeKey,this.focusCellNodeKey),f.$setSelection(this.gridSelection),this.editor.dispatchCommand(f.SELECTION_CHANGE_COMMAND,void 0),H(this.grid,this.gridSelection)))})}setAnchorCellForSelection(a){this.editor.update(()=>{this.anchorCell=a;this.startX=a.x;this.startY=a.y;var b=window.getSelection();b&&b.setBaseAndExtent(a.elem,0,a.elem,0);b=f.$getNearestNodeFromDOMNode(a.elem);y(b)&&(b=b.getKey(),
23
- this.gridSelection=f.$createGridSelection(),this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=f.$getSelection();f.$isGridSelection(b)||D(11);let d=f.$createRangeSelection(),k=d.anchor,c=d.focus;b.getNodes().forEach(h=>{y(h)&&0!==h.getTextContentSize()&&(k.set(h.getKey(),0,"element"),c.set(h.getKey(),h.getChildrenSize(),"element"),d.formatText(a))});f.$setSelection(b);this.editor.dispatchCommand(f.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){this.editor.update(()=>{let a=f.$getNodeByKey(this.tableNodeKey);
24
- if(!G(a))throw Error("Expected TableNode.");var b=f.$getSelection();f.$isGridSelection(b)||D(11);b=b.getNodes().filter(y);b.length===this.grid.columns*this.grid.rows?(a.selectPrevious(),a.remove(),this.clearHighlight()):(b.forEach(d=>{if(f.$isElementNode(d)){let k=f.$createParagraphNode(),c=f.$createTextNode();k.append(c);d.append(k);d.getChildren().forEach(h=>{h!==k&&h.remove()})}}),H(this.grid,null),f.$setSelection(null),this.editor.dispatchCommand(f.SELECTION_CHANGE_COMMAND,void 0))})}}
25
- function I(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}
26
- function F(a){let b=[],d={cells:b,columns:0,rows:0};var k=a.firstChild;let c=a=0;for(b.length=0;null!=k;){var h=k.nodeName;if("TD"===h||"TH"===h)h={elem:k,highlighted:!1,x:a,y:c},k._cell=h,void 0===b[c]&&(b[c]=[]),b[c][a]=h;else if(h=k.firstChild,null!=h){k=h;continue}h=k.nextSibling;if(null!=h)a++,k=h;else if(h=k.parentNode,null!=h){k=h.nextSibling;if(null==k)break;c++;a=0}}d.columns=a+1;d.rows=c+1;return d}
27
- function H(a,b){let d=[],k=new Set(b?b.getNodes():[]);J(a,(c,h)=>{let n=c.elem;k.has(h)?(c.highlighted=!0,n.style.setProperty("background-color","rgb(172, 206, 247)"),n.style.setProperty("caret-color","transparent"),d.push(c)):(c.highlighted=!1,n.style.removeProperty("background-color"),n.style.removeProperty("caret-color"),n.getAttribute("style")||n.removeAttribute("style"))});return d}
28
- function J(a,b){({cells:a}=a);for(let d=0;d<a.length;d++){let k=a[d];for(let c=0;c<k.length;c++){let h=k[c],n=f.$getNearestNodeFromDOMNode(h.elem);null!==n&&b(h,n,{x:c,y:d})}}}function K(a){a.disableHighlightStyle();J(a.grid,b=>{let d=b.elem;b.highlighted=!0;d.style.setProperty("background-color","rgb(172, 206, 247)");d.style.setProperty("caret-color","transparent")})}
29
- function O(a){a.enableHighlightStyle();J(a.grid,b=>{let d=b.elem;b.highlighted=!1;d.style.removeProperty("background-color");d.style.removeProperty("caret-color");d.getAttribute("style")||d.removeAttribute("style")})}
30
- let Q=(a,b,d,k,c)=>{const h="forward"===c;switch(c){case "backward":case "forward":return d!==(h?a.grid.columns-1:0)?P(b.getCellNodeFromCordsOrThrow(d+(h?1:-1),k,a.grid)):k!==(h?a.grid.rows-1:0)?P(b.getCellNodeFromCordsOrThrow(h?0:a.grid.columns-1,k+(h?1:-1),a.grid)):h?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==k?P(b.getCellNodeFromCordsOrThrow(d,k-1,a.grid)):b.selectPrevious(),!0;case "down":return k!==a.grid.rows-1?P(b.getCellNodeFromCordsOrThrow(d,k+1,a.grid)):b.selectNext(),!0;
31
- default:return!1}},R=(a,b,d,k,c)=>{const h="forward"===c;switch(c){case "backward":case "forward":return d!==(h?a.grid.columns-1:0)&&a.adjustFocusCellForSelection(b.getCellFromCordsOrThrow(d+(h?1:-1),k,a.grid)),!0;case "up":return 0!==k?(a.adjustFocusCellForSelection(b.getCellFromCordsOrThrow(d,k-1,a.grid)),!0):!1;case "down":return k!==a.grid.rows-1?(a.adjustFocusCellForSelection(b.getCellFromCordsOrThrow(d,k+1,a.grid)),!0):!1;default:return!1}};
32
- function S(a,b){if(f.$isRangeSelection(a)||f.$isGridSelection(a)){let d=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return d&&a}return!1}function P(a){let b=a.getChildren().find(d=>f.$isParagraphNode(d));f.$isParagraphNode(b)?b.selectEnd():a.selectEnd()}
33
- class T extends f.GridNode{static getType(){return"table"}static clone(a){return new T(a.__key)}static importDOM(){return{table:()=>({conversion:U,priority:0})}}static importJSON(){return V()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");p.addClassNamesToElement(b,a.theme.table);return b}updateDOM(){return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let d=b.cloneNode(),k=document.createElement("colgroup"),
34
- c=document.createElement("tbody");c.append(...b.children);b=this.getFirstChildOrThrow();if(!C(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let h=0;h<b;h++){let n=document.createElement("col");k.append(n)}d.replaceChildren(k,c);return d}}}}canExtractContents(){return!1}canBeEmpty(){return!1}getCordsFromCellNode(a,b){let {rows:d,cells:k}=b;for(b=0;b<d;b++){var c=k[b];if(null==c)throw Error(`Row not found at y:${b}`);c=c.findIndex(({elem:h})=>f.$getNearestNodeFromDOMNode(h)===
35
- a);if(-1!==c)return{x:c,y:b}}throw Error("Cell not found in table.");}getCellFromCords(a,b,d){({cells:d}=d);b=d[b];if(null==b)return null;a=b[a];return null==a?null:a}getCellFromCordsOrThrow(a,b,d){a=this.getCellFromCords(a,b,d);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,d){a=this.getCellFromCords(a,b,d);if(null==a)return null;a=f.$getNearestNodeFromDOMNode(a.elem);return y(a)?a:null}getCellNodeFromCordsOrThrow(a,b,d){a=this.getCellNodeFromCords(a,b,d);if(!a)throw Error("Node at cords not TableCellNode.");
36
- return a}canSelectBefore(){return!0}canIndent(){return!1}}function U(){return{node:V()}}function V(){return new T}function G(a){return a instanceof T}function W(a){a=p.$findMatchingParent(a,b=>C(b));if(C(a))return a;throw Error("Expected table cell to be inside of table row.");}function X(a){a=p.$findMatchingParent(a,b=>G(b));if(G(a))return a;throw Error("Expected table cell to be inside of table.");}let Y=f.createCommand();exports.$createTableCellNode=x;exports.$createTableNode=V;
37
- exports.$createTableNodeWithDimensions=function(a,b,d=!0){let k=V();for(let h=0;h<a;h++){let n=B();for(let r=0;r<b;r++){var c=q.NO_STATUS;d&&(0===h&&(c|=q.ROW),0===r&&(c|=q.COLUMN));c=x(c);let v=f.$createParagraphNode();v.append(f.$createTextNode());c.append(v);n.append(c)}k.append(n)}return k};exports.$createTableRowNode=B;
38
- exports.$deleteTableColumn=function(a,b){let d=a.getChildren();for(let c=0;c<d.length;c++){var k=d[c];if(C(k)){k=k.getChildren();if(b>=k.length||0>b)throw Error("Table column target index out of range");k[b].remove()}}return a};exports.$getElementGridForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return F(a)};exports.$getTableCellNodeFromLexicalNode=function(a){a=p.$findMatchingParent(a,b=>y(b));return y(a)?a:null};
39
- exports.$getTableColumnIndexFromTableCellNode=function(a){return W(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=X;exports.$getTableRowIndexFromTableCellNode=function(a){let b=W(a);return X(b).getChildren().findIndex(d=>d.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=W;
40
- exports.$insertTableColumn=function(a,b,d=!0,k){let c=a.getChildren();for(let r=0;r<c.length;r++){let v=c[r];if(C(v))for(let g=0;g<k;g++){var h=q.NO_STATUS;0===r&&(h|=q.ROW);h=x(h);h.append(f.$createParagraphNode());var n=v.getChildren();if(b>=n.length||0>b)throw Error("Table column target index out of range");n=n[b];d?n.insertAfter(h):n.insertBefore(h)}}return a};
41
- exports.$insertTableRow=function(a,b,d=!0,k,c){var h=a.getChildren();if(b>=h.length||0>b)throw Error("Table row target index out of range");b=h[b];if(C(b))for(h=0;h<k;h++){let v=b.getChildren(),g=v.length,e=B();for(let l=0;l<g;l++){var n=v[l];y(n)||D(12);var r=c;let m=X(n),{x:u,y:L}=m.getCordsFromCellNode(n,r);n={above:m.getCellNodeFromCords(u,L-1,r),below:m.getCellNodeFromCords(u,L+1,r),left:m.getCellNodeFromCords(u-1,L,r),right:m.getCellNodeFromCords(u+1,L,r)};let {above:M,below:N}=n;n=q.NO_STATUS;
42
- r=M&&M.getWidth()||N&&N.getWidth()||void 0;if(M&&M.hasHeaderState(q.COLUMN)||N&&N.hasHeaderState(q.COLUMN))n|=q.COLUMN;n=x(n,1,r);n.append(f.$createParagraphNode());e.append(n)}d?b.insertAfter(e):b.insertBefore(e)}else throw Error("Row before insertion index does not exist.");return a};exports.$isTableCellNode=y;exports.$isTableNode=G;exports.$isTableRowNode=C;
43
- exports.$removeTableRowAtIndex=function(a,b){let d=a.getChildren();if(b>=d.length||0>b)throw Error("Expected table cell to be inside of table row.");d[b].remove();return a};exports.INSERT_TABLE_COMMAND=Y;exports.TableCellHeaderStates=q;exports.TableCellNode=t;exports.TableNode=T;exports.TableRowNode=z;exports.TableSelection=E;
44
- exports.applyTableHandlers=function(a,b,d){let k=d.getRootElement();if(null===k)throw Error("No root element.");let c=new E(d,a.getKey());b.__lexicalTableSelection=c;let h=!1,n=!1;b.addEventListener("dblclick",g=>{let e=I(g.target);null!==e&&(g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),c.setAnchorCellForSelection(e),c.adjustFocusCellForSelection(e,!0),h=!1)});b.addEventListener("mousedown",g=>{setTimeout(()=>{if(0===g.button){var e=I(g.target);null!==e&&(c.setAnchorCellForSelection(e),
45
- document.addEventListener("mouseup",()=>{h=!1},{capture:!0,once:!0}))}},0)});b.addEventListener("mousemove",g=>{n&&(g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation());if(h){let e=I(g.target);if(null!==e){let l=e.x,m=e.y;h&&(c.startX!==l||c.startY!==m||c.isHighlightingCells)&&(g.preventDefault(),h=!0,c.adjustFocusCellForSelection(e))}}});b.addEventListener("mouseup",()=>{h&&(h=!1)});b.addEventListener("mouseleave",()=>{});let r=g=>{h=!0;0===g.button&&d.update(()=>{const e=f.$getSelection();
46
- if(f.$isGridSelection(e)&&e.gridKey===c.tableNodeKey&&k.contains(g.target))return c.clearHighlight()})};window.addEventListener("mousedown",r);c.listenersToRemove.add(()=>window.removeEventListener("mousedown",r));let v=()=>{h=!1};window.addEventListener("mouseup",v);c.listenersToRemove.add(()=>window.removeEventListener("mouseup",v));c.listenersToRemove.add(d.registerCommand(f.KEY_ARROW_DOWN_COMMAND,g=>{var e=f.$getSelection();if(!S(e,a))return!1;if(f.$isRangeSelection(e)){if(e.isCollapsed()){var l=
47
- p.$findMatchingParent(e.anchor.getNode(),u=>y(u));if(!y(l))return!1;var m=a.getCordsFromCellNode(l,c.grid);e=p.$findMatchingParent(e.anchor.getNode(),u=>f.$isElementNode(u));if(null==e)throw Error("Expected BlockNode Parent");if((l=l.getLastChild())&&e.isParentOf(l)||e===l||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(m.x,m.y,c.grid)),R(c,a,m.x,m.y,"down")):Q(c,a,m.x,m.y,"down")}}else if(f.$isGridSelection(e)&&
48
- g.shiftKey){m=e.focus.getNode();if(!y(m))return!1;m=a.getCordsFromCellNode(m,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return R(c,a,m.x,m.y,"down")}return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.KEY_ARROW_UP_COMMAND,g=>{var e=f.$getSelection();if(!S(e,a))return!1;if(f.$isRangeSelection(e)){if(e.isCollapsed()){var l=p.$findMatchingParent(e.anchor.getNode(),u=>y(u));if(!y(l))return!1;var m=a.getCordsFromCellNode(l,c.grid);e=p.$findMatchingParent(e.anchor.getNode(),
49
- u=>f.$isElementNode(u));if(null==e)throw Error("Expected BlockNode Parent");if((l=l.getLastChild())&&e.isParentOf(l)||e===l||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(m.x,m.y,c.grid)),R(c,a,m.x,m.y,"up")):Q(c,a,m.x,m.y,"up")}}else if(f.$isGridSelection(e)&&g.shiftKey){m=e.focus.getNode();if(!y(m))return!1;m=a.getCordsFromCellNode(m,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();
50
- return R(c,a,m.x,m.y,"up")}return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.KEY_ARROW_LEFT_COMMAND,g=>{var e=f.$getSelection();if(!S(e,a))return!1;if(f.$isRangeSelection(e)){if(e.isCollapsed()){var l=p.$findMatchingParent(e.anchor.getNode(),m=>y(m));if(!y(l))return!1;l=a.getCordsFromCellNode(l,c.grid);if(null==p.$findMatchingParent(e.anchor.getNode(),m=>f.$isElementNode(m)))throw Error("Expected BlockNode Parent");if(0===e.anchor.offset||g.shiftKey)return g.preventDefault(),
51
- g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(l.x,l.y,c.grid)),R(c,a,l.x,l.y,"backward")):Q(c,a,l.x,l.y,"backward")}}else if(f.$isGridSelection(e)&&g.shiftKey){e=e.focus.getNode();if(!y(e))return!1;e=a.getCordsFromCellNode(e,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return R(c,a,e.x,e.y,"backward")}return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.KEY_ARROW_RIGHT_COMMAND,
52
- g=>{var e=f.$getSelection();if(!S(e,a))return!1;if(f.$isRangeSelection(e)){if(e.isCollapsed()){var l=p.$findMatchingParent(e.anchor.getNode(),m=>y(m));if(!y(l))return!1;l=a.getCordsFromCellNode(l,c.grid);if(null==p.$findMatchingParent(e.anchor.getNode(),m=>f.$isElementNode(m)))throw Error("Expected BlockNode Parent");if(e.anchor.offset===e.anchor.getNode().getTextContentSize()||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(l.x,
53
- l.y,c.grid)),R(c,a,l.x,l.y,"forward")):Q(c,a,l.x,l.y,"forward")}}else if(f.$isGridSelection(e)&&g.shiftKey){e=e.focus.getNode();if(!y(e))return!1;e=a.getCordsFromCellNode(e,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return R(c,a,e.x,e.y,"forward")}return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.DELETE_CHARACTER_COMMAND,()=>{let g=f.$getSelection();if(!S(g,a))return!1;if(f.$isGridSelection(g))return c.clearText(),!0;if(f.$isRangeSelection(g)){var e=
54
- p.$findMatchingParent(g.anchor.getNode(),l=>y(l));if(!y(e))return!1;e=p.$findMatchingParent(g.anchor.getNode(),l=>f.$isParagraphNode(l));if(!f.$isParagraphNode(e))return!1;if(g.isCollapsed()&&0===g.anchor.offset&&0===e.getPreviousSiblings().length)return!0}return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.KEY_BACKSPACE_COMMAND,g=>{let e=f.$getSelection();if(!S(e,a))return!1;if(f.$isGridSelection(e))return g.preventDefault(),g.stopPropagation(),c.clearText(),!0;f.$isRangeSelection(e)&&
55
- (g=p.$findMatchingParent(e.anchor.getNode(),l=>y(l)),y(g));return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.FORMAT_TEXT_COMMAND,g=>{let e=f.$getSelection();if(!S(e,a))return!1;if(f.$isGridSelection(e))return c.formatCells(g),!0;f.$isRangeSelection(e)&&(g=p.$findMatchingParent(e.anchor.getNode(),l=>y(l)),y(g));return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var g=f.$getSelection();if(!S(g,
56
- a))return!1;f.$isGridSelection(g)?c.clearHighlight():f.$isRangeSelection(g)&&(g=p.$findMatchingParent(g.anchor.getNode(),e=>y(e)),y(g));return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.KEY_TAB_COMMAND,g=>{var e=f.$getSelection();if(!S(e,a))return!1;if(f.$isRangeSelection(e)){let l=p.$findMatchingParent(e.anchor.getNode(),m=>y(m));if(!y(l))return!1;if(e.isCollapsed())return e=a.getCordsFromCellNode(l,c.grid),g.preventDefault(),Q(c,a,e.x,e.y,g.shiftKey?"backward":
57
- "forward"),!0}return!1},f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.FOCUS_COMMAND,()=>a.isSelected(),f.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(d.registerCommand(f.SELECTION_CHANGE_COMMAND,()=>{let g=f.$getSelection();var e=f.$getPreviousSelection();if(g!==e&&(f.$isGridSelection(g)||f.$isGridSelection(e))&&c.gridSelection!==g)return c.updateTableGridSelection(f.$isGridSelection(g)&&a.isSelected()?g:null),!1;if(g&&f.$isRangeSelection(g)&&!g.isCollapsed()){var l=
58
- g.anchor.getNode();e=g.focus.getNode();l=a.isParentOf(l);e=a.isParentOf(e);if(l&&!e||e&&!l){e=g.isBackward();l=f.$createRangeSelection();let m=a.getIndexWithinParent(),u=a.getParentOrThrow().getKey();l.anchor.set(g.anchor.key,g.anchor.offset,g.anchor.type);l.focus.set(u,e?m-1:m+1,"element");n=!0;f.$setSelection(l);K(c);return!0}}c.hasHijackedSelectionStyles&&!a.isSelected()?(O(c),n=!1):!c.hasHijackedSelectionStyles&&a.isSelected()&&K(c);return!1},f.COMMAND_PRIORITY_CRITICAL));return c};
59
- exports.getCellFromTarget=I;exports.getTableSelectionFromTableElement=function(a){return a.__lexicalTableSelection}
7
+ 'use strict';var d=require("lexical"),n=require("@lexical/utils");let q={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};
8
+ class t extends d.DEPRECATED_GridCellNode{static getType(){return"tablecell"}static clone(a){return new t(a.__headerState,a.__colSpan,a.__width,a.__key)}static importDOM(){return{td:()=>({conversion:x,priority:0}),th:()=>({conversion:x,priority:0})}}static importJSON(a){return z(a.headerState,a.colSpan,a.width||void 0)}constructor(a=q.NO_STATUS,b=1,e,h){super(b,h);this.__headerState=a;this.__width=e}createDOM(a){let b=document.createElement(this.getTag());this.__width&&(b.style.width=`${this.__width}px`);
9
+ n.addClassNamesToElement(b,a.theme.tableCell,this.hasHeader()&&a.theme.tableCellHeader);return b}exportDOM(a){({element:a}=super.exportDOM(a));if(a){let b=this.getParentOrThrow().getChildrenSize();a.style.border="1px solid black";a.style.width=`${this.getWidth()||Math.max(90,700/b)}px`;a.style.verticalAlign="top";a.style.textAlign="start";this.hasHeader()&&(a.style.backgroundColor="#f2f3f5")}return{element:a}}exportJSON(){return{...super.exportJSON(),colSpan:super.__colSpan,headerState:this.__headerState,
10
+ type:"tablecell",width:this.getWidth()}}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}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()&
11
+ a)===a}hasHeader(){return this.getLatest().__headerState!==q.NO_STATUS}updateDOM(a){return a.__headerState!==this.__headerState||a.__width!==this.__width}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}
12
+ function x(a){a=a.nodeName.toLowerCase();return{forChild:(b,e)=>{if(B(e)&&!d.$isElementNode(b)){e=d.$createParagraphNode();if(d.$isLineBreakNode(b)&&"\n"===b.getTextContent())return null;e.append(b);return e}return b},node:z("th"===a?q.ROW:q.NO_STATUS)}}function z(a,b=1,e){return new t(a,b,e)}function B(a){return a instanceof t}
13
+ class C extends d.DEPRECATED_GridRowNode{static getType(){return"tablerow"}static clone(a){return new C(a.__height,a.__key)}static importDOM(){return{tr:()=>({conversion:D,priority:0})}}static importJSON(a){return E(a.height)}constructor(a,b){super(b);this.__height=a}exportJSON(){return{...super.exportJSON(),type:"tablerow",version:1}}createDOM(a){let b=document.createElement("tr");this.__height&&(b.style.height=`${this.__height}px`);n.addClassNamesToElement(b,a.theme.tableRow);return b}isShadowRoot(){return!0}setHeight(a){this.getWritable().__height=
14
+ a;return this.__height}getHeight(){return this.getLatest().__height}updateDOM(a){return a.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function D(){return{node:E()}}function E(a){return new C(a)}function F(a){return a instanceof C}function H(a){throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?code=${a} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}
15
+ let I="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;
16
+ if(I){let a=document.createElement("style");a.innerHTML="\n table.disable-selection {\n -webkit-touch-callout: none;\n -webkit-user-select: none; \n -khtml-user-select: none; \n -moz-user-select: none; \n -ms-user-select: none; \n user-select: none;\n }\n \n .disable-selection span::selection{\n background-color: transparent;\n }\n .disable-selection br::selection{\n background-color: transparent;\n }\n ";document.body&&document.body.append(a)}
17
+ class J{constructor(a,b){this.isHighlightingCells=!1;this.currentY=this.currentX=this.startY=this.startX=-1;this.listenersToRemove=new Set;this.tableNodeKey=b;this.editor=a;this.grid={cells:[],columns:0,rows:0};this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null;this.hasHijackedSelectionStyles=!1;this.trackTableGrid()}getGrid(){return this.grid}removeListeners(){Array.from(this.listenersToRemove).forEach(a=>a())}trackTableGrid(){let a=new MutationObserver(b=>
18
+ {this.editor.update(()=>{var e=!1;for(let h=0;h<b.length;h++){const c=b[h].target.nodeName;if("TABLE"===c||"TR"===c){e=!0;break}}if(e){e=this.editor.getElementByKey(this.tableNodeKey);if(!e)throw Error("Expected to find TableElement in DOM");this.grid=K(e)}})});this.editor.update(()=>{let b=this.editor.getElementByKey(this.tableNodeKey);if(!b)throw Error("Expected to find TableElement in DOM");this.grid=K(b);a.observe(b,{childList:!0,subtree:!0})})}clearHighlight(){this.editor.update(()=>{var a=d.$getNodeByKey(this.tableNodeKey);
19
+ if(!L(a))throw Error("Expected TableNode.");a=this.editor.getElementByKey(this.tableNodeKey);if(!a)throw Error("Expected to find TableElement in DOM");a=K(a);this.isHighlightingCells=!1;this.currentY=this.currentX=this.startY=this.startX=-1;this.focusCell=this.anchorCell=this.focusCellNodeKey=this.anchorCellNodeKey=this.gridSelection=null;this.hasHijackedSelectionStyles=!1;M(a,null);d.$setSelection(null);this.editor.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0);this.enableHighlightStyle()})}enableHighlightStyle(){this.editor.update(()=>
20
+ {let a=this.editor.getElementByKey(this.tableNodeKey);if(!a)throw Error("Expected to find TableElement in DOM");a.classList.remove("disable-selection");this.hasHijackedSelectionStyles=!1})}disableHighlightStyle(){this.editor.update(()=>{let a=this.editor.getElementByKey(this.tableNodeKey);if(!a)throw Error("Expected to find TableElement in DOM");a.classList.add("disable-selection");this.hasHijackedSelectionStyles=!0})}updateTableGridSelection(a){null!=a&&a.gridKey===this.tableNodeKey&&(this.gridSelection=
21
+ a,this.isHighlightingCells=!0,this.disableHighlightStyle(),M(this.grid,this.gridSelection));null==a&&this.clearHighlight()}adjustFocusCellForSelection(a,b=!1){this.editor.update(()=>{var e=d.$getNodeByKey(this.tableNodeKey);if(!L(e))throw Error("Expected TableNode.");if(!this.editor.getElementByKey(this.tableNodeKey))throw Error("Expected to find TableElement in DOM");e=a.x;let h=a.y;this.focusCell=a;if(null!==this.anchorCell){let c=I?window.getSelection():null;c&&c.setBaseAndExtent(this.anchorCell.elem,
22
+ 0,this.anchorCell.elem,0)}if(!this.isHighlightingCells&&(this.startX!==e||this.startY!==h||b))this.isHighlightingCells=!0,this.disableHighlightStyle();else if(e===this.currentX&&h===this.currentY)return;this.currentX=e;this.currentY=h;this.isHighlightingCells&&(e=d.$getNearestNodeFromDOMNode(a.elem),null!=this.gridSelection&&null!=this.anchorCellNodeKey&&B(e)&&(e=e.getKey(),this.gridSelection=d.DEPRECATED_$createGridSelection(),this.focusCellNodeKey=e,this.gridSelection.set(this.tableNodeKey,this.anchorCellNodeKey,
23
+ this.focusCellNodeKey),d.$setSelection(this.gridSelection),this.editor.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0),M(this.grid,this.gridSelection)))})}setAnchorCellForSelection(a){this.editor.update(()=>{if(this.anchorCell===a&&this.isHighlightingCells){var b=I?window.getSelection():null;b&&b.setBaseAndExtent(a.elem,0,a.elem,0)}this.anchorCell=a;this.startX=a.x;this.startY=a.y;b=d.$getNearestNodeFromDOMNode(a.elem);B(b)&&(b=b.getKey(),this.gridSelection=d.DEPRECATED_$createGridSelection(),
24
+ this.anchorCellNodeKey=b)})}formatCells(a){this.editor.update(()=>{let b=d.$getSelection();d.DEPRECATED_$isGridSelection(b)||H(11);let e=d.$createRangeSelection(),h=e.anchor,c=e.focus;b.getNodes().forEach(l=>{B(l)&&0!==l.getTextContentSize()&&(h.set(l.getKey(),0,"element"),c.set(l.getKey(),l.getChildrenSize(),"element"),e.formatText(a))});d.$setSelection(b);this.editor.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0)})}clearText(){this.editor.update(()=>{let a=d.$getNodeByKey(this.tableNodeKey);
25
+ if(!L(a))throw Error("Expected TableNode.");var b=d.$getSelection();d.DEPRECATED_$isGridSelection(b)||H(11);b=b.getNodes().filter(B);b.length===this.grid.columns*this.grid.rows?(a.selectPrevious(),a.remove(),d.$getRoot().selectStart()):(b.forEach(e=>{if(d.$isElementNode(e)){let h=d.$createParagraphNode(),c=d.$createTextNode();h.append(c);e.append(h);e.getChildren().forEach(l=>{l!==h&&l.remove()})}}),M(this.grid,null),d.$setSelection(null),this.editor.dispatchCommand(d.SELECTION_CHANGE_COMMAND,void 0))})}}
26
+ function N(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}
27
+ function K(a){let b=[],e={cells:b,columns:0,rows:0};var h=a.firstChild;let c=a=0;for(b.length=0;null!=h;){var l=h.nodeName;if("TD"===l||"TH"===l)l={elem:h,highlighted:!1,x:a,y:c},h._cell=l,void 0===b[c]&&(b[c]=[]),b[c][a]=l;else if(l=h.firstChild,null!=l){h=l;continue}l=h.nextSibling;if(null!=l)a++,h=l;else if(l=h.parentNode,null!=l){h=l.nextSibling;if(null==h)break;c++;a=0}}e.columns=a+1;e.rows=c+1;return e}
28
+ function M(a,b){let e=[],h=new Set(b?b.getNodes():[]);O(a,(c,l)=>{let p=c.elem;h.has(l)?(c.highlighted=!0,p.style.setProperty("background-color","rgb(172, 206, 247)"),p.style.setProperty("caret-color","transparent"),e.push(c)):(c.highlighted=!1,p.style.removeProperty("background-color"),p.style.removeProperty("caret-color"),p.getAttribute("style")||p.removeAttribute("style"))});return e}
29
+ function O(a,b){({cells:a}=a);for(let e=0;e<a.length;e++){let h=a[e];for(let c=0;c<h.length;c++){let l=h[c],p=d.$getNearestNodeFromDOMNode(l.elem);null!==p&&b(l,p,{x:c,y:e})}}}function P(a){a.disableHighlightStyle();O(a.grid,b=>{let e=b.elem;b.highlighted=!0;e.style.setProperty("background-color","rgb(172, 206, 247)");e.style.setProperty("caret-color","transparent")})}
30
+ function aa(a){a.enableHighlightStyle();O(a.grid,b=>{let e=b.elem;b.highlighted=!1;e.style.removeProperty("background-color");e.style.removeProperty("caret-color");e.getAttribute("style")||e.removeAttribute("style")})}
31
+ let R=(a,b,e,h,c)=>{const l="forward"===c;switch(c){case "backward":case "forward":return e!==(l?a.grid.columns-1:0)?Q(b.getCellNodeFromCordsOrThrow(e+(l?1:-1),h,a.grid)):h!==(l?a.grid.rows-1:0)?Q(b.getCellNodeFromCordsOrThrow(l?0:a.grid.columns-1,h+(l?1:-1),a.grid)):l?b.selectNext():b.selectPrevious(),!0;case "up":return 0!==h?Q(b.getCellNodeFromCordsOrThrow(e,h-1,a.grid)):b.selectPrevious(),!0;case "down":return h!==a.grid.rows-1?Q(b.getCellNodeFromCordsOrThrow(e,h+1,a.grid)):b.selectNext(),!0;
32
+ default:return!1}},S=(a,b,e,h,c)=>{const l="forward"===c;switch(c){case "backward":case "forward":return e!==(l?a.grid.columns-1:0)&&a.adjustFocusCellForSelection(b.getCellFromCordsOrThrow(e+(l?1:-1),h,a.grid)),!0;case "up":return 0!==h?(a.adjustFocusCellForSelection(b.getCellFromCordsOrThrow(e,h-1,a.grid)),!0):!1;case "down":return h!==a.grid.rows-1?(a.adjustFocusCellForSelection(b.getCellFromCordsOrThrow(e,h+1,a.grid)),!0):!1;default:return!1}};
33
+ function T(a,b){if(d.$isRangeSelection(a)||d.DEPRECATED_$isGridSelection(a)){let e=b.isParentOf(a.anchor.getNode());a=b.isParentOf(a.focus.getNode());return e&&a}return!1}function Q(a){let b=a.getChildren().find(e=>d.$isParagraphNode(e));d.$isParagraphNode(b)?b.selectEnd():a.selectEnd()}
34
+ class U extends d.DEPRECATED_GridNode{static getType(){return"table"}static clone(a){return new U(a.__key)}static importDOM(){return{table:()=>({conversion:ba,priority:1})}}static importJSON(){return V()}constructor(a){super(a)}exportJSON(){return{...super.exportJSON(),type:"table",version:1}}createDOM(a){let b=document.createElement("table");n.addClassNamesToElement(b,a.theme.table);return b}updateDOM(){return!1}exportDOM(a){return{...super.exportDOM(a),after:b=>{if(b){let e=b.cloneNode(),h=document.createElement("colgroup"),
35
+ c=document.createElement("tbody");c.append(...b.children);b=this.getFirstChildOrThrow();if(!F(b))throw Error("Expected to find row node.");b=b.getChildrenSize();for(let l=0;l<b;l++){let p=document.createElement("col");h.append(p)}e.replaceChildren(h,c);return e}}}}canExtractContents(){return!1}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(a,b){let {rows:e,cells:h}=b;for(b=0;b<e;b++){var c=h[b];if(null==c)throw Error(`Row not found at y:${b}`);c=c.findIndex(({elem:l})=>d.$getNearestNodeFromDOMNode(l)===
36
+ a);if(-1!==c)return{x:c,y:b}}throw Error("Cell not found in table.");}getCellFromCords(a,b,e){({cells:e}=e);b=e[b];if(null==b)return null;a=b[a];return null==a?null:a}getCellFromCordsOrThrow(a,b,e){a=this.getCellFromCords(a,b,e);if(!a)throw Error("Cell not found at cords.");return a}getCellNodeFromCords(a,b,e){a=this.getCellFromCords(a,b,e);if(null==a)return null;a=d.$getNearestNodeFromDOMNode(a.elem);return B(a)?a:null}getCellNodeFromCordsOrThrow(a,b,e){a=this.getCellNodeFromCords(a,b,e);if(!a)throw Error("Node at cords not TableCellNode.");
37
+ return a}canSelectBefore(){return!0}canIndent(){return!1}}function ba(){return{node:V()}}function V(){return new U}function L(a){return a instanceof U}function W(a){a=n.$findMatchingParent(a,b=>F(b));if(F(a))return a;throw Error("Expected table cell to be inside of table row.");}function X(a){a=n.$findMatchingParent(a,b=>L(b));if(L(a))return a;throw Error("Expected table cell to be inside of table.");}
38
+ function Z(a,b){let e=X(a),{x:h,y:c}=e.getCordsFromCellNode(a,b);return{above:e.getCellNodeFromCords(h,c-1,b),below:e.getCellNodeFromCords(h,c+1,b),left:e.getCellNodeFromCords(h-1,c,b),right:e.getCellNodeFromCords(h+1,c,b)}}let ca=d.createCommand("INSERT_TABLE_COMMAND");exports.$createTableCellNode=z;exports.$createTableNode=V;
39
+ exports.$createTableNodeWithDimensions=function(a,b,e=!0){let h=V();for(let l=0;l<a;l++){let p=E();for(let u=0;u<b;u++){var c=q.NO_STATUS;e&&(0===l&&(c|=q.ROW),0===u&&(c|=q.COLUMN));c=z(c);let v=d.$createParagraphNode();v.append(d.$createTextNode());c.append(v);p.append(c)}h.append(p)}return h};exports.$createTableRowNode=E;
40
+ exports.$deleteTableColumn=function(a,b){let e=a.getChildren();for(let c=0;c<e.length;c++){var h=e[c];if(F(h)){h=h.getChildren();if(b>=h.length||0>b)throw Error("Table column target index out of range");h[b].remove()}}return a};exports.$getElementGridForTableNode=function(a,b){a=a.getElementByKey(b.getKey());if(null==a)throw Error("Table Element Not Found");return K(a)};exports.$getTableCellNodeFromLexicalNode=function(a){a=n.$findMatchingParent(a,b=>B(b));return B(a)?a:null};
41
+ exports.$getTableColumnIndexFromTableCellNode=function(a){return W(a).getChildren().findIndex(b=>b.is(a))};exports.$getTableNodeFromLexicalNodeOrThrow=X;exports.$getTableRowIndexFromTableCellNode=function(a){let b=W(a);return X(b).getChildren().findIndex(e=>e.is(b))};exports.$getTableRowNodeFromTableCellNodeOrThrow=W;
42
+ exports.$insertTableColumn=function(a,b,e=!0,h,c){let l=a.getChildren();for(let v=0;v<l.length;v++){let A=l[v];if(F(A))for(let y=0;y<h;y++){var p=A.getChildren();if(b>=p.length||0>b)throw Error("Table column target index out of range");p=p[b];B(p)||H(12);let {left:g,right:f}=Z(p,c);var u=q.NO_STATUS;if(g&&g.hasHeaderState(q.ROW)||f&&f.hasHeaderState(q.ROW))u|=q.ROW;u=z(u);u.append(d.$createParagraphNode());e?p.insertAfter(u):p.insertBefore(u)}}return a};
43
+ exports.$insertTableRow=function(a,b,e=!0,h,c){var l=a.getChildren();if(b>=l.length||0>b)throw Error("Table row target index out of range");b=l[b];if(F(b))for(l=0;l<h;l++){let u=b.getChildren(),v=u.length,A=E();for(let y=0;y<v;y++){var p=u[y];B(p)||H(12);let {above:g,below:f}=Z(p,c);p=q.NO_STATUS;let k=g&&g.getWidth()||f&&f.getWidth()||void 0;if(g&&g.hasHeaderState(q.COLUMN)||f&&f.hasHeaderState(q.COLUMN))p|=q.COLUMN;p=z(p,1,k);p.append(d.$createParagraphNode());A.append(p)}e?b.insertAfter(A):b.insertBefore(A)}else throw Error("Row before insertion index does not exist.");
44
+ return a};exports.$isTableCellNode=B;exports.$isTableNode=L;exports.$isTableRowNode=F;exports.$removeTableRowAtIndex=function(a,b){let e=a.getChildren();if(b>=e.length||0>b)throw Error("Expected table cell to be inside of table row.");e[b].remove();return a};exports.INSERT_TABLE_COMMAND=ca;exports.TableCellHeaderStates=q;exports.TableCellNode=t;exports.TableNode=U;exports.TableRowNode=C;exports.TableSelection=J;
45
+ exports.applyTableHandlers=function(a,b,e){let h=e.getRootElement();if(null===h)throw Error("No root element.");let c=new J(e,a.getKey());b.__lexicalTableSelection=c;let l=!1,p=!1;b.addEventListener("dblclick",g=>{let f=N(g.target);null!==f&&(g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),c.setAnchorCellForSelection(f),c.adjustFocusCellForSelection(f,!0),l=!1)});b.addEventListener("mousedown",g=>{setTimeout(()=>{if(0===g.button){var f=N(g.target);null!==f&&(g.preventDefault(),
46
+ g.stopPropagation(),g.stopImmediatePropagation(),c.setAnchorCellForSelection(f))}},0)});b.addEventListener("mousemove",g=>{p&&(g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation());if(l){let f=N(g.target);if(null!==f){let k=f.x,m=f.y;l&&(c.startX!==k||c.startY!==m||c.isHighlightingCells)&&(g.preventDefault(),l=!0,c.adjustFocusCellForSelection(f))}}});b.addEventListener("mouseleave",()=>{});let u=g=>{l=!0;0===g.button&&e.update(()=>{const f=d.$getSelection();if(d.DEPRECATED_$isGridSelection(f)&&
47
+ f.gridKey===c.tableNodeKey&&h.contains(g.target))return c.clearHighlight()})};window.addEventListener("mousedown",u);c.listenersToRemove.add(()=>window.removeEventListener("mousedown",u));let v=g=>{l&&(g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation(),l=!1)};window.addEventListener("mouseup",v);c.listenersToRemove.add(()=>window.removeEventListener("mouseup",v));c.listenersToRemove.add(()=>b.addEventListener("mouseup",v));c.listenersToRemove.add(()=>b.removeEventListener("mouseup",
48
+ v));c.listenersToRemove.add(e.registerCommand(d.KEY_ARROW_DOWN_COMMAND,g=>{var f=d.$getSelection();if(!T(f,a))return!1;if(d.$isRangeSelection(f)){if(f.isCollapsed()){var k=n.$findMatchingParent(f.anchor.getNode(),r=>B(r));if(!B(k))return!1;var m=a.getCordsFromCellNode(k,c.grid);f=n.$findMatchingParent(f.anchor.getNode(),r=>d.$isElementNode(r));if(null==f)throw Error("Expected BlockNode Parent");if((k=k.getLastChild())&&f.isParentOf(k)||f===k||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),
49
+ g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(m.x,m.y,c.grid)),S(c,a,m.x,m.y,"down")):R(c,a,m.x,m.y,"down")}}else if(d.DEPRECATED_$isGridSelection(f)&&g.shiftKey){m=f.focus.getNode();if(!B(m))return!1;m=a.getCordsFromCellNode(m,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return S(c,a,m.x,m.y,"down")}return!1},d.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(e.registerCommand(d.KEY_ARROW_UP_COMMAND,g=>{var f=d.$getSelection();
50
+ if(!T(f,a))return!1;if(d.$isRangeSelection(f)){if(f.isCollapsed()){var k=n.$findMatchingParent(f.anchor.getNode(),r=>B(r));if(!B(k))return!1;var m=a.getCordsFromCellNode(k,c.grid);f=n.$findMatchingParent(f.anchor.getNode(),r=>d.$isElementNode(r));if(null==f)throw Error("Expected BlockNode Parent");if((k=k.getLastChild())&&f.isParentOf(k)||f===k||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(m.x,
51
+ m.y,c.grid)),S(c,a,m.x,m.y,"up")):R(c,a,m.x,m.y,"up")}}else if(d.DEPRECATED_$isGridSelection(f)&&g.shiftKey){m=f.focus.getNode();if(!B(m))return!1;m=a.getCordsFromCellNode(m,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return S(c,a,m.x,m.y,"up")}return!1},d.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(e.registerCommand(d.KEY_ARROW_LEFT_COMMAND,g=>{var f=d.$getSelection();if(!T(f,a))return!1;if(d.$isRangeSelection(f)){if(f.isCollapsed()){var k=n.$findMatchingParent(f.anchor.getNode(),
52
+ m=>B(m));if(!B(k))return!1;k=a.getCordsFromCellNode(k,c.grid);if(null==n.$findMatchingParent(f.anchor.getNode(),m=>d.$isElementNode(m)))throw Error("Expected BlockNode Parent");if(0===f.anchor.offset||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(k.x,k.y,c.grid)),S(c,a,k.x,k.y,"backward")):R(c,a,k.x,k.y,"backward")}}else if(d.DEPRECATED_$isGridSelection(f)&&g.shiftKey){f=f.focus.getNode();if(!B(f))return!1;
53
+ f=a.getCordsFromCellNode(f,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return S(c,a,f.x,f.y,"backward")}return!1},d.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(e.registerCommand(d.KEY_ARROW_RIGHT_COMMAND,g=>{var f=d.$getSelection();if(!T(f,a))return!1;if(d.$isRangeSelection(f)){if(f.isCollapsed()){var k=n.$findMatchingParent(f.anchor.getNode(),m=>B(m));if(!B(k))return!1;k=a.getCordsFromCellNode(k,c.grid);if(null==n.$findMatchingParent(f.anchor.getNode(),m=>d.$isElementNode(m)))throw Error("Expected BlockNode Parent");
54
+ if(f.anchor.offset===f.anchor.getNode().getTextContentSize()||g.shiftKey)return g.preventDefault(),g.stopImmediatePropagation(),g.stopPropagation(),g.shiftKey?(c.setAnchorCellForSelection(a.getCellFromCordsOrThrow(k.x,k.y,c.grid)),S(c,a,k.x,k.y,"forward")):R(c,a,k.x,k.y,"forward")}}else if(d.DEPRECATED_$isGridSelection(f)&&g.shiftKey){f=f.focus.getNode();if(!B(f))return!1;f=a.getCordsFromCellNode(f,c.grid);g.preventDefault();g.stopImmediatePropagation();g.stopPropagation();return S(c,a,f.x,f.y,"forward")}return!1},
55
+ d.COMMAND_PRIORITY_HIGH));let A=g=>()=>{const f=d.$getSelection();if(!T(f,a))return!1;if(d.DEPRECATED_$isGridSelection(f))return c.clearText(),!0;if(d.$isRangeSelection(f)){const r=n.$findMatchingParent(f.anchor.getNode(),w=>B(w));if(!B(r))return!1;var k=f.anchor.getNode(),m=f.focus.getNode();k=a.isParentOf(k);m=a.isParentOf(m);if(k&&!m||m&&!k)return c.clearText(),!0;m=n.$findMatchingParent(f.anchor.getNode(),w=>d.$isElementNode(w)&&B(w.getParent()));k=n.$findMatchingParent(f.anchor.getNode(),w=>
56
+ d.$isElementNode(w));if(!d.$isElementNode(m)||!d.$isElementNode(k))return!1;const G=()=>{const w=d.$createParagraphNode(),da=d.$createTextNode();w.append(da);r.append(w);r.getChildren().forEach(Y=>{Y!==w&&Y.remove()})};if(g===d.DELETE_LINE_COMMAND&&null===m.getPreviousSibling())return G(),!0;if(g===d.DELETE_CHARACTER_COMMAND||g===d.DELETE_WORD_COMMAND){if(f.isCollapsed()&&0===f.anchor.offset&&m===k&&null===m.getPreviousSibling())return!0;if(!d.$isParagraphNode(m)&&0===m.getTextContentSize())return G(),
57
+ !0}}return!1};[d.DELETE_WORD_COMMAND,d.DELETE_LINE_COMMAND,d.DELETE_CHARACTER_COMMAND].forEach(g=>{c.listenersToRemove.add(e.registerCommand(g,A(g),d.COMMAND_PRIORITY_CRITICAL))});let y=g=>{const f=d.$getSelection();if(!T(f,a))return!1;if(d.DEPRECATED_$isGridSelection(f))return g.preventDefault(),g.stopPropagation(),c.clearText(),!0;d.$isRangeSelection(f)&&(g=n.$findMatchingParent(f.anchor.getNode(),k=>B(k)),B(g));return!1};c.listenersToRemove.add(e.registerCommand(d.KEY_BACKSPACE_COMMAND,y,d.COMMAND_PRIORITY_CRITICAL));
58
+ c.listenersToRemove.add(e.registerCommand(d.KEY_DELETE_COMMAND,y,d.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(e.registerCommand(d.FORMAT_TEXT_COMMAND,g=>{let f=d.$getSelection();if(!T(f,a))return!1;if(d.DEPRECATED_$isGridSelection(f))return c.formatCells(g),!0;d.$isRangeSelection(f)&&(g=n.$findMatchingParent(f.anchor.getNode(),k=>B(k)),B(g));return!1},d.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(e.registerCommand(d.CONTROLLED_TEXT_INSERTION_COMMAND,()=>{var g=d.$getSelection();if(!T(g,
59
+ a))return!1;d.DEPRECATED_$isGridSelection(g)?c.clearHighlight():d.$isRangeSelection(g)&&(g=n.$findMatchingParent(g.anchor.getNode(),f=>B(f)),B(g));return!1},d.COMMAND_PRIORITY_CRITICAL));c.listenersToRemove.add(e.registerCommand(d.KEY_TAB_COMMAND,g=>{var f=d.$getSelection();if(!T(f,a))return!1;if(d.$isRangeSelection(f)){let k=n.$findMatchingParent(f.anchor.getNode(),m=>B(m));if(!B(k))return!1;if(f.isCollapsed())return f=a.getCordsFromCellNode(k,c.grid),g.preventDefault(),R(c,a,f.x,f.y,g.shiftKey?
60
+ "backward":"forward"),!0}return!1},d.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(e.registerCommand(d.FOCUS_COMMAND,()=>a.isSelected(),d.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>{let g=d.$getSelection();var f=d.$getPreviousSelection();if(g&&d.$isRangeSelection(g)&&!g.isCollapsed()){var k=g.anchor.getNode(),m=g.focus.getNode();k=a.isParentOf(k);var r=a.isParentOf(m);m=k&&!r||r&&!k;k=k&&r&&!a.isSelected();if(m)return f=g.isBackward(),k=d.$createRangeSelection(),
61
+ m=a.getKey(),k.anchor.set(g.anchor.key,g.anchor.offset,g.anchor.type),k.focus.set(m,f?0:a.getChildrenSize(),"element"),p=!0,d.$setSelection(k),P(c),!0;if(k&&({grid:k}=c,g.getNodes().filter(B).length===k.rows*k.columns)){k=d.DEPRECATED_$createGridSelection();m=a.getKey();r=a.getFirstChildOrThrow().getFirstChild();let G=a.getLastChildOrThrow().getLastChild();if(null!=r&&null!=G)return k.set(m,r.getKey(),G.getKey()),d.$setSelection(k),c.updateTableGridSelection(k),!0}}if(g&&!g.is(f)&&(d.DEPRECATED_$isGridSelection(g)||
62
+ d.DEPRECATED_$isGridSelection(f))&&c.gridSelection&&!c.gridSelection.is(f))return d.DEPRECATED_$isGridSelection(g)&&g.gridKey===c.tableNodeKey?c.updateTableGridSelection(g):!d.DEPRECATED_$isGridSelection(g)&&d.DEPRECATED_$isGridSelection(f)&&f.gridKey===c.tableNodeKey&&c.updateTableGridSelection(null),!1;c.hasHijackedSelectionStyles&&!a.isSelected()?(aa(c),p=!1):!c.hasHijackedSelectionStyles&&a.isSelected()&&P(c);return!1},d.COMMAND_PRIORITY_CRITICAL));return c};exports.getCellFromTarget=N;
63
+ exports.getTableSelectionFromTableElement=function(a){return a.__lexicalTableSelection}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedGridCellNode, Spread } from 'lexical';
9
- import { GridCellNode } from 'lexical';
9
+ import { DEPRECATED_GridCellNode } from 'lexical';
10
10
  export declare const TableCellHeaderStates: {
11
11
  BOTH: number;
12
12
  COLUMN: number;
@@ -20,7 +20,7 @@ export declare type SerializedTableCellNode = Spread<{
20
20
  width?: number;
21
21
  }, SerializedGridCellNode>;
22
22
  /** @noInheritDoc */
23
- export declare class TableCellNode extends GridCellNode {
23
+ export declare class TableCellNode extends DEPRECATED_GridCellNode {
24
24
  /** @internal */
25
25
  __headerState: TableCellHeaderState;
26
26
  /** @internal */
@@ -42,6 +42,7 @@ export declare class TableCellNode extends GridCellNode {
42
42
  hasHeaderState(headerState: TableCellHeaderState): boolean;
43
43
  hasHeader(): boolean;
44
44
  updateDOM(prevNode: TableCellNode): boolean;
45
+ isShadowRoot(): boolean;
45
46
  collapseAtStart(): true;
46
47
  canBeEmpty(): false;
47
48
  canIndent(): false;
@@ -8,13 +8,13 @@
8
8
  import type { TableCellNode } from './LexicalTableCellNode';
9
9
  import type { Cell, Grid } from './LexicalTableSelection';
10
10
  import type { DOMConversionMap, DOMConversionOutput, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
11
- import { GridNode } from 'lexical';
11
+ import { DEPRECATED_GridNode } from 'lexical';
12
12
  export declare type SerializedTableNode = Spread<{
13
13
  type: 'table';
14
14
  version: 1;
15
15
  }, SerializedElementNode>;
16
16
  /** @noInheritDoc */
17
- export declare class TableNode extends GridNode {
17
+ export declare class TableNode extends DEPRECATED_GridNode {
18
18
  /** @internal */
19
19
  __grid?: Grid;
20
20
  static getType(): 'table';
@@ -28,6 +28,7 @@ export declare class TableNode extends GridNode {
28
28
  exportDOM(editor: LexicalEditor): DOMExportOutput;
29
29
  canExtractContents(): false;
30
30
  canBeEmpty(): false;
31
+ isShadowRoot(): boolean;
31
32
  getCordsFromCellNode(tableCellNode: TableCellNode, grid: Grid): {
32
33
  x: number;
33
34
  y: number;
@@ -6,14 +6,14 @@
6
6
  *
7
7
  */
8
8
  import type { Spread } from 'lexical';
9
- import { DOMConversionMap, DOMConversionOutput, EditorConfig, GridRowNode, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
9
+ import { DEPRECATED_GridRowNode, DOMConversionMap, DOMConversionOutput, EditorConfig, LexicalNode, NodeKey, SerializedElementNode } from 'lexical';
10
10
  export declare type SerializedTableRowNode = Spread<{
11
11
  height: number;
12
12
  type: 'tablerow';
13
13
  version: 1;
14
14
  }, SerializedElementNode>;
15
15
  /** @noInheritDoc */
16
- export declare class TableRowNode extends GridRowNode {
16
+ export declare class TableRowNode extends DEPRECATED_GridRowNode {
17
17
  /** @internal */
18
18
  __height?: number;
19
19
  static getType(): 'tablerow';
@@ -23,6 +23,7 @@ export declare class TableRowNode extends GridRowNode {
23
23
  constructor(height?: number, key?: NodeKey);
24
24
  exportJSON(): SerializedElementNode;
25
25
  createDOM(config: EditorConfig): HTMLElement;
26
+ isShadowRoot(): boolean;
26
27
  setHeight(height: number): number | null | undefined;
27
28
  getHeight(): number | null | undefined;
28
29
  updateDOM(prevNode: TableRowNode): boolean;
@@ -25,5 +25,5 @@ export declare type TableCellSiblings = {
25
25
  export declare function $getTableCellSiblingsFromTableCellNode(tableCellNode: TableCellNode, grid: Grid): TableCellSiblings;
26
26
  export declare function $removeTableRowAtIndex(tableNode: TableNode, indexToDelete: number): TableNode;
27
27
  export declare function $insertTableRow(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, rowCount: number, grid: Grid): TableNode;
28
- export declare function $insertTableColumn(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, columnCount: number): TableNode;
28
+ export declare function $insertTableColumn(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, columnCount: number, grid: Grid): TableNode;
29
29
  export declare function $deleteTableColumn(tableNode: TableNode, targetIndex: number): TableNode;
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "table"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.4.1",
11
+ "version": "0.5.1-next.0",
12
12
  "main": "LexicalTable.js",
13
13
  "peerDependencies": {
14
- "lexical": "0.4.1"
14
+ "lexical": "0.5.1-next.0"
15
15
  },
16
16
  "dependencies": {
17
- "@lexical/utils": "0.4.1"
17
+ "@lexical/utils": "0.5.1-next.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
package/utils.d.ts DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import type { Grid } from './LexicalTableSelection';
9
- import type { LexicalNode } from 'lexical';
10
- import { TableCellNode } from './LexicalTableCellNode';
11
- import { TableNode } from './LexicalTableNode';
12
- import { TableRowNode } from './LexicalTableRowNode';
13
- export declare function $createTableNodeWithDimensions(rowCount: number, columnCount: number, includeHeaders?: boolean): TableNode;
14
- export declare function $getTableCellNodeFromLexicalNode(startingNode: LexicalNode): TableCellNode | null;
15
- export declare function $getTableRowNodeFromTableCellNodeOrThrow(startingNode: LexicalNode): TableRowNode;
16
- export declare function $getTableNodeFromLexicalNodeOrThrow(startingNode: LexicalNode): TableNode;
17
- export declare function $getTableRowIndexFromTableCellNode(tableCellNode: TableCellNode): number;
18
- export declare function $getTableColumnIndexFromTableCellNode(tableCellNode: TableCellNode): number;
19
- export declare type TableCellSiblings = {
20
- above: TableCellNode | null | undefined;
21
- below: TableCellNode | null | undefined;
22
- left: TableCellNode | null | undefined;
23
- right: TableCellNode | null | undefined;
24
- };
25
- export declare function $getTableCellSiblingsFromTableCellNode(tableCellNode: TableCellNode, grid: Grid): TableCellSiblings;
26
- export declare function $removeTableRowAtIndex(tableNode: TableNode, indexToDelete: number): TableNode;
27
- export declare function $insertTableRow(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, rowCount: number, grid: Grid): TableNode;
28
- export declare function $insertTableColumn(tableNode: TableNode, targetIndex: number, shouldInsertAfter: boolean | undefined, columnCount: number): TableNode;
29
- export declare function $deleteTableColumn(tableNode: TableNode, targetIndex: number): TableNode;