Skip to content

Commit

Permalink
[lexical-table] Stop selecting the whole table after pasting cells (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivailop7 committed Aug 22, 2024
1 parent 3f1f765 commit fb82331
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions packages/lexical-table/src/LexicalTableSelectionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ import {$isTableCellNode} from './LexicalTableCellNode';
import {$isTableNode} from './LexicalTableNode';
import {TableDOMTable, TableObserver} from './LexicalTableObserver';
import {$isTableRowNode} from './LexicalTableRowNode';
import {
$createTableSelection,
$isTableSelection,
} from './LexicalTableSelection';
import {$isTableSelection} from './LexicalTableSelection';
import {$computeTableMap, $getNodeTriplet} from './LexicalTableUtils';

const LEXICAL_ELEMENT_KEY = '__lexicalTableSelection';
Expand Down Expand Up @@ -672,8 +669,6 @@ export function applyTableHandlers(
const toY = Math.max(startY, stopY);
const gridRowNodes = gridNode.getChildren();
let newRowIdx = 0;
let newAnchorCellKey;
let newFocusCellKey;

for (let r = fromY; r <= toY; r++) {
const currentGridRowNode = gridRowNodes[r];
Expand Down Expand Up @@ -705,12 +700,6 @@ export function applyTableHandlers(
return false;
}

if (r === fromY && c === fromX) {
newAnchorCellKey = currentGridCellNode.getKey();
} else if (r === toY && c === toX) {
newFocusCellKey = currentGridCellNode.getKey();
}

const originalChildren = currentGridCellNode.getChildren();
newGridCellNode.getChildren().forEach((child) => {
if ($isTextNode(child)) {
Expand All @@ -727,15 +716,6 @@ export function applyTableHandlers(

newRowIdx++;
}
if (newAnchorCellKey && newFocusCellKey) {
const newTableSelection = $createTableSelection();
newTableSelection.set(
nodes[0].getKey(),
newAnchorCellKey,
newFocusCellKey,
);
$setSelection(newTableSelection);
}
return true;
},
COMMAND_PRIORITY_CRITICAL,
Expand Down

0 comments on commit fb82331

Please sign in to comment.