-
I'm creating a number scrubber for Monaco editor. To do so I need to be able to programmatically edit a range in the code. I can create a range using new monaco.Range(1, 1, 1, 1) and I can then get the text from the range using editor.getModel().getValueInRange(myRange);. However I can't figure out how to edit a range. The EditOperationBuilder was the only thing I could find in the docs (https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditOperationBuilder.html) which is maybe what I want, but I can't find any examples online of how to use it. And when I try using IEditOperationBuilder with my version of Monaco Editor v0.41.0 it seems that IEditOperationBuilder doesn't even exist as a property of the global monaco object, the editor, or the editor model. I also checked and there is no setValueInRange method which would be intuitive given that there is a getValueInRange method. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.ICodeEditor.html#executeEdits editor.executeEdits('number-scrubber', [
{
range: new monaco.Range(1, 1, 1, 1),
text: code,
},
]); |
Beta Was this translation helpful? Give feedback.
https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.ICodeEditor.html#executeEdits
example: