mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 17:08:58 +01:00
chore(react/type_widget): render math in read-only text
This commit is contained in:
parent
a8007b9063
commit
ff941b2cb1
@ -12,6 +12,7 @@ import FNote from "../../../entities/fnote";
|
||||
import { getLocaleById } from "../../../services/i18n";
|
||||
import { getMermaidConfig } from "../../../services/mermaid";
|
||||
import { loadIncludedNote, refreshIncludedNote } from "./utils";
|
||||
import { renderMathInElement } from "../../../services/math";
|
||||
|
||||
export default function ReadOnlyText({ note }: TypeWidgetProps) {
|
||||
const blob = useNoteBlob(note);
|
||||
@ -25,6 +26,7 @@ export default function ReadOnlyText({ note }: TypeWidgetProps) {
|
||||
|
||||
applyInlineMermaid(container);
|
||||
applyIncludedNotes(container);
|
||||
applyMath(container);
|
||||
}, [ blob ]);
|
||||
|
||||
// React to included note changes.
|
||||
@ -86,3 +88,9 @@ function applyIncludedNotes(container: HTMLDivElement) {
|
||||
}
|
||||
}
|
||||
|
||||
function applyMath(container: HTMLDivElement) {
|
||||
const equations = container.querySelectorAll("span.math-tex");
|
||||
for (const equation of equations) {
|
||||
renderMathInElement(equation, { trust: true });
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,10 +37,6 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
|
||||
this.loadReferenceLinkTitle($(el));
|
||||
});
|
||||
|
||||
if (this.$content.find("span.math-tex").length > 0) {
|
||||
renderMathInElement(this.$content[0], { trust: true });
|
||||
}
|
||||
|
||||
await formatCodeBlocks(this.$content);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user