monaco-editor

Monaco Editor: Custom Undo / Redo


I'm wondering how can we disable the default undo/redo stack and implement our own so that whenever the user press Ctrl-Z, customUndo() function is called.

I'm building a real-time code collaborator and reimplementing undo/redo action is needed.

I have been looking up the documentation and the issues page on Github but didn't find much relevant information.

Please help!

Thank you


Solution

  • editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_Z, function() {
       customUndo();
    });