A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
7 years ago
|
import InputComponent from './input';
|
||
|
import KeymapperComponent from './keymapper';
|
||
|
import FollowComponent from './follow';
|
||
|
import * as inputActions from 'content/actions/input';
|
||
|
import messages from 'shared/messages';
|
||
|
|
||
|
export default class Common {
|
||
|
constructor(win, store) {
|
||
|
const follow = new FollowComponent(win, store);
|
||
|
const input = new InputComponent(win.document.body, store);
|
||
|
const keymapper = new KeymapperComponent(store);
|
||
|
|
||
|
input.onKey((key, ctrl) => {
|
||
|
follow.key(key, ctrl);
|
||
|
keymapper.key(key, ctrl);
|
||
|
});
|
||
|
|
||
|
this.store = store;
|
||
|
this.children = [
|
||
|
follow,
|
||
|
input,
|
||
|
keymapper,
|
||
|
];
|
||
|
|
||
|
this.reloadSettings();
|
||
|
}
|
||
|
|
||
|
update() {
|
||
|
this.children.forEach(c => c.update());
|
||
|
}
|
||
|
|
||
|
onMessage(message) {
|
||
|
switch (message) {
|
||
|
case messages.SETTINGS_CHANGED:
|
||
|
this.reloadSettings();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
reloadSettings() {
|
||
|
browser.runtime.sendMessage({
|
||
|
type: messages.SETTINGS_QUERY,
|
||
|
}).then((settings) => {
|
||
|
this.store.dispatch(inputActions.setKeymaps(settings.keymaps));
|
||
|
});
|
||
|
}
|
||
|
}
|