From a2475150d639228180ff1709954cf49f6cdc7201 Mon Sep 17 00:00:00 2001 From: Ivaylo Pavlov Date: Sat, 24 Aug 2024 15:45:12 +0300 Subject: [PATCH 1/6] Almost done --- .../plugins/TableActionMenuPlugin/index.tsx | 25 +++++++-- .../src/themes/PlaygroundEditorTheme.css | 3 ++ .../src/themes/PlaygroundEditorTheme.ts | 1 + .../lexical-table/src/LexicalTableNode.ts | 51 +++++++++++++++---- .../__tests__/unit/LexicalTableNode.test.tsx | 1 + 5 files changed, 69 insertions(+), 12 deletions(-) diff --git a/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx b/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx index eb72fd9d7dc..0796241e5e1 100644 --- a/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx +++ b/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx @@ -282,9 +282,9 @@ function TableActionMenu({ throw new Error('Expected to find tableElement in DOM'); } - const tableSelection = getTableObserverFromTableElement(tableElement); - if (tableSelection !== null) { - tableSelection.clearHighlight(); + const tableObserver = getTableObserverFromTableElement(tableElement); + if (tableObserver !== null) { + tableObserver.clearHighlight(); } tableNode.markDirty(); @@ -457,7 +457,19 @@ function TableActionMenu({ tableCell.toggleHeaderStyle(TableCellHeaderStates.COLUMN); } + clearTableSelection(); + onClose(); + }); + }, [editor, tableCellNode, clearTableSelection, onClose]); + const toggleRowStriping = useCallback(() => { + editor.update(() => { + if (tableCellNode.isAttached()) { + const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode); + if (tableNode) { + tableNode.setRowStriping(!tableNode.getRowStriping()); + } + } clearTableSelection(); onClose(); }); @@ -537,6 +549,13 @@ function TableActionMenu({ data-test-id="table-background-color"> Background color +