Lexical: Altered keyboard handling to indicant handled state

This commit is contained in:
Dan Brown 2024-09-13 16:05:55 +01:00
parent 662110c269
commit 6872eb802c
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -58,15 +58,19 @@ function insertAfterSingleSelectedNode(editor: LexicalEditor, event: KeyboardEve
return false; return false;
} }
function handleInsetOnTab(editor: LexicalEditor, event: KeyboardEvent|null) { function handleInsetOnTab(editor: LexicalEditor, event: KeyboardEvent|null): boolean {
const change = event?.shiftKey ? -40 : 40; const change = event?.shiftKey ? -40 : 40;
editor.update(() => { const selection = $getSelection();
const selection = $getSelection(); const nodes = selection?.getNodes() || [];
const nodes = selection?.getNodes() || []; if (nodes.length > 1 || (nodes.length === 1 && $isCustomListItemNode(nodes[0].getParent()))) {
if (nodes.length > 1 || (nodes.length === 1 && $isCustomListItemNode(nodes[0].getParent()))) { editor.update(() => {
$setInsetForSelection(editor, change); $setInsetForSelection(editor, change);
} });
}); event?.preventDefault();
return true;
}
return false;
} }
export function registerKeyboardHandling(context: EditorUiContext): () => void { export function registerKeyboardHandling(context: EditorUiContext): () => void {