monaco-editor version: 0.10.0
Browser: CEF3
OS: win10 x64
Steps or JS usage snippet reproducing the issue:
How do I use js to insert text at the mouse cursor
i found use editor.executeEdits
editor.executeEdits("", [
{ range: new monaco.Range(1,14,1,20), text: "prepend" }
]);
https://github.com/Microsoft/monaco-editor/issues/172
https://github.com/Microsoft/monaco-editor/issues/192
@lwinhong How do you insert it at the cursor position?
@Panhaiwei 我是这样写的
var result =“my test string”;
var p = monacoEditor.getPosition();
monacoEditor.executeEdits("",
[
{
range: new monaco.Range(p.lineNumber,
p.column,
p.lineNumber,
p.column),
text: result
}
]
);
@lwinhong 谢谢
Most helpful comment
@Panhaiwei 我是这样写的