From e4597dededf0852cf331c05250e8d1859ad34f36 Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 15 Jan 2026 23:28:14 +0800 Subject: [PATCH] update --- layout/includes/third-party/math/mermaid.pug | 11 ++++++--- source/css/_layout/third-party.styl | 26 ++++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/layout/includes/third-party/math/mermaid.pug b/layout/includes/third-party/math/mermaid.pug index 8b62cd7..148d18f 100644 --- a/layout/includes/third-party/math/mermaid.pug +++ b/layout/includes/third-party/math/mermaid.pug @@ -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 = ` + + ${svgSource}` + 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') { diff --git a/source/css/_layout/third-party.styl b/source/css/_layout/third-party.styl index 676743f..cc7ff8d 100644 --- a/source/css/_layout/third-party.styl +++ b/source/css/_layout/third-party.styl @@ -67,29 +67,29 @@ if hexo-config('mermaid.enable') .mermaid-wrap position: relative margin: 0 0 20px - text-align: center background: var(--card-bg) + text-align: center .mermaid-open-btn position: absolute top: 8px right: 8px z-index: 2 + display: flex + justify-content: center + align-items: center + padding: 0 width: 34px height: 25px - padding: 0 border: none border-radius: 20% - display: flex - align-items: center - justify-content: center + background: #D3D3D3 + box-shadow: 0 4px 10px rgba(0, 0, 0, .15) + color: #fff font-size: 0 line-height: 1 - background: #D3D3D3 - color: #fff cursor: pointer - box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15) - transition: background 0.2s ease, transform 0.2s ease + transition: background .2s ease, transform .2s ease i font-size: 16px @@ -97,16 +97,16 @@ if hexo-config('mermaid.enable') &:hover, &:focus-visible - transform: translateY(-1px) - background: #C0C0C0 outline: none + background: #C0C0C0 + transform: translateY(-1px) & > svg - height: 100% max-width: 100% + height: 100% cursor: grab - touch-action: none user-select: none + touch-action: none &:active cursor: grabbing