@lexical/table 0.20.1-nightly.20241112.0 → 0.20.1-nightly.20241114.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { addClassNamesToElement, $findMatchingParent, removeClassNamesFromElement, objectKlassEquals, isHTMLElement } from '@lexical/utils';
10
- import { ElementNode, $createParagraphNode, $isElementNode, $isLineBreakNode, $isTextNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $createPoint, $isParagraphNode, $normalizeSelection__EXPERIMENTAL, $getNodeByKey, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $setSelection, SELECTION_CHANGE_COMMAND, $getNearestNodeFromDOMNode, $createRangeSelection, $getRoot, KEY_ARROW_DOWN_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ESCAPE_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, COMMAND_PRIORITY_CRITICAL, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $createRangeSelectionFromDom, INSERT_PARAGRAPH_COMMAND, $isRootOrShadowRoot, $isDecoratorNode } from 'lexical';
10
+ import { ElementNode, $createParagraphNode, $isElementNode, $isLineBreakNode, $isTextNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $createPoint, $isParagraphNode, $normalizeSelection__EXPERIMENTAL, $getNodeByKey, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $getEditor, $setSelection, SELECTION_CHANGE_COMMAND, $getNearestNodeFromDOMNode, $createRangeSelection, $getRoot, KEY_ARROW_DOWN_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ESCAPE_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, COMMAND_PRIORITY_CRITICAL, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $createRangeSelectionFromDom, INSERT_PARAGRAPH_COMMAND, $isRootOrShadowRoot, $isDecoratorNode, setDOMUnmanaged } from 'lexical';
11
11
  import { copyToClipboard, $getClipboardDataFromSelection } from '@lexical/clipboard';
12
12
 
13
13
  /**
@@ -1427,6 +1427,20 @@ function $getChildrenRecursively(node) {
1427
1427
  *
1428
1428
  */
1429
1429
 
1430
+ function $getTableAndElementByKey(tableNodeKey, editor = $getEditor()) {
1431
+ const tableNode = $getNodeByKey(tableNodeKey);
1432
+ if (!$isTableNode(tableNode)) {
1433
+ throw Error(`TableObserver: Expected tableNodeKey ${tableNodeKey} to be a TableNode`);
1434
+ }
1435
+ const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNodeKey));
1436
+ if (!(tableElement !== null)) {
1437
+ throw Error(`TableObserver: Expected to find TableElement in DOM for key ${tableNodeKey}`);
1438
+ }
1439
+ return {
1440
+ tableElement,
1441
+ tableNode
1442
+ };
1443
+ }
1430
1444
  class TableObserver {
1431
1445
  constructor(editor, tableNodeKey) {
1432
1446
  this.isHighlightingCells = false;
@@ -1448,12 +1462,13 @@ class TableObserver {
1448
1462
  this.anchorCell = null;
1449
1463
  this.focusCell = null;
1450
1464
  this.hasHijackedSelectionStyles = false;
1451
- this.trackTable();
1452
1465
  this.isSelecting = false;
1466
+ this.shouldCheckSelection = false;
1453
1467
  this.abortController = new AbortController();
1454
1468
  this.listenerOptions = {
1455
1469
  signal: this.abortController.signal
1456
1470
  };
1471
+ this.trackTable();
1457
1472
  }
1458
1473
  getTable() {
1459
1474
  return this.table;
@@ -1463,9 +1478,12 @@ class TableObserver {
1463
1478
  Array.from(this.listenersToRemove).forEach(removeListener => removeListener());
1464
1479
  this.listenersToRemove.clear();
1465
1480
  }
1481
+ $lookup() {
1482
+ return $getTableAndElementByKey(this.tableNodeKey, this.editor);
1483
+ }
1466
1484
  trackTable() {
1467
1485
  const observer = new MutationObserver(records => {
1468
- this.editor.update(() => {
1486
+ this.editor.getEditorState().read(() => {
1469
1487
  let gridNeedsRedraw = false;
1470
1488
  for (let i = 0; i < records.length; i++) {
1471
1489
  const record = records[i];
@@ -1479,24 +1497,28 @@ class TableObserver {
1479
1497
  if (!gridNeedsRedraw) {
1480
1498
  return;
1481
1499
  }
1482
- const tableElement = this.editor.getElementByKey(this.tableNodeKey);
1483
- if (!tableElement) {
1484
- throw new Error('Expected to find TableElement in DOM');
1485
- }
1486
- this.table = getTable(tableElement);
1500
+ const {
1501
+ tableNode,
1502
+ tableElement
1503
+ } = this.$lookup();
1504
+ this.table = getTable(tableNode, tableElement);
1505
+ }, {
1506
+ editor: this.editor
1487
1507
  });
1488
1508
  });
1489
- this.editor.update(() => {
1490
- const tableElement = this.editor.getElementByKey(this.tableNodeKey);
1491
- if (!tableElement) {
1492
- throw new Error('Expected to find TableElement in DOM');
1493
- }
1494
- this.table = getTable(tableElement);
1509
+ this.editor.getEditorState().read(() => {
1510
+ const {
1511
+ tableNode,
1512
+ tableElement
1513
+ } = this.$lookup();
1514
+ this.table = getTable(tableNode, tableElement);
1495
1515
  observer.observe(tableElement, {
1496
1516
  attributes: true,
1497
1517
  childList: true,
1498
1518
  subtree: true
1499
1519
  });
1520
+ }, {
1521
+ editor: this.editor
1500
1522
  });
1501
1523
  }
1502
1524
  clearHighlight() {
@@ -1514,15 +1536,11 @@ class TableObserver {
1514
1536
  this.hasHijackedSelectionStyles = false;
1515
1537
  this.enableHighlightStyle();
1516
1538
  editor.update(() => {
1517
- const tableNode = $getNodeByKey(this.tableNodeKey);
1518
- if (!$isTableNode(tableNode)) {
1519
- throw new Error('Expected TableNode.');
1520
- }
1521
- const tableElement = editor.getElementByKey(this.tableNodeKey);
1522
- if (!tableElement) {
1523
- throw new Error('Expected to find TableElement in DOM');
1524
- }
1525
- const grid = getTable(tableElement);
1539
+ const {
1540
+ tableNode,
1541
+ tableElement
1542
+ } = this.$lookup();
1543
+ const grid = getTable(tableNode, tableElement);
1526
1544
  $updateDOMForSelection(editor, grid, null);
1527
1545
  $setSelection(null);
1528
1546
  editor.dispatchCommand(SELECTION_CHANGE_COMMAND, undefined);
@@ -1530,25 +1548,27 @@ class TableObserver {
1530
1548
  }
1531
1549
  enableHighlightStyle() {
1532
1550
  const editor = this.editor;
1533
- editor.update(() => {
1534
- const tableElement = editor.getElementByKey(this.tableNodeKey);
1535
- if (!tableElement) {
1536
- throw new Error('Expected to find TableElement in DOM');
1537
- }
1551
+ editor.getEditorState().read(() => {
1552
+ const {
1553
+ tableElement
1554
+ } = this.$lookup();
1538
1555
  removeClassNamesFromElement(tableElement, editor._config.theme.tableSelection);
1539
1556
  tableElement.classList.remove('disable-selection');
1540
1557
  this.hasHijackedSelectionStyles = false;
1558
+ }, {
1559
+ editor
1541
1560
  });
1542
1561
  }
1543
1562
  disableHighlightStyle() {
1544
1563
  const editor = this.editor;
1545
- editor.update(() => {
1546
- const tableElement = editor.getElementByKey(this.tableNodeKey);
1547
- if (!tableElement) {
1548
- throw new Error('Expected to find TableElement in DOM');
1549
- }
1564
+ editor.getEditorState().read(() => {
1565
+ const {
1566
+ tableElement
1567
+ } = this.$lookup();
1550
1568
  addClassNamesToElement(tableElement, editor._config.theme.tableSelection);
1551
1569
  this.hasHijackedSelectionStyles = true;
1570
+ }, {
1571
+ editor
1552
1572
  });
1553
1573
  }
1554
1574
  updateTableTableSelection(selection) {
@@ -1565,17 +1585,35 @@ class TableObserver {
1565
1585
  this.updateTableTableSelection(selection);
1566
1586
  }
1567
1587
  }
1588
+
1589
+ /**
1590
+ * @internal
1591
+ * Firefox has a strange behavior where pressing the down arrow key from
1592
+ * above the table will move the caret after the table and then lexical
1593
+ * will select the last cell instead of the first.
1594
+ * We do still want to let the browser handle caret movement but we will
1595
+ * use this property to "tag" the update so that we can recheck the
1596
+ * selection after the event is processed.
1597
+ */
1598
+ setShouldCheckSelection() {
1599
+ this.shouldCheckSelection = true;
1600
+ }
1601
+ /**
1602
+ * @internal
1603
+ */
1604
+ getAndClearShouldCheckSelection() {
1605
+ if (this.shouldCheckSelection) {
1606
+ this.shouldCheckSelection = false;
1607
+ return true;
1608
+ }
1609
+ return false;
1610
+ }
1568
1611
  setFocusCellForSelection(cell, ignoreStart = false) {
1569
1612
  const editor = this.editor;
1570
1613
  editor.update(() => {
1571
- const tableNode = $getNodeByKey(this.tableNodeKey);
1572
- if (!$isTableNode(tableNode)) {
1573
- throw new Error('Expected TableNode.');
1574
- }
1575
- const tableElement = editor.getElementByKey(this.tableNodeKey);
1576
- if (!tableElement) {
1577
- throw new Error('Expected to find TableElement in DOM');
1578
- }
1614
+ const {
1615
+ tableNode
1616
+ } = this.$lookup();
1579
1617
  const cellX = cell.x;
1580
1618
  const cellY = cell.y;
1581
1619
  this.focusCell = cell;
@@ -1700,15 +1738,26 @@ const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).g
1700
1738
  const isMouseDownOnEvent = event => {
1701
1739
  return (event.buttons & 1) === 1;
1702
1740
  };
1703
- function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
1741
+ function getTableElement(tableNode, dom) {
1742
+ if (!dom) {
1743
+ return dom;
1744
+ }
1745
+ const element = dom.nodeName === 'TABLE' ? dom : tableNode.getDOMSlot(dom).element;
1746
+ if (!(element.nodeName === 'TABLE')) {
1747
+ throw Error(`getTableElement: Expecting table in as DOM node for TableNode, not ${dom.nodeName}`);
1748
+ }
1749
+ return element;
1750
+ }
1751
+ function applyTableHandlers(tableNode, element, editor, hasTabHandler) {
1704
1752
  const rootElement = editor.getRootElement();
1705
1753
  if (rootElement === null) {
1706
1754
  throw new Error('No root element.');
1707
1755
  }
1708
1756
  const tableObserver = new TableObserver(editor, tableNode.getKey());
1709
1757
  const editorWindow = editor._window || window;
1758
+ const tableElement = getTableElement(tableNode, element);
1710
1759
  attachTableObserverToTableElement(tableElement, tableObserver);
1711
- tableObserver.listenersToRemove.add(() => deatatchTableObserverFromTableElement(tableElement, tableObserver));
1760
+ tableObserver.listenersToRemove.add(() => detatchTableObserverFromTableElement(tableElement, tableObserver));
1712
1761
  const createMouseHandlers = () => {
1713
1762
  const onMouseUp = () => {
1714
1763
  tableObserver.isSelecting = false;
@@ -2050,6 +2099,21 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
2050
2099
  tableObserver.listenersToRemove.add(editor.registerCommand(SELECTION_CHANGE_COMMAND, () => {
2051
2100
  const selection = $getSelection();
2052
2101
  const prevSelection = $getPreviousSelection();
2102
+ // If they pressed the down arrow with the selection outside of the
2103
+ // table, and then the selection ends up in the table but not in the
2104
+ // first cell, then move the selection to the first cell.
2105
+ if (tableObserver.getAndClearShouldCheckSelection() && $isRangeSelection(prevSelection) && $isRangeSelection(selection) && selection.isCollapsed()) {
2106
+ const anchor = selection.anchor.getNode();
2107
+ const firstRow = tableNode.getFirstChild();
2108
+ const anchorCell = $findCellNode(anchor);
2109
+ if (anchorCell !== null && $isTableRowNode(firstRow)) {
2110
+ const firstCell = firstRow.getFirstChild();
2111
+ if ($isTableCellNode(firstCell) && !$findMatchingParent(anchorCell, node => node.is(firstCell))) {
2112
+ firstCell.selectStart();
2113
+ return true;
2114
+ }
2115
+ }
2116
+ }
2053
2117
  if ($isRangeSelection(selection)) {
2054
2118
  const {
2055
2119
  anchor,
@@ -2153,7 +2217,7 @@ function applyTableHandlers(tableNode, tableElement, editor, hasTabHandler) {
2153
2217
  }, COMMAND_PRIORITY_CRITICAL));
2154
2218
  return tableObserver;
2155
2219
  }
2156
- function deatatchTableObserverFromTableElement(tableElement, tableObserver) {
2220
+ function detatchTableObserverFromTableElement(tableElement, tableObserver) {
2157
2221
  if (getTableObserverFromTableElement(tableElement) === tableObserver) {
2158
2222
  delete tableElement[LEXICAL_ELEMENT_KEY];
2159
2223
  }
@@ -2183,7 +2247,8 @@ function getDOMCellFromTarget(node) {
2183
2247
  }
2184
2248
  return null;
2185
2249
  }
2186
- function getTable(tableElement) {
2250
+ function getTable(tableNode, dom) {
2251
+ const tableElement = getTableElement(tableNode, dom);
2187
2252
  const domRows = [];
2188
2253
  const grid = {
2189
2254
  columns: 0,
@@ -2525,6 +2590,10 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver) {
2525
2590
  }
2526
2591
  }
2527
2592
  }
2593
+ if (direction === 'down' && $isScrollableTablesActive(editor)) {
2594
+ // Enable Firefox workaround
2595
+ tableObserver.setShouldCheckSelection();
2596
+ }
2528
2597
  return false;
2529
2598
  }
2530
2599
  if ($isRangeSelection(selection) && selection.isCollapsed()) {
@@ -2539,9 +2608,9 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver) {
2539
2608
  }
2540
2609
  const anchorCellTable = $findTableNode(anchorCellNode);
2541
2610
  if (anchorCellTable !== tableNode && anchorCellTable != null) {
2542
- const anchorCellTableElement = editor.getElementByKey(anchorCellTable.getKey());
2611
+ const anchorCellTableElement = getTableElement(anchorCellTable, editor.getElementByKey(anchorCellTable.getKey()));
2543
2612
  if (anchorCellTableElement != null) {
2544
- tableObserver.table = getTable(anchorCellTableElement);
2613
+ tableObserver.table = getTable(anchorCellTable, anchorCellTableElement);
2545
2614
  return $handleArrowKey(editor, event, direction, anchorCellTable, tableObserver);
2546
2615
  }
2547
2616
  }
@@ -2607,12 +2676,15 @@ function $handleArrowKey(editor, event, direction, tableNode, tableObserver) {
2607
2676
  const anchorCellNode = $findMatchingParent(anchor.getNode(), $isTableCellNode);
2608
2677
  const focusCellNode = $findMatchingParent(focus.getNode(), $isTableCellNode);
2609
2678
  const [tableNodeFromSelection] = selection.getNodes();
2610
- const tableElement = editor.getElementByKey(tableNodeFromSelection.getKey());
2679
+ if (!$isTableNode(tableNodeFromSelection)) {
2680
+ throw Error(`$handleArrowKey: TableSelection.getNodes()[0] expected to be TableNode`);
2681
+ }
2682
+ const tableElement = getTableElement(tableNodeFromSelection, editor.getElementByKey(tableNodeFromSelection.getKey()));
2611
2683
  if (!$isTableCellNode(anchorCellNode) || !$isTableCellNode(focusCellNode) || !$isTableNode(tableNodeFromSelection) || tableElement == null) {
2612
2684
  return false;
2613
2685
  }
2614
2686
  tableObserver.updateTableTableSelection(selection);
2615
- const grid = getTable(tableElement);
2687
+ const grid = getTable(tableNodeFromSelection, tableElement);
2616
2688
  const cordsAnchor = tableNode.getCordsFromCellNode(anchorCellNode, grid);
2617
2689
  const anchorCell = tableNode.getDOMCellFromCordsOrThrow(cordsAnchor.x, cordsAnchor.y, grid);
2618
2690
  tableObserver.setAnchorCellForSelection(anchorCell);
@@ -2708,14 +2780,21 @@ function $getTableEdgeCursorPosition(editor, selection, tableNode) {
2708
2780
  if (!tableNodeParent) {
2709
2781
  return undefined;
2710
2782
  }
2711
- const tableNodeParentDOM = editor.getElementByKey(tableNodeParent.getKey());
2712
- if (!tableNodeParentDOM) {
2713
- return undefined;
2714
- }
2715
2783
 
2716
2784
  // TODO: Add support for nested tables
2717
2785
  const domSelection = window.getSelection();
2718
- if (!domSelection || domSelection.anchorNode !== tableNodeParentDOM) {
2786
+ if (!domSelection) {
2787
+ return undefined;
2788
+ }
2789
+ const domAnchorNode = domSelection.anchorNode;
2790
+ const tableNodeParentDOM = editor.getElementByKey(tableNodeParent.getKey());
2791
+ const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));
2792
+ // We are only interested in the scenario where the
2793
+ // native selection anchor is:
2794
+ // - at or inside the table's parent DOM
2795
+ // - and NOT at or inside the table DOM
2796
+ // It may be adjacent to the table DOM (e.g. in a wrapper)
2797
+ if (!domAnchorNode || !tableNodeParentDOM || !tableElement || !tableNodeParentDOM.contains(domAnchorNode) || tableElement.contains(domAnchorNode)) {
2719
2798
  return undefined;
2720
2799
  }
2721
2800
  const anchorCellNode = $findMatchingParent(selection.anchor.getNode(), n => $isTableCellNode(n));
@@ -2777,6 +2856,20 @@ function setRowStriping(dom, config, rowStriping) {
2777
2856
  dom.removeAttribute('data-lexical-row-striping');
2778
2857
  }
2779
2858
  }
2859
+ const scrollableEditors = new WeakSet();
2860
+ function $isScrollableTablesActive(editor = $getEditor()) {
2861
+ return scrollableEditors.has(editor);
2862
+ }
2863
+ function setScrollableTablesActive(editor, active) {
2864
+ if (active) {
2865
+ if (!editor._config.theme.tableScrollableWrapper) {
2866
+ console.warn('TableNode: hasHorizontalScroll is active but theme.tableScrollableWrapper is not defined.');
2867
+ }
2868
+ scrollableEditors.add(editor);
2869
+ } else {
2870
+ scrollableEditors.delete(editor);
2871
+ }
2872
+ }
2780
2873
 
2781
2874
  /** @noInheritDoc */
2782
2875
  class TableNode extends ElementNode {
@@ -2830,15 +2923,34 @@ class TableNode extends ElementNode {
2830
2923
  version: 1
2831
2924
  };
2832
2925
  }
2926
+ getDOMSlot(element) {
2927
+ const tableElement = element.nodeName !== 'TABLE' && element.querySelector('table') || element;
2928
+ if (!(tableElement.nodeName === 'TABLE')) {
2929
+ throw Error(`TableNode.getDOMSlot: createDOM() did not return a table`);
2930
+ }
2931
+ return super.getDOMSlot(tableElement).withAfter(tableElement.querySelector('colgroup'));
2932
+ }
2833
2933
  createDOM(config, editor) {
2834
2934
  const tableElement = document.createElement('table');
2835
2935
  const colGroup = document.createElement('colgroup');
2836
2936
  tableElement.appendChild(colGroup);
2837
2937
  updateColgroup(tableElement, config, this.getColumnCount(), this.getColWidths());
2938
+ setDOMUnmanaged(colGroup);
2838
2939
  addClassNamesToElement(tableElement, config.theme.table);
2839
2940
  if (this.__rowStriping) {
2840
2941
  setRowStriping(tableElement, config, true);
2841
2942
  }
2943
+ if ($isScrollableTablesActive(editor)) {
2944
+ const wrapperElement = document.createElement('div');
2945
+ const classes = config.theme.tableScrollableWrapper;
2946
+ if (classes) {
2947
+ addClassNamesToElement(wrapperElement, classes);
2948
+ } else {
2949
+ wrapperElement.style.cssText = 'overflow-x: auto;';
2950
+ }
2951
+ wrapperElement.appendChild(tableElement);
2952
+ return wrapperElement;
2953
+ }
2842
2954
  return tableElement;
2843
2955
  }
2844
2956
  updateDOM(prevNode, dom, config) {
@@ -2852,19 +2964,20 @@ class TableNode extends ElementNode {
2852
2964
  return {
2853
2965
  ...super.exportDOM(editor),
2854
2966
  after: tableElement => {
2855
- if (tableElement) {
2856
- const newElement = tableElement.cloneNode();
2857
- const colGroup = document.createElement('colgroup');
2967
+ if (tableElement && isHTMLElement(tableElement) && tableElement.nodeName !== 'TABLE') {
2968
+ tableElement = tableElement.querySelector('table');
2969
+ }
2970
+ if (!tableElement || !isHTMLElement(tableElement)) {
2971
+ return null;
2972
+ }
2973
+ // Wrap direct descendant rows in a tbody for export
2974
+ const rows = tableElement.querySelectorAll(':scope > tr');
2975
+ if (rows.length > 0) {
2858
2976
  const tBody = document.createElement('tbody');
2859
- if (isHTMLElement(tableElement)) {
2860
- const cols = tableElement.querySelectorAll('col');
2861
- colGroup.append(...cols);
2862
- const rows = tableElement.querySelectorAll('tr');
2863
- tBody.append(...rows);
2864
- }
2865
- newElement.replaceChildren(colGroup, tBody);
2866
- return newElement;
2977
+ tBody.append(...rows);
2978
+ tableElement.append(tBody);
2867
2979
  }
2980
+ return tableElement;
2868
2981
  }
2869
2982
  };
2870
2983
  }
@@ -2971,10 +3084,10 @@ class TableNode extends ElementNode {
2971
3084
  }
2972
3085
  function $getElementForTableNode(editor, tableNode) {
2973
3086
  const tableElement = editor.getElementByKey(tableNode.getKey());
2974
- if (tableElement == null) {
2975
- throw new Error('Table Element Not Found');
3087
+ if (!(tableElement !== null)) {
3088
+ throw Error(`$getElementForTableNode: Table Element Not Found`);
2976
3089
  }
2977
- return getTable(tableElement);
3090
+ return getTable(tableNode, tableElement);
2978
3091
  }
2979
3092
  function $convertTableElement(domNode) {
2980
3093
  const tableNode = $createTableNode();
@@ -3007,4 +3120,4 @@ function $isTableNode(node) {
3007
3120
  return node instanceof TableNode;
3008
3121
  }
3009
3122
 
3010
- export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableCellNode, $createTableNode, $createTableNodeWithDimensions, $createTableRowNode, $createTableSelection, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $findCellNode, $findTableNode, $getElementForTableNode, $getNodeTriplet, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRow__EXPERIMENTAL, $isTableCellNode, $isTableNode, $isTableRowNode, $isTableSelection, $removeTableRowAtIndex, $unmergeCell, INSERT_TABLE_COMMAND, TableCellHeaderStates, TableCellNode, TableNode, TableObserver, TableRowNode, applyTableHandlers, getDOMCellFromTarget, getTableObserverFromTableElement };
3123
+ export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableCellNode, $createTableNode, $createTableNodeWithDimensions, $createTableRowNode, $createTableSelection, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $findCellNode, $findTableNode, $getElementForTableNode, $getNodeTriplet, $getTableAndElementByKey, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableRow, $insertTableRow__EXPERIMENTAL, $isScrollableTablesActive, $isTableCellNode, $isTableNode, $isTableRowNode, $isTableSelection, $removeTableRowAtIndex, $unmergeCell, INSERT_TABLE_COMMAND, TableCellHeaderStates, TableCellNode, TableNode, TableObserver, TableRowNode, applyTableHandlers, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, setScrollableTablesActive };
@@ -162,6 +162,7 @@ declare export function applyTableHandlers(
162
162
  tableNode: TableNode,
163
163
  tableElement: HTMLElement,
164
164
  editor: LexicalEditor,
165
+ hasTabHandler: boolean,
165
166
  ): TableObserver;
166
167
 
167
168
  declare export function $getElementForTableNode(
package/LexicalTable.mjs CHANGED
@@ -23,6 +23,7 @@ export const $findCellNode = mod.$findCellNode;
23
23
  export const $findTableNode = mod.$findTableNode;
24
24
  export const $getElementForTableNode = mod.$getElementForTableNode;
25
25
  export const $getNodeTriplet = mod.$getNodeTriplet;
26
+ export const $getTableAndElementByKey = mod.$getTableAndElementByKey;
26
27
  export const $getTableCellNodeFromLexicalNode = mod.$getTableCellNodeFromLexicalNode;
27
28
  export const $getTableCellNodeRect = mod.$getTableCellNodeRect;
28
29
  export const $getTableColumnIndexFromTableCellNode = mod.$getTableColumnIndexFromTableCellNode;
@@ -33,6 +34,7 @@ export const $insertTableColumn = mod.$insertTableColumn;
33
34
  export const $insertTableColumn__EXPERIMENTAL = mod.$insertTableColumn__EXPERIMENTAL;
34
35
  export const $insertTableRow = mod.$insertTableRow;
35
36
  export const $insertTableRow__EXPERIMENTAL = mod.$insertTableRow__EXPERIMENTAL;
37
+ export const $isScrollableTablesActive = mod.$isScrollableTablesActive;
36
38
  export const $isTableCellNode = mod.$isTableCellNode;
37
39
  export const $isTableNode = mod.$isTableNode;
38
40
  export const $isTableRowNode = mod.$isTableRowNode;
@@ -47,4 +49,6 @@ export const TableObserver = mod.TableObserver;
47
49
  export const TableRowNode = mod.TableRowNode;
48
50
  export const applyTableHandlers = mod.applyTableHandlers;
49
51
  export const getDOMCellFromTarget = mod.getDOMCellFromTarget;
50
- export const getTableObserverFromTableElement = mod.getTableObserverFromTableElement;
52
+ export const getTableElement = mod.getTableElement;
53
+ export const getTableObserverFromTableElement = mod.getTableObserverFromTableElement;
54
+ export const setScrollableTablesActive = mod.setScrollableTablesActive;
@@ -21,6 +21,7 @@ export const $findCellNode = mod.$findCellNode;
21
21
  export const $findTableNode = mod.$findTableNode;
22
22
  export const $getElementForTableNode = mod.$getElementForTableNode;
23
23
  export const $getNodeTriplet = mod.$getNodeTriplet;
24
+ export const $getTableAndElementByKey = mod.$getTableAndElementByKey;
24
25
  export const $getTableCellNodeFromLexicalNode = mod.$getTableCellNodeFromLexicalNode;
25
26
  export const $getTableCellNodeRect = mod.$getTableCellNodeRect;
26
27
  export const $getTableColumnIndexFromTableCellNode = mod.$getTableColumnIndexFromTableCellNode;
@@ -31,6 +32,7 @@ export const $insertTableColumn = mod.$insertTableColumn;
31
32
  export const $insertTableColumn__EXPERIMENTAL = mod.$insertTableColumn__EXPERIMENTAL;
32
33
  export const $insertTableRow = mod.$insertTableRow;
33
34
  export const $insertTableRow__EXPERIMENTAL = mod.$insertTableRow__EXPERIMENTAL;
35
+ export const $isScrollableTablesActive = mod.$isScrollableTablesActive;
34
36
  export const $isTableCellNode = mod.$isTableCellNode;
35
37
  export const $isTableNode = mod.$isTableNode;
36
38
  export const $isTableRowNode = mod.$isTableRowNode;
@@ -45,4 +47,6 @@ export const TableObserver = mod.TableObserver;
45
47
  export const TableRowNode = mod.TableRowNode;
46
48
  export const applyTableHandlers = mod.applyTableHandlers;
47
49
  export const getDOMCellFromTarget = mod.getDOMCellFromTarget;
48
- export const getTableObserverFromTableElement = mod.getTableObserverFromTableElement;
50
+ export const getTableElement = mod.getTableElement;
51
+ export const getTableObserverFromTableElement = mod.getTableObserverFromTableElement;
52
+ export const setScrollableTablesActive = mod.setScrollableTablesActive;