Skip to content

Commit

Permalink
fix(formula): add mathml output config
Browse files Browse the repository at this point in the history
  • Loading branch information
cycleccc committed Nov 26, 2024
1 parent 1e87dde commit b6af4f1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/plugin-formula/src/module/render-elem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, // 不可编辑
},
Expand Down
11 changes: 1 addition & 10 deletions packages/plugin-formula/src/register-custom-elem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -58,6 +48,7 @@ class WangEditorFormulaCard extends HTMLElement {
private render(value: string) {
katex.render(value, this.span, {
throwOnError: false,
output: 'mathml',
})
}
}
Expand Down

0 comments on commit b6af4f1

Please sign in to comment.