Properly format SVG source from and to the editor
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@313 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
8e8f44861d
commit
d1a011d5d3
|
@ -32,7 +32,7 @@
|
|||
<div>
|
||||
<img class="tool_button" id="tool_clear" src="images/clear.png" title="New Image [N]" alt="Clear" />
|
||||
<img class="tool_button" id="tool_save" src="images/save.png" title="Save Image [S]" alt="Save"/>
|
||||
<!--img class="tool_button" id="tool_source" src="images/source.png" title="Edit Source [U]" alt="Source"/-->
|
||||
<img class="tool_button" id="tool_source" src="images/source.png" title="Edit Source [U]" alt="Source"/>
|
||||
</div>
|
||||
|
||||
<!-- History buttons -->
|
||||
|
|
|
@ -411,7 +411,6 @@ function svg_edit_setup() {
|
|||
};
|
||||
|
||||
// TODO: prevent 'u' from showing up in the textarea
|
||||
// TODO: prevent extra carriage returns
|
||||
// TODO: properly size the text area during resize
|
||||
// TODO: properly handle error conditions (error msg dialog)
|
||||
// TODO: prevent @style showing up on the svg element
|
||||
|
@ -420,7 +419,6 @@ function svg_edit_setup() {
|
|||
if (editingsource) return;
|
||||
editingsource = true;
|
||||
var str = svgCanvas.getSvgString();
|
||||
console.log(str);
|
||||
$('#svg_source_textarea').val(str);
|
||||
$('#svg_source_editor').fadeIn();
|
||||
properlySourceSizeTextArea();
|
||||
|
|
|
@ -545,7 +545,11 @@ function SvgCanvas(c)
|
|||
// this function only keeps what is allowed from our whitelist defined above
|
||||
var sanitizeSvg = function(node) {
|
||||
// we only care about element nodes
|
||||
// automatically return for all text, comment, etc nodes
|
||||
// automatically return for all comment, etc nodes
|
||||
// for text, we do a whitespace trim
|
||||
if (node.nodeType == 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
if (node.nodeType != 1) return;
|
||||
|
||||
var doc = node.ownerDocument;
|
||||
|
@ -617,9 +621,10 @@ function SvgCanvas(c)
|
|||
out.push("\n");
|
||||
out.push(svgToString(childs.item(i), indent));
|
||||
} else if (child.nodeType == 3) { // text node
|
||||
bOneLine = true;
|
||||
if (child.nodeValue != "") {
|
||||
out.push(child.nodeValue + "");
|
||||
var str = child.nodeValue.replace(/^\s+|\s+$/g, "");
|
||||
if (str != "") {
|
||||
bOneLine = true;
|
||||
out.push(str + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1338,7 +1343,6 @@ function SvgCanvas(c)
|
|||
// FIXME: after parsing in the new file, how do we synchronize getId()?
|
||||
this.setSvgString = function(xmlString) {
|
||||
try {
|
||||
console.log(xmlString);
|
||||
// convert string into XML document
|
||||
var newDoc = Utils.text2xml(xmlString);
|
||||
|
||||
|
|
Loading…
Reference in New Issue