diff --git a/ts/routes/editor/NoteEditor.svelte b/ts/routes/editor/NoteEditor.svelte index 0e848b1ba..0ad5c705c 100644 --- a/ts/routes/editor/NoteEditor.svelte +++ b/ts/routes/editor/NoteEditor.svelte @@ -443,7 +443,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html closeMathjaxEditor?.(); $commitTagEdits(); await saveFieldNow(); - if(!isLegacy) { + if (!isLegacy) { bridgeCommand("saved"); } } diff --git a/ts/routes/editor/rich-text-input/RichTextStyles.svelte b/ts/routes/editor/rich-text-input/RichTextStyles.svelte index 7e3a651d0..dfe34f872 100644 --- a/ts/routes/editor/rich-text-input/RichTextStyles.svelte +++ b/ts/routes/editor/rich-text-input/RichTextStyles.svelte @@ -46,43 +46,48 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html $: setStyling("fontSize", fontSize + "px"); $: setStyling("direction", direction); - - async function attachToShadow(element: Element) { - let styles: StyleLinkType[]; + function attachToShadow(element: Element) { + let stylesPromise: Promise; if (isLegacy) { - styles = [ + stylesPromise = Promise.resolve([ { id: "rootStyle", type: "link", href: "./_anki/css/editable.css", }, - ]; + ]); } else { - styles = [ + stylesPromise = Promise.all([ + import("$lib/editable/editable-base.scss?url"), + import("$lib/editable/content-editable.scss?url"), + import("$lib/editable/mathjax.scss?url"), + ]).then(([editableBase, contentEditable, mathjax]) => [ { id: "editableBaseStyle", type: "link", - href: (await import("$lib/editable/editable-base.scss?url")).default, + href: editableBase.default, }, { id: "contentEditableStyle", type: "link", - href: (await import("$lib/editable/content-editable.scss?url")).default, + href: contentEditable.default, }, { id: "mathjaxStyle", type: "link", - href: (await import("$lib/editable/mathjax.scss?url")).default, + href: mathjax.default, }, - ]; + ]); } - const customStyles = mount(CustomStyles, { - target: element.shadowRoot!, - props: { styles }, - }); - customStyles.addStyleTag("userBase").then((styleTag) => { - userBaseResolve(styleTag); - callback(customStyles); + stylesPromise.then((styles) => { + const customStyles = mount(CustomStyles, { + target: element.shadowRoot!, + props: { styles }, + }); + customStyles.addStyleTag("userBase").then((styleTag) => { + userBaseResolve(styleTag); + callback(customStyles); + }); }); }