Added ability to include children in the json to addSvgElementFromJson().

master
KB Jørgensen 2016-08-05 14:29:58 +02:00
parent 2246052141
commit b301acf716
1 changed files with 7 additions and 1 deletions

View File

@ -188,7 +188,7 @@ var selectedElements = [];
// * curStyles - Boolean indicating that current style attributes should be applied first
//
// Returns: The new element
var addSvgElementFromJson = this.addSvgElementFromJson = function(data) {
var addSvgElementFromJson = this.addSvgElementFromJson = function addSvgElementFromJson(data) {
var shape = svgedit.utilities.getElem(data.attr.id);
// if shape is a path but we need to create a rect/ellipse, then remove the path
var current_layer = getCurrentDrawing().getCurrentLayer();
@ -218,6 +218,12 @@ var addSvgElementFromJson = this.addSvgElementFromJson = function(data) {
}
svgedit.utilities.assignAttributes(shape, data.attr, 100);
svgedit.utilities.cleanupElement(shape);
// Children
if(data.children) data.children.forEach(function(child){
shape.appendChild(addSvgElementFromJson(child));
});
return shape;
};