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:
parent
caf4653079
commit
ffd8987bb5
1 changed files with 21 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue