diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-11-29 09:31:45 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-12-09 23:09:34 +0900 |
commit | 36c28a538955c0cd9d94c210372337d7a5c2a01b (patch) | |
tree | be12ff6abed9443cfedcb3ab1564ee8562e33858 /src/content/operators/impls/PasteOperator.ts | |
parent | 809bdb11f3d213254c098411755631b1264c52f0 (diff) |
extract independent classes
Diffstat (limited to 'src/content/operators/impls/PasteOperator.ts')
-rw-r--r-- | src/content/operators/impls/PasteOperator.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/content/operators/impls/PasteOperator.ts b/src/content/operators/impls/PasteOperator.ts new file mode 100644 index 0000000..592da66 --- /dev/null +++ b/src/content/operators/impls/PasteOperator.ts @@ -0,0 +1,25 @@ +import Operator from "../Operator"; +import ClipboardRepository from "../../repositories/ClipboardRepository"; +import SettingRepository from "../../repositories/SettingRepository"; +import OperationClient from "../../client/OperationClient"; +import * as urls from "../../../shared/urls"; + +export default class PasteOperator implements Operator { + constructor( + private readonly repository: ClipboardRepository, + private readonly settingRepository: SettingRepository, + private readonly operationClient: OperationClient, + private readonly newTab: boolean + ) {} + + async run(): Promise<void> { + const search = this.settingRepository.get().search; + const text = this.repository.read(); + const url = urls.searchUrl(text, search); + + // NOTE: Repeat pasting from clipboard instead of opening a certain url. + // 'Repeat last' command is implemented in the background script and cannot + // access to clipboard until Firefox 63. + await this.operationClient.internalOpenUrl(url, this.newTab); + } +} |