]> BookStack Code Mirror - bookstack/commitdiff
Lexical: Altered keyboard handling to indicant handled state
authorDan Brown <redacted>
Fri, 13 Sep 2024 15:05:55 +0000 (16:05 +0100)
committerDan Brown <redacted>
Fri, 13 Sep 2024 15:05:55 +0000 (16:05 +0100)
resources/js/wysiwyg/services/keyboard-handling.ts

index 791fb0bed3fc196957d257995f4fe565d9c975a9..2c7bfdbbae7ae431e8275a7501a0895570602af5 100644 (file)
@@ -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 {