From 3a140d205ac9ee5d2faa3b5696047ac67bab1d01 Mon Sep 17 00:00:00 2001 From: mohammed shaheer kp <72137242+mshaheerz@users.noreply.github.com> Date: Tue, 28 Jan 2025 06:19:45 +0530 Subject: [PATCH] [lexical-playground] Bug Fix: Ensure Delete Node handles all node types (#7096) Co-authored-by: shaheerkpzaigo --- .../src/plugins/ContextMenuPlugin/index.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/lexical-playground/src/plugins/ContextMenuPlugin/index.tsx b/packages/lexical-playground/src/plugins/ContextMenuPlugin/index.tsx index d6c561b1dec..eeec5e02788 100644 --- a/packages/lexical-playground/src/plugins/ContextMenuPlugin/index.tsx +++ b/packages/lexical-playground/src/plugins/ContextMenuPlugin/index.tsx @@ -17,6 +17,8 @@ import { import { $getNearestNodeFromDOMNode, $getSelection, + $isDecoratorNode, + $isNodeSelection, $isRangeSelection, COPY_COMMAND, CUT_COMMAND, @@ -183,6 +185,13 @@ export default function ContextMenuPlugin(): JSX.Element { .at(-2); ancestorNodeWithRootAsParent?.remove(); + } else if ($isNodeSelection(selection)) { + const selectedNodes = selection.getNodes(); + selectedNodes.forEach((node) => { + if ($isDecoratorNode(node)) { + node.remove(); + } + }); } }, }),