From ffd8987bb5932f4ca2d535d36caaa6dc89a24b75 Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Thu, 5 Jun 2025 16:54:01 +0200 Subject: [PATCH] feat(table): enable Ctrl+Shift+Up/Down to reorder rows from cell keydown handler --- src/ts/component/block/table.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ts/component/block/table.tsx b/src/ts/component/block/table.tsx index d9fc9d5ae1..2c7062cb62 100644 --- a/src/ts/component/block/table.tsx +++ b/src/ts/component/block/table.tsx @@ -786,6 +786,26 @@ const BlockTable = observer(class BlockTable extends React.Component { + e.preventDefault(); + + const dir = pressed.match('Up') ? -1 : 1; + const { rows } = this.getData(); + const idx = rows.findIndex(row => row.id === rowId); + const nextIdx = idx + dir; + + if (idx === -1 || nextIdx < 0 || nextIdx >= rows.length) return; + + const nextRow = rows[nextIdx]; + if (nextRow && !nextRow.content.isHeader) { + const position = dir < 0 ? I.BlockPosition.Top : I.BlockPosition.Bottom; + this.onSortEndRow(rowId, nextRow.id, position); + } + + ret = true; + }); + keyboard.shortcut('shift+space', e, () => { e.preventDefault(); @@ -796,7 +816,7 @@ const BlockTable = observer(class BlockTable extends React.Component