aboutsummaryrefslogtreecommitdiff
path: root/src/content/components/common
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-21 19:40:22 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-21 19:40:22 +0900
commitdc6d93c1da28ed17fe1bc5be07bdfab30a40dd66 (patch)
tree8c1474bf6b4999a59db789d3b00ed455f5411f6a /src/content/components/common
parent59f7ef205df4750063c755a7b8834bfd7509da83 (diff)
enable/disable addon by keys
Diffstat (limited to 'src/content/components/common')
-rw-r--r--src/content/components/common/keymapper.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/content/components/common/keymapper.js b/src/content/components/common/keymapper.js
index 8c0ddb1..5070cd8 100644
--- a/src/content/components/common/keymapper.js
+++ b/src/content/components/common/keymapper.js
@@ -1,5 +1,6 @@
import * as inputActions from 'content/actions/input';
import * as operationActions from 'content/actions/operation';
+import operations from 'shared/operations';
export default class KeymapperComponent {
constructor(store) {
@@ -10,12 +11,23 @@ export default class KeymapperComponent {
}
key(key) {
+ let enabled = this.store.getState().addon.enabled;
+
this.store.dispatch(inputActions.keyPress(key));
let input = this.store.getState().input;
let matched = Object.keys(input.keymaps).filter((keyStr) => {
return keyStr.startsWith(input.keys);
});
+ if (!enabled) {
+ // available keymaps are only ADDON_ENABLE and ADDON_TOGGLE_ENABLED if
+ // the addon disabled
+ matched = matched.filter((keys) => {
+ let type = input.keymaps[keys].type;
+ return type === operations.ADDON_ENABLE ||
+ type === operations.ADDON_TOGGLE_ENABLED;
+ });
+ }
if (matched.length === 0) {
this.store.dispatch(inputActions.clearKeys());
return false;