Hi,
I wonder if there is a way to disable editing i.e. enter into read only mode.
Thanks,
Sorry I found that we can pass readonly option while creating editor.
var editor = monaco.editor.create(element.nativeElement, {
model: null,
readOnly: true
});
Has anyone seen a reliable way to change this post-creation?
@James9074 try this action on the code editor:
https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.icodeeditor.html#updateoptions
and then check out readonly here:
https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditoroptions.html
@James9074 editorInstance.updateOptions({ readOnly: true }) or editorInstance.updateOptions({ readOnly: false }) as @andyg8180 mentions will do the trick.
Hey that actually worked! Thanks @elAndyG and @alexandrudima. I was getting caught up in the doc's typing and forgot I could just pass a json object into updateOptions to make that work.
Most helpful comment
Sorry I found that we can pass
readonlyoption while creating editor.