Monaco-editor: How to insert text into mouse cursor

Created on 14 Sep 2017  ·  4Comments  ·  Source: microsoft/monaco-editor


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

Most helpful comment

@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
            }
        ]
    );

All 4 comments

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 谢谢

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabiospampinato picture fabiospampinato  ·  3Comments

PinkyJie picture PinkyJie  ·  3Comments

ststeiger picture ststeiger  ·  3Comments

galyech picture galyech  ·  3Comments

akosyakov picture akosyakov  ·  3Comments