fix(svg-export): workaround safari incompatiblity
This commit is contained in:
parent
c672e2e442
commit
6dee60e2ab
|
@ -17,9 +17,12 @@ require('./feature/movecanvas');
|
||||||
require('diagram-js/lib/features/selection/Visuals');
|
require('diagram-js/lib/features/selection/Visuals');
|
||||||
|
|
||||||
|
|
||||||
function getSvgNode(diagram) {
|
function getSvgContents(diagram) {
|
||||||
var paper = diagram.get('canvas').getPaper();
|
var paper = diagram.get('canvas').getPaper();
|
||||||
return paper.node;
|
var outerNode = paper.node.parentNode;
|
||||||
|
|
||||||
|
var svg = outerNode.innerHTML;
|
||||||
|
return svg.replace(/^<svg[^>]>|<\/svg>$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function initListeners(diagram, listeners) {
|
function initListeners(diagram, listeners) {
|
||||||
|
@ -131,10 +134,9 @@ Viewer.prototype.saveSVG = function(options, done) {
|
||||||
return done(new Error('no definitions loaded'));
|
return done(new Error('no definitions loaded'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var svgNode = getSvgNode(this.diagram);
|
var svgContents = getSvgContents(this.diagram);
|
||||||
var svg = svgNode.innerHTML;
|
|
||||||
|
|
||||||
svg = SVG_HEADER + svg + SVG_FOOTER;
|
var svg = SVG_HEADER + svgContents + SVG_FOOTER;
|
||||||
|
|
||||||
done(null, svg);
|
done(null, svg);
|
||||||
};
|
};
|
||||||
|
|
|
@ -88,6 +88,9 @@ describe('Viewer', function() {
|
||||||
expect(svg.indexOf(expectedStart)).toEqual(0);
|
expect(svg.indexOf(expectedStart)).toEqual(0);
|
||||||
expect(svg.indexOf(expectedEnd)).toEqual(svg.length - expectedEnd.length);
|
expect(svg.indexOf(expectedEnd)).toEqual(svg.length - expectedEnd.length);
|
||||||
|
|
||||||
|
// ensure correct rendering of SVG contents
|
||||||
|
expect(svg.indexOf('undefined')).toBe(-1);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue