在CodeMirror编辑界面中光标处插入内容

  |   1 评论   |   506 浏览

效果

要实现的效果图如下所示:

官方API:

**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.

**doc.replaceSelections**(replacements: array, ?select: string)

The length of the given array should be the same as the number of active selections. Replaces the content of the selections with the strings in the array. The selectargument works the same as in replaceSelection.

实现

官方文档好一顿翻,终于特么一句话搞定的!😓

myCodeMirror.replaceSelection("插入的内容");

🎉


文章标题:
文章作者:TuChief
本文链接:http://www.tuchief.com/
版权声明: 本文章不涉及商业用途,仅供学习参考,欢迎转载。除特别声明外,转载请注明出处和原文链接!

评论

发表评论