remove fit to screen script
This commit is contained in:
parent
6374223365
commit
45e58fdca5
2 changed files with 1 additions and 26 deletions
|
|
@ -1448,9 +1448,6 @@ func appendOnTrigger(buf *bytes.Buffer, source string, triggers []string, newCon
|
|||
}
|
||||
}
|
||||
|
||||
//go:embed fitToScreen.js
|
||||
var fitToScreenScript string
|
||||
|
||||
const DEFAULT_THEME int64 = 0
|
||||
|
||||
var DEFAULT_DARK_THEME *int64 = nil // no theme selected
|
||||
|
|
@ -1548,9 +1545,7 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
fmt.Fprintf(upperBuf, `<style type="text/css"><![CDATA[%s%s]]></style>`, baseStylesheet, themeStylesheet)
|
||||
// this script won't run in --watch mode because script tags are ignored when added via el.innerHTML = element
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
|
||||
fmt.Fprintf(upperBuf, `<script type="application/javascript"><![CDATA[%s]]></script>`, fitToScreenScript)
|
||||
|
||||
hasMarkdown := false
|
||||
for _, s := range diagram.Shapes {
|
||||
if s.Label != "" && s.Type == d2target.ShapeText {
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
window.addEventListener("DOMContentLoaded", () => {
|
||||
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;
|
||||
if (width > height) {
|
||||
if (width > window.innerWidth) {
|
||||
ratio = window.innerWidth / width;
|
||||
}
|
||||
} else if (height > window.innerHeight) {
|
||||
ratio = window.innerHeight / height;
|
||||
}
|
||||
if (ratio) {
|
||||
svgEl.setAttribute("width", width * ratio - 16);
|
||||
svgEl.setAttribute("height", height * ratio - 16);
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue