mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-21 17:30:58 +08:00
This upgrades to Mathjax 4.1 and latest katex Implement rich text composer support for math Adds support for /( )/ and /[ /] which was missing and very common now Removes math javascript from our repo --------- Co-authored-by: Mark McClure <mcmcclur@unca.edu>
29 lines
629 B
JavaScript
Vendored
29 lines
629 B
JavaScript
Vendored
import {
|
|
getKaTeX,
|
|
loadCopyTex,
|
|
loadKaTeX as loadKaTeXBundle,
|
|
loadMhchem,
|
|
} from "discourse/plugins/discourse-math/lib/katex-bundle";
|
|
|
|
let basePromise;
|
|
let mhchemPromise;
|
|
let copyTexPromise;
|
|
|
|
export default async function loadKaTeX(options = {}) {
|
|
if (!basePromise) {
|
|
basePromise = loadKaTeXBundle();
|
|
}
|
|
await basePromise;
|
|
|
|
if (options.enableMhchem && !mhchemPromise) {
|
|
mhchemPromise = loadMhchem();
|
|
}
|
|
|
|
if (options.enableCopyTex && !copyTexPromise) {
|
|
copyTexPromise = loadCopyTex();
|
|
}
|
|
|
|
await Promise.all([mhchemPromise, copyTexPromise].filter(Boolean));
|
|
|
|
return getKaTeX() ?? window.katex;
|
|
}
|