From: Dan Brown Date: Fri, 13 Sep 2024 15:05:55 +0000 (+0100) Subject: Lexical: Altered keyboard handling to indicant handled state X-Git-Tag: v24.10~1^2~23^2~14 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/6872eb802c3c7bf9fed1e21eb7dc691a5e09af98 Lexical: Altered keyboard handling to indicant handled state --- diff --git a/resources/js/wysiwyg/services/keyboard-handling.ts b/resources/js/wysiwyg/services/keyboard-handling.ts index 791fb0bed..2c7bfdbba 100644 --- a/resources/js/wysiwyg/services/keyboard-handling.ts +++ b/resources/js/wysiwyg/services/keyboard-handling.ts @@ -58,15 +58,19 @@ function insertAfterSingleSelectedNode(editor: LexicalEditor, event: KeyboardEve return false; } -function handleInsetOnTab(editor: LexicalEditor, event: KeyboardEvent|null) { +function handleInsetOnTab(editor: LexicalEditor, event: KeyboardEvent|null): boolean { const change = event?.shiftKey ? -40 : 40; - editor.update(() => { - const selection = $getSelection(); - const nodes = selection?.getNodes() || []; - if (nodes.length > 1 || (nodes.length === 1 && $isCustomListItemNode(nodes[0].getParent()))) { + const selection = $getSelection(); + const nodes = selection?.getNodes() || []; + if (nodes.length > 1 || (nodes.length === 1 && $isCustomListItemNode(nodes[0].getParent()))) { + editor.update(() => { $setInsetForSelection(editor, change); - } - }); + }); + event?.preventDefault(); + return true; + } + + return false; } export function registerKeyboardHandling(context: EditorUiContext): () => void {