(四)CodeMirror - API

时间:2023-12-19 23:41:44

内容相关

cm.getValue()

cm.setValue()

cm.getRange()

editor.getRange({line:1},{line:2})  // 获取内容块字符

cm.replaceRange()

// 替换内容块内容为test
editors['js'].replaceRange('test',{line:2,ch:0},{line:2})
var lineobject = editors.getLineHandle(1)    // 获取行对象

Structure
{
gutterMarkers: Object
height: 14
parent: LeafChunk
stateAfter: Object
styles: Array[11]
text: "init:function() {"
}

cm.scrollTo()

editors.scrollTo(0,1000)    // 滚动到x:0,y:1000