@univerjs/sheets-thread-comment 0.4.2 → 0.5.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +4 -73
  2. package/lib/cjs/facade.js +1 -0
  3. package/lib/cjs/index.js +1 -1
  4. package/lib/es/facade.js +218 -0
  5. package/lib/es/index.js +331 -784
  6. package/lib/types/controllers/config.schema.d.ts +17 -6
  7. package/lib/types/controllers/sheets-thread-comment-ref-range.controller.d.ts +22 -0
  8. package/lib/types/facade/f-range.d.ts +26 -0
  9. package/lib/types/facade/f-thread-comment.d.ts +56 -0
  10. package/lib/types/facade/f-workbook.d.ts +35 -0
  11. package/lib/types/facade/f-worksheet.d.ts +13 -0
  12. package/lib/types/{locale/en-US.d.ts → facade/index.d.ts} +4 -9
  13. package/lib/types/index.d.ts +3 -9
  14. package/lib/types/models/sheets-thread-comment.model.d.ts +30 -0
  15. package/lib/types/plugin.d.ts +2 -7
  16. package/lib/types/types/const.d.ts +1 -3
  17. package/lib/umd/facade.js +1 -0
  18. package/lib/umd/index.js +1 -1
  19. package/package.json +27 -28
  20. package/lib/locale/en-US.json +0 -8
  21. package/lib/locale/fa-IR.json +0 -8
  22. package/lib/locale/ru-RU.json +0 -8
  23. package/lib/locale/vi-VN.json +0 -8
  24. package/lib/locale/zh-CN.json +0 -8
  25. package/lib/locale/zh-TW.json +0 -8
  26. package/lib/types/commands/operations/comment.operation.d.ts +0 -2
  27. package/lib/types/controllers/menu.d.ts +0 -12
  28. package/lib/types/controllers/menu.schema.d.ts +0 -2
  29. package/lib/types/controllers/render-controllers/render.controller.d.ts +0 -13
  30. package/lib/types/controllers/sheets-thread-comment-copy-paste.controller.d.ts +0 -12
  31. package/lib/types/controllers/sheets-thread-comment-hover.controller.d.ts +0 -12
  32. package/lib/types/controllers/sheets-thread-comment-popup.controller.d.ts +0 -28
  33. package/lib/types/controllers/sheets-thread-comment-remove.controller.d.ts +0 -11
  34. package/lib/types/controllers/sheets-thread-comment.controller.d.ts +0 -11
  35. package/lib/types/locale/fa-IR.d.ts +0 -24
  36. package/lib/types/locale/ru-RU.d.ts +0 -24
  37. package/lib/types/locale/vi-VN.d.ts +0 -24
  38. package/lib/types/locale/zh-CN.d.ts +0 -24
  39. package/lib/types/locale/zh-TW.d.ts +0 -24
  40. package/lib/types/services/sheets-thread-comment-popup.service.d.ts +0 -23
  41. package/lib/types/views/sheets-thread-comment-cell/index.d.ts +0 -2
  42. package/lib/types/views/sheets-thread-comment-panel/index.d.ts +0 -2
@@ -1,9 +1,20 @@
1
- import { MenuConfig } from '@univerjs/ui';
2
- import { DependencyOverride } from '@univerjs/core';
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
3
16
  export declare const PLUGIN_CONFIG_KEY = "sheets-thread-comment.config";
4
17
  export declare const configSymbol: unique symbol;
5
- export interface IUniverSheetsThreadCommentConfig {
6
- menu?: MenuConfig;
7
- overrides?: DependencyOverride;
18
+ export interface IUniverSheetsThreadCommentBaseConfig {
8
19
  }
9
- export declare const defaultPluginConfig: IUniverSheetsThreadCommentConfig;
20
+ export declare const defaultPluginConfig: IUniverSheetsThreadCommentBaseConfig;
@@ -0,0 +1,22 @@
1
+ import { Disposable, ICommandService } from '@univerjs/core';
2
+ import { RefRangeService, SheetsSelectionsService } from '@univerjs/sheets';
3
+ import { ThreadCommentModel } from '@univerjs/thread-comment';
4
+ import { SheetsThreadCommentModel } from '../models/sheets-thread-comment.model';
5
+ export declare class SheetsThreadCommentRefRangeController extends Disposable {
6
+ private readonly _refRangeService;
7
+ private readonly _sheetsThreadCommentModel;
8
+ private readonly _threadCommentModel;
9
+ private readonly _selectionManagerService;
10
+ private readonly _commandService;
11
+ private _disposableMap;
12
+ private _watcherMap;
13
+ constructor(_refRangeService: RefRangeService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentModel: ThreadCommentModel, _selectionManagerService: SheetsSelectionsService, _commandService: ICommandService);
14
+ private _getIdWithUnitId;
15
+ private _handleRangeChange;
16
+ private _register;
17
+ private _watch;
18
+ private _unwatch;
19
+ private _unregister;
20
+ private _initData;
21
+ private _initRefRange;
22
+ }
@@ -0,0 +1,26 @@
1
+ import { IDocumentBody, Nullable } from '@univerjs/core';
2
+ import { FRange } from '@univerjs/sheets/facade';
3
+ import { FThreadComment } from './f-thread-comment';
4
+ interface IFRangeCommentMixin {
5
+ /**
6
+ * Get the comment of the start cell in the current range.
7
+ * @returns The comment of the start cell in the current range. If the cell does not have a comment, return `null`.
8
+ */
9
+ getComment(): Nullable<FThreadComment>;
10
+ /**
11
+ * Add a comment to the start cell in the current range.
12
+ * @param content The content of the comment.
13
+ * @returns Whether the comment is added successfully.
14
+ */
15
+ addComment(this: FRange, content: IDocumentBody): Promise<boolean>;
16
+ /**
17
+ * Clear the comment of the start cell in the current range.
18
+ * @returns Whether the comment is cleared successfully.
19
+ */
20
+ clearComment(): Promise<boolean>;
21
+ }
22
+ declare module '@univerjs/sheets/facade' {
23
+ interface FRange extends IFRangeCommentMixin {
24
+ }
25
+ }
26
+ export {};
@@ -0,0 +1,56 @@
1
+ import { IDocumentBody, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
2
+ import { IBaseComment, IThreadComment } from '@univerjs/thread-comment';
3
+ import { FRange } from '@univerjs/sheets/facade';
4
+ import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment';
5
+ export declare class FThreadComment {
6
+ private readonly _thread;
7
+ private readonly _parent;
8
+ private readonly _injector;
9
+ private readonly _commandService;
10
+ private readonly _univerInstanceService;
11
+ private readonly _threadCommentModel;
12
+ constructor(_thread: IThreadComment | IBaseComment, _parent: IThreadComment | undefined, _injector: Injector, _commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _threadCommentModel: SheetsThreadCommentModel);
13
+ private _getRef;
14
+ /**
15
+ * Whether the comment is a root comment
16
+ * @returns Whether the comment is a root comment
17
+ */
18
+ getIsRoot(): boolean;
19
+ /**
20
+ * Get the comment data
21
+ * @returns The comment data
22
+ */
23
+ getCommentData(): IBaseComment;
24
+ /**
25
+ * Get the replies of the comment
26
+ * @returns the replies of the comment
27
+ */
28
+ getReplies(): FThreadComment[] | undefined;
29
+ /**
30
+ * Get the range of the comment
31
+ * @returns The range of the comment
32
+ */
33
+ getRange(): FRange | null;
34
+ /**
35
+ * Get the content of the comment
36
+ * @returns The content of the comment
37
+ */
38
+ getContent(): IDocumentBody;
39
+ /**
40
+ * Delete the comment and it's replies
41
+ * @returns success or not
42
+ */
43
+ delete(): Promise<boolean>;
44
+ /**
45
+ * Update the comment content
46
+ * @param content The new content of the comment
47
+ * @returns success or not
48
+ */
49
+ update(content: IDocumentBody): Promise<boolean>;
50
+ /**
51
+ * Resolve the comment
52
+ * @param resolved Whether the comment is resolved
53
+ * @returns success or not
54
+ */
55
+ resolve(resolved?: boolean): Promise<boolean>;
56
+ }
@@ -0,0 +1,35 @@
1
+ import { IDisposable, IExecutionOptions } from '@univerjs/core';
2
+ import { CommentUpdate, IAddCommentCommandParams, IDeleteCommentCommandParams } from '@univerjs/thread-comment';
3
+ import { FWorkbook } from '@univerjs/sheets/facade';
4
+ type IUpdateCommandParams = any;
5
+ interface IFWorkbookThreadCommentMixin {
6
+ /**
7
+ * The onThreadCommentChange event is fired when the thread comment of this sheet is changed.
8
+ * @param callback Callback function that will be called when the event is fired
9
+ * @returns A disposable object that can be used to unsubscribe from the event
10
+ */
11
+ onThreadCommentChange(callback: (commentUpdate: CommentUpdate) => void | false): IDisposable;
12
+ /**
13
+ * The onThreadCommentChange event is fired when the thread comment of this sheet is changed.
14
+ * @param callback Callback function that will be called when the event is fired
15
+ * @returns A disposable object that can be used to unsubscribe from the event
16
+ */
17
+ onBeforeAddThreadComment(this: FWorkbook, callback: (params: IAddCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
18
+ /**
19
+ * The onBeforeUpdateThreadComment event is fired before the thread comment is updated.
20
+ * @param callback Callback function that will be called when the event is fired
21
+ * @returns A disposable object that can be used to unsubscribe from the event
22
+ */
23
+ onBeforeUpdateThreadComment(this: FWorkbook, callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
24
+ /**
25
+ * The onBeforeDeleteThreadComment event is fired before the thread comment is deleted.
26
+ * @param callback Callback function that will be called when the event is fired
27
+ * @returns A disposable object that can be used to unsubscribe from the event
28
+ */
29
+ onBeforeDeleteThreadComment(this: FWorkbook, callback: (params: IDeleteCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
30
+ }
31
+ declare module '@univerjs/sheets/facade' {
32
+ interface FWorkbook extends IFWorkbookThreadCommentMixin {
33
+ }
34
+ }
35
+ export {};
@@ -0,0 +1,13 @@
1
+ import { FThreadComment } from './f-thread-comment';
2
+ interface IFWorksheetCommentMixin {
3
+ /**
4
+ * Get all comments in the current sheet
5
+ * @returns all comments in the current sheet
6
+ */
7
+ getComments(): FThreadComment[];
8
+ }
9
+ declare module '@univerjs/sheets/facade' {
10
+ interface FWorksheet extends IFWorksheetCommentMixin {
11
+ }
12
+ }
13
+ export {};
@@ -13,12 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- declare const _default: {
17
- sheetThreadComment: {
18
- menu: {
19
- addComment: string;
20
- commentManagement: string;
21
- };
22
- };
23
- };
24
- export default _default;
16
+ import './f-range';
17
+ import './f-workbook';
18
+ import './f-worksheet';
19
+ export { FThreadComment } from './f-thread-comment';
@@ -13,13 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { ShowAddSheetCommentModalOperation } from './commands/operations/comment.operation';
16
+ export { SheetsThreadCommentRefRangeController } from './controllers/sheets-thread-comment-ref-range.controller';
17
+ export { SheetsThreadCommentModel } from './models/sheets-thread-comment.model';
18
+ export type { ISheetThreadComment } from './types/interfaces/i-sheet-thread-comment';
17
19
  export { UniverSheetsThreadCommentPlugin } from './plugin';
18
- export { SheetsThreadCommentPopupService } from './services/sheets-thread-comment-popup.service';
19
- export { SHEETS_THREAD_COMMENT } from './types/const';
20
- export { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
21
- export { IThreadCommentDataSourceService } from '@univerjs/thread-comment';
22
- export { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, UpdateCommentCommand, } from '@univerjs/thread-comment';
23
- export type { IAddCommentCommandParams, IDeleteCommentCommandParams, IDeleteCommentTreeCommandParams, IResolveCommentCommandParams, IUpdateCommentCommandParams, } from '@univerjs/thread-comment';
24
- export { UniverThreadCommentUIPlugin } from '@univerjs/thread-comment-ui';
25
- export { IThreadCommentMentionDataService } from '@univerjs/thread-comment-ui';
@@ -0,0 +1,30 @@
1
+ import { CommentUpdate, IThreadComment, ThreadCommentModel } from '@univerjs/thread-comment';
2
+ import { Disposable, IUniverInstanceService } from '@univerjs/core';
3
+ export type SheetCommentUpdate = CommentUpdate & {
4
+ row: number;
5
+ column: number;
6
+ };
7
+ export declare class SheetsThreadCommentModel extends Disposable {
8
+ private readonly _threadCommentModel;
9
+ private readonly _univerInstanceService;
10
+ private _matrixMap;
11
+ private _locationMap;
12
+ private _commentUpdate$;
13
+ commentUpdate$: import('rxjs').Observable<SheetCommentUpdate>;
14
+ constructor(_threadCommentModel: ThreadCommentModel, _univerInstanceService: IUniverInstanceService);
15
+ private _init;
16
+ private _ensureCommentMatrix;
17
+ private _ensureCommentLocationMap;
18
+ private _addCommentToMatrix;
19
+ private _deleteCommentFromMatrix;
20
+ private _ensure;
21
+ private _initData;
22
+ private _addComment;
23
+ private _initUpdateTransform;
24
+ getByLocation(unitId: string, subUnitId: string, row: number, column: number): string | undefined;
25
+ getAllByLocation(unitId: string, subUnitId: string, row: number, column: number): IThreadComment[];
26
+ getComment(unitId: string, subUnitId: string, commentId: string): IThreadComment | undefined;
27
+ getCommentWithChildren(unitId: string, subUnitId: string, row: number, column: number): import('@univerjs/core').Nullable<import('@univerjs/thread-comment/models/thread-comment.model.js').IThreadInfo>;
28
+ showCommentMarker(unitId: string, subUnitId: string, row: number, column: number): boolean;
29
+ getSubUnitAll(unitId: string, subUnitId: string): IThreadComment[];
30
+ }
@@ -1,14 +1,9 @@
1
- import { IUniverSheetsThreadCommentConfig } from './controllers/config.schema';
2
- import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
3
2
  export declare class UniverSheetsThreadCommentPlugin extends Plugin {
4
- private readonly _config;
5
3
  protected _injector: Injector;
6
4
  protected _commandService: ICommandService;
7
- private readonly _configService;
8
5
  static pluginName: string;
9
6
  static type: UniverInstanceType;
10
- constructor(_config: Partial<IUniverSheetsThreadCommentConfig> | undefined, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
7
+ constructor(config: unknown, _injector: Injector, _commandService: ICommandService);
11
8
  onStarting(): void;
12
- onReady(): void;
13
- onRendered(): void;
14
9
  }
@@ -13,6 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal";
17
- export declare const COMMENT_SINGLE_ICON = "comment-single";
18
- export declare const SHEETS_THREAD_COMMENT = "SHEET_THREAD_COMMENT";
16
+ export declare const SHEET_THREAD_COMMENT_BASE = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
@@ -0,0 +1 @@
1
+ (function(o,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets/facade"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets/facade","@univerjs/sheets-thread-comment","@univerjs/thread-comment","@univerjs/engine-formula","rxjs"],i):(o=typeof globalThis<"u"?globalThis:o||self,i(o.UniverSheetsThreadCommentFacade={},o.UniverCore,o.UniverSheetsFacade,o.UniverSheetsThreadComment,o.UniverThreadComment,o.UniverEngineFormula,o.rxjs))})(this,function(o,i,h,u,d,I,g){"use strict";var l=Object.defineProperty,f=Object.getOwnPropertyDescriptor,v=(a,t,e,n)=>{for(var r=n>1?void 0:n?f(t,e):t,m=a.length-1,s;m>=0;m--)(s=a[m])&&(r=(n?s(t,e,r):s(r))||r);return n&&r&&l(t,e,r),r},c=(a,t)=>(e,n)=>t(e,n,a);o.FThreadComment=class{constructor(t,e,n,r,m,s){this._thread=t,this._parent=e,this._injector=n,this._commandService=r,this._univerInstanceService=m,this._threadCommentModel=s}_getRef(){var n;const t=((n=this._parent)==null?void 0:n.ref)||this._thread.ref;return I.deserializeRangeWithSheet(t).range}getIsRoot(){return!this._parent}getCommentData(){const{children:t,...e}=this._thread;return e}getReplies(){var n;const t=this._getRef(),e=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return(n=e==null?void 0:e.children)==null?void 0:n.map(r=>this._injector.createInstance(o.FThreadComment,r))}getRange(){const t=this._univerInstanceService.getUnit(this._thread.unitId,i.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const e=t.getSheetBySheetId(this._thread.subUnitId);if(!e)return null;const n=this._getRef();return this._injector.createInstance(h.FRange,t,e,n)}getContent(){return this._thread.text}delete(){return this._commandService.executeCommand(this.getIsRoot()?d.DeleteCommentTreeCommand.id:d.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}async update(t){const e=d.getDT();return await this._commandService.executeCommand(d.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:t,updated:!0,updateT:e}})}resolve(t){return this._commandService.executeCommand(d.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:t!=null?t:!this._thread.resolved})}},o.FThreadComment=v([c(2,i.Inject(i.Injector)),c(3,i.ICommandService),c(4,i.IUniverInstanceService),c(5,i.Inject(u.SheetsThreadCommentModel))],o.FThreadComment);class p extends h.FRange{getComment(){const e=this._injector.get(u.SheetsThreadCommentModel),n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),m=e.getByLocation(n,r,this._range.startRow,this._range.startColumn);if(!m)return null;const s=e.getComment(n,r,m);return s?this._injector.createInstance(o.FThreadComment,s):null}addComment(t){var C;const e=this._injector,n=(C=this.getComment())==null?void 0:C.getCommentData(),r=e.get(i.ICommandService),m=e.get(i.UserManagerService),s=this._workbook.getUnitId(),_=this._worksheet.getSheetId(),b=`${i.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,j=m.getCurrentUser();return r.executeCommand(d.AddCommentCommand.id,{unitId:s,subUnitId:_,comment:{text:t,attachments:[],dT:d.getDT(),id:i.Tools.generateRandomId(),ref:b,personId:j.userID,parentId:n==null?void 0:n.id,unitId:s,subUnitId:_,threadId:n==null?void 0:n.threadId}})}clearComment(){var s;const t=this._injector,e=(s=this.getComment())==null?void 0:s.getCommentData(),n=t.get(i.ICommandService),r=this._workbook.getUnitId(),m=this._worksheet.getSheetId();return e?n.executeCommand(d.DeleteCommentTreeCommand.id,{unitId:r,subUnitId:m,threadId:e.threadId,commentId:e.id}):Promise.resolve(!0)}}h.FRange.extend(p);class U extends h.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(d.ThreadCommentModel)}})}onThreadCommentChange(t){return i.toDisposable(this._threadCommentModel.commentUpdate$.pipe(g.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddThreadComment(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,n)=>{const r=e.params;if(e.id===d.AddCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,n)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,n)=>{const r=e.params;if(e.id===d.UpdateCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,n)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,n)=>{const r=e.params;if(e.id===d.DeleteCommentCommand.id||e.id===d.DeleteCommentTreeCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,n)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}h.FWorkbook.extend(U);class T extends h.FWorksheet{getComments(){return this._injector.get(u.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(n=>this._injector.createInstance(o.FThreadComment,n))}}h.FWorksheet.extend(T),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment-base"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment-base","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/engine-formula","@univerjs/thread-comment"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsThreadComment={},global.UniverCore,global.UniverSheets,global.UniverSheetsThreadCommentBase,global.UniverThreadCommentUi,global.UniverSheetsUi,global.UniverUi,global.rxjs,global.UniverEngineRender,global.React,global.UniverEngineFormula,global.UniverThreadComment))})(this,function(exports2,core,sheets,sheetsThreadCommentBase,threadCommentUi,sheetsUi,ui,rxjs,engineRender,React,engineFormula,threadComment){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g,_h;const SHEETS_THREAD_COMMENT_MODAL="univer.sheet.thread-comment-modal",COMMENT_SINGLE_ICON="comment-single",SHEETS_THREAD_COMMENT="SHEET_THREAD_COMMENT";var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7");exports2.SheetsThreadCommentPopupService=(_a=class extends core.Disposable{constructor(_canvasPopupManagerService,_zenZoneService){super();__publicField(this,"_lastPopup",null);__publicField(this,"_activePopup");__publicField(this,"_activePopup$",new rxjs.BehaviorSubject(null));__publicField(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=_canvasPopupManagerService,this._zenZoneService=_zenZoneService,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(visible=>{visible&&this.hidePopup()}))}showPopup(location,onHide){var _a2;const{row,col,unitId,subUnitId}=location;if(this._activePopup&&row===this._activePopup.row&&col===this._activePopup.col&&unitId===this._activePopup.unitId&&subUnitId===((_a2=this.activePopup)==null?void 0:_a2.subUnitId)){this._activePopup=location,this._activePopup$.next(location);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=location,this._activePopup$.next(location);const popupDisposable=this._canvasPopupManagerService.attachPopupToCell(row,col,{componentKey:SHEETS_THREAD_COMMENT_MODAL,onClickOutside:__name(()=>{this.hidePopup()},"onClickOutside"),direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!popupDisposable)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const disposableCollection=new core.DisposableCollection;disposableCollection.add(popupDisposable),disposableCollection.add({dispose:__name(()=>{onHide==null||onHide()},"dispose")}),this._lastPopup=disposableCollection}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},__name(_a,"SheetsThreadCommentPopupService"),_a),exports2.SheetsThreadCommentPopupService=__decorateClass$7([__decorateParam$7(0,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$7(1,ui.IZenZoneService)],exports2.SheetsThreadCommentPopupService);const ShowAddSheetCommentModalOperation={type:core.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(accessor){var _a2;const selectionManagerService=accessor.get(sheets.SheetsSelectionsService),univerInstanceService=accessor.get(core.IUniverInstanceService),sheetsThreadCommentPopupService=accessor.get(exports2.SheetsThreadCommentPopupService),threadCommentPanelService=accessor.get(threadCommentUi.ThreadCommentPanelService),activeCell=(_a2=selectionManagerService.getCurrentLastSelection())==null?void 0:_a2.primary,model=accessor.get(sheetsThreadCommentBase.SheetsThreadCommentModel);if(!activeCell)return!1;const result=sheets.getSheetCommandTarget(univerInstanceService);if(!result)return!1;const{workbook,worksheet,unitId,subUnitId}=result,location={workbook,worksheet,unitId,subUnitId,row:activeCell.startRow,col:activeCell.startColumn};sheetsThreadCommentPopupService.showPopup(location);const rootId=model.getByLocation(unitId,subUnitId,activeCell.startRow,activeCell.startColumn);return rootId&&threadCommentPanelService.setActiveComment({unitId,subUnitId,commentId:rootId,trigger:"context-menu"}),!0}},PLUGIN_CONFIG_KEY="sheets-thread-comment.config",defaultPluginConfig={};var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");let SheetsThreadCommentRenderController=(_b=class extends core.Disposable{constructor(_sheetInterceptorService,_sheetsThreadCommentModel,_univerInstanceService,_renderManagerService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._univerInstanceService=_univerInstanceService,this._renderManagerService=_renderManagerService,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{effect:core.InterceptorEffectEnum.Style,handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos;return this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)?next({...cell,markers:{...cell==null?void 0:cell.markers,tr:{color:"#FFBD37",size:6}}}):next(cell)},"handler"),priority:100}))}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a2;const workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId(),currentRender=this._renderManagerService.getRenderById(unitId);(_a2=currentRender==null?void 0:currentRender.mainComponent)==null||_a2.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(rxjs.debounceTime(16)).subscribe(()=>{markSkeletonDirty()}))}},__name(_b,"SheetsThreadCommentRenderController"),_b);SheetsThreadCommentRenderController=__decorateClass$6([__decorateParam$6(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$6(1,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$6(2,core.IUniverInstanceService),__decorateParam$6(3,engineRender.IRenderManagerService)],SheetsThreadCommentRenderController);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CommentSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"comment-single",ref,icon:element}))});CommentSingle.displayName="CommentSingle";const SheetsThreadCommentCell=__name(()=>{const univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports2.SheetsThreadCommentPopupService),activePopup=ui.useObservable(sheetsThreadCommentPopupService.activePopup$),sheetThreadCommentModel=core.useDependency(sheetsThreadCommentBase.SheetsThreadCommentModel);if(ui.useObservable(sheetThreadCommentModel.commentUpdate$),!activePopup)return null;const{row,col,unitId,subUnitId,trigger}=activePopup,rootId=sheetThreadCommentModel.getByLocation(unitId,subUnitId,row,col),ref=`${core.Tools.chatAtABC(col)}${row+1}`,onClose=__name(()=>{sheetsThreadCommentPopupService.hidePopup()},"onClose"),getSubUnitName=__name(id=>{var _a2,_b2,_c2;return(_c2=(_b2=(_a2=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getSheetBySheetId(id))==null?void 0:_b2.getName())!=null?_c2:""},"getSubUnitName");return React.createElement(threadCommentUi.ThreadCommentTree,{onClick:__name(()=>{sheetsThreadCommentPopupService.persistPopup()},"onClick"),prefix:"cell",id:rootId,unitId,subUnitId,type:core.UniverInstanceType.UNIVER_SHEET,refStr:ref,onClose,getSubUnitName,autoFocus:trigger==="context-menu"})},"SheetsThreadCommentCell"),SheetsThreadCommentPanel=__name(()=>{var _a2;const markSelectionService=core.useDependency(sheetsUi.IMarkSelectionService),univerInstanceService=core.useDependency(core.IUniverInstanceService),sheetsThreadCommentPopupService=core.useDependency(exports2.SheetsThreadCommentPopupService),workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET),unitId=workbook.getUnitId(),commandService=core.useDependency(core.ICommandService),subUnitId$=React.useMemo(()=>workbook.activeSheet$.pipe(rxjs.map(i=>i==null?void 0:i.getSheetId())),[workbook.activeSheet$]),subUnitId=ui.useObservable(subUnitId$,(_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId()),hoverShapeId=React.useRef(),panelService=core.useDependency(threadCommentUi.ThreadCommentPanelService),activeCommentId=ui.useObservable(panelService.activeCommentId$),panelVisible=ui.useObservable(panelService.panelVisible$,panelService.panelVisible),sortComments=React.useCallback(comments=>{const worksheets=workbook.getSheets(),sheetIndex={};worksheets.forEach((sheet,i)=>{sheetIndex[sheet.getSheetId()]=i});const sort=__name(comments2=>comments2.map(comment=>{var _a3;const ref=engineFormula.singleReferenceToGrid(comment.ref),p=[(_a3=sheetIndex[comment.subUnitId])!=null?_a3:0,ref.row,ref.column];return{...comment,p}}).sort((pre,aft)=>pre.p[0]===aft.p[0]?pre.p[1]===aft.p[1]?pre.p[2]-aft.p[2]:pre.p[1]-aft.p[1]:pre.p[0]-aft.p[0]),"sort");return[...sort(comments.filter(comment=>!comment.resolved)),...sort(comments.filter(comment=>comment.resolved))]},[workbook]),showShape=React.useCallback(comment=>{var _a3;if(comment.unitId===unitId&&comment.subUnitId===subUnitId&&!comment.resolved){const{row,column}=engineFormula.singleReferenceToGrid(comment.ref),worksheet=workbook.getSheetBySheetId(comment.subUnitId),mergeInfo=(_a3=worksheet==null?void 0:worksheet.getMergedCell(row,column))!=null?_a3:{startColumn:column,endColumn:column,startRow:row,endRow:row};if(!Number.isNaN(row)&&!Number.isNaN(column))return markSelectionService.addShape({range:mergeInfo,style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[markSelectionService,subUnitId,unitId]),getSubUnitName=__name(id=>{var _a3,_b2;return(_b2=(_a3=workbook.getSheetBySheetId(id))==null?void 0:_a3.getName())!=null?_b2:""},"getSubUnitName"),handleAdd=__name(()=>{commandService.executeCommand(ShowAddSheetCommentModalOperation.id)},"handleAdd"),handleHover=__name(comment=>{activeCommentId&&activeCommentId.unitId===comment.unitId&&activeCommentId.subUnitId===comment.subUnitId&&activeCommentId.commentId===comment.id||(hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null),hoverShapeId.current=showShape(comment))},"handleHover"),handleLeave=__name(()=>{hoverShapeId.current&&(markSelectionService.removeShape(hoverShapeId.current),hoverShapeId.current=null)},"handleLeave"),handleResolve=__name((id,resolved)=>{resolved&&sheetsThreadCommentPopupService.hidePopup()},"handleResolve");return React.useEffect(()=>{!panelVisible&&hoverShapeId.current&&markSelectionService.removeShape(hoverShapeId.current)},[markSelectionService,panelVisible]),React.createElement(threadCommentUi.ThreadCommentPanel,{unitId,subUnitId$,type:core.UniverInstanceType.UNIVER_SHEET,onAdd:handleAdd,getSubUnitName,onResolve:handleResolve,sortComments,onItemEnter:handleHover,onItemLeave:handleLeave,onDeleteComment:__name(()=>(handleLeave(),!0),"onDeleteComment")})},"SheetsThreadCommentPanel"),threadCommentMenuFactory=__name(accessor=>({id:ShowAddSheetCommentModalOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,title:"sheetThreadComment.menu.addComment",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]})}),"threadCommentMenuFactory"),threadPanelMenuFactory=__name(accessor=>({id:threadCommentUi.ToggleSheetCommentPanelOperation.id,type:ui.MenuItemType.BUTTON,icon:COMMENT_SINGLE_ICON,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]}),hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET)}),"threadPanelMenuFactory"),AddCommentShortcut={id:ShowAddSheetCommentModalOperation.id,binding:ui.KeyCode.M|ui.MetaKeys.CTRL_COMMAND|ui.MetaKeys.ALT,preconditions:sheetsUi.whenSheetEditorFocused},menuSchema={[ui.RibbonStartGroup.OTHERS]:{[threadCommentUi.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:threadPanelMenuFactory}},[ui.ContextMenuPosition.MAIN_AREA]:{[ui.ContextMenuGroup.OTHERS]:{[ShowAddSheetCommentModalOperation.id]:{order:0,menuItemFactory:threadCommentMenuFactory}}}};var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");let SheetsThreadCommentController=(_c=class extends core.Disposable{constructor(_menuManagerService,_componentManager,_shortcutService){super(),this._menuManagerService=_menuManagerService,this._componentManager=_componentManager,this._shortcutService=_shortcutService,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(AddCommentShortcut)}_initMenu(){this._menuManagerService.mergeMenu(menuSchema)}_initComponent(){[[SHEETS_THREAD_COMMENT_MODAL,SheetsThreadCommentCell],[threadCommentUi.THREAD_COMMENT_PANEL,SheetsThreadCommentPanel],[COMMENT_SINGLE_ICON,CommentSingle]].forEach(([key,comp])=>{this._componentManager.register(key,comp)})}},__name(_c,"SheetsThreadCommentController"),_c);SheetsThreadCommentController=__decorateClass$5([__decorateParam$5(0,ui.IMenuManagerService),__decorateParam$5(1,core.Inject(ui.ComponentManager)),__decorateParam$5(2,ui.IShortcutService)],SheetsThreadCommentController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");const transformRef=__name((ref,source,target)=>{const refObj=engineFormula.singleReferenceToGrid(ref),offsetRow=target.row-source.row,offsetCol=target.column-source.column,targetRange={startColumn:refObj.column+offsetCol,startRow:refObj.row+offsetRow,endColumn:refObj.column+offsetCol,endRow:refObj.row+offsetRow};return engineFormula.serializeRange(targetRange)},"transformRef");let SheetsThreadCommentCopyPasteController=(_d=class extends core.Disposable{constructor(_sheetClipboardService,_sheetsThreadCommentModel,_threadCommentDataSourceService){super();__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:SHEETS_THREAD_COMMENT,onBeforeCopy:__name((unitId,subUnitId,range)=>{this._copyInfo={unitId,subUnitId,range}},"onBeforeCopy"),onPasteCells:__name((_pasteFrom,pasteTo,_data,payload)=>{const{unitId:targetUnitId,subUnitId:targetSubUnitId,range}=pasteTo,targetPos={row:range.rows[0],column:range.cols[0]};if(payload.copyType===sheetsUi.COPY_TYPE.CUT&&this._copyInfo){const{range:range2,unitId:sourceUnitId,subUnitId:sourceSubUnitId}=this._copyInfo,sourcePos={row:range2.startRow,column:range2.startColumn};if(!(targetUnitId===sourceUnitId&&targetSubUnitId===sourceSubUnitId)){const roots=[];core.Range.foreach(range2,(row,col)=>{const comments=this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId,sourceSubUnitId,row,col);this._threadCommentDataSourceService.syncUpdateMutationToColla?comments.forEach(comment=>{roots.push(comment)}):comments.forEach(({children,...comment})=>{comment.parentId||roots.push(comment)})});const sourceRedos=[],sourceUndos=[],targetRedos=[],targetUndos=[],handleCommentItem=__name(item=>{sourceRedos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,commentId:item.id}}),targetRedos.push({id:threadComment.AddCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,comment:{...item,ref:transformRef(item.ref,sourcePos,targetPos),unitId:targetUnitId,subUnitId:targetSubUnitId},sync:!0}}),sourceUndos.push({id:threadComment.AddCommentMutation.id,params:{unitId:sourceUnitId,subUnitId:sourceSubUnitId,comment:item,sync:!0}}),targetUndos.unshift({id:threadComment.DeleteCommentMutation.id,params:{unitId:targetUnitId,subUnitId:targetSubUnitId,commentId:item.id}})},"handleCommentItem");return roots.forEach(root=>{handleCommentItem(root)}),{redos:[...sourceRedos,...targetRedos],undos:[...targetUndos,...sourceUndos]}}}return{redos:[],undos:[]}},"onPasteCells")}))}},__name(_d,"SheetsThreadCommentCopyPasteController"),_d);SheetsThreadCommentCopyPasteController=__decorateClass$4([__decorateParam$4(0,core.Inject(sheetsUi.ISheetClipboardService)),__decorateParam$4(1,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$4(2,threadComment.IThreadCommentDataSourceService)],SheetsThreadCommentCopyPasteController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let SheetsThreadCommentHoverController=(_e=class extends core.Disposable{constructor(_hoverManagerService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_sheetPermissionInterceptorBaseController){super(),this._hoverManagerService=_hoverManagerService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rxjs.debounceTime(100)).subscribe(cell=>{const currentPopup=this._sheetsThreadCommentPopupService.activePopup;if(cell&&(currentPopup&&currentPopup.temp||!currentPopup)){const{location}=cell,{unitId,subUnitId,row,col}=location,commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);if(commentId){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);comment&&!comment.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row,col,commentId,temp:!0})}else currentPopup&&this._sheetsThreadCommentPopupService.hidePopup()}}))}},__name(_e,"SheetsThreadCommentHoverController"),_e);SheetsThreadCommentHoverController=__decorateClass$3([__decorateParam$3(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$3(1,core.Inject(exports2.SheetsThreadCommentPopupService)),__decorateParam$3(2,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$3(3,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController))],SheetsThreadCommentHoverController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");let SheetsThreadCommentPopupController=(_f=class extends core.Disposable{constructor(_commandService,_sheetsThreadCommentPopupService,_sheetsThreadCommentModel,_threadCommentPanelService,_univerInstanceService,_sheetPermissionInterceptorBaseController,_markSelectionService,_sheetSelectionService,_editorBridgeService,_renderManagerService){super();__publicField(this,"_isSwitchToCommenting",!1);__publicField(this,"_selectionShapeInfo",null);this._commandService=_commandService,this._sheetsThreadCommentPopupService=_sheetsThreadCommentPopupService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentPanelService=_threadCommentPanelService,this._univerInstanceService=_univerInstanceService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._markSelectionService=_markSelectionService,this._sheetSelectionService=_sheetSelectionService,this._editorBridgeService=_editorBridgeService,this._renderManagerService=_renderManagerService,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(selections,unitId,subUnitId){var _a2,_b2,_c2;const range=(_a2=selections[0])==null?void 0:_a2.range,render2=this._renderManagerService.getRenderById(unitId),skeleton=(_b2=render2==null?void 0:render2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId))==null?void 0:_b2.skeleton;if(!skeleton||!range)return;const actualCell=skeleton.getCellByIndex(range.startRow,range.startColumn);if((((_c2=range.rangeType)!=null?_c2:core.RANGE_TYPE.NORMAL)!==core.RANGE_TYPE.NORMAL||range.endColumn-range.startColumn>0||range.endRow-range.startRow>0)&&!((actualCell.isMerged||actualCell.isMergedMainCell)&&core.Rectangle.equals(actualCell.mergeInfo,range))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const row=actualCell.actualRow,col=actualCell.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(unitId,subUnitId,row,col)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id);return}const commentId=this._sheetsThreadCommentModel.getByLocation(unitId,subUnitId,row,col);commentId&&this._commandService.executeCommand(threadCommentUi.SetActiveCommentOperation.id,{unitId,subUnitId,commentId})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(selections=>{if(this._isSwitchToCommenting)return;const current=this._sheetSelectionService.currentSelectionParam;current&&this._handleSelectionChange(selections,current.unitId,current.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(visible=>{visible.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(commandInfo=>{if(commandInfo.id===threadComment.DeleteCommentMutation.id){const params=commandInfo.params,active=this._sheetsThreadCommentPopupService.activePopup;if(!active)return;const{unitId,subUnitId,commentId}=active;params.unitId===unitId&&params.subUnitId===subUnitId&&params.commentId===commentId&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async commentInfo=>{var _a2;if(commentInfo){const{unitId,subUnitId,commentId,trigger}=commentInfo,comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment||comment.resolved)return;const currentUnit=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!currentUnit||currentUnit.getUnitId()!==unitId)return;this._isSwitchToCommenting=!0,((_a2=currentUnit.getActiveSheet())==null?void 0:_a2.getSheetId())!==subUnitId&&await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId}),this._isSwitchToCommenting=!1;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column:col}=location;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookCommentPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:row,startColumn:col,endRow:row,endColumn:col}]))return;const GAP=1;if(await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(location.row-GAP,0),endRow:location.row+GAP,startColumn:Math.max(location.column-GAP,0),endColumn:location.column+GAP}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId,subUnitId,row:location.row,col:location.column,commentId:comment.id,trigger})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(rxjs.debounceTime(100)).subscribe(activeComment=>{var _a2,_b2;if(!activeComment){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId,subUnitId,commentId}=activeComment;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment)return;const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column}=location;if(Number.isNaN(row)||Number.isNaN(column))return null;const worksheet=(_a2=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getSheetBySheetId(subUnitId),mergeInfo=(_b2=worksheet==null?void 0:worksheet.getMergedCell(row,column))!=null?_b2:{startColumn:column,endColumn:column,startRow:row,endRow:row},shapeId=this._markSelectionService.addShape({range:mergeInfo,style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);shapeId&&(this._selectionShapeInfo={...activeComment,shapeId})}))}},__name(_f,"SheetsThreadCommentPopupController"),_f);SheetsThreadCommentPopupController=__decorateClass$2([__decorateParam$2(0,core.ICommandService),__decorateParam$2(1,core.Inject(exports2.SheetsThreadCommentPopupService)),__decorateParam$2(2,core.Inject(sheetsThreadCommentBase.SheetsThreadCommentModel)),__decorateParam$2(3,core.Inject(threadCommentUi.ThreadCommentPanelService)),__decorateParam$2(4,core.IUniverInstanceService),__decorateParam$2(5,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController)),__decorateParam$2(6,sheetsUi.IMarkSelectionService),__decorateParam$2(7,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$2(8,sheetsUi.IEditorBridgeService),__decorateParam$2(9,engineRender.IRenderManagerService)],SheetsThreadCommentPopupController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let ThreadCommentRemoveSheetsController=(_g=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_threadCommentModel,_threadCommentDataSourceService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._threadCommentDataSourceService=_threadCommentDataSourceService,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a2;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const commentMap=this._threadCommentModel.ensureMap(unitId,subUnitId),comments=Array.from(commentMap.values()).filter(comment=>!comment.parentId),ids=comments.map(comment=>comment.id),shouldSync=this._threadCommentDataSourceService.syncUpdateMutationToColla,redos=ids.map(id=>({id:threadComment.DeleteCommentMutation.id,params:{unitId,subUnitId,commentId:id}})),undos=comments.map(({children,...comment})=>({id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId,comment:{...comment,children:shouldSync?children:void 0},sync:!shouldSync}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_g,"ThreadCommentRemoveSheetsController"),_g);ThreadCommentRemoveSheetsController=__decorateClass$1([__decorateParam$1(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$1(1,core.IUniverInstanceService),__decorateParam$1(2,core.Inject(threadComment.ThreadCommentModel)),__decorateParam$1(3,threadComment.IThreadCommentDataSourceService)],ThreadCommentRemoveSheetsController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsThreadCommentPlugin=(_h=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_commandService,_configService){super(),this._config=_config,this._injector=_injector,this._commandService=_commandService,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){[[SheetsThreadCommentController],[SheetsThreadCommentRenderController],[SheetsThreadCommentCopyPasteController],[SheetsThreadCommentHoverController],[ThreadCommentRemoveSheetsController],[SheetsThreadCommentPopupController],[exports2.SheetsThreadCommentPopupService]].forEach(dep=>{this._injector.add(dep)}),[ShowAddSheetCommentModalOperation].forEach(command=>{this._commandService.registerCommand(command)}),this._injector.get(SheetsThreadCommentController)}onReady(){this._injector.get(SheetsThreadCommentRenderController),this._injector.get(ThreadCommentRemoveSheetsController)}onRendered(){this._injector.get(SheetsThreadCommentCopyPasteController),this._injector.get(SheetsThreadCommentHoverController),this._injector.get(SheetsThreadCommentPopupController)}},__name(_h,"UniverSheetsThreadCommentPlugin"),_h),__publicField2(exports2.UniverSheetsThreadCommentPlugin,"pluginName",SHEETS_THREAD_COMMENT),__publicField2(exports2.UniverSheetsThreadCommentPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsThreadCommentPlugin=__decorateClass([core.DependentOn(threadCommentUi.UniverThreadCommentUIPlugin,sheetsThreadCommentBase.UniverSheetsThreadCommentBasePlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.ICommandService)),__decorateParam(3,core.IConfigService)],exports2.UniverSheetsThreadCommentPlugin),Object.defineProperty(exports2,"SheetsThreadCommentModel",{enumerable:!0,get:__name(()=>sheetsThreadCommentBase.SheetsThreadCommentModel,"get")}),Object.defineProperty(exports2,"IThreadCommentMentionDataService",{enumerable:!0,get:__name(()=>threadCommentUi.IThreadCommentMentionDataService,"get")}),Object.defineProperty(exports2,"UniverThreadCommentUIPlugin",{enumerable:!0,get:__name(()=>threadCommentUi.UniverThreadCommentUIPlugin,"get")}),Object.defineProperty(exports2,"AddCommentCommand",{enumerable:!0,get:__name(()=>threadComment.AddCommentCommand,"get")}),Object.defineProperty(exports2,"DeleteCommentCommand",{enumerable:!0,get:__name(()=>threadComment.DeleteCommentCommand,"get")}),Object.defineProperty(exports2,"DeleteCommentTreeCommand",{enumerable:!0,get:__name(()=>threadComment.DeleteCommentTreeCommand,"get")}),Object.defineProperty(exports2,"IThreadCommentDataSourceService",{enumerable:!0,get:__name(()=>threadComment.IThreadCommentDataSourceService,"get")}),Object.defineProperty(exports2,"ResolveCommentCommand",{enumerable:!0,get:__name(()=>threadComment.ResolveCommentCommand,"get")}),Object.defineProperty(exports2,"UpdateCommentCommand",{enumerable:!0,get:__name(()=>threadComment.UpdateCommentCommand,"get")}),exports2.SHEETS_THREAD_COMMENT=SHEETS_THREAD_COMMENT,exports2.ShowAddSheetCommentModalOperation=ShowAddSheetCommentModalOperation,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-formula","@univerjs/sheets","@univerjs/thread-comment","rxjs"],i):(d=typeof globalThis<"u"?globalThis:d||self,i(d.UniverSheetsThreadComment={},d.UniverCore,d.UniverEngineFormula,d.UniverSheets,d.UniverThreadComment,d.rxjs))})(this,function(d,i,l,g,p,S){"use strict";var O=Object.defineProperty;var x=(d,i,l)=>i in d?O(d,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[i]=l;var f=(d,i,l)=>x(d,typeof i!="symbol"?i+"":i,l);var T=Object.defineProperty,y=Object.getOwnPropertyDescriptor,U=(h,o,e,n)=>{for(var t=n>1?void 0:n?y(o,e):o,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=(n?s(o,e,t):s(t))||t);return n&&t&&T(o,e,t),t},M=(h,o)=>(e,n)=>o(e,n,h);d.SheetsThreadCommentModel=class extends i.Disposable{constructor(e,n){super();f(this,"_matrixMap",new Map);f(this,"_locationMap",new Map);f(this,"_commentUpdate$",new S.Subject);f(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=e,this._univerInstanceService=n,this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let t=this._matrixMap.get(e);t||(t=new Map,this._matrixMap.set(e,t));let r=t.get(n);return r||(r=new i.ObjectMatrix,t.set(n,r)),r}_ensureCommentLocationMap(e,n){let t=this._locationMap.get(e);t||(t=new Map,this._locationMap.set(e,t));let r=t.get(n);return r||(r=new Map,t.set(n,r)),r}_addCommentToMatrix(e,n,t,r){var a;const s=(a=e.getValue(n,t))!=null?a:new Set;s.add(r),e.setValue(n,t,s)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const s=e.getValue(n,t);s&&s.has(r)&&(s.delete(r),s.size===0&&e.realDeleteValue(n,t))}}_ensure(e,n){const t=this._ensureCommentMatrix(e,n),r=this._ensureCommentLocationMap(e,n);return{matrix:t,locationMap:r}}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t;this._addComment(r,s,a)}}_addComment(e,n,t){const r=l.singleReferenceToGrid(t.ref),s=t.parentId,{row:a,column:m}=r,c=t.id,{matrix:_,locationMap:u}=this._ensure(e,n);!s&&a>=0&&m>=0&&(this._addCommentToMatrix(_,a,m,c),u.set(c,{row:a,column:m})),s||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!s,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==i.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:s}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:a,comment:m}=e.payload;if(a){const c=l.singleReferenceToGrid(m.ref),{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,m.id),this._commentUpdate$.next({...e,...c})}break}case"update":{const{commentId:a}=e.payload,m=this._threadCommentModel.getComment(n,t,a);if(!m)return;const c=l.singleReferenceToGrid(m.ref);this._commentUpdate$.next({...e,...c});break}case"updateRef":{const a=l.singleReferenceToGrid(e.payload.ref),{commentId:m}=e.payload,c=s.get(m);if(!c)return;const{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,m),s.delete(m),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,m),s.set(m,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:m,payload:c}=e,{locationMap:_}=this._ensure(a,m),u=_.get(c.commentId);u&&this._commentUpdate$.next({...e,...u});break}}}))}getByLocation(e,n,t,r){var m;return(m=this.getAllByLocation(e,n,t,r).filter(c=>!c.resolved)[0])==null?void 0:m.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(m=>this.getComment(e,n,m)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return;const a=this.getComment(e,n,s);if(a)return this._threadCommentModel.getThread(e,n,a.threadId)}showCommentMarker(e,n,t,r){const s=this.getByLocation(e,n,t,r);if(!s)return!1;const a=this.getComment(e,n,s);return!!(a&&!a.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}},d.SheetsThreadCommentModel=U([M(0,i.Inject(p.ThreadCommentModel)),M(1,i.IUniverInstanceService)],d.SheetsThreadCommentModel);var I=Object.defineProperty,b=Object.getOwnPropertyDescriptor,j=(h,o,e,n)=>{for(var t=n>1?void 0:n?b(o,e):o,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=(n?s(o,e,t):s(t))||t);return n&&t&&I(o,e,t),t},C=(h,o)=>(e,n)=>o(e,n,h);d.SheetsThreadCommentRefRangeController=class extends i.Disposable{constructor(e,n,t,r,s){super();f(this,"_disposableMap",new Map);f(this,"_watcherMap",new Map);f(this,"_handleRangeChange",(e,n,t,r,s)=>{const a=t.id,m={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:p.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(r),commentId:a},silent:s}}],undos:[{id:p.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(m),commentId:a},silent:s}}]}:{redos:[{id:p.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:a}}],undos:[{id:p.AddCommentMutation.id,params:{unitId:e,subUnitId:n,comment:t,sync:!0}}]}});this._refRangeService=e,this._sheetsThreadCommentModel=n,this._threadCommentModel=t,this._selectionManagerService=r,this._commandService=s,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(s,a=>{const m=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),c=Array.isArray(m)?m[0]:m;return c&&c.startColumn===s.startColumn&&c.startRow===s.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,c,!1)},e,n))}_watch(e,n,t){const r=t.id,s={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._watcherMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.watchRange(e,n,s,(a,m)=>{const{redos:c}=this._handleRangeChange(e,n,t,m,!0);i.sequenceExecuteAsync(c,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._watcherMap.get(r))==null||s.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var s;const r=this._getIdWithUnitId(e,n,t);(s=this._disposableMap.get(r))==null||s.dispose(),this._disposableMap.delete(r)}_initData(){const e=this._threadCommentModel.getAll();for(const n of e)for(const t of n.threads){const{unitId:r,subUnitId:s,root:a}=t,m=l.singleReferenceToGrid(a.ref),c={...a,...m};this._register(r,s,c),this._watch(r,s,c)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;switch(e.type){case"add":{if(e.payload.parentId)return;const r={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,r),this._watch(e.unitId,e.subUnitId,r);break}case"delete":{this._unregister(n,t,e.payload.commentId),this._unwatch(n,t,e.payload.commentId);break}case"updateRef":{const r=this._sheetsThreadCommentModel.getComment(n,t,e.payload.commentId);if(!r)return;this._unregister(n,t,e.payload.commentId);const s={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,s)),this._register(e.unitId,e.subUnitId,s);break}}})),this.disposeWithMe(i.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},d.SheetsThreadCommentRefRangeController=j([C(0,i.Inject(g.RefRangeService)),C(1,i.Inject(d.SheetsThreadCommentModel)),C(2,i.Inject(p.ThreadCommentModel)),C(3,i.Inject(g.SheetsSelectionsService)),C(4,i.ICommandService)],d.SheetsThreadCommentRefRangeController);const P="SHEET_THREAD_COMMENT_BASE_PLUGIN";var v=Object.defineProperty,$=Object.getOwnPropertyDescriptor,E=(h,o,e)=>o in h?v(h,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[o]=e,D=(h,o,e,n)=>{for(var t=n>1?void 0:n?$(o,e):o,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=(n?s(o,e,t):s(t))||t);return n&&t&&v(o,e,t),t},R=(h,o)=>(e,n)=>o(e,n,h),w=(h,o,e)=>E(h,typeof o!="symbol"?o+"":o,e);d.UniverSheetsThreadCommentPlugin=class extends i.Plugin{constructor(o,e,n){super(),this._injector=e,this._commandService=n}onStarting(){[[d.SheetsThreadCommentModel],[d.SheetsThreadCommentRefRangeController]].forEach(o=>{this._injector.add(o)}),this._injector.get(d.SheetsThreadCommentRefRangeController)}},w(d.UniverSheetsThreadCommentPlugin,"pluginName",P),w(d.UniverSheetsThreadCommentPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentPlugin=D([i.DependentOn(p.UniverThreadCommentPlugin),R(1,i.Inject(i.Injector)),R(2,i.Inject(i.ICommandService))],d.UniverSheetsThreadCommentPlugin),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-thread-comment",
3
- "version": "0.4.2",
3
+ "version": "0.5.0-alpha.0",
4
4
  "private": false,
5
- "description": "Univer thread comment plugin",
5
+ "description": "Univer sheets thread comment base plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
@@ -29,11 +29,14 @@
29
29
  "require": "./lib/cjs/*",
30
30
  "types": "./lib/types/index.d.ts"
31
31
  },
32
- "./lib/*": "./lib/*",
33
- "./locale/*": "./lib/locale/*.json"
32
+ "./facade": {
33
+ "import": "./lib/es/facade.js",
34
+ "require": "./lib/cjs/facade.js",
35
+ "types": "./lib/types/facade/index.d.ts"
36
+ },
37
+ "./lib/*": "./lib/*"
34
38
  },
35
- "main": "./lib/cjs/index.js",
36
- "module": "./lib/es/index.js",
39
+ "main": "./lib/es/index.js",
37
40
  "types": "./lib/types/index.d.ts",
38
41
  "publishConfig": {
39
42
  "access": "public"
@@ -45,32 +48,23 @@
45
48
  "lib"
46
49
  ],
47
50
  "peerDependencies": {
48
- "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
49
51
  "rxjs": ">=7.0.0"
50
52
  },
51
53
  "dependencies": {
52
- "@univerjs/icons": "^0.1.84",
53
- "clsx": "^2.1.1",
54
- "@univerjs/core": "0.4.2",
55
- "@univerjs/design": "0.4.2",
56
- "@univerjs/engine-render": "0.4.2",
57
- "@univerjs/engine-formula": "0.4.2",
58
- "@univerjs/sheets": "0.4.2",
59
- "@univerjs/sheets-thread-comment-base": "0.4.2",
60
- "@univerjs/sheets-ui": "0.4.2",
61
- "@univerjs/thread-comment": "0.4.2",
62
- "@univerjs/ui": "0.4.2",
63
- "@univerjs/thread-comment-ui": "0.4.2"
54
+ "@vitejs/plugin-react": "4.3.3",
55
+ "@univerjs/core": "0.5.0-alpha.0",
56
+ "@univerjs/sheets": "0.5.0-alpha.0",
57
+ "@univerjs/thread-comment": "0.5.0-alpha.0",
58
+ "@univerjs/engine-formula": "0.5.0-alpha.0"
64
59
  },
65
60
  "devDependencies": {
66
- "react": "18.3.1",
67
61
  "rxjs": "^7.8.1",
68
62
  "typescript": "^5.6.3",
69
- "vite": "^5.4.8",
70
- "vitest": "^2.1.2",
71
- "@univerjs-infra/shared": "0.4.2"
63
+ "vite": "^5.4.10",
64
+ "vitest": "^2.1.4",
65
+ "@univerjs-infra/shared": "0.5.0-alpha.0"
72
66
  },
73
- "univerSpace": {
67
+ "space": {
74
68
  ".": {
75
69
  "import": "./lib/es/index.js",
76
70
  "require": "./lib/cjs/index.js",
@@ -81,14 +75,19 @@
81
75
  "require": "./lib/cjs/*",
82
76
  "types": "./lib/types/index.d.ts"
83
77
  },
84
- "./lib/*": "./lib/*",
85
- "./locale/*": "./lib/locale/*.json"
78
+ "./facade": {
79
+ "import": "./lib/es/facade.js",
80
+ "require": "./lib/cjs/facade.js",
81
+ "types": "./lib/types/facade/index.d.ts"
82
+ },
83
+ "./lib/*": "./lib/*"
86
84
  },
87
85
  "scripts": {
88
86
  "test": "vitest run",
89
87
  "test:watch": "vitest",
90
88
  "coverage": "vitest run --coverage",
91
89
  "lint:types": "tsc --noEmit",
92
- "build": "tsc && vite build"
93
- }
90
+ "build": "tsx build.ts"
91
+ },
92
+ "module": "./lib/es/index.js"
94
93
  }
@@ -1,8 +0,0 @@
1
- {
2
- "sheetThreadComment": {
3
- "menu": {
4
- "addComment": "Add Comment",
5
- "commentManagement": "Comment Management"
6
- }
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "sheetThreadComment": {
3
- "menu": {
4
- "addComment": "افزودن نظر",
5
- "commentManagement": "مدیریت نظر"
6
- }
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "sheetThreadComment": {
3
- "menu": {
4
- "addComment": "Add Comment",
5
- "commentManagement": "Comment Management"
6
- }
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "sheetThreadComment": {
3
- "menu": {
4
- "addComment": "Thêm bình luận",
5
- "commentManagement": "Quản lý bình luận"
6
- }
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "sheetThreadComment": {
3
- "menu": {
4
- "addComment": "添加评论",
5
- "commentManagement": "评论管理"
6
- }
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "sheetThreadComment": {
3
- "menu": {
4
- "addComment": "新增評論",
5
- "commentManagement": "評論管理"
6
- }
7
- }
8
- }
@@ -1,2 +0,0 @@
1
- import { ICommand } from '@univerjs/core';
2
- export declare const ShowAddSheetCommentModalOperation: ICommand;
@@ -1,12 +0,0 @@
1
- import { MenuItemType, IMenuItem, IShortcutItem } from '@univerjs/ui';
2
- import { IAccessor } from '@univerjs/core';
3
- export declare const threadCommentMenuFactory: (accessor: IAccessor) => IMenuItem;
4
- export declare const threadPanelMenuFactory: (accessor: IAccessor) => {
5
- id: string;
6
- type: MenuItemType;
7
- icon: string;
8
- tooltip: string;
9
- disabled$: import('rxjs').Observable<boolean>;
10
- hidden$: import('rxjs').Observable<boolean>;
11
- };
12
- export declare const AddCommentShortcut: IShortcutItem;
@@ -1,2 +0,0 @@
1
- import { MenuSchemaType } from '@univerjs/ui';
2
- export declare const menuSchema: MenuSchemaType;
@@ -1,13 +0,0 @@
1
- import { Disposable, IUniverInstanceService } from '@univerjs/core';
2
- import { IRenderManagerService } from '@univerjs/engine-render';
3
- import { SheetInterceptorService } from '@univerjs/sheets';
4
- import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
5
- export declare class SheetsThreadCommentRenderController extends Disposable {
6
- private readonly _sheetInterceptorService;
7
- private readonly _sheetsThreadCommentModel;
8
- private readonly _univerInstanceService;
9
- private readonly _renderManagerService;
10
- constructor(_sheetInterceptorService: SheetInterceptorService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _univerInstanceService: IUniverInstanceService, _renderManagerService: IRenderManagerService);
11
- private _initViewModelIntercept;
12
- private _initSkeletonChange;
13
- }
@@ -1,12 +0,0 @@
1
- import { Disposable } from '@univerjs/core';
2
- import { SheetsThreadCommentModel } from '@univerjs/sheets-thread-comment-base';
3
- import { ISheetClipboardService } from '@univerjs/sheets-ui';
4
- import { IThreadCommentDataSourceService } from '@univerjs/thread-comment';
5
- export declare class SheetsThreadCommentCopyPasteController extends Disposable {
6
- private _sheetClipboardService;
7
- private _sheetsThreadCommentModel;
8
- private _threadCommentDataSourceService;
9
- private _copyInfo;
10
- constructor(_sheetClipboardService: ISheetClipboardService, _sheetsThreadCommentModel: SheetsThreadCommentModel, _threadCommentDataSourceService: IThreadCommentDataSourceService);
11
- private _initClipboardHook;
12
- }