mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Reset image handle on keydown and blur
This commit is contained in:
parent
c6e56e0465
commit
30e0894ad9
1 changed files with 16 additions and 6 deletions
|
@ -79,11 +79,17 @@ export class EditingArea extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback(): void {
|
connectedCallback(): void {
|
||||||
this.addEventListener("keydown", onKey);
|
this.addEventListener("keydown", (event) => {
|
||||||
|
this.resetImageHandle();
|
||||||
|
onKey(event);
|
||||||
|
});
|
||||||
this.addEventListener("keyup", onKeyUp);
|
this.addEventListener("keyup", onKeyUp);
|
||||||
this.addEventListener("input", onInput);
|
this.addEventListener("input", onInput);
|
||||||
this.addEventListener("focusin", onFocus);
|
this.addEventListener("focusin", onFocus);
|
||||||
this.addEventListener("focusout", onBlur);
|
this.addEventListener("focusout", (event) => {
|
||||||
|
this.resetImageHandle();
|
||||||
|
onBlur(event);
|
||||||
|
});
|
||||||
this.addEventListener("paste", this.onPaste);
|
this.addEventListener("paste", this.onPaste);
|
||||||
this.addEventListener("copy", onCutOrCopy);
|
this.addEventListener("copy", onCutOrCopy);
|
||||||
this.addEventListener("oncut", onCutOrCopy);
|
this.addEventListener("oncut", onCutOrCopy);
|
||||||
|
@ -166,6 +172,13 @@ export class EditingArea extends HTMLDivElement {
|
||||||
this.activeInput.onPaste(event);
|
this.activeInput.onPaste(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetImageHandle(): void {
|
||||||
|
(this.imageHandle as any).$set({
|
||||||
|
image: null,
|
||||||
|
imageRule: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
showImageHandle(event: MouseEvent): void {
|
showImageHandle(event: MouseEvent): void {
|
||||||
if (event.target instanceof HTMLImageElement) {
|
if (event.target instanceof HTMLImageElement) {
|
||||||
(this.imageHandle as any).$set({
|
(this.imageHandle as any).$set({
|
||||||
|
@ -174,10 +187,7 @@ export class EditingArea extends HTMLDivElement {
|
||||||
isRtl: this.isRightToLeft(),
|
isRtl: this.isRightToLeft(),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
(this.imageHandle as any).$set({
|
this.resetImageHandle();
|
||||||
image: null,
|
|
||||||
imageRule: null,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue