Skip to content

Commit

Permalink
fix(*): merge default plugin configuration with existing config in mu…
Browse files Browse the repository at this point in the history
…ltiple plugins
  • Loading branch information
jikkai committed Dec 26, 2024
1 parent 57467da commit 79669c0
Show file tree
Hide file tree
Showing 49 changed files with 268 additions and 103 deletions.
7 changes: 5 additions & 2 deletions packages-experimental/action-recorder/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
}
Expand Down
7 changes: 5 additions & 2 deletions packages-experimental/debugger/src/debugger-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
}
Expand Down
7 changes: 5 additions & 2 deletions packages/data-validation/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/docs-drawing-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/docs-drawing/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/docs-hyper-link-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
}
Expand Down
7 changes: 5 additions & 2 deletions packages/docs-hyper-link/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/docs-mention-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
}
Expand Down
7 changes: 5 additions & 2 deletions packages/docs-thread-comment-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
}
Expand Down
7 changes: 5 additions & 2 deletions packages/docs-ui/src/docs-ui-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });
}
Expand Down
6 changes: 5 additions & 1 deletion packages/docs/src/doc-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/drawing-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
}
Expand Down
7 changes: 5 additions & 2 deletions packages/drawing/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/engine-formula/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/engine-render/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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, [
Expand Down
7 changes: 5 additions & 2 deletions packages/find-replace/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
12 changes: 9 additions & 3 deletions packages/rpc/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Inject,
Injector,
Plugin,
Tools,
UniverInstanceType,
} from '@univerjs/core';
import { SHEET_CONDITIONAL_FORMATTING_PLUGIN, UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
Expand Down Expand Up @@ -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 });
}
Expand Down
Loading

0 comments on commit 79669c0

Please sign in to comment.