refactor: reordered function calls for readability

This commit is contained in:
Chris Kruining 2025-02-25 17:04:03 +11:00
parent 5f6138d30b
commit 789d14330a
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2

View file

@ -113,6 +113,26 @@ export function createEditor(ref: Accessor<Element | undefined>, value: Accessor
}, },
}); });
DocumentEventListener({
onSelectionchange(e) {
const selection = document.getSelection();
if (selection === null) {
return;
}
if (selection.rangeCount === 0) {
return;
}
if (document.activeElement !== ref()) {
return;
}
updateSelection(selection.getRangeAt(0)!);
},
});
createEventListenerMap(() => ref()!, { createEventListenerMap(() => ref()!, {
keydown(e: KeyboardEvent) { keydown(e: KeyboardEvent) {
// keyCode === 229 is a special code that indicates an IME event. // keyCode === 229 is a special code that indicates an IME event.
@ -134,26 +154,6 @@ export function createEditor(ref: Accessor<Element | undefined>, value: Accessor
}, },
}); });
DocumentEventListener({
onSelectionchange(e) {
const selection = document.getSelection();
if (selection === null) {
return;
}
if (selection.rangeCount === 0) {
return;
}
if (document.activeElement !== ref()) {
return;
}
updateSelection(selection.getRangeAt(0)!);
},
});
onMount(() => { onMount(() => {
updateControlBounds(); updateControlBounds();
}); });