From adaaf21b4c01dc0856a1659e4da5746249a2520d Mon Sep 17 00:00:00 2001 From: Ivaylo Pavlov Date: Mon, 17 Feb 2025 17:46:20 +0000 Subject: [PATCH] [lexical-table] Freeze top row using pure CSS (#7190) --- .../plugins/TableActionMenuPlugin/index.tsx | 20 +++++++++++ .../src/themes/PlaygroundEditorTheme.css | 28 +++++++++++++++ .../src/themes/PlaygroundEditorTheme.ts | 1 + .../lexical-table/src/LexicalTableNode.ts | 36 +++++++++++++++++++ .../__tests__/unit/LexicalTableNode.test.tsx | 1 + 5 files changed, 86 insertions(+) diff --git a/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx b/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx index 9df7c6355f5..46096a69ec6 100644 --- a/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx +++ b/packages/lexical-playground/src/plugins/TableActionMenuPlugin/index.tsx @@ -516,6 +516,19 @@ function TableActionMenu({ }); }, [editor, tableCellNode, clearTableSelection, onClose]); + const toggleFirstRowFreeze = useCallback(() => { + editor.update(() => { + if (tableCellNode.isAttached()) { + const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode); + if (tableNode) { + tableNode.setFrozenRows(tableNode.getFrozenRows() === 0 ? 1 : 0); + } + } + clearTableSelection(); + onClose(); + }); + }, [editor, tableCellNode, clearTableSelection, onClose]); + const toggleFirstColumnFreeze = useCallback(() => { editor.update(() => { if (tableCellNode.isAttached()) { @@ -670,6 +683,13 @@ function TableActionMenu({ +