mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
feat: add beta tag to global search plugin
This commit is contained in:
+34
-4
@@ -29,6 +29,9 @@ const myFirstPlugin: Plugin = {
|
|||||||
// This tells BetterSEQTA+ that users can turn our plugin on/off
|
// This tells BetterSEQTA+ that users can turn our plugin on/off
|
||||||
disableToggle: true,
|
disableToggle: true,
|
||||||
|
|
||||||
|
// Optional: Mark your plugin as beta to show a "Beta" tag in settings
|
||||||
|
beta: true,
|
||||||
|
|
||||||
// This is where the magic happens!
|
// This is where the magic happens!
|
||||||
run: async (api) => {
|
run: async (api) => {
|
||||||
// Wait for the homepage to load
|
// Wait for the homepage to load
|
||||||
@@ -65,10 +68,11 @@ Let's break down what's happening here:
|
|||||||
- `description`: Explain what your plugin does
|
- `description`: Explain what your plugin does
|
||||||
- `version`: Your plugin's version number
|
- `version`: Your plugin's version number
|
||||||
3. We set `disableToggle: true` so users can turn our plugin on/off in settings
|
3. We set `disableToggle: true` so users can turn our plugin on/off in settings
|
||||||
4. The `run` function is where we put our plugin's code
|
4. We set `beta: true` to mark the plugin as beta
|
||||||
5. We use `api.seqta.onMount` to wait for the homepage to load
|
5. The `run` function is where we put our plugin's code
|
||||||
6. We create and style a message element
|
6. We use `api.seqta.onMount` to wait for the homepage to load
|
||||||
7. We return a cleanup function that removes our changes when the plugin is disabled
|
7. We create and style a message element
|
||||||
|
8. We return a cleanup function that removes our changes when the plugin is disabled
|
||||||
|
|
||||||
## The Plugin API
|
## The Plugin API
|
||||||
|
|
||||||
@@ -246,6 +250,32 @@ Here are some tips to make your plugin awesome:
|
|||||||
- Add clear settings with good descriptions
|
- Add clear settings with good descriptions
|
||||||
- Use `disableToggle: true` so users can turn it off if needed
|
- Use `disableToggle: true` so users can turn it off if needed
|
||||||
- Add helpful error messages if something goes wrong
|
- Add helpful error messages if something goes wrong
|
||||||
|
- Use `beta: true` for experimental features to let users know they're trying something new
|
||||||
|
|
||||||
|
## Plugin Metadata Options
|
||||||
|
|
||||||
|
Your plugin object supports several optional flags to customize how it appears and behaves:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const myPlugin: Plugin = {
|
||||||
|
id: "my-plugin",
|
||||||
|
name: "My Plugin",
|
||||||
|
description: "What my plugin does",
|
||||||
|
version: "1.0.0",
|
||||||
|
|
||||||
|
// Optional flags:
|
||||||
|
disableToggle: true, // Show enable/disable toggle in settings
|
||||||
|
defaultEnabled: false, // Start disabled by default (requires disableToggle: true)
|
||||||
|
beta: true, // Show "Beta" tag in settings UI
|
||||||
|
|
||||||
|
// Your plugin code...
|
||||||
|
run: async (api) => { /* ... */ },
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
- **`disableToggle`**: When `true`, users can enable/disable your plugin in settings
|
||||||
|
- **`defaultEnabled`**: When `false`, your plugin starts disabled (only works with `disableToggle: true`)
|
||||||
|
- **`beta`**: When `true`, shows an orange "Beta" tag next to your plugin name in settings
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ const myPlugin: Plugin<typeof settings> = {
|
|||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
settings: settingsInstance.settings,
|
settings: settingsInstance.settings,
|
||||||
disableToggle: true,
|
disableToggle: true,
|
||||||
|
beta: true,
|
||||||
|
|
||||||
run: async (api) => {
|
run: async (api) => {
|
||||||
console.log("Plugin is running!");
|
console.log("Plugin is running!");
|
||||||
@@ -62,6 +63,35 @@ const myPlugin: Plugin<typeof settings> = {
|
|||||||
export default myPlugin;
|
export default myPlugin;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The plugin object supports several metadata fields and options:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface Plugin {
|
||||||
|
// Required fields
|
||||||
|
id: string; // Unique identifier (lowercase, dashes)
|
||||||
|
name: string; // Display name shown to users
|
||||||
|
description: string; // Brief description of what the plugin does
|
||||||
|
version: string; // Semantic version (e.g., "1.0.0")
|
||||||
|
settings: PluginSettings; // Plugin settings object
|
||||||
|
run: (api: PluginAPI) => void; // Main plugin function
|
||||||
|
|
||||||
|
// Optional fields
|
||||||
|
styles?: string; // CSS styles to inject
|
||||||
|
disableToggle?: boolean; // Show enable/disable toggle in settings
|
||||||
|
defaultEnabled?: boolean; // Start enabled/disabled (requires disableToggle)
|
||||||
|
beta?: boolean; // Show "Beta" tag in settings UI
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Metadata Options
|
||||||
|
|
||||||
|
- **`disableToggle`**: When `true`, users can enable/disable your plugin in the settings page
|
||||||
|
- **`defaultEnabled`**: When `false`, your plugin starts disabled by default (only works with `disableToggle: true`)
|
||||||
|
- **`beta`**: When `true`, displays an orange "Beta" tag next to your plugin name in the settings UI
|
||||||
|
- **`styles`**: CSS string that gets injected into the page when your plugin runs
|
||||||
|
|
||||||
## SEQTA API
|
## SEQTA API
|
||||||
|
|
||||||
The SEQTA API helps you interact with SEQTA's pages:
|
The SEQTA API helps you interact with SEQTA's pages:
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
pluginId: string;
|
pluginId: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
beta?: boolean;
|
||||||
settings: Record<string, SettingType>;
|
settings: Record<string, SettingType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +195,14 @@
|
|||||||
{#if (plugin as any).disableToggle}
|
{#if (plugin as any).disableToggle}
|
||||||
<div class="flex justify-between items-center px-4 py-3">
|
<div class="flex justify-between items-center px-4 py-3">
|
||||||
<div class="pr-4">
|
<div class="pr-4">
|
||||||
<h2 class="text-sm font-bold">Enable {plugin.name}</h2>
|
<h2 class="text-sm font-bold flex items-center gap-2">
|
||||||
|
Enable {plugin.name}
|
||||||
|
{#if plugin.beta}
|
||||||
|
<span class="px-2 py-0.5 text-xs font-medium bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-300 rounded-full">
|
||||||
|
Beta
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</h2>
|
||||||
<p class="text-xs">{plugin.description}</p>
|
<p class="text-xs">{plugin.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ const globalSearchPlugin: Plugin<typeof settings> = {
|
|||||||
settings: settingsInstance.settings,
|
settings: settingsInstance.settings,
|
||||||
disableToggle: true,
|
disableToggle: true,
|
||||||
defaultEnabled: false,
|
defaultEnabled: false,
|
||||||
|
beta: true,
|
||||||
styles: styles,
|
styles: styles,
|
||||||
|
|
||||||
run: async (api) => {
|
run: async (api) => {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const testPlugin: Plugin<typeof settings> = {
|
|||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
settings: settingsInstance.settings,
|
settings: settingsInstance.settings,
|
||||||
disableToggle: true,
|
disableToggle: true,
|
||||||
|
beta: true,
|
||||||
|
|
||||||
run: async (api) => {
|
run: async (api) => {
|
||||||
console.log("Test plugin running");
|
console.log("Test plugin running");
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export class PluginManager {
|
|||||||
pluginId: string;
|
pluginId: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
beta?: boolean;
|
||||||
settings: {
|
settings: {
|
||||||
[key: string]:
|
[key: string]:
|
||||||
| (Omit<BooleanSetting, "type"> & { type: "boolean"; id: string })
|
| (Omit<BooleanSetting, "type"> & { type: "boolean"; id: string })
|
||||||
@@ -235,6 +236,7 @@ export class PluginManager {
|
|||||||
pluginId: id,
|
pluginId: id,
|
||||||
name: plugin.name,
|
name: plugin.name,
|
||||||
description: plugin.description,
|
description: plugin.description,
|
||||||
|
beta: plugin.beta,
|
||||||
settings: Object.fromEntries(settingsEntries),
|
settings: Object.fromEntries(settingsEntries),
|
||||||
disableToggle: plugin.disableToggle,
|
disableToggle: plugin.disableToggle,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ export interface Plugin<T extends PluginSettings = PluginSettings, S = any> {
|
|||||||
styles?: string; // Optional CSS styles for the plugin
|
styles?: string; // Optional CSS styles for the plugin
|
||||||
disableToggle?: boolean; // Optional flag to show/hide the plugin's enable/disable toggle in settings
|
disableToggle?: boolean; // Optional flag to show/hide the plugin's enable/disable toggle in settings
|
||||||
defaultEnabled?: boolean; // Optional flag to set the plugin's default enabled state
|
defaultEnabled?: boolean; // Optional flag to set the plugin's default enabled state
|
||||||
|
beta?: boolean; // Optional flag to mark the plugin as beta
|
||||||
run: (
|
run: (
|
||||||
api: PluginAPI<T, S>,
|
api: PluginAPI<T, S>,
|
||||||
) => void | Promise<void> | (() => void) | Promise<() => void>;
|
) => void | Promise<void> | (() => void) | Promise<() => void>;
|
||||||
|
|||||||
Reference in New Issue
Block a user