Open jagaxa opened 2 years ago
This should really be part of the undo plugin so I'll leave this issue open.
For now, adding a method to the editor in the undo plugin init should work. Something like:
editor.clearUndo = function () {
undoStates = [];
redoPosition = 0;
storeState();
};
Full file: https://gist.github.com/samclarke/4a53460692a0d8ecc55eadca861dbd57
Can then be called with:
instance.clearUndo();
I suggest also to add support to undo/redo commands (the translations already contains those keywords even if not used..) I did it this way:
.sceditor-button-undo div{background-position:0 -659px} .sceditor-button-redo div{background-position:0 -675px}
var utils = sceditor.utils;
added this code to the plugin init method: ` var commands = this.commands;
commands.undo = utils.extend(commands.undo || {}, {
state: function () {
return redoPosition < undoStates.length - 1 ? 0 : -1;
},
exec: function () {
base.undo();
},
tooltip: 'Undo'
});
commands.redo = utils.extend(commands.redo || {}, {
state: function () {
return redoPosition > 0 ? 0 : -1;
},
exec: function () {
base.redo();
},
tooltip: 'Redo'
});
editor.resetUndo = function() {
undoStates = [];
redoPosition = 0;
storeState();
}
`
I'm currently using the undo plugin. Is there any way to clear the undo history after I empty the editor using
.val("")
?If not, how can I implement something like