mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix alignment of empty icon
This commit is contained in:
parent
de056fbd89
commit
af556c391d
3 changed files with 16 additions and 8 deletions
|
@ -15,12 +15,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
const nightMode = getContext<boolean>(nightModeKey);
|
const nightMode = getContext<boolean>(nightModeKey);
|
||||||
|
|
||||||
$: [converted, title] = convertMathjax(mathjax, nightMode, fontSize);
|
$: [converted, title] = convertMathjax(mathjax, nightMode, fontSize);
|
||||||
|
$: empty = title === "MathJax";
|
||||||
$: encoded = encodeURIComponent(converted);
|
$: encoded = encodeURIComponent(converted);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
src="data:image/svg+xml,{encoded}"
|
src="data:image/svg+xml,{encoded}"
|
||||||
class:block
|
class:block
|
||||||
|
class:empty
|
||||||
alt="Mathjax"
|
alt="Mathjax"
|
||||||
{title}
|
{title}
|
||||||
data-anki="mathjax"
|
data-anki="mathjax"
|
||||||
|
@ -32,4 +34,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
display: block;
|
display: block;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
vertical-align: sub;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -11,10 +11,6 @@ function getCSS(nightMode: boolean, fontSize: number): string {
|
||||||
return `svg { color: ${color}; fill: ${color}; font-size: ${fontSize}px; }`;
|
return `svg { color: ${color}; fill: ${color}; font-size: ${fontSize}px; }`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getErrorCSS(fontSize: number): string {
|
|
||||||
return `svg { color: yellow; font-size: ${fontSize}px; }`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStyle(css: string): HTMLStyleElement {
|
function getStyle(css: string): HTMLStyleElement {
|
||||||
const style = document.createElement("style") as HTMLStyleElement;
|
const style = document.createElement("style") as HTMLStyleElement;
|
||||||
style.appendChild(document.createTextNode(css));
|
style.appendChild(document.createTextNode(css));
|
||||||
|
@ -26,7 +22,7 @@ function getEmptyIcon(style: HTMLStyleElement): [string, string] {
|
||||||
const svg = icon.children[0];
|
const svg = icon.children[0];
|
||||||
svg.insertBefore(style, svg.children[0]);
|
svg.insertBefore(style, svg.children[0]);
|
||||||
|
|
||||||
return [svg.outerHTML, ""];
|
return [svg.outerHTML, "MathJax"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertMathjax(
|
export function convertMathjax(
|
||||||
|
|
|
@ -101,7 +101,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let:shortcutLabel
|
let:shortcutLabel
|
||||||
>
|
>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
on:click={() => wrapCurrent("<anki-mathjax>", "</anki-mathjax>")}
|
on:click={() =>
|
||||||
|
wrapCurrent("<anki-mathjax>", "</anki-mathjax>")}
|
||||||
on:mount={withButton(createShortcut)}
|
on:mount={withButton(createShortcut)}
|
||||||
>
|
>
|
||||||
{tr.editingMathjaxInline()}
|
{tr.editingMathjaxInline()}
|
||||||
|
@ -115,7 +116,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let:shortcutLabel
|
let:shortcutLabel
|
||||||
>
|
>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
on:click={() => wrapCurrent("<anki-mathjax block=\"true\">", "</anki-matjax>")}
|
on:click={() =>
|
||||||
|
wrapCurrent(
|
||||||
|
'<anki-mathjax block="true">',
|
||||||
|
"</anki-matjax>"
|
||||||
|
)}
|
||||||
on:mount={withButton(createShortcut)}
|
on:mount={withButton(createShortcut)}
|
||||||
>
|
>
|
||||||
{tr.editingMathjaxBlock()}
|
{tr.editingMathjaxBlock()}
|
||||||
|
@ -129,7 +134,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let:shortcutLabel
|
let:shortcutLabel
|
||||||
>
|
>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
on:click={() => wrapCurrent("<anki-mathjax>\\ce{", "}</anki-mathjax>")}
|
on:click={() =>
|
||||||
|
wrapCurrent("<anki-mathjax>\\ce{", "}</anki-mathjax>")}
|
||||||
on:mount={withButton(createShortcut)}
|
on:mount={withButton(createShortcut)}
|
||||||
>
|
>
|
||||||
{tr.editingMathjaxChemistry()}
|
{tr.editingMathjaxChemistry()}
|
||||||
|
|
Loading…
Reference in a new issue