From 92f6ff06802976ff8796687e675ce1bed43a2d81 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Tue, 16 Jun 2009 02:39:12 +0000 Subject: [PATCH] Fix Issue 23: Freehand rect/ellipse tools no longer working git-svn-id: http://svg-edit.googlecode.com/svn/trunk@129 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 6b4d6bdb..51dc3709 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -517,6 +517,7 @@ function SvgCanvas(c) "fill-opacity": current_fill_opacity } })); + keep = true; } break; case "fhrect": @@ -539,6 +540,7 @@ function SvgCanvas(c) "fill-opacity": current_fill_opacity } })); + keep = true; } break; case "text": @@ -679,11 +681,17 @@ function SvgCanvas(c) this.updateElementFromJson = function(data) { var shape = svgdoc.getElementById(data.attr.id); - var newshape = !shape; - if (newshape) shape = svgdoc.createElementNS(svgns, data.element); + // if shape is a path but we need to create a rect/ellipse, then remove the path + if (shape && data.element !== shape.tagName) { + svgroot.removeChild(shape); + shape = null; + } + if (!shape) { + shape = svgdoc.createElementNS(svgns, data.element); + svgroot.appendChild(shape); + } assignAttributes(shape, data.attr); cleanupElement(shape); - if (newshape) svgroot.appendChild(shape); return shape; }