From 4840dd510de1427515324826c93333070ca15369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Wed, 25 Mar 2026 14:45:00 +0400 Subject: [PATCH] Select all column / row cells on menu trigger click MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- packages/ui/src/RichEditor/TableColumnMenu.tsx | 18 ++++++++++++++++++ packages/ui/src/RichEditor/TableRowMenu.tsx | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/packages/ui/src/RichEditor/TableColumnMenu.tsx b/packages/ui/src/RichEditor/TableColumnMenu.tsx index 4b1dc58c8..8d7f398a4 100644 --- a/packages/ui/src/RichEditor/TableColumnMenu.tsx +++ b/packages/ui/src/RichEditor/TableColumnMenu.tsx @@ -423,6 +423,24 @@ export function TableColumnMenu({ editor }: TableColumnMenuProps) { // table may have changed } } else { + try { + const table = editor.state.doc.nodeAt(tableStart - 1); + if (table) { + const map = TableMap.get(table); + const anchorPos + = map.positionAt(0, fromCol, table) + tableStart; + const headPos + = map.positionAt(map.height - 1, fromCol, table) + tableStart; + const sel = CellSelection.create( + view.state.doc, + anchorPos, + headPos, + ); + view.dispatch(view.state.tr.setSelection(sel)); + } + } catch { + // table may have changed + } setMenuOpen(prev => !prev); } diff --git a/packages/ui/src/RichEditor/TableRowMenu.tsx b/packages/ui/src/RichEditor/TableRowMenu.tsx index 7659c33b5..9ddd1b433 100644 --- a/packages/ui/src/RichEditor/TableRowMenu.tsx +++ b/packages/ui/src/RichEditor/TableRowMenu.tsx @@ -419,6 +419,24 @@ export function TableRowMenu({ editor }: TableRowMenuProps) { // table may have changed } } else { + try { + const table = editor.state.doc.nodeAt(tableStart - 1); + if (table) { + const map = TableMap.get(table); + const anchorPos + = map.positionAt(fromRow, 0, table) + tableStart; + const headPos + = map.positionAt(fromRow, map.width - 1, table) + tableStart; + const sel = CellSelection.create( + view.state.doc, + anchorPos, + headPos, + ); + view.dispatch(view.state.tr.setSelection(sel)); + } + } catch { + // table may have changed + } setMenuOpen(prev => !prev); }