Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to set monaco-editor readonly? #54

Closed
uadnan opened this issue Jul 8, 2016 · 5 comments
Closed

Is there a way to set monaco-editor readonly? #54

uadnan opened this issue Jul 8, 2016 · 5 comments

Comments

@uadnan
Copy link

uadnan commented Jul 8, 2016

Hi,

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

Thanks,

@uadnan
Copy link
Author

uadnan commented Jul 8, 2016

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

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

@uadnan uadnan closed this as completed Jul 8, 2016
@James9074
Copy link

James9074 commented Aug 17, 2017

Has anyone seen a reliable way to change this post-creation?

@elAndyG
Copy link

elAndyG commented Oct 4, 2017

@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

@alexdima
Copy link
Member

@James9074 editorInstance.updateOptions({ readOnly: true }) or editorInstance.updateOptions({ readOnly: false }) as @andyg8180 mentions will do the trick.

@James9074
Copy link

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.

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants