Reputation: 74
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.
Upvotes: 1
Views: 685
Reputation: 74
https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.ICodeEditor.html#executeEdits example:
editor.executeEdits('number-scrubber', [
{
range: new monaco.Range(1, 1, 1, 1),
text: code,
},
]);
Upvotes: 1