This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a commit to branch feat/1.7.2/ui
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/feat/1.7.2/ui by this push:
new cb83bb69 feat(plugins): implement singleton plugin type handling and
remove registrationMode from PluginInfo
cb83bb69 is described below
commit cb83bb6905a47799951e6cd5b306a8fd0b1b2228
Author: robin <[email protected]>
AuthorDate: Fri Dec 26 10:32:17 2025 +0800
feat(plugins): implement singleton plugin type handling and remove
registrationMode from PluginInfo
---
ui/src/utils/pluginKit/index.ts | 14 +++++++++++---
ui/src/utils/pluginKit/interface.ts | 1 -
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ui/src/utils/pluginKit/index.ts b/ui/src/utils/pluginKit/index.ts
index fc892614..34a2de7c 100644
--- a/ui/src/utils/pluginKit/index.ts
+++ b/ui/src/utils/pluginKit/index.ts
@@ -42,6 +42,15 @@ import { Plugin, PluginInfo, PluginType } from './interface';
* @field description: Plugin description, optionally configurable. Usually
read from the `i18n` file
*/
+// Define which plugin types are singleton by design
+const SingletonTypes: Set<PluginType> = new Set<PluginType>([
+ PluginType.EditorReplacement,
+]);
+
+function isSingletonType(type: PluginType): boolean {
+ return SingletonTypes.has(type);
+}
+
class Plugins {
plugins: Plugin[] = [];
@@ -179,9 +188,8 @@ class Plugins {
return;
}
- // Handle singleton plugins (only one per type allowed)
- const mode = plugin.info.registrationMode || 'multiple';
- if (mode === 'singleton') {
+ // Handle singleton-by-type plugins (only one per type allowed)
+ if (isSingletonType(plugin.info.type)) {
const existingPlugin = this.replacementPlugins.get(plugin.info.type);
if (existingPlugin) {
const error = new Error(
diff --git a/ui/src/utils/pluginKit/interface.ts
b/ui/src/utils/pluginKit/interface.ts
index 1a2c4bee..d57729e5 100644
--- a/ui/src/utils/pluginKit/interface.ts
+++ b/ui/src/utils/pluginKit/interface.ts
@@ -39,7 +39,6 @@ export interface PluginInfo {
name?: string;
description?: string;
route?: string;
- registrationMode?: 'multiple' | 'singleton';
}
export interface Plugin {