1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-07 21:47:02 +09:00

feat(table): enable Ctrl+Shift+Up/Down to reorder rows from cell keydown handler

This commit is contained in:
Andrew Simachev 2025-06-05 16:54:01 +02:00
parent caf4653079
commit ffd8987bb5
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF

View file

@ -786,6 +786,26 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
let ret = false;
// Handle row reordering with Ctrl+Shift+Up/Down
keyboard.shortcut('moveSelectionUp, moveSelectionDown', e, (pressed: string) => {
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<I.BlockComp
if (!ret) {
onKeyDown(e, text, marks, range, props);
this.framesUpdate();
};
}
};
onCellKeyUp (e: any, rowId: string, columnId: string, id: string, text: string, marks: I.Mark[], range: I.TextRange, props: any) {