Skip to content

Instantly share code, notes, and snippets.

@samclarke
Created September 17, 2013 23:50
Show Gist options
  • Save samclarke/6602408 to your computer and use it in GitHub Desktop.
Save samclarke/6602408 to your computer and use it in GitHub Desktop.
$.sceditor.plugins.undomanager = function() {
var base = this;
base.init = function() {
// The this variable will be set to the instance of the editor calling it,
// hence why the plugins "this" is saved to the base variable.
// addShortcut is the easiest way to add handlers to specific shortcuts
this.addShortcut('ctrl+z', base.undo);
this.addShortcut('ctrl+shift+z', base.redo);
this.addShortcut('ctrl+y', base.redo);
};
base.undo = function() {
alert('Undo!');
// Prevent the default action
return false;
};
base.redo = function() {
alert('Redo!');
// Prevent the default action
return false;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment