Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*
* MIT licensed.
*/
(function() {

// based on Backbone.js' inherits
var ctor = function(){};
Expand Down Expand Up @@ -52,17 +51,19 @@ Undo.Stack = function() {
};

extend(Undo.Stack.prototype, {
execute: function(command) {
execute: async function(command) {
this._clearRedo();
command.execute();
await command.execute();
this.commands.push(command);
this.stackPosition++;
this.changed();
},
undo: function() {
this.commands[this.stackPosition].undo();
this.stackPosition--;
this.changed();
undo: async function() {
if (this.canUndo()) {
await this.commands[this.stackPosition].undo();
this.stackPosition--;
this.changed();
}
},
canUndo: function() {
return this.stackPosition >= 0;
Expand Down Expand Up @@ -115,13 +116,4 @@ Undo.Command.extend = function(protoProps) {
return child;
};

// AMD support
if (typeof define === "function" && define.amd) {
// Define as an anonymous module
define(Undo);
} else if(typeof module != "undefined" && module.exports){
module.exports = Undo
}else {
this.Undo = Undo;
}
}).call(this);
export default Undo;