diff --git a/lib/Viewer.js b/lib/Viewer.js index 5f01bf5e..144a8076 100644 --- a/lib/Viewer.js +++ b/lib/Viewer.js @@ -20,6 +20,48 @@ Viewer.prototype.importXML = function(xml, done) { }); }; +Viewer.prototype.saveXML = function(options, done) { + + if (!done) { + done = options; + options = {}; + } + + var definitions = this.definitions; + + if (!definitions) { + return done(new Error('no definitions loaded')); + } + + Model.toXML(definitions, options, function(err, xml) { + done(err, xml); + }); +}; + + +var SVG_HEADER = +'\n' + +'\n' + +'\n' + +'\n'; + +Viewer.prototype.saveSVG = function(options, done) { + if (!done) { + done = options; + options = {}; + } + + if (!this.definitions) { + return done(new Error('no definitions loaded')); + } + + var svg = this.container.innerHTML; + + svg = svg.replace(/]+>/, SVG_HEADER); + + done(null, svg); +}; + Viewer.prototype.importDefinitions = function(definitions, done) { if (this.diagram) {