diff --git a/build/configure/src/aqt.rs b/build/configure/src/aqt.rs index 80f7462f5..c3fb5ffac 100644 --- a/build/configure/src/aqt.rs +++ b/build/configure/src/aqt.rs @@ -148,8 +148,7 @@ fn build_css(build: &mut Build) -> Result<()> { }, )?; } - let other_ts_css = - build.inputs_with_suffix(inputs![":ts:editable", ":ts:reviewer:reviewer.css"], ".css"); + let other_ts_css = build.inputs_with_suffix(inputs![":ts:reviewer:reviewer.css"], ".css"); build.add_action( "qt:aqt:data:web:css", CopyFiles { diff --git a/build/configure/src/web.rs b/build/configure/src/web.rs index 2e5411c41..152a1a4d0 100644 --- a/build/configure/src/web.rs +++ b/build/configure/src/web.rs @@ -202,19 +202,6 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> { 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( "congrats", true, diff --git a/ts/lib/editable/ContentEditable.svelte b/ts/lib/editable/ContentEditable.svelte index d0cfe89df..3f3b7c7f5 100644 --- a/ts/lib/editable/ContentEditable.svelte +++ b/ts/lib/editable/ContentEditable.svelte @@ -57,21 +57,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html > diff --git a/ts/lib/editable/Mathjax.svelte b/ts/lib/editable/Mathjax.svelte index bc8e5cf81..7be3c986d 100644 --- a/ts/lib/editable/Mathjax.svelte +++ b/ts/lib/editable/Mathjax.svelte @@ -127,24 +127,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /> diff --git a/ts/lib/editable/content-editable.scss b/ts/lib/editable/content-editable.scss new file mode 100644 index 000000000..6648283d1 --- /dev/null +++ b/ts/lib/editable/content-editable.scss @@ -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; +} diff --git a/ts/lib/editable/index.ts b/ts/lib/editable/index.ts index b44eb6435..00984a718 100644 --- a/ts/lib/editable/index.ts +++ b/ts/lib/editable/index.ts @@ -2,6 +2,5 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import "./editable-base.scss"; -/* only imported for the CSS */ -import "./ContentEditable.svelte"; -import "./Mathjax.svelte"; +import "./content-editable.scss"; +import "./mathjax.scss"; diff --git a/ts/lib/editable/mathjax.scss b/ts/lib/editable/mathjax.scss new file mode 100644 index 000000000..30f4c7541 --- /dev/null +++ b/ts/lib/editable/mathjax.scss @@ -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); +} diff --git a/ts/routes/editor/rich-text-input/RichTextStyles.svelte b/ts/routes/editor/rich-text-input/RichTextStyles.svelte index b4f9cae0c..87629c347 100644 --- a/ts/routes/editor/rich-text-input/RichTextStyles.svelte +++ b/ts/routes/editor/rich-text-input/RichTextStyles.svelte @@ -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 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"; export let callback: (styles: Record) => void; @@ -45,9 +49,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const styles: StyleLinkType[] = [ { - id: "rootStyle", + id: "editableBaseStyle", type: "link", - href: "./_anki/css/editable.css", + href: editableBaseCSS, + }, + { + id: "contentEditableStyle", + type: "link", + href: contentEditableCSS, + }, + { + id: "mathjaxStyle", + type: "link", + href: mathjaxCSS, }, ];