Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
chore: normalize plugin config registration (#7179)
白熱b0ba09c455c7
diff --git a/packages/sheets-filter-ui/src/worker/plugin.ts b/packages/sheets-filter-ui/src/worker/plugin.tsindex 2b6e2fc2b9..3d43ae8b0a 100644--- a/packages/sheets-filter-ui/src/worker/plugin.ts+++ b/packages/sheets-filter-ui/src/worker/plugin.ts@@ -15,9 +15,11 @@*/import type { Dependency } from '@univerjs/core';-import { Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';+import type { IUniverSheetsFilterUIConfig } from '../config/config';+import { IConfigService, Inject, Injector, merge, Plugin, UniverInstanceType } from '@univerjs/core';import { fromModule, IRPCChannelService } from '@univerjs/rpc';import pkg from '../../package.json';+import { defaultPluginConfig, SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY } from '../config/config';import { ISheetsGenerateFilterValuesService, SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME, SheetsGenerateFilterValuesService } from './generate-filter-values.service';export class UniverSheetsFilterUIWorkerPlugin extends Plugin {@@ -27,11 +29,19 @@ export class UniverSheetsFilterUIWorkerPlugin extends Plugin {static override version = pkg.version;constructor(- private readonly _config: unknown,+ private readonly _config: Partial<IUniverSheetsFilterUIConfig> = defaultPluginConfig,@Inject(Injector) protected readonly _injector: Injector,+ @IConfigService private readonly _configService: IConfigService,@IRPCChannelService private readonly _rpcChannelService: IRPCChannelService) {super();++ const { ...rest } = merge(+ {},+ defaultPluginConfig,+ this._config+ );+ this._configService.setConfig(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);}override onStarting() {diff --git a/packages/sheets-numfmt-ui/src/plugin.ts b/packages/sheets-numfmt-ui/src/plugin.tsindex 1ccc3be1e9..910d74b870 100644--- a/packages/sheets-numfmt-ui/src/plugin.ts+++ b/packages/sheets-numfmt-ui/src/plugin.ts@@ -31,7 +31,7 @@ import { IRenderManagerService } from '@univerjs/engine-render';import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';import pkg from '../package.json';-import { defaultPluginConfig } from './config/config';+import { defaultPluginConfig, SHEETS_NUMFMT_UI_PLUGIN_CONFIG_KEY } from './config/config';import { ComponentsController } from './controllers/components.controller';import { NumfmtAlertRenderController } from './controllers/numfmt-alert-render.controller';import { NumfmtRepeatLastActionController } from './controllers/numfmt-repeat-last-action.controller';@@ -65,7 +65,7 @@ export class UniverSheetsNumfmtUIPlugin extends Plugin {this._configService.setConfig('menu', menu, { merge: true });}- this._configService.setConfig('sheets-numfmt-ui.config', rest);+ this._configService.setConfig(SHEETS_NUMFMT_UI_PLUGIN_CONFIG_KEY, rest);}override onStarting(): void {diff --git a/packages/sheets-thread-comment/src/plugin.ts b/packages/sheets-thread-comment/src/plugin.tsindex 11badd9956..7abf7fffe3 100644--- a/packages/sheets-thread-comment/src/plugin.ts+++ b/packages/sheets-thread-comment/src/plugin.ts@@ -16,10 +16,20 @@import type { Dependency } from '@univerjs/core';import type { IUniverSheetsThreadCommentConfig } from './config/config';-import { DependentOn, ICommandService, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core';+import {+ DependentOn,+ ICommandService,+ IConfigService,+ Inject,+ Injector,+ merge,+ Plugin,+ touchDependencies,+ UniverInstanceType,+} from '@univerjs/core';import { UniverThreadCommentPlugin } from '@univerjs/thread-comment';import pkg from '../package.json';-import { defaultPluginConfig } from './config/config';+import { defaultPluginConfig, SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY } from './config/config';import { SheetsThreadCommentRefRangeController } from './controllers/sheets-thread-comment-ref-range.controller';import { SheetsThreadCommentResourceController } from './controllers/sheets-thread-comment-resource.controller';import { SheetsThreadCommentModel } from './models/sheets-thread-comment.model';@@ -35,9 +45,17 @@ export class UniverSheetsThreadCommentPlugin extends Plugin {constructor(private readonly _config: Partial<IUniverSheetsThreadCommentConfig> = defaultPluginConfig,@Inject(Injector) protected override _injector: Injector,- @Inject(ICommandService) protected _commandService: ICommandService+ @Inject(ICommandService) protected _commandService: ICommandService,+ @IConfigService private readonly _configService: IConfigService) {super();++ const { ...rest } = merge(+ {},+ defaultPluginConfig,+ this._config+ );+ this._configService.setConfig(SHEETS_THREAD_COMMENT_PLUGIN_CONFIG_KEY, rest);}override onStarting(): void {diff --git a/packages/ui-adapter-vue3/src/config/config.ts b/packages/ui-adapter-vue3/src/config/config.tsnew file mode 100644index 0000000000..6ef91f0615--- /dev/null+++ b/packages/ui-adapter-vue3/src/config/config.ts@@ -0,0 +1,23 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export const UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY = 'ui-adapter-vue3.config';++export const configSymbol = Symbol(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY);++export interface IUniverVue3AdapterConfig {}++export const defaultPluginConfig: IUniverVue3AdapterConfig = {};diff --git a/packages/ui-adapter-vue3/src/index.ts b/packages/ui-adapter-vue3/src/index.tsindex 02ed459910..19a97ef8fd 100644--- a/packages/ui-adapter-vue3/src/index.ts+++ b/packages/ui-adapter-vue3/src/index.ts@@ -14,4 +14,6 @@* limitations under the License.*/+export { UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY } from './config/config';+export type { IUniverVue3AdapterConfig } from './config/config';export { UniverVue3AdapterPlugin } from './plugin';diff --git a/packages/ui-adapter-vue3/src/plugin.ts b/packages/ui-adapter-vue3/src/plugin.tsindex 73dcf63222..3b133eccd6 100644--- a/packages/ui-adapter-vue3/src/plugin.ts+++ b/packages/ui-adapter-vue3/src/plugin.ts@@ -16,10 +16,12 @@import type { IComponent } from '@univerjs/ui';import type { defineComponent } from 'vue';-import { DependentOn, Inject, Injector, Plugin } from '@univerjs/core';+import type { IUniverVue3AdapterConfig } from './config/config';+import { DependentOn, IConfigService, Inject, Injector, merge, Plugin } from '@univerjs/core';import { ComponentManager, UniverUIPlugin } from '@univerjs/ui';import { h, render } from 'vue';import pkg from '../package.json';+import { defaultPluginConfig, UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY } from './config/config';/*** The plugin that allows Univer to use Vue 3 components as UI components.@@ -31,11 +33,19 @@ export class UniverVue3AdapterPlugin extends Plugin {static override version = pkg.version;constructor(- private readonly _config = {},+ private readonly _config: Partial<IUniverVue3AdapterConfig> = defaultPluginConfig,@Inject(Injector) protected readonly _injector: Injector,+ @IConfigService private readonly _configService: IConfigService,@Inject(ComponentManager) protected readonly _componentManager: ComponentManager) {super();++ const { ...rest } = merge(+ {},+ defaultPluginConfig,+ this._config+ );+ this._configService.setConfig(UI_ADAPTER_VUE3_PLUGIN_CONFIG_KEY, rest);}override onStarting(): void {diff --git a/packages/ui-adapter-web-component/src/config/config.ts b/packages/ui-adapter-web-component/src/config/config.tsnew file mode 100644index 0000000000..f1e8c2ce4f--- /dev/null+++ b/packages/ui-adapter-web-component/src/config/config.ts@@ -0,0 +1,23 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export const UI_ADAPTER_WEB_COMPONENT_PLUGIN_CONFIG_KEY = 'ui-adapter-web-component.config';++export const configSymbol = Symbol(UI_ADAPTER_WEB_COMPONENT_PLUGIN_CONFIG_KEY);++export interface IUniverWebComponentAdapterConfig {}++export const defaultPluginConfig: IUniverWebComponentAdapterConfig = {};diff --git a/packages/ui-adapter-web-component/src/index.ts b/packages/ui-adapter-web-component/src/index.tsindex b77219b39c..ead778cf98 100644--- a/packages/ui-adapter-web-component/src/index.ts+++ b/packages/ui-adapter-web-component/src/index.ts@@ -14,4 +14,6 @@* limitations under the License.*/+export { UI_ADAPTER_WEB_COMPONENT_PLUGIN_CONFIG_KEY } from './config/config';+export type { IUniverWebComponentAdapterConfig } from './config/config';export { UniverWebComponentAdapterPlugin } from './plugin';diff --git a/packages/ui-adapter-web-component/src/plugin.ts b/packages/ui-adapter-web-component/src/plugin.tsindex d7c6a5d9bf..de677352f1 100644--- a/packages/ui-adapter-web-component/src/plugin.ts+++ b/packages/ui-adapter-web-component/src/plugin.ts@@ -15,9 +15,11 @@*/import type { IComponent } from '@univerjs/ui';-import { DependentOn, Inject, Injector, Plugin } from '@univerjs/core';+import type { IUniverWebComponentAdapterConfig } from './config/config';+import { DependentOn, IConfigService, Inject, Injector, merge, Plugin } from '@univerjs/core';import { ComponentManager, UniverUIPlugin } from '@univerjs/ui';import pkg from '../package.json';+import { defaultPluginConfig, UI_ADAPTER_WEB_COMPONENT_PLUGIN_CONFIG_KEY } from './config/config';/*** The plugin that allows Univer to use web components as UI components.@@ -29,11 +31,19 @@ export class UniverWebComponentAdapterPlugin extends Plugin {static override version = pkg.version;constructor(- private readonly _config = {},+ private readonly _config: Partial<IUniverWebComponentAdapterConfig> = defaultPluginConfig,@Inject(Injector) protected readonly _injector: Injector,+ @IConfigService private readonly _configService: IConfigService,@Inject(ComponentManager) protected readonly _componentManager: ComponentManager) {super();++ const { ...rest } = merge(+ {},+ defaultPluginConfig,+ this._config+ );+ this._configService.setConfig(UI_ADAPTER_WEB_COMPONENT_PLUGIN_CONFIG_KEY, rest);}override onStarting(): void {