From 4475f02586c053fc2f258395819bf28ecf5e72cc Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 17 Feb 2010 08:26:05 -0600 Subject: [PATCH] Fix SVG-Edit Regression "text" and "foreignObject" tools should not disable "line" and "freehand" tools. --- public/svg-edit/editor/svg-editor.js | 1 + public/svg-edit/editor/svgcanvas.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/public/svg-edit/editor/svg-editor.js b/public/svg-edit/editor/svg-editor.js index 0383caf8..837e45e0 100644 --- a/public/svg-edit/editor/svg-editor.js +++ b/public/svg-edit/editor/svg-editor.js @@ -666,6 +666,7 @@ function svg_edit_setup() { var updateToolbar = function() { if (selectedElement != null && selectedElement.tagName != "image" && + selectedElement.tagName != "text" && selectedElement.tagName != "foreignObject" && selectedElement.tagName != "g") { diff --git a/public/svg-edit/editor/svgcanvas.js b/public/svg-edit/editor/svgcanvas.js index 2e301b2d..6d276968 100644 --- a/public/svg-edit/editor/svgcanvas.js +++ b/public/svg-edit/editor/svgcanvas.js @@ -939,7 +939,8 @@ function BatchCommand(text) { '').documentElement, true); $(svgroot).appendTo(container); - + + // map namespace URIs to prefixes var nsMap = {}; nsMap[xlinkns] = 'xlink'; nsMap[xmlns] = 'xml'; @@ -947,13 +948,13 @@ function BatchCommand(text) { nsMap[se_ns] = 'se'; nsMap[htmlns] = 'xhtml'; nsMap[mathns] = 'mathml'; - + + // map prefixes to namespace URIs var nsRevMap = {}; $.each(nsMap, function(key,value){ nsRevMap[value] = key; }); - // Produce a Namespace-aware version of svgWhitelist var svgWhiteListNS = {}; $.each(svgWhiteList, function(elt,atts){ @@ -1332,10 +1333,11 @@ function BatchCommand(text) { var attrName = attr.nodeName; var attrLocalName = attr.localName; var attrNsURI = attr.namespaceURI; - //Check that an attribute with the correct localName in the correct namespace is on our whitelist - // or is a namespace declaration for one of our allowed namespaces + // Check that an attribute with the correct localName in the correct namespace is on + // our whitelist or is a namespace declaration for one of our allowed namespaces if (!(allowedAttrsNS.hasOwnProperty(attrLocalName) && attrNsURI == allowedAttrsNS[attrLocalName] && attrNsURI != xmlnsns) && - !(attrNsURI == xmlnsns && nsMap[attr.nodeValue]) ) { + !(attrNsURI == xmlnsns && nsMap[attr.nodeValue]) ) + { // Bypassing the whitelist to allow se: prefixes. Is there // a more appropriate way to do this? if(attrName.indexOf('se:') == 0) { @@ -1531,8 +1533,6 @@ function BatchCommand(text) { if (attrVal != "" && $.inArray(attr.localName, ['width','height','xmlns','x','y','viewBox','id','overflow']) == -1) { - // map various namespaces to our fixed namespace prefixes - // (the default xmlns attribute itself does not get a prefix) if(!attr.namespaceURI || nsMap[attr.namespaceURI]) { out.push(' '); out.push(attr.nodeName); out.push("=\""); out.push(attrVal); out.push("\""); @@ -7721,7 +7721,7 @@ function BatchCommand(text) { // Function: getVersion // Returns a string which describes the revision number of SvgCanvas. this.getVersion = function() { - return "svgcanvas.js ($Rev: 1394 $)"; + return "svgcanvas.js ($Rev: 1396 $)"; }; this.setUiStrings = function(strs) {