diff --git a/ts/editor/MathjaxHandle.svelte b/ts/editor/MathjaxHandle.svelte index fc1c1c850..b98f98aaa 100644 --- a/ts/editor/MathjaxHandle.svelte +++ b/ts/editor/MathjaxHandle.svelte @@ -31,8 +31,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let updateSelection: () => void; let title: string; + function getComponent(image: HTMLImageElement): HTMLElement { + return (image.closest("anki-mathjax")! as HTMLElement); + } + function onUpdate(event: CustomEvent) { - activeImage!.parentElement!.dataset.mathjax = event.detail.mathjax; + getComponent(activeImage!).dataset.mathjax = event.detail.mathjax; setTimeout(() => { updateSelection(); title = activeImage!.title; @@ -63,7 +67,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html { onUpdate(event); setTimeout(dropdownObject.update);