@univerjs/sheets-thread-comment 0.5.4 → 0.5.5-experimental.20250122-3362a4a
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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +213 -184
- package/lib/es/index.js +239 -238
- package/lib/types/facade/f-range.d.ts +53 -4
- package/lib/types/facade/f-thread-comment.d.ts +3 -0
- package/lib/types/facade/f-univer.d.ts +4 -1
- package/lib/types/facade/f-workbook.d.ts +18 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/LICENSE +0 -176
|
@@ -4,30 +4,76 @@ import { FTheadCommentBuilder, FThreadComment } from './f-thread-comment';
|
|
|
4
4
|
export interface IFRangeCommentMixin {
|
|
5
5
|
/**
|
|
6
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`.
|
|
7
|
+
* @returns {FThreadComment | null} The comment of the start cell in the current range. If the cell does not have a comment, return `null`.
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const range = univerAPI.getActiveWorkbook()
|
|
11
|
+
* .getActiveSheet()
|
|
12
|
+
* .getActiveRange();
|
|
13
|
+
* const comment = range.getComment();
|
|
14
|
+
* ```
|
|
8
15
|
*/
|
|
9
16
|
getComment(): Nullable<FThreadComment>;
|
|
10
17
|
/**
|
|
11
18
|
* Get the comments in the current range.
|
|
12
19
|
* @returns {FThreadComment[]} The comments in the current range.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const range = univerAPI.getActiveWorkbook()
|
|
23
|
+
* .getActiveSheet()
|
|
24
|
+
* .getActiveRange();
|
|
25
|
+
* const comments = range.getComments();
|
|
26
|
+
* comments.forEach((comment) => {
|
|
27
|
+
* console.log(comment.getContent());
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
13
30
|
*/
|
|
14
31
|
getComments(): FThreadComment[];
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated use `addCommentAsync` as instead.
|
|
34
|
+
*/
|
|
35
|
+
addComment(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
|
|
15
36
|
/**
|
|
16
37
|
* Add a comment to the start cell in the current range.
|
|
17
38
|
* @param content The content of the comment.
|
|
18
39
|
* @returns Whether the comment is added successfully.
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const range = univerAPI.getActiveWorkbook()
|
|
43
|
+
* .getActiveSheet()
|
|
44
|
+
* .getActiveRange();
|
|
45
|
+
*
|
|
46
|
+
* const comment = univerAPI.newTheadComment()
|
|
47
|
+
* .setContent(univerAPI.newRichText().insertText('hello zhangsan'));
|
|
48
|
+
* const success = await range.addCommentAsync(comment);
|
|
49
|
+
* ```
|
|
19
50
|
*/
|
|
20
|
-
|
|
51
|
+
addCommentAsync(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated use `clearCommentAsync` as instead.
|
|
54
|
+
*/
|
|
55
|
+
clearComment(): Promise<boolean>;
|
|
21
56
|
/**
|
|
22
57
|
* Clear the comment of the start cell in the current range.
|
|
23
58
|
* @returns Whether the comment is cleared successfully.
|
|
24
59
|
*/
|
|
25
|
-
|
|
60
|
+
clearCommentAsync(): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated use `clearComments` as instead.
|
|
63
|
+
*/
|
|
64
|
+
clearComments(): Promise<boolean>;
|
|
26
65
|
/**
|
|
27
66
|
* Clear all of the comments in the current range.
|
|
28
67
|
* @returns Whether the comments are cleared successfully.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const range = univerAPI.getActiveWorkbook()
|
|
71
|
+
* .getActiveSheet()
|
|
72
|
+
* .getActiveRange();
|
|
73
|
+
* const success = await range.clearCommentsAsync();
|
|
74
|
+
* ```
|
|
29
75
|
*/
|
|
30
|
-
|
|
76
|
+
clearCommentsAsync(): Promise<boolean>;
|
|
31
77
|
}
|
|
32
78
|
export declare class FRangeCommentMixin extends FRange implements IFRangeCommentMixin {
|
|
33
79
|
getComment(): Nullable<FThreadComment>;
|
|
@@ -35,6 +81,9 @@ export declare class FRangeCommentMixin extends FRange implements IFRangeComment
|
|
|
35
81
|
addComment(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
|
|
36
82
|
clearComment(): Promise<boolean>;
|
|
37
83
|
clearComments(): Promise<boolean>;
|
|
84
|
+
addCommentAsync(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
|
|
85
|
+
clearCommentAsync(): Promise<boolean>;
|
|
86
|
+
clearCommentsAsync(): Promise<boolean>;
|
|
38
87
|
}
|
|
39
88
|
declare module '@univerjs/sheets/facade' {
|
|
40
89
|
interface FRange extends IFRangeCommentMixin {
|
|
@@ -157,6 +157,9 @@ export declare class FTheadCommentBuilder extends FTheadCommentItem {
|
|
|
157
157
|
*/
|
|
158
158
|
build(): IThreadComment;
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* @hideconstructor
|
|
162
|
+
*/
|
|
160
163
|
export declare class FThreadComment {
|
|
161
164
|
private readonly _thread;
|
|
162
165
|
private readonly _parent;
|
|
@@ -21,7 +21,7 @@ export interface IFUniverCommentMixin {
|
|
|
21
21
|
onCommentResolved(callback: (event: ISheetCommentResolveEvent) => void): IDisposable;
|
|
22
22
|
/**
|
|
23
23
|
* create a new thread comment
|
|
24
|
-
* @
|
|
24
|
+
* @returns {FTheadCommentBuilder} thead comment builder
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
27
|
* const comment = univerAPI.newTheadComment().setContent(univerAPI.newRichText().insertText('hello zhangsan'));
|
|
@@ -32,6 +32,9 @@ export interface IFUniverCommentMixin {
|
|
|
32
32
|
export declare class FUniverCommentMixin extends FUniver implements IFUniverCommentMixin {
|
|
33
33
|
private _handleCommentCommand;
|
|
34
34
|
private _handleBeforeCommentCommand;
|
|
35
|
+
/**
|
|
36
|
+
* @ignore
|
|
37
|
+
*/
|
|
35
38
|
_initialize(injector: Injector): void;
|
|
36
39
|
newTheadComment(comment?: IThreadComment): FTheadCommentBuilder;
|
|
37
40
|
}
|
|
@@ -7,10 +7,21 @@ export interface IFWorkbookThreadCommentMixin {
|
|
|
7
7
|
/**
|
|
8
8
|
* Get all comments in the current sheet
|
|
9
9
|
* @returns all comments in the current sheet
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
13
|
+
* const comments = workbook.getComments();
|
|
14
|
+
* ```
|
|
10
15
|
*/
|
|
11
16
|
getComments(): FThreadComment[];
|
|
12
17
|
/**
|
|
13
18
|
* Clear all comments in the current sheet
|
|
19
|
+
* @returns Whether the comments are cleared successfully.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
23
|
+
* const success = await workbook.clearComments();
|
|
24
|
+
* ```
|
|
14
25
|
*/
|
|
15
26
|
clearComments(): Promise<boolean>;
|
|
16
27
|
/**
|
|
@@ -32,22 +43,29 @@ export interface IFWorkbookThreadCommentMixin {
|
|
|
32
43
|
}
|
|
33
44
|
export declare class FWorkbookThreadCommentMixin extends FWorkbook implements IFWorkbookThreadCommentMixin {
|
|
34
45
|
_threadCommentModel: ThreadCommentModel;
|
|
46
|
+
/**
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
35
49
|
_initialize(): void;
|
|
36
50
|
getComments(): FThreadComment[];
|
|
37
51
|
clearComments(): Promise<boolean>;
|
|
38
52
|
/**
|
|
53
|
+
* @param callback
|
|
39
54
|
* @deprecated
|
|
40
55
|
*/
|
|
41
56
|
onThreadCommentChange(callback: (commentUpdate: CommentUpdate) => void | false): IDisposable;
|
|
42
57
|
/**
|
|
58
|
+
* @param callback
|
|
43
59
|
* @deprecated
|
|
44
60
|
*/
|
|
45
61
|
onBeforeAddThreadComment(callback: (params: IAddCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
46
62
|
/**
|
|
63
|
+
* @param callback
|
|
47
64
|
* @deprecated
|
|
48
65
|
*/
|
|
49
66
|
onBeforeUpdateThreadComment(callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
50
67
|
/**
|
|
68
|
+
* @param callback
|
|
51
69
|
* @deprecated
|
|
52
70
|
*/
|
|
53
71
|
onBeforeDeleteThreadComment(callback: (params: IDeleteCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-thread-comment","@univerjs/sheets/facade","@univerjs/thread-comment","@univerjs/engine-formula","rxjs"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.UniverSheetsThreadCommentFacade={},s.UniverCore,s.UniverSheetsThreadComment,s.UniverSheetsFacade,s.UniverThreadComment,s.UniverEngineFormula,s.rxjs))})(this,function(s,r,a,u,m,U,b){"use strict";var w=Object.defineProperty;var B=(s,r,a)=>r in s?w(s,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[r]=a;var T=(s,r,a)=>B(s,typeof r!="symbol"?r+"":r,a);var S=Object.defineProperty,j=Object.getOwnPropertyDescriptor,k=(h,e,t,n)=>{for(var o=n>1?void 0:n?j(e,t):e,i=h.length-1,d;i>=0;i--)(d=h[i])&&(o=(n?d(e,t,o):d(o))||o);return n&&o&&S(e,t,o),o},I=(h,e)=>(t,n)=>e(t,n,h);class p{constructor(e){T(this,"_comment",{id:r.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:r.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});e&&(this._comment=e)}static create(e){return new p(e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return r.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return _.create(r.Tools.deepClone(this._comment))}}class _ extends p{static create(e){return new _(e)}setContent(e){return e instanceof r.RichTextValue?this._comment.text=e.getData().body:this._comment.text=e,this}setPersonId(e){return this._comment.personId=e,this}setDateTime(e){return this._comment.dT=m.getDT(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}}s.FThreadComment=class{constructor(e,t,n,o,i,d,C){this._thread=e,this._parent=t,this._injector=n,this._commandService=o,this._univerInstanceService=i,this._threadCommentModel=d,this._userManagerService=C}_getRef(){var n;const e=((n=this._parent)==null?void 0:n.ref)||this._thread.ref;return U.deserializeRangeWithSheet(e).range}getIsRoot(){return!this._parent}getCommentData(){const{children:e,...t}=this._thread;return t}getReplies(){var n;const e=this._getRef(),t=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,e.startRow,e.startColumn);return(n=t==null?void 0:t.children)==null?void 0:n.map(o=>this._injector.createInstance(s.FThreadComment,o))}getRange(){const e=this._univerInstanceService.getUnit(this._thread.unitId,r.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const t=e.getSheetBySheetId(this._thread.subUnitId);if(!t)return null;const n=this._getRef();return this._injector.createInstance(u.FRange,e,t,n)}getContent(){return this._thread.text}getRichText(){const e=this._thread.text;return r.RichTextValue.create({body:e,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?m.DeleteCommentTreeCommand.id:m.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(e){return this.updateAsync(e)}async updateAsync(e){const t=e instanceof r.RichTextValue?e.getData().body:e,n=m.getDT();return await this._commandService.executeCommand(m.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:t,updated:!0,updateT:n}})}resolve(e){return this.resolveAsync(e)}resolveAsync(e){return this._commandService.executeCommand(m.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:e!=null?e:!this._thread.resolved})}async replyAsync(e){var n;const t=e.build();return this._commandService.executeCommand(m.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:r.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:(n=this._parent)==null?void 0:n.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:t.text,attachments:t.attachments,dT:t.dT||m.getDT(),personId:t.personId||this._userManagerService.getCurrentUser().userID}})}},s.FThreadComment=k([I(2,r.Inject(r.Injector)),I(3,r.ICommandService),I(4,r.IUniverInstanceService),I(5,r.Inject(a.SheetsThreadCommentModel)),I(6,r.Inject(r.UserManagerService))],s.FThreadComment);class y extends u.FRange{getComment(){const t=this._injector.get(a.SheetsThreadCommentModel),n=this._workbook.getUnitId(),o=this._worksheet.getSheetId(),i=t.getByLocation(n,o,this._range.startRow,this._range.startColumn);if(!i)return null;const d=t.getComment(n,o,i);return d?this._injector.createInstance(s.FThreadComment,d):null}getComments(){const t=this._injector.get(a.SheetsThreadCommentModel),n=this._workbook.getUnitId(),o=this._worksheet.getSheetId(),i=[];return r.Range.foreach(this._range,(d,C)=>{const l=t.getByLocation(n,o,d,C);if(l){const g=t.getComment(n,o,l);g&&i.push(this._injector.createInstance(s.FThreadComment,g))}}),i}addComment(e){var v;const t=this._injector,n=(v=this.getComment())==null?void 0:v.getCommentData(),o=t.get(r.ICommandService),i=t.get(r.UserManagerService),d=this._workbook.getUnitId(),C=this._worksheet.getSheetId(),l=`${r.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,g=i.getCurrentUser(),f=e instanceof _?e.build():{text:e};return o.executeCommand(m.AddCommentCommand.id,{unitId:d,subUnitId:C,comment:{text:f.text,dT:f.dT||m.getDT(),attachments:[],id:f.id||r.generateRandomId(),ref:l,personId:f.personId||g.userID,parentId:n==null?void 0:n.id,unitId:d,subUnitId:C,threadId:(n==null?void 0:n.threadId)||r.generateRandomId()}})}clearComment(){var d;const e=this._injector,t=(d=this.getComment())==null?void 0:d.getCommentData(),n=e.get(r.ICommandService),o=this._workbook.getUnitId(),i=this._worksheet.getSheetId();return t?n.executeCommand(m.DeleteCommentTreeCommand.id,{unitId:o,subUnitId:i,threadId:t.threadId,commentId:t.id}):Promise.resolve(!0)}clearComments(){const t=this.getComments().map(n=>n.deleteAsync());return Promise.all(t).then(()=>!0)}}u.FRange.extend(y);class x extends u.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(m.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(s.FThreadComment,e.root))}clearComments(){const t=this.getComments().map(n=>n.deleteAsync());return Promise.all(t).then(()=>!0)}onThreadCommentChange(e){return r.toDisposable(this._threadCommentModel.commentUpdate$.pipe(b.filter(t=>t.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddThreadComment(e){return r.toDisposable(this._commandService.beforeCommandExecuted((t,n)=>{const o=t.params;if(t.id===m.AddCommentCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(e(o,n)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(e){return r.toDisposable(this._commandService.beforeCommandExecuted((t,n)=>{const o=t.params;if(t.id===m.UpdateCommentCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(e(o,n)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(e){return r.toDisposable(this._commandService.beforeCommandExecuted((t,n)=>{const o=t.params;if(t.id===m.DeleteCommentCommand.id||t.id===m.DeleteCommentTreeCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(e(o,n)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}u.FWorkbook.extend(x);class D extends u.FWorksheet{getComments(){return this._injector.get(a.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(n=>this._injector.createInstance(s.FThreadComment,n))}clearComments(){const t=this.getComments().map(n=>n.deleteAsync());return Promise.all(t).then(()=>!0)}onCommented(e){return this._injector.get(r.ICommandService).onCommandExecuted(n=>{if(n.id===m.AddCommentCommand.id){const o=n.params;e(o)}})}getCommentById(e){const n=this._injector.get(a.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(n)return this._injector.createInstance(s.FThreadComment,n)}}u.FWorksheet.extend(D);const c={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDeleted:"BeforeCommentDeleted",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class R extends r.FEventName{get CommentAdded(){return c.CommentAdded}get BeforeCommentAdd(){return c.BeforeCommentAdd}get CommentUpdated(){return c.CommentUpdated}get BeforeCommentUpdate(){return c.BeforeCommentUpdate}get CommentDeleted(){return c.CommentDeleted}get BeforeCommentDeleted(){return c.BeforeCommentDeleted}get CommentResolved(){return c.CommentResolved}get BeforeCommentResolve(){return c.BeforeCommentResolve}}r.FEventName.extend(R),Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-thread-comment","@univerjs/sheets/facade","@univerjs/thread-comment","@univerjs/engine-formula","rxjs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsThreadCommentFacade={},global.UniverCore,global.UniverSheetsThreadComment,global.UniverSheetsFacade,global.UniverThreadComment,global.UniverEngineFormula,global.rxjs))})(this,function(exports2,core,sheetsThreadComment,facade,threadComment,engineFormula,rxjs){"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;var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__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");const _FTheadCommentItem=class _FTheadCommentItem{constructor(comment){__publicField(this,"_comment",{id:core.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:core.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});comment&&(this._comment=comment)}static create(comment){return new _FTheadCommentItem(comment)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return core.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return FTheadCommentBuilder.create(core.Tools.deepClone(this._comment))}};__name(_FTheadCommentItem,"FTheadCommentItem");let FTheadCommentItem=_FTheadCommentItem;const _FTheadCommentBuilder=class _FTheadCommentBuilder extends FTheadCommentItem{static create(comment){return new _FTheadCommentBuilder(comment)}setContent(content){return content instanceof core.RichTextValue?this._comment.text=content.getData().body:this._comment.text=content,this}setPersonId(userId){return this._comment.personId=userId,this}setDateTime(date){return this._comment.dT=threadComment.getDT(date),this}setId(id){return this._comment.id=id,this}setThreadId(threadId){return this._comment.threadId=threadId,this}build(){return this._comment}};__name(_FTheadCommentBuilder,"FTheadCommentBuilder");let FTheadCommentBuilder=_FTheadCommentBuilder;exports2.FThreadComment=(_a=class{constructor(_thread,_parent,_injector,_commandService,_univerInstanceService,_threadCommentModel,_userManagerService){this._thread=_thread,this._parent=_parent,this._injector=_injector,this._commandService=_commandService,this._univerInstanceService=_univerInstanceService,this._threadCommentModel=_threadCommentModel,this._userManagerService=_userManagerService}_getRef(){var _a2;const ref=((_a2=this._parent)==null?void 0:_a2.ref)||this._thread.ref;return engineFormula.deserializeRangeWithSheet(ref).range}getIsRoot(){return!this._parent}getCommentData(){const{children,...comment}=this._thread;return comment}getReplies(){var _a2;const range=this._getRef(),comments=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,range.startRow,range.startColumn);return(_a2=comments==null?void 0:comments.children)==null?void 0:_a2.map(child=>this._injector.createInstance(exports2.FThreadComment,child))}getRange(){const workbook=this._univerInstanceService.getUnit(this._thread.unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return null;const worksheet=workbook.getSheetBySheetId(this._thread.subUnitId);if(!worksheet)return null;const range=this._getRef();return this._injector.createInstance(facade.FRange,workbook,worksheet,range)}getContent(){return this._thread.text}getRichText(){const body=this._thread.text;return core.RichTextValue.create({body,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?threadComment.DeleteCommentTreeCommand.id:threadComment.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(content){return this.updateAsync(content)}async updateAsync(content){const body=content instanceof core.RichTextValue?content.getData().body:content,dt=threadComment.getDT();return await this._commandService.executeCommand(threadComment.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:body,updated:!0,updateT:dt}})}resolve(resolved){return this.resolveAsync(resolved)}resolveAsync(resolved){return this._commandService.executeCommand(threadComment.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:resolved!=null?resolved:!this._thread.resolved})}async replyAsync(comment){var _a2;const commentData=comment.build();return this._commandService.executeCommand(threadComment.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:core.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:(_a2=this._parent)==null?void 0:_a2.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:commentData.text,attachments:commentData.attachments,dT:commentData.dT||threadComment.getDT(),personId:commentData.personId||this._userManagerService.getCurrentUser().userID}})}},__name(_a,"FThreadComment"),_a),exports2.FThreadComment=__decorateClass([__decorateParam(2,core.Inject(core.Injector)),__decorateParam(3,core.ICommandService),__decorateParam(4,core.IUniverInstanceService),__decorateParam(5,core.Inject(sheetsThreadComment.SheetsThreadCommentModel)),__decorateParam(6,core.Inject(core.UserManagerService))],exports2.FThreadComment);const _FRangeCommentMixin=class _FRangeCommentMixin extends facade.FRange{getComment(){const sheetsTheadCommentModel=this._injector.get(sheetsThreadComment.SheetsThreadCommentModel),unitId=this._workbook.getUnitId(),sheetId=this._worksheet.getSheetId(),commentId=sheetsTheadCommentModel.getByLocation(unitId,sheetId,this._range.startRow,this._range.startColumn);if(!commentId)return null;const comment=sheetsTheadCommentModel.getComment(unitId,sheetId,commentId);return comment?this._injector.createInstance(exports2.FThreadComment,comment):null}getComments(){const sheetsTheadCommentModel=this._injector.get(sheetsThreadComment.SheetsThreadCommentModel),unitId=this._workbook.getUnitId(),sheetId=this._worksheet.getSheetId(),comments=[];return core.Range.foreach(this._range,(row,col)=>{const commentId=sheetsTheadCommentModel.getByLocation(unitId,sheetId,row,col);if(commentId){const comment=sheetsTheadCommentModel.getComment(unitId,sheetId,commentId);comment&&comments.push(this._injector.createInstance(exports2.FThreadComment,comment))}}),comments}addComment(content){var _a2;const injector=this._injector,currentComment=(_a2=this.getComment())==null?void 0:_a2.getCommentData(),commentService=injector.get(core.ICommandService),userService=injector.get(core.UserManagerService),unitId=this._workbook.getUnitId(),sheetId=this._worksheet.getSheetId(),refStr=`${core.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,currentUser=userService.getCurrentUser(),commentData=content instanceof FTheadCommentBuilder?content.build():{text:content};return commentService.executeCommand(threadComment.AddCommentCommand.id,{unitId,subUnitId:sheetId,comment:{text:commentData.text,dT:commentData.dT||threadComment.getDT(),attachments:[],id:commentData.id||core.generateRandomId(),ref:refStr,personId:commentData.personId||currentUser.userID,parentId:currentComment==null?void 0:currentComment.id,unitId,subUnitId:sheetId,threadId:(currentComment==null?void 0:currentComment.threadId)||core.generateRandomId()}})}clearComment(){var _a2;const injector=this._injector,currentComment=(_a2=this.getComment())==null?void 0:_a2.getCommentData(),commentService=injector.get(core.ICommandService),unitId=this._workbook.getUnitId(),sheetId=this._worksheet.getSheetId();return currentComment?commentService.executeCommand(threadComment.DeleteCommentTreeCommand.id,{unitId,subUnitId:sheetId,threadId:currentComment.threadId,commentId:currentComment.id}):Promise.resolve(!0)}clearComments(){const promises=this.getComments().map(comment=>comment.deleteAsync());return Promise.all(promises).then(()=>!0)}addCommentAsync(content){return this.addComment(content)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}};__name(_FRangeCommentMixin,"FRangeCommentMixin");let FRangeCommentMixin=_FRangeCommentMixin;facade.FRange.extend(FRangeCommentMixin);const _FWorkbookThreadCommentMixin=class _FWorkbookThreadCommentMixin extends facade.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(threadComment.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(i=>this._injector.createInstance(exports2.FThreadComment,i.root))}clearComments(){const promises=this.getComments().map(comment=>comment.deleteAsync());return Promise.all(promises).then(()=>!0)}onThreadCommentChange(callback){return core.toDisposable(this._threadCommentModel.commentUpdate$.pipe(rxjs.filter(change=>change.unitId===this._workbook.getUnitId())).subscribe(callback))}onBeforeAddThreadComment(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===threadComment.AddCommentCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===threadComment.UpdateCommentCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(callback){return core.toDisposable(this._commandService.beforeCommandExecuted((commandInfo,options)=>{const params=commandInfo.params;if(commandInfo.id===threadComment.DeleteCommentCommand.id||commandInfo.id===threadComment.DeleteCommentTreeCommand.id){if(params.unitId!==this._workbook.getUnitId())return;if(callback(params,options)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}};__name(_FWorkbookThreadCommentMixin,"FWorkbookThreadCommentMixin");let FWorkbookThreadCommentMixin=_FWorkbookThreadCommentMixin;facade.FWorkbook.extend(FWorkbookThreadCommentMixin);const _FWorksheetCommentMixin=class _FWorksheetCommentMixin extends facade.FWorksheet{getComments(){return this._injector.get(sheetsThreadComment.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(comment=>this._injector.createInstance(exports2.FThreadComment,comment))}clearComments(){const promises=this.getComments().map(comment=>comment.deleteAsync());return Promise.all(promises).then(()=>!0)}onCommented(callback){return this._injector.get(core.ICommandService).onCommandExecuted(command=>{if(command.id===threadComment.AddCommentCommand.id){const params=command.params;callback(params)}})}getCommentById(commentId){const comment=this._injector.get(sheetsThreadComment.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),commentId);if(comment)return this._injector.createInstance(exports2.FThreadComment,comment)}};__name(_FWorksheetCommentMixin,"FWorksheetCommentMixin");let FWorksheetCommentMixin=_FWorksheetCommentMixin;facade.FWorksheet.extend(FWorksheetCommentMixin);const CommentEvent={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDeleted:"BeforeCommentDeleted",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"},_FCommentEvent=class _FCommentEvent extends core.FEventName{get CommentAdded(){return CommentEvent.CommentAdded}get BeforeCommentAdd(){return CommentEvent.BeforeCommentAdd}get CommentUpdated(){return CommentEvent.CommentUpdated}get BeforeCommentUpdate(){return CommentEvent.BeforeCommentUpdate}get CommentDeleted(){return CommentEvent.CommentDeleted}get BeforeCommentDeleted(){return CommentEvent.BeforeCommentDeleted}get CommentResolved(){return CommentEvent.CommentResolved}get BeforeCommentResolve(){return CommentEvent.BeforeCommentResolve}};__name(_FCommentEvent,"FCommentEvent");let FCommentEvent=_FCommentEvent;core.FEventName.extend(FCommentEvent),Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,o){typeof exports=="object"&&typeof module<"u"?o(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"],o):(m=typeof globalThis<"u"?globalThis:m||self,o(m.UniverSheetsThreadComment={},m.UniverCore,m.UniverEngineFormula,m.UniverSheets,m.UniverThreadComment,m.rxjs))})(this,function(m,o,l,g,p,S){"use strict";var O=Object.defineProperty;var x=(m,o,l)=>o in m?O(m,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):m[o]=l;var f=(m,o,l)=>x(m,typeof o!="symbol"?o+"":o,l);var T=Object.defineProperty,y=Object.getOwnPropertyDescriptor,U=(h,i,e,n)=>{for(var t=n>1?void 0:n?y(i,e):i,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=(n?s(i,e,t):s(t))||t);return n&&t&&T(i,e,t),t},M=(h,i)=>(e,n)=>i(e,n,h);m.SheetsThreadCommentModel=class extends o.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 o.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:d}=r,c=t.id,{matrix:_,locationMap:u}=this._ensure(e,n);!s&&a>=0&&d>=0&&(this._addCommentToMatrix(_,a,d,c),u.set(c,{row:a,column:d})),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)!==o.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:d}=e.payload;if(a){const c=l.singleReferenceToGrid(d.ref),{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,d.id),this._commentUpdate$.next({...e,...c})}break}case"update":{const{commentId:a}=e.payload,d=this._threadCommentModel.getComment(n,t,a);if(!d)return;const c=l.singleReferenceToGrid(d.ref);this._commentUpdate$.next({...e,...c});break}case"updateRef":{const a=l.singleReferenceToGrid(e.payload.ref),{commentId:d}=e.payload,c=s.get(d);if(!c)return;const{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,d),s.delete(d),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,d),s.set(d,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:d,payload:c}=e,{locationMap:_}=this._ensure(a,d),u=_.get(c.commentId);u&&this._commentUpdate$.next({...e,...u});break}}}))}getByLocation(e,n,t,r){var d;return(d=this.getAllByLocation(e,n,t,r).filter(c=>!c.resolved)[0])==null?void 0:d.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(d=>this.getComment(e,n,d)).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)}},m.SheetsThreadCommentModel=U([M(0,o.Inject(p.ThreadCommentModel)),M(1,o.IUniverInstanceService)],m.SheetsThreadCommentModel);var I=Object.defineProperty,b=Object.getOwnPropertyDescriptor,j=(h,i,e,n)=>{for(var t=n>1?void 0:n?b(i,e):i,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=(n?s(i,e,t):s(t))||t);return n&&t&&I(i,e,t),t},C=(h,i)=>(e,n)=>i(e,n,h);m.SheetsThreadCommentRefRangeController=class extends o.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,d={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(d),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 d=g.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),c=Array.isArray(d)?d[0]:d;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,d)=>{const{redos:c}=this._handleRangeChange(e,n,t,d,!0);o.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,d=l.singleReferenceToGrid(a.ref),c={...a,...d};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(o.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}},m.SheetsThreadCommentRefRangeController=j([C(0,o.Inject(g.RefRangeService)),C(1,o.Inject(m.SheetsThreadCommentModel)),C(2,o.Inject(p.ThreadCommentModel)),C(3,o.Inject(g.SheetsSelectionsService)),C(4,o.ICommandService)],m.SheetsThreadCommentRefRangeController);const P="SHEET_THREAD_COMMENT_BASE_PLUGIN";var v=Object.defineProperty,$=Object.getOwnPropertyDescriptor,E=(h,i,e)=>i in h?v(h,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[i]=e,D=(h,i,e,n)=>{for(var t=n>1?void 0:n?$(i,e):i,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=(n?s(i,e,t):s(t))||t);return n&&t&&v(i,e,t),t},R=(h,i)=>(e,n)=>i(e,n,h),w=(h,i,e)=>E(h,typeof i!="symbol"?i+"":i,e);m.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(i,e,n){super(),this._injector=e,this._commandService=n}onStarting(){[[m.SheetsThreadCommentModel],[m.SheetsThreadCommentRefRangeController]].forEach(i=>{this._injector.add(i)}),this._injector.get(m.SheetsThreadCommentRefRangeController)}},w(m.UniverSheetsThreadCommentPlugin,"pluginName",P),w(m.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),m.UniverSheetsThreadCommentPlugin=D([o.DependentOn(p.UniverThreadCommentPlugin),R(1,o.Inject(o.Injector)),R(2,o.Inject(o.ICommandService))],m.UniverSheetsThreadCommentPlugin),Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(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"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsThreadComment={},global.UniverCore,global.UniverEngineFormula,global.UniverSheets,global.UniverThreadComment,global.rxjs))})(this,function(exports2,core,engineFormula,sheets,threadComment,rxjs){"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;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");exports2.SheetsThreadCommentModel=(_a=class extends core.Disposable{constructor(_threadCommentModel,_univerInstanceService){super();__publicField(this,"_matrixMap",new Map);__publicField(this,"_locationMap",new Map);__publicField(this,"_commentUpdate$",new rxjs.Subject);__publicField(this,"commentUpdate$",this._commentUpdate$.asObservable());this._threadCommentModel=_threadCommentModel,this._univerInstanceService=_univerInstanceService,this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(unitId,subUnitId){let unitMap=this._matrixMap.get(unitId);unitMap||(unitMap=new Map,this._matrixMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new core.ObjectMatrix,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_ensureCommentLocationMap(unitId,subUnitId){let unitMap=this._locationMap.get(unitId);unitMap||(unitMap=new Map,this._locationMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new Map,unitMap.set(subUnitId,subUnitMap)),subUnitMap}_addCommentToMatrix(matrix,row,column,commentId){var _a2;const current=(_a2=matrix.getValue(row,column))!=null?_a2:new Set;current.add(commentId),matrix.setValue(row,column,current)}_deleteCommentFromMatrix(matrix,row,column,commentId){if(row>=0&&column>=0){const current=matrix.getValue(row,column);current&¤t.has(commentId)&&(current.delete(commentId),current.size===0&&matrix.realDeleteValue(row,column))}}_ensure(unitId,subUnitId){const matrix=this._ensureCommentMatrix(unitId,subUnitId),locationMap=this._ensureCommentLocationMap(unitId,subUnitId);return{matrix,locationMap}}_initData(){const datas=this._threadCommentModel.getAll();for(const data of datas)for(const thread of data.threads){const{unitId,subUnitId,root}=thread;this._addComment(unitId,subUnitId,root)}}_addComment(unitId,subUnitId,comment){const location=engineFormula.singleReferenceToGrid(comment.ref),parentId=comment.parentId,{row,column}=location,commentId=comment.id,{matrix,locationMap}=this._ensure(unitId,subUnitId);!parentId&&row>=0&&column>=0&&(this._addCommentToMatrix(matrix,row,column,commentId),locationMap.set(commentId,{row,column})),parentId||this._commentUpdate$.next({unitId,subUnitId,payload:comment,type:"add",isRoot:!parentId,...location})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(update=>{const{unitId,subUnitId}=update;try{if(this._univerInstanceService.getUnitType(unitId)!==core.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix,locationMap}=this._ensure(unitId,subUnitId);switch(update.type){case"add":{this._addComment(update.unitId,update.subUnitId,update.payload);break}case"delete":{const{isRoot,comment}=update.payload;if(isRoot){const location=engineFormula.singleReferenceToGrid(comment.ref),{row,column}=location;this._deleteCommentFromMatrix(matrix,row,column,comment.id),this._commentUpdate$.next({...update,...location})}break}case"update":{const{commentId}=update.payload,comment=this._threadCommentModel.getComment(unitId,subUnitId,commentId);if(!comment)return;const location=engineFormula.singleReferenceToGrid(comment.ref);this._commentUpdate$.next({...update,...location});break}case"updateRef":{const location=engineFormula.singleReferenceToGrid(update.payload.ref),{commentId}=update.payload,currentLoc=locationMap.get(commentId);if(!currentLoc)return;const{row,column}=currentLoc;this._deleteCommentFromMatrix(matrix,row,column,commentId),locationMap.delete(commentId),location.row>=0&&location.column>=0&&(this._addCommentToMatrix(matrix,location.row,location.column,commentId),locationMap.set(commentId,{row:location.row,column:location.column})),this._commentUpdate$.next({...update,...location});break}case"resolve":{const{unitId:unitId2,subUnitId:subUnitId2,payload}=update,{locationMap:locationMap2}=this._ensure(unitId2,subUnitId2),location=locationMap2.get(payload.commentId);location&&this._commentUpdate$.next({...update,...location});break}}}))}getByLocation(unitId,subUnitId,row,column){var _a2;return(_a2=this.getAllByLocation(unitId,subUnitId,row,column).filter(comment=>!comment.resolved)[0])==null?void 0:_a2.id}getAllByLocation(unitId,subUnitId,row,column){const current=this._ensureCommentMatrix(unitId,subUnitId).getValue(row,column);return current?Array.from(current).map(id=>this.getComment(unitId,subUnitId,id)).filter(Boolean):[]}getComment(unitId,subUnitId,commentId){return this._threadCommentModel.getComment(unitId,subUnitId,commentId)}getCommentWithChildren(unitId,subUnitId,row,column){const commentId=this.getByLocation(unitId,subUnitId,row,column);if(!commentId)return;const comment=this.getComment(unitId,subUnitId,commentId);if(comment)return this._threadCommentModel.getThread(unitId,subUnitId,comment.threadId)}showCommentMarker(unitId,subUnitId,row,column){const commentId=this.getByLocation(unitId,subUnitId,row,column);if(!commentId)return!1;const comment=this.getComment(unitId,subUnitId,commentId);return!!(comment&&!comment.resolved)}getSubUnitAll(unitId,subUnitId){return this._threadCommentModel.getUnit(unitId).filter(i=>i.subUnitId===subUnitId).map(i=>i.root)}},__name(_a,"SheetsThreadCommentModel"),_a),exports2.SheetsThreadCommentModel=__decorateClass$2([__decorateParam$2(0,core.Inject(threadComment.ThreadCommentModel)),__decorateParam$2(1,core.IUniverInstanceService)],exports2.SheetsThreadCommentModel);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");exports2.SheetsThreadCommentRefRangeController=(_b=class extends core.Disposable{constructor(_refRangeService,_sheetsThreadCommentModel,_threadCommentModel,_selectionManagerService,_commandService){super();__publicField(this,"_disposableMap",new Map);__publicField(this,"_watcherMap",new Map);__publicField(this,"_handleRangeChange",__name((unitId,subUnitId,comment,resultRange,silent)=>{const commentId=comment.id,oldRange={startColumn:comment.column,endColumn:comment.column,startRow:comment.row,endRow:comment.row};return resultRange?{redos:[{id:threadComment.UpdateCommentRefMutation.id,params:{unitId,subUnitId,payload:{ref:engineFormula.serializeRange(resultRange),commentId},silent}}],undos:[{id:threadComment.UpdateCommentRefMutation.id,params:{unitId,subUnitId,payload:{ref:engineFormula.serializeRange(oldRange),commentId},silent}}]}:{redos:[{id:threadComment.DeleteCommentMutation.id,params:{unitId,subUnitId,commentId}}],undos:[{id:threadComment.AddCommentMutation.id,params:{unitId,subUnitId,comment,sync:!0}}]}},"_handleRangeChange"));this._refRangeService=_refRangeService,this._sheetsThreadCommentModel=_sheetsThreadCommentModel,this._threadCommentModel=_threadCommentModel,this._selectionManagerService=_selectionManagerService,this._commandService=_commandService,this._initData(),this._initRefRange()}_getIdWithUnitId(unitId,subUnitId,id){return`${unitId}-${subUnitId}-${id}`}_register(unitId,subUnitId,comment){const commentId=comment.id,oldRange={startColumn:comment.column,endColumn:comment.column,startRow:comment.row,endRow:comment.row};this._disposableMap.set(this._getIdWithUnitId(unitId,subUnitId,commentId),this._refRangeService.registerRefRange(oldRange,commandInfo=>{const resultRanges=sheets.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(oldRange,commandInfo,{selectionManagerService:this._selectionManagerService}),resultRange=Array.isArray(resultRanges)?resultRanges[0]:resultRanges;return resultRange&&resultRange.startColumn===oldRange.startColumn&&resultRange.startRow===oldRange.startRow?{undos:[],redos:[]}:this._handleRangeChange(unitId,subUnitId,comment,resultRange,!1)},unitId,subUnitId))}_watch(unitId,subUnitId,comment){const commentId=comment.id,oldRange={startColumn:comment.column,endColumn:comment.column,startRow:comment.row,endRow:comment.row};this._watcherMap.set(this._getIdWithUnitId(unitId,subUnitId,commentId),this._refRangeService.watchRange(unitId,subUnitId,oldRange,(before,after)=>{const{redos}=this._handleRangeChange(unitId,subUnitId,comment,after,!0);core.sequenceExecuteAsync(redos,this._commandService,{onlyLocal:!0})},!0))}_unwatch(unitId,subUnitId,commentId){var _a2;const id=this._getIdWithUnitId(unitId,subUnitId,commentId);(_a2=this._watcherMap.get(id))==null||_a2.dispose(),this._watcherMap.delete(id)}_unregister(unitId,subUnitId,commentId){var _a2;const id=this._getIdWithUnitId(unitId,subUnitId,commentId);(_a2=this._disposableMap.get(id))==null||_a2.dispose(),this._disposableMap.delete(id)}_initData(){const datas=this._threadCommentModel.getAll();for(const data of datas)for(const thread of data.threads){const{unitId,subUnitId,root}=thread,pos=engineFormula.singleReferenceToGrid(root.ref),sheetComment={...root,...pos};this._register(unitId,subUnitId,sheetComment),this._watch(unitId,subUnitId,sheetComment)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(option=>{const{unitId,subUnitId}=option;switch(option.type){case"add":{if(option.payload.parentId)return;const comment={...option.payload,row:option.row,column:option.column};this._register(option.unitId,option.subUnitId,comment),this._watch(option.unitId,option.subUnitId,comment);break}case"delete":{this._unregister(unitId,subUnitId,option.payload.commentId),this._unwatch(unitId,subUnitId,option.payload.commentId);break}case"updateRef":{const comment=this._sheetsThreadCommentModel.getComment(unitId,subUnitId,option.payload.commentId);if(!comment)return;this._unregister(unitId,subUnitId,option.payload.commentId);const sheetComment={...comment,row:option.row,column:option.column};option.silent||(this._unwatch(unitId,subUnitId,option.payload.commentId),this._watch(unitId,subUnitId,sheetComment)),this._register(option.unitId,option.subUnitId,sheetComment);break}}})),this.disposeWithMe(core.toDisposable(()=>{this._disposableMap.forEach(item=>{item.dispose()}),this._disposableMap.clear()}))}},__name(_b,"SheetsThreadCommentRefRangeController"),_b),exports2.SheetsThreadCommentRefRangeController=__decorateClass$1([__decorateParam$1(0,core.Inject(sheets.RefRangeService)),__decorateParam$1(1,core.Inject(exports2.SheetsThreadCommentModel)),__decorateParam$1(2,core.Inject(threadComment.ThreadCommentModel)),__decorateParam$1(3,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$1(4,core.ICommandService)],exports2.SheetsThreadCommentRefRangeController);const SHEET_THREAD_COMMENT_BASE="SHEET_THREAD_COMMENT_BASE_PLUGIN";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=(_c=class extends core.Plugin{constructor(config,_injector,_commandService){super(),this._injector=_injector,this._commandService=_commandService}onStarting(){[[exports2.SheetsThreadCommentModel],[exports2.SheetsThreadCommentRefRangeController]].forEach(dep=>{this._injector.add(dep)}),this._injector.get(exports2.SheetsThreadCommentRefRangeController)}},__name(_c,"UniverSheetsThreadCommentPlugin"),_c),__publicField2(exports2.UniverSheetsThreadCommentPlugin,"pluginName",SHEET_THREAD_COMMENT_BASE),__publicField2(exports2.UniverSheetsThreadCommentPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsThreadCommentPlugin=__decorateClass([core.DependentOn(threadComment.UniverThreadCommentPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,core.Inject(core.ICommandService))],exports2.UniverSheetsThreadCommentPlugin),Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5-experimental.20250122-3362a4a",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer sheets thread comment base plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -51,17 +51,17 @@
|
|
|
51
51
|
"rxjs": ">=7.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@univerjs/core": "0.5.
|
|
55
|
-
"@univerjs/
|
|
56
|
-
"@univerjs/thread-comment": "0.5.
|
|
57
|
-
"@univerjs/
|
|
54
|
+
"@univerjs/core": "0.5.5-experimental.20250122-3362a4a",
|
|
55
|
+
"@univerjs/engine-formula": "0.5.5-experimental.20250122-3362a4a",
|
|
56
|
+
"@univerjs/thread-comment": "0.5.5-experimental.20250122-3362a4a",
|
|
57
|
+
"@univerjs/sheets": "0.5.5-experimental.20250122-3362a4a"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"rxjs": "^7.8.1",
|
|
61
61
|
"typescript": "^5.7.2",
|
|
62
62
|
"vite": "^6.0.7",
|
|
63
63
|
"vitest": "^2.1.8",
|
|
64
|
-
"@univerjs-infra/shared": "0.5.
|
|
64
|
+
"@univerjs-infra/shared": "0.5.5"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|