diff --git a/editor/svg-editor.js b/editor/svg-editor.js index c3274b97..edf1ceac 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -4906,12 +4906,14 @@ TODOS if (file.type.indexOf('svg') != -1) { reader = new FileReader(); reader.onloadend = function(e) { - svgCanvas.importSvgString(e.target.result, true); + var newElement = svgCanvas.importSvgString(e.target.result, true); svgCanvas.ungroupSelectedElement(); svgCanvas.ungroupSelectedElement(); svgCanvas.groupSelectedElements(); svgCanvas.alignSelectedElements('m', 'page'); svgCanvas.alignSelectedElements('c', 'page'); + // highlight imported element, otherwise we get strange empty selectbox + svgCanvas.selectOnly([newElement]); $('#dialog_box').hide(); }; reader.readAsText(file); diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 0bb58bc1..3f2cf464 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -4946,7 +4946,7 @@ this.setSvgString = function(xmlString) { // xmlString - The SVG as XML text. // // Returns: -// This function returns false if the import was unsuccessful, true otherwise. +// This function returns null if the import was unsuccessful, or the element otherwise. // TODO: // * properly handle if namespace is introduced by imported content (must add to svgcontent // and update all prefixes in the imported node) @@ -5067,10 +5067,11 @@ this.importSvgString = function(xmlString) { } catch(e) { console.log(e); - return false; + return null; } - return true; + // we want to return the element so we can automatically select it + return use_el; }; // TODO(codedread): Move all layer/context functions in draw.js