mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Fix legacy editable styles
This commit is contained in:
parent
a305665bf6
commit
33a1b32095
2 changed files with 41 additions and 32 deletions
|
|
@ -42,6 +42,16 @@ if (!sourcemap) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ignoreCssUrlPlugin = {
|
||||||
|
name: "ignore-css-url",
|
||||||
|
setup(build) {
|
||||||
|
// This works around esbuild unconditionally resolving CSS imports that uses Vite's `?url` syntax in the editor
|
||||||
|
build.onResolve({ filter: /.*?\.scss\?url$/ }, (args) => {
|
||||||
|
return { path: args.path, external: true };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
build({
|
build({
|
||||||
bundle: true,
|
bundle: true,
|
||||||
entryPoints: [entrypoint],
|
entryPoints: [entrypoint],
|
||||||
|
|
@ -51,6 +61,7 @@ build({
|
||||||
loader: { ".svg": "text" },
|
loader: { ".svg": "text" },
|
||||||
preserveSymlinks: true,
|
preserveSymlinks: true,
|
||||||
sourcemap: sourcemap ? "inline" : false,
|
sourcemap: sourcemap ? "inline" : false,
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
sassPlugin({ loadPaths: ["node_modules"] }),
|
sassPlugin({ loadPaths: ["node_modules"] }),
|
||||||
sveltePlugin({
|
sveltePlugin({
|
||||||
|
|
@ -59,6 +70,7 @@ build({
|
||||||
// let us focus on errors; we can see the warnings with svelte-check
|
// let us focus on errors; we can see the warnings with svelte-check
|
||||||
filterWarnings: (_warning) => false,
|
filterWarnings: (_warning) => false,
|
||||||
}),
|
}),
|
||||||
|
ignoreCssUrlPlugin,
|
||||||
],
|
],
|
||||||
target,
|
target,
|
||||||
// logLevel: "info",
|
// logLevel: "info",
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ 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";
|
||||||
|
|
||||||
|
|
@ -49,36 +46,36 @@ 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);
|
||||||
|
|
||||||
let styles: StyleLinkType[];
|
|
||||||
if (isLegacy) {
|
|
||||||
styles = [
|
|
||||||
{
|
|
||||||
id: "rootStyle",
|
|
||||||
type: "link",
|
|
||||||
href: "./_anki/css/editable.css",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
styles = [
|
|
||||||
{
|
|
||||||
id: "editableBaseStyle",
|
|
||||||
type: "link",
|
|
||||||
href: editableBaseCSS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "contentEditableStyle",
|
|
||||||
type: "link",
|
|
||||||
href: contentEditableCSS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "mathjaxStyle",
|
|
||||||
type: "link",
|
|
||||||
href: mathjaxCSS,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
function attachToShadow(element: Element) {
|
async function attachToShadow(element: Element) {
|
||||||
|
let styles: StyleLinkType[];
|
||||||
|
if (isLegacy) {
|
||||||
|
styles = [
|
||||||
|
{
|
||||||
|
id: "rootStyle",
|
||||||
|
type: "link",
|
||||||
|
href: "./_anki/css/editable.css",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
styles = [
|
||||||
|
{
|
||||||
|
id: "editableBaseStyle",
|
||||||
|
type: "link",
|
||||||
|
href: (await import("$lib/editable/editable-base.scss?url")).default,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "contentEditableStyle",
|
||||||
|
type: "link",
|
||||||
|
href: (await import("$lib/editable/content-editable.scss?url")).default,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "mathjaxStyle",
|
||||||
|
type: "link",
|
||||||
|
href: (await import("$lib/editable/mathjax.scss?url")).default,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
const customStyles = mount(CustomStyles, {
|
const customStyles = mount(CustomStyles, {
|
||||||
target: element.shadowRoot!,
|
target: element.shadowRoot!,
|
||||||
props: { styles },
|
props: { styles },
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue