This commit is contained in:
Ophir LOJKINE 2021-06-02 18:55:01 +02:00
parent c932c0f838
commit 259486b855

View file

@ -33,7 +33,7 @@
// Copy the stylesheets from the whiteboard to the exported SVG
styleNode.innerHTML = Array.from(document.styleSheets)
.filter(function (stylesheet) {
if(stylesheet.href && (stylesheet.href.match(/boards\/tools\/.*\.css/)
if (stylesheet.href && (stylesheet.href.match(/boards\/tools\/.*\.css/)
|| stylesheet.href.match(/board\.css/))) {
// This is a Stylesheet from a Tool or the Board itself, so we should include it
return true;
@ -45,28 +45,31 @@
return Array.from(stylesheet.cssRules).map(
function (rule) {
return rule.cssText
}
)}
).join("\n")
}
)
}
).join("\n")
canvasCopy.appendChild(styleNode);
downloadContent(new Blob([canvasCopy.outerHTML || new XMLSerializer().serializeToString(canvasCopy)], { type: 'image/svg+xml;charset=utf-8' }), Tools.boardName + ".svg")
var outerHTML = canvasCopy.outerHTML || new XMLSerializer().serializeToString(canvasCopy);
var blob = new Blob([outerHTML], { type: 'image/svg+xml;charset=utf-8' });
downloadContent(blob, Tools.boardName + ".svg");
}
function downloadContent(blob, filename){
if (window.navigator.msSaveBlob) {
function downloadContent(blob, filename) {
if (window.navigator.msSaveBlob) { // Internet Explorer
window.navigator.msSaveBlob(blob, filename);
} else {
} else {
const url = URL.createObjectURL(blob);
var element = document.createElement('a');
element.setAttribute('href', url);
element.setAttribute('download', filename);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
window.URL.revokeObjectURL(url);
}
}
}
Tools.add({ //The new tool