@lexical/table 0.29.1-nightly.20250331.0 → 0.29.1-nightly.20250402.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LexicalTable.dev.js +256 -52
- package/LexicalTable.dev.mjs +259 -56
- package/LexicalTable.mjs +1 -0
- package/LexicalTable.node.mjs +1 -0
- package/LexicalTable.prod.js +1 -1
- package/LexicalTable.prod.mjs +1 -1
- package/LexicalTableUtils.d.ts +14 -0
- package/index.d.ts +1 -1
- package/package.json +4 -4
package/LexicalTable.dev.mjs
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
*/
|
8
8
|
|
9
9
|
import { addClassNamesToElement, $descendantsMatching, $findMatchingParent, removeClassNamesFromElement, objectKlassEquals, isHTMLElement as isHTMLElement$1, $insertFirst as $insertFirst$1, mergeRegister, $insertNodeToNearestRoot, $unwrapAndFilterDescendants } from '@lexical/utils';
|
10
|
-
import { ElementNode, isHTMLElement, $isInlineElementOrDecoratorNode, $isTextNode, $isLineBreakNode, $createParagraphNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $
|
10
|
+
import { ElementNode, isHTMLElement, $isInlineElementOrDecoratorNode, $isTextNode, $isLineBreakNode, $createParagraphNode, $applyNodeReplacement, createCommand, $createTextNode, $getSelection, $isRangeSelection, $isParagraphNode, $createPoint, $isElementNode, $normalizeSelection__EXPERIMENTAL, isCurrentlyReadOnlyMode, TEXT_TYPE_TO_FORMAT, $getNodeByKey, $getEditor, $setSelection, SELECTION_CHANGE_COMMAND, getDOMSelection, $createRangeSelection, $isRootNode, INSERT_PARAGRAPH_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_CRITICAL, CUT_COMMAND, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, KEY_TAB_COMMAND, FOCUS_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $getPreviousSelection, $getNearestNodeFromDOMNode, $createRangeSelectionFromDom, $isRootOrShadowRoot, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, DELETE_CHARACTER_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, isDOMNode, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isSiblingCaret, $getSiblingCaret, $setPointFromCaret, $normalizeCaret, $getAdjacentChildCaret, $isChildCaret, $getChildCaret, setDOMUnmanaged, COMMAND_PRIORITY_EDITOR, CLICK_COMMAND } from 'lexical';
|
11
11
|
import { copyToClipboard, $getClipboardDataFromSelection } from '@lexical/clipboard';
|
12
12
|
|
13
13
|
/**
|
@@ -594,17 +594,35 @@ function $insertTableRow__EXPERIMENTAL(insertAfter = true) {
|
|
594
594
|
const focus = selection.focus.getNode();
|
595
595
|
const [anchorCell] = $getNodeTriplet(anchor);
|
596
596
|
const [focusCell,, grid] = $getNodeTriplet(focus);
|
597
|
-
const [
|
598
|
-
const columnCount = gridMap[0].length;
|
597
|
+
const [, focusCellMap, anchorCellMap] = $computeTableMap(grid, focusCell, anchorCell);
|
599
598
|
const {
|
600
599
|
startRow: anchorStartRow
|
601
600
|
} = anchorCellMap;
|
602
601
|
const {
|
603
602
|
startRow: focusStartRow
|
604
603
|
} = focusCellMap;
|
604
|
+
if (insertAfter) {
|
605
|
+
return $insertTableRowAtNode(anchorStartRow + anchorCell.__rowSpan > focusStartRow + focusCell.__rowSpan ? anchorCell : focusCell, true);
|
606
|
+
} else {
|
607
|
+
return $insertTableRowAtNode(focusStartRow < anchorStartRow ? focusCell : anchorCell, false);
|
608
|
+
}
|
609
|
+
}
|
610
|
+
|
611
|
+
/**
|
612
|
+
* Inserts a table row before or after the given cell node,
|
613
|
+
* taking into account any spans. If successful, returns the
|
614
|
+
* inserted table row node.
|
615
|
+
*/
|
616
|
+
function $insertTableRowAtNode(cellNode, insertAfter = true) {
|
617
|
+
const [,, grid] = $getNodeTriplet(cellNode);
|
618
|
+
const [gridMap, cellMap] = $computeTableMap(grid, cellNode, cellNode);
|
619
|
+
const columnCount = gridMap[0].length;
|
620
|
+
const {
|
621
|
+
startRow: cellStartRow
|
622
|
+
} = cellMap;
|
605
623
|
let insertedRow = null;
|
606
624
|
if (insertAfter) {
|
607
|
-
const insertAfterEndRow =
|
625
|
+
const insertAfterEndRow = cellStartRow + cellNode.__rowSpan - 1;
|
608
626
|
const insertAfterEndRowMap = gridMap[insertAfterEndRow];
|
609
627
|
const newRow = $createTableRowNode();
|
610
628
|
for (let i = 0; i < columnCount; i++) {
|
@@ -628,7 +646,7 @@ function $insertTableRow__EXPERIMENTAL(insertAfter = true) {
|
|
628
646
|
insertAfterEndRowNode.insertAfter(newRow);
|
629
647
|
insertedRow = newRow;
|
630
648
|
} else {
|
631
|
-
const insertBeforeStartRow =
|
649
|
+
const insertBeforeStartRow = cellStartRow;
|
632
650
|
const insertBeforeStartRowMap = gridMap[insertBeforeStartRow];
|
633
651
|
const newRow = $createTableRowNode();
|
634
652
|
for (let i = 0; i < columnCount; i++) {
|
@@ -713,10 +731,33 @@ function $insertTableColumn__EXPERIMENTAL(insertAfter = true) {
|
|
713
731
|
const focus = selection.focus.getNode();
|
714
732
|
const [anchorCell] = $getNodeTriplet(anchor);
|
715
733
|
const [focusCell,, grid] = $getNodeTriplet(focus);
|
716
|
-
const [
|
734
|
+
const [, focusCellMap, anchorCellMap] = $computeTableMap(grid, focusCell, anchorCell);
|
735
|
+
const {
|
736
|
+
startColumn: anchorStartColumn
|
737
|
+
} = anchorCellMap;
|
738
|
+
const {
|
739
|
+
startColumn: focusStartColumn
|
740
|
+
} = focusCellMap;
|
741
|
+
if (insertAfter) {
|
742
|
+
return $insertTableColumnAtNode(anchorStartColumn + anchorCell.__colSpan > focusStartColumn + focusCell.__colSpan ? anchorCell : focusCell, true);
|
743
|
+
} else {
|
744
|
+
return $insertTableColumnAtNode(focusStartColumn < anchorStartColumn ? focusCell : anchorCell, false);
|
745
|
+
}
|
746
|
+
}
|
747
|
+
|
748
|
+
/**
|
749
|
+
* Inserts a column before or after the given cell node,
|
750
|
+
* taking into account any spans. If successful, returns the
|
751
|
+
* first inserted cell node.
|
752
|
+
*/
|
753
|
+
function $insertTableColumnAtNode(cellNode, insertAfter = true, shouldSetSelection = true) {
|
754
|
+
const [,, grid] = $getNodeTriplet(cellNode);
|
755
|
+
const [gridMap, cellMap] = $computeTableMap(grid, cellNode, cellNode);
|
717
756
|
const rowCount = gridMap.length;
|
718
|
-
const
|
719
|
-
|
757
|
+
const {
|
758
|
+
startColumn
|
759
|
+
} = cellMap;
|
760
|
+
const insertAfterColumn = insertAfter ? startColumn + cellNode.__colSpan - 1 : startColumn - 1;
|
720
761
|
const gridFirstChild = grid.getFirstChild();
|
721
762
|
if (!$isTableRowNode(gridFirstChild)) {
|
722
763
|
formatDevErrorMessage(`Expected firstTable child to be a row`);
|
@@ -773,7 +814,7 @@ function $insertTableColumn__EXPERIMENTAL(insertAfter = true) {
|
|
773
814
|
currentCell.setColSpan(currentCell.__colSpan + 1);
|
774
815
|
}
|
775
816
|
}
|
776
|
-
if (firstInsertedCell !== null) {
|
817
|
+
if (firstInsertedCell !== null && shouldSetSelection) {
|
777
818
|
$moveSelectionToCell(firstInsertedCell);
|
778
819
|
}
|
779
820
|
const colWidths = grid.getColWidths();
|
@@ -975,13 +1016,122 @@ function $insertFirst(parent, node) {
|
|
975
1016
|
parent.append(node);
|
976
1017
|
}
|
977
1018
|
}
|
1019
|
+
function $mergeCells(cellNodes) {
|
1020
|
+
if (cellNodes.length === 0) {
|
1021
|
+
return null;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
// Find the table node
|
1025
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(cellNodes[0]);
|
1026
|
+
const [gridMap] = $computeTableMapSkipCellCheck(tableNode, null, null);
|
1027
|
+
|
1028
|
+
// Find the boundaries of the selection including merged cells
|
1029
|
+
let minRow = Infinity;
|
1030
|
+
let maxRow = -Infinity;
|
1031
|
+
let minCol = Infinity;
|
1032
|
+
let maxCol = -Infinity;
|
1033
|
+
|
1034
|
+
// First pass: find the actual boundaries considering merged cells
|
1035
|
+
const processedCells = new Set();
|
1036
|
+
for (const row of gridMap) {
|
1037
|
+
for (const mapCell of row) {
|
1038
|
+
if (!mapCell || !mapCell.cell) {
|
1039
|
+
continue;
|
1040
|
+
}
|
1041
|
+
const cellKey = mapCell.cell.getKey();
|
1042
|
+
if (processedCells.has(cellKey)) {
|
1043
|
+
continue;
|
1044
|
+
}
|
1045
|
+
if (cellNodes.some(cell => cell.is(mapCell.cell))) {
|
1046
|
+
processedCells.add(cellKey);
|
1047
|
+
// Get the actual position of this cell in the grid
|
1048
|
+
const cellStartRow = mapCell.startRow;
|
1049
|
+
const cellStartCol = mapCell.startColumn;
|
1050
|
+
const cellRowSpan = mapCell.cell.__rowSpan || 1;
|
1051
|
+
const cellColSpan = mapCell.cell.__colSpan || 1;
|
1052
|
+
|
1053
|
+
// Update boundaries considering the cell's actual position and span
|
1054
|
+
minRow = Math.min(minRow, cellStartRow);
|
1055
|
+
maxRow = Math.max(maxRow, cellStartRow + cellRowSpan - 1);
|
1056
|
+
minCol = Math.min(minCol, cellStartCol);
|
1057
|
+
maxCol = Math.max(maxCol, cellStartCol + cellColSpan - 1);
|
1058
|
+
}
|
1059
|
+
}
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
// Validate boundaries
|
1063
|
+
if (minRow === Infinity || minCol === Infinity) {
|
1064
|
+
return null;
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
// The total span of the merged cell
|
1068
|
+
const totalRowSpan = maxRow - minRow + 1;
|
1069
|
+
const totalColSpan = maxCol - minCol + 1;
|
1070
|
+
|
1071
|
+
// Use the top-left cell as the target cell
|
1072
|
+
const targetCellMap = gridMap[minRow][minCol];
|
1073
|
+
if (!targetCellMap.cell) {
|
1074
|
+
return null;
|
1075
|
+
}
|
1076
|
+
const targetCell = targetCellMap.cell;
|
1077
|
+
|
1078
|
+
// Set the spans for the target cell
|
1079
|
+
targetCell.setColSpan(totalColSpan);
|
1080
|
+
targetCell.setRowSpan(totalRowSpan);
|
1081
|
+
|
1082
|
+
// Move content from other cells to the target cell
|
1083
|
+
const seenCells = new Set([targetCell.getKey()]);
|
1084
|
+
|
1085
|
+
// Second pass: merge content and remove other cells
|
1086
|
+
for (let row = minRow; row <= maxRow; row++) {
|
1087
|
+
for (let col = minCol; col <= maxCol; col++) {
|
1088
|
+
const mapCell = gridMap[row][col];
|
1089
|
+
if (!mapCell.cell) {
|
1090
|
+
continue;
|
1091
|
+
}
|
1092
|
+
const currentCell = mapCell.cell;
|
1093
|
+
const key = currentCell.getKey();
|
1094
|
+
if (!seenCells.has(key)) {
|
1095
|
+
seenCells.add(key);
|
1096
|
+
const isEmpty = $cellContainsEmptyParagraph(currentCell);
|
1097
|
+
if (!isEmpty) {
|
1098
|
+
targetCell.append(...currentCell.getChildren());
|
1099
|
+
}
|
1100
|
+
currentCell.remove();
|
1101
|
+
}
|
1102
|
+
}
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
// Ensure target cell has content
|
1106
|
+
if (targetCell.getChildrenSize() === 0) {
|
1107
|
+
targetCell.append($createParagraphNode());
|
1108
|
+
}
|
1109
|
+
return targetCell;
|
1110
|
+
}
|
1111
|
+
function $cellContainsEmptyParagraph(cell) {
|
1112
|
+
if (cell.getChildrenSize() !== 1) {
|
1113
|
+
return false;
|
1114
|
+
}
|
1115
|
+
const firstChild = cell.getFirstChildOrThrow();
|
1116
|
+
if (!$isParagraphNode(firstChild) || !firstChild.isEmpty()) {
|
1117
|
+
return false;
|
1118
|
+
}
|
1119
|
+
return true;
|
1120
|
+
}
|
978
1121
|
function $unmergeCell() {
|
979
1122
|
const selection = $getSelection();
|
980
1123
|
if (!($isRangeSelection(selection) || $isTableSelection(selection))) {
|
981
1124
|
formatDevErrorMessage(`Expected a RangeSelection or TableSelection`);
|
982
1125
|
}
|
983
1126
|
const anchor = selection.anchor.getNode();
|
984
|
-
const
|
1127
|
+
const cellNode = $findMatchingParent(anchor, $isTableCellNode);
|
1128
|
+
if (!$isTableCellNode(cellNode)) {
|
1129
|
+
formatDevErrorMessage(`Expected to find a parent TableCellNode`);
|
1130
|
+
}
|
1131
|
+
return $unmergeCellNode(cellNode);
|
1132
|
+
}
|
1133
|
+
function $unmergeCellNode(cellNode) {
|
1134
|
+
const [cell, row, grid] = $getNodeTriplet(cellNode);
|
985
1135
|
const colSpan = cell.__colSpan;
|
986
1136
|
const rowSpan = cell.__rowSpan;
|
987
1137
|
if (colSpan === 1 && rowSpan === 1) {
|
@@ -2283,62 +2433,115 @@ function applyTableHandlers(tableNode, element, editor, hasTabHandler) {
|
|
2283
2433
|
if (nodes.length !== 1 || !$isTableNode(nodes[0]) || !isSelectionInsideOfGrid || anchorAndFocus === null) {
|
2284
2434
|
return false;
|
2285
2435
|
}
|
2286
|
-
const [anchor] = anchorAndFocus;
|
2287
|
-
const
|
2288
|
-
const
|
2289
|
-
|
2290
|
-
const newRowCount = newGrid.getChildrenSize();
|
2291
|
-
const gridCellNode = $findMatchingParent(anchor.getNode(), n => $isTableCellNode(n));
|
2292
|
-
const gridRowNode = gridCellNode && $findMatchingParent(gridCellNode, n => $isTableRowNode(n));
|
2293
|
-
const gridNode = gridRowNode && $findMatchingParent(gridRowNode, n => $isTableNode(n));
|
2294
|
-
if (!$isTableCellNode(gridCellNode) || !$isTableRowNode(gridRowNode) || !$isTableNode(gridNode)) {
|
2436
|
+
const [anchor, focus] = anchorAndFocus;
|
2437
|
+
const [anchorCellNode, anchorRowNode, gridNode] = $getNodeTriplet(anchor);
|
2438
|
+
const focusCellNode = $findMatchingParent(focus.getNode(), n => $isTableCellNode(n));
|
2439
|
+
if (!$isTableCellNode(anchorCellNode) || !$isTableCellNode(focusCellNode) || !$isTableRowNode(anchorRowNode) || !$isTableNode(gridNode)) {
|
2295
2440
|
return false;
|
2296
2441
|
}
|
2297
|
-
const
|
2298
|
-
const
|
2299
|
-
const
|
2300
|
-
const
|
2301
|
-
const
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
let
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
const
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2442
|
+
const templateGrid = nodes[0];
|
2443
|
+
const [initialGridMap, anchorCellMap, focusCellMap] = $computeTableMap(gridNode, anchorCellNode, focusCellNode);
|
2444
|
+
const [templateGridMap] = $computeTableMapSkipCellCheck(templateGrid, null, null);
|
2445
|
+
const initialRowCount = initialGridMap.length;
|
2446
|
+
const initialColCount = initialRowCount > 0 ? initialGridMap[0].length : 0;
|
2447
|
+
|
2448
|
+
// If we have a range selection, we'll fit the template grid into the
|
2449
|
+
// table, growing the table if necessary.
|
2450
|
+
let startRow = anchorCellMap.startRow;
|
2451
|
+
let startCol = anchorCellMap.startColumn;
|
2452
|
+
let affectedRowCount = templateGridMap.length;
|
2453
|
+
let affectedColCount = affectedRowCount > 0 ? templateGridMap[0].length : 0;
|
2454
|
+
if (isTableSelection) {
|
2455
|
+
// If we have a table selection, we'll only modify the cells within
|
2456
|
+
// the selection boundary.
|
2457
|
+
const selectionBoundary = $computeTableCellRectBoundary(initialGridMap, anchorCellMap, focusCellMap);
|
2458
|
+
const selectionRowCount = selectionBoundary.maxRow - selectionBoundary.minRow + 1;
|
2459
|
+
const selectionColCount = selectionBoundary.maxColumn - selectionBoundary.minColumn + 1;
|
2460
|
+
startRow = selectionBoundary.minRow;
|
2461
|
+
startCol = selectionBoundary.minColumn;
|
2462
|
+
affectedRowCount = Math.min(affectedRowCount, selectionRowCount);
|
2463
|
+
affectedColCount = Math.min(affectedColCount, selectionColCount);
|
2464
|
+
}
|
2465
|
+
|
2466
|
+
// Step 1: Unmerge all merged cells within the affected area
|
2467
|
+
let didPerformMergeOperations = false;
|
2468
|
+
const lastRowForUnmerge = Math.min(initialRowCount, startRow + affectedRowCount) - 1;
|
2469
|
+
const lastColForUnmerge = Math.min(initialColCount, startCol + affectedColCount) - 1;
|
2470
|
+
const unmergedKeys = new Set();
|
2471
|
+
for (let row = startRow; row <= lastRowForUnmerge; row++) {
|
2472
|
+
for (let col = startCol; col <= lastColForUnmerge; col++) {
|
2473
|
+
const cellMap = initialGridMap[row][col];
|
2474
|
+
if (unmergedKeys.has(cellMap.cell.getKey())) {
|
2475
|
+
continue; // cell was a merged cell that was already handled
|
2476
|
+
}
|
2477
|
+
if (cellMap.cell.__rowSpan === 1 && cellMap.cell.__colSpan === 1) {
|
2478
|
+
continue; // cell is not a merged cell
|
2479
|
+
}
|
2480
|
+
$unmergeCellNode(cellMap.cell);
|
2481
|
+
unmergedKeys.add(cellMap.cell.getKey());
|
2482
|
+
didPerformMergeOperations = true;
|
2483
|
+
}
|
2484
|
+
}
|
2485
|
+
let [interimGridMap] = $computeTableMapSkipCellCheck(gridNode.getWritable(), null, null);
|
2486
|
+
|
2487
|
+
// Step 2: Expand current table (if needed)
|
2488
|
+
const rowsToInsert = affectedRowCount - initialRowCount + startRow;
|
2489
|
+
for (let i = 0; i < rowsToInsert; i++) {
|
2490
|
+
const cellMap = interimGridMap[initialRowCount - 1][0];
|
2491
|
+
$insertTableRowAtNode(cellMap.cell);
|
2492
|
+
}
|
2493
|
+
const colsToInsert = affectedColCount - initialColCount + startCol;
|
2494
|
+
for (let i = 0; i < colsToInsert; i++) {
|
2495
|
+
const cellMap = interimGridMap[0][initialColCount - 1];
|
2496
|
+
$insertTableColumnAtNode(cellMap.cell, true, false);
|
2497
|
+
}
|
2498
|
+
[interimGridMap] = $computeTableMapSkipCellCheck(gridNode.getWritable(), null, null);
|
2499
|
+
|
2500
|
+
// Step 3: Merge cells and set cell content, to match template grid
|
2501
|
+
for (let row = startRow; row < startRow + affectedRowCount; row++) {
|
2502
|
+
for (let col = startCol; col < startCol + affectedColCount; col++) {
|
2503
|
+
const templateRow = row - startRow;
|
2504
|
+
const templateCol = col - startCol;
|
2505
|
+
const templateCellMap = templateGridMap[templateRow][templateCol];
|
2506
|
+
if (templateCellMap.startRow !== templateRow || templateCellMap.startColumn !== templateCol) {
|
2507
|
+
continue; // cell is a merged cell that was already handled
|
2508
|
+
}
|
2509
|
+
const templateCell = templateCellMap.cell;
|
2510
|
+
if (templateCell.__rowSpan !== 1 || templateCell.__colSpan !== 1) {
|
2511
|
+
const cellsToMerge = [];
|
2512
|
+
const lastRowForMerge = Math.min(row + templateCell.__rowSpan, startRow + affectedRowCount) - 1;
|
2513
|
+
const lastColForMerge = Math.min(col + templateCell.__colSpan, startCol + affectedColCount) - 1;
|
2514
|
+
for (let r = row; r <= lastRowForMerge; r++) {
|
2515
|
+
for (let c = col; c <= lastColForMerge; c++) {
|
2516
|
+
const cellMap = interimGridMap[r][c];
|
2517
|
+
cellsToMerge.push(cellMap.cell);
|
2518
|
+
}
|
2519
|
+
}
|
2520
|
+
$mergeCells(cellsToMerge);
|
2521
|
+
didPerformMergeOperations = true;
|
2327
2522
|
}
|
2328
|
-
const
|
2329
|
-
|
2523
|
+
const {
|
2524
|
+
cell
|
2525
|
+
} = interimGridMap[row][col];
|
2526
|
+
const originalChildren = cell.getChildren();
|
2527
|
+
templateCell.getChildren().forEach(child => {
|
2330
2528
|
if ($isTextNode(child)) {
|
2331
2529
|
const paragraphNode = $createParagraphNode();
|
2332
2530
|
paragraphNode.append(child);
|
2333
|
-
|
2531
|
+
cell.append(child);
|
2334
2532
|
} else {
|
2335
|
-
|
2533
|
+
cell.append(child);
|
2336
2534
|
}
|
2337
2535
|
});
|
2338
2536
|
originalChildren.forEach(n => n.remove());
|
2339
|
-
newColumnIdx++;
|
2340
2537
|
}
|
2341
|
-
|
2538
|
+
}
|
2539
|
+
if (isTableSelection && didPerformMergeOperations) {
|
2540
|
+
// reset the table selection in case the anchor or focus cell was
|
2541
|
+
// removed via merge operations
|
2542
|
+
const [finalGridMap] = $computeTableMapSkipCellCheck(gridNode.getWritable(), null, null);
|
2543
|
+
const newAnchorCellMap = finalGridMap[anchorCellMap.startRow][anchorCellMap.startColumn];
|
2544
|
+
newAnchorCellMap.cell.selectEnd();
|
2342
2545
|
}
|
2343
2546
|
return true;
|
2344
2547
|
}, COMMAND_PRIORITY_CRITICAL));
|
@@ -3889,4 +4092,4 @@ function registerTablePlugin(editor) {
|
|
3889
4092
|
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(CLICK_COMMAND, $tableClickCommand, COMMAND_PRIORITY_EDITOR), editor.registerNodeTransform(TableNode, $tableTransform), editor.registerNodeTransform(TableRowNode, $tableRowTransform), editor.registerNodeTransform(TableCellNode, $tableCellTransform));
|
3890
4093
|
}
|
3891
4094
|
|
3892
|
-
export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableCellNode, $createTableNode, $createTableNodeWithDimensions, $createTableRowNode, $createTableSelection, $createTableSelectionFrom, $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, registerTableCellUnmergeTransform, registerTablePlugin, registerTableSelectionObserver, setScrollableTablesActive };
|
4095
|
+
export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableCellNode, $createTableNode, $createTableNodeWithDimensions, $createTableRowNode, $createTableSelection, $createTableSelectionFrom, $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, $mergeCells, $removeTableRowAtIndex, $unmergeCell, INSERT_TABLE_COMMAND, TableCellHeaderStates, TableCellNode, TableNode, TableObserver, TableRowNode, applyTableHandlers, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, registerTableCellUnmergeTransform, registerTablePlugin, registerTableSelectionObserver, setScrollableTablesActive };
|
package/LexicalTable.mjs
CHANGED
@@ -40,6 +40,7 @@ export const $isTableCellNode = mod.$isTableCellNode;
|
|
40
40
|
export const $isTableNode = mod.$isTableNode;
|
41
41
|
export const $isTableRowNode = mod.$isTableRowNode;
|
42
42
|
export const $isTableSelection = mod.$isTableSelection;
|
43
|
+
export const $mergeCells = mod.$mergeCells;
|
43
44
|
export const $removeTableRowAtIndex = mod.$removeTableRowAtIndex;
|
44
45
|
export const $unmergeCell = mod.$unmergeCell;
|
45
46
|
export const INSERT_TABLE_COMMAND = mod.INSERT_TABLE_COMMAND;
|
package/LexicalTable.node.mjs
CHANGED
@@ -38,6 +38,7 @@ export const $isTableCellNode = mod.$isTableCellNode;
|
|
38
38
|
export const $isTableNode = mod.$isTableNode;
|
39
39
|
export const $isTableRowNode = mod.$isTableRowNode;
|
40
40
|
export const $isTableSelection = mod.$isTableSelection;
|
41
|
+
export const $mergeCells = mod.$mergeCells;
|
41
42
|
export const $removeTableRowAtIndex = mod.$removeTableRowAtIndex;
|
42
43
|
export const $unmergeCell = mod.$unmergeCell;
|
43
44
|
export const INSERT_TABLE_COMMAND = mod.INSERT_TABLE_COMMAND;
|