add d2-svg id on generation
This commit is contained in:
parent
070b50a6e2
commit
dfd66232fc
2 changed files with 3 additions and 4 deletions
|
|
@ -74,6 +74,7 @@ func setViewbox(writer io.Writer, diagram *d2target.Diagram, pad int) (width int
|
|||
// TODO background stuff. e.g. dotted, grid, colors
|
||||
fmt.Fprintf(writer, `<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg
|
||||
id="d2-svg"
|
||||
style="background: white;"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="%d" height="%d" viewBox="%d %d %d %d">`, w, h, tl.X-pad, tl.Y-pad, w, h)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const svgEl = document.querySelector("svg");
|
||||
const svgID = "d2-svg";
|
||||
svgEl.setAttribute("id", svgID);
|
||||
if (document.documentElement.getAttribute("id") !== svgID) {
|
||||
if (document.documentElement.getAttribute("id") !== "d2-svg") {
|
||||
return;
|
||||
}
|
||||
const svgEl = document.documentElement;
|
||||
let width = parseInt(svgEl.getAttribute("width"), 10);
|
||||
let height = parseInt(svgEl.getAttribute("height"), 10);
|
||||
let ratio;
|
||||
|
|
|
|||
Loading…
Reference in a new issue