summaryrefslogtreecommitdiff
path: root/public/js/lib
diff options
context:
space:
mode:
authorYukai Huang2017-03-28 11:18:36 +0800
committerYukai Huang2017-03-28 11:18:36 +0800
commit81666a726c831af23e1d04d18e8efae3ecc0930d (patch)
treeebd6b7eea6d43574b894a5803f84dbfd0d866782 /public/js/lib
parentfff7ebd1b57467ed43925de33cfe013f6e61e5a7 (diff)
Impl multiple codemirror event listener
Diffstat (limited to 'public/js/lib')
-rw-r--r--public/js/lib/editor/index.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js
index 6ae40d82..8d617247 100644
--- a/public/js/lib/editor/index.js
+++ b/public/js/lib/editor/index.js
@@ -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) {