Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use setValue in Monaco editor?

What is the proper way of setting a Monaco editors text content, without worrying about the undo stack? monacoEditor.setValue("text") seems to crash somewhere deep inside:

vue.esm.js?efeb:1741 TypeError: (intermediate value)(intermediate value)(intermediate value).create is not a function
    at D (textModel.ts:90)
    at f.setValue (textModel.ts:385)
    at t.setValue (commonCodeEditor.ts:211)
    at VueComponent.loadFile (ResourceViewer.vue?d447:85)
like image 657
Vadim Peretokin Avatar asked Dec 23 '22 07:12

Vadim Peretokin


1 Answers

For the future traveler from google, the following code works for 0.2.0, after you have initialized the editor:

editor.getModel().setValue('some value');
like image 109
Adnan Y Avatar answered Jan 24 '23 20:01

Adnan Y