From 07803fd1db1992f7854a6e219b126ba6352c895e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KB=20J=C3=B8rgensen?= Date: Mon, 22 Jan 2018 11:37:42 +0100 Subject: [PATCH 1/3] Add ability to set the svg drawing without adding to the undo stack. --- editor/svgcanvas.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index ec49107c..71054e8d 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -4442,7 +4442,7 @@ var convertToGroup = this.convertToGroup = function(elem) { // // Returns: // This function returns false if the set was unsuccessful, true otherwise. -this.setSvgString = function(xmlString) { +this.setSvgString = function(xmlString, preventUndo) { try { // convert string into XML document var newDoc = svgedit.utilities.text2xml(xmlString); @@ -4596,7 +4596,7 @@ this.setSvgString = function(xmlString) { svgedit.path.clearData(); svgroot.appendChild(selectorManager.selectorParentGroup); - addCommandToHistory(batchCmd); + if(!preventUndo) addCommandToHistory(batchCmd); call('changed', [svgcontent]); } catch(e) { console.log(e); From d3ed6cbb8c3ee4469c33830a7d7d76b6f80e1382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KB=20J=C3=B8rgensen?= Date: Fri, 26 Jan 2018 14:59:39 +0100 Subject: [PATCH 2/3] Changed code style as requested in svgedit pull request #208. --- editor/svgcanvas.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 71054e8d..152bd0d9 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -3817,7 +3817,7 @@ this.svgToString = function(elem, indent) { var el = this; // for some elements have no attribute var uri = this.namespaceURI; - if(uri && !nsuris[uri] && nsMap[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml' ) { + if (uri && !nsuris[uri] && nsMap[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml' ) { nsuris[uri] = true; out.push(' xmlns:' + nsMap[uri] + '="' + uri +'"'); } @@ -4596,7 +4596,7 @@ this.setSvgString = function(xmlString, preventUndo) { svgedit.path.clearData(); svgroot.appendChild(selectorManager.selectorParentGroup); - if(!preventUndo) addCommandToHistory(batchCmd); + if (!preventUndo) addCommandToHistory(batchCmd); call('changed', [svgcontent]); } catch(e) { console.log(e); From 64759a8cab150ab77ff4d79194acdc265ccb6631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KB=20J=C3=B8rgensen?= Date: Tue, 27 Feb 2018 11:21:07 +0100 Subject: [PATCH 3/3] Added documentation for the preventUndo parameter in the svgcanvas.setSvgString() function. --- editor/svgcanvas.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 152bd0d9..0ae24687 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -4439,6 +4439,9 @@ var convertToGroup = this.convertToGroup = function(elem) { // // Parameters: // xmlString - The SVG as XML text. +// preventUndo - Boolean (defaults to false) indicating if we want to do the +// changes without adding them to the undo stack - e.g. for initializing a +// drawing on page load. // // Returns: // This function returns false if the set was unsuccessful, true otherwise.