Guy Michael
Guy Michael

Reputation: 142

Monaco Editor: Manually trigger undo\redo from code

I have a React application in which I'm trying to manually call undo\redo from code on an instance of a Monaco editor. I want to do this so I can perform undo\redo when the editor is not in focus. I've searched the API and did not find a way, help would be appreciated :)

Upvotes: 2

Views: 3075

Answers (1)

gazorp
gazorp

Reputation: 96

You can call IEditor.trigger, and use undo or redo handlers.

Example, where editor implements IEditor:

// Undo
editor.trigger("myapp", "undo");

// Redo
editor.trigger("myapp", "redo");

Source: https://github.com/microsoft/monaco-editor/issues/451#issuecomment-305445971

Upvotes: 6

Related Questions