Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,8 @@ If you've looked at the options above and still want to motivate the maintainer
### Services

[![Github Actions Status](https://github.com/exteditor/ghostbird/actions/workflows/build.yml/badge.svg)](https://github.com/exteditor/ghostbird/actions/workflows/build.yml)
[![Reviewed by CodeRabbit](https://img.shields.io/badge/reviewed_by-CodeRabbit-ff570a?logo=coderabbit)](https://github.com/search?q=repo%3Aexteditor%2Fghostbird&type=pullrequests&s=created&o=desc)
[![Test coverage tracked with Codecov](https://codecov.io/github/exteditor/ghostbird/graph/badge.svg?token=NDWAK8NEC6)](https://codecov.io/github/exteditor/ghostbird)
[![Bundle size tracked with Codecov (esm)](https://codecov.io/github/exteditor/ghostbird/graph/bundle/esm/badge.svg?token=NDWAK8NEC6)](https://codecov.io/github/exteditor/ghostbird/bundles/background)
[![Bundle size tracked with Codecov (iife)](https://codecov.io/github/exteditor/ghostbird/graph/bundle/iife/badge.svg?token=NDWAK8NEC6)](https://codecov.io/github/exteditor/ghostbird/bundles/compose)
[![Reviewed by CodeRabbit](https://img.shields.io/coderabbit/prs/github/exteditor/ghostbird?utm_source=oss&utm_medium=github&utm_campaign=exteditor%2Fghostbird&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews&logo=coderabbit&logoSize=auto)](https://github.com/search?q=repo%3Aexteditor%2Fghostbird&type=pullrequests&s=created&o=desc)
[![Covered by Codecov](https://codecov.io/github/exteditor/ghostbird/graph/badge.svg?token=NDWAK8NEC6)](https://app.codecov.io/github/exteditor/ghostbird/commits)

## License

Expand Down
33 changes: 32 additions & 1 deletion locales.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ zh = "连接到文本编辑器"
zh-tw = "連接到文本編輯器"

[manifest_commands_stop_ghostbird_description]
# Description of the shortcut key to stop Ghostbird.
# Description of the shortcut key to stop Ghostbird. Also used as a context menu item.
ar = "قطع الاتصال بمحرر النصوص"
be = "Адключыцца ад тэкставага рэдактара"
ca = "Desconnecta de l'editor de text"
Expand Down Expand Up @@ -159,6 +159,37 @@ vi = "Chuyển đổi kết nối với trình soạn thảo văn bản"
zh = "切换与文本编辑器的连接"
zh-tw = "切換與文本編輯器的連接"

[manifest_commands_open_options_description]
# Description of the shortcut key to open the options. Also used as a context menu item.
ar = "خيارات"
be = "Параметры"
ca = "Opcions"
cs = "Možnosti"
de = "Optionen"
el = "Επιλογές"
en = "Options"
es = "Opciones"
fi = "Asetukset"
fr = "Options"
hu = "Beállítások"
id = "Opsi"
it = "Opzioni"
ja = "オプション"
ko = "옵션"
nl = "Opties"
pl = "Opcje"
pt = "Opções"
pt-br = "Opções"
ro = "Opțiuni"
ru = "Настройки"
sk = "Možnosti"
th = "ตัวเลือก"
tr = "Seçenekler"
uk = "Параметри"
vi = "Tùy chọn"
zh = "选项"
zh-tw = "選項"

[options_server_port]
# Description of the option item for the server port.
ar = "منفذ وجهة GhostText"
Expand Down
3 changes: 3 additions & 0 deletions manifest_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
},
"toggle_ghostbird": {
"description": "__MSG_manifest_commands_toggle_ghostbird_description__"
},
"open_options": {
"description": "__MSG_manifest_commands_open_options_description__"
}
},
"background": {
Expand Down
8 changes: 7 additions & 1 deletion src/app-background/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { MessageId } from "src/util"
export type { IGhostServerPort } from "src/ghosttext-adaptor/api"

/** IDs of shortcut keys. Must be in sync with ones in manifest.json */
export type CommandId = "start_ghostbird" | "stop_ghostbird" | "toggle_ghostbird"
export type CommandId = "start_ghostbird" | "stop_ghostbird" | "toggle_ghostbird" | "open_options"

/** Queries current shortcut key config */
export interface ICommandConfig {
Expand All @@ -14,6 +14,12 @@ export interface ICommandConfig {
getAll(): PromiseLike<Readonly<CommandInfo>[]>
}

/** Miscellaneous UI utilities */
export interface IUiUtil {
/** Opens the options page for the extension */
openOptionsPage(): Promise<void>
}

/**
* A single shortcut key command.
*/
Expand Down
9 changes: 7 additions & 2 deletions src/app-background/command_handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import type { IComposeWindow } from "src/ghosttext-adaptor"
import type { CommandId } from "./api"
import type { CommandId, IUiUtil } from "./api"
import type { ComposeActionNotifier } from "./compose_action_notifier"

/** Handles execution of commands in the context a compose tab */

export class CommandHandler {
static isSingleton = true
constructor(private readonly composeActionNotifier: ComposeActionNotifier) {}
constructor(
private readonly composeActionNotifier: ComposeActionNotifier,
private readonly uiUtil: IUiUtil,
) {}

/** Executes a command in the context of a compose tab */
runCommand(command: CommandId, composeTab: IComposeWindow): Promise<void> {
Expand All @@ -17,6 +20,8 @@ export class CommandHandler {
return this.composeActionNotifier.stop(composeTab)
case "toggle_ghostbird":
return this.composeActionNotifier.toggle(composeTab)
case "open_options":
return this.uiUtil.openOptionsPage()
}
// We don't handle default here so that tsc checks for exhaustiveness
}
Expand Down
6 changes: 4 additions & 2 deletions src/ghosttext-adaptor/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ export interface IManifestInfo {

/** Options stored in local storage */
export type StoredOptions = {
/** The port of the GhostText server to connect to */
serverPort: number
/** Shows notifications when connecting or disconnecting from GhostText if true */
enableNotifications: boolean
}

/** * Loads options from storage */
/** Manages access to options */
export interface IStoredOptionsLoader {
/** * Loads options from storage */
/** Loads options from storage */
load(): Promise<StoredOptions>
}

Expand Down
5 changes: 5 additions & 0 deletions src/root/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const prepareThen: LazyThen<BackgroundEventRouter> = makeLazyThen(async () => {
id: "stop_ghostbird",
icon: "gray.svg",
},
{
label: "manifest_commands_open_options_description",
id: "open_options",
icon: "gray.svg",
},
]
let heart = new AlarmHeart(messenger)

Expand Down
11 changes: 11 additions & 0 deletions src/thunderbird/background_util/ui_util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { IUiUtil } from "src/app-background"

export class UiUtil implements IUiUtil {
static isSingleton = true

constructor(private readonly messenger: typeof globalThis.messenger) {}

openOptionsPage(): Promise<void> {
return this.messenger.runtime.openOptionsPage()
}
}
2 changes: 1 addition & 1 deletion src/thunderbird/messenger/alarms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file `messenger.alarms` API somehow missing in the type lib
* @see https://webextension-api.thunderbird.net/en/128-esr-mv3/alarms.html
* @see https://webextension-api.thunderbird.net/en/esr-mv3/alarms.html
*/

/** Use the scripting API to execute script in different contexts. */
Expand Down
2 changes: 1 addition & 1 deletion src/thunderbird/messenger/global.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Functions added in Thunderbird 128 ESR
* @see https://webextension-api.thunderbird.net/en/128-esr-mv3/
* @see https://webextension-api.thunderbird.net/en/esr-mv3/
*/

import type { IAlarmsAPI } from "./alarms"
Expand Down
2 changes: 1 addition & 1 deletion src/thunderbird/messenger/scripting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file `messenger.scripting` API added at Thunderbird 128 ESR
* @see https://webextension-api.thunderbird.net/en/128-esr-mv3/scripting.html
* @see https://webextension-api.thunderbird.net/en/esr-mv3/scripting.html
*/

import type { PlainJSONValue } from "./"
Expand Down