X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/73e8795a3d19b7221f34353799d39808d57a4d05..b0bea8d363c03e64a67eb18c4e8702c69ecb72cc:/src/smartxml/smartxml.js diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index 47c527f..bf64c27 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -420,6 +420,7 @@ $.extend(Document.prototype, Backbone.Events, { transform: function(Transformation, args) { //console.log('transform'); var toret, transformation; + //debugger; // ref: odrebnie przygotowanie transformacji, odrebnie jej wykonanie (to pierwsze to analog transform z node) @@ -430,13 +431,15 @@ $.extend(Document.prototype, Backbone.Events, { } if(transformation) { this._transformationLevel++; - toret = transformation.run(); - if(this._transformationLevel === 1) { + toret = transformation.run({beUndoable:this._transformationLevel === 1}); + if(this._transformationLevel === 1 && !this._undoInProgress) { this.undoStack.push(transformation); } this._transformationLevel--; //console.log('clearing redo stack'); - this.redoStack = []; + if(!this._undoInProgress) { + this.redoStack = []; + } return toret; } else { throw new Error('Transformation ' + transformation + ' doesn\'t exist!'); @@ -445,15 +448,20 @@ $.extend(Document.prototype, Backbone.Events, { undo: function() { var transformation = this.undoStack.pop(); if(transformation) { + this._undoInProgress = true; transformation.undo(); + this._undoInProgress = false; this.redoStack.push(transformation); } }, redo: function() { var transformation = this.redoStack.pop(); if(transformation) { - transformation.run(); + this._transformationLevel++; + transformation.run({beUndoable: true}); + this._transformationLevel--; this.undoStack.push(transformation); + } },