摩纳哥编辑器复制/剪切/粘贴操作

Web*_*san 4 javascript monaco-editor

我正在为我的项目使用monaco 编辑器,我可以为撤消/重做操作发出编辑器事件,如下所示:

editor.getModel().redo();
editor.getModel().undo();
Run Code Online (Sandbox Code Playgroud)

这是一个非常常见的编辑器,所以我认为也应该有剪切/复制/粘贴操作,但不幸的是,我没有看到类似的操作,如 editor.getModel().cut.. 等

我错过了什么?

Gil*_*Gil 5

您可以触发编辑器操作来复制/粘贴:

editorInstance.trigger('source','editor.action.clipboardCopyAction');
editorInstance.trigger('source','editor.action.clipboardPasteAction');
Run Code Online (Sandbox Code Playgroud)

可用的操作可以列出: editorInstance.getActions().map(a => a.id)

我仍然没有弄清楚 trigger 的第一个参数有什么影响,所以我只是提供了一个字符串,表明是什么触发了操作。