From: Aleksander Ɓukasz Date: Tue, 13 May 2014 09:57:17 +0000 (+0200) Subject: editor: plugins/core - undo/redo action support for restoring pre action canvas selection X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/f90725bd2dd63943756915116b9a5f743ab94616?ds=inline;hp=fb1b343bcfc05dbdd9f5d4d2d6ad9f243bb21300 editor: plugins/core - undo/redo action support for restoring pre action canvas selection If a valid/restorable fragment is available in a transaction metadata it gets passed to the callback where client code can handle selection restore. --- diff --git a/src/editor/plugins/core/core.js b/src/editor/plugins/core/core.js index 935b6d4..ba6229f 100644 --- a/src/editor/plugins/core/core.js +++ b/src/editor/plugins/core/core.js @@ -79,7 +79,17 @@ var undoRedoAction = function(dir) { icon: 'share-alt', iconStyle: dir === 'undo' ? '-webkit-transform: scale(-1,1); transform: scale(-1, 1)' : '', execute: function(callback, params) { + var metadata = _.last(params.document[dir+'Stack']).metadata, + fragment = metadata && metadata.fragment; params.document[dir](); + if(fragment) { + if(!fragment.isValid()) { + fragment.restoreFromPaths(); + } + if(fragment.isValid()) { + callback(fragment); + } + } callback(); }, },