Use registerShortcut in inputHandlers + Avoid focus on color picker
This commit is contained in:
parent
8ca40369a7
commit
f6ef4d43cb
@ -74,5 +74,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
{title}
|
{title}
|
||||||
on:click={delegateToInput}
|
on:click={delegateToInput}
|
||||||
on:mousedown|preventDefault>
|
on:mousedown|preventDefault>
|
||||||
<input bind:this={inputRef} type="color" on:change={onChange} />
|
<input tabindex="-1" bind:this={inputRef} type="color" on:change={onChange} />
|
||||||
</button>
|
</button>
|
||||||
|
@ -5,6 +5,7 @@ import { updateActiveButtons } from "editor-toolbar";
|
|||||||
import { EditingArea } from "./editingArea";
|
import { EditingArea } from "./editingArea";
|
||||||
import { caretToEnd, nodeIsElement, getBlockElement } from "./helpers";
|
import { caretToEnd, nodeIsElement, getBlockElement } from "./helpers";
|
||||||
import { triggerChangeTimer } from "./changeTimer";
|
import { triggerChangeTimer } from "./changeTimer";
|
||||||
|
import { registerShortcut } from "anki/shortcuts";
|
||||||
|
|
||||||
export function onInput(event: Event): void {
|
export function onInput(event: Event): void {
|
||||||
// make sure IME changes get saved
|
// make sure IME changes get saved
|
||||||
@ -51,21 +52,22 @@ export function onKey(evt: KeyboardEvent): void {
|
|||||||
triggerChangeTimer(currentField);
|
triggerChangeTimer(currentField);
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.addEventListener("keydown", (evt: KeyboardEvent) => {
|
function updateFocus(evt: FocusEvent) {
|
||||||
if (evt.code === "Tab") {
|
const newFocusTarget = evt.target;
|
||||||
globalThis.addEventListener(
|
if (newFocusTarget instanceof EditingArea) {
|
||||||
"focusin",
|
caretToEnd(newFocusTarget);
|
||||||
(evt: FocusEvent) => {
|
updateActiveButtons();
|
||||||
const newFocusTarget = evt.target;
|
|
||||||
if (newFocusTarget instanceof EditingArea) {
|
|
||||||
caretToEnd(newFocusTarget);
|
|
||||||
updateActiveButtons();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
registerShortcut(
|
||||||
|
() => document.addEventListener("focusin", updateFocus, { once: true }),
|
||||||
|
"Tab"
|
||||||
|
);
|
||||||
|
registerShortcut(
|
||||||
|
() => document.addEventListener("focusin", updateFocus, { once: true }),
|
||||||
|
"Shift+Tab"
|
||||||
|
);
|
||||||
|
|
||||||
export function onKeyUp(evt: KeyboardEvent): void {
|
export function onKeyUp(evt: KeyboardEvent): void {
|
||||||
const currentField = evt.currentTarget as EditingArea;
|
const currentField = evt.currentTarget as EditingArea;
|
||||||
|
Loading…
Reference in New Issue
Block a user