Skip to content

Commit

Permalink
Download diagram as SVG (Ericsson#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
intjftw authored Feb 23, 2022
1 parent 5e1c7a0 commit 8a6c4c4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions webgui/scripts/codecompass/view/diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,24 @@ function (declare, attr, dom, query, topic, BorderContainer, ContentPane,
priority : 30,
center : 'diagram'
});

var downloadImageButton = new Button({
label : 'Download image',
render : function () { return this; },
onClick : function () {
var element = document.createElement('a');
element.setAttribute('href',
'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(diagram._svg));
element.setAttribute('download', 'diagram.svg');
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
});

viewHandler.registerModule(downloadImageButton, {
type : viewHandler.moduleType.ContextButton,
priority : 40,
center : 'diagram'
});
});

0 comments on commit 8a6c4c4

Please sign in to comment.