Skip to content

Commit

Permalink
Add stylesheets from document instead of manually specifying them
Browse files Browse the repository at this point in the history
Co-authored-by: sents
  • Loading branch information
DanielHabenicht authored May 28, 2021
1 parent cf981aa commit 9c507ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client-data/tools/download/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
function downloadSVGFile(evt) {
var canvasCopy = Tools.svg.cloneNode(true);
var styleNode = document.createElement("style");
styleNode.innerHTML = "rect, ellipse { fill:none; } path, line {fill: none;stroke-linecap: round; stroke-linejoin: round;}";

// Copy the stylesheets from the whiteboard to the exported SVG
stylesheets = document.styleSheets;
styleText = "";
Array.from(stylesheets).forEach(stylesheet => {
styleText += "\n" + Array.from(stylesheet.cssRules).map(x => x.cssText).join("\n");
});
styleNode.innerHTML = styleText;
canvasCopy.appendChild(styleNode);
downloadContent('data:image/svg+xml;charset=utf-8,' + encodeURIComponent(canvasCopy.outerHTML), "svg")
}
Expand Down

0 comments on commit 9c507ac

Please sign in to comment.