mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
fix(move_block): keep moved blocks in view
This commit is contained in:
parent
48613da57f
commit
be447b4139
@ -70,12 +70,21 @@ abstract class MoveBlockUpDownCommand extends Command {
|
|||||||
writer.createPositionAt(
|
writer.createPositionAt(
|
||||||
selectedBlocks[selectedBlocks.length - 1], offsets[1]));
|
selectedBlocks[selectedBlocks.length - 1], offsets[1]));
|
||||||
writer.setSelection(range);
|
writer.setSelection(range);
|
||||||
|
|
||||||
|
this.scrollToSelection();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedBlocks(selection: DocumentSelection) {
|
getSelectedBlocks(selection: DocumentSelection) {
|
||||||
return [...selection.getSelectedBlocks()];
|
return [...selection.getSelectedBlocks()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToSelection() {
|
||||||
|
// Ensure scroll happens in sync with DOM updates
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
this.editor.editing.view.scrollToTheSelection();
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class MoveBlockUpCommand extends MoveBlockUpDownCommand {
|
class MoveBlockUpCommand extends MoveBlockUpDownCommand {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user