mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
MathJax
Problems with font cors (I'm shocked that using the import with the .js worked without a hitch O_O)
This commit is contained in:
parent
3cf58419d7
commit
cd5f25469e
2 changed files with 16 additions and 2 deletions
|
|
@ -104,7 +104,7 @@ async function setInnerHTML(element: Element, html: string): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
const renderError = (type: string) => (error: unknown): string => {
|
||||
export const renderError = (type: string) => (error: unknown): string => {
|
||||
const errorMessage = String(error).substring(0, 2000);
|
||||
let errorStack: string;
|
||||
if (error instanceof Error) {
|
||||
|
|
|
|||
|
|
@ -2,15 +2,18 @@
|
|||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
import "../base.scss";
|
||||
import "../../reviewer/reviewer.scss";
|
||||
import "mathjax/es5/tex-chtml-full.js";
|
||||
import { renderError } from "../../reviewer";
|
||||
import { enableNightMode } from "../reviewer/reviewer";
|
||||
import type { InnerReviewerRequest } from "./reviewerRequest";
|
||||
|
||||
declare const MathJax: any;
|
||||
const urlParams = new URLSearchParams(location.search);
|
||||
|
||||
const style = document.createElement("style");
|
||||
document.head.appendChild(style);
|
||||
|
||||
addEventListener("message", (e: MessageEvent<InnerReviewerRequest>) => {
|
||||
addEventListener("message", async (e: MessageEvent<InnerReviewerRequest>) => {
|
||||
switch (e.data.type) {
|
||||
case "html": {
|
||||
document.body.innerHTML = e.data.value;
|
||||
|
|
@ -26,6 +29,17 @@ addEventListener("message", (e: MessageEvent<InnerReviewerRequest>) => {
|
|||
document.body.classList.add("nightMode");
|
||||
}
|
||||
}
|
||||
|
||||
// wait for mathjax to ready
|
||||
await MathJax.startup.promise
|
||||
.then(() => {
|
||||
// clear MathJax buffers from previous typesets
|
||||
MathJax.typesetClear();
|
||||
|
||||
return MathJax.typesetPromise([document.body]);
|
||||
})
|
||||
.catch(renderError("MathJax"));
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue