Impl multiple codemirror event listener

This commit is contained in:
Yukai Huang 2017-03-28 11:18:36 +08:00
parent fff7ebd1b5
commit 81666a726c
2 changed files with 22 additions and 9 deletions

View file

@ -116,6 +116,19 @@ export default class Editor {
utils.wrapTextWith(this.editor, cm, 'Backspace')
}
}
this.eventListeners = {}
}
on (event, cb) {
if (!this.eventListeners[event]) {
this.eventListeners[event] = [cb]
} else {
this.eventListeners[event].push(cb)
}
this.editor.on(event, (...args) => {
this.eventListeners[event].forEach(cb => cb(...args))
})
}
getStatusBarTemplate (callback) {