@univerjs/sheets-thread-comment 0.6.0-nightly.202502151605 → 0.6.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.
- package/LICENSE +176 -0
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +34 -34
- package/lib/es/index.js +150 -150
- package/lib/types/facade/f-univer.d.ts +4 -4
- package/lib/types/facade/f-workbook.d.ts +4 -4
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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
|
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var E=(I,e,o)=>e in I?T(I,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):I[e]=o;var R=(I,e,o)=>E(I,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@univerjs/core"),b=require("@univerjs/sheets-thread-comment"),f=require("@univerjs/sheets/facade"),a=require("@univerjs/thread-comment"),x=require("@univerjs/engine-formula"),y=require("rxjs"),S=require("@univerjs/core/facade");var A=Object.defineProperty,B=Object.getOwnPropertyDescriptor,D=(I,e,o,t)=>{for(var n=t>1?void 0:t?B(e,o):e,r=I.length-1,s;r>=0;r--)(s=I[r])&&(n=(t?s(e,o,n):s(n))||n);return t&&n&&A(e,o,n),n},p=(I,e)=>(o,t)=>e(o,t,I);class U{constructor(e){R(this,"_comment",{id:m.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:m.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});e&&(this._comment=e)}static create(e){return new U(e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return m.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return k.create(m.Tools.deepClone(this._comment))}}class k extends U{static create(e){return new k(e)}setContent(e){return e instanceof m.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=a.getDT(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}}exports.FThreadComment=class{constructor(e,o,t,n,r,s,c){this._thread=e,this._parent=o,this._injector=t,this._commandService=n,this._univerInstanceService=r,this._threadCommentModel=s,this._userManagerService=c}_getRef(){var t;const e=((t=this._parent)==null?void 0:t.ref)||this._thread.ref;return x.deserializeRangeWithSheet(e).range}getIsRoot(){return!this._parent}getCommentData(){const{children:e,...o}=this._thread;return o}getReplies(){var t;const e=this._getRef(),o=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,e.startRow,e.startColumn);return(t=o==null?void 0:o.children)==null?void 0:t.map(n=>this._injector.createInstance(exports.FThreadComment,n))}getRange(){const e=this._univerInstanceService.getUnit(this._thread.unitId,m.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const o=e.getSheetBySheetId(this._thread.subUnitId);if(!o)return null;const t=this._getRef();return this._injector.createInstance(f.FRange,e,o,t)}getContent(){return this._thread.text}getRichText(){const e=this._thread.text;return m.RichTextValue.create({body:e,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?a.DeleteCommentTreeCommand.id:a.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 o=e instanceof m.RichTextValue?e.getData().body:e,t=a.getDT();return await this._commandService.executeCommand(a.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:o,updated:!0,updateT:t}})}resolve(e){return this.resolveAsync(e)}resolveAsync(e){return this._commandService.executeCommand(a.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 t;const o=e.build();return this._commandService.executeCommand(a.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:m.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:(t=this._parent)==null?void 0:t.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:o.text,attachments:o.attachments,dT:o.dT||a.getDT(),personId:o.personId||this._userManagerService.getCurrentUser().userID}})}};exports.FThreadComment=D([p(2,m.Inject(m.Injector)),p(3,m.ICommandService),p(4,m.IUniverInstanceService),p(5,m.Inject(b.SheetsThreadCommentModel)),p(6,m.Inject(m.UserManagerService))],exports.FThreadComment);class j extends f.FRange{getComment(){const o=this._injector.get(b.SheetsThreadCommentModel),t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=o.getByLocation(t,n,this._range.startRow,this._range.startColumn);if(!r)return null;const s=o.getComment(t,n,r);return s?this._injector.createInstance(exports.FThreadComment,s):null}getComments(){const o=this._injector.get(b.SheetsThreadCommentModel),t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=[];return m.Range.foreach(this._range,(s,c)=>{const u=o.getByLocation(t,n,s,c);if(u){const i=o.getComment(t,n,u);i&&r.push(this._injector.createInstance(exports.FThreadComment,i))}}),r}addComment(e){var h;const o=this._injector,t=(h=this.getComment())==null?void 0:h.getCommentData(),n=o.get(m.ICommandService),r=o.get(m.UserManagerService),s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),u=`${m.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,i=r.getCurrentUser(),d=e instanceof k?e.build():{text:e};return n.executeCommand(a.AddCommentCommand.id,{unitId:s,subUnitId:c,comment:{text:d.text,dT:d.dT||a.getDT(),attachments:[],id:d.id||m.generateRandomId(),ref:u,personId:d.personId||i.userID,parentId:t==null?void 0:t.id,unitId:s,subUnitId:c,threadId:(t==null?void 0:t.threadId)||m.generateRandomId()}})}clearComment(){var s;const e=this._injector,o=(s=this.getComment())==null?void 0:s.getCommentData(),t=e.get(m.ICommandService),n=this._workbook.getUnitId(),r=this._worksheet.getSheetId();return o?t.executeCommand(a.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,threadId:o.threadId,commentId:o.id}):Promise.resolve(!0)}clearComments(){const o=this.getComments().map(t=>t.deleteAsync());return Promise.all(o).then(()=>!0)}addCommentAsync(e){return this.addComment(e)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}}f.FRange.extend(j);class F extends f.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(a.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(exports.FThreadComment,e.root))}clearComments(){const o=this.getComments().map(t=>t.deleteAsync());return Promise.all(o).then(()=>!0)}onThreadCommentChange(e){return m.toDisposable(this._threadCommentModel.commentUpdate$.pipe(y.filter(o=>o.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddThreadComment(e){return m.toDisposable(this._commandService.beforeCommandExecuted((o,t)=>{const n=o.params;if(o.id===a.AddCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(e(n,t)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(e){return m.toDisposable(this._commandService.beforeCommandExecuted((o,t)=>{const n=o.params;if(o.id===a.UpdateCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(e(n,t)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(e){return m.toDisposable(this._commandService.beforeCommandExecuted((o,t)=>{const n=o.params;if(o.id===a.DeleteCommentCommand.id||o.id===a.DeleteCommentTreeCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(e(n,t)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}f.FWorkbook.extend(F);class M extends f.FWorksheet{getComments(){return this._injector.get(b.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(t=>this._injector.createInstance(exports.FThreadComment,t))}clearComments(){const o=this.getComments().map(t=>t.deleteAsync());return Promise.all(o).then(()=>!0)}onCommented(e){return this._injector.get(m.ICommandService).onCommandExecuted(t=>{if(t.id===a.AddCommentCommand.id){const n=t.params;e(n)}})}getCommentById(e){const t=this._injector.get(b.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(exports.FThreadComment,t)}}f.FWorksheet.extend(M);const v={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDeleted:"BeforeCommentDeleted",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class P extends S.FEventName{get CommentAdded(){return v.CommentAdded}get BeforeCommentAdd(){return v.BeforeCommentAdd}get CommentUpdated(){return v.CommentUpdated}get BeforeCommentUpdate(){return v.BeforeCommentUpdate}get CommentDeleted(){return v.CommentDeleted}get BeforeCommentDeleted(){return v.BeforeCommentDeleted}get CommentResolved(){return v.CommentResolved}get BeforeCommentResolve(){return v.BeforeCommentResolve}}S.FEventName.extend(P);class W extends S.FUniver{_initialize(e){const o=e.get(m.ICommandService);this.registerEventHandler(this.Event.CommentAdded,()=>o.onCommandExecuted(t=>{var d,h,C,g,l;if(t.id!==a.AddCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{comment:u}=c,i=s.getRange(u.ref).getComment();i&&this.fireEvent(this.Event.CommentAdded,{workbook:r,worksheet:s,row:(C=(h=i.getRange())==null?void 0:h.getRow())!=null?C:0,col:(l=(g=i.getRange())==null?void 0:g.getColumn())!=null?l:0,comment:i})})),this.registerEventHandler(this.Event.CommentUpdated,()=>o.onCommandExecuted(t=>{var d,h,C,g,l;if(t.id!==a.UpdateCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u}=c.payload,i=s.getCommentById(u);i&&this.fireEvent(this.Event.CommentUpdated,{workbook:r,worksheet:s,row:(C=(h=i.getRange())==null?void 0:h.getRow())!=null?C:0,col:(l=(g=i.getRange())==null?void 0:g.getColumn())!=null?l:0,comment:i})})),this.registerEventHandler(this.Event.CommentDeleted,()=>o.onCommandExecuted(t=>{var i;if(t.id!==a.DeleteCommentCommand.id&&t.id!==a.DeleteCommentTreeCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(i=this.getActiveWorkbook)==null?void 0:i.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u}=c;this.fireEvent(this.Event.CommentDeleted,{workbook:r,worksheet:s,commentId:u})})),this.registerEventHandler(this.Event.CommentResolved,()=>o.onCommandExecuted(t=>{var h,C,g;if(t.id!==a.ResolveCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u,resolved:i}=c,d=s.getComments().find(l=>l.getCommentData().id===u);d&&this.fireEvent(this.Event.CommentResolved,{workbook:r,worksheet:s,row:(C=d.getRange().getRow())!=null?C:0,col:(g=d.getRange().getColumn())!=null?g:0,comment:d,resolved:i})})),this.registerEventHandler(this.Event.BeforeCommentAdd,()=>o.beforeCommandExecuted(t=>{var h,C,g;if(t.id!==a.AddCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{comment:u}=c,i=s.getActiveRange();if(!i)return;const d={workbook:r,worksheet:s,row:(C=i.getRow())!=null?C:0,col:(g=i.getColumn())!=null?g:0,comment:U.create(u)};if(this.fireEvent(this.Event.BeforeCommentAdd,d),d.cancel)throw new m.CanceledError})),this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>o.beforeCommandExecuted(t=>{var h,C,g,l,_;if(t.id!==a.UpdateCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u,text:i}=c.payload,d=s.getCommentById(u);if(d){const w={workbook:r,worksheet:s,row:(g=(C=d.getRange())==null?void 0:C.getRow())!=null?g:0,col:(_=(l=d.getRange())==null?void 0:l.getColumn())!=null?_:0,comment:d,newContent:m.RichTextValue.createByBody(i)};if(this.fireEvent(this.Event.BeforeCommentUpdate,w),w.cancel)throw new m.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentDeleted,()=>o.beforeCommandExecuted(t=>{var d,h,C,g,l;if(t.id!==a.DeleteCommentCommand.id&&t.id!==a.DeleteCommentTreeCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u}=c,i=s.getCommentById(u);if(i){const _={workbook:r,worksheet:s,row:(C=(h=i.getRange())==null?void 0:h.getRow())!=null?C:0,col:(l=(g=i.getRange())==null?void 0:g.getColumn())!=null?l:0,comment:i};if(this.fireEvent(this.Event.BeforeCommentDeleted,_),_.cancel)throw new m.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentResolve,()=>o.beforeCommandExecuted(t=>{var h,C,g;if(t.id!==a.ResolveCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u,resolved:i}=c,d=s.getComments().find(l=>l.getCommentData().id===u);if(d){const l={workbook:r,worksheet:s,row:(C=d.getRange().getRow())!=null?C:0,col:(g=d.getRange().getColumn())!=null?g:0,comment:d,resolved:i};if(this.fireEvent(this.Event.BeforeCommentResolve,l),l.cancel)throw new m.CanceledError}}))}newTheadComment(e){return new k(e)}}S.FUniver.extend(W);
|
|
1
|
+
"use strict";var T=Object.defineProperty;var E=(I,e,o)=>e in I?T(I,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):I[e]=o;var R=(I,e,o)=>E(I,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@univerjs/core"),b=require("@univerjs/sheets-thread-comment"),f=require("@univerjs/sheets/facade"),a=require("@univerjs/thread-comment"),y=require("@univerjs/engine-formula"),x=require("rxjs"),S=require("@univerjs/core/facade");var A=Object.getOwnPropertyDescriptor,B=(I,e,o,t)=>{for(var n=t>1?void 0:t?A(e,o):e,r=I.length-1,s;r>=0;r--)(s=I[r])&&(n=s(n)||n);return n},p=(I,e)=>(o,t)=>e(o,t,I);class U{constructor(e){R(this,"_comment",{id:m.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:m.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});e&&(this._comment=e)}static create(e){return new U(e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return m.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return k.create(m.Tools.deepClone(this._comment))}}class k extends U{static create(e){return new k(e)}setContent(e){return e instanceof m.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=a.getDT(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}}exports.FThreadComment=class{constructor(e,o,t,n,r,s,c){this._thread=e,this._parent=o,this._injector=t,this._commandService=n,this._univerInstanceService=r,this._threadCommentModel=s,this._userManagerService=c}_getRef(){var t;const e=((t=this._parent)==null?void 0:t.ref)||this._thread.ref;return y.deserializeRangeWithSheet(e).range}getIsRoot(){return!this._parent}getCommentData(){const{children:e,...o}=this._thread;return o}getReplies(){var t;const e=this._getRef(),o=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,e.startRow,e.startColumn);return(t=o==null?void 0:o.children)==null?void 0:t.map(n=>this._injector.createInstance(exports.FThreadComment,n))}getRange(){const e=this._univerInstanceService.getUnit(this._thread.unitId,m.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const o=e.getSheetBySheetId(this._thread.subUnitId);if(!o)return null;const t=this._getRef();return this._injector.createInstance(f.FRange,e,o,t)}getContent(){return this._thread.text}getRichText(){const e=this._thread.text;return m.RichTextValue.create({body:e,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?a.DeleteCommentTreeCommand.id:a.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 o=e instanceof m.RichTextValue?e.getData().body:e,t=a.getDT();return await this._commandService.executeCommand(a.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:o,updated:!0,updateT:t}})}resolve(e){return this.resolveAsync(e)}resolveAsync(e){return this._commandService.executeCommand(a.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 t;const o=e.build();return this._commandService.executeCommand(a.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:m.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:(t=this._parent)==null?void 0:t.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:o.text,attachments:o.attachments,dT:o.dT||a.getDT(),personId:o.personId||this._userManagerService.getCurrentUser().userID}})}};exports.FThreadComment=B([p(2,m.Inject(m.Injector)),p(3,m.ICommandService),p(4,m.IUniverInstanceService),p(5,m.Inject(b.SheetsThreadCommentModel)),p(6,m.Inject(m.UserManagerService))],exports.FThreadComment);class D extends f.FRange{getComment(){const o=this._injector.get(b.SheetsThreadCommentModel),t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=o.getByLocation(t,n,this._range.startRow,this._range.startColumn);if(!r)return null;const s=o.getComment(t,n,r);return s?this._injector.createInstance(exports.FThreadComment,s):null}getComments(){const o=this._injector.get(b.SheetsThreadCommentModel),t=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),r=[];return m.Range.foreach(this._range,(s,c)=>{const u=o.getByLocation(t,n,s,c);if(u){const i=o.getComment(t,n,u);i&&r.push(this._injector.createInstance(exports.FThreadComment,i))}}),r}addComment(e){var h;const o=this._injector,t=(h=this.getComment())==null?void 0:h.getCommentData(),n=o.get(m.ICommandService),r=o.get(m.UserManagerService),s=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),u=`${m.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,i=r.getCurrentUser(),d=e instanceof k?e.build():{text:e};return n.executeCommand(a.AddCommentCommand.id,{unitId:s,subUnitId:c,comment:{text:d.text,dT:d.dT||a.getDT(),attachments:[],id:d.id||m.generateRandomId(),ref:u,personId:d.personId||i.userID,parentId:t==null?void 0:t.id,unitId:s,subUnitId:c,threadId:(t==null?void 0:t.threadId)||m.generateRandomId()}})}clearComment(){var s;const e=this._injector,o=(s=this.getComment())==null?void 0:s.getCommentData(),t=e.get(m.ICommandService),n=this._workbook.getUnitId(),r=this._worksheet.getSheetId();return o?t.executeCommand(a.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,threadId:o.threadId,commentId:o.id}):Promise.resolve(!0)}clearComments(){const o=this.getComments().map(t=>t.deleteAsync());return Promise.all(o).then(()=>!0)}addCommentAsync(e){return this.addComment(e)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}}f.FRange.extend(D);class j extends f.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(a.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(exports.FThreadComment,e.root))}clearComments(){const o=this.getComments().map(t=>t.deleteAsync());return Promise.all(o).then(()=>!0)}onThreadCommentChange(e){return m.toDisposable(this._threadCommentModel.commentUpdate$.pipe(x.filter(o=>o.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddThreadComment(e){return m.toDisposable(this._commandService.beforeCommandExecuted((o,t)=>{const n=o.params;if(o.id===a.AddCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(e(n,t)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(e){return m.toDisposable(this._commandService.beforeCommandExecuted((o,t)=>{const n=o.params;if(o.id===a.UpdateCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(e(n,t)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(e){return m.toDisposable(this._commandService.beforeCommandExecuted((o,t)=>{const n=o.params;if(o.id===a.DeleteCommentCommand.id||o.id===a.DeleteCommentTreeCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(e(n,t)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}f.FWorkbook.extend(j);class F extends f.FWorksheet{getComments(){return this._injector.get(b.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(t=>this._injector.createInstance(exports.FThreadComment,t))}clearComments(){const o=this.getComments().map(t=>t.deleteAsync());return Promise.all(o).then(()=>!0)}onCommented(e){return this._injector.get(m.ICommandService).onCommandExecuted(t=>{if(t.id===a.AddCommentCommand.id){const n=t.params;e(n)}})}getCommentById(e){const t=this._injector.get(b.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(exports.FThreadComment,t)}}f.FWorksheet.extend(F);const v={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDeleted:"BeforeCommentDeleted",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class M extends S.FEventName{get CommentAdded(){return v.CommentAdded}get BeforeCommentAdd(){return v.BeforeCommentAdd}get CommentUpdated(){return v.CommentUpdated}get BeforeCommentUpdate(){return v.BeforeCommentUpdate}get CommentDeleted(){return v.CommentDeleted}get BeforeCommentDeleted(){return v.BeforeCommentDeleted}get CommentResolved(){return v.CommentResolved}get BeforeCommentResolve(){return v.BeforeCommentResolve}}S.FEventName.extend(M);class P extends S.FUniver{_initialize(e){const o=e.get(m.ICommandService);this.registerEventHandler(this.Event.CommentAdded,()=>o.onCommandExecuted(t=>{var d,h,C,g,l;if(t.id!==a.AddCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{comment:u}=c,i=s.getRange(u.ref).getComment();i&&this.fireEvent(this.Event.CommentAdded,{workbook:r,worksheet:s,row:(C=(h=i.getRange())==null?void 0:h.getRow())!=null?C:0,col:(l=(g=i.getRange())==null?void 0:g.getColumn())!=null?l:0,comment:i})})),this.registerEventHandler(this.Event.CommentUpdated,()=>o.onCommandExecuted(t=>{var d,h,C,g,l;if(t.id!==a.UpdateCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u}=c.payload,i=s.getCommentById(u);i&&this.fireEvent(this.Event.CommentUpdated,{workbook:r,worksheet:s,row:(C=(h=i.getRange())==null?void 0:h.getRow())!=null?C:0,col:(l=(g=i.getRange())==null?void 0:g.getColumn())!=null?l:0,comment:i})})),this.registerEventHandler(this.Event.CommentDeleted,()=>o.onCommandExecuted(t=>{var i;if(t.id!==a.DeleteCommentCommand.id&&t.id!==a.DeleteCommentTreeCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(i=this.getActiveWorkbook)==null?void 0:i.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u}=c;this.fireEvent(this.Event.CommentDeleted,{workbook:r,worksheet:s,commentId:u})})),this.registerEventHandler(this.Event.CommentResolved,()=>o.onCommandExecuted(t=>{var h,C,g;if(t.id!==a.ResolveCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u,resolved:i}=c,d=s.getComments().find(l=>l.getCommentData().id===u);d&&this.fireEvent(this.Event.CommentResolved,{workbook:r,worksheet:s,row:(C=d.getRange().getRow())!=null?C:0,col:(g=d.getRange().getColumn())!=null?g:0,comment:d,resolved:i})})),this.registerEventHandler(this.Event.BeforeCommentAdd,()=>o.beforeCommandExecuted(t=>{var h,C,g;if(t.id!==a.AddCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{comment:u}=c,i=s.getActiveRange();if(!i)return;const d={workbook:r,worksheet:s,row:(C=i.getRow())!=null?C:0,col:(g=i.getColumn())!=null?g:0,comment:U.create(u)};if(this.fireEvent(this.Event.BeforeCommentAdd,d),d.cancel)throw new m.CanceledError})),this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>o.beforeCommandExecuted(t=>{var h,C,g,l,_;if(t.id!==a.UpdateCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u,text:i}=c.payload,d=s.getCommentById(u);if(d){const w={workbook:r,worksheet:s,row:(g=(C=d.getRange())==null?void 0:C.getRow())!=null?g:0,col:(_=(l=d.getRange())==null?void 0:l.getColumn())!=null?_:0,comment:d,newContent:m.RichTextValue.createByBody(i)};if(this.fireEvent(this.Event.BeforeCommentUpdate,w),w.cancel)throw new m.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentDeleted,()=>o.beforeCommandExecuted(t=>{var d,h,C,g,l;if(t.id!==a.DeleteCommentCommand.id&&t.id!==a.DeleteCommentTreeCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u}=c,i=s.getCommentById(u);if(i){const _={workbook:r,worksheet:s,row:(C=(h=i.getRange())==null?void 0:h.getRow())!=null?C:0,col:(l=(g=i.getRange())==null?void 0:g.getColumn())!=null?l:0,comment:i};if(this.fireEvent(this.Event.BeforeCommentDeleted,_),_.cancel)throw new m.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentResolve,()=>o.beforeCommandExecuted(t=>{var h,C,g;if(t.id!==a.ResolveCommentCommand.id)return;const n=t.params;if(!n)return;const r=n.unitId?this.getUniverSheet(n.unitId):(h=this.getActiveWorkbook)==null?void 0:h.call(this);if(!r)return;const s=r.getSheetBySheetId(n.subUnitId||n.sheetId)||r.getActiveSheet();if(!s)return;const c=t.params,{commentId:u,resolved:i}=c,d=s.getComments().find(l=>l.getCommentData().id===u);if(d){const l={workbook:r,worksheet:s,row:(C=d.getRange().getRow())!=null?C:0,col:(g=d.getRange().getColumn())!=null?g:0,comment:d,resolved:i};if(this.fireEvent(this.Event.BeforeCommentResolve,l),l.cancel)throw new m.CanceledError}}))}newTheadComment(e){return new k(e)}}S.FUniver.extend(P);
|
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var v=Object.defineProperty;var w=(c,a,e)=>a in c?v(c,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[a]=e;var _=(c,a,e)=>w(c,typeof a!="symbol"?a+"":a,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),u=require("@univerjs/engine-formula"),C=require("@univerjs/sheets"),g=require("@univerjs/thread-comment"),S=require("rxjs");var T=Object.getOwnPropertyDescriptor,y=(c,a,e,n)=>{for(var t=n>1?void 0:n?T(a,e):a,r=c.length-1,o;r>=0;r--)(o=c[r])&&(t=o(t)||t);return t},f=(c,a)=>(e,n)=>a(e,n,c);exports.SheetsThreadCommentModel=class extends d.Disposable{constructor(e,n){super();_(this,"_matrixMap",new Map);_(this,"_locationMap",new Map);_(this,"_commentUpdate$",new S.Subject);_(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 d.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 s;const o=(s=e.getValue(n,t))!=null?s:new Set;o.add(r),e.setValue(n,t,o)}_deleteCommentFromMatrix(e,n,t,r){if(n>=0&&t>=0){const o=e.getValue(n,t);o&&o.has(r)&&(o.delete(r),o.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:o,root:s}=t;this._addComment(r,o,s)}}_addComment(e,n,t){const r=u.singleReferenceToGrid(t.ref),o=t.parentId,{row:s,column:i}=r,m=t.id,{matrix:h,locationMap:l}=this._ensure(e,n);!o&&s>=0&&i>=0&&(this._addCommentToMatrix(h,s,i,m),l.set(m,{row:s,column:i})),o||this._commentUpdate$.next({unitId:e,subUnitId:n,payload:t,type:"add",isRoot:!o,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{const{unitId:n,subUnitId:t}=e;try{if(this._univerInstanceService.getUnitType(n)!==d.UniverInstanceType.UNIVER_SHEET)return}catch{}const{matrix:r,locationMap:o}=this._ensure(n,t);switch(e.type){case"add":{this._addComment(e.unitId,e.subUnitId,e.payload);break}case"delete":{const{isRoot:s,comment:i}=e.payload;if(s){const m=u.singleReferenceToGrid(i.ref),{row:h,column:l}=m;this._deleteCommentFromMatrix(r,h,l,i.id),this._commentUpdate$.next({...e,...m})}break}case"update":{const{commentId:s}=e.payload,i=this._threadCommentModel.getComment(n,t,s);if(!i)return;const m=u.singleReferenceToGrid(i.ref);this._commentUpdate$.next({...e,...m});break}case"updateRef":{const s=u.singleReferenceToGrid(e.payload.ref),{commentId:i}=e.payload,m=o.get(i);if(!m)return;const{row:h,column:l}=m;this._deleteCommentFromMatrix(r,h,l,i),o.delete(i),s.row>=0&&s.column>=0&&(this._addCommentToMatrix(r,s.row,s.column,i),o.set(i,{row:s.row,column:s.column})),this._commentUpdate$.next({...e,...s});break}case"resolve":{const{unitId:s,subUnitId:i,payload:m}=e,{locationMap:h}=this._ensure(s,i),l=h.get(m.commentId);l&&this._commentUpdate$.next({...e,...l});break}}}))}getByLocation(e,n,t,r){var i;return(i=this.getAllByLocation(e,n,t,r).filter(m=>!m.resolved)[0])==null?void 0:i.id}getAllByLocation(e,n,t,r){const s=this._ensureCommentMatrix(e,n).getValue(t,r);return s?Array.from(s).map(i=>this.getComment(e,n,i)).filter(Boolean):[]}getComment(e,n,t){return this._threadCommentModel.getComment(e,n,t)}getCommentWithChildren(e,n,t,r){const o=this.getByLocation(e,n,t,r);if(!o)return;const s=this.getComment(e,n,o);if(s)return this._threadCommentModel.getThread(e,n,s.threadId)}showCommentMarker(e,n,t,r){const o=this.getByLocation(e,n,t,r);if(!o)return!1;const s=this.getComment(e,n,o);return!!(s&&!s.resolved)}getSubUnitAll(e,n){return this._threadCommentModel.getUnit(e).filter(t=>t.subUnitId===n).map(t=>t.root)}};exports.SheetsThreadCommentModel=y([f(0,d.Inject(g.ThreadCommentModel)),f(1,d.IUniverInstanceService)],exports.SheetsThreadCommentModel);var I=Object.getOwnPropertyDescriptor,b=(c,a,e,n)=>{for(var t=n>1?void 0:n?I(a,e):a,r=c.length-1,o;r>=0;r--)(o=c[r])&&(t=o(t)||t);return t},p=(c,a)=>(e,n)=>a(e,n,c);exports.SheetsThreadCommentRefRangeController=class extends d.Disposable{constructor(e,n,t,r,o){super();_(this,"_disposableMap",new Map);_(this,"_watcherMap",new Map);_(this,"_handleRangeChange",(e,n,t,r,o)=>{const s=t.id,i={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:u.serializeRange(r),commentId:s},silent:o}}],undos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:u.serializeRange(i),commentId:s},silent:o}}]}:{redos:[{id:g.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:s}}],undos:[{id:g.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=o,this._initData(),this._initRefRange()}_getIdWithUnitId(e,n,t){return`${e}-${n}-${t}`}_register(e,n,t){const r=t.id,o={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};this._disposableMap.set(this._getIdWithUnitId(e,n,r),this._refRangeService.registerRefRange(o,s=>{const i=C.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(o,s,{selectionManagerService:this._selectionManagerService}),m=Array.isArray(i)?i[0]:i;return m&&m.startColumn===o.startColumn&&m.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,n,t,m,!1)},e,n))}_watch(e,n,t){const r=t.id,o={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,o,(s,i)=>{const{redos:m}=this._handleRangeChange(e,n,t,i,!0);d.sequenceExecuteAsync(m,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,n,t){var o;const r=this._getIdWithUnitId(e,n,t);(o=this._watcherMap.get(r))==null||o.dispose(),this._watcherMap.delete(r)}_unregister(e,n,t){var o;const r=this._getIdWithUnitId(e,n,t);(o=this._disposableMap.get(r))==null||o.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:o,root:s}=t,i=u.singleReferenceToGrid(s.ref),m={...s,...i};this._register(r,o,m),this._watch(r,o,m)}}_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 o={...r,row:e.row,column:e.column};e.silent||(this._unwatch(n,t,e.payload.commentId),this._watch(n,t,o)),this._register(e.unitId,e.subUnitId,o);break}}})),this.disposeWithMe(d.toDisposable(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};exports.SheetsThreadCommentRefRangeController=b([p(0,d.Inject(C.RefRangeService)),p(1,d.Inject(exports.SheetsThreadCommentModel)),p(2,d.Inject(g.ThreadCommentModel)),p(3,d.Inject(C.SheetsSelectionsService)),p(4,d.ICommandService)],exports.SheetsThreadCommentRefRangeController);const U="SHEET_THREAD_COMMENT_BASE_PLUGIN";var x=Object.defineProperty,P=Object.getOwnPropertyDescriptor,E=(c,a,e)=>a in c?x(c,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[a]=e,$=(c,a,e,n)=>{for(var t=n>1?void 0:n?P(a,e):a,r=c.length-1,o;r>=0;r--)(o=c[r])&&(t=o(t)||t);return t},M=(c,a)=>(e,n)=>a(e,n,c),R=(c,a,e)=>E(c,typeof a!="symbol"?a+"":a,e);exports.UniverSheetsThreadCommentPlugin=class extends d.Plugin{constructor(a,e,n){super(),this._injector=e,this._commandService=n}onStarting(){[[exports.SheetsThreadCommentModel],[exports.SheetsThreadCommentRefRangeController]].forEach(a=>{this._injector.add(a)}),this._injector.get(exports.SheetsThreadCommentRefRangeController)}};R(exports.UniverSheetsThreadCommentPlugin,"pluginName",U);R(exports.UniverSheetsThreadCommentPlugin,"type",d.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentPlugin=$([d.DependentOn(g.UniverThreadCommentPlugin),M(1,d.Inject(d.Injector)),M(2,d.Inject(d.ICommandService))],exports.UniverSheetsThreadCommentPlugin);
|
package/lib/es/facade.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var L = Object.defineProperty;
|
|
2
2
|
var N = (i, e, r) => e in i ? L(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
|
|
3
3
|
var M = (i, e, r) => N(i, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { Inject as T, Injector as V,
|
|
5
|
-
import { SheetsThreadCommentModel as
|
|
4
|
+
import { Inject as T, Injector as V, ICommandService as _, IUniverInstanceService as q, UserManagerService as W, UniverInstanceType as G, RichTextValue as k, generateRandomId as R, RichTextBuilder as J, Tools as F, Range as K, toDisposable as S, CanceledError as E } from "@univerjs/core";
|
|
5
|
+
import { SheetsThreadCommentModel as b } from "@univerjs/sheets-thread-comment";
|
|
6
6
|
import { FRange as j, FWorkbook as H, FWorksheet as O } from "@univerjs/sheets/facade";
|
|
7
7
|
import { DeleteCommentTreeCommand as w, DeleteCommentCommand as y, getDT as B, UpdateCommentCommand as x, ResolveCommentCommand as D, AddCommentCommand as f, ThreadCommentModel as Q } from "@univerjs/thread-comment";
|
|
8
8
|
import { deserializeRangeWithSheet as X } from "@univerjs/engine-formula";
|
|
9
9
|
import { filter as Y } from "rxjs";
|
|
10
10
|
import { FEventName as z, FUniver as $ } from "@univerjs/core/facade";
|
|
11
|
-
var Z = Object.
|
|
12
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
13
|
-
(s = i[o]) && (n =
|
|
14
|
-
return
|
|
11
|
+
var Z = Object.getOwnPropertyDescriptor, ee = (i, e, r, t) => {
|
|
12
|
+
for (var n = t > 1 ? void 0 : t ? Z(e, r) : e, o = i.length - 1, s; o >= 0; o--)
|
|
13
|
+
(s = i[o]) && (n = s(n) || n);
|
|
14
|
+
return n;
|
|
15
15
|
}, p = (i, e) => (r, t) => e(r, t, i);
|
|
16
16
|
class A {
|
|
17
17
|
constructor(e) {
|
|
@@ -80,7 +80,7 @@ class A {
|
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
82
|
get content() {
|
|
83
|
-
return
|
|
83
|
+
return k.createByBody(this._comment.text);
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Get the id of the comment
|
|
@@ -140,7 +140,7 @@ class U extends A {
|
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
142
|
setContent(e) {
|
|
143
|
-
return e instanceof
|
|
143
|
+
return e instanceof k ? this._comment.text = e.getData().body : this._comment.text = e, this;
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Set the person id of the comment
|
|
@@ -277,7 +277,7 @@ let I = class {
|
|
|
277
277
|
* ```
|
|
278
278
|
*/
|
|
279
279
|
getRange() {
|
|
280
|
-
const i = this._univerInstanceService.getUnit(this._thread.unitId,
|
|
280
|
+
const i = this._univerInstanceService.getUnit(this._thread.unitId, G.UNIVER_SHEET);
|
|
281
281
|
if (!i)
|
|
282
282
|
return null;
|
|
283
283
|
const e = i.getSheetBySheetId(this._thread.subUnitId);
|
|
@@ -306,7 +306,7 @@ let I = class {
|
|
|
306
306
|
*/
|
|
307
307
|
getRichText() {
|
|
308
308
|
const i = this._thread.text;
|
|
309
|
-
return
|
|
309
|
+
return k.create({ body: i, documentStyle: {}, id: "d" });
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* Delete the comment and it's replies
|
|
@@ -356,7 +356,7 @@ let I = class {
|
|
|
356
356
|
* ```
|
|
357
357
|
*/
|
|
358
358
|
async updateAsync(i) {
|
|
359
|
-
const e = i instanceof
|
|
359
|
+
const e = i instanceof k ? i.getData().body : i, r = B();
|
|
360
360
|
return await this._commandService.executeCommand(
|
|
361
361
|
x.id,
|
|
362
362
|
{
|
|
@@ -441,23 +441,23 @@ let I = class {
|
|
|
441
441
|
);
|
|
442
442
|
}
|
|
443
443
|
};
|
|
444
|
-
I =
|
|
444
|
+
I = ee([
|
|
445
445
|
p(2, T(V)),
|
|
446
|
-
p(3,
|
|
447
|
-
p(4,
|
|
448
|
-
p(5, T(
|
|
446
|
+
p(3, _),
|
|
447
|
+
p(4, q),
|
|
448
|
+
p(5, T(b)),
|
|
449
449
|
p(6, T(W))
|
|
450
450
|
], I);
|
|
451
|
-
class
|
|
451
|
+
class te extends j {
|
|
452
452
|
getComment() {
|
|
453
|
-
const r = this._injector.get(
|
|
453
|
+
const r = this._injector.get(b), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), o = r.getByLocation(t, n, this._range.startRow, this._range.startColumn);
|
|
454
454
|
if (!o)
|
|
455
455
|
return null;
|
|
456
456
|
const s = r.getComment(t, n, o);
|
|
457
457
|
return s ? this._injector.createInstance(I, s) : null;
|
|
458
458
|
}
|
|
459
459
|
getComments() {
|
|
460
|
-
const r = this._injector.get(
|
|
460
|
+
const r = this._injector.get(b), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), o = [];
|
|
461
461
|
return K.foreach(this._range, (s, h) => {
|
|
462
462
|
const c = r.getByLocation(t, n, s, h);
|
|
463
463
|
if (c) {
|
|
@@ -468,7 +468,7 @@ class ne extends j {
|
|
|
468
468
|
}
|
|
469
469
|
addComment(e) {
|
|
470
470
|
var a;
|
|
471
|
-
const r = this._injector, t = (a = this.getComment()) == null ? void 0 : a.getCommentData(), n = r.get(
|
|
471
|
+
const r = this._injector, t = (a = this.getComment()) == null ? void 0 : a.getCommentData(), n = r.get(_), o = r.get(W), s = this._workbook.getUnitId(), h = this._worksheet.getSheetId(), c = `${F.chatAtABC(this._range.startColumn)}${this._range.startRow + 1}`, m = o.getCurrentUser(), d = e instanceof U ? e.build() : { text: e };
|
|
472
472
|
return n.executeCommand(f.id, {
|
|
473
473
|
unitId: s,
|
|
474
474
|
subUnitId: h,
|
|
@@ -488,7 +488,7 @@ class ne extends j {
|
|
|
488
488
|
}
|
|
489
489
|
clearComment() {
|
|
490
490
|
var s;
|
|
491
|
-
const e = this._injector, r = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(
|
|
491
|
+
const e = this._injector, r = (s = this.getComment()) == null ? void 0 : s.getCommentData(), t = e.get(_), n = this._workbook.getUnitId(), o = this._worksheet.getSheetId();
|
|
492
492
|
return r ? t.executeCommand(w.id, {
|
|
493
493
|
unitId: n,
|
|
494
494
|
subUnitId: o,
|
|
@@ -510,8 +510,8 @@ class ne extends j {
|
|
|
510
510
|
return this.clearComments();
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
j.extend(
|
|
514
|
-
class
|
|
513
|
+
j.extend(te);
|
|
514
|
+
class ne extends H {
|
|
515
515
|
/**
|
|
516
516
|
* @ignore
|
|
517
517
|
*/
|
|
@@ -582,10 +582,10 @@ class re extends H {
|
|
|
582
582
|
}));
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
|
-
H.extend(
|
|
586
|
-
class
|
|
585
|
+
H.extend(ne);
|
|
586
|
+
class re extends O {
|
|
587
587
|
getComments() {
|
|
588
|
-
return this._injector.get(
|
|
588
|
+
return this._injector.get(b).getSubUnitAll(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => this._injector.createInstance(I, t));
|
|
589
589
|
}
|
|
590
590
|
clearComments() {
|
|
591
591
|
const r = this.getComments().map((t) => t.deleteAsync());
|
|
@@ -596,7 +596,7 @@ class oe extends O {
|
|
|
596
596
|
* @param callback Callback function, param contains comment info and target cell.
|
|
597
597
|
*/
|
|
598
598
|
onCommented(e) {
|
|
599
|
-
return this._injector.get(
|
|
599
|
+
return this._injector.get(_).onCommandExecuted((t) => {
|
|
600
600
|
if (t.id === f.id) {
|
|
601
601
|
const n = t.params;
|
|
602
602
|
e(n);
|
|
@@ -604,12 +604,12 @@ class oe extends O {
|
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
606
|
getCommentById(e) {
|
|
607
|
-
const t = this._injector.get(
|
|
607
|
+
const t = this._injector.get(b).getComment(this._workbook.getUnitId(), this._worksheet.getSheetId(), e);
|
|
608
608
|
if (t)
|
|
609
609
|
return this._injector.createInstance(I, t);
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
|
-
O.extend(
|
|
612
|
+
O.extend(re);
|
|
613
613
|
const l = {
|
|
614
614
|
CommentAdded: "CommentAdded",
|
|
615
615
|
BeforeCommentAdd: "BeforeCommentAdd",
|
|
@@ -620,7 +620,7 @@ const l = {
|
|
|
620
620
|
CommentResolved: "CommentResolved",
|
|
621
621
|
BeforeCommentResolve: "BeforeCommentResolve"
|
|
622
622
|
};
|
|
623
|
-
class
|
|
623
|
+
class oe extends z {
|
|
624
624
|
get CommentAdded() {
|
|
625
625
|
return l.CommentAdded;
|
|
626
626
|
}
|
|
@@ -646,11 +646,11 @@ class se extends z {
|
|
|
646
646
|
return l.BeforeCommentResolve;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
z.extend(
|
|
650
|
-
class
|
|
649
|
+
z.extend(oe);
|
|
650
|
+
class se extends $ {
|
|
651
651
|
// eslint-disable-next-line max-lines-per-function
|
|
652
652
|
_initialize(e) {
|
|
653
|
-
const r = e.get(
|
|
653
|
+
const r = e.get(_);
|
|
654
654
|
this.registerEventHandler(
|
|
655
655
|
this.Event.CommentAdded,
|
|
656
656
|
() => r.onCommandExecuted((t) => {
|
|
@@ -772,7 +772,7 @@ class ie extends $ {
|
|
|
772
772
|
row: (g = (u = d.getRange()) == null ? void 0 : u.getRow()) != null ? g : 0,
|
|
773
773
|
col: (v = (C = d.getRange()) == null ? void 0 : C.getColumn()) != null ? v : 0,
|
|
774
774
|
comment: d,
|
|
775
|
-
newContent:
|
|
775
|
+
newContent: k.createByBody(m)
|
|
776
776
|
};
|
|
777
777
|
if (this.fireEvent(this.Event.BeforeCommentUpdate, P), P.cancel)
|
|
778
778
|
throw new E();
|
|
@@ -836,7 +836,7 @@ class ie extends $ {
|
|
|
836
836
|
return new U(e);
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
|
-
$.extend(
|
|
839
|
+
$.extend(se);
|
|
840
840
|
export {
|
|
841
841
|
I as FThreadComment
|
|
842
842
|
};
|
package/lib/es/index.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (i, e,
|
|
4
|
-
import { Inject as l, Disposable as R, ObjectMatrix as
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var x = (i, e, r) => e in i ? U(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
|
|
3
|
+
var h = (i, e, r) => x(i, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { Inject as l, IUniverInstanceService as T, Disposable as R, ObjectMatrix as E, UniverInstanceType as y, ICommandService as b, sequenceExecuteAsync as $, toDisposable as D, DependentOn as P, Injector as O, Plugin as A } from "@univerjs/core";
|
|
5
5
|
import { singleReferenceToGrid as u, serializeRange as M } from "@univerjs/engine-formula";
|
|
6
|
-
import { RefRangeService as W, SheetsSelectionsService as L, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as
|
|
7
|
-
import { ThreadCommentModel as S,
|
|
8
|
-
import { Subject as
|
|
9
|
-
var
|
|
10
|
-
for (var
|
|
11
|
-
(
|
|
12
|
-
return
|
|
13
|
-
}, w = (i, e) => (
|
|
6
|
+
import { RefRangeService as W, SheetsSelectionsService as L, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as j } from "@univerjs/sheets";
|
|
7
|
+
import { ThreadCommentModel as S, AddCommentMutation as B, DeleteCommentMutation as N, UpdateCommentRefMutation as C, UniverThreadCommentPlugin as V } from "@univerjs/thread-comment";
|
|
8
|
+
import { Subject as H } from "rxjs";
|
|
9
|
+
var F = Object.getOwnPropertyDescriptor, k = (i, e, r, t) => {
|
|
10
|
+
for (var n = t > 1 ? void 0 : t ? F(e, r) : e, o = i.length - 1, s; o >= 0; o--)
|
|
11
|
+
(s = i[o]) && (n = s(n) || n);
|
|
12
|
+
return n;
|
|
13
|
+
}, w = (i, e) => (r, t) => e(r, t, i);
|
|
14
14
|
let p = class extends R {
|
|
15
|
-
constructor(e,
|
|
15
|
+
constructor(e, r) {
|
|
16
16
|
super();
|
|
17
17
|
h(this, "_matrixMap", /* @__PURE__ */ new Map());
|
|
18
18
|
h(this, "_locationMap", /* @__PURE__ */ new Map());
|
|
19
|
-
h(this, "_commentUpdate$", new
|
|
19
|
+
h(this, "_commentUpdate$", new H());
|
|
20
20
|
h(this, "commentUpdate$", this._commentUpdate$.asObservable());
|
|
21
|
-
this._threadCommentModel = e, this._univerInstanceService =
|
|
21
|
+
this._threadCommentModel = e, this._univerInstanceService = r, this._init(), this.disposeWithMe(() => {
|
|
22
22
|
this._commentUpdate$.complete();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
_init() {
|
|
26
26
|
this._initData(), this._initUpdateTransform();
|
|
27
27
|
}
|
|
28
|
-
_ensureCommentMatrix(e,
|
|
28
|
+
_ensureCommentMatrix(e, r) {
|
|
29
29
|
let t = this._matrixMap.get(e);
|
|
30
30
|
t || (t = /* @__PURE__ */ new Map(), this._matrixMap.set(e, t));
|
|
31
|
-
let
|
|
32
|
-
return
|
|
31
|
+
let n = t.get(r);
|
|
32
|
+
return n || (n = new E(), t.set(r, n)), n;
|
|
33
33
|
}
|
|
34
|
-
_ensureCommentLocationMap(e,
|
|
34
|
+
_ensureCommentLocationMap(e, r) {
|
|
35
35
|
let t = this._locationMap.get(e);
|
|
36
36
|
t || (t = /* @__PURE__ */ new Map(), this._locationMap.set(e, t));
|
|
37
|
-
let
|
|
38
|
-
return
|
|
37
|
+
let n = t.get(r);
|
|
38
|
+
return n || (n = /* @__PURE__ */ new Map(), t.set(r, n)), n;
|
|
39
39
|
}
|
|
40
|
-
_addCommentToMatrix(e,
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
|
|
40
|
+
_addCommentToMatrix(e, r, t, n) {
|
|
41
|
+
var s;
|
|
42
|
+
const o = (s = e.getValue(r, t)) != null ? s : /* @__PURE__ */ new Set();
|
|
43
|
+
o.add(n), e.setValue(r, t, o);
|
|
44
44
|
}
|
|
45
|
-
_deleteCommentFromMatrix(e,
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
|
|
45
|
+
_deleteCommentFromMatrix(e, r, t, n) {
|
|
46
|
+
if (r >= 0 && t >= 0) {
|
|
47
|
+
const o = e.getValue(r, t);
|
|
48
|
+
o && o.has(n) && (o.delete(n), o.size === 0 && e.realDeleteValue(r, t));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
_ensure(e,
|
|
52
|
-
const t = this._ensureCommentMatrix(e,
|
|
53
|
-
return { matrix: t, locationMap:
|
|
51
|
+
_ensure(e, r) {
|
|
52
|
+
const t = this._ensureCommentMatrix(e, r), n = this._ensureCommentLocationMap(e, r);
|
|
53
|
+
return { matrix: t, locationMap: n };
|
|
54
54
|
}
|
|
55
55
|
_initData() {
|
|
56
56
|
const e = this._threadCommentModel.getAll();
|
|
57
|
-
for (const
|
|
58
|
-
for (const t of
|
|
59
|
-
const { unitId:
|
|
60
|
-
this._addComment(
|
|
57
|
+
for (const r of e)
|
|
58
|
+
for (const t of r.threads) {
|
|
59
|
+
const { unitId: n, subUnitId: o, root: s } = t;
|
|
60
|
+
this._addComment(n, o, s);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
_addComment(e,
|
|
64
|
-
const
|
|
65
|
-
!
|
|
63
|
+
_addComment(e, r, t) {
|
|
64
|
+
const n = u(t.ref), o = t.parentId, { row: s, column: a } = n, c = t.id, { matrix: m, locationMap: d } = this._ensure(e, r);
|
|
65
|
+
!o && s >= 0 && a >= 0 && (this._addCommentToMatrix(m, s, a, c), d.set(c, { row: s, column: a })), o || this._commentUpdate$.next({
|
|
66
66
|
unitId: e,
|
|
67
|
-
subUnitId:
|
|
67
|
+
subUnitId: r,
|
|
68
68
|
payload: t,
|
|
69
69
|
type: "add",
|
|
70
|
-
isRoot: !
|
|
71
|
-
...
|
|
70
|
+
isRoot: !o,
|
|
71
|
+
...n
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
// eslint-disable-next-line max-lines-per-function
|
|
75
75
|
_initUpdateTransform() {
|
|
76
76
|
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((e) => {
|
|
77
|
-
const { unitId:
|
|
77
|
+
const { unitId: r, subUnitId: t } = e;
|
|
78
78
|
try {
|
|
79
|
-
if (this._univerInstanceService.getUnitType(
|
|
79
|
+
if (this._univerInstanceService.getUnitType(r) !== y.UNIVER_SHEET)
|
|
80
80
|
return;
|
|
81
81
|
} catch {
|
|
82
82
|
}
|
|
83
|
-
const { matrix:
|
|
83
|
+
const { matrix: n, locationMap: o } = this._ensure(r, t);
|
|
84
84
|
switch (e.type) {
|
|
85
85
|
case "add": {
|
|
86
86
|
this._addComment(e.unitId, e.subUnitId, e.payload);
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
89
|
case "delete": {
|
|
90
|
-
const { isRoot:
|
|
91
|
-
if (
|
|
90
|
+
const { isRoot: s, comment: a } = e.payload;
|
|
91
|
+
if (s) {
|
|
92
92
|
const c = u(a.ref), { row: m, column: d } = c;
|
|
93
|
-
this._deleteCommentFromMatrix(
|
|
93
|
+
this._deleteCommentFromMatrix(n, m, d, a.id), this._commentUpdate$.next({
|
|
94
94
|
...e,
|
|
95
95
|
...c
|
|
96
96
|
});
|
|
@@ -98,7 +98,7 @@ let p = class extends R {
|
|
|
98
98
|
break;
|
|
99
99
|
}
|
|
100
100
|
case "update": {
|
|
101
|
-
const { commentId:
|
|
101
|
+
const { commentId: s } = e.payload, a = this._threadCommentModel.getComment(r, t, s);
|
|
102
102
|
if (!a)
|
|
103
103
|
return;
|
|
104
104
|
const c = u(a.ref);
|
|
@@ -109,18 +109,18 @@ let p = class extends R {
|
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
case "updateRef": {
|
|
112
|
-
const
|
|
112
|
+
const s = u(e.payload.ref), { commentId: a } = e.payload, c = o.get(a);
|
|
113
113
|
if (!c)
|
|
114
114
|
return;
|
|
115
115
|
const { row: m, column: d } = c;
|
|
116
|
-
this._deleteCommentFromMatrix(
|
|
116
|
+
this._deleteCommentFromMatrix(n, m, d, a), o.delete(a), s.row >= 0 && s.column >= 0 && (this._addCommentToMatrix(n, s.row, s.column, a), o.set(a, { row: s.row, column: s.column })), this._commentUpdate$.next({
|
|
117
117
|
...e,
|
|
118
|
-
...
|
|
118
|
+
...s
|
|
119
119
|
});
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
122
|
case "resolve": {
|
|
123
|
-
const { unitId:
|
|
123
|
+
const { unitId: s, subUnitId: a, payload: c } = e, { locationMap: m } = this._ensure(s, a), d = m.get(c.commentId);
|
|
124
124
|
d && this._commentUpdate$.next({
|
|
125
125
|
...e,
|
|
126
126
|
...d
|
|
@@ -130,80 +130,80 @@ let p = class extends R {
|
|
|
130
130
|
}
|
|
131
131
|
}));
|
|
132
132
|
}
|
|
133
|
-
getByLocation(e,
|
|
133
|
+
getByLocation(e, r, t, n) {
|
|
134
134
|
var a;
|
|
135
|
-
return (a = this.getAllByLocation(e,
|
|
135
|
+
return (a = this.getAllByLocation(e, r, t, n).filter((c) => !c.resolved)[0]) == null ? void 0 : a.id;
|
|
136
136
|
}
|
|
137
|
-
getAllByLocation(e,
|
|
138
|
-
const
|
|
139
|
-
return
|
|
137
|
+
getAllByLocation(e, r, t, n) {
|
|
138
|
+
const s = this._ensureCommentMatrix(e, r).getValue(t, n);
|
|
139
|
+
return s ? Array.from(s).map((a) => this.getComment(e, r, a)).filter(Boolean) : [];
|
|
140
140
|
}
|
|
141
|
-
getComment(e,
|
|
142
|
-
return this._threadCommentModel.getComment(e,
|
|
141
|
+
getComment(e, r, t) {
|
|
142
|
+
return this._threadCommentModel.getComment(e, r, t);
|
|
143
143
|
}
|
|
144
|
-
getCommentWithChildren(e,
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
144
|
+
getCommentWithChildren(e, r, t, n) {
|
|
145
|
+
const o = this.getByLocation(e, r, t, n);
|
|
146
|
+
if (!o)
|
|
147
147
|
return;
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
return this._threadCommentModel.getThread(e,
|
|
148
|
+
const s = this.getComment(e, r, o);
|
|
149
|
+
if (s)
|
|
150
|
+
return this._threadCommentModel.getThread(e, r, s.threadId);
|
|
151
151
|
}
|
|
152
|
-
showCommentMarker(e,
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
152
|
+
showCommentMarker(e, r, t, n) {
|
|
153
|
+
const o = this.getByLocation(e, r, t, n);
|
|
154
|
+
if (!o)
|
|
155
155
|
return !1;
|
|
156
|
-
const
|
|
157
|
-
return !!(
|
|
156
|
+
const s = this.getComment(e, r, o);
|
|
157
|
+
return !!(s && !s.resolved);
|
|
158
158
|
}
|
|
159
|
-
getSubUnitAll(e,
|
|
160
|
-
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId ===
|
|
159
|
+
getSubUnitAll(e, r) {
|
|
160
|
+
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId === r).map((t) => t.root);
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
|
-
p =
|
|
163
|
+
p = k([
|
|
164
164
|
w(0, l(S)),
|
|
165
|
-
w(1,
|
|
165
|
+
w(1, T)
|
|
166
166
|
], p);
|
|
167
|
-
var
|
|
168
|
-
for (var
|
|
169
|
-
(
|
|
170
|
-
return
|
|
171
|
-
}, _ = (i, e) => (
|
|
167
|
+
var z = Object.getOwnPropertyDescriptor, G = (i, e, r, t) => {
|
|
168
|
+
for (var n = t > 1 ? void 0 : t ? z(e, r) : e, o = i.length - 1, s; o >= 0; o--)
|
|
169
|
+
(s = i[o]) && (n = s(n) || n);
|
|
170
|
+
return n;
|
|
171
|
+
}, _ = (i, e) => (r, t) => e(r, t, i);
|
|
172
172
|
let f = class extends R {
|
|
173
|
-
constructor(e,
|
|
173
|
+
constructor(e, r, t, n, o) {
|
|
174
174
|
super();
|
|
175
175
|
h(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
176
176
|
h(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
177
|
-
h(this, "_handleRangeChange", (e,
|
|
178
|
-
const
|
|
177
|
+
h(this, "_handleRangeChange", (e, r, t, n, o) => {
|
|
178
|
+
const s = t.id, a = {
|
|
179
179
|
startColumn: t.column,
|
|
180
180
|
endColumn: t.column,
|
|
181
181
|
startRow: t.row,
|
|
182
182
|
endRow: t.row
|
|
183
183
|
};
|
|
184
|
-
return
|
|
184
|
+
return n ? {
|
|
185
185
|
redos: [{
|
|
186
186
|
id: C.id,
|
|
187
187
|
params: {
|
|
188
188
|
unitId: e,
|
|
189
|
-
subUnitId:
|
|
189
|
+
subUnitId: r,
|
|
190
190
|
payload: {
|
|
191
|
-
ref: M(
|
|
192
|
-
commentId:
|
|
191
|
+
ref: M(n),
|
|
192
|
+
commentId: s
|
|
193
193
|
},
|
|
194
|
-
silent:
|
|
194
|
+
silent: o
|
|
195
195
|
}
|
|
196
196
|
}],
|
|
197
197
|
undos: [{
|
|
198
198
|
id: C.id,
|
|
199
199
|
params: {
|
|
200
200
|
unitId: e,
|
|
201
|
-
subUnitId:
|
|
201
|
+
subUnitId: r,
|
|
202
202
|
payload: {
|
|
203
203
|
ref: M(a),
|
|
204
|
-
commentId:
|
|
204
|
+
commentId: s
|
|
205
205
|
},
|
|
206
|
-
silent:
|
|
206
|
+
silent: o
|
|
207
207
|
}
|
|
208
208
|
}]
|
|
209
209
|
} : {
|
|
@@ -211,111 +211,111 @@ let f = class extends R {
|
|
|
211
211
|
id: N.id,
|
|
212
212
|
params: {
|
|
213
213
|
unitId: e,
|
|
214
|
-
subUnitId:
|
|
215
|
-
commentId:
|
|
214
|
+
subUnitId: r,
|
|
215
|
+
commentId: s
|
|
216
216
|
}
|
|
217
217
|
}],
|
|
218
218
|
undos: [{
|
|
219
|
-
id:
|
|
219
|
+
id: B.id,
|
|
220
220
|
params: {
|
|
221
221
|
unitId: e,
|
|
222
|
-
subUnitId:
|
|
222
|
+
subUnitId: r,
|
|
223
223
|
comment: t,
|
|
224
224
|
sync: !0
|
|
225
225
|
}
|
|
226
226
|
}]
|
|
227
227
|
};
|
|
228
228
|
});
|
|
229
|
-
this._refRangeService = e, this._sheetsThreadCommentModel =
|
|
229
|
+
this._refRangeService = e, this._sheetsThreadCommentModel = r, this._threadCommentModel = t, this._selectionManagerService = n, this._commandService = o, this._initData(), this._initRefRange();
|
|
230
230
|
}
|
|
231
|
-
_getIdWithUnitId(e,
|
|
232
|
-
return `${e}-${
|
|
231
|
+
_getIdWithUnitId(e, r, t) {
|
|
232
|
+
return `${e}-${r}-${t}`;
|
|
233
233
|
}
|
|
234
|
-
_register(e,
|
|
235
|
-
const
|
|
234
|
+
_register(e, r, t) {
|
|
235
|
+
const n = t.id, o = {
|
|
236
236
|
startColumn: t.column,
|
|
237
237
|
endColumn: t.column,
|
|
238
238
|
startRow: t.row,
|
|
239
239
|
endRow: t.row
|
|
240
240
|
};
|
|
241
241
|
this._disposableMap.set(
|
|
242
|
-
this._getIdWithUnitId(e,
|
|
243
|
-
this._refRangeService.registerRefRange(
|
|
244
|
-
const a =
|
|
245
|
-
return c && c.startColumn ===
|
|
242
|
+
this._getIdWithUnitId(e, r, n),
|
|
243
|
+
this._refRangeService.registerRefRange(o, (s) => {
|
|
244
|
+
const a = j(o, s, { selectionManagerService: this._selectionManagerService }), c = Array.isArray(a) ? a[0] : a;
|
|
245
|
+
return c && c.startColumn === o.startColumn && c.startRow === o.startRow ? {
|
|
246
246
|
undos: [],
|
|
247
247
|
redos: []
|
|
248
|
-
} : this._handleRangeChange(e,
|
|
249
|
-
}, e,
|
|
248
|
+
} : this._handleRangeChange(e, r, t, c, !1);
|
|
249
|
+
}, e, r)
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
|
-
_watch(e,
|
|
253
|
-
const
|
|
252
|
+
_watch(e, r, t) {
|
|
253
|
+
const n = t.id, o = {
|
|
254
254
|
startColumn: t.column,
|
|
255
255
|
endColumn: t.column,
|
|
256
256
|
startRow: t.row,
|
|
257
257
|
endRow: t.row
|
|
258
258
|
};
|
|
259
259
|
this._watcherMap.set(
|
|
260
|
-
this._getIdWithUnitId(e,
|
|
261
|
-
this._refRangeService.watchRange(e,
|
|
262
|
-
const { redos: c } = this._handleRangeChange(e,
|
|
263
|
-
|
|
260
|
+
this._getIdWithUnitId(e, r, n),
|
|
261
|
+
this._refRangeService.watchRange(e, r, o, (s, a) => {
|
|
262
|
+
const { redos: c } = this._handleRangeChange(e, r, t, a, !0);
|
|
263
|
+
$(c, this._commandService, { onlyLocal: !0 });
|
|
264
264
|
}, !0)
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
_unwatch(e,
|
|
268
|
-
var
|
|
269
|
-
const
|
|
270
|
-
(
|
|
267
|
+
_unwatch(e, r, t) {
|
|
268
|
+
var o;
|
|
269
|
+
const n = this._getIdWithUnitId(e, r, t);
|
|
270
|
+
(o = this._watcherMap.get(n)) == null || o.dispose(), this._watcherMap.delete(n);
|
|
271
271
|
}
|
|
272
|
-
_unregister(e,
|
|
273
|
-
var
|
|
274
|
-
const
|
|
275
|
-
(
|
|
272
|
+
_unregister(e, r, t) {
|
|
273
|
+
var o;
|
|
274
|
+
const n = this._getIdWithUnitId(e, r, t);
|
|
275
|
+
(o = this._disposableMap.get(n)) == null || o.dispose(), this._disposableMap.delete(n);
|
|
276
276
|
}
|
|
277
277
|
_initData() {
|
|
278
278
|
const e = this._threadCommentModel.getAll();
|
|
279
|
-
for (const
|
|
280
|
-
for (const t of
|
|
281
|
-
const { unitId:
|
|
282
|
-
...
|
|
279
|
+
for (const r of e)
|
|
280
|
+
for (const t of r.threads) {
|
|
281
|
+
const { unitId: n, subUnitId: o, root: s } = t, a = u(s.ref), c = {
|
|
282
|
+
...s,
|
|
283
283
|
...a
|
|
284
284
|
};
|
|
285
|
-
this._register(
|
|
285
|
+
this._register(n, o, c), this._watch(n, o, c);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
_initRefRange() {
|
|
289
289
|
this.disposeWithMe(
|
|
290
290
|
this._sheetsThreadCommentModel.commentUpdate$.subscribe((e) => {
|
|
291
|
-
const { unitId:
|
|
291
|
+
const { unitId: r, subUnitId: t } = e;
|
|
292
292
|
switch (e.type) {
|
|
293
293
|
case "add": {
|
|
294
294
|
if (e.payload.parentId)
|
|
295
295
|
return;
|
|
296
|
-
const
|
|
296
|
+
const n = {
|
|
297
297
|
...e.payload,
|
|
298
298
|
row: e.row,
|
|
299
299
|
column: e.column
|
|
300
300
|
};
|
|
301
|
-
this._register(e.unitId, e.subUnitId,
|
|
301
|
+
this._register(e.unitId, e.subUnitId, n), this._watch(e.unitId, e.subUnitId, n);
|
|
302
302
|
break;
|
|
303
303
|
}
|
|
304
304
|
case "delete": {
|
|
305
|
-
this._unregister(
|
|
305
|
+
this._unregister(r, t, e.payload.commentId), this._unwatch(r, t, e.payload.commentId);
|
|
306
306
|
break;
|
|
307
307
|
}
|
|
308
308
|
case "updateRef": {
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
309
|
+
const n = this._sheetsThreadCommentModel.getComment(r, t, e.payload.commentId);
|
|
310
|
+
if (!n)
|
|
311
311
|
return;
|
|
312
|
-
this._unregister(
|
|
313
|
-
const
|
|
314
|
-
...
|
|
312
|
+
this._unregister(r, t, e.payload.commentId);
|
|
313
|
+
const o = {
|
|
314
|
+
...n,
|
|
315
315
|
row: e.row,
|
|
316
316
|
column: e.column
|
|
317
317
|
};
|
|
318
|
-
e.silent || (this._unwatch(
|
|
318
|
+
e.silent || (this._unwatch(r, t, e.payload.commentId), this._watch(r, t, o)), this._register(e.unitId, e.subUnitId, o);
|
|
319
319
|
break;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
@@ -327,22 +327,22 @@ let f = class extends R {
|
|
|
327
327
|
}));
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
|
-
f =
|
|
330
|
+
f = G([
|
|
331
331
|
_(0, l(W)),
|
|
332
332
|
_(1, l(p)),
|
|
333
333
|
_(2, l(S)),
|
|
334
334
|
_(3, l(L)),
|
|
335
335
|
_(4, b)
|
|
336
336
|
], f);
|
|
337
|
-
const
|
|
338
|
-
var
|
|
339
|
-
for (var
|
|
340
|
-
(
|
|
341
|
-
return
|
|
342
|
-
}, v = (i, e) => (
|
|
343
|
-
let g = class extends
|
|
344
|
-
constructor(i, e,
|
|
345
|
-
super(), this._injector = e, this._commandService =
|
|
337
|
+
const q = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
338
|
+
var J = Object.defineProperty, K = Object.getOwnPropertyDescriptor, Q = (i, e, r) => e in i ? J(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r, X = (i, e, r, t) => {
|
|
339
|
+
for (var n = t > 1 ? void 0 : t ? K(e, r) : e, o = i.length - 1, s; o >= 0; o--)
|
|
340
|
+
(s = i[o]) && (n = s(n) || n);
|
|
341
|
+
return n;
|
|
342
|
+
}, v = (i, e) => (r, t) => e(r, t, i), I = (i, e, r) => Q(i, typeof e != "symbol" ? e + "" : e, r);
|
|
343
|
+
let g = class extends A {
|
|
344
|
+
constructor(i, e, r) {
|
|
345
|
+
super(), this._injector = e, this._commandService = r;
|
|
346
346
|
}
|
|
347
347
|
onStarting() {
|
|
348
348
|
[
|
|
@@ -353,11 +353,11 @@ let g = class extends j {
|
|
|
353
353
|
}), this._injector.get(f);
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
g =
|
|
359
|
-
|
|
360
|
-
v(1, l(
|
|
356
|
+
I(g, "pluginName", q);
|
|
357
|
+
I(g, "type", y.UNIVER_SHEET);
|
|
358
|
+
g = X([
|
|
359
|
+
P(V),
|
|
360
|
+
v(1, l(O)),
|
|
361
361
|
v(2, l(b))
|
|
362
362
|
], g);
|
|
363
363
|
export {
|
|
@@ -8,19 +8,19 @@ import { FTheadCommentBuilder } from './f-thread-comment';
|
|
|
8
8
|
*/
|
|
9
9
|
export interface IFUniverCommentMixin {
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
11
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.CommentAdded, () => {})` as instead
|
|
12
12
|
*/
|
|
13
13
|
onCommentAdded(callback: (event: ISheetCommentAddEvent) => void): IDisposable;
|
|
14
14
|
/**
|
|
15
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
15
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.CommentUpdated, () => {})` as instead
|
|
16
16
|
*/
|
|
17
17
|
onCommentUpdated(callback: (event: ISheetCommentUpdateEvent) => void): IDisposable;
|
|
18
18
|
/**
|
|
19
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
19
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.CommentDeleted, () => {})` as instead
|
|
20
20
|
*/
|
|
21
21
|
onCommentDeleted(callback: (event: ISheetCommentDeleteEvent) => void): IDisposable;
|
|
22
22
|
/**
|
|
23
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
23
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.CommentResolved, () => {})` as instead
|
|
24
24
|
*/
|
|
25
25
|
onCommentResolved(callback: (event: ISheetCommentResolveEvent) => void): IDisposable;
|
|
26
26
|
/**
|
|
@@ -28,19 +28,19 @@ export interface IFWorkbookThreadCommentMixin {
|
|
|
28
28
|
*/
|
|
29
29
|
clearComments(): Promise<boolean>;
|
|
30
30
|
/**
|
|
31
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
31
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.CommentUpdated, () => {})` as instead
|
|
32
32
|
*/
|
|
33
33
|
onThreadCommentChange(callback: (commentUpdate: CommentUpdate) => void | false): IDisposable;
|
|
34
34
|
/**
|
|
35
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
35
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.BeforeCommentAdd, () => {})` as instead
|
|
36
36
|
*/
|
|
37
37
|
onBeforeAddThreadComment(this: FWorkbook, callback: (params: IAddCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
38
38
|
/**
|
|
39
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
39
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.BeforeCommentUpdate, () => {})` as instead
|
|
40
40
|
*/
|
|
41
41
|
onBeforeUpdateThreadComment(this: FWorkbook, callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
42
42
|
/**
|
|
43
|
-
* @deprecated use `univerAPI.addEvent(univerAPI.
|
|
43
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.event.BeforeCommentDelete, () => {})` as instead
|
|
44
44
|
*/
|
|
45
45
|
onBeforeDeleteThreadComment(this: FWorkbook, callback: (params: IDeleteCommentCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
46
46
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-thread-comment","@univerjs/sheets/facade","@univerjs/thread-comment","@univerjs/engine-formula","rxjs","@univerjs/core/facade"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.UniverSheetsThreadCommentFacade={},a.UniverCore,a.UniverSheetsThreadComment,a.UniverSheetsFacade,a.UniverThreadComment,a.UniverEngineFormula,a.rxjs,a.UniverCoreFacade))})(this,function(a,i,I,p,h,E,y,k){"use strict";var W=Object.defineProperty;var H=(a,i,I)=>i in a?W(a,i,{enumerable:!0,configurable:!0,writable:!0,value:I}):a[i]=I;var T=(a,i,I)=>H(a,typeof i!="symbol"?i+"":i,I);var A=Object.defineProperty,B=Object.getOwnPropertyDescriptor,x=(f,t,r,e)=>{for(var n=e>1?void 0:e?B(t,r):t,o=f.length-1,s;o>=0;o--)(s=f[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&A(t,r,n),n},U=(f,t)=>(r,e)=>t(r,e,f);class w{constructor(t){T(this,"_comment",{id:i.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:i.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});t&&(this._comment=t)}static create(t){return new w(t)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return i.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return S.create(i.Tools.deepClone(this._comment))}}class S extends w{static create(t){return new S(t)}setContent(t){return t instanceof i.RichTextValue?this._comment.text=t.getData().body:this._comment.text=t,this}setPersonId(t){return this._comment.personId=t,this}setDateTime(t){return this._comment.dT=h.getDT(t),this}setId(t){return this._comment.id=t,this}setThreadId(t){return this._comment.threadId=t,this}build(){return this._comment}}a.FThreadComment=class{constructor(t,r,e,n,o,s,u){this._thread=t,this._parent=r,this._injector=e,this._commandService=n,this._univerInstanceService=o,this._threadCommentModel=s,this._userManagerService=u}_getRef(){var e;const t=((e=this._parent)==null?void 0:e.ref)||this._thread.ref;return E.deserializeRangeWithSheet(t).range}getIsRoot(){return!this._parent}getCommentData(){const{children:t,...r}=this._thread;return r}getReplies(){var e;const t=this._getRef(),r=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return(e=r==null?void 0:r.children)==null?void 0:e.map(n=>this._injector.createInstance(a.FThreadComment,n))}getRange(){const t=this._univerInstanceService.getUnit(this._thread.unitId,i.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const r=t.getSheetBySheetId(this._thread.subUnitId);if(!r)return null;const e=this._getRef();return this._injector.createInstance(p.FRange,t,r,e)}getContent(){return this._thread.text}getRichText(){const t=this._thread.text;return i.RichTextValue.create({body:t,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?h.DeleteCommentTreeCommand.id:h.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(t){return this.updateAsync(t)}async updateAsync(t){const r=t instanceof i.RichTextValue?t.getData().body:t,e=h.getDT();return await this._commandService.executeCommand(h.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:r,updated:!0,updateT:e}})}resolve(t){return this.resolveAsync(t)}resolveAsync(t){return this._commandService.executeCommand(h.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:t!=null?t:!this._thread.resolved})}async replyAsync(t){var e;const r=t.build();return this._commandService.executeCommand(h.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:i.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:(e=this._parent)==null?void 0:e.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||h.getDT(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}},a.FThreadComment=x([U(2,i.Inject(i.Injector)),U(3,i.ICommandService),U(4,i.IUniverInstanceService),U(5,i.Inject(I.SheetsThreadCommentModel)),U(6,i.Inject(i.UserManagerService))],a.FThreadComment);class j extends p.FRange{getComment(){const r=this._injector.get(I.SheetsThreadCommentModel),e=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),o=r.getByLocation(e,n,this._range.startRow,this._range.startColumn);if(!o)return null;const s=r.getComment(e,n,o);return s?this._injector.createInstance(a.FThreadComment,s):null}getComments(){const r=this._injector.get(I.SheetsThreadCommentModel),e=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),o=[];return i.Range.foreach(this._range,(s,u)=>{const C=r.getByLocation(e,n,s,u);if(C){const m=r.getComment(e,n,C);m&&o.push(this._injector.createInstance(a.FThreadComment,m))}}),o}addComment(t){var c;const r=this._injector,e=(c=this.getComment())==null?void 0:c.getCommentData(),n=r.get(i.ICommandService),o=r.get(i.UserManagerService),s=this._workbook.getUnitId(),u=this._worksheet.getSheetId(),C=`${i.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,m=o.getCurrentUser(),d=t instanceof S?t.build():{text:t};return n.executeCommand(h.AddCommentCommand.id,{unitId:s,subUnitId:u,comment:{text:d.text,dT:d.dT||h.getDT(),attachments:[],id:d.id||i.generateRandomId(),ref:C,personId:d.personId||m.userID,parentId:e==null?void 0:e.id,unitId:s,subUnitId:u,threadId:(e==null?void 0:e.threadId)||i.generateRandomId()}})}clearComment(){var s;const t=this._injector,r=(s=this.getComment())==null?void 0:s.getCommentData(),e=t.get(i.ICommandService),n=this._workbook.getUnitId(),o=this._worksheet.getSheetId();return r?e.executeCommand(h.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:o,threadId:r.threadId,commentId:r.id}):Promise.resolve(!0)}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}addCommentAsync(t){return this.addComment(t)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}}p.FRange.extend(j);class D extends p.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(h.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(t=>this._injector.createInstance(a.FThreadComment,t.root))}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}onThreadCommentChange(t){return i.toDisposable(this._threadCommentModel.commentUpdate$.pipe(y.filter(r=>r.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddThreadComment(t){return i.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.AddCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(t){return i.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.UpdateCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(t){return i.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.DeleteCommentCommand.id||r.id===h.DeleteCommentTreeCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}p.FWorkbook.extend(D);class F extends p.FWorksheet{getComments(){return this._injector.get(I.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(a.FThreadComment,e))}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}onCommented(t){return this._injector.get(i.ICommandService).onCommandExecuted(e=>{if(e.id===h.AddCommentCommand.id){const n=e.params;t(n)}})}getCommentById(t){const e=this._injector.get(I.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),t);if(e)return this._injector.createInstance(a.FThreadComment,e)}}p.FWorksheet.extend(F);const _={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDeleted:"BeforeCommentDeleted",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class M extends k.FEventName{get CommentAdded(){return _.CommentAdded}get BeforeCommentAdd(){return _.BeforeCommentAdd}get CommentUpdated(){return _.CommentUpdated}get BeforeCommentUpdate(){return _.BeforeCommentUpdate}get CommentDeleted(){return _.CommentDeleted}get BeforeCommentDeleted(){return _.BeforeCommentDeleted}get CommentResolved(){return _.CommentResolved}get BeforeCommentResolve(){return _.BeforeCommentResolve}}k.FEventName.extend(M);class P extends k.FUniver{_initialize(t){const r=t.get(i.ICommandService);this.registerEventHandler(this.Event.CommentAdded,()=>r.onCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.AddCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{comment:C}=u,m=s.getRange(C.ref).getComment();m&&this.fireEvent(this.Event.CommentAdded,{workbook:o,worksheet:s,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m})})),this.registerEventHandler(this.Event.CommentUpdated,()=>r.onCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.UpdateCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{commentId:C}=u.payload,m=s.getCommentById(C);m&&this.fireEvent(this.Event.CommentUpdated,{workbook:o,worksheet:s,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m})})),this.registerEventHandler(this.Event.CommentDeleted,()=>r.onCommandExecuted(e=>{var m;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(m=this.getActiveWorkbook)==null?void 0:m.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{commentId:C}=u;this.fireEvent(this.Event.CommentDeleted,{workbook:o,worksheet:s,commentId:C})})),this.registerEventHandler(this.Event.CommentResolved,()=>r.onCommandExecuted(e=>{var c,g,l;if(e.id!==h.ResolveCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{commentId:C,resolved:m}=u,d=s.getComments().find(v=>v.getCommentData().id===C);d&&this.fireEvent(this.Event.CommentResolved,{workbook:o,worksheet:s,row:(g=d.getRange().getRow())!=null?g:0,col:(l=d.getRange().getColumn())!=null?l:0,comment:d,resolved:m})})),this.registerEventHandler(this.Event.BeforeCommentAdd,()=>r.beforeCommandExecuted(e=>{var c,g,l;if(e.id!==h.AddCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{comment:C}=u,m=s.getActiveRange();if(!m)return;const d={workbook:o,worksheet:s,row:(g=m.getRow())!=null?g:0,col:(l=m.getColumn())!=null?l:0,comment:w.create(C)};if(this.fireEvent(this.Event.BeforeCommentAdd,d),d.cancel)throw new i.CanceledError})),this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>r.beforeCommandExecuted(e=>{var c,g,l,v,b;if(e.id!==h.UpdateCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{commentId:C,text:m}=u.payload,d=s.getCommentById(C);if(d){const R={workbook:o,worksheet:s,row:(l=(g=d.getRange())==null?void 0:g.getRow())!=null?l:0,col:(b=(v=d.getRange())==null?void 0:v.getColumn())!=null?b:0,comment:d,newContent:i.RichTextValue.createByBody(m)};if(this.fireEvent(this.Event.BeforeCommentUpdate,R),R.cancel)throw new i.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentDeleted,()=>r.beforeCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{commentId:C}=u,m=s.getCommentById(C);if(m){const b={workbook:o,worksheet:s,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m};if(this.fireEvent(this.Event.BeforeCommentDeleted,b),b.cancel)throw new i.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentResolve,()=>r.beforeCommandExecuted(e=>{var c,g,l;if(e.id!==h.ResolveCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const s=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!s)return;const u=e.params,{commentId:C,resolved:m}=u,d=s.getComments().find(v=>v.getCommentData().id===C);if(d){const v={workbook:o,worksheet:s,row:(g=d.getRange().getRow())!=null?g:0,col:(l=d.getRange().getColumn())!=null?l:0,comment:d,resolved:m};if(this.fireEvent(this.Event.BeforeCommentResolve,v),v.cancel)throw new i.CanceledError}}))}newTheadComment(t){return new S(t)}}k.FUniver.extend(P),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-thread-comment","@univerjs/sheets/facade","@univerjs/thread-comment","@univerjs/engine-formula","rxjs","@univerjs/core/facade"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a.UniverSheetsThreadCommentFacade={},a.UniverCore,a.UniverSheetsThreadComment,a.UniverSheetsFacade,a.UniverThreadComment,a.UniverEngineFormula,a.rxjs,a.UniverCoreFacade))})(this,function(a,s,I,p,h,E,y,b){"use strict";var P=Object.defineProperty;var W=(a,s,I)=>s in a?P(a,s,{enumerable:!0,configurable:!0,writable:!0,value:I}):a[s]=I;var T=(a,s,I)=>W(a,typeof s!="symbol"?s+"":s,I);var A=Object.getOwnPropertyDescriptor,B=(f,t,r,e)=>{for(var n=e>1?void 0:e?A(t,r):t,o=f.length-1,i;o>=0;o--)(i=f[o])&&(n=i(n)||n);return n},U=(f,t)=>(r,e)=>t(r,e,f);class w{constructor(t){T(this,"_comment",{id:s.generateRandomId(),ref:"",threadId:"",dT:"",personId:"",text:s.RichTextBuilder.newEmptyData().body,attachments:[],unitId:"",subUnitId:""});t&&(this._comment=t)}static create(t){return new w(t)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return s.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return k.create(s.Tools.deepClone(this._comment))}}class k extends w{static create(t){return new k(t)}setContent(t){return t instanceof s.RichTextValue?this._comment.text=t.getData().body:this._comment.text=t,this}setPersonId(t){return this._comment.personId=t,this}setDateTime(t){return this._comment.dT=h.getDT(t),this}setId(t){return this._comment.id=t,this}setThreadId(t){return this._comment.threadId=t,this}build(){return this._comment}}a.FThreadComment=class{constructor(t,r,e,n,o,i,u){this._thread=t,this._parent=r,this._injector=e,this._commandService=n,this._univerInstanceService=o,this._threadCommentModel=i,this._userManagerService=u}_getRef(){var e;const t=((e=this._parent)==null?void 0:e.ref)||this._thread.ref;return E.deserializeRangeWithSheet(t).range}getIsRoot(){return!this._parent}getCommentData(){const{children:t,...r}=this._thread;return r}getReplies(){var e;const t=this._getRef(),r=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return(e=r==null?void 0:r.children)==null?void 0:e.map(n=>this._injector.createInstance(a.FThreadComment,n))}getRange(){const t=this._univerInstanceService.getUnit(this._thread.unitId,s.UniverInstanceType.UNIVER_SHEET);if(!t)return null;const r=t.getSheetBySheetId(this._thread.subUnitId);if(!r)return null;const e=this._getRef();return this._injector.createInstance(p.FRange,t,r,e)}getContent(){return this._thread.text}getRichText(){const t=this._thread.text;return s.RichTextValue.create({body:t,documentStyle:{},id:"d"})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?h.DeleteCommentTreeCommand.id:h.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(t){return this.updateAsync(t)}async updateAsync(t){const r=t instanceof s.RichTextValue?t.getData().body:t,e=h.getDT();return await this._commandService.executeCommand(h.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:r,updated:!0,updateT:e}})}resolve(t){return this.resolveAsync(t)}resolveAsync(t){return this._commandService.executeCommand(h.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:t!=null?t:!this._thread.resolved})}async replyAsync(t){var e;const r=t.build();return this._commandService.executeCommand(h.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:s.generateRandomId(),parentId:this._thread.id,threadId:this._thread.threadId,ref:(e=this._parent)==null?void 0:e.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||h.getDT(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}},a.FThreadComment=B([U(2,s.Inject(s.Injector)),U(3,s.ICommandService),U(4,s.IUniverInstanceService),U(5,s.Inject(I.SheetsThreadCommentModel)),U(6,s.Inject(s.UserManagerService))],a.FThreadComment);class x extends p.FRange{getComment(){const r=this._injector.get(I.SheetsThreadCommentModel),e=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),o=r.getByLocation(e,n,this._range.startRow,this._range.startColumn);if(!o)return null;const i=r.getComment(e,n,o);return i?this._injector.createInstance(a.FThreadComment,i):null}getComments(){const r=this._injector.get(I.SheetsThreadCommentModel),e=this._workbook.getUnitId(),n=this._worksheet.getSheetId(),o=[];return s.Range.foreach(this._range,(i,u)=>{const C=r.getByLocation(e,n,i,u);if(C){const m=r.getComment(e,n,C);m&&o.push(this._injector.createInstance(a.FThreadComment,m))}}),o}addComment(t){var c;const r=this._injector,e=(c=this.getComment())==null?void 0:c.getCommentData(),n=r.get(s.ICommandService),o=r.get(s.UserManagerService),i=this._workbook.getUnitId(),u=this._worksheet.getSheetId(),C=`${s.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,m=o.getCurrentUser(),d=t instanceof k?t.build():{text:t};return n.executeCommand(h.AddCommentCommand.id,{unitId:i,subUnitId:u,comment:{text:d.text,dT:d.dT||h.getDT(),attachments:[],id:d.id||s.generateRandomId(),ref:C,personId:d.personId||m.userID,parentId:e==null?void 0:e.id,unitId:i,subUnitId:u,threadId:(e==null?void 0:e.threadId)||s.generateRandomId()}})}clearComment(){var i;const t=this._injector,r=(i=this.getComment())==null?void 0:i.getCommentData(),e=t.get(s.ICommandService),n=this._workbook.getUnitId(),o=this._worksheet.getSheetId();return r?e.executeCommand(h.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:o,threadId:r.threadId,commentId:r.id}):Promise.resolve(!0)}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}addCommentAsync(t){return this.addComment(t)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}}p.FRange.extend(x);class D extends p.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(h.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(t=>this._injector.createInstance(a.FThreadComment,t.root))}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}onThreadCommentChange(t){return s.toDisposable(this._threadCommentModel.commentUpdate$.pipe(y.filter(r=>r.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddThreadComment(t){return s.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.AddCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeAddThreadComment")}}))}onBeforeUpdateThreadComment(t){return s.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.UpdateCommentCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateThreadComment")}}))}onBeforeDeleteThreadComment(t){return s.toDisposable(this._commandService.beforeCommandExecuted((r,e)=>{const n=r.params;if(r.id===h.DeleteCommentCommand.id||r.id===h.DeleteCommentTreeCommand.id){if(n.unitId!==this._workbook.getUnitId())return;if(t(n,e)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteThreadComment")}}))}}p.FWorkbook.extend(D);class j extends p.FWorksheet{getComments(){return this._injector.get(I.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(a.FThreadComment,e))}clearComments(){const r=this.getComments().map(e=>e.deleteAsync());return Promise.all(r).then(()=>!0)}onCommented(t){return this._injector.get(s.ICommandService).onCommandExecuted(e=>{if(e.id===h.AddCommentCommand.id){const n=e.params;t(n)}})}getCommentById(t){const e=this._injector.get(I.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),t);if(e)return this._injector.createInstance(a.FThreadComment,e)}}p.FWorksheet.extend(j);const _={CommentAdded:"CommentAdded",BeforeCommentAdd:"BeforeCommentAdd",CommentUpdated:"CommentUpdated",BeforeCommentUpdate:"BeforeCommentUpdate",CommentDeleted:"CommentDeleted",BeforeCommentDeleted:"BeforeCommentDeleted",CommentResolved:"CommentResolved",BeforeCommentResolve:"BeforeCommentResolve"};class F extends b.FEventName{get CommentAdded(){return _.CommentAdded}get BeforeCommentAdd(){return _.BeforeCommentAdd}get CommentUpdated(){return _.CommentUpdated}get BeforeCommentUpdate(){return _.BeforeCommentUpdate}get CommentDeleted(){return _.CommentDeleted}get BeforeCommentDeleted(){return _.BeforeCommentDeleted}get CommentResolved(){return _.CommentResolved}get BeforeCommentResolve(){return _.BeforeCommentResolve}}b.FEventName.extend(F);class M extends b.FUniver{_initialize(t){const r=t.get(s.ICommandService);this.registerEventHandler(this.Event.CommentAdded,()=>r.onCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.AddCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{comment:C}=u,m=i.getRange(C.ref).getComment();m&&this.fireEvent(this.Event.CommentAdded,{workbook:o,worksheet:i,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m})})),this.registerEventHandler(this.Event.CommentUpdated,()=>r.onCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.UpdateCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C}=u.payload,m=i.getCommentById(C);m&&this.fireEvent(this.Event.CommentUpdated,{workbook:o,worksheet:i,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m})})),this.registerEventHandler(this.Event.CommentDeleted,()=>r.onCommandExecuted(e=>{var m;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(m=this.getActiveWorkbook)==null?void 0:m.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C}=u;this.fireEvent(this.Event.CommentDeleted,{workbook:o,worksheet:i,commentId:C})})),this.registerEventHandler(this.Event.CommentResolved,()=>r.onCommandExecuted(e=>{var c,g,l;if(e.id!==h.ResolveCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C,resolved:m}=u,d=i.getComments().find(v=>v.getCommentData().id===C);d&&this.fireEvent(this.Event.CommentResolved,{workbook:o,worksheet:i,row:(g=d.getRange().getRow())!=null?g:0,col:(l=d.getRange().getColumn())!=null?l:0,comment:d,resolved:m})})),this.registerEventHandler(this.Event.BeforeCommentAdd,()=>r.beforeCommandExecuted(e=>{var c,g,l;if(e.id!==h.AddCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{comment:C}=u,m=i.getActiveRange();if(!m)return;const d={workbook:o,worksheet:i,row:(g=m.getRow())!=null?g:0,col:(l=m.getColumn())!=null?l:0,comment:w.create(C)};if(this.fireEvent(this.Event.BeforeCommentAdd,d),d.cancel)throw new s.CanceledError})),this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>r.beforeCommandExecuted(e=>{var c,g,l,v,S;if(e.id!==h.UpdateCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C,text:m}=u.payload,d=i.getCommentById(C);if(d){const R={workbook:o,worksheet:i,row:(l=(g=d.getRange())==null?void 0:g.getRow())!=null?l:0,col:(S=(v=d.getRange())==null?void 0:v.getColumn())!=null?S:0,comment:d,newContent:s.RichTextValue.createByBody(m)};if(this.fireEvent(this.Event.BeforeCommentUpdate,R),R.cancel)throw new s.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentDeleted,()=>r.beforeCommandExecuted(e=>{var d,c,g,l,v;if(e.id!==h.DeleteCommentCommand.id&&e.id!==h.DeleteCommentTreeCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(d=this.getActiveWorkbook)==null?void 0:d.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C}=u,m=i.getCommentById(C);if(m){const S={workbook:o,worksheet:i,row:(g=(c=m.getRange())==null?void 0:c.getRow())!=null?g:0,col:(v=(l=m.getRange())==null?void 0:l.getColumn())!=null?v:0,comment:m};if(this.fireEvent(this.Event.BeforeCommentDeleted,S),S.cancel)throw new s.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommentResolve,()=>r.beforeCommandExecuted(e=>{var c,g,l;if(e.id!==h.ResolveCommentCommand.id)return;const n=e.params;if(!n)return;const o=n.unitId?this.getUniverSheet(n.unitId):(c=this.getActiveWorkbook)==null?void 0:c.call(this);if(!o)return;const i=o.getSheetBySheetId(n.subUnitId||n.sheetId)||o.getActiveSheet();if(!i)return;const u=e.params,{commentId:C,resolved:m}=u,d=i.getComments().find(v=>v.getCommentData().id===C);if(d){const v={workbook:o,worksheet:i,row:(g=d.getRange().getRow())!=null?g:0,col:(l=d.getRange().getColumn())!=null?l:0,comment:d,resolved:m};if(this.fireEvent(this.Event.BeforeCommentResolve,v),v.cancel)throw new s.CanceledError}}))}newTheadComment(t){return new k(t)}}b.FUniver.extend(M),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,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):(d=typeof globalThis<"u"?globalThis:d||self,o(d.UniverSheetsThreadComment={},d.UniverCore,d.UniverEngineFormula,d.UniverSheets,d.UniverThreadComment,d.rxjs))})(this,function(d,o,l,p,g,w){"use strict";var $=Object.defineProperty;var D=(d,o,l)=>o in d?$(d,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[o]=l;var f=(d,o,l)=>D(d,typeof o!="symbol"?o+"":o,l);var S=Object.getOwnPropertyDescriptor,T=(h,m,e,n)=>{for(var t=n>1?void 0:n?S(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},M=(h,m)=>(e,n)=>m(e,n,h);d.SheetsThreadCommentModel=class extends o.Disposable{constructor(e,n){super();f(this,"_matrixMap",new Map);f(this,"_locationMap",new Map);f(this,"_commentUpdate$",new w.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:i}=r,c=t.id,{matrix:_,locationMap:u}=this._ensure(e,n);!s&&a>=0&&i>=0&&(this._addCommentToMatrix(_,a,i,c),u.set(c,{row:a,column:i})),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:i}=e.payload;if(a){const c=l.singleReferenceToGrid(i.ref),{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i.id),this._commentUpdate$.next({...e,...c})}break}case"update":{const{commentId:a}=e.payload,i=this._threadCommentModel.getComment(n,t,a);if(!i)return;const c=l.singleReferenceToGrid(i.ref);this._commentUpdate$.next({...e,...c});break}case"updateRef":{const a=l.singleReferenceToGrid(e.payload.ref),{commentId:i}=e.payload,c=s.get(i);if(!c)return;const{row:_,column:u}=c;this._deleteCommentFromMatrix(r,_,u,i),s.delete(i),a.row>=0&&a.column>=0&&(this._addCommentToMatrix(r,a.row,a.column,i),s.set(i,{row:a.row,column:a.column})),this._commentUpdate$.next({...e,...a});break}case"resolve":{const{unitId:a,subUnitId:i,payload:c}=e,{locationMap:_}=this._ensure(a,i),u=_.get(c.commentId);u&&this._commentUpdate$.next({...e,...u});break}}}))}getByLocation(e,n,t,r){var i;return(i=this.getAllByLocation(e,n,t,r).filter(c=>!c.resolved)[0])==null?void 0:i.id}getAllByLocation(e,n,t,r){const a=this._ensureCommentMatrix(e,n).getValue(t,r);return a?Array.from(a).map(i=>this.getComment(e,n,i)).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=T([M(0,o.Inject(g.ThreadCommentModel)),M(1,o.IUniverInstanceService)],d.SheetsThreadCommentModel);var y=Object.getOwnPropertyDescriptor,U=(h,m,e,n)=>{for(var t=n>1?void 0:n?y(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},C=(h,m)=>(e,n)=>m(e,n,h);d.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,i={startColumn:t.column,endColumn:t.column,startRow:t.row,endRow:t.row};return r?{redos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(r),commentId:a},silent:s}}],undos:[{id:g.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:n,payload:{ref:l.serializeRange(i),commentId:a},silent:s}}]}:{redos:[{id:g.DeleteCommentMutation.id,params:{unitId:e,subUnitId:n,commentId:a}}],undos:[{id:g.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 i=p.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(s,a,{selectionManagerService:this._selectionManagerService}),c=Array.isArray(i)?i[0]:i;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,i)=>{const{redos:c}=this._handleRangeChange(e,n,t,i,!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,i=l.singleReferenceToGrid(a.ref),c={...a,...i};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()}))}},d.SheetsThreadCommentRefRangeController=U([C(0,o.Inject(p.RefRangeService)),C(1,o.Inject(d.SheetsThreadCommentModel)),C(2,o.Inject(g.ThreadCommentModel)),C(3,o.Inject(p.SheetsSelectionsService)),C(4,o.ICommandService)],d.SheetsThreadCommentRefRangeController);const I="SHEET_THREAD_COMMENT_BASE_PLUGIN";var b=Object.defineProperty,j=Object.getOwnPropertyDescriptor,P=(h,m,e)=>m in h?b(h,m,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[m]=e,E=(h,m,e,n)=>{for(var t=n>1?void 0:n?j(m,e):m,r=h.length-1,s;r>=0;r--)(s=h[r])&&(t=s(t)||t);return t},v=(h,m)=>(e,n)=>m(e,n,h),R=(h,m,e)=>P(h,typeof m!="symbol"?m+"":m,e);d.UniverSheetsThreadCommentPlugin=class extends o.Plugin{constructor(m,e,n){super(),this._injector=e,this._commandService=n}onStarting(){[[d.SheetsThreadCommentModel],[d.SheetsThreadCommentRefRangeController]].forEach(m=>{this._injector.add(m)}),this._injector.get(d.SheetsThreadCommentRefRangeController)}},R(d.UniverSheetsThreadCommentPlugin,"pluginName",I),R(d.UniverSheetsThreadCommentPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),d.UniverSheetsThreadCommentPlugin=E([o.DependentOn(g.UniverThreadCommentPlugin),v(1,o.Inject(o.Injector)),v(2,o.Inject(o.ICommandService))],d.UniverSheetsThreadCommentPlugin),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.6.0
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer sheets thread comment base plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"rxjs": ">=7.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@univerjs/core": "0.6.0
|
|
55
|
-
"@univerjs/sheets": "0.6.0
|
|
56
|
-
"@univerjs/thread-comment": "0.6.0
|
|
57
|
-
"@univerjs/engine-formula": "0.6.0
|
|
54
|
+
"@univerjs/core": "0.6.0",
|
|
55
|
+
"@univerjs/sheets": "0.6.0",
|
|
56
|
+
"@univerjs/thread-comment": "0.6.0",
|
|
57
|
+
"@univerjs/engine-formula": "0.6.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"rxjs": "^7.8.1",
|