From e06ff2ae3c793c6672f6595e57d0661effd29ee6 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 7 Aug 2021 22:52:48 +0200 Subject: [PATCH] Focus on mount when using Mathjax shortcuts --- ts/editable/Mathjax.svelte | 13 ++++++++++++- ts/editable/mathjax-component.ts | 7 ++++++- ts/editable/mathjax.ts | 2 +- ts/editor/TemplateButtons.svelte | 12 +++++++++--- ts/editor/editing-area.ts | 9 +++++---- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ts/editable/Mathjax.svelte b/ts/editable/Mathjax.svelte index 59ecfc33e..d471c6fed 100644 --- a/ts/editable/Mathjax.svelte +++ b/ts/editable/Mathjax.svelte @@ -3,12 +3,14 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - wrapCurrent("", "")} + wrapCurrent( + "", + "" + )} on:mount={withButton(createShortcut)} > {tr.editingMathjaxInline()} @@ -118,7 +121,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html wrapCurrent( - '', + '', "" )} on:mount={withButton(createShortcut)} @@ -135,7 +138,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > - wrapCurrent("\\ce{", "}")} + wrapCurrent( + "\\ce{", + "}" + )} on:mount={withButton(createShortcut)} > {tr.editingMathjaxChemistry()} diff --git a/ts/editor/editing-area.ts b/ts/editor/editing-area.ts index 90867bf93..127963c2c 100644 --- a/ts/editor/editing-area.ts +++ b/ts/editor/editing-area.ts @@ -238,18 +238,19 @@ export class EditingArea extends HTMLDivElement { async showHandles(event: MouseEvent): Promise { if (event.target instanceof HTMLImageElement) { + const image = event.target as HTMLImageElement; await this.resetHandles(); - if (!event.target.dataset.anki) { + if (!image.dataset.anki) { await this.imageHandle.then((imageHandle) => (imageHandle as any).$set({ - activeImage: event.target, + activeImage: image, isRtl: this.isRightToLeft(), }) ); - } else if (event.target.dataset.anki === "mathjax") { + } else if (image.dataset.anki === "mathjax") { (this.mathjaxHandle as any).$set({ - activeImage: event.target, + activeImage: image, isRtl: this.isRightToLeft(), }); }