()
| 12 | constructor(public markdown: string, public muya?: Muya) {} |
| 13 | |
| 14 | async renderMermaid() { |
| 15 | const codes = this._exportContainer!.querySelectorAll( |
| 16 | 'code.language-mermaid', |
| 17 | ); |
| 18 | for (const code of codes) { |
| 19 | const preEle = code.parentNode; |
| 20 | if (!isHTMLElement(preEle)) |
| 21 | continue; |
| 22 | const mermaidContainer = document.createElement('div'); |
| 23 | mermaidContainer.innerHTML = sanitize( |
| 24 | unescapeHTML(code.innerHTML), |
| 25 | EXPORT_DOMPURIFY_CONFIG, |
| 26 | true, |
| 27 | ) as string; |
| 28 | mermaidContainer.classList.add('mermaid'); |
| 29 | preEle.replaceWith(mermaidContainer); |
| 30 | } |
| 31 | const mermaid = await loadRenderer('mermaid'); |
| 32 | // We only export light theme, so set mermaid theme to `default`, in the future, we can choose which theme to export. |
| 33 | mermaid.initialize({ |
| 34 | startOnLoad: false, |
| 35 | securityLevel: 'strict', |
| 36 | theme: 'default', |
| 37 | }); |
| 38 | await mermaid.run({ |
| 39 | nodes: [...this._exportContainer!.querySelectorAll('div.mermaid')], |
| 40 | }); |
| 41 | if (this.muya) { |
| 42 | mermaid.initialize({ |
| 43 | securityLevel: 'strict', |
| 44 | theme: this.muya.options.mermaidTheme, |
| 45 | }); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | async renderDiagram() { |
| 50 | const selector |
no test coverage detected