refactor: reordered function calls for readability
This commit is contained in:
parent
5f6138d30b
commit
789d14330a
1 changed files with 20 additions and 20 deletions
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue