Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(thread-comment): comment datasource (#3787)
zhangw8978364fbffc
diff --git a/examples/src/uni/main.ts b/examples/src/uni/main.tsindex ead32bcc42..b15773a2da 100644--- a/examples/src/uni/main.ts+++ b/examples/src/uni/main.ts@@ -40,7 +40,8 @@ import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-commentimport { SheetUIController, UniverSheetsUIPlugin } from '@univerjs/sheets-ui';import { UniverSlidesPlugin } from '@univerjs/slides';import { SlidesUIController, UniverSlidesUIPlugin } from '@univerjs/slides-ui';-import { IThreadCommentMentionDataService, UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';+import { IThreadCommentMentionDataService } from '@univerjs/thread-comment';+import { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';import { UniDocsUIController } from '@univerjs/uni-docs-ui';import { UniverDocUniFormulaPlugin } from '@univerjs/uni-formula';import { UniSheetsUIController } from '@univerjs/uni-sheets-ui';diff --git a/packages/sheets-thread-comment/src/index.ts b/packages/sheets-thread-comment/src/index.tsindex 9754967a1b..d4ace84e50 100644--- a/packages/sheets-thread-comment/src/index.ts+++ b/packages/sheets-thread-comment/src/index.ts@@ -39,6 +39,6 @@ export type {IUpdateCommentCommandParams,} from '@univerjs/thread-comment';export { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';-export { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';+export { IThreadCommentMentionDataService } from '@univerjs/thread-comment';// #endregiondiff --git a/packages/thread-comment-ui/src/index.ts b/packages/thread-comment-ui/src/index.tsindex 074246225a..500ebeb2de 100644--- a/packages/thread-comment-ui/src/index.ts+++ b/packages/thread-comment-ui/src/index.ts@@ -22,7 +22,6 @@ 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 { IThreadCommentMentionDataService, type IThreadCommentMentionDataSource } from './services/thread-comment-mention-data.service';// #region - all commandsdiff --git a/packages/thread-comment-ui/src/plugin.ts b/packages/thread-comment-ui/src/plugin.tsindex 4b9bd89e81..ff51a491bb 100644--- a/packages/thread-comment-ui/src/plugin.ts+++ b/packages/thread-comment-ui/src/plugin.ts@@ -20,7 +20,6 @@ import { DependentOn, ICommandService, IConfigService, Inject, Injector, mergeOvimport { PLUGIN_NAME } from './types/const';import { ThreadCommentPanelService } from './services/thread-comment-panel.service';import { SetActiveCommentOperation, ToggleSheetCommentPanelOperation } from './commands/operations/comment.operations';-import { IThreadCommentMentionDataService, ThreadCommentMentionDataService } from './services/thread-comment-mention-data.service';import type { IUniverThreadCommentUIConfig } from './controllers/config.schema';import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';@@ -48,7 +47,6 @@ export class UniverThreadCommentUIPlugin extends Plugin {override onStarting(): void {(mergeOverrideWithDependencies([[ThreadCommentPanelService],- [IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }],], this._config?.overrides) as Dependency[]).forEach((dep) => {this._injector.add(dep);});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.tsxindex cc642d0836..42d2f64ccd 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@@ -24,7 +24,7 @@ import type { IDocumentBody } from '@univerjs/core';import type { MentionProps } from '@univerjs/design';import type { IThreadComment } from '@univerjs/thread-comment';import { SetActiveCommentOperation } from '../../commands/operations/comment.operations';-import { IThreadCommentMentionDataService } from '../../services/thread-comment-mention-data.service';+import { IThreadCommentMentionDataService } from '@univerjs/thread-comment';import styles from './index.module.less';import { parseMentions, transformDocument2TextNodes, transformMention, transformTextNode2Text, transformTextNodes2Document } from './util';diff --git a/packages/thread-comment/src/index.ts b/packages/thread-comment/src/index.tsindex fb837767b6..e328002d4c 100644--- a/packages/thread-comment/src/index.ts+++ b/packages/thread-comment/src/index.ts@@ -26,7 +26,11 @@ export {ThreadCommentDataSourceService,type ThreadCommentJSON,} from './services/tc-datasource.service';-+export {+ type IThreadCommentMentionDataSource,+ IThreadCommentMentionDataService,+ ThreadCommentMentionDataService,+} from './services/thread-comment-mention-data.service';// #region - all commandsexport {diff --git a/packages/thread-comment/src/models/thread-comment.model.ts b/packages/thread-comment/src/models/thread-comment.model.tsindex 122f79b09c..83f1c5302d 100644--- a/packages/thread-comment/src/models/thread-comment.model.ts+++ b/packages/thread-comment/src/models/thread-comment.model.ts@@ -195,7 +195,10 @@ export class ThreadCommentModel extends Disposable {addComment(unitId: string, subUnitId: string, origin: IThreadComment, shouldSync?: boolean) {const { commentMap, commentChildrenMap } = this.ensureMap(unitId, subUnitId);- const comment = origin;+ const comment = {+ ...origin,+ parentId: origin.parentId === origin.id ? undefined : origin.parentId,+ };const addCommentItem = (item: IThreadComment) => {commentMap[item.id] = item;this._commentUpdate$.next({diff --git a/packages/thread-comment/src/plugin.ts b/packages/thread-comment/src/plugin.tsindex 8952d65522..484bfad4d9 100644--- a/packages/thread-comment/src/plugin.ts+++ b/packages/thread-comment/src/plugin.ts@@ -24,6 +24,7 @@ import { ThreadCommentResourceController } from './controllers/tc-resource.contrimport { ThreadCommentModel } from './models/thread-comment.model';import { IThreadCommentDataSourceService, ThreadCommentDataSourceService } from './services/tc-datasource.service';import { TC_PLUGIN_NAME } from './types/const';+import { IThreadCommentMentionDataService, ThreadCommentMentionDataService } from './services/thread-comment-mention-data.service';export class UniverThreadCommentPlugin extends Plugin {static override pluginName = TC_PLUGIN_NAME;@@ -45,6 +46,7 @@ export class UniverThreadCommentPlugin extends Plugin {override onStarting(): void {(mergeOverrideWithDependencies([[IThreadCommentDataSourceService, { useClass: ThreadCommentDataSourceService }],+ [IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }],[ThreadCommentModel],[ThreadCommentResourceController],], this._config?.overrides) as Dependency[]).forEach(diff --git a/packages/thread-comment-ui/src/services/thread-comment-mention-data.service.ts b/packages/thread-comment/src/services/thread-comment-mention-data.service.tssimilarity index 100%rename from packages/thread-comment-ui/src/services/thread-comment-mention-data.service.tsrename to packages/thread-comment/src/services/thread-comment-mention-data.service.ts