mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
feat: improved hotkey support and controls
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
SelectSetting,
|
||||
StringSetting,
|
||||
ButtonSetting,
|
||||
HotkeySetting,
|
||||
} from "./types";
|
||||
import { createPluginAPI } from "./createAPI";
|
||||
import browser from "webextension-polyfill";
|
||||
@@ -193,7 +194,8 @@ export class PluginManager {
|
||||
id: string;
|
||||
options: Array<{ value: string; label: string }>;
|
||||
})
|
||||
| (Omit<ButtonSetting, "type"> & { type: "button"; id: string; trigger?: () => void | Promise<void> });
|
||||
| (Omit<ButtonSetting, "type"> & { type: "button"; id: string; trigger?: () => void | Promise<void> })
|
||||
| (Omit<HotkeySetting, "type"> & { type: "hotkey"; id: string });
|
||||
};
|
||||
}> {
|
||||
return Array.from(this.plugins.entries()).map(([id, plugin]) => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
NumberSetting,
|
||||
SelectSetting,
|
||||
StringSetting,
|
||||
HotkeySetting,
|
||||
} from "./types";
|
||||
|
||||
export function numberSetting(
|
||||
@@ -51,6 +52,15 @@ export function buttonSetting(
|
||||
};
|
||||
}
|
||||
|
||||
export function hotkeySetting(
|
||||
options: Omit<HotkeySetting, "type">,
|
||||
): HotkeySetting {
|
||||
return {
|
||||
type: "hotkey",
|
||||
...options,
|
||||
};
|
||||
}
|
||||
|
||||
export function defineSettings<T extends Record<string, any>>(settings: T): T {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -41,12 +41,20 @@ export interface ButtonSetting {
|
||||
trigger?: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
export interface HotkeySetting {
|
||||
type: "hotkey";
|
||||
default: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export type PluginSetting =
|
||||
| BooleanSetting
|
||||
| StringSetting
|
||||
| NumberSetting
|
||||
| SelectSetting<string>
|
||||
| ButtonSetting;
|
||||
| ButtonSetting
|
||||
| HotkeySetting;
|
||||
|
||||
export type PluginSettings = {
|
||||
[key: string]: PluginSetting;
|
||||
@@ -61,7 +69,9 @@ export type SettingValue<T extends PluginSetting> = T extends BooleanSetting
|
||||
? number
|
||||
: T extends SelectSetting<infer O>
|
||||
? O
|
||||
: never;
|
||||
: T extends HotkeySetting
|
||||
? string
|
||||
: never;
|
||||
|
||||
export type SettingsAPI<T extends PluginSettings> = {
|
||||
[K in keyof T]: SettingValue<T[K]>;
|
||||
|
||||
Reference in New Issue
Block a user