From b301acf716135236cd13e67e5b7e47c51e85234d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KB=20J=C3=B8rgensen?= Date: Fri, 5 Aug 2016 14:29:58 +0200 Subject: [PATCH] Added ability to include children in the json to addSvgElementFromJson(). --- editor/svgcanvas.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 754745fc..d6604300 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -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; };