From 8fb7683e9f9af53d5df405cb4b582034a87ccbae Mon Sep 17 00:00:00 2001 From: alazarev Date: Thu, 19 Dec 2024 11:29:04 +0300 Subject: [PATCH] TablePlugin: - check is current selection in target table node --- packages/lexical-table/src/LexicalTableObserver.ts | 3 --- packages/lexical-table/src/LexicalTableSelectionHelpers.ts | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/lexical-table/src/LexicalTableObserver.ts b/packages/lexical-table/src/LexicalTableObserver.ts index 2f76ce0712a..3dc2a77b1e6 100644 --- a/packages/lexical-table/src/LexicalTableObserver.ts +++ b/packages/lexical-table/src/LexicalTableObserver.ts @@ -18,7 +18,6 @@ import { $createTextNode, $getEditor, $getNodeByKey, - $getRoot, $getSelection, $isElementNode, $isParagraphNode, @@ -470,8 +469,6 @@ export class TableObserver { tableNode.selectPrevious(); // Delete entire table tableNode.remove(); - const rootNode = $getRoot(); - rootNode.selectStart(); return; } diff --git a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts index 5d010cc0bc2..970ddd17132 100644 --- a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts +++ b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts @@ -456,6 +456,10 @@ export function applyTableHandlers( return false; } + if (!$isSelectionInTable(selection, tableNode)) { + return false; + } + if ($isTableSelection(selection)) { if (event) { event.preventDefault();