Monaco-editor: Is there a way to set monaco-editor readonly?

Created on 8 Jul 2016  路  5Comments  路  Source: microsoft/monaco-editor

Hi,

I wonder if there is a way to disable editing i.e. enter into read only mode.

Thanks,

Most helpful comment

Sorry I found that we can pass readonly option while creating editor.

var editor = monaco.editor.create(element.nativeElement, {
    model: null,
    readOnly: true
});

All 5 comments

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 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.

Was this page helpful?
0 / 5 - 0 ratings