Added ability to include children in the json to addSvgElementFromJson().
This commit is contained in:
@@ -188,7 +188,7 @@ var selectedElements = [];
|
|||||||
// * curStyles - Boolean indicating that current style attributes should be applied first
|
// * curStyles - Boolean indicating that current style attributes should be applied first
|
||||||
//
|
//
|
||||||
// Returns: The new element
|
// 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);
|
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
|
// if shape is a path but we need to create a rect/ellipse, then remove the path
|
||||||
var current_layer = getCurrentDrawing().getCurrentLayer();
|
var current_layer = getCurrentDrawing().getCurrentLayer();
|
||||||
@@ -218,6 +218,12 @@ var addSvgElementFromJson = this.addSvgElementFromJson = function(data) {
|
|||||||
}
|
}
|
||||||
svgedit.utilities.assignAttributes(shape, data.attr, 100);
|
svgedit.utilities.assignAttributes(shape, data.attr, 100);
|
||||||
svgedit.utilities.cleanupElement(shape);
|
svgedit.utilities.cleanupElement(shape);
|
||||||
|
|
||||||
|
// Children
|
||||||
|
if(data.children) data.children.forEach(function(child){
|
||||||
|
shape.appendChild(addSvgElementFromJson(child));
|
||||||
|
});
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user