This commit is contained in:
Jerry
2026-01-15 23:28:14 +08:00
parent 2c5e8c7cbb
commit e4597deded
2 changed files with 21 additions and 16 deletions

View File

@@ -61,14 +61,19 @@ script.
const serializer = new XMLSerializer()
const svgSource = serializer.serializeToString(clone)
const blob = new Blob([svgSource], { type: 'image/svg+xml;charset=utf-8' })
const htmlSource = `<!doctype html><html><head><meta charset="utf-8" />
<style>
html, body { width: 100%; height: 100%; margin: 0; display: flex; align-items: center; justify-content: center; background: ${bg}; }
svg { max-width: 100%; max-height: 100%; height: auto; width: auto; }
</style>
</head><body>${svgSource}</body></html>`
const blob = new Blob([htmlSource], { type: 'text/html;charset=utf-8' })
const url = URL.createObjectURL(blob)
window.open(url, '_blank', 'noopener')
setTimeout(() => URL.revokeObjectURL(url), 30000)
}
const attachMermaidViewerButton = wrap => {
const originalSvg = wrap.__mermaidOriginalSvg
let btn = wrap.querySelector('.mermaid-open-btn')
if (!btn) {
btn = document.createElement('button')
@@ -83,7 +88,7 @@ script.
btn.addEventListener('click', e => {
e.preventDefault()
e.stopPropagation()
const svg = originalSvg || wrap.querySelector('svg')
const svg = wrap.__mermaidOriginalSvg || wrap.querySelector('svg')
if (!svg) return
const initViewBox = wrap.__mermaidInitViewBox
if (typeof svg === 'string') {