Fix SVG-Edit Regression

"text" and "foreignObject" tools should not
disable "line" and "freehand" tools.
This commit is contained in:
Jacques Distler 2010-02-17 08:26:05 -06:00
parent db5b418659
commit 4475f02586
2 changed files with 10 additions and 9 deletions

View file

@ -666,6 +666,7 @@ function svg_edit_setup() {
var updateToolbar = function() { var updateToolbar = function() {
if (selectedElement != null && if (selectedElement != null &&
selectedElement.tagName != "image" && selectedElement.tagName != "image" &&
selectedElement.tagName != "text" &&
selectedElement.tagName != "foreignObject" && selectedElement.tagName != "foreignObject" &&
selectedElement.tagName != "g") selectedElement.tagName != "g")
{ {

View file

@ -939,7 +939,8 @@ function BatchCommand(text) {
'</svg>').documentElement, true); '</svg>').documentElement, true);
$(svgroot).appendTo(container); $(svgroot).appendTo(container);
// map namespace URIs to prefixes
var nsMap = {}; var nsMap = {};
nsMap[xlinkns] = 'xlink'; nsMap[xlinkns] = 'xlink';
nsMap[xmlns] = 'xml'; nsMap[xmlns] = 'xml';
@ -947,13 +948,13 @@ function BatchCommand(text) {
nsMap[se_ns] = 'se'; nsMap[se_ns] = 'se';
nsMap[htmlns] = 'xhtml'; nsMap[htmlns] = 'xhtml';
nsMap[mathns] = 'mathml'; nsMap[mathns] = 'mathml';
// map prefixes to namespace URIs
var nsRevMap = {}; var nsRevMap = {};
$.each(nsMap, function(key,value){ $.each(nsMap, function(key,value){
nsRevMap[value] = key; nsRevMap[value] = key;
}); });
// Produce a Namespace-aware version of svgWhitelist // Produce a Namespace-aware version of svgWhitelist
var svgWhiteListNS = {}; var svgWhiteListNS = {};
$.each(svgWhiteList, function(elt,atts){ $.each(svgWhiteList, function(elt,atts){
@ -1332,10 +1333,11 @@ function BatchCommand(text) {
var attrName = attr.nodeName; var attrName = attr.nodeName;
var attrLocalName = attr.localName; var attrLocalName = attr.localName;
var attrNsURI = attr.namespaceURI; var attrNsURI = attr.namespaceURI;
//Check that an attribute with the correct localName in the correct namespace is on our whitelist // Check that an attribute with the correct localName in the correct namespace is on
// or is a namespace declaration for one of our allowed namespaces // our whitelist or is a namespace declaration for one of our allowed namespaces
if (!(allowedAttrsNS.hasOwnProperty(attrLocalName) && attrNsURI == allowedAttrsNS[attrLocalName] && attrNsURI != xmlnsns) && 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 // Bypassing the whitelist to allow se: prefixes. Is there
// a more appropriate way to do this? // a more appropriate way to do this?
if(attrName.indexOf('se:') == 0) { if(attrName.indexOf('se:') == 0) {
@ -1531,8 +1533,6 @@ function BatchCommand(text) {
if (attrVal != "" && if (attrVal != "" &&
$.inArray(attr.localName, ['width','height','xmlns','x','y','viewBox','id','overflow']) == -1) $.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]) { if(!attr.namespaceURI || nsMap[attr.namespaceURI]) {
out.push(' '); out.push(attr.nodeName); out.push("=\""); out.push(' '); out.push(attr.nodeName); out.push("=\"");
out.push(attrVal); out.push("\""); out.push(attrVal); out.push("\"");
@ -7721,7 +7721,7 @@ function BatchCommand(text) {
// Function: getVersion // Function: getVersion
// Returns a string which describes the revision number of SvgCanvas. // Returns a string which describes the revision number of SvgCanvas.
this.getVersion = function() { this.getVersion = function() {
return "svgcanvas.js ($Rev: 1394 $)"; return "svgcanvas.js ($Rev: 1396 $)";
}; };
this.setUiStrings = function(strs) { this.setUiStrings = function(strs) {