From 79669c02218d760f10f8a7629f75d8e863e434d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E7=86=B1?= Date: Thu, 26 Dec 2024 17:28:08 +0800 Subject: [PATCH] fix(*): merge default plugin configuration with existing config in multiple plugins --- .../action-recorder/src/plugin.ts | 7 +++-- .../debugger/src/debugger-plugin.ts | 7 +++-- packages/data-validation/src/plugin.ts | 7 +++-- packages/docs-drawing-ui/src/plugin.ts | 7 +++-- packages/docs-drawing/src/plugin.ts | 7 +++-- packages/docs-hyper-link-ui/src/plugin.ts | 7 +++-- packages/docs-hyper-link/src/plugin.ts | 7 +++-- packages/docs-mention-ui/src/plugin.ts | 7 +++-- packages/docs-thread-comment-ui/src/plugin.ts | 7 +++-- packages/docs-ui/src/docs-ui-plugin.ts | 7 +++-- packages/docs/src/doc-plugin.ts | 6 ++++- packages/drawing-ui/src/plugin.ts | 7 +++-- packages/drawing/src/plugin.ts | 7 +++-- packages/engine-formula/src/plugin.ts | 7 +++-- packages/engine-render/src/plugin.ts | 7 +++-- packages/find-replace/src/plugin.ts | 7 +++-- packages/rpc/src/plugin.ts | 12 ++++++--- .../src/mobile-plugin.ts | 6 ++++- .../src/plugin.ts | 6 ++++- .../src/plugin.ts | 7 +++-- .../sheets-crosshair-highlight/src/plugin.ts | 7 +++-- .../src/mobile-plugin.ts | 9 ++++--- .../sheets-data-validation-ui/src/plugin.ts | 9 ++++--- packages/sheets-data-validation/src/plugin.ts | 8 ++++-- packages/sheets-drawing-ui/src/plugin.ts | 6 ++++- packages/sheets-drawing/src/plugin.ts | 7 +++-- .../src/filter-ui-desktop.plugin.ts | 6 ++++- .../src/filter-ui-mobile.plugin.ts | 7 +++-- packages/sheets-filter/src/plugin.ts | 7 +++-- packages/sheets-find-replace/src/plugin.ts | 7 +++-- .../src/sheets-formula-ui.plugin.ts | 7 +++-- .../src/sheets-formula.plugin.ts | 12 ++++++--- packages/sheets-graphics/src/plugin.ts | 7 +++-- packages/sheets-hyper-link-ui/src/plugin.ts | 7 +++-- packages/sheets-hyper-link/src/plugin.ts | 7 +++-- packages/sheets-numfmt-ui/src/plugin.ts | 7 +++-- packages/sheets-sort-ui/src/plugin.ts | 6 ++++- packages/sheets-sort/src/plugin.ts | 7 +++-- .../sheets-thread-comment-ui/src/plugin.ts | 7 +++-- packages/sheets-ui/src/plugin.ts | 7 +++-- packages/sheets-zen-editor/src/plugin.ts | 7 +++-- packages/sheets/src/sheets-plugin.ts | 7 +++-- packages/slides-ui/src/slides-ui-plugin.ts | 7 +++-- packages/slides/src/slides-plugin.ts | 7 +++-- packages/thread-comment-ui/src/plugin.ts | 7 +++-- packages/thread-comment/src/plugin.ts | 7 +++-- packages/ui/src/ui-plugin.ts | 7 +++-- packages/uniscript/src/plugin.ts | 7 +++-- packages/watermark/src/plugin.ts | 26 ++++++++++++------- 49 files changed, 268 insertions(+), 103 deletions(-) diff --git a/packages-experimental/action-recorder/src/plugin.ts b/packages-experimental/action-recorder/src/plugin.ts index 049b92b376e..08bab42ecde 100644 --- a/packages-experimental/action-recorder/src/plugin.ts +++ b/packages-experimental/action-recorder/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverActionRecorderConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools } from '@univerjs/core'; import { ActionRecorderController } from './controllers/action-recorder.controller'; import { ACTION_RECORDER_PLUGIN_CONFIG_KEY, defaultPluginConfig } from './controllers/config.schema'; import { ActionRecorderService } from './services/action-recorder.service'; @@ -37,7 +37,10 @@ export class UniverActionRecorderPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages-experimental/debugger/src/debugger-plugin.ts b/packages-experimental/debugger/src/debugger-plugin.ts index 603cf2f1f9e..2743a208024 100644 --- a/packages-experimental/debugger/src/debugger-plugin.ts +++ b/packages-experimental/debugger/src/debugger-plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDebuggerConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools } from '@univerjs/core'; import { DEBUGGER_PLUGIN_CONFIG_KEY, defaultPluginConfig } from './controllers/config.schema'; import { DebuggerController } from './controllers/debugger.controller'; import { E2EController } from './controllers/e2e/e2e.controller'; @@ -36,7 +36,10 @@ export class UniverDebuggerPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/data-validation/src/plugin.ts b/packages/data-validation/src/plugin.ts index eef7a217510..6c960430b75 100644 --- a/packages/data-validation/src/plugin.ts +++ b/packages/data-validation/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDataValidationConfig } from './controllers/config.schema'; -import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { ICommandService, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { AddDataValidationCommand, RemoveAllDataValidationCommand, RemoveDataValidationCommand, UpdateDataValidationOptionsCommand, UpdateDataValidationSettingCommand } from './commands/commands/data-validation.command'; import { AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation } from './commands/mutations/data-validation.mutation'; import { DATA_VALIDATION_PLUGIN_CONFIG_KEY, defaultPluginConfig } from './controllers/config.schema'; @@ -39,7 +39,10 @@ export class UniverDataValidationPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(DATA_VALIDATION_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/docs-drawing-ui/src/plugin.ts b/packages/docs-drawing-ui/src/plugin.ts index 803fb90baf9..d0317d2244b 100644 --- a/packages/docs-drawing-ui/src/plugin.ts +++ b/packages/docs-drawing-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDocsDrawingUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverDocsDrawingPlugin } from '@univerjs/docs-drawing'; import { UniverDrawingPlugin } from '@univerjs/drawing'; import { UniverDrawingUIPlugin } from '@univerjs/drawing-ui'; @@ -47,7 +47,10 @@ export class UniverDocsDrawingUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(DOCS_DRAWING_UI_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/docs-drawing/src/plugin.ts b/packages/docs-drawing/src/plugin.ts index c86ed6d20d5..d8efb9a379b 100644 --- a/packages/docs-drawing/src/plugin.ts +++ b/packages/docs-drawing/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDocsDrawingConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { defaultPluginConfig, DOCS_DRAWING_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { DocDrawingController, DOCS_DRAWING_PLUGIN } from './controllers/doc-drawing.controller'; import { DocDrawingService, IDocDrawingService } from './services/doc-drawing.service'; @@ -33,7 +33,10 @@ export class UniverDocsDrawingPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(DOCS_DRAWING_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/docs-hyper-link-ui/src/plugin.ts b/packages/docs-hyper-link-ui/src/plugin.ts index c3a87760a38..b9ac0b2f581 100644 --- a/packages/docs-hyper-link-ui/src/plugin.ts +++ b/packages/docs-hyper-link-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDocsHyperLinkUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverDocsHyperLinkPlugin } from '@univerjs/docs-hyper-link'; import { IRenderManagerService } from '@univerjs/engine-render'; import { defaultPluginConfig, DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -41,7 +41,10 @@ export class UniverDocsHyperLinkUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/docs-hyper-link/src/plugin.ts b/packages/docs-hyper-link/src/plugin.ts index a1c73e33879..44720e8b6b9 100644 --- a/packages/docs-hyper-link/src/plugin.ts +++ b/packages/docs-hyper-link/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDocsHyperLinkConfig } from './controllers/config.schema'; -import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { ICommandService, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { AddHyperLinkMuatation, DeleteHyperLinkMuatation, UpdateHyperLinkMuatation } from './commands/mutations/hyper-link.mutation'; import { defaultPluginConfig, DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { DOC_HYPER_LINK_PLUGIN, DocHyperLinkResourceController } from './controllers/resource.controller'; @@ -34,7 +34,10 @@ export class UniverDocsHyperLinkPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(DOCS_HYPER_LINK_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/docs-mention-ui/src/plugin.ts b/packages/docs-mention-ui/src/plugin.ts index 336438426e2..ec83493ad4a 100644 --- a/packages/docs-mention-ui/src/plugin.ts +++ b/packages/docs-mention-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDocsMentionUIConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { defaultPluginConfig, DOCS_MENTION_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { DocMentionTriggerController } from './controllers/doc-mention-trigger.controller'; import { DocMentionUIController } from './controllers/doc-mention-ui.controller'; @@ -36,7 +36,10 @@ export class UniverDocsMentionUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/docs-thread-comment-ui/src/plugin.ts b/packages/docs-thread-comment-ui/src/plugin.ts index da76366b18e..ff98d2095ac 100644 --- a/packages/docs-thread-comment-ui/src/plugin.ts +++ b/packages/docs-thread-comment-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDocsThreadCommentUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; import { PLUGIN_NAME } from './common/const'; @@ -40,7 +40,10 @@ export class UniverDocsThreadCommentUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/docs-ui/src/docs-ui-plugin.ts b/packages/docs-ui/src/docs-ui-plugin.ts index cc821916a23..15b2916bac5 100644 --- a/packages/docs-ui/src/docs-ui-plugin.ts +++ b/packages/docs-ui/src/docs-ui-plugin.ts @@ -24,7 +24,7 @@ import { Injector, IUniverInstanceService, mergeOverrideWithDependencies, - Plugin, touchDependencies, UniverInstanceType, + Plugin, Tools, touchDependencies, UniverInstanceType, } from '@univerjs/core'; import { DocInterceptorService, DocSkeletonManagerService } from '@univerjs/docs'; import { IRenderManagerService, UniverRenderEnginePlugin } from '@univerjs/engine-render'; @@ -114,7 +114,10 @@ export class UniverDocsUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/docs/src/doc-plugin.ts b/packages/docs/src/doc-plugin.ts index a90dca6281f..e414edf92c5 100644 --- a/packages/docs/src/doc-plugin.ts +++ b/packages/docs/src/doc-plugin.ts @@ -22,6 +22,7 @@ import { Inject, Injector, Plugin, + Tools, } from '@univerjs/core'; import { RichTextEditingMutation } from './commands/mutations/core-editing.mutation'; import { DocsRenameMutation } from './commands/mutations/docs-rename.mutation'; @@ -45,7 +46,10 @@ export class UniverDocsPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(DOCS_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/drawing-ui/src/plugin.ts b/packages/drawing-ui/src/plugin.ts index 00bea883b1e..c821eb93b69 100644 --- a/packages/drawing-ui/src/plugin.ts +++ b/packages/drawing-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDrawingUIConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools } from '@univerjs/core'; import { defaultPluginConfig, DRAWING_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { DrawingUIController } from './controllers/drawing-ui.controller'; import { DrawingUpdateController } from './controllers/drawing-update.controller'; @@ -37,7 +37,10 @@ export class UniverDrawingUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/drawing/src/plugin.ts b/packages/drawing/src/plugin.ts index 94ef8d11ff3..3bf5ba16758 100644 --- a/packages/drawing/src/plugin.ts +++ b/packages/drawing/src/plugin.ts @@ -17,7 +17,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverDrawingConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin } from '@univerjs/core'; +import { IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, Tools } from '@univerjs/core'; import { defaultPluginConfig, DRAWING_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { DrawingManagerService } from './services/drawing-manager-impl.service'; import { IDrawingManagerService } from './services/drawing-manager.service'; @@ -37,7 +37,10 @@ export class UniverDrawingPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(DRAWING_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/engine-formula/src/plugin.ts b/packages/engine-formula/src/plugin.ts index 1a4bf792ffc..a31c6af0e74 100644 --- a/packages/engine-formula/src/plugin.ts +++ b/packages/engine-formula/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverEngineFormulaConfig } from './controller/config.schema'; -import { IConfigService, Inject, Injector, Plugin, touchDependencies } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, touchDependencies } from '@univerjs/core'; import { CalculateController } from './controller/calculate.controller'; import { defaultPluginConfig, ENGINE_FORMULA_PLUGIN_CONFIG_KEY } from './controller/config.schema'; import { FormulaController } from './controller/formula.controller'; @@ -67,7 +67,10 @@ export class UniverFormulaEnginePlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(ENGINE_FORMULA_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/engine-render/src/plugin.ts b/packages/engine-render/src/plugin.ts index 21b057cf140..89195c4183f 100644 --- a/packages/engine-render/src/plugin.ts +++ b/packages/engine-render/src/plugin.ts @@ -16,7 +16,7 @@ import type { IUniverEngineRenderConfig } from './controllers/config.schema'; -import { createIdentifier, IConfigService, Inject, Injector, Plugin, registerDependencies } from '@univerjs/core'; +import { createIdentifier, IConfigService, Inject, Injector, Plugin, registerDependencies, Tools } from '@univerjs/core'; import { defaultPluginConfig, ENGINE_RENDER_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { Engine } from './engine'; import { IRenderManagerService, RenderManagerService } from './render-manager/render-manager.service'; @@ -39,7 +39,10 @@ export class UniverRenderEnginePlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(ENGINE_RENDER_PLUGIN_CONFIG_KEY, rest); registerDependencies(this._injector, [ diff --git a/packages/find-replace/src/plugin.ts b/packages/find-replace/src/plugin.ts index 858151e19ac..4b813495975 100644 --- a/packages/find-replace/src/plugin.ts +++ b/packages/find-replace/src/plugin.ts @@ -15,7 +15,7 @@ */ import type { IUniverFindReplaceConfig } from './controllers/config.schema'; -import { IConfigService, Plugin } from '@univerjs/core'; +import { IConfigService, Plugin, Tools } from '@univerjs/core'; import { type Dependency, Inject, Injector } from '@univerjs/core'; import { defaultPluginConfig, FIND_REPLACE_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -35,7 +35,10 @@ export class UniverFindReplacePlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(FIND_REPLACE_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/rpc/src/plugin.ts b/packages/rpc/src/plugin.ts index 43ec115ac88..95894a75796 100644 --- a/packages/rpc/src/plugin.ts +++ b/packages/rpc/src/plugin.ts @@ -19,7 +19,7 @@ import type { IUniverRPCMainThreadConfig, IUniverRPCWorkerThreadConfig, } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools } from '@univerjs/core'; import { defaultPluginMainThreadConfig, defaultPluginWorkerThreadConfig, @@ -56,7 +56,10 @@ export class UniverRPCMainThreadPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginMainThreadConfig, + this._config + ); this._configService.setConfig(PLUGIN_CONFIG_KEY_MAIN_THREAD, rest); } @@ -111,7 +114,10 @@ export class UniverRPCWorkerThreadPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginWorkerThreadConfig, + this._config + ); this._configService.setConfig(PLUGIN_CONFIG_KEY_WORKER_THREAD, rest); } diff --git a/packages/sheets-conditional-formatting-ui/src/mobile-plugin.ts b/packages/sheets-conditional-formatting-ui/src/mobile-plugin.ts index 66c8c8fc2d4..c3a1211c9d3 100644 --- a/packages/sheets-conditional-formatting-ui/src/mobile-plugin.ts +++ b/packages/sheets-conditional-formatting-ui/src/mobile-plugin.ts @@ -22,6 +22,7 @@ import { Inject, Injector, Plugin, + Tools, UniverInstanceType, } from '@univerjs/core'; import { SHEET_CONDITIONAL_FORMATTING_PLUGIN, UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting'; @@ -63,7 +64,10 @@ export class UniverSheetsConditionalFormattingMobileUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-conditional-formatting-ui/src/plugin.ts b/packages/sheets-conditional-formatting-ui/src/plugin.ts index 48a17d3b33f..d33d1d501af 100644 --- a/packages/sheets-conditional-formatting-ui/src/plugin.ts +++ b/packages/sheets-conditional-formatting-ui/src/plugin.ts @@ -23,6 +23,7 @@ import { Injector, Plugin, registerDependencies, + Tools, touchDependencies, UniverInstanceType, } from '@univerjs/core'; @@ -72,7 +73,10 @@ export class UniverSheetsConditionalFormattingUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-conditional-formatting/src/plugin.ts b/packages/sheets-conditional-formatting/src/plugin.ts index 36cd489536a..1e55c3f4ef8 100644 --- a/packages/sheets-conditional-formatting/src/plugin.ts +++ b/packages/sheets-conditional-formatting/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsConditionalFormattingConfig } from './controllers/config.schema'; -import { ICommandService, IConfigService, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { ICommandService, IConfigService, Inject, Injector, Plugin, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { SHEET_CONDITIONAL_FORMATTING_PLUGIN } from './base/const'; import { AddConditionalRuleMutation } from './commands/mutations/add-conditional-rule.mutation'; import { DeleteConditionalRuleMutation } from './commands/mutations/delete-conditional-rule.mutation'; @@ -45,7 +45,10 @@ export class UniverSheetsConditionalFormattingPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_CONDITIONAL_FORMATTING_PLUGIN_CONFIG_KEY, rest); ([ diff --git a/packages/sheets-crosshair-highlight/src/plugin.ts b/packages/sheets-crosshair-highlight/src/plugin.ts index 5a401eeffa7..125e9bf71f1 100644 --- a/packages/sheets-crosshair-highlight/src/plugin.ts +++ b/packages/sheets-crosshair-highlight/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsCrosshairHighlightConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { defaultPluginConfig, SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { SheetsCrosshairHighlightController } from './controllers/crosshair.controller'; @@ -36,7 +36,10 @@ export class UniverSheetsCrosshairHighlightPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-data-validation-ui/src/mobile-plugin.ts b/packages/sheets-data-validation-ui/src/mobile-plugin.ts index 3a74648dbc1..221ccb86ab9 100644 --- a/packages/sheets-data-validation-ui/src/mobile-plugin.ts +++ b/packages/sheets-data-validation-ui/src/mobile-plugin.ts @@ -16,7 +16,7 @@ import type { Dependency, Workbook } from '@univerjs/core'; import type { IUniverSheetsDataValidationUIConfig } from './controllers/config.schema'; -import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { ICommandService, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { AddSheetDataValidationAndOpenCommand } from './commands/commands/data-validation-ui.command'; import { @@ -51,8 +51,11 @@ export class UniverSheetsDataValidationMobileUIPlugin extends Plugin { ) { super(); - // Manage the plugin configuration.. - const { menu, ...rest } = this._config; + // Manage the plugin configuration. + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-data-validation-ui/src/plugin.ts b/packages/sheets-data-validation-ui/src/plugin.ts index d70a8c44101..c946a6f5e9a 100644 --- a/packages/sheets-data-validation-ui/src/plugin.ts +++ b/packages/sheets-data-validation-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency, Workbook } from '@univerjs/core'; import type { IUniverSheetsDataValidationUIConfig } from './controllers/config.schema'; -import { ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { ICommandService, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { AddSheetDataValidationAndOpenCommand } from './commands/commands/data-validation-ui.command'; import { @@ -52,8 +52,11 @@ export class UniverSheetsDataValidationUIPlugin extends Plugin { ) { super(); - // Manage the plugin configuration.. - const { menu, ...rest } = this._config; + // Manage the plugin configuration. + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-data-validation/src/plugin.ts b/packages/sheets-data-validation/src/plugin.ts index 2b0d3914bae..4fc57ebcb18 100644 --- a/packages/sheets-data-validation/src/plugin.ts +++ b/packages/sheets-data-validation/src/plugin.ts @@ -20,6 +20,7 @@ import { ICommandService, IConfigService, Plugin, + Tools, UniverInstanceType, } from '@univerjs/core'; import { type Dependency, Inject, Injector } from '@univerjs/core'; @@ -59,8 +60,11 @@ export class UniverSheetsDataValidationPlugin extends Plugin { ) { super(); - // Manage the plugin configuration.. - const { ...rest } = this._config; + // Manage the plugin configuration. + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_DATA_VALIDATION_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-drawing-ui/src/plugin.ts b/packages/sheets-drawing-ui/src/plugin.ts index 2cd12c30998..48550c84b46 100644 --- a/packages/sheets-drawing-ui/src/plugin.ts +++ b/packages/sheets-drawing-ui/src/plugin.ts @@ -23,6 +23,7 @@ import { Injector, Plugin, registerDependencies, + Tools, touchDependencies, UniverInstanceType, } from '@univerjs/core'; @@ -61,7 +62,10 @@ export class UniverSheetsDrawingUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-drawing/src/plugin.ts b/packages/sheets-drawing/src/plugin.ts index 7da19f005d3..2443032433d 100644 --- a/packages/sheets-drawing/src/plugin.ts +++ b/packages/sheets-drawing/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsDrawingConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverDrawingPlugin } from '@univerjs/drawing'; import { defaultPluginConfig, SHEETS_DRAWING_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { SHEET_DRAWING_PLUGIN, SheetsDrawingLoadController } from './controllers/sheet-drawing.controller'; @@ -35,7 +35,10 @@ export class UniverSheetsDrawingPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_DRAWING_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts b/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts index 969977eebe1..30511efe0ce 100644 --- a/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts +++ b/packages/sheets-filter-ui/src/filter-ui-desktop.plugin.ts @@ -23,6 +23,7 @@ import { Injector, Optional, Plugin, + Tools, UniverInstanceType, } from '@univerjs/core'; import { IRPCChannelService, toModule } from '@univerjs/rpc'; @@ -52,7 +53,10 @@ export class UniverSheetsFilterUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-filter-ui/src/filter-ui-mobile.plugin.ts b/packages/sheets-filter-ui/src/filter-ui-mobile.plugin.ts index 8430c75bf56..446fcde4d29 100644 --- a/packages/sheets-filter-ui/src/filter-ui-mobile.plugin.ts +++ b/packages/sheets-filter-ui/src/filter-ui-mobile.plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsFilterUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter'; import { defaultPluginConfig, SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -38,7 +38,10 @@ export class UniverSheetsFilterMobileUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-filter/src/plugin.ts b/packages/sheets-filter/src/plugin.ts index b45a3c4ff26..fec3779ee23 100644 --- a/packages/sheets-filter/src/plugin.ts +++ b/packages/sheets-filter/src/plugin.ts @@ -17,7 +17,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsFilterConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { defaultPluginConfig, SHEETS_FILTER_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { SheetsFilterController } from './controllers/sheets-filter.controller'; import { SHEET_FILTER_SNAPSHOT_ID, SheetsFilterService } from './services/sheet-filter.service'; @@ -34,7 +34,10 @@ export class UniverSheetsFilterPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_FILTER_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-find-replace/src/plugin.ts b/packages/sheets-find-replace/src/plugin.ts index 4e6eee349ce..c61ad8e38c0 100644 --- a/packages/sheets-find-replace/src/plugin.ts +++ b/packages/sheets-find-replace/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsFindReplaceConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverFindReplacePlugin } from '@univerjs/find-replace'; import { UniverSheetsPlugin } from '@univerjs/sheets'; import { defaultPluginConfig, SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -37,7 +37,10 @@ export class UniverSheetsFindReplacePlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_FIND_REPLACE_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts index 9e097a76622..1f6ad8f6ced 100644 --- a/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts +++ b/packages/sheets-formula-ui/src/sheets-formula-ui.plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsFormulaBaseConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; import { IRenderManagerService } from '@univerjs/engine-render'; import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'; @@ -56,7 +56,10 @@ export class UniverSheetsFormulaUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginBaseConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-formula/src/sheets-formula.plugin.ts b/packages/sheets-formula/src/sheets-formula.plugin.ts index a13f46c5a28..35b6a83cf25 100644 --- a/packages/sheets-formula/src/sheets-formula.plugin.ts +++ b/packages/sheets-formula/src/sheets-formula.plugin.ts @@ -19,7 +19,7 @@ import type { IUniverSheetsFormulaBaseConfig, IUniverSheetsFormulaRemoteConfig, } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, isNodeEnv, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, isNodeEnv, Plugin, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; import { fromModule, IRPCChannelService, toModule } from '@univerjs/rpc'; @@ -58,7 +58,10 @@ export class UniverRemoteSheetsFormulaPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginRemoteConfig, + this._config + ); this._configService.setConfig(PLUGIN_CONFIG_KEY_REMOTE, rest); } @@ -84,7 +87,10 @@ export class UniverSheetsFormulaPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginBaseConfig, + this._config + ); this._configService.setConfig(PLUGIN_CONFIG_KEY_BASE, rest); } diff --git a/packages/sheets-graphics/src/plugin.ts b/packages/sheets-graphics/src/plugin.ts index ece07b28022..a268996b9bd 100644 --- a/packages/sheets-graphics/src/plugin.ts +++ b/packages/sheets-graphics/src/plugin.ts @@ -17,7 +17,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetGraphicsConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { SheetGraphicsRenderController } from './controllers/graphics-render.controller'; @@ -35,7 +35,10 @@ export class UniverSheetGraphicsPlugin extends Plugin { ) { super(); - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-hyper-link-ui/src/plugin.ts b/packages/sheets-hyper-link-ui/src/plugin.ts index 98d90424b28..39a8aa12e36 100644 --- a/packages/sheets-hyper-link-ui/src/plugin.ts +++ b/packages/sheets-hyper-link-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency, Workbook } from '@univerjs/core'; import type { IUniverSheetsHyperLinkUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverDocsUIPlugin } from '@univerjs/docs-ui'; import { IRenderManagerService } from '@univerjs/engine-render'; import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link'; @@ -46,7 +46,10 @@ export class UniverSheetsHyperLinkUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-hyper-link/src/plugin.ts b/packages/sheets-hyper-link/src/plugin.ts index a5c1bbd7396..90c1cd0f14f 100644 --- a/packages/sheets-hyper-link/src/plugin.ts +++ b/packages/sheets-hyper-link/src/plugin.ts @@ -15,7 +15,7 @@ */ import type { IUniverSheetsHyperLinkConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, registerDependencies, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { UniverSheetsPlugin } from '@univerjs/sheets'; import { defaultPluginConfig, SHEETS_HYPER_LINK_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { SheetsHyperLinkRefRangeController } from './controllers/ref-range.controller'; @@ -41,7 +41,10 @@ export class UniverSheetsHyperLinkPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_HYPER_LINK_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-numfmt-ui/src/plugin.ts b/packages/sheets-numfmt-ui/src/plugin.ts index 2954a6a24bc..27b017d0894 100644 --- a/packages/sheets-numfmt-ui/src/plugin.ts +++ b/packages/sheets-numfmt-ui/src/plugin.ts @@ -15,7 +15,7 @@ */ import type { IUniverSheetsNumfmtUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, Plugin, registerDependencies, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt'; import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'; import { UI_PLUGIN_CONFIG_KEY } from '@univerjs/ui'; @@ -40,7 +40,10 @@ export class UniverSheetsNumfmtUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-sort-ui/src/plugin.ts b/packages/sheets-sort-ui/src/plugin.ts index 61a01648fd5..94164c62283 100644 --- a/packages/sheets-sort-ui/src/plugin.ts +++ b/packages/sheets-sort-ui/src/plugin.ts @@ -22,6 +22,7 @@ import { Inject, Injector, Plugin, + Tools, UniverInstanceType, } from '@univerjs/core'; import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort'; @@ -44,7 +45,10 @@ export class UniverSheetsSortUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_SORT_UI_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-sort/src/plugin.ts b/packages/sheets-sort/src/plugin.ts index 6772ecd981d..c9c010104a3 100644 --- a/packages/sheets-sort/src/plugin.ts +++ b/packages/sheets-sort/src/plugin.ts @@ -17,7 +17,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsSortConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { defaultPluginConfig, SHEETS_SORT_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { SheetsSortController } from './controllers/sheets-sort.controller'; import { SheetsSortService } from './services/sheets-sort.service'; @@ -36,7 +36,10 @@ export class UniverSheetsSortPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_SORT_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/sheets-thread-comment-ui/src/plugin.ts b/packages/sheets-thread-comment-ui/src/plugin.ts index 7e4599e9ca5..85d6a007eff 100644 --- a/packages/sheets-thread-comment-ui/src/plugin.ts +++ b/packages/sheets-thread-comment-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsThreadCommentUIConfig } from './controllers/config.schema'; -import { DependentOn, ICommandService, IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, ICommandService, IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment'; import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui'; import { ShowAddSheetCommentModalOperation } from './commands/operations/comment.operation'; @@ -44,7 +44,10 @@ export class UniverSheetsThreadCommentUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets-ui/src/plugin.ts b/packages/sheets-ui/src/plugin.ts index 8857cfd65c0..2f83179ba27 100644 --- a/packages/sheets-ui/src/plugin.ts +++ b/packages/sheets-ui/src/plugin.ts @@ -17,7 +17,7 @@ import type { Dependency, Workbook } from '@univerjs/core'; import type { IUniverUIConfig } from '@univerjs/ui'; import type { IUniverSheetsUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, IUniverInstanceService, mergeOverrideWithDependencies, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, IUniverInstanceService, mergeOverrideWithDependencies, Plugin, registerDependencies, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { IRefSelectionsService, RefSelectionsService, UniverSheetsPlugin } from '@univerjs/sheets'; import { UI_PLUGIN_CONFIG_KEY } from '@univerjs/ui'; @@ -106,7 +106,10 @@ export class UniverSheetsUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); diff --git a/packages/sheets-zen-editor/src/plugin.ts b/packages/sheets-zen-editor/src/plugin.ts index 3fff59296b3..55a96e0beac 100644 --- a/packages/sheets-zen-editor/src/plugin.ts +++ b/packages/sheets-zen-editor/src/plugin.ts @@ -17,7 +17,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsZenEditorConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { defaultPluginConfig, SHEETS_ZEN_EDITOR_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { ZenEditorUIController } from './controllers/zen-editor-ui.controller'; import { ZenEditorController } from './controllers/zen-editor.controller'; @@ -35,7 +35,10 @@ export class UniverSheetsZenEditorPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/sheets/src/sheets-plugin.ts b/packages/sheets/src/sheets-plugin.ts index c071da782bc..51239fdb9f8 100644 --- a/packages/sheets/src/sheets-plugin.ts +++ b/packages/sheets/src/sheets-plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverSheetsConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, Inject, Injector, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, mergeOverrideWithDependencies, Plugin, registerDependencies, touchDependencies, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, IConfigService, Inject, Injector, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, mergeOverrideWithDependencies, Plugin, registerDependencies, Tools, touchDependencies, UniverInstanceType } from '@univerjs/core'; import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'; import { BasicWorksheetController } from './controllers/basic-worksheet.controller'; import { CalculateResultApplyController } from './controllers/calculate-result-apply.controller'; @@ -56,7 +56,10 @@ export class UniverSheetsPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SHEETS_PLUGIN_CONFIG_KEY, rest); this._initConfig(); diff --git a/packages/slides-ui/src/slides-ui-plugin.ts b/packages/slides-ui/src/slides-ui-plugin.ts index fb09c58083d..efe2b98e11b 100644 --- a/packages/slides-ui/src/slides-ui-plugin.ts +++ b/packages/slides-ui/src/slides-ui-plugin.ts @@ -16,7 +16,7 @@ import type { Dependency, SlideDataModel } from '@univerjs/core'; import type { IUniverSlidesUIConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, IUniverInstanceService, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, IUniverInstanceService, mergeOverrideWithDependencies, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { CanvasView } from './controllers/canvas-view'; import { defaultPluginConfig, SLIDES_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -46,7 +46,10 @@ export class UniverSlidesUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/slides/src/slides-plugin.ts b/packages/slides/src/slides-plugin.ts index 2cb3fbf8a29..f871ca6cc50 100644 --- a/packages/slides/src/slides-plugin.ts +++ b/packages/slides/src/slides-plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { Engine } from '@univerjs/engine-render'; -import { IConfigService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderingEngine, IRenderManagerService } from '@univerjs/engine-render'; import { defaultPluginConfig, SLIDES_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; // import { DocSelectionManagerService } from '@univerjs/docs'; @@ -45,7 +45,10 @@ export class UniverSlidesPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(SLIDES_PLUGIN_CONFIG_KEY, rest); this._initializeDependencies(this._injector); diff --git a/packages/thread-comment-ui/src/plugin.ts b/packages/thread-comment-ui/src/plugin.ts index bebd9bdf927..f446890c5fa 100644 --- a/packages/thread-comment-ui/src/plugin.ts +++ b/packages/thread-comment-ui/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverThreadCommentUIConfig } from './controllers/config.schema'; -import { DependentOn, ICommandService, IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core'; +import { DependentOn, ICommandService, IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { UniverThreadCommentPlugin } from '@univerjs/thread-comment'; import { SetActiveCommentOperation, ToggleSheetCommentPanelOperation } from './commands/operations/comment.operations'; import { defaultPluginConfig, THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -37,7 +37,10 @@ export class UniverThreadCommentUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/thread-comment/src/plugin.ts b/packages/thread-comment/src/plugin.ts index 867ee08372b..52507e43252 100644 --- a/packages/thread-comment/src/plugin.ts +++ b/packages/thread-comment/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverThreadCommentConfig } from './controllers/config.schema'; -import { ICommandService, IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core'; +import { ICommandService, IConfigService, Inject, Injector, mergeOverrideWithDependencies, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand } from './commands/commands/comment.command'; import { AddCommentMutation, DeleteCommentMutation, ResolveCommentMutation, UpdateCommentMutation, UpdateCommentRefMutation } from './commands/mutations/comment.mutation'; import { defaultPluginConfig, THREAD_COMMENT_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; @@ -38,7 +38,10 @@ export class UniverThreadCommentPlugin extends Plugin { super(); // Manage the plugin configuration. - const { ...rest } = this._config; + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); this._configService.setConfig(THREAD_COMMENT_PLUGIN_CONFIG_KEY, rest); } diff --git a/packages/ui/src/ui-plugin.ts b/packages/ui/src/ui-plugin.ts index 81932bce242..0e3dcd875d9 100644 --- a/packages/ui/src/ui-plugin.ts +++ b/packages/ui/src/ui-plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverUIConfig } from './controllers/config.schema'; -import { DependentOn, IConfigService, IContextService, ILocalStorageService, Inject, Injector, mergeOverrideWithDependencies, Plugin } from '@univerjs/core'; +import { DependentOn, IConfigService, IContextService, ILocalStorageService, Inject, Injector, mergeOverrideWithDependencies, Plugin, Tools } from '@univerjs/core'; import { UniverRenderEnginePlugin } from '@univerjs/engine-render'; import { ComponentManager } from './common/component-manager'; @@ -76,7 +76,10 @@ export class UniverUIPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (rest.disableAutoFocus) { this._contextService.setContextValue(DISABLE_AUTO_FOCUS_KEY, true); } diff --git a/packages/uniscript/src/plugin.ts b/packages/uniscript/src/plugin.ts index fd28cdc84f0..c201ded9158 100644 --- a/packages/uniscript/src/plugin.ts +++ b/packages/uniscript/src/plugin.ts @@ -16,7 +16,7 @@ import type { Dependency } from '@univerjs/core'; import type { IUniverUniscriptConfig } from './controllers/config.schema'; -import { IConfigService, Inject, Injector, Plugin } from '@univerjs/core'; +import { IConfigService, Inject, Injector, Plugin, Tools } from '@univerjs/core'; import { defaultPluginConfig, UNISCRIPT_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { UniscriptController } from './controllers/uniscript.controller'; import { ScriptEditorService } from './services/script-editor.service'; @@ -36,7 +36,10 @@ export class UniverUniscriptPlugin extends Plugin { super(); // Manage the plugin configuration. - const { menu, ...rest } = this._config; + const { menu, ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); if (menu) { this._configService.setConfig('menu', menu, { merge: true }); } diff --git a/packages/watermark/src/plugin.ts b/packages/watermark/src/plugin.ts index 06cc5e04c2d..7529cbd2901 100644 --- a/packages/watermark/src/plugin.ts +++ b/packages/watermark/src/plugin.ts @@ -17,10 +17,11 @@ import type { Dependency } from '@univerjs/core'; import type { IWatermarkConfigWithType } from './common/type'; import type { IUniverWatermarkConfig } from './controllers/config.schema'; -import { IConfigService, ILocalStorageService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core'; +import { IConfigService, ILocalStorageService, Inject, Injector, Plugin, Tools, UniverInstanceType } from '@univerjs/core'; import { IRenderManagerService } from '@univerjs/engine-render'; import { UNIVER_WATERMARK_STORAGE_KEY, WatermarkImageBaseConfig, WatermarkTextBaseConfig, WatermarkUserInfoBaseConfig } from './common/const'; import { IWatermarkTypeEnum } from './common/type'; +import { defaultPluginConfig, WATERMARK_PLUGIN_CONFIG_KEY } from './controllers/config.schema'; import { WatermarkRenderController } from './controllers/watermark.render.controller'; import { WatermarkService } from './services/watermark.service'; @@ -30,7 +31,7 @@ export class UniverWatermarkPlugin extends Plugin { static override pluginName = PLUGIN_NAME; constructor( - private readonly _config: Partial = {}, + private readonly _config: Partial = defaultPluginConfig, @Inject(Injector) protected override _injector: Injector, @IConfigService private readonly _configService: IConfigService, @IRenderManagerService private readonly _renderManagerSrv: IRenderManagerService, @@ -38,18 +39,25 @@ export class UniverWatermarkPlugin extends Plugin { ) { super(); + // Manage the plugin configuration. + const { ...rest } = Tools.deepMerge( + defaultPluginConfig, + this._config + ); + this._configService.setConfig(WATERMARK_PLUGIN_CONFIG_KEY, rest); + this._initWatermarkStorage(); this._initDependencies(); } private async _initWatermarkStorage() { - const { ...rest } = this._config; - if (rest.userWatermarkSettings) { - this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.UserInfo, config: { userInfo: { ...WatermarkUserInfoBaseConfig, ...rest.userWatermarkSettings } } }); - } else if (rest.textWatermarkSettings) { - this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.Text, config: { text: { ...WatermarkTextBaseConfig, ...rest.textWatermarkSettings } } }); - } else if (rest.imageWatermarkSettings) { - this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.Image, config: { image: { ...WatermarkImageBaseConfig, ...rest.imageWatermarkSettings } } }); + const { userWatermarkSettings, textWatermarkSettings, imageWatermarkSettings } = this._config; + if (userWatermarkSettings) { + this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.UserInfo, config: { userInfo: { ...WatermarkUserInfoBaseConfig, userWatermarkSettings } } }); + } else if (textWatermarkSettings) { + this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.Text, config: { text: { ...WatermarkTextBaseConfig, textWatermarkSettings } } }); + } else if (imageWatermarkSettings) { + this._localStorageService.setItem(UNIVER_WATERMARK_STORAGE_KEY, { type: IWatermarkTypeEnum.Image, config: { image: { ...WatermarkImageBaseConfig, imageWatermarkSettings } } }); } else { const config = await this._localStorageService.getItem(UNIVER_WATERMARK_STORAGE_KEY); if (config?.type === IWatermarkTypeEnum.UserInfo) {