'How to open embedded editors (e.g. peek references) in read-only mode with Monaco?
I use a Monaco editor in a web application. The text models are provided lazily via HTTP. Now I want to show some of the resolved text models as read-only. It is clear how to open a Monaco "main editor" in read-only mode. Based on the text models URI I can decide whether it should be read-only or not, so I can configure the editor accordingly.
However, how can I set an embedded editor (the inline editor opening up after a "peek definition", "peek references", etc.) to read-only independently of the "main editor"?
A quite ugly workaround is to reset the value on every content change of the respective text model shown in the embedded editor. But clearly this is neither efficient nor nice.
// model is a monaco.editor.ITextModel that should be readonly
model.onDidChangeContent(() => {
if (model.getValue() !== content) {
model.setValue(content);
}
});
Thanks a lot in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
