Skip to content

Build your personal knowledge base with Trilium Notes

feat(editor/move_block): support multiple keystrokes

Elian Dorane2a089eb7ee3
diff --git a/packages/ckeditor5/src/augmentation.ts b/packages/ckeditor5/src/augmentation.ts
index c7a2a12fec..c34f07e66f 100644
--- a/packages/ckeditor5/src/augmentation.ts
+++ b/packages/ckeditor5/src/augmentation.ts
@@ -23,6 +23,8 @@ declare global {
}
}
+type Keystroke = string | string[];
+
declare module "ckeditor5" {
interface Editor {
getSelectedHtml(): string;
@@ -37,10 +39,10 @@ declare module "ckeditor5" {
enabled: boolean;
},
moveBlockUp?: {
- keystroke: string;
+ keystroke: Keystroke;
},
moveBlockDown?: {
- keystroke: string;
+ keystroke: Keystroke;
},
clipboard?: {
copy(text: string): void;
diff --git a/packages/ckeditor5/src/plugins/move_block_updown.ts b/packages/ckeditor5/src/plugins/move_block_updown.ts
index ef4f6a8ddc..580c8dbe4c 100644
--- a/packages/ckeditor5/src/plugins/move_block_updown.ts
+++ b/packages/ckeditor5/src/plugins/move_block_updown.ts
@@ -9,20 +9,21 @@ export default class MoveBlockUpDownPlugin extends Plugin {
init() {
const editor = this.editor;
editor.config.define('moveBlockUp', {
- keystroke: 'ctrl+arrowup',
+ keystroke: ['ctrl+arrowup', 'alt+arrowup'],
});
editor.config.define('moveBlockDown', {
- keystroke: 'ctrl+arrowdown',
+ keystroke: ['ctrl+arrowdown', 'alt+arrowdown'],
});
- const keystrokeUp = editor.config.get('moveBlockUp.keystroke')!;
- const keystrokeDown = editor.config.get('moveBlockDown.keystroke')!;
-
editor.commands.add('moveBlockUp', new MoveBlockUpCommand(editor));
editor.commands.add('moveBlockDown', new MoveBlockDownCommand(editor));
- editor.keystrokes.set(keystrokeUp, 'moveBlockUp');
- editor.keystrokes.set(keystrokeDown, 'moveBlockDown');
+ for (const keystroke of editor.config.get('moveBlockUp.keystroke') ?? []) {
+ editor.keystrokes.set(keystroke, 'moveBlockUp');
+ }
+ for (const keystroke of editor.config.get('moveBlockDown.keystroke') ?? []) {
+ editor.keystrokes.set(keystroke, 'moveBlockDown');
+ }
}
}