2021-08-04 01:55:39 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2021-08-07 21:03:36 +02:00
|
|
|
import { getContext } from "svelte";
|
|
|
|
import { nightModeKey } from "components/context-keys";
|
2021-08-04 01:55:39 +02:00
|
|
|
import { convertMathjax } from "./mathjax";
|
|
|
|
|
|
|
|
export let mathjax: string;
|
2021-08-05 06:01:43 +02:00
|
|
|
export let block: boolean;
|
2021-08-07 21:27:50 +02:00
|
|
|
/* have fixed fontSize for normal */
|
|
|
|
export const fontSize: number = 20;
|
2021-08-04 04:21:35 +02:00
|
|
|
|
2021-08-07 21:27:50 +02:00
|
|
|
const nightMode = getContext<boolean>(nightModeKey);
|
2021-08-07 21:03:36 +02:00
|
|
|
|
|
|
|
$: [converted, title] = convertMathjax(mathjax, nightMode, fontSize);
|
2021-08-07 22:23:18 +02:00
|
|
|
$: empty = title === "MathJax";
|
2021-08-04 18:57:34 +02:00
|
|
|
$: encoded = encodeURIComponent(converted);
|
2021-08-04 01:55:39 +02:00
|
|
|
</script>
|
|
|
|
|
2021-08-07 04:04:42 +02:00
|
|
|
<img
|
|
|
|
src="data:image/svg+xml,{encoded}"
|
|
|
|
class:block
|
2021-08-07 22:23:18 +02:00
|
|
|
class:empty
|
2021-08-07 04:04:42 +02:00
|
|
|
alt="Mathjax"
|
2021-08-07 19:33:01 +02:00
|
|
|
{title}
|
2021-08-07 04:04:42 +02:00
|
|
|
data-anki="mathjax"
|
|
|
|
on:dragstart|preventDefault
|
|
|
|
/>
|
2021-08-04 05:13:42 +02:00
|
|
|
|
|
|
|
<style lang="scss">
|
2021-08-07 22:18:31 +02:00
|
|
|
.block {
|
|
|
|
display: block;
|
|
|
|
margin: auto;
|
2021-08-04 05:13:42 +02:00
|
|
|
}
|
2021-08-07 22:23:18 +02:00
|
|
|
|
|
|
|
.empty {
|
|
|
|
vertical-align: sub;
|
|
|
|
}
|
2021-08-04 05:13:42 +02:00
|
|
|
</style>
|