Skip to content

Commit

Permalink
fix(thread-comment): comment datasource (#3787)
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 authored Oct 18, 2024
1 parent dbd1b8c commit 8978364
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion examples/src/uni/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment
import { 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';
Expand Down
2 changes: 1 addition & 1 deletion packages/sheets-thread-comment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

// #endregion
1 change: 0 additions & 1 deletion packages/thread-comment-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 commands

Expand Down
2 changes: 0 additions & 2 deletions packages/thread-comment-ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { DependentOn, ICommandService, IConfigService, Inject, Injector, mergeOv
import { 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';

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
6 changes: 5 additions & 1 deletion packages/thread-comment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 commands

export {
Expand Down
5 changes: 4 additions & 1 deletion packages/thread-comment/src/models/thread-comment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions packages/thread-comment/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ThreadCommentResourceController } from './controllers/tc-resource.contr
import { 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;
Expand All @@ -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(
Expand Down

0 comments on commit 8978364

Please sign in to comment.