Inserting a new text at given cursor position

后端 未结 7 2194
夕颜
夕颜 2021-01-01 18:35

I am working on customizing the codemirror for my new language mode. As part of this new mode implementation, I am writing a new tool bar where user can select some text and

7条回答
  •  太阳男子
    2021-01-01 18:57

    How about replaceSelection (http://codemirror.net/doc/manual.html#replaceSelection)?

    doc.replaceSelection(replacement: string, ?select: string) Replace the selection(s) with the given string. By default, the new selection ends up after the inserted text. The optional select argument can be used to change this—passing "around" will cause the new text to be selected, passing "start" will collapse the selection to the start of the inserted text.

提交回复
热议问题