follow from content-input

jh-changes
Shin'ya Ueoka 7 years ago
parent 6f9b217df8
commit e2aae9cff2
  1. 3
      src/components/content-input.js
  2. 12
      src/components/follow.js
  3. 3
      src/content/index.js

@ -49,6 +49,9 @@ export default class ContentInputComponent {
let stop = false; let stop = false;
for (let listener of this.onKeyListeners) { for (let listener of this.onKeyListeners) {
stop = stop || listener(e.key, e.ctrlKey); stop = stop || listener(e.key, e.ctrlKey);
if (stop) {
break;
}
} }
if (stop) { if (stop) {
e.preventDefault(); e.preventDefault();

@ -22,9 +22,6 @@ export default class FollowComponent {
this.store = store; this.store = store;
this.hintElements = {}; this.hintElements = {};
this.state = {}; this.state = {};
let doc = wrapper.ownerDocument;
doc.addEventListener('keydown', this.onKeyDown.bind(this));
} }
update() { update() {
@ -39,12 +36,11 @@ export default class FollowComponent {
} }
} }
onKeyDown(e) { key(key) {
if (!this.state.enabled) { if (!this.state.enabled) {
return; return false;
} }
let { key } = e;
switch (key) { switch (key) {
case 'Enter': case 'Enter':
this.activate(this.hintElements[this.state.keys].target); this.activate(this.hintElements[this.state.keys].target);
@ -62,9 +58,7 @@ export default class FollowComponent {
} }
break; break;
} }
return true;
e.stopPropagation();
e.preventDefault();
} }
updateHints() { updateHints() {

@ -13,6 +13,9 @@ const followComponent = new FollowComponent(window.document.body, store);
const contentInputComponent = const contentInputComponent =
new ContentInputComponent(window.document.body, store); new ContentInputComponent(window.document.body, store);
const keymapperComponent = new KeymapperComponent(store); const keymapperComponent = new KeymapperComponent(store);
contentInputComponent.onKey((key, ctrl) => {
return followComponent.key(key, ctrl);
});
contentInputComponent.onKey((key, ctrl) => { contentInputComponent.onKey((key, ctrl) => {
return keymapperComponent.key(key, ctrl); return keymapperComponent.key(key, ctrl);
}); });