Skip to content

Commit 5b24c79

Browse files
authored
fix(formula): add mathml output config (#393)
* fix(formula): add mathml output config * Create rare-guests-double.md
1 parent 1e87dde commit 5b24c79

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

.changeset/rare-guests-double.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@wangeditor-next/plugin-formula": minor
3+
---
4+
5+
fix(formula): add mathml output config

packages/plugin-formula/src/module/render-elem.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function renderFormula(elem: SlateElement, children: VNode[] | null, editor: IDo
2626
const containerVnode = h(
2727
'div',
2828
{
29+
className: 'w-e-textarea-formula-container',
2930
props: {
3031
contentEditable: false, // 不可编辑
3132
},

packages/plugin-formula/src/register-custom-elem/index.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ class WangEditorFormulaCard extends HTMLElement {
1919
super()
2020
const shadow = this.attachShadow({ mode: 'open' })
2121
const document = shadow.ownerDocument
22-
23-
// 将样式通过 link 标签引入
24-
const styleLink = document.createElement('link')
25-
26-
styleLink.rel = 'stylesheet'
27-
styleLink.href = 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css'
28-
styleLink.integrity = 'sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV'
29-
styleLink.crossOrigin = 'anonymous'
30-
shadow.appendChild(styleLink)
31-
3222
const span = document.createElement('span')
3323

3424
span.style.display = 'inline-block'
@@ -58,6 +48,7 @@ class WangEditorFormulaCard extends HTMLElement {
5848
private render(value: string) {
5949
katex.render(value, this.span, {
6050
throwOnError: false,
51+
output: 'mathml',
6152
})
6253
}
6354
}

0 commit comments

Comments
 (0)