我需要在具有 codemirror 插件的 textarea 中获取特定字符串的行号。
var editor= CodeMirror.fromTextArea(document.getElementById("refstyle");
var doc = editor.getDoc();
var cursor = doc.getCursor(); // gets the line number in the cursor position
var line = doc.getLine(cursor.line); // get the line contents
editor.getSelection(line number) //it will select the text based on line number
Run Code Online (Sandbox Code Playgroud)
那么,如何根据字符串获取行号(我希望像 doc.getLine(string) 或 doc.getSelection(String))
是否有任何函数可以根据字符串获取行号或根据文本区域中的行号获取选择的搜索字符串?请帮忙!
| 归档时间: |
|
| 查看次数: |
2703 次 |
| 最近记录: |