mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-10 06:24:17 +00:00
format
This commit is contained in:
parent
c932c0f838
commit
259486b855
1 changed files with 13 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue