From 554e5b5bb78559e79b0f725b47e420bc737e6f11 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 29 Aug 2023 12:02:32 +0800 Subject: [PATCH] :art: fix https://github.com/Vanessa219/vditor/issues/1453 --- CHANGELOG.md | 2 +- README.md | 1 + README_en_US.md | 1 + src/ts/markdown/mathRender.ts | 2 ++ types/index.d.ts | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2295f28e8..28279de6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ ### v3.9.4 / 2023-09 - +* [MathJax 支持传入其他配置项](https://github.com/Vanessa219/vditor/issues/1453) `引入特性` ### v3.9.5 / 2023-08-29 diff --git a/README.md b/README.md index 24b511fdc..9786a1b7d 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,7 @@ new Vditor('vditor', { | inlineDigit | 内联数学公式起始 $ 后是否允许数字 | false | | macros | 使用 MathJax 渲染时传入的宏定义 | {} | | engine | 数学公式渲染引擎:KaTeX, MathJax | 'KaTeX' | +| mathJaxOptions | 数学公式渲染引擎为 MathJax 时的参数 | - | #### options.preview.actions?: Array diff --git a/README_en_US.md b/README_en_US.md index 37fe31df8..bb255742b 100644 --- a/README_en_US.md +++ b/README_en_US.md @@ -318,6 +318,7 @@ new Vditor('vditor', { | inlineDigit | Whether numbers are allowed after the inline math formula starting with $ | false | | macros | Macro definition passed in when rendering with MathJax | {} | | engine | Math formula rendering engine: KaTeX, MathJax | 'KaTeX' | +| mathJaxOptions | Parameters when the math formula rendering engine is MathJax | - | #### options.preview.actions diff --git a/src/ts/markdown/mathRender.ts b/src/ts/markdown/mathRender.ts index 08fe1ac72..f06a7dccf 100644 --- a/src/ts/markdown/mathRender.ts +++ b/src/ts/markdown/mathRender.ts @@ -99,6 +99,8 @@ export const mathRender = (element: HTMLElement, options?: { cdn?: string, math? macros: options.math.macros, }, }; + // https://github.com/Vanessa219/vditor/issues/1453 + Object.assign(window.MathJax, options.math.mathJaxOptions); } // 循环加载会抛异常 addScriptSync(`${options.cdn}/dist/js/mathjax/tex-svg-full.js`, "protyleMathJaxScript"); diff --git a/types/index.d.ts b/types/index.d.ts index bbc6889e0..100187417 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -445,6 +445,8 @@ interface IMath { macros?: object; /** 数学公式渲染引擎。默认值: 'KaTeX' */ engine?: "KaTeX" | "MathJax"; + /** 数学公式渲染引擎为 MathJax 时传入的参数 */ + mathJaxOptions?: any; } /** @link https://ld246.com/article/1549638745630#options-preview-markdown */