From 4d745dc05b67151526f69b0e9321de42da5a1666 Mon Sep 17 00:00:00 2001 From: ibrierley Date: Thu, 16 Jul 2015 15:45:48 +0200 Subject: [PATCH 1/3] Fix for importing svg files where grabber just selects nothing as it doesnt know the svg to select --- editor/svg-editor.js | 6 ++++-- editor/svgcanvas.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 67ba44f9..b532698b 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -4745,7 +4745,7 @@ TODOS $('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom }) // Set default zoom .val(svgCanvas.getZoom() * 100); - +///EDITED $('#workarea').contextMenu({ menu: 'cmenu_canvas', inSpeed: 0 @@ -4904,12 +4904,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 773ba265..babfa1b8 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -5083,7 +5083,8 @@ this.importSvgString = function(xmlString) { return false; } - 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 From ea129f009e36469ca175223b2c73fef36230306d Mon Sep 17 00:00:00 2001 From: ibrierley Date: Thu, 16 Jul 2015 19:28:20 +0200 Subject: [PATCH 2/3] formatting --- editor/svg-editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index b532698b..bc0c2c1f 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -4745,7 +4745,7 @@ TODOS $('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom }) // Set default zoom .val(svgCanvas.getZoom() * 100); -///EDITED + $('#workarea').contextMenu({ menu: 'cmenu_canvas', inSpeed: 0 From f1b67e415905d0fd7b4fb9364507a5be8396f2b6 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 30 Sep 2015 11:24:16 +0100 Subject: [PATCH 3/3] Update svgcanvas.js Changed docs and return value to match if unsuccessful --- editor/svgcanvas.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index babfa1b8..0b7d60a8 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -4959,7 +4959,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) @@ -5080,7 +5080,7 @@ this.importSvgString = function(xmlString) { } catch(e) { console.log(e); - return false; + return null; } // we want to return the element so we can automatically select it