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