My problem consists of two parts actually. I am getting the editor content by using getValue()
. This returns the raw text from the Monaco editor. Suppose I want to append new code after a specific code block. Then how do I achieve this.
I can get currentPosition()
and it returns the current cursor location just fine. But how do I get the location specifically for a code block and insert new code after that. For example I can get code from the editor like this.
<body>
<div>Big brown fox jumps at lazy dog.</div>
<!-- I WANT TO ADD CODE HERE PROGRAMMATICALLY -->
<p>we have all the details for singleton methods.</p>
<div>new data comes here.</div>
</body>
How can I add code between two code blocks. The only solution that comes to my mind is if I could get positions/line locations along with the code by getValue
. And later on use those pointers to add new blocks in the code. But I could not find any helpful solution yet.