Fix anki-editable styles not applying

This commit is contained in:
Abdo 2025-05-26 02:26:59 +03:00
parent 0a3710e967
commit 8a9baca554
8 changed files with 56 additions and 57 deletions

View file

@ -148,8 +148,7 @@ fn build_css(build: &mut Build) -> Result<()> {
}, },
)?; )?;
} }
let other_ts_css = let other_ts_css = build.inputs_with_suffix(inputs![":ts:reviewer:reviewer.css"], ".css");
build.inputs_with_suffix(inputs![":ts:editable", ":ts:reviewer:reviewer.css"], ".css");
build.add_action( build.add_action(
"qt:aqt:data:web:css", "qt:aqt:data:web:css",
CopyFiles { CopyFiles {

View file

@ -202,19 +202,6 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
Ok(()) Ok(())
}; };
// we use the generated .css file separately
build_page(
"editable",
false,
inputs![
":ts:lib",
":ts:components",
":ts:domlib",
":ts:sveltelib",
":sass",
":sveltekit",
],
)?;
build_page( build_page(
"congrats", "congrats",
true, true,

View file

@ -57,21 +57,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
></anki-editable> ></anki-editable>
<style lang="scss"> <style lang="scss">
anki-editable { @import "./content-editable.scss";
display: block;
position: relative;
overflow: auto;
overflow-wrap: anywhere;
/* fallback for iOS */
word-break: break-word;
&:focus {
outline: none;
}
min-height: 1.5em;
}
/* editable-base.scss contains styling targeting user HTML */
</style> </style>

View file

@ -127,24 +127,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/> />
<style lang="scss"> <style lang="scss">
:global(anki-mathjax) { @import "./mathjax.scss";
white-space: pre;
}
img {
vertical-align: var(--vertical-center);
}
.block {
display: block;
margin: 1rem auto;
transform: scale(1.1);
}
.empty {
vertical-align: text-bottom;
width: var(--font-size);
height: var(--font-size);
}
</style> </style>

View file

@ -0,0 +1,15 @@
anki-editable {
display: block;
position: relative;
overflow: auto;
overflow-wrap: anywhere;
/* fallback for iOS */
word-break: break-word;
&:focus {
outline: none;
}
min-height: 1.5em;
}

View file

@ -2,6 +2,5 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import "./editable-base.scss"; import "./editable-base.scss";
/* only imported for the CSS */ import "./content-editable.scss";
import "./ContentEditable.svelte"; import "./mathjax.scss";
import "./Mathjax.svelte";

View file

@ -0,0 +1,20 @@
:global(anki-mathjax) {
white-space: pre;
}
img {
vertical-align: var(--vertical-center);
}
.block {
display: block;
margin: 1rem auto;
transform: scale(1.1);
}
.empty {
vertical-align: text-bottom;
width: var(--font-size);
height: var(--font-size);
}

View file

@ -7,6 +7,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { StyleLinkType, StyleObject } from "./CustomStyles.svelte"; import type { StyleLinkType, StyleObject } from "./CustomStyles.svelte";
import CustomStyles from "./CustomStyles.svelte"; import CustomStyles from "./CustomStyles.svelte";
import editableBaseCSS from "$lib/editable/editable-base.scss?url";
import contentEditableCSS from "$lib/editable/content-editable.scss?url";
import mathjaxCSS from "$lib/editable/mathjax.scss?url";
import { mount } from "svelte"; import { mount } from "svelte";
export let callback: (styles: Record<string, any>) => void; export let callback: (styles: Record<string, any>) => void;
@ -45,9 +49,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
const styles: StyleLinkType[] = [ const styles: StyleLinkType[] = [
{ {
id: "rootStyle", id: "editableBaseStyle",
type: "link", type: "link",
href: "./_anki/css/editable.css", href: editableBaseCSS,
},
{
id: "contentEditableStyle",
type: "link",
href: contentEditableCSS,
},
{
id: "mathjaxStyle",
type: "link",
href: mathjaxCSS,
}, },
]; ];