File tree Expand file tree Collapse file tree
thunderbird/background_util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ zh = "连接到文本编辑器"
9898zh-tw = " 連接到文本編輯器"
9999
100100[manifest_commands_stop_ghostbird_description ]
101- # Description of the shortcut key to stop Ghostbird.
101+ # Description of the shortcut key to stop Ghostbird. Also used as a context menu item.
102102ar = " قطع الاتصال بمحرر النصوص"
103103be = " Адключыцца ад тэкставага рэдактара"
104104ca = " Desconnecta de l'editor de text"
@@ -159,6 +159,37 @@ vi = "Chuyển đổi kết nối với trình soạn thảo văn bản"
159159zh = " 切换与文本编辑器的连接"
160160zh-tw = " 切換與文本編輯器的連接"
161161
162+ [manifest_commands_open_options_description ]
163+ # Description of the shortcut key to open the options. Also used as a context menu item.
164+ ar = " خيارات"
165+ be = " Параметры"
166+ ca = " Opcions"
167+ cs = " Možnosti"
168+ de = " Optionen"
169+ el = " Επιλογές"
170+ en = " Options"
171+ es = " Opciones"
172+ fi = " Asetukset"
173+ fr = " Options"
174+ hu = " Beállítások"
175+ id = " Opsi"
176+ it = " Opzioni"
177+ ja = " オプション"
178+ ko = " 옵션"
179+ nl = " Opties"
180+ pl = " Opcje"
181+ pt = " Opções"
182+ pt-br = " Opções"
183+ ro = " Opțiuni"
184+ ru = " Настройки"
185+ sk = " Možnosti"
186+ th = " ตัวเลือก"
187+ tr = " Seçenekler"
188+ uk = " Параметри"
189+ vi = " Tùy chọn"
190+ zh = " 选项"
191+ zh-tw = " 選項"
192+
162193[options_server_port ]
163194# Description of the option item for the server port.
164195ar = " منفذ وجهة GhostText"
Original file line number Diff line number Diff line change 4949 },
5050 "toggle_ghostbird" : {
5151 "description" : " __MSG_manifest_commands_toggle_ghostbird_description__"
52+ },
53+ "open_options" : {
54+ "description" : " __MSG_manifest_commands_open_options_description__"
5255 }
5356 },
5457 "background" : {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import type { MessageId } from "src/util"
44export type { IGhostServerPort } from "src/ghosttext-adaptor/api"
55
66/** IDs of shortcut keys. Must be in sync with ones in manifest.json */
7- export type CommandId = "start_ghostbird" | "stop_ghostbird" | "toggle_ghostbird"
7+ export type CommandId = "start_ghostbird" | "stop_ghostbird" | "toggle_ghostbird" | "open_options"
88
99/** Queries current shortcut key config */
1010export interface ICommandConfig {
@@ -14,6 +14,12 @@ export interface ICommandConfig {
1414 getAll ( ) : PromiseLike < Readonly < CommandInfo > [ ] >
1515}
1616
17+ /** Miscellaneous UI utilities */
18+ export interface IUiUtil {
19+ /** Opens the options page for the extension */
20+ openOptionsPage ( ) : Promise < void >
21+ }
22+
1723/**
1824 * A single shortcut key command.
1925 */
Original file line number Diff line number Diff line change 11import type { IComposeWindow } from "src/ghosttext-adaptor"
2- import type { CommandId } from "./api"
2+ import type { CommandId , IUiUtil } from "./api"
33import type { ComposeActionNotifier } from "./compose_action_notifier"
44
55/** Handles execution of commands in the context a compose tab */
66
77export class CommandHandler {
88 static isSingleton = true
9- constructor ( private readonly composeActionNotifier : ComposeActionNotifier ) { }
9+ constructor (
10+ private readonly composeActionNotifier : ComposeActionNotifier ,
11+ private readonly uiUtil : IUiUtil ,
12+ ) { }
1013
1114 /** Executes a command in the context of a compose tab */
1215 runCommand ( command : CommandId , composeTab : IComposeWindow ) : Promise < void > {
@@ -17,6 +20,8 @@ export class CommandHandler {
1720 return this . composeActionNotifier . stop ( composeTab )
1821 case "toggle_ghostbird" :
1922 return this . composeActionNotifier . toggle ( composeTab )
23+ case "open_options" :
24+ return this . uiUtil . openOptionsPage ( )
2025 }
2126 // We don't handle default here so that tsc checks for exhaustiveness
2227 }
Original file line number Diff line number Diff line change @@ -79,13 +79,15 @@ export interface IManifestInfo {
7979
8080/** Options stored in local storage */
8181export type StoredOptions = {
82+ /** The port of the GhostText server to connect to */
8283 serverPort : number
84+ /** Shows notifications when connecting or disconnecting from GhostText if true */
8385 enableNotifications : boolean
8486}
8587
86- /** * Loads options from storage */
88+ /** Manages access to options */
8789export interface IStoredOptionsLoader {
88- /** * Loads options from storage */
90+ /** Loads options from storage */
8991 load ( ) : Promise < StoredOptions >
9092}
9193
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ const prepareThen: LazyThen<BackgroundEventRouter> = makeLazyThen(async () => {
2020 id : "stop_ghostbird" ,
2121 icon : "gray.svg" ,
2222 } ,
23+ {
24+ label : "manifest_commands_open_options_description" ,
25+ id : "open_options" ,
26+ icon : "gray.svg" ,
27+ } ,
2328 ]
2429 let heart = new AlarmHeart ( messenger )
2530
Original file line number Diff line number Diff line change 1+ import type { IUiUtil } from "src/app-background"
2+
3+ export class UiUtil implements IUiUtil {
4+ static isSingleton = true
5+
6+ constructor ( private readonly messenger : typeof globalThis . messenger ) { }
7+
8+ openOptionsPage ( ) : Promise < void > {
9+ return this . messenger . runtime . openOptionsPage ( )
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments