From 789d14330aa24997af87dd02bba64e142f0aebf5 Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Tue, 25 Feb 2025 17:04:03 +1100 Subject: [PATCH] refactor: reordered function calls for readability --- src/features/editor/context.ts | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/features/editor/context.ts b/src/features/editor/context.ts index c102c98..732db12 100644 --- a/src/features/editor/context.ts +++ b/src/features/editor/context.ts @@ -113,6 +113,26 @@ export function createEditor(ref: Accessor, 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()!, { keydown(e: KeyboardEvent) { // keyCode === 229 is a special code that indicates an IME event. @@ -134,26 +154,6 @@ export function createEditor(ref: Accessor, 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(() => { updateControlBounds(); });