Skip to content

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.

feat(sheets-thread-comment): optimize comment mention source injector method (#2303)

zhangwa5a7b33f37e4
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index a83414e5d1..51477894e9 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -38,6 +38,7 @@ import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment
import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { FUniver } from '@univerjs/facade';
+import { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '../data/sheets/demo/default-workbook-data-demo';
import { locales } from './locales';
@@ -107,26 +108,29 @@ const mockUser = {
canBindAnonymous: false,
};
+class CustomMentionDataService implements IThreadCommentMentionDataService {
+ trigger: string = '@';
+
+ async getMentions(search: string) {
+ return [
+ {
+ id: mockUser.userID,
+ label: mockUser.name,
+ type: 'user',
+ icon: mockUser.avatar,
+ },
+ {
+ id: '2',
+ label: 'User2',
+ type: 'user',
+ icon: mockUser.avatar,
+ },
+ ];
+ }
+}
+
univer.registerPlugin(UniverSheetsThreadCommentPlugin, {
- mentions: [{
- trigger: '@',
- getMentions: async () => {
- return [
- {
- id: mockUser.userID,
- label: mockUser.name,
- type: 'user',
- icon: mockUser.avatar,
- },
- {
- id: '2',
- label: 'User2',
- type: 'user',
- icon: mockUser.avatar,
- },
- ];
- },
- }],
+ overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]],
});
// debugger plugin
diff --git a/packages/sheets-thread-comment/README-zh.md b/packages/sheets-thread-comment/README-zh.md
index 9606191a46..c4d32288f6 100644
--- a/packages/sheets-thread-comment/README-zh.md
+++ b/packages/sheets-thread-comment/README-zh.md
@@ -22,36 +22,39 @@ pnpm add @univerjs/sheets-thread-comment
### 使用
```js
-import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';
+import { UniverSheetsThreadCommentPlugin, IThreadCommentMentionDataService } from '@univerjs/sheets-thread-comment';
const mockUser = {
userID: 'mockId',
name: 'MockUser',
- avatar: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAInSURBVHgBtZU9TxtBEIbfWRzFSIdkikhBSqRQkJqkCKTCFkqVInSUSaT0wC8w/gXxD4gU2nRJkXQWhAZowDUUWKIwEgWWbEEB3mVmx3dn4DA2nB/ppNuPeWd29mMIPXDr+RxwtgRHeW6+guNPRxogqnL7Dwz9psJ27S4NShaeZTH3kwXy6I81dlRKcmRui88swdq9AcSFL7Buz1Vmlns64MiLsCjzwnIYHLH57tbfFbs7KRaXyEU8FVZofqccOfA5l7Q8LPIkGrwnb2RPNEXWFVMUF3L+kDCk0btDDAMzOm5YfAHDwp4tG74wnzAsiOYMnJ3GoDybA7IT98/jm5+JNnfiIzAS6LlqHQBN/i6b2t/cV1Hh6BfwYlHnHP4AXi5q/8kmMMpOs8+BixZw/Fd6xUEHEbnkgclvQP2fGp7uShRKnQ3G32rkjV1th8JhIGG7tR/JyjGteSOZELwGMmNqIIigRCLRh2OZIE6BjItdd7pCW6Uhm1zzkUtungSxwEUzNpQ+GQumtH1ej1MqgmNT6vwmhCq5yuwq56EYTbgeQUz3yvrpV1b4ok3nYJ+eYhgYmjRUqErx2EDq0Fr8FhG++iqVGqxlUJI/70Ar0UgJaWHj6hYVHJrfKssAHot1JfqwE9WVWzXZVd5z2Ws/4PnmtEjkXeKJDvxUecLbWOXH/DP6QQ4J72NS0adedp1aseBfXP8odlZFfPvBF7SN/8hky1TYuPOAXAEipMx15u5ToAAAAABJRU5ErkJggg==',
+ avatar: 'avatar-icon-url',
anonymous: false,
canBindAnonymous: false,
};
+class CustomMentionDataService implements IThreadCommentMentionDataService {
+ trigger: string = '@';
+
+ // 获取提及用户的通用接口实现
+ async getMentions(search: string) {
+ return [
+ {
+ id: mockUser.userID,
+ label: mockUser.name,
+ type: 'user',
+ icon: mockUser.avatar,
+ },
+ {
+ id: '2',
+ label: 'User2',
+ type: 'user',
+ icon: mockUser.avatar,
+ },
+ ];
+ }
+}
+
univer.registerPlugin(UniverSheetsThreadCommentPlugin, {
- mentions: [{
- trigger: '@',
- // 获取提及用户的通用接口实现
- getMentions: async () => {
- return [
- {
- id: mockUser.userID,
- label: mockUser.name,
- type: 'user',
- icon: mockUser.avatar,
- },
- {
- id: '2',
- label: 'User2',
- type: 'user',
- icon: mockUser.avatar,
- },
- ];
- },
- }],
+ overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]],
});
```
diff --git a/packages/sheets-thread-comment/README.md b/packages/sheets-thread-comment/README.md
index 423aab038b..6af55ce216 100644
--- a/packages/sheets-thread-comment/README.md
+++ b/packages/sheets-thread-comment/README.md
@@ -22,36 +22,39 @@ pnpm add @univerjs/sheets-thread-comment
### use
```js
-import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';
+import { UniverSheetsThreadCommentPlugin, IThreadCommentMentionDataService} from '@univerjs/sheets-thread-comment';
const mockUser = {
userID: 'mockId',
name: 'MockUser',
- avatar: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAInSURBVHgBtZU9TxtBEIbfWRzFSIdkikhBSqRQk JqkCKTCFkqVInSUSaT0wC8w/gXxD4gU2nRJkXQWhAZowDUUWKIwEgWWbEEB3mVmx3dn4DA2nB/ppNuPeWd29mMIPXDr+RxwtgRHeW6+guNPRxogqnL7Dwz9psJ27S4NShaeZTH3kwXy6I81 dlRKcmRui88swdq9AcSFL7Buz1Vmlns64MiLsCjzwnIYHLH57tbfFbs7KRaXyEU8FVZofqccOfA5 l7Q8LPIkGrwnb2RPNEXWFVMUF3L+kDCk0btDDAMzOm5YfAHDwp4tG74wnzAsiOYMnJ3GoDybA7IT 98/jm5+JNnfiIzAS6LlqHQBN/i6b2t/cV1Hh6BfwYlHnHP4AXi5q/8kmMMpOs8+BixZw/Fd6xUE HEbnkgclvQP2fGp7uShRKnQ3G32rkjV1th8JhIGG7tR/JyjGteSOZELwGMmNqIIigRCLRh2OZIE 6BjItdd7pCW6Uhm1zzkUtungSxwEUzNpQ+GQumtH1ej1MqgmNT6vwmhCq5yuwq56EYTbgeQUz 3yvrpV1b4ok3nYJ+eYhgYmjRUqErx2EDq0Fr8FhG++iqVGqxlUJI/70Ar0UgJaWHj6hYVHJrf KssAHot1JfqwE9WVWzXZVd5z2Ws/4PnmtEjkXeKJDvxUecLbWOXH/ DP6QQ4J72NS0adedp1aseBfXP8odlZFfPvBF7SN/8hky1TYuPOAXAEipMx15u5ToAAAAABJRU5ErkJggg==',
+ avatar: 'icon-url',
anonymous: false,
canBindAnonymous: false,
};
+class CustomMentionDataService implements IThreadCommentMentionDataService {
+ trigger: string = '@';
+
+ // Get the common interface implementation of the mentioned user
+ async getMentions(search: string) {
+ return [
+ {
+ id: mockUser.userID,
+ label: mockUser.name,
+ type: 'user',
+ icon: mockUser.avatar,
+ },
+ {
+ id: '2',
+ label: 'User2',
+ type: 'user',
+ icon: mockUser.avatar,
+ },
+ ];
+ }
+}
+
univer.registerPlugin(UniverSheetsThreadCommentPlugin, {
- mentions: [{
- trigger: '@',
- // Get the common interface implementation of the mentioned user
- getMentions: async () => {
- return [
- {
- id: mockUser.userID,
- label: mockUser.name,
- type: 'user',
- icon: mockUser.avatar,
- },
- {
- id: '2',
- label: 'User2',
- type: 'user',
- icon: mockUser.avatar,
- },
- ];
- },
- }],
+ overrides: [[IThreadCommentMentionDataService, { useClass: CustomMentionDataService }]],
});
```
diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
index ce2868ac94..7a625975de 100644
--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-import type { Workbook } from '@univerjs/core';
+import type { DependencyOverride, Workbook } from '@univerjs/core';
import { Disposable, ICommandService, IUniverInstanceService, LifecycleStages, LocaleService, OnLifecycle, UniverInstanceType } from '@univerjs/core';
import type { MenuConfig } from '@univerjs/ui';
import { ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
import { Inject, Injector } from '@wendellhu/redi';
import { CommentSingle } from '@univerjs/icons';
-import type { IThreadCommentUIConfig } from '@univerjs/thread-comment-ui';
import { SetActiveCommentOperation, THREAD_COMMENT_PANEL, ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
import type { ISetSelectionsOperationParams } from '@univerjs/sheets';
import { SelectionMoveType, SetSelectionsOperation, SetWorksheetActiveOperation } from '@univerjs/sheets';
@@ -36,21 +35,13 @@ import { SheetsThreadCommentPopupService } from '../services/sheets-thread-comme
import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';
import { AddCommentShortcut, threadCommentMenuFactory, threadPanelMenuFactory } from './menu';
-export interface IUniverSheetsThreadCommentConfig extends IThreadCommentUIConfig {
+export interface IUniverSheetsThreadCommentConfig {
menu?: MenuConfig;
+ overrides?: DependencyOverride;
}
export const DefaultSheetsThreadCommentConfig: IUniverSheetsThreadCommentConfig = {
- mentions: [{
- trigger: '@',
- async getMentions() {
- return [{
- id: 'mock',
- label: 'MockUser',
- type: 'user',
- }];
- },
- }],
+
};
@OnLifecycle(LifecycleStages.Starting, SheetsThreadCommentController)
diff --git a/packages/sheets-thread-comment/src/index.ts b/packages/sheets-thread-comment/src/index.ts
index e0d3700417..2e1874ef15 100644
--- a/packages/sheets-thread-comment/src/index.ts
+++ b/packages/sheets-thread-comment/src/index.ts
@@ -27,3 +27,5 @@ export { SHEETS_THREAD_COMMENT } from './types/const';
export { SheetsThreadCommentCopyPasteController } from './controllers/sheets-thread-comment-copy-paste.controller';
export { SheetsThreadCommentHoverController } from './controllers/sheets-thread-comment-hover.controller';
export { ThreadCommentRemoveSheetsController } from './controllers/sheets-thread-comment-remove.controller';
+export { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';
+export { IThreadCommentDataSourceService } from '@univerjs/thread-comment';
diff --git a/packages/sheets-thread-comment/src/plugin.ts b/packages/sheets-thread-comment/src/plugin.ts
index 5e798e0a8d..7083f69fd0 100644
--- a/packages/sheets-thread-comment/src/plugin.ts
+++ b/packages/sheets-thread-comment/src/plugin.ts
@@ -16,7 +16,7 @@
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
-import { ICommandService, IConfigService, Tools, UniverInstanceType } from '@univerjs/core';
+import { ICommandService, Tools, UniverInstanceType } from '@univerjs/core';
import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
import type { IUniverSheetsThreadCommentConfig } from './controllers/sheets-thread-comment.controller';
import { DefaultSheetsThreadCommentConfig, SheetsThreadCommentController } from './controllers/sheets-thread-comment.controller';
@@ -34,15 +34,16 @@ export class UniverSheetsThreadCommentPlugin extends UniverThreadCommentUIPlugin
static override pluginName = SHEETS_THREAD_COMMENT;
static override type = UniverInstanceType.UNIVER_SHEET;
+ private _pluginConfig: IUniverSheetsThreadCommentConfig;
+
constructor(
- private readonly _config: Partial<IUniverSheetsThreadCommentConfig> = {},
+ config: Partial<IUniverSheetsThreadCommentConfig> = {},
@Inject(Injector) protected override _injector: Injector,
- @Inject(ICommandService) protected override _commandService: ICommandService,
- @Inject(IConfigService) protected override _configService: IConfigService
+ @Inject(ICommandService) protected override _commandService: ICommandService
) {
- super(_config, _injector, _commandService, _configService);
+ super(config, _injector, _commandService);
- this._config = Tools.deepMerge({}, DefaultSheetsThreadCommentConfig, this._config);
+ this._pluginConfig = Tools.deepMerge({}, DefaultSheetsThreadCommentConfig, config);
}
override onStarting(injector: Injector): void {
@@ -52,7 +53,7 @@ export class UniverSheetsThreadCommentPlugin extends UniverThreadCommentUIPlugin
[
SheetsThreadCommentController,
{
- useFactory: () => this._injector.createInstance(SheetsThreadCommentController, this._config),
+ useFactory: () => this._injector.createInstance(SheetsThreadCommentController, this._pluginConfig),
},
],
[SheetsThreadCommentRefRangeController],
@@ -60,7 +61,6 @@ export class UniverSheetsThreadCommentPlugin extends UniverThreadCommentUIPlugin
[SheetsThreadCommentCopyPasteController],
[SheetsThreadCommentHoverController],
[ThreadCommentRemoveSheetsController],
-
[SheetsThreadCommentPopupService],
] as Dependency[]).forEach((dep) => {
this._injector.add(dep);
diff --git a/packages/thread-comment-ui/package.json b/packages/thread-comment-ui/package.json
index 84971e7100..d0744c2af6 100644
--- a/packages/thread-comment-ui/package.json
+++ b/packages/thread-comment-ui/package.json
@@ -65,6 +65,7 @@
"@univerjs/thread-comment": "workspace:*",
"@univerjs/ui": "workspace:*",
"@wendellhu/redi": "0.15.2",
+ "clsx": ">=2.0.0",
"dayjs": ">=1.11.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"rxjs": ">=7.0.0"
diff --git a/packages/thread-comment-ui/src/index.ts b/packages/thread-comment-ui/src/index.ts
index 9b53cc184e..86f18d5261 100644
--- a/packages/thread-comment-ui/src/index.ts
+++ b/packages/thread-comment-ui/src/index.ts
@@ -22,4 +22,4 @@ export type { IThreadCommentPanelProps } from './views/thread-comment-panel';
export { ThreadCommentTree } from './views/thread-comment-tree';
export type { IThreadCommentTreeProps } from './views/thread-comment-tree';
export { THREAD_COMMENT_PANEL } from './types/const';
-export type { IThreadCommentUIConfig } from './types/interfaces/i-thread-comment-mention';
+export { IThreadCommentMentionDataService } from './services/thread-comment-mention-data.service';
diff --git a/packages/thread-comment-ui/src/plugin.ts b/packages/thread-comment-ui/src/plugin.ts
index 25942e132f..0282f4585c 100644
--- a/packages/thread-comment-ui/src/plugin.ts
+++ b/packages/thread-comment-ui/src/plugin.ts
@@ -15,40 +15,45 @@
*/
import { UniverThreadCommentPlugin } from '@univerjs/thread-comment';
-import { ICommandService, IConfigService, UniverInstanceType } from '@univerjs/core';
+import type { DependencyOverride } from '@univerjs/core';
+import { ICommandService, mergeOverrideWithDependencies, UniverInstanceType } from '@univerjs/core';
import type { Dependency } from '@wendellhu/redi';
import { Inject, Injector } from '@wendellhu/redi';
import { PLUGIN_NAME } from './types/const';
import { ThreadCommentPanelService } from './services/thread-comment-panel.service';
import { SetActiveCommentOperation, ToggleSheetCommentPanelOperation } from './commands/operations/comment.operations';
import { ThreadCommentUIController } from './controllers/thread-comment-ui.controller';
-import type { IThreadCommentUIConfig } from './types/interfaces/i-thread-comment-mention';
+import { IThreadCommentMentionDataService, ThreadCommentMentionDataService } from './services/thread-comment-mention-data.service';
+
+export interface IUniverThreadCommentUIConfig {
+ overrides?: DependencyOverride;
+}
export class UniverThreadCommentUIPlugin extends UniverThreadCommentPlugin {
static override pluginName = PLUGIN_NAME;
static override type = UniverInstanceType.UNIVER_UNKNOWN;
+ private _config1: IUniverThreadCommentUIConfig;
constructor(
- _config: IThreadCommentUIConfig,
+ config: IUniverThreadCommentUIConfig,
@Inject(Injector) protected override _injector: Injector,
- @ICommandService protected override _commandService: ICommandService,
- @IConfigService protected _configService: IConfigService
+ @ICommandService protected override _commandService: ICommandService
) {
super(
- _config,
+ config,
_injector,
_commandService
);
-
- this._configService.setConfig(PLUGIN_NAME, _config);
+ this._config1 = config;
}
override onStarting(injector: Injector): void {
super.onStarting(injector);
- ([
+ (mergeOverrideWithDependencies([
[ThreadCommentUIController],
[ThreadCommentPanelService],
- ] as Dependency[]).forEach((dep) => {
+ [IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }],
+ ], this._config1.overrides) as Dependency[]).forEach((dep) => {
injector.add(dep);
});
diff --git a/packages/thread-comment-ui/src/types/interfaces/i-thread-comment-mention.ts b/packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts
similarity index 67%
rename from packages/thread-comment-ui/src/types/interfaces/i-thread-comment-mention.ts
rename to packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts
index f44e37a628..81efc7350d 100644
--- a/packages/thread-comment-ui/src/types/interfaces/i-thread-comment-mention.ts
+++ b/packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts
@@ -14,15 +14,22 @@
* limitations under the License.
*/
-import type { IThreadCommentMention } from '@univerjs/thread-comment';
import type { MentionProps } from '@univerjs/design';
+import type { IThreadCommentMention } from '@univerjs/thread-comment';
+import { createIdentifier } from '@wendellhu/redi';
-export interface IThreadCommentMentionConfig {
+export interface IThreadCommentMentionDataService {
getMentions: (search: string) => Promise<IThreadCommentMention[]>;
trigger: string;
renderSuggestion?: MentionProps['renderSuggestion'];
}
-export interface IThreadCommentUIConfig {
- mentions?: IThreadCommentMentionConfig[];
+export class ThreadCommentMentionDataService implements IThreadCommentMentionDataService {
+ async getMentions(search: string) {
+ return [];
+ }
+
+ trigger = '@';
}
+
+export const IThreadCommentMentionDataService = createIdentifier<IThreadCommentMentionDataService>('thread-comment.mention-data.service');
diff --git a/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx b/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx
index cfd53f6d04..22daf4d463 100644
--- a/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx
+++ b/packages/thread-comment-ui/src/views/thread-comment-editor/index.tsx
@@ -20,9 +20,8 @@ import { Button, Mention, Mentions } from '@univerjs/design';
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
import { useDependency } from '@wendellhu/redi/react-bindings';
import type { IDocumentBody } from '@univerjs/core';
-import { IConfigService, LocaleService } from '@univerjs/core';
-import { PLUGIN_NAME } from '../../types/const';
-import type { IThreadCommentUIConfig } from '../../types/interfaces/i-thread-comment-mention';
+import { LocaleService } from '@univerjs/core';
+import { IThreadCommentMentionDataService } from '../../services/thread-comment-mention-data.service';
import styles from './index.module.less';
import { parseMentions, transformDocument2TextNodes, transformMention, transformTextNode2Text, transformTextNodes2Document } from './util';
@@ -52,11 +51,10 @@ const defaultRenderSuggestion: MentionProps['renderSuggestion'] = (mention, sear
export const ThreadCommentEditor = forwardRef<IThreadCommentEditorInstance, IThreadCommentEditorProps>((props, ref) => {
const { comment, onSave, id, onCancel, autoFocus } = props;
- const configService = useDependency(IConfigService);
+ const mentionDataService = useDependency(IThreadCommentMentionDataService);
const localeService = useDependency(LocaleService);
const [localComment, setLocalComment] = useState({ ...comment });
const [editing, setEditing] = useState(false);
- const mentions = configService.getConfig<IThreadCommentUIConfig>(PLUGIN_NAME)?.mentions ?? [];
const inputRef = useRef(null);
useImperativeHandle(ref, () => ({
@@ -89,16 +87,14 @@ export const ThreadCommentEditor = forwardRef<IThreadCommentEditorInstance, IThr
setEditing(true);
}}
>
- {mentions.map((mention) => (
- <Mention
- key={mention.trigger}
- trigger={mention.trigger}
- data={(query, callback) => mention.getMentions!(query)
- .then((res) => res.map(transformMention)).then(callback) as any}
- displayTransform={(id, label) => `@${label} `}
- renderSuggestion={mention.renderSuggestion ?? defaultRenderSuggestion}
- />
- ))}
+ <Mention
+ key={mentionDataService.trigger}
+ trigger={mentionDataService.trigger}
+ data={(query, callback) => mentionDataService.getMentions!(query)
+ .then((res) => res.map(transformMention)).then(callback) as any}
+ displayTransform={(id, label) => `@${label} `}
+ renderSuggestion={mentionDataService.renderSuggestion ?? defaultRenderSuggestion}
+ />
</Mentions>
{editing
? (
diff --git a/packages/thread-comment/src/plugin.ts b/packages/thread-comment/src/plugin.ts
index 8ad8bbae2a..8d4bdd4212 100644
--- a/packages/thread-comment/src/plugin.ts
+++ b/packages/thread-comment/src/plugin.ts
@@ -14,7 +14,8 @@
* limitations under the License.
*/
-import { ICommandService, Plugin, UniverInstanceType } from '@univerjs/core';
+import type { DependencyOverride } from '@univerjs/core';
+import { ICommandService, mergeOverrideWithDependencies, Plugin, UniverInstanceType } from '@univerjs/core';
import { type Dependency, Inject, Injector } from '@wendellhu/redi';
import { ThreadCommentModel } from './models/thread-comment.model';
import { ThreadCommentResourceController } from './controllers/tc-resource.controller';
@@ -23,24 +24,30 @@ import { AddCommentMutation, DeleteCommentMutation, ResolveCommentMutation, Upda
import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand } from './commands/commands/comment.command';
import { IThreadCommentDataSourceService, ThreadCommentDataSourceService } from './services/tc-datasource.service';
+export interface IUniverThreadCommentConfig {
+ overrides?: DependencyOverride;
+}
+
export class UniverThreadCommentPlugin extends Plugin {
static override pluginName = TC_PLUGIN_NAME;
static override type = UniverInstanceType.UNIVER_UNKNOWN;
+ private _config: IUniverThreadCommentConfig;
constructor(
- _config: unknown,
+ config: IUniverThreadCommentConfig,
@Inject(Injector) protected _injector: Injector,
@ICommandService protected _commandService: ICommandService
) {
super();
+ this._config = config;
}
override onStarting(injector: Injector): void {
- ([
+ (mergeOverrideWithDependencies([
[ThreadCommentModel],
[ThreadCommentResourceController],
[IThreadCommentDataSourceService, { useClass: ThreadCommentDataSourceService }],
- ] as Dependency[]).forEach(
+ ], this._config.overrides) as Dependency[]).forEach(
(d) => {
injector.add(d);
}