首页 > 代码库 > (三)CodeMirror - Event

(三)CodeMirror - Event

"change" (instance: CodeMirror, changeObj: object)

{    from,         // object    to,           // object    text,         // array     removed,      // string,被删除的字符    origin}           

 

"beforeChange" (instance: CodeMirror, changeObj: object)

1 // 如编辑行存在init字符,则取消编辑2 editors[type].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[type].on(‘keyHandled‘, function(cm,name,e){2     console.log(name);3 });

 

(三)CodeMirror - Event