diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 4bde4ec3..9a273341 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -53,7 +53,7 @@ function svg_edit_setup() { // upon creation of a text element the editor is switched into // select mode and this event fires - we need our UI to be in sync - is_node = selectedElement.id && selectedElement.id.indexOf('pathpointgrip') == 0; + is_node = !!(selectedElement.id && selectedElement.id.indexOf('pathpointgrip') == 0); if (svgCanvas.getMode() != "multiselect" && !is_node) { setSelectMode(); diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 7eeafea3..b459335c 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -3907,6 +3907,7 @@ function BatchCommand(text) { this.setResolution = function(x, y) { var res = canvas.getResolution(); var w = res.w, h = res.h; + var batchCmd; if(x == 'fit') { canvas.clearSelection(); @@ -3915,15 +3916,17 @@ function BatchCommand(text) { var bbox = canvas.getStrokedBBox(); if(bbox) { + batchCmd = new BatchCommand("Fit Canvas to Content"); canvas.addToSelection(canvas.getVisibleElements()); $.each(selectedElements, function(i, item) { var sel_bb = item.getBBox(); - recalculateDimensions(item, { + var cmd = recalculateDimensions(item, { x: sel_bb.x - bbox.x, y: sel_bb.y - bbox.y, width: sel_bb.width, height: sel_bb.height }); + batchCmd.addSubCommand(cmd); }); canvas.clearSelection(); x = Math.round(bbox.width); @@ -3936,7 +3939,9 @@ function BatchCommand(text) { y *= current_zoom; if (x != w || y != h) { var handle = svgroot.suspendRedraw(1000); - var batchCmd = new BatchCommand("Change Image Dimensions"); + if(!batchCmd) { + batchCmd = new BatchCommand("Change Image Dimensions"); + } svgroot.setAttribute('width', x); svgroot.setAttribute('height', y); batchCmd.addSubCommand(new ChangeElementCommand(svgroot, {"width":w, "height":h}));