[英]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.我有一个 React 应用程序,我在其中尝试从 Monaco 编辑器实例上的代码手动调用 undo\redo。 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:)
我搜索了 API 并没有找到方法,不胜感激:)
You can call IEditor.trigger
, and use undo
or redo
handlers.您可以调用
IEditor.trigger
并使用undo
或redo
处理程序。
Example, where editor
implements IEditor
:示例,其中
editor
实现IEditor
:
// Undo
editor.trigger("myapp", "undo");
// Redo
editor.trigger("myapp", "redo");
Source: https://github.com/microsoft/monaco-editor/issues/451#issuecomment-305445971来源: https://github.com/microsoft/monaco-editor/issues/451#issuecomment-305445971
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.