diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-10-09 11:50:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-09 11:50:52 +0000 |
commit | 18c72bf15c6bc7e4c88dd06d38ff861f29d66b1b (patch) | |
tree | f46720349e17c57db7bbfc55241b12c4410f2773 /src/content/usecases | |
parent | 8eddcc1785a85bbe74be254d1055ebe5125dad10 (diff) | |
parent | 68f6211aac4177f3a70a40031dabbd1b61840071 (diff) |
Merge pull request #655 from ueokande/partial-blacklist
Partial blacklist
Diffstat (limited to 'src/content/usecases')
-rw-r--r-- | src/content/usecases/KeymapUseCase.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts index 495f6d0..67d667d 100644 --- a/src/content/usecases/KeymapUseCase.ts +++ b/src/content/usecases/KeymapUseCase.ts @@ -6,6 +6,7 @@ import * as operations from '../../shared/operations'; import Keymaps from '../../shared/settings/Keymaps'; import Key from '../../shared/settings/Key'; import KeySequence from '../../shared/settings/KeySequence'; +import AddressRepository from '../repositories/AddressRepository'; type KeymapEntityMap = Map<KeySequence, operations.Operation>; @@ -25,11 +26,19 @@ export default class KeymapUseCase { @inject('AddonEnabledRepository') private addonEnabledRepository: AddonEnabledRepository, + + @inject('AddressRepository') + private addressRepository: AddressRepository, ) { } nextOp(key: Key): operations.Operation | null { let sequence = this.repository.enqueueKey(key); + if (sequence.length() === 1 && this.blacklistKey(key)) { + // ignore if the input starts with black list keys + this.repository.clear(); + return null; + } let keymaps = this.keymapEntityMap(); let matched = Array.from(keymaps.keys()).filter( @@ -71,4 +80,10 @@ export default class KeymapUseCase { ) as [KeySequence, operations.Operation][]; return new Map<KeySequence, operations.Operation>(entries); } + + private blacklistKey(key: Key): boolean { + let url = this.addressRepository.getCurrentURL(); + let blacklist = this.settingRepository.get().blacklist; + return blacklist.includeKey(url, key); + } } |