diff --git a/ts/editable/Mathjax.svelte b/ts/editable/Mathjax.svelte index 3642ef27c..ccf442f12 100644 --- a/ts/editable/Mathjax.svelte +++ b/ts/editable/Mathjax.svelte @@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> void) => (): void => { + errorMessage = activeImage!.title; + updateSelection().then(resolve); + }; + function onEditorUpdate(event: CustomEvent): Promise { let selectionResolve: (value: void) => void; - const afterSelectionUpdate = new Promise((resolve) => { + const afterSelectionUpdate = new Promise((resolve: (value: void) => void) => { selectionResolve = resolve; }); - setTimeout(async () => { - errorMessage = activeImage!.title; - await updateSelection(); - selectionResolve(); - }); + const imageResize = onImageResize(selectionResolve!); + + activeImage!.addEventListener("resize", imageResize, { once: true }); + /* this updates the image in Mathjax.svelte */ + getComponent(activeImage!).dataset.mathjax = event.detail.mathjax; return afterSelectionUpdate; }