Skip to content
Snippets Groups Projects
Commit 594da506 authored by Quentin Bolsee's avatar Quentin Bolsee
Browse files

SVG download

parent 13fdb85e
Branches
Tags
No related merge requests found
......@@ -23,7 +23,7 @@
<div>
<!-- <button class="interface" id="loadButton">Load file(s)...</button></input> -->
<button class="interface" id="downloadRenderButton">Download render</button>
<button class="interface" id="downloadlayersButton">Download layers</button>
<!-- <button class="interface" id="downloadlayersButton">Download layers</button> -->
</div>
</div>
<div class="panel">
......@@ -37,7 +37,7 @@
</div>
<div>
<input type="checkbox" id="settingsAsSVG" checked=unchecked>
<input type="checkbox" id="settingsAsSVG" disabled="true" checked=checked>
<label for="settingsAsSVG">Download as SVG</label>
</div>
......
......@@ -217,7 +217,18 @@ function downloadImage(separateLayers=false) {
return;
}
saveSvg.saveSvgAsPng(svgElem, "diagram.png");
let svgTxt = new XMLSerializer().serializeToString(svgElem);
let url = "data:image/svg+xml;charset=utf-8,"+encodeURIComponent(svgTxt);
let downloadLink = document.createElement("a");
downloadLink.href = url;
downloadLink.download = "render.svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
// window.URL.revokeObjectURL(url);
// document.getElementById("link").href = url;
// saveSvg.saveSvgAsPng(svgElem, "diagram.png");
// if (isNaN(globalSettings.svgDim[0])) {
// return;
// }
......@@ -452,9 +463,9 @@ document.getElementById("downloadRenderButton").addEventListener("click", () =>
downloadImage(false);
});
document.getElementById("downloadlayersButton").addEventListener("click", () => {
downloadImage(true);
});
// document.getElementById("downloadlayersButton").addEventListener("click", () => {
// downloadImage(true);
// });
readSettings();
initListeners();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment