From fb54e70a6b4c9053a5813d804e8b0b332667234f Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Tue, 13 Oct 2009 00:51:15 +0000 Subject: [PATCH] Fix Issue 273: preserve whitespace in text elements git-svn-id: http://svg-edit.googlecode.com/svn/trunk@807 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index c7d1e735..06a57369 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -25,7 +25,7 @@ var svgWhiteList = { "rect": ["fill", "fill-opacity", "height", "id", "opacity", "rx", "ry", "stroke", "stroke-dasharray", "stroke-linecap", "stroke-linejoin", "stroke-opacity", "stroke-width", "transform", "width", "x", "y"], "stop": ["id", "offset", "stop-color", "stop-opacity"], "svg": ["id", "height", "transform", "viewBox", "width", "xmlns", "xmlns:xlink"], - "text": ["fill", "fill-opacity", "font-family", "font-size", "font-style", "font-weight", "id", "opacity", "stroke", "stroke-dasharray", "stroke-linecap", "stroke-linejoin", "stroke-opacity", "stroke-width", "transform", "text-anchor", "x", "y"], + "text": ["fill", "fill-opacity", "font-family", "font-size", "font-style", "font-weight", "id", "opacity", "stroke", "stroke-dasharray", "stroke-linecap", "stroke-linejoin", "stroke-opacity", "stroke-width", "transform", "text-anchor", "x", "xml:space", "y"], "title": [], }; @@ -555,7 +555,8 @@ function BatchCommand(text) { var handle = svgroot.suspendRedraw(suspendLength); for (i in attrs) { - node.setAttributeNS(null, i, attrs[i]); + var ns = (i.substr(0,4) == "xml:" ? "http://www.w3.org/XML/1998/namespace" : null); + node.setAttributeNS(ns, i, attrs[i]); } svgroot.unsuspendRedraw(handle); @@ -1654,7 +1655,8 @@ function BatchCommand(text) { "font-size": cur_text.font_size, "font-family": cur_text.font_family, "text-anchor": "middle", - "style": "pointer-events:inherit" + "style": "pointer-events:inherit", + "xml:space": "preserve" } }); newText.textContent = "text";