"change" (instance: CodeMirror, changeObj: object)
{ from, // object to, // object text, // array removed, // string,被删除的字符 origin }
"beforeChange" (instance: CodeMirror, changeObj: object)
1 // 如编辑行存在init字符,则取消编辑 2 editors.on("beforeChange", function(cm, co) { 3 if(cm.doc.children[0].lines[co.from.line].text.indexOf('init')>-1){ 4 co.cancel(); 5 } 6 });
"keyHandled" (instance: CodeMirror, name: string, event: Event)
当按下扩展快捷键触发
{ cm, name, // 扩展键名 event // keypress或keydown事件对象 }
1 editors.on('keyHandled', function(cm,name,e){ 2 console.log(name); 3 });
"renderLine" (instance: CodeMirror, line: LineHandle, element: Element)
1 // 代码显示 2 editors.on("renderLine", function(cm, line, elt) { 3 var off = CodeMirror.countColumn(line.text, null, cm.getOption("tabSize")) * charWidth; 4 elt.style.textIndent = "-" + off + "px"; 5 elt.style.paddingLeft = (basePadding + off) + "px"; 6 });