Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monaco editor copy/cut/paste action

I'm using monaco editor for my project and I can be able to emit editor events for undo/redo actions like so:

editor.getModel().redo();
editor.getModel().undo();

This is a very common editor, so I think there should be cut/copy/pase actions also, but unfortunately, I don't see similar actions like editor.getModel().cut.. e.t.c.

What have I missed?

like image 471
WebArtisan Avatar asked Jan 03 '23 10:01

WebArtisan


1 Answers

You can trigger editor actions to copy/paste:

editorInstance.trigger('source','editor.action.clipboardCopyAction');
editorInstance.trigger('source','editor.action.clipboardPasteAction');

Actions available can be listed with: editorInstance.getActions().map(a => a.id)

I still haven't figured out what effect the first argument to trigger has, so I have simply provided a string that suggests what triggered the action.

like image 152
Gil Avatar answered Jan 15 '23 19:01

Gil