fix(editor): resolve strange stuck indent when a Note has images (#8520)

This commit is contained in:
Elian Doran
2026-02-22 00:01:07 +02:00
committed by GitHub

View File

@@ -2,28 +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 ) => {
const command = this.editor.commands.get( 'indentBlock' );
this.listenTo<ViewDocumentTabEvent>(this.editor.editing.view.document, "tab", (ev, data) => {
// In tables, allow default Tab behavior for cell navigation
if (this.isInTable()) return;
if (command && command.isEnabled && !this.isInTable() ) {
// 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();
cancel();
}
} );
this.editor.keystrokes.set( 'Shift+Tab', ( _, cancel ) => {
const command = this.editor.commands.get( 'outdentBlock' );
if (command && command.isEnabled && !this.isInTable() ) {
command.execute();
cancel();
}
} );
}, {
priority: "highest",
context: node => isWidget( node ) || node.is( 'editableElement' ),
});
}
// in table TAB should switch cells