Hi,
I'm trying to replace dynamically part of the monaco-editor content within a given range with other content.
For example, I would like to replace "append" with "prepend" dynamically, in a button click.
$("#my_div").append($("<div></div>"));
Is there any way to do it?
you can call editor.applyEdits where you can pass in an array of edits described in IIdentifiedSingleEditOperation. You can control the undo-redo behaviour via editor.pushUndoStop
thank you @alexandrudima, you gave me a direction to the solution. i eventually used editor.executeEdits.
So, the full solution for my problem above:
editor.executeEdits("", [
{ range: new monaco.Range(1,14,1,20), text: "prepend" }
]);
Most helpful comment
thank you @alexandrudima, you gave me a direction to the solution. i eventually used
editor.executeEdits.So, the full solution for my problem above: