Thanks a lot for the fast answer!
Unfortunately there is very little information about this event. Even the w3c spec only mentions them briefly: https://www.w3.org/TR/input-events-2/ (search for historyUndo
)
This is what works for me in Chrome / Electron:
handleDOMEvents: {
beforeinput: (view, event) => {
switch (event.inputType) {
case 'historyUndo':
this.execCommand('undo');
event.preventDefault();
return true;
case 'historyRedo':
this.execCommand('redo');
event.preventDefault();
return true;
default:
return false;
}
}
}
Please note that beforeinput
currently is only supported in WebKit based browsers.
As I mentioned, the redo button does not work with the above approach, because it thinks that the history is empty. My hope is that I can somehow trick the native undo history to think there is something on the undo-stack.
But for now I’m wondering if we should catch historyUndo
by default. The faulty behavior of the native input event is pretty confusing.
I will report in this thread when I find an approach to trick the undo history.