fix(markdown): scope SVG download buttons to rendered diagrams

Only target SVGs inside .tikz / .mermaid containers so action-bar
icons (edit, save, freshness badge) no longer get download buttons.
This commit is contained in:
Julien Calixte
2026-05-16 12:57:16 +02:00
parent 0e70d808ce
commit 0ef339d42e

View File

@@ -169,12 +169,13 @@ const makeButton = (label: string, title: string, onClick: () => void): HTMLButt
return btn
}
const RENDERED_DIAGRAM_SELECTOR = ".tikz svg, .mermaid svg"
export const attachSvgDownloads = (scope: ParentNode | null | undefined): void => {
if (!scope) return
const svgs = scope.querySelectorAll<SVGSVGElement>("svg")
const svgs = scope.querySelectorAll<SVGSVGElement>(RENDERED_DIAGRAM_SELECTOR)
let index = 0
svgs.forEach((svg) => {
if (svg.closest(".svg-download-button")) return
if (svg.closest(".svg-download-host")) return
const host = document.createElement("span")