Fix formatting/typing errors

This commit is contained in:
Abdo 2025-10-18 14:38:21 +03:00
parent 3084d59fb4
commit 9dcbf70aeb
2 changed files with 23 additions and 18 deletions

View file

@ -46,36 +46,40 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: setStyling("fontSize", fontSize + "px"); $: setStyling("fontSize", fontSize + "px");
$: setStyling("direction", direction); $: setStyling("direction", direction);
function attachToShadow(element: Element) {
async function attachToShadow(element: Element) { let stylesPromise: Promise<StyleLinkType[]>;
let styles: StyleLinkType[];
if (isLegacy) { if (isLegacy) {
styles = [ stylesPromise = Promise.resolve([
{ {
id: "rootStyle", id: "rootStyle",
type: "link", type: "link",
href: "./_anki/css/editable.css", href: "./_anki/css/editable.css",
}, },
]; ]);
} else { } 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", id: "editableBaseStyle",
type: "link", type: "link",
href: (await import("$lib/editable/editable-base.scss?url")).default, href: editableBase.default,
}, },
{ {
id: "contentEditableStyle", id: "contentEditableStyle",
type: "link", type: "link",
href: (await import("$lib/editable/content-editable.scss?url")).default, href: contentEditable.default,
}, },
{ {
id: "mathjaxStyle", id: "mathjaxStyle",
type: "link", type: "link",
href: (await import("$lib/editable/mathjax.scss?url")).default, href: mathjax.default,
}, },
]; ]);
} }
stylesPromise.then((styles) => {
const customStyles = mount(CustomStyles, { const customStyles = mount(CustomStyles, {
target: element.shadowRoot!, target: element.shadowRoot!,
props: { styles }, props: { styles },
@ -84,6 +88,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
userBaseResolve(styleTag); userBaseResolve(styleTag);
callback(customStyles); callback(customStyles);
}); });
});
} }
</script> </script>