From 5b24c79a6abdfb0364b292be4ccf236806aa9c0b Mon Sep 17 00:00:00 2001 From: cycleccc <2991205548@qq.com> Date: Tue, 26 Nov 2024 15:59:45 +0800 Subject: [PATCH] fix(formula): add mathml output config (#393) * fix(formula): add mathml output config * Create rare-guests-double.md --- .changeset/rare-guests-double.md | 5 +++++ packages/plugin-formula/src/module/render-elem.ts | 1 + .../plugin-formula/src/register-custom-elem/index.ts | 11 +---------- 3 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 .changeset/rare-guests-double.md diff --git a/.changeset/rare-guests-double.md b/.changeset/rare-guests-double.md new file mode 100644 index 000000000..95464b3e4 --- /dev/null +++ b/.changeset/rare-guests-double.md @@ -0,0 +1,5 @@ +--- +"@wangeditor-next/plugin-formula": minor +--- + +fix(formula): add mathml output config diff --git a/packages/plugin-formula/src/module/render-elem.ts b/packages/plugin-formula/src/module/render-elem.ts index 5abebf1c3..f380ab072 100644 --- a/packages/plugin-formula/src/module/render-elem.ts +++ b/packages/plugin-formula/src/module/render-elem.ts @@ -26,6 +26,7 @@ function renderFormula(elem: SlateElement, children: VNode[] | null, editor: IDo const containerVnode = h( 'div', { + className: 'w-e-textarea-formula-container', props: { contentEditable: false, // 不可编辑 }, diff --git a/packages/plugin-formula/src/register-custom-elem/index.ts b/packages/plugin-formula/src/register-custom-elem/index.ts index 0011cf191..419af31e7 100644 --- a/packages/plugin-formula/src/register-custom-elem/index.ts +++ b/packages/plugin-formula/src/register-custom-elem/index.ts @@ -19,16 +19,6 @@ class WangEditorFormulaCard extends HTMLElement { super() const shadow = this.attachShadow({ mode: 'open' }) const document = shadow.ownerDocument - - // 将样式通过 link 标签引入 - const styleLink = document.createElement('link') - - styleLink.rel = 'stylesheet' - styleLink.href = 'https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css' - styleLink.integrity = 'sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV' - styleLink.crossOrigin = 'anonymous' - shadow.appendChild(styleLink) - const span = document.createElement('span') span.style.display = 'inline-block' @@ -58,6 +48,7 @@ class WangEditorFormulaCard extends HTMLElement { private render(value: string) { katex.render(value, this.span, { throwOnError: false, + output: 'mathml', }) } }