Merge pull request #208 from iuyiuy/setSvgString_without_undo
Add ability to set the svg drawing without adding to the undo stack.
This commit is contained in:
@@ -4456,10 +4456,13 @@ var convertToGroup = this.convertToGroup = function(elem) {
|
|||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// xmlString - The SVG as XML text.
|
// 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:
|
// Returns:
|
||||||
// This function returns false if the set was unsuccessful, true otherwise.
|
// This function returns false if the set was unsuccessful, true otherwise.
|
||||||
this.setSvgString = function(xmlString) {
|
this.setSvgString = function(xmlString, preventUndo) {
|
||||||
try {
|
try {
|
||||||
// convert string into XML document
|
// convert string into XML document
|
||||||
var newDoc = svgedit.utilities.text2xml(xmlString);
|
var newDoc = svgedit.utilities.text2xml(xmlString);
|
||||||
@@ -4613,7 +4616,7 @@ this.setSvgString = function(xmlString) {
|
|||||||
svgedit.path.clearData();
|
svgedit.path.clearData();
|
||||||
svgroot.appendChild(selectorManager.selectorParentGroup);
|
svgroot.appendChild(selectorManager.selectorParentGroup);
|
||||||
|
|
||||||
addCommandToHistory(batchCmd);
|
if (!preventUndo) addCommandToHistory(batchCmd);
|
||||||
call('changed', [svgcontent]);
|
call('changed', [svgcontent]);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user