Skip to content

Instantly share code, notes, and snippets.

@medynski
Last active November 9, 2016 20:18
Show Gist options
  • Save medynski/e2bd8d0efb869aed4d57cd4ccbe2d5ed to your computer and use it in GitHub Desktop.
Save medynski/e2bd8d0efb869aed4d57cd4ccbe2d5ed to your computer and use it in GitHub Desktop.
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