From 786f0db4bbe1369f11b103c5bcb277cc271b6889 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 27 Nov 2025 19:37:21 +0200 Subject: [PATCH] fix(ckeditor): move block interfering with normal shortcut (closes #6964) --- .../src/plugins/move_block_updown.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/ckeditor5/src/plugins/move_block_updown.ts b/packages/ckeditor5/src/plugins/move_block_updown.ts index 2c6e7dc80..5eea69537 100644 --- a/packages/ckeditor5/src/plugins/move_block_updown.ts +++ b/packages/ckeditor5/src/plugins/move_block_updown.ts @@ -2,9 +2,14 @@ * https://github.com/TriliumNext/Trilium/issues/1002 */ -import { Command, ModelDocumentSelection, ModelElement, ModelNode, Plugin, ModelRange } from 'ckeditor5'; -export default class MoveBlockUpDownPlugin extends Plugin { +import { Command, ModelDocumentSelection, ModelElement, ModelNode, Plugin, ModelRange, _isMac } from 'ckeditor5'; +const keyMap = { + ArrowUp: 'moveBlockUp', + ArrowDown: 'moveBlockDown' +}; + +export default class MoveBlockUpDownPlugin extends Plugin { init() { const editor = this.editor; @@ -21,17 +26,14 @@ export default class MoveBlockUpDownPlugin extends Plugin { const domRoot = editor.editing.view.getDomRoot(); if (!domRoot) return; + const isMac = _isMac(navigator.userAgent.toLowerCase()); const handleKeydown = (e: KeyboardEvent) => { - const keyMap = { - ArrowUp: 'moveBlockUp', - ArrowDown: 'moveBlockDown' - }; - const command = keyMap[e.key]; - const isCtrl = e.ctrlKey || e.metaKey; - const hasModifier = (isCtrl || e.altKey) && !(isCtrl && e.altKey); + if (!command) return; + const isOnlyMeta = (!e.ctrlKey && !e.altKey && e.metaKey); + const isOnlyAlt = (!e.ctrlKey && e.altKey && !e.metaKey); - if (command && hasModifier) { + if ((!isMac && isOnlyMeta) || isOnlyAlt) { e.preventDefault(); e.stopImmediatePropagation(); editor.execute(command);