X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/7e4209de3c2972b1ca4ada5e3de85197365f58af..7509ad5d22654faa0abd75465de9f3fa632b1f3a:/src/smartxml/transformations.js?ds=sidebyside diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index f0b89f1..9aea150 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -87,21 +87,22 @@ toret.createGenericTransformation = function(desc, name) { }; _.extend(GenericTransformation.prototype, { name: name, - run: function() { + run: function(options) { var changeRoot; - if(!desc.undo) { + if(!desc.undo && options.beUndoable) { changeRoot = desc.getChangeRoot ? desc.getChangeRoot.call(this) : this.document.root; this.snapshot = changeRoot.clone(); this.changeRootPath = changeRoot.getPath(); } //var toret = desc.impl.call(this.context, this.args); // a argumenty do metody? - var toret = desc.impl.apply(this.context, this.args); + var argsToPass = desc.undo ? [this].concat(this.args) : this.args; + var toret = desc.impl.apply(this.context, argsToPass); this.hasRun = true; return toret; }, undo: function() { if(desc.undo) { - desc.undo.call(this.context); + desc.undo.call(this.context, this); } else { this.document.getNodeByPath(this.changeRootPath).replaceWith(this.snapshot); }