mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -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";
|
||||
|
||||
export let mathjax: string;
|
||||
$: console.log(mathjax, convertMathjax(`\\(${mathjax}\\)`));
|
||||
$: converted = convertMathjax(`\\(${mathjax}\\)`);
|
||||
</script>
|
||||
|
||||
|
|
|
@ -41,10 +41,11 @@ export function toMathjaxTags(html: string): string {
|
|||
.replace(
|
||||
mathjaxInlineDelimiterPattern,
|
||||
(_match: string, text: string) =>
|
||||
`<anki-mathjax-inline>${text}</anki-cloze>`
|
||||
`<anki-mathjax-inline>${text}</anki-mathjax-inline>`
|
||||
)
|
||||
.replace(
|
||||
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 { onFocus, onBlur } from "./focus-handlers";
|
||||
import { nightModeKey } from "components/context-keys";
|
||||
import { toMathjaxTags, toMathjaxDelimiters } from "editable/mathjax-components";
|
||||
|
||||
function onCutOrCopy(): void {
|
||||
bridgeCommand("cutOrCopy");
|
||||
|
@ -92,11 +93,13 @@ export class EditingArea extends HTMLDivElement {
|
|||
}
|
||||
|
||||
set fieldHTML(content: string) {
|
||||
this.imageHandle.then(() => (this.activeInput.fieldHTML = content));
|
||||
this.imageHandle.then(
|
||||
() => (this.activeInput.fieldHTML = toMathjaxTags(content))
|
||||
);
|
||||
}
|
||||
|
||||
get fieldHTML(): string {
|
||||
return this.activeInput.fieldHTML;
|
||||
return toMathjaxDelimiters(this.activeInput.fieldHTML);
|
||||
}
|
||||
|
||||
connectedCallback(): void {
|
||||
|
|
Loading…
Reference in a new issue