From 80ed062487356310efd5e4a76f1f8978dc836a4f Mon Sep 17 00:00:00 2001 From: Shin'ya UEOKA Date: Mon, 30 Sep 2019 06:15:46 +0000 Subject: Add :help command to open help --- src/background/controllers/CommandController.ts | 3 +++ src/background/domains/CommandDocs.ts | 1 + src/background/presenters/HelpPresenter.ts | 10 ++++++++++ src/background/usecases/CommandUseCase.ts | 8 +++++++- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/background/presenters/HelpPresenter.ts diff --git a/src/background/controllers/CommandController.ts b/src/background/controllers/CommandController.ts index 2ad1683..11fed01 100644 --- a/src/background/controllers/CommandController.ts +++ b/src/background/controllers/CommandController.ts @@ -96,6 +96,9 @@ export default class CommandController { return this.commandIndicator.quitAll(); case 'set': return this.commandIndicator.set(keywords); + case 'h': + case 'help': + return this.commandIndicator.help(); } throw new Error(words[0] + ' command is not defined'); } diff --git a/src/background/domains/CommandDocs.ts b/src/background/domains/CommandDocs.ts index 25ea62a..e926851 100644 --- a/src/background/domains/CommandDocs.ts +++ b/src/background/domains/CommandDocs.ts @@ -8,4 +8,5 @@ export default { bdeletes: 'Close all tabs matched by keywords', quit: 'Close the current tab', quitall: 'Close all tabs', + help: 'Open Vim Vixen help in new tab', } as {[key: string]: string}; diff --git a/src/background/presenters/HelpPresenter.ts b/src/background/presenters/HelpPresenter.ts new file mode 100644 index 0000000..f5c3a6b --- /dev/null +++ b/src/background/presenters/HelpPresenter.ts @@ -0,0 +1,10 @@ +import { injectable } from 'tsyringe'; + +const url = 'https://ueokande.github.io/vim-vixen/'; + +@injectable() +export default class HelpPresenter { + async open(): Promise { + await browser.tabs.create({ url, active: true }); + } +} diff --git a/src/background/usecases/CommandUseCase.ts b/src/background/usecases/CommandUseCase.ts index a526cfc..d757215 100644 --- a/src/background/usecases/CommandUseCase.ts +++ b/src/background/usecases/CommandUseCase.ts @@ -4,6 +4,7 @@ import * as parsers from './parsers'; import * as urls from '../../shared/urls'; import TabPresenter from '../presenters/TabPresenter'; import WindowPresenter from '../presenters/WindowPresenter'; +import HelpPresenter from '../presenters/HelpPresenter'; import SettingRepository from '../repositories/SettingRepository'; import BookmarkRepository from '../repositories/BookmarkRepository'; import ConsoleClient from '../infrastructures/ConsoleClient'; @@ -15,6 +16,7 @@ export default class CommandIndicator { constructor( private tabPresenter: TabPresenter, private windowPresenter: WindowPresenter, + private helpPresenter: HelpPresenter, private settingRepository: SettingRepository, private bookmarkRepository: BookmarkRepository, private consoleClient: ConsoleClient, @@ -136,7 +138,11 @@ export default class CommandIndicator { return this.contentMessageClient.broadcastSettingsChanged(); } - async urlOrSearch(keywords: string): Promise { + help(): Promise { + return this.helpPresenter.open(); + } + + private async urlOrSearch(keywords: string): Promise { let settings = await this.settingRepository.get(); return urls.searchUrl(keywords, settings.search); } -- cgit v1.2.3