mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Transform to mathjax components for fieldHTML
This commit is contained in:
parent
5129aca66f
commit
b0b2ae3ece
3 changed files with 8 additions and 5 deletions
|
@ -6,7 +6,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import { convertMathjax } from "./mathjax";
|
import { convertMathjax } from "./mathjax";
|
||||||
|
|
||||||
export let mathjax: string;
|
export let mathjax: string;
|
||||||
$: console.log(mathjax, convertMathjax(`\\(${mathjax}\\)`));
|
|
||||||
$: converted = convertMathjax(`\\(${mathjax}\\)`);
|
$: converted = convertMathjax(`\\(${mathjax}\\)`);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,11 @@ export function toMathjaxTags(html: string): string {
|
||||||
.replace(
|
.replace(
|
||||||
mathjaxInlineDelimiterPattern,
|
mathjaxInlineDelimiterPattern,
|
||||||
(_match: string, text: string) =>
|
(_match: string, text: string) =>
|
||||||
`<anki-mathjax-inline>${text}</anki-cloze>`
|
`<anki-mathjax-inline>${text}</anki-mathjax-inline>`
|
||||||
)
|
)
|
||||||
.replace(
|
.replace(
|
||||||
mathjaxBlockDelimiterPattern,
|
mathjaxBlockDelimiterPattern,
|
||||||
(_match: string, text: string) => `<anki-mathjax-block>${text}</anki-cloze>`
|
(_match: string, text: string) =>
|
||||||
|
`<anki-mathjax-block>${text}</anki-mathjax-block>`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { bridgeCommand } from "./lib";
|
||||||
import { onInput, onKey, onKeyUp } from "./input-handlers";
|
import { onInput, onKey, onKeyUp } from "./input-handlers";
|
||||||
import { onFocus, onBlur } from "./focus-handlers";
|
import { onFocus, onBlur } from "./focus-handlers";
|
||||||
import { nightModeKey } from "components/context-keys";
|
import { nightModeKey } from "components/context-keys";
|
||||||
|
import { toMathjaxTags, toMathjaxDelimiters } from "editable/mathjax-components";
|
||||||
|
|
||||||
function onCutOrCopy(): void {
|
function onCutOrCopy(): void {
|
||||||
bridgeCommand("cutOrCopy");
|
bridgeCommand("cutOrCopy");
|
||||||
|
@ -92,11 +93,13 @@ export class EditingArea extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
set fieldHTML(content: string) {
|
set fieldHTML(content: string) {
|
||||||
this.imageHandle.then(() => (this.activeInput.fieldHTML = content));
|
this.imageHandle.then(
|
||||||
|
() => (this.activeInput.fieldHTML = toMathjaxTags(content))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get fieldHTML(): string {
|
get fieldHTML(): string {
|
||||||
return this.activeInput.fieldHTML;
|
return toMathjaxDelimiters(this.activeInput.fieldHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback(): void {
|
connectedCallback(): void {
|
||||||
|
|
Loading…
Reference in a new issue