From 51325e2f4a91f08519510e199673ba8c4bc045e9 Mon Sep 17 00:00:00 2001 From: perfectra1n Date: Mon, 26 Jan 2026 17:03:42 -0800 Subject: [PATCH 1/2] fix(editor): resolve strange stuck indent when a Note has images --- .../src/plugins/indent_block_shortcut.ts | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/ckeditor5/src/plugins/indent_block_shortcut.ts b/packages/ckeditor5/src/plugins/indent_block_shortcut.ts index 2e65e978c8..5fa2cf0f9e 100644 --- a/packages/ckeditor5/src/plugins/indent_block_shortcut.ts +++ b/packages/ckeditor5/src/plugins/indent_block_shortcut.ts @@ -8,21 +8,33 @@ export default class IndentBlockShortcutPlugin extends Plugin { init() { this.editor.keystrokes.set( 'Tab', ( _, cancel ) => { - const command = this.editor.commands.get( 'indentBlock' ); - - if (command && command.isEnabled && !this.isInTable() ) { - command.execute(); - cancel(); + // In tables, allow default Tab behavior for cell navigation + if (this.isInTable()) { + return; } + + const command = this.editor.commands.get( 'indentBlock' ); + if (command?.isEnabled) { + command.execute(); + } + + // Always cancel in non-table contexts to prevent widget navigation + cancel(); } ); this.editor.keystrokes.set( 'Shift+Tab', ( _, cancel ) => { - const command = this.editor.commands.get( 'outdentBlock' ); - - if (command && command.isEnabled && !this.isInTable() ) { - command.execute(); - cancel(); + // In tables, allow default Shift+Tab behavior for cell navigation + if (this.isInTable()) { + return; } + + const command = this.editor.commands.get( 'outdentBlock' ); + if (command?.isEnabled) { + command.execute(); + } + + // Always cancel in non-table contexts to prevent widget navigation + cancel(); } ); } From f4b6c65bad5f33318d0843ecdbde5979a4181570 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 21 Feb 2026 21:30:57 +0200 Subject: [PATCH 2/2] fix(ckeditor5): cursor jumping on Tab for other widgets such as separators or footnote --- .../src/plugins/indent_block_shortcut.ts | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/packages/ckeditor5/src/plugins/indent_block_shortcut.ts b/packages/ckeditor5/src/plugins/indent_block_shortcut.ts index 5fa2cf0f9e..813922dcec 100644 --- a/packages/ckeditor5/src/plugins/indent_block_shortcut.ts +++ b/packages/ckeditor5/src/plugins/indent_block_shortcut.ts @@ -2,40 +2,28 @@ * https://github.com/zadam/trilium/issues/978 */ -import { ModelDocumentFragment, ModelElement, Plugin, ModelPosition } from "ckeditor5"; +import { ModelDocumentFragment, ModelElement, Plugin, ModelPosition, ViewDocumentTabEvent, isWidget } from "ckeditor5"; export default class IndentBlockShortcutPlugin extends Plugin { init() { - this.editor.keystrokes.set( 'Tab', ( _, cancel ) => { + this.listenTo(this.editor.editing.view.document, "tab", (ev, data) => { // In tables, allow default Tab behavior for cell navigation - if (this.isInTable()) { - return; - } + if (this.isInTable()) return; - const command = this.editor.commands.get( 'indentBlock' ); + // Always cancel in non-table contexts to prevent widget navigation + data.preventDefault(); + ev.stop(); + + const commandName = data.shiftKey ? "outdentBlock" : "indentBlock"; + const command = this.editor.commands.get(commandName); if (command?.isEnabled) { command.execute(); } - - // Always cancel in non-table contexts to prevent widget navigation - cancel(); - } ); - - this.editor.keystrokes.set( 'Shift+Tab', ( _, cancel ) => { - // In tables, allow default Shift+Tab behavior for cell navigation - if (this.isInTable()) { - return; - } - - const command = this.editor.commands.get( 'outdentBlock' ); - if (command?.isEnabled) { - command.execute(); - } - - // Always cancel in non-table contexts to prevent widget navigation - cancel(); - } ); + }, { + priority: "highest", + context: node => isWidget( node ) || node.is( 'editableElement' ), + }); } // in table TAB should switch cells