Last active
November 9, 2016 20:18
-
-
Save medynski/e2bd8d0efb869aed4d57cd4ccbe2d5ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Extension { | |
constructor(api, component, element) { | |
this.$api = api; | |
this.$component = component; | |
this.$el = element; | |
this.id = api.store.currentConversation().id; | |
this.keyboardListener = api.dom.onTextareaKeyboardEvent(this.onKeyboardEvent.bind(this)); | |
api.common.onCurrentConversationChanged(event => { | |
this.keyboardListener.destroy(); | |
console.info(event.id); | |
if (this.id === event.id) { | |
console.info('add listener', this.id); | |
this.keyboardListener = api.dom.onTextareaKeyboardEvent(this.onKeyboardEvent.bind(this)); | |
} | |
}); | |
} | |
onInit() { | |
console.info('Init'); | |
} | |
onKeyboardEvent(event) { | |
if (event.type === 'keydown' && event.keyCode === 13) { | |
console.info('Enter: ', this.id, event); | |
} | |
} | |
onDestroy() { | |
} | |
} | |
module.exports = Extension; | |
module.exports.template = ` | |
<div id="canneds"></div> | |
`; | |
module.exports.styles = ``; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment