change d2-svg to class

This commit is contained in:
Alexander Wang 2025-01-26 14:31:29 -07:00
parent 9aea07e22c
commit 21c724c58d
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
3 changed files with 3 additions and 3 deletions

View file

@ -27,7 +27,7 @@ function init(reconnectDelay) {
const parsedXML = new DOMParser().parseFromString(msg.svg, "text/xml"); const parsedXML = new DOMParser().parseFromString(msg.svg, "text/xml");
d2SVG.replaceChildren(parsedXML.documentElement); d2SVG.replaceChildren(parsedXML.documentElement);
changeFavicon("/static/favicon.ico"); changeFavicon("/static/favicon.ico");
const svgEl = d2SVG.querySelector("#d2-svg"); const svgEl = d2SVG.querySelector(".d2-svg");
// just use inner SVG in watch mode // just use inner SVG in watch mode
svgEl.parentElement.replaceWith(svgEl); svgEl.parentElement.replaceWith(svgEl);
let width = parseInt(svgEl.getAttribute("width"), 10); let width = parseInt(svgEl.getAttribute("width"), 10);

View file

@ -68,7 +68,7 @@ func Wrap(rootDiagram *d2target.Diagram, svgs [][]byte, renderOpts d2svg.RenderO
) )
fmt.Fprint(buf, fitToScreenWrapperOpening) fmt.Fprint(buf, fitToScreenWrapperOpening)
innerOpening := fmt.Sprintf(`<svg id="d2-svg" width="%d" height="%d" viewBox="%d %d %d %d">`, innerOpening := fmt.Sprintf(`<svg class="d2-svg" width="%d" height="%d" viewBox="%d %d %d %d">`,
width, height, left, top, width, height) width, height, left, top, width, height)
fmt.Fprint(buf, innerOpening) fmt.Fprint(buf, innerOpening)

View file

@ -2123,7 +2123,7 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
xmlTag = `<?xml version="1.0" encoding="utf-8"?>` xmlTag = `<?xml version="1.0" encoding="utf-8"?>`
} }
fitToScreenWrapperClosing = "</svg>" fitToScreenWrapperClosing = "</svg>"
idAttr = `id="d2-svg"` idAttr = `class="d2-svg"`
tag = "svg" tag = "svg"
} }