@univerjs/sheets-thread-comment-ui 0.4.2-nightly.202411091134 → 0.5.0-beta.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/index.js +2 -2
- package/lib/es/index.js +20 -20
- package/lib/umd/index.js +2 -2
- package/package.json +16 -16
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/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ve=Object.defineProperty;var Ce=(o,e,n)=>e in o?ve(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var D=(o,e,n)=>Ce(o,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),I=require("@univerjs/thread-comment-ui"),g=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),B=require("rxjs"),oe=require("@univerjs/engine-render"),O=require("react"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie="univer.sheet.thread-comment-modal",ee="comment-single",te="SHEET_THREAD_COMMENT";var Se=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?_e(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Se(e,n,r),r},re=(o,e)=>(n,t)=>e(n,t,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,t){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new B.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,t){var h;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(m),d.add({dispose:()=>{t==null||t()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=fe([re(0,a.Inject(g.SheetCanvasPopManagerService)),re(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const e=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),t=o.get(exports.SheetsThreadCommentPopupService),r=o.get(I.ThreadCommentPanelService),i=(f=e.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=c,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};t.showPopup(l);const v=s.getByLocation(h,u,i.startRow,i.startColumn);return v&&r.setActiveComment({unitId:h,subUnitId:u,commentId:v,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ge={};var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,e,n,t)=>{for(var r=t>1?void 0:t?Te(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Pe(e,n,r),r},k=(o,e)=>(n,t)=>e(n,t,o);let
|
|
1
|
+
"use strict";var ve=Object.defineProperty;var Ce=(o,e,n)=>e in o?ve(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var D=(o,e,n)=>Ce(o,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),C=require("@univerjs/sheets"),N=require("@univerjs/sheets-thread-comment"),I=require("@univerjs/thread-comment-ui"),g=require("@univerjs/sheets-ui"),S=require("@univerjs/ui"),B=require("rxjs"),oe=require("@univerjs/engine-render"),O=require("react"),x=require("@univerjs/engine-formula"),_=require("@univerjs/thread-comment"),ie="univer.sheet.thread-comment-modal",ee="comment-single",te="SHEET_THREAD_COMMENT";var Se=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?_e(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Se(e,n,r),r},re=(o,e)=>(n,t)=>e(n,t,o);exports.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(n,t){super();D(this,"_lastPopup",null);D(this,"_activePopup");D(this,"_activePopup$",new B.BehaviorSubject(null));D(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=n,this._zenZoneService=t,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(n=>{n&&this.hidePopup()}))}showPopup(n,t){var h;const{row:r,col:i,unitId:s,subUnitId:c}=n;if(this._activePopup&&r===this._activePopup.row&&i===this._activePopup.col&&s===this._activePopup.unitId&&c===((h=this.activePopup)==null?void 0:h.subUnitId)){this._activePopup=n,this._activePopup$.next(n);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=n,this._activePopup$.next(n);const m=this._canvasPopupManagerService.attachPopupToCell(r,i,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!m)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const d=new a.DisposableCollection;d.add(m),d.add({dispose:()=>{t==null||t()}}),this._lastPopup=d}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};exports.SheetsThreadCommentPopupService=fe([re(0,a.Inject(g.SheetCanvasPopManagerService)),re(1,S.IZenZoneService)],exports.SheetsThreadCommentPopupService);const A={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(o){var f;const e=o.get(C.SheetsSelectionsService),n=o.get(a.IUniverInstanceService),t=o.get(exports.SheetsThreadCommentPopupService),r=o.get(I.ThreadCommentPanelService),i=(f=e.getCurrentLastSelection())==null?void 0:f.primary,s=o.get(N.SheetsThreadCommentModel);if(!i)return!1;const c=C.getSheetCommandTarget(n);if(!c)return!1;const{workbook:m,worksheet:d,unitId:h,subUnitId:u}=c,l={workbook:m,worksheet:d,unitId:h,subUnitId:u,row:i.startRow,col:i.startColumn};t.showPopup(l);const v=s.getByLocation(h,u,i.startRow,i.startColumn);return v&&r.setActiveComment({unitId:h,subUnitId:u,commentId:v,trigger:"context-menu"}),!0}},Ie="sheets-thread-comment.config",ge={};var Pe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(o,e,n,t)=>{for(var r=t>1?void 0:t?Te(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Pe(e,n,r),r},k=(o,e)=>(n,t)=>e(n,t,o);let W=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,this._sheetsThreadCommentModel=e,this._univerInstanceService=n,this._renderManagerService=t,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(o,e,n)=>{const{row:t,col:r,unitId:i,subUnitId:s}=e;return this._sheetsThreadCommentModel.showCommentMarker(i,s,t,r)?n({...o,markers:{...o==null?void 0:o.markers,tr:{color:"#FFBD37",size:6}}}):n(o)},priority:100}))}_initSkeletonChange(){const o=()=>{var r;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return;const n=e.getUnitId(),t=this._renderManagerService.getRenderById(n);(r=t==null?void 0:t.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(B.debounceTime(16)).subscribe(()=>{o()}))}};W=be([k(0,a.Inject(C.SheetInterceptorService)),k(1,a.Inject(N.SheetsThreadCommentModel)),k(2,a.IUniverInstanceService),k(3,oe.IRenderManagerService)],W);var w=function(){return w=Object.assign||function(o){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r])}return o},w.apply(this,arguments)},ye=function(o,e){var n={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(n[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(o);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(o,t[r])&&(n[t[r]]=o[t[r]]);return n},se=O.forwardRef(function(o,e){var n=o.icon,t=o.id,r=o.className,i=o.extend,s=ye(o,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(r||"").trim(),m=O.useRef("_".concat(Ue()));return ae(n,"".concat(t),{defIds:n.defIds,idSuffix:m.current},w({ref:e,className:c},s),i)});function ae(o,e,n,t,r){return O.createElement(o.tag,w(w({key:e},Me(o,n,r)),t),(we(o,n).children||[]).map(function(i,s){return ae(i,"".concat(e,"-").concat(o.tag,"-").concat(s),n,void 0,r)}))}function Me(o,e,n){var t=w({},o.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(o.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(i){var s=i[0],c=i[1];typeof c=="string"&&(t[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function we(o,e){var n,t=e.defIds;return!t||t.length===0?o:o.tag==="defs"&&(!((n=o.children)===null||n===void 0)&&n.length)?w(w({},o),{children:o.children.map(function(r){return typeof r.attrs.id=="string"&&t&&t.indexOf(r.attrs.id)>-1?w(w({},r),{attrs:w(w({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):o}function Ue(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var Oe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=O.forwardRef(function(o,e){return O.createElement(se,Object.assign({},o,{id:"comment-single",ref:e,icon:Oe}))});ce.displayName="CommentSingle";var me={exports:{}},Y={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Ee=O,Re=Symbol.for("react.element"),je=Symbol.for("react.fragment"),De=Object.prototype.hasOwnProperty,$e=Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ne={key:!0,ref:!0,__self:!0,__source:!0};function de(o,e,n){var t,r={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)De.call(e,t)&&!Ne.hasOwnProperty(t)&&(r[t]=e[t]);if(o&&o.defaultProps)for(t in e=o.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:Re,type:o,key:i,ref:s,props:r,_owner:$e.current}}Y.Fragment=je;Y.jsx=de;Y.jsxs=de;me.exports=Y;var ue=me.exports;const xe=()=>{const o=a.useDependency(a.IUniverInstanceService),e=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(e.activePopup$),t=a.useDependency(N.SheetsThreadCommentModel);if(S.useObservable(t.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,d=t.getByLocation(s,c,r,i),h=`${a.Tools.chatAtABC(i)}${r+1}`,u=()=>{e.hidePopup()},l=v=>{var f,b,$;return($=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:b.getName())!=null?$:""};return ue.jsx(I.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Ae=()=>{var y;const o=a.useDependency(g.IMarkSelectionService),e=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=t.getUnitId(),i=a.useDependency(a.ICommandService),s=O.useMemo(()=>t.activeSheet$.pipe(B.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),c=S.useObservable(s,(y=t.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(),d=a.useDependency(I.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=O.useCallback(p=>{const M=t.getSheets(),P={};M.forEach((U,T)=>{P[U.getSheetId()]=T});const E=U=>U.map(T=>{var ne;const j=x.singleReferenceToGrid(T.ref),pe=[(ne=P[T.subUnitId])!=null?ne:0,j.row,j.column];return{...T,p:pe}}).sort((T,j)=>T.p[0]===j.p[0]?T.p[1]===j.p[1]?T.p[2]-j.p[2]:T.p[1]-j.p[1]:T.p[0]-j.p[0]);return[...E(p.filter(U=>!U.resolved)),...E(p.filter(U=>U.resolved))]},[t]),v=O.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===c&&!p.resolved){const{row:P,column:E}=x.singleReferenceToGrid(p.ref),U=t.getSheetBySheetId(p.subUnitId),T=(M=U==null?void 0:U.getMergedCell(P,E))!=null?M:{startColumn:E,endColumn:E,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(E))return o.addShape({range:T,style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=p=>{var M,P;return(P=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?P:""},b=()=>{i.executeCommand(A.id)},$=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=v(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return O.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ue.jsx(I.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:$,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Ve=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:ee,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Be=o=>({id:I.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:ee,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),ke={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},He={[S.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Be}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:Ve}}}};var Le=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,We=(o,e,n,t)=>{for(var r=t>1?void 0:t?Fe(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Le(e,n,r),r},J=(o,e)=>(n,t)=>e(n,t,o);let W=class extends a.Disposable{constructor(o,e,n){super(),this._menuManagerService=o,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(ke)}_initMenu(){this._menuManagerService.mergeMenu(He)}_initComponent(){[[ie,xe],[I.THREAD_COMMENT_PANEL,Ae],[ee,ce]].forEach(([o,e])=>{this._componentManager.register(o,e)})}};W=We([J(0,S.IMenuManagerService),J(1,a.Inject(S.ComponentManager)),J(2,S.IShortcutService)],W);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ze=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ge(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&qe(e,n,r),r},Q=(o,e)=>(n,t)=>e(n,t,o);const ze=(o,e,n)=>{const t=x.singleReferenceToGrid(o),r=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+r,endColumn:t.column+i,endRow:t.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(e,n,t){super();D(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:te,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const v=[];a.Range.foreach(d,(y,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,y,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(P=>{v.push(P)}):M.forEach(({children:P,...E})=>{E.parentId||v.push(E)})});const f=[],b=[],$=[],V=[],K=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:y.id}}),$.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:ze(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return v.forEach(y=>{K(y)}),{redos:[...f,...$],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ze([Q(0,a.Inject(g.ISheetClipboardService)),Q(1,a.Inject(N.SheetsThreadCommentModel)),Q(2,_.IThreadCommentDataSourceService)],q);var Ye=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Je=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ke(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ye(e,n,r),r},H=(o,e)=>(n,t)=>e(n,t,o);let G=class extends a.Disposable{constructor(o,e,n,t){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(B.debounceTime(100)).subscribe(o=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(o&&(e&&e.temp||!e)){const{location:n}=o,{unitId:t,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(t,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(t,r,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=Je([H(0,a.Inject(g.HoverManagerService)),H(1,a.Inject(exports.SheetsThreadCommentPopupService)),H(2,a.Inject(N.SheetsThreadCommentModel)),H(3,a.Inject(g.SheetPermissionInterceptorBaseController))],G);var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,e,n,t)=>{for(var r=t>1?void 0:t?Xe(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Qe(e,n,r),r},R=(o,e)=>(n,t)=>e(n,t,o);let Z=class extends a.Disposable{constructor(e,n,t,r,i,s,c,m,d,h){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var l,v,f;const r=(l=e[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(g.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:v.skeleton;if(!s||!r)return;const c=s.getCellByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const d=c.actualRow,h=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,t,d,h);u&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:u})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(e,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===_.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:r,subUnitId:i,commentId:s}=t;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{var n;if(e){const{unitId:t,subUnitId:r,commentId:i,trigger:s}=e,c=this._sheetsThreadCommentModel.getComment(t,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:r}),this._isSwitchToCommenting=!1;const u=x.singleReferenceToGrid(c.ref),{row:l,column:v}=u;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:v,endRow:l,endColumn:v}]))return;const b=1;if(await this._commandService.executeCommand(g.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-b,0),endRow:u.row+b,startColumn:Math.max(u.column-b,0),endColumn:u.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:u.row,col:u.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(B.debounceTime(100)).subscribe(e=>{var l,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:r}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(t),h=(v=d==null?void 0:d.getMergedCell(c,m))!=null?v:{startColumn:m,endColumn:m,startRow:c,endRow:c},u=this._markSelectionService.addShape({range:h,style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...e,shapeId:u})}))}};Z=et([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(I.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(g.SheetPermissionInterceptorBaseController)),R(6,g.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,g.IEditorBridgeService),R(9,oe.IRenderManagerService)],Z);var tt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(o,e,n,t)=>{for(var r=t>1?void 0:t?nt(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&tt(e,n,r),r},L=(o,e)=>(n,t)=>e(n,t,o);let z=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,this._univerInstanceService=e,this._threadCommentModel=n,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var e;if(o.id===C.RemoveSheetCommand.id){const n=o.params,t=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const r=t.getUnitId(),i=n.subUnitId||((e=t.getActiveSheet())==null?void 0:e.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=c.map(({children:l,...v})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...v,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};z=rt([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],z);var he=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,it=(o,e,n)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,st=(o,e,n,t)=>{for(var r=t>1?void 0:t?ot(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&he(e,n,r),r},X=(o,e)=>(n,t)=>e(n,t,o),le=(o,e,n)=>it(o,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ge,n,t,r){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=r;const{menu:i,...s}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ie,s)}onStarting(){[[W],[F],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(W)}onReady(){this._injector.get(F),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};le(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",te);le(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=st([a.DependentOn(I.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>I.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=te;exports.ShowAddSheetCommentModalOperation=A;
|
|
9
|
+
*/var Ee=O,Re=Symbol.for("react.element"),je=Symbol.for("react.fragment"),De=Object.prototype.hasOwnProperty,$e=Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ne={key:!0,ref:!0,__self:!0,__source:!0};function de(o,e,n){var t,r={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(t in e)De.call(e,t)&&!Ne.hasOwnProperty(t)&&(r[t]=e[t]);if(o&&o.defaultProps)for(t in e=o.defaultProps,e)r[t]===void 0&&(r[t]=e[t]);return{$$typeof:Re,type:o,key:i,ref:s,props:r,_owner:$e.current}}Y.Fragment=je;Y.jsx=de;Y.jsxs=de;me.exports=Y;var ue=me.exports;const xe=()=>{const o=a.useDependency(a.IUniverInstanceService),e=a.useDependency(exports.SheetsThreadCommentPopupService),n=S.useObservable(e.activePopup$),t=a.useDependency(N.SheetsThreadCommentModel);if(S.useObservable(t.commentUpdate$),!n)return null;const{row:r,col:i,unitId:s,subUnitId:c,trigger:m}=n,d=t.getByLocation(s,c,r,i),h=`${a.Tools.chatAtABC(i)}${r+1}`,u=()=>{e.hidePopup()},l=v=>{var f,b,$;return($=(b=(f=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:f.getSheetBySheetId(v))==null?void 0:b.getName())!=null?$:""};return ue.jsx(I.ThreadCommentTree,{onClick:()=>{e.persistPopup()},prefix:"cell",id:d,unitId:s,subUnitId:c,type:a.UniverInstanceType.UNIVER_SHEET,refStr:h,onClose:u,getSubUnitName:l,autoFocus:m==="context-menu"})},Ae=()=>{var y;const o=a.useDependency(g.IMarkSelectionService),e=a.useDependency(a.IUniverInstanceService),n=a.useDependency(exports.SheetsThreadCommentPopupService),t=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=t.getUnitId(),i=a.useDependency(a.ICommandService),s=O.useMemo(()=>t.activeSheet$.pipe(B.map(p=>p==null?void 0:p.getSheetId())),[t.activeSheet$]),c=S.useObservable(s,(y=t.getActiveSheet())==null?void 0:y.getSheetId()),m=O.useRef(),d=a.useDependency(I.ThreadCommentPanelService),h=S.useObservable(d.activeCommentId$),u=S.useObservable(d.panelVisible$,d.panelVisible),l=O.useCallback(p=>{const M=t.getSheets(),P={};M.forEach((U,T)=>{P[U.getSheetId()]=T});const E=U=>U.map(T=>{var ne;const j=x.singleReferenceToGrid(T.ref),pe=[(ne=P[T.subUnitId])!=null?ne:0,j.row,j.column];return{...T,p:pe}}).sort((T,j)=>T.p[0]===j.p[0]?T.p[1]===j.p[1]?T.p[2]-j.p[2]:T.p[1]-j.p[1]:T.p[0]-j.p[0]);return[...E(p.filter(U=>!U.resolved)),...E(p.filter(U=>U.resolved))]},[t]),v=O.useCallback(p=>{var M;if(p.unitId===r&&p.subUnitId===c&&!p.resolved){const{row:P,column:E}=x.singleReferenceToGrid(p.ref),U=t.getSheetBySheetId(p.subUnitId),T=(M=U==null?void 0:U.getMergedCell(P,E))!=null?M:{startColumn:E,endColumn:E,startRow:P,endRow:P};if(!Number.isNaN(P)&&!Number.isNaN(E))return o.addShape({range:T,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[o,c,r]),f=p=>{var M,P;return(P=(M=t.getSheetBySheetId(p))==null?void 0:M.getName())!=null?P:""},b=()=>{i.executeCommand(A.id)},$=p=>{h&&h.unitId===p.unitId&&h.subUnitId===p.subUnitId&&h.commentId===p.id||(m.current&&(o.removeShape(m.current),m.current=null),m.current=v(p))},V=()=>{m.current&&(o.removeShape(m.current),m.current=null)},K=(p,M)=>{M&&n.hidePopup()};return O.useEffect(()=>{!u&&m.current&&o.removeShape(m.current)},[o,u]),ue.jsx(I.ThreadCommentPanel,{unitId:r,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:b,getSubUnitName:f,onResolve:K,sortComments:l,onItemEnter:$,onItemLeave:V,onDeleteComment:()=>(V(),!0)})},Ve=o=>({id:A.id,type:S.MenuItemType.BUTTON,icon:ee,title:"sheetThreadComment.menu.addComment",hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]})}),Be=o=>({id:I.ToggleSheetCommentPanelOperation.id,type:S.MenuItemType.BUTTON,icon:ee,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(o,{workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]}),hidden$:S.getMenuHiddenObservable(o,a.UniverInstanceType.UNIVER_SHEET)}),ke={id:A.id,binding:S.KeyCode.M|S.MetaKeys.CTRL_COMMAND|S.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},He={[S.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:Be}},[S.ContextMenuPosition.MAIN_AREA]:{[S.ContextMenuGroup.OTHERS]:{[A.id]:{order:0,menuItemFactory:Ve}}}};var Le=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Fe=(o,e,n,t)=>{for(var r=t>1?void 0:t?We(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Le(e,n,r),r},J=(o,e)=>(n,t)=>e(n,t,o);let F=class extends a.Disposable{constructor(o,e,n){super(),this._menuManagerService=o,this._componentManager=e,this._shortcutService=n,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(ke)}_initMenu(){this._menuManagerService.mergeMenu(He)}_initComponent(){[[ie,xe],[I.THREAD_COMMENT_PANEL,Ae],[ee,ce]].forEach(([o,e])=>{this._componentManager.register(o,e)})}};F=Fe([J(0,S.IMenuManagerService),J(1,a.Inject(S.ComponentManager)),J(2,S.IShortcutService)],F);var qe=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Ze=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ge(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&qe(e,n,r),r},Q=(o,e)=>(n,t)=>e(n,t,o);const ze=(o,e,n)=>{const t=x.singleReferenceToGrid(o),r=n.row-e.row,i=n.column-e.column,s={startColumn:t.column+i,startRow:t.row+r,endColumn:t.column+i,endRow:t.row+r};return x.serializeRange(s)};let q=class extends a.Disposable{constructor(e,n,t){super();D(this,"_copyInfo");this._sheetClipboardService=e,this._sheetsThreadCommentModel=n,this._threadCommentDataSourceService=t,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:te,onBeforeCopy:(e,n,t)=>{this._copyInfo={unitId:e,subUnitId:n,range:t}},onPasteCells:(e,n,t,r)=>{const{unitId:i,subUnitId:s,range:c}=n,m={row:c.rows[0],column:c.cols[0]};if(r.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:d,unitId:h,subUnitId:u}=this._copyInfo,l={row:d.startRow,column:d.startColumn};if(!(i===h&&s===u)){const v=[];a.Range.foreach(d,(y,p)=>{const M=this._sheetsThreadCommentModel.getAllByLocation(h,u,y,p);this._threadCommentDataSourceService.syncUpdateMutationToColla?M.forEach(P=>{v.push(P)}):M.forEach(({children:P,...E})=>{E.parentId||v.push(E)})});const f=[],b=[],$=[],V=[],K=y=>{f.unshift({id:_.DeleteCommentMutation.id,params:{unitId:h,subUnitId:u,commentId:y.id}}),$.push({id:_.AddCommentMutation.id,params:{unitId:i,subUnitId:s,comment:{...y,ref:ze(y.ref,l,m),unitId:i,subUnitId:s},sync:!0}}),b.push({id:_.AddCommentMutation.id,params:{unitId:h,subUnitId:u,comment:y,sync:!0}}),V.unshift({id:_.DeleteCommentMutation.id,params:{unitId:i,subUnitId:s,commentId:y.id}})};return v.forEach(y=>{K(y)}),{redos:[...f,...$],undos:[...V,...b]}}}return{redos:[],undos:[]}}}))}};q=Ze([Q(0,a.Inject(g.ISheetClipboardService)),Q(1,a.Inject(N.SheetsThreadCommentModel)),Q(2,_.IThreadCommentDataSourceService)],q);var Ye=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Je=(o,e,n,t)=>{for(var r=t>1?void 0:t?Ke(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Ye(e,n,r),r},H=(o,e)=>(n,t)=>e(n,t,o);let G=class extends a.Disposable{constructor(o,e,n,t){super(),this._hoverManagerService=o,this._sheetsThreadCommentPopupService=e,this._sheetsThreadCommentModel=n,this._sheetPermissionInterceptorBaseController=t,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(B.debounceTime(100)).subscribe(o=>{const e=this._sheetsThreadCommentPopupService.activePopup;if(o&&(e&&e.temp||!e)){const{location:n}=o,{unitId:t,subUnitId:r,row:i,col:s}=n,c=this._sheetsThreadCommentModel.getByLocation(t,r,i,s);if(c){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:s,endRow:i,endColumn:s}]))return;const d=this._sheetsThreadCommentModel.getComment(t,r,c);d&&!d.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:i,col:s,commentId:c,temp:!0})}else e&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};G=Je([H(0,a.Inject(g.HoverManagerService)),H(1,a.Inject(exports.SheetsThreadCommentPopupService)),H(2,a.Inject(N.SheetsThreadCommentModel)),H(3,a.Inject(g.SheetPermissionInterceptorBaseController))],G);var Qe=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,et=(o,e,n,t)=>{for(var r=t>1?void 0:t?Xe(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&Qe(e,n,r),r},R=(o,e)=>(n,t)=>e(n,t,o);let Z=class extends a.Disposable{constructor(e,n,t,r,i,s,c,m,d,h){super();D(this,"_isSwitchToCommenting",!1);D(this,"_selectionShapeInfo",null);this._commandService=e,this._sheetsThreadCommentPopupService=n,this._sheetsThreadCommentModel=t,this._threadCommentPanelService=r,this._univerInstanceService=i,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=c,this._sheetSelectionService=m,this._editorBridgeService=d,this._renderManagerService=h,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(e,n,t){var l,v,f;const r=(l=e[0])==null?void 0:l.range,i=this._renderManagerService.getRenderById(n),s=(v=i==null?void 0:i.with(g.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:v.skeleton;if(!s||!r)return;const c=s.getCellWithCoordByIndex(r.startRow,r.startColumn);if((((f=r.rangeType)!=null?f:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||r.endColumn-r.startColumn>0||r.endRow-r.startRow>0)&&!((c.isMerged||c.isMergedMainCell)&&a.Rectangle.equals(c.mergeInfo,r))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const d=c.actualRow,h=c.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(n,t,d,h)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const u=this._sheetsThreadCommentModel.getByLocation(n,t,d,h);u&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:n,subUnitId:t,commentId:u})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchToCommenting)return;const n=this._sheetSelectionService.currentSelectionParam;n&&this._handleSelectionChange(e,n.unitId,n.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(e=>{if(e.id===_.DeleteCommentMutation.id){const n=e.params,t=this._sheetsThreadCommentPopupService.activePopup;if(!t)return;const{unitId:r,subUnitId:i,commentId:s}=t;n.unitId===r&&n.subUnitId===i&&n.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async e=>{var n;if(e){const{unitId:t,subUnitId:r,commentId:i,trigger:s}=e,c=this._sheetsThreadCommentModel.getComment(t,r,i);if(!c||c.resolved)return;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m||m.getUnitId()!==t)return;this._isSwitchToCommenting=!0,((n=m.getActiveSheet())==null?void 0:n.getSheetId())!==r&&await this._commandService.executeCommand(C.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:r}),this._isSwitchToCommenting=!1;const u=x.singleReferenceToGrid(c.ref),{row:l,column:v}=u;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[C.WorkbookCommentPermission],worksheetTypes:[C.WorksheetViewPermission],rangeTypes:[C.RangeProtectionPermissionViewPoint]},[{startRow:l,startColumn:v,endRow:l,endColumn:v}]))return;const b=1;if(await this._commandService.executeCommand(g.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-b,0),endRow:u.row+b,startColumn:Math.max(u.column-b,0),endColumn:u.column+b}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:t,subUnitId:r,row:u.row,col:u.column,commentId:c.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(B.debounceTime(100)).subscribe(e=>{var l,v;if(!e){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:n,subUnitId:t,commentId:r}=e;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const i=this._sheetsThreadCommentModel.getComment(n,t,r);if(!i)return;const s=x.singleReferenceToGrid(i.ref),{row:c,column:m}=s;if(Number.isNaN(c)||Number.isNaN(m))return null;const d=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getSheetBySheetId(t),h=(v=d==null?void 0:d.getMergedCell(c,m))!=null?v:{startColumn:m,endColumn:m,startRow:c,endRow:c},u=this._markSelectionService.addShape({range:h,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);u&&(this._selectionShapeInfo={...e,shapeId:u})}))}};Z=et([R(0,a.ICommandService),R(1,a.Inject(exports.SheetsThreadCommentPopupService)),R(2,a.Inject(N.SheetsThreadCommentModel)),R(3,a.Inject(I.ThreadCommentPanelService)),R(4,a.IUniverInstanceService),R(5,a.Inject(g.SheetPermissionInterceptorBaseController)),R(6,g.IMarkSelectionService),R(7,a.Inject(C.SheetsSelectionsService)),R(8,g.IEditorBridgeService),R(9,oe.IRenderManagerService)],Z);var tt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(o,e,n,t)=>{for(var r=t>1?void 0:t?nt(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&tt(e,n,r),r},L=(o,e)=>(n,t)=>e(n,t,o);let z=class extends a.Disposable{constructor(o,e,n,t){super(),this._sheetInterceptorService=o,this._univerInstanceService=e,this._threadCommentModel=n,this._threadCommentDataSourceService=t,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:o=>{var e;if(o.id===C.RemoveSheetCommand.id){const n=o.params,t=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return{redos:[],undos:[]};const r=t.getUnitId(),i=n.subUnitId||((e=t.getActiveSheet())==null?void 0:e.getSheetId());if(!i)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(r,i),c=Array.from(s.values()).filter(l=>!l.parentId),m=c.map(l=>l.id),d=this._threadCommentDataSourceService.syncUpdateMutationToColla,h=m.map(l=>({id:_.DeleteCommentMutation.id,params:{unitId:r,subUnitId:i,commentId:l}})),u=c.map(({children:l,...v})=>({id:_.AddCommentMutation.id,params:{unitId:r,subUnitId:i,comment:{...v,children:d?l:void 0},sync:!d}}));return{redos:h,undos:u}}return{redos:[],undos:[]}}}))}};z=rt([L(0,a.Inject(C.SheetInterceptorService)),L(1,a.IUniverInstanceService),L(2,a.Inject(_.ThreadCommentModel)),L(3,_.IThreadCommentDataSourceService)],z);var he=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,it=(o,e,n)=>e in o?he(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,st=(o,e,n,t)=>{for(var r=t>1?void 0:t?ot(e,n):e,i=o.length-1,s;i>=0;i--)(s=o[i])&&(r=(t?s(e,n,r):s(r))||r);return t&&r&&he(e,n,r),r},X=(o,e)=>(n,t)=>e(n,t,o),le=(o,e,n)=>it(o,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(e=ge,n,t,r){super(),this._config=e,this._injector=n,this._commandService=t,this._configService=r;const{menu:i,...s}=this._config;i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ie,s)}onStarting(){[[F],[W],[q],[G],[z],[Z],[exports.SheetsThreadCommentPopupService]].forEach(e=>{this._injector.add(e)}),[A].forEach(e=>{this._commandService.registerCommand(e)}),this._injector.get(F)}onReady(){this._injector.get(W),this._injector.get(z)}onRendered(){this._injector.get(q),this._injector.get(G),this._injector.get(Z)}};le(exports.UniverSheetsThreadCommentUIPlugin,"pluginName",te);le(exports.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsThreadCommentUIPlugin=st([a.DependentOn(I.UniverThreadCommentUIPlugin,N.UniverSheetsThreadCommentPlugin),X(1,a.Inject(a.Injector)),X(2,a.Inject(a.ICommandService)),X(3,a.IConfigService)],exports.UniverSheetsThreadCommentUIPlugin);Object.defineProperty(exports,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>I.IThreadCommentMentionDataService});Object.defineProperty(exports,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin});Object.defineProperty(exports,"AddCommentCommand",{enumerable:!0,get:()=>_.AddCommentCommand});Object.defineProperty(exports,"DeleteCommentCommand",{enumerable:!0,get:()=>_.DeleteCommentCommand});Object.defineProperty(exports,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>_.DeleteCommentTreeCommand});Object.defineProperty(exports,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>_.IThreadCommentDataSourceService});Object.defineProperty(exports,"ResolveCommentCommand",{enumerable:!0,get:()=>_.ResolveCommentCommand});Object.defineProperty(exports,"UpdateCommentCommand",{enumerable:!0,get:()=>_.UpdateCommentCommand});exports.SHEETS_THREAD_COMMENT=te;exports.ShowAddSheetCommentModalOperation=A;
|
package/lib/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Be = Object.defineProperty;
|
|
2
2
|
var Le = (o, e, r) => e in o ? Be(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r;
|
|
3
3
|
var E = (o, e, r) => Le(o, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { Inject as v, Disposable as $, DisposableCollection as He, CommandType as
|
|
4
|
+
import { Inject as v, Disposable as $, DisposableCollection as He, CommandType as ke, IUniverInstanceService as N, InterceptorEffectEnum as Fe, UniverInstanceType as b, useDependency as O, Tools as We, ICommandService as se, Range as Ze, RANGE_TYPE as he, Rectangle as ze, DependentOn as Ge, Injector as Ye, Plugin as qe, IConfigService as Ke } from "@univerjs/core";
|
|
5
5
|
import { SheetsSelectionsService as ve, getSheetCommandTarget as Je, SheetInterceptorService as _e, INTERCEPTOR_POINT as Qe, WorkbookCommentPermission as K, WorksheetViewPermission as J, RangeProtectionPermissionViewPoint as Q, SetWorksheetActiveOperation as Xe, RemoveSheetCommand as et } from "@univerjs/sheets";
|
|
6
6
|
import { SheetsThreadCommentModel as x, UniverSheetsThreadCommentPlugin as tt } from "@univerjs/sheets-thread-comment";
|
|
7
7
|
import { ThreadCommentPanelService as ae, ThreadCommentTree as nt, ThreadCommentPanel as rt, ToggleSheetCommentPanelOperation as fe, THREAD_COMMENT_PANEL as ot, SetActiveCommentOperation as te, UniverThreadCommentUIPlugin as it } from "@univerjs/thread-comment-ui";
|
|
@@ -12,8 +12,8 @@ import { BehaviorSubject as Pt, debounceTime as ce, map as Tt } from "rxjs";
|
|
|
12
12
|
import { IRenderManagerService as Te } from "@univerjs/engine-render";
|
|
13
13
|
import bt, { forwardRef as be, useRef as Me, createElement as we, useMemo as Mt, useCallback as le, useEffect as wt } from "react";
|
|
14
14
|
import { singleReferenceToGrid as A, serializeRange as yt } from "@univerjs/engine-formula";
|
|
15
|
-
import { IThreadCommentDataSourceService as ye, DeleteCommentMutation as
|
|
16
|
-
import { AddCommentCommand as An, DeleteCommentCommand as Vn, DeleteCommentTreeCommand as Bn, IThreadCommentDataSourceService as Ln, ResolveCommentCommand as Hn, UpdateCommentCommand as
|
|
15
|
+
import { IThreadCommentDataSourceService as ye, DeleteCommentMutation as k, AddCommentMutation as ie, ThreadCommentModel as Et } from "@univerjs/thread-comment";
|
|
16
|
+
import { AddCommentCommand as An, DeleteCommentCommand as Vn, DeleteCommentTreeCommand as Bn, IThreadCommentDataSourceService as Ln, ResolveCommentCommand as Hn, UpdateCommentCommand as kn } from "@univerjs/thread-comment";
|
|
17
17
|
const Ee = "univer.sheet.thread-comment-modal", me = "comment-single", Oe = "SHEET_THREAD_COMMENT";
|
|
18
18
|
var Ot = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, Ut = (o, e, r, t) => {
|
|
19
19
|
for (var n = t > 1 ? void 0 : t ? Rt(e, r) : e, i = o.length - 1, s; i >= 0; i--)
|
|
@@ -88,7 +88,7 @@ R = Ut([
|
|
|
88
88
|
pe(1, pt)
|
|
89
89
|
], R);
|
|
90
90
|
const V = {
|
|
91
|
-
type:
|
|
91
|
+
type: ke.OPERATION,
|
|
92
92
|
id: "sheets.operation.show-comment-modal",
|
|
93
93
|
handler(o) {
|
|
94
94
|
var _;
|
|
@@ -121,7 +121,7 @@ var xt = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, jt = (o, e
|
|
|
121
121
|
(s = o[i]) && (n = (t ? s(e, r, n) : s(n)) || n);
|
|
122
122
|
return t && n && xt(e, r, n), n;
|
|
123
123
|
}, B = (o, e) => (r, t) => e(r, t, o);
|
|
124
|
-
let
|
|
124
|
+
let F = class extends $ {
|
|
125
125
|
constructor(o, e, r, t) {
|
|
126
126
|
super(), this._sheetInterceptorService = o, this._sheetsThreadCommentModel = e, this._univerInstanceService = r, this._renderManagerService = t, this._initViewModelIntercept(), this._initSkeletonChange();
|
|
127
127
|
}
|
|
@@ -130,7 +130,7 @@ let k = class extends $ {
|
|
|
130
130
|
this._sheetInterceptorService.intercept(
|
|
131
131
|
Qe.CELL_CONTENT,
|
|
132
132
|
{
|
|
133
|
-
effect:
|
|
133
|
+
effect: Fe.Style,
|
|
134
134
|
handler: (o, e, r) => {
|
|
135
135
|
const { row: t, col: n, unitId: i, subUnitId: s } = e;
|
|
136
136
|
return this._sheetsThreadCommentModel.showCommentMarker(i, s, t, n) ? r({
|
|
@@ -162,12 +162,12 @@ let k = class extends $ {
|
|
|
162
162
|
}));
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
|
-
|
|
165
|
+
F = jt([
|
|
166
166
|
B(0, v(_e)),
|
|
167
167
|
B(1, v(x)),
|
|
168
168
|
B(2, N),
|
|
169
169
|
B(3, Te)
|
|
170
|
-
],
|
|
170
|
+
], F);
|
|
171
171
|
var P = function() {
|
|
172
172
|
return P = Object.assign || function(o) {
|
|
173
173
|
for (var e, r = 1, t = arguments.length; r < t; r++) {
|
|
@@ -229,13 +229,13 @@ var Ne = { exports: {} }, X = {};
|
|
|
229
229
|
* This source code is licensed under the MIT license found in the
|
|
230
230
|
* LICENSE file in the root directory of this source tree.
|
|
231
231
|
*/
|
|
232
|
-
var
|
|
232
|
+
var kt = bt, Ft = Symbol.for("react.element"), Wt = Symbol.for("react.fragment"), Zt = Object.prototype.hasOwnProperty, zt = kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Gt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
233
233
|
function xe(o, e, r) {
|
|
234
234
|
var t, n = {}, i = null, s = null;
|
|
235
235
|
r !== void 0 && (i = "" + r), e.key !== void 0 && (i = "" + e.key), e.ref !== void 0 && (s = e.ref);
|
|
236
236
|
for (t in e) Zt.call(e, t) && !Gt.hasOwnProperty(t) && (n[t] = e[t]);
|
|
237
237
|
if (o && o.defaultProps) for (t in e = o.defaultProps, e) n[t] === void 0 && (n[t] = e[t]);
|
|
238
|
-
return { $$typeof:
|
|
238
|
+
return { $$typeof: Ft, type: o, key: i, ref: s, props: n, _owner: zt.current };
|
|
239
239
|
}
|
|
240
240
|
X.Fragment = Wt;
|
|
241
241
|
X.jsx = xe;
|
|
@@ -298,7 +298,7 @@ const Yt = () => {
|
|
|
298
298
|
return o.addShape({
|
|
299
299
|
range: C,
|
|
300
300
|
style: {
|
|
301
|
-
hasAutoFill:
|
|
301
|
+
// hasAutoFill: false,
|
|
302
302
|
fill: "rgb(255, 189, 55, 0.35)",
|
|
303
303
|
strokeWidth: 1,
|
|
304
304
|
stroke: "#FFBD37",
|
|
@@ -463,7 +463,7 @@ let Z = class extends $ {
|
|
|
463
463
|
});
|
|
464
464
|
const _ = [], S = [], U = [], D = [], ee = (g) => {
|
|
465
465
|
_.unshift({
|
|
466
|
-
id:
|
|
466
|
+
id: k.id,
|
|
467
467
|
params: {
|
|
468
468
|
unitId: h,
|
|
469
469
|
subUnitId: d,
|
|
@@ -491,7 +491,7 @@ let Z = class extends $ {
|
|
|
491
491
|
sync: !0
|
|
492
492
|
}
|
|
493
493
|
}), D.unshift({
|
|
494
|
-
id:
|
|
494
|
+
id: k.id,
|
|
495
495
|
params: {
|
|
496
496
|
unitId: i,
|
|
497
497
|
subUnitId: s,
|
|
@@ -582,7 +582,7 @@ let G = class extends $ {
|
|
|
582
582
|
const n = (u = e[0]) == null ? void 0 : u.range, i = this._renderManagerService.getRenderById(r), s = (p = i == null ? void 0 : i.with(ut).getWorksheetSkeleton(t)) == null ? void 0 : p.skeleton;
|
|
583
583
|
if (!s || !n)
|
|
584
584
|
return;
|
|
585
|
-
const a = s.
|
|
585
|
+
const a = s.getCellWithCoordByIndex(n.startRow, n.startColumn);
|
|
586
586
|
if ((((_ = n.rangeType) != null ? _ : he.NORMAL) !== he.NORMAL || n.endColumn - n.startColumn > 0 || n.endRow - n.startRow > 0) && !((a.isMerged || a.isMergedMainCell) && ze.equals(a.mergeInfo, n))) {
|
|
587
587
|
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(te.id);
|
|
588
588
|
return;
|
|
@@ -618,7 +618,7 @@ let G = class extends $ {
|
|
|
618
618
|
}
|
|
619
619
|
_initCommandListener() {
|
|
620
620
|
this._commandService.onCommandExecuted((e) => {
|
|
621
|
-
if (e.id ===
|
|
621
|
+
if (e.id === k.id) {
|
|
622
622
|
const r = e.params, t = this._sheetsThreadCommentPopupService.activePopup;
|
|
623
623
|
if (!t)
|
|
624
624
|
return;
|
|
@@ -694,7 +694,7 @@ let G = class extends $ {
|
|
|
694
694
|
{
|
|
695
695
|
range: h,
|
|
696
696
|
style: {
|
|
697
|
-
hasAutoFill:
|
|
697
|
+
// hasAutoFill: false,
|
|
698
698
|
fill: "rgb(255, 189, 55, 0.35)",
|
|
699
699
|
strokeWidth: 1,
|
|
700
700
|
stroke: "#FFBD37",
|
|
@@ -746,7 +746,7 @@ let Y = class extends $ {
|
|
|
746
746
|
if (!i)
|
|
747
747
|
return { redos: [], undos: [] };
|
|
748
748
|
const s = this._threadCommentModel.ensureMap(n, i), a = Array.from(s.values()).filter((u) => !u.parentId), c = a.map((u) => u.id), m = this._threadCommentDataSourceService.syncUpdateMutationToColla, h = c.map((u) => ({
|
|
749
|
-
id:
|
|
749
|
+
id: k.id,
|
|
750
750
|
params: {
|
|
751
751
|
unitId: n,
|
|
752
752
|
subUnitId: i,
|
|
@@ -792,7 +792,7 @@ let q = class extends qe {
|
|
|
792
792
|
onStarting() {
|
|
793
793
|
[
|
|
794
794
|
[W],
|
|
795
|
-
[
|
|
795
|
+
[F],
|
|
796
796
|
[Z],
|
|
797
797
|
[z],
|
|
798
798
|
[Y],
|
|
@@ -805,7 +805,7 @@ let q = class extends qe {
|
|
|
805
805
|
}), this._injector.get(W);
|
|
806
806
|
}
|
|
807
807
|
onReady() {
|
|
808
|
-
this._injector.get(
|
|
808
|
+
this._injector.get(F), this._injector.get(Y);
|
|
809
809
|
}
|
|
810
810
|
onRendered() {
|
|
811
811
|
this._injector.get(Z), this._injector.get(z), this._injector.get(G);
|
|
@@ -831,5 +831,5 @@ export {
|
|
|
831
831
|
V as ShowAddSheetCommentModalOperation,
|
|
832
832
|
q as UniverSheetsThreadCommentUIPlugin,
|
|
833
833
|
Dn as UniverThreadCommentUIPlugin,
|
|
834
|
-
|
|
834
|
+
kn as UpdateCommentCommand
|
|
835
835
|
};
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/engine-formula","@univerjs/thread-comment"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.React,c.UniverEngineFormula,c.UniverThreadComment))})(this,function(c,a,p,A,I,g,f,k,re,E,$,C){"use strict";var st=Object.defineProperty;var at=(c,a,p)=>a in c?st(c,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[a]=p;var N=(c,a,p)=>at(c,typeof a!="symbol"?a+"":a,p);const ie="univer.sheet.thread-comment-modal",J="comment-single",Q="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,_e=(i,t,r,e)=>{for(var n=e>1?void 0:e?Se(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ve(t,r,n),n},oe=(i,t)=>(r,e)=>t(r,e,i);c.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:n,col:o,unitId:s,subUnitId:
|
|
1
|
+
(function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-thread-comment"),require("@univerjs/thread-comment-ui"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/thread-comment")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-thread-comment","@univerjs/thread-comment-ui","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/engine-formula","@univerjs/thread-comment"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverSheetsThreadCommentUi={},c.UniverCore,c.UniverSheets,c.UniverSheetsThreadComment,c.UniverThreadCommentUi,c.UniverSheetsUi,c.UniverUi,c.rxjs,c.UniverEngineRender,c.React,c.UniverEngineFormula,c.UniverThreadComment))})(this,function(c,a,p,A,I,g,f,k,re,E,$,C){"use strict";var st=Object.defineProperty;var at=(c,a,p)=>a in c?st(c,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[a]=p;var N=(c,a,p)=>at(c,typeof a!="symbol"?a+"":a,p);const ie="univer.sheet.thread-comment-modal",J="comment-single",Q="SHEET_THREAD_COMMENT";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,_e=(i,t,r,e)=>{for(var n=e>1?void 0:e?Se(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ve(t,r,n),n},oe=(i,t)=>(r,e)=>t(r,e,i);c.SheetsThreadCommentPopupService=class extends a.Disposable{constructor(r,e){super();N(this,"_lastPopup",null);N(this,"_activePopup");N(this,"_activePopup$",new k.BehaviorSubject(null));N(this,"activePopup$",this._activePopup$.asObservable());this._canvasPopupManagerService=r,this._zenZoneService=e,this._initZenVisible(),this.disposeWithMe(()=>{this._activePopup$.complete()})}get activePopup(){return this._activePopup}_initZenVisible(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(r=>{r&&this.hidePopup()}))}showPopup(r,e){var l;const{row:n,col:o,unitId:s,subUnitId:d}=r;if(this._activePopup&&n===this._activePopup.row&&o===this._activePopup.col&&s===this._activePopup.unitId&&d===((l=this.activePopup)==null?void 0:l.subUnitId)){this._activePopup=r,this._activePopup$.next(r);return}if(this._lastPopup&&this._lastPopup.dispose(),this._zenZoneService.visible)return;this._activePopup=r,this._activePopup$.next(r);const u=this._canvasPopupManagerService.attachPopupToCell(n,o,{componentKey:ie,onClickOutside:()=>{this.hidePopup()},direction:"horizontal",excludeOutside:[...Array.from(document.querySelectorAll(".univer-thread-comment")),document.getElementById("thread-comment-add")].filter(Boolean)});if(!u)throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");const m=new a.DisposableCollection;m.add(u),m.add({dispose:()=>{e==null||e()}}),this._lastPopup=m}hidePopup(){this._activePopup&&(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}},c.SheetsThreadCommentPopupService=_e([oe(0,a.Inject(g.SheetCanvasPopManagerService)),oe(1,f.IZenZoneService)],c.SheetsThreadCommentPopupService);const B={type:a.CommandType.OPERATION,id:"sheets.operation.show-comment-modal",handler(i){var P;const t=i.get(p.SheetsSelectionsService),r=i.get(a.IUniverInstanceService),e=i.get(c.SheetsThreadCommentPopupService),n=i.get(I.ThreadCommentPanelService),o=(P=t.getCurrentLastSelection())==null?void 0:P.primary,s=i.get(A.SheetsThreadCommentModel);if(!o)return!1;const d=p.getSheetCommandTarget(r);if(!d)return!1;const{workbook:u,worksheet:m,unitId:l,subUnitId:h}=d,v={workbook:u,worksheet:m,unitId:l,subUnitId:h,row:o.startRow,col:o.startColumn};e.showPopup(v);const _=s.getByLocation(l,h,o.startRow,o.startColumn);return _&&n.setActiveComment({unitId:l,subUnitId:h,commentId:_,trigger:"context-menu"}),!0}},fe="sheets-thread-comment.config",Ce={};var Ie=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Pe=(i,t,r,e)=>{for(var n=e>1?void 0:e?ge(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Ie(t,r,n),n},L=(i,t)=>(r,e)=>t(r,e,i);let x=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._sheetsThreadCommentModel=t,this._univerInstanceService=r,this._renderManagerService=e,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(i,t,r)=>{const{row:e,col:n,unitId:o,subUnitId:s}=t;return this._sheetsThreadCommentModel.showCommentMarker(o,s,e,n)?r({...i,markers:{...i==null?void 0:i.markers,tr:{color:"#FFBD37",size:6}}}):r(i)},priority:100}))}_initSkeletonChange(){const i=()=>{var n;const t=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!t)return;const r=t.getUnitId(),e=this._renderManagerService.getRenderById(r);(n=e==null?void 0:e.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(k.debounceTime(16)).subscribe(()=>{i()}))}};x=Pe([L(0,a.Inject(p.SheetInterceptorService)),L(1,a.Inject(A.SheetsThreadCommentModel)),L(2,a.IUniverInstanceService),L(3,re.IRenderManagerService)],x);var y=function(){return y=Object.assign||function(i){for(var t,r=1,e=arguments.length;r<e;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},y.apply(this,arguments)},Te=function(i,t){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)t.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(r[e[n]]=i[e[n]]);return r},se=E.forwardRef(function(i,t){var r=i.icon,e=i.id,n=i.className,o=i.extend,s=Te(i,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),u=E.useRef("_".concat(Me()));return ae(r,"".concat(e),{defIds:r.defIds,idSuffix:u.current},y({ref:t,className:d},s),o)});function ae(i,t,r,e,n){return E.createElement(i.tag,y(y({key:t},be(i,r,n)),e),(ye(i,r).children||[]).map(function(o,s){return ae(o,"".concat(t,"-").concat(i.tag,"-").concat(s),r,void 0,n)}))}function be(i,t,r){var e=y({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var n=t.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(e[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ye(i,t){var r,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?y(y({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?y(y({},n),{attrs:y(y({},n.attrs),{id:n.attrs.id+t.idSuffix})}):n})}):i}function Me(){return Math.random().toString(36).substring(2,8)}se.displayName="UniverIcon";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=E.forwardRef(function(i,t){return E.createElement(se,Object.assign({},i,{id:"comment-single",ref:t,icon:we}))});ce.displayName="CommentSingle";var de={exports:{}},W={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Oe=E,Ee=Symbol.for("react.element"),Re=Symbol.for("react.fragment"),Ue=Object.prototype.hasOwnProperty,je=Oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,De={key:!0,ref:!0,__self:!0,__source:!0};function de(i,t,r){var e,n={},o=null,s=null;r!==void 0&&(o=""+r),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)Ue.call(t,e)&&!De.hasOwnProperty(e)&&(n[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)n[e]===void 0&&(n[e]=t[e]);return{$$typeof:Ee,type:i,key:o,ref:s,props:n,_owner:je.current}}W.Fragment=Re,W.jsx=de,W.jsxs=de,ue.exports=W;var me=ue.exports;const Ne=()=>{const i=a.useDependency(a.IUniverInstanceService),t=a.useDependency(c.SheetsThreadCommentPopupService),r=f.useObservable(t.activePopup$),e=a.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!r)return null;const{row:n,col:o,unitId:s,subUnitId:u,trigger:d}=r,m=e.getByLocation(s,u,n,o),l=`${a.Tools.chatAtABC(o)}${n+1}`,h=()=>{t.hidePopup()},v=_=>{var P,M,V;return(V=(M=(P=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:P.getSheetBySheetId(_))==null?void 0:M.getName())!=null?V:""};return me.jsx(I.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:s,subUnitId:u,type:a.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:v,autoFocus:d==="context-menu"})},Ae=()=>{var w;const i=a.useDependency(g.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),r=a.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),o=a.useDependency(a.ICommandService),s=E.useMemo(()=>e.activeSheet$.pipe(k.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),u=f.useObservable(s,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),d=E.useRef(),m=a.useDependency(I.ThreadCommentPanelService),l=f.useObservable(m.activeCommentId$),h=f.useObservable(m.panelVisible$,m.panelVisible),v=E.useCallback(S=>{const O=e.getSheets(),T={};O.forEach((R,b)=>{T[R.getSheetId()]=b});const j=R=>R.map(b=>{var pe;const D=$.singleReferenceToGrid(b.ref),ot=[(pe=T[b.subUnitId])!=null?pe:0,D.row,D.column];return{...b,p:ot}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(S.filter(R=>!R.resolved)),...j(S.filter(R=>R.resolved))]},[e]),_=E.useCallback(S=>{var O;if(S.unitId===n&&S.subUnitId===u&&!S.resolved){const{row:T,column:j}=$.singleReferenceToGrid(S.ref),R=e.getSheetBySheetId(S.subUnitId),b=(O=R==null?void 0:R.getMergedCell(T,j))!=null?O:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,u,n]),P=S=>{var O,T;return(T=(O=e.getSheetBySheetId(S))==null?void 0:O.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=S=>{l&&l.unitId===S.unitId&&l.subUnitId===S.subUnitId&&l.commentId===S.id||(d.current&&(i.removeShape(d.current),d.current=null),d.current=_(S))},H=()=>{d.current&&(i.removeShape(d.current),d.current=null)},ne=(S,O)=>{O&&r.hidePopup()};return E.useEffect(()=>{!h&&d.current&&i.removeShape(d.current)},[i,h]),me.jsx(I.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:P,onResolve:ne,sortComments:v,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ve=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:J,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),$e=i=>({id:I.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:J,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}),Be={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},ke={[f.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:$e}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ve}}}};var He=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,xe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Le(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&He(t,r,n),n},X=(i,t)=>(r,e)=>t(r,e,i);let F=class extends a.Disposable{constructor(i,t,r){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Be)}_initMenu(){this._menuManagerService.mergeMenu(ke)}_initComponent(){[[ie,Ne],[I.THREAD_COMMENT_PANEL,Ae],[J,ce]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};F=xe([X(0,f.IMenuManagerService),X(1,a.Inject(f.ComponentManager)),X(2,f.IShortcutService)],F);var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Ge=(i,t,r,e)=>{for(var n=e>1?void 0:e?Fe(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&We(t,r,n),n},ee=(i,t)=>(r,e)=>t(r,e,i);const Ze=(i,t,r)=>{const e=$.singleReferenceToGrid(i),n=r.row-t.row,o=r.column-t.column,s={startColumn:e.column+o,startRow:e.row+n,endColumn:e.column+o,endRow:e.row+n};return $.serializeRange(s)};let G=class extends a.Disposable{constructor(t,r,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,n)=>{const{unitId:o,subUnitId:s,range:u}=r,d={row:u.rows[0],column:u.cols[0]};if(n.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,v={row:m.startRow,column:m.startColumn};if(!(o===l&&s===h)){const _=[];a.Range.foreach(m,(w,S)=>{const O=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?O.forEach(T=>{_.push(T)}):O.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const P=[],M=[],V=[],H=[],ne=w=>{P.unshift({id:C.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...w,ref:Ze(w.ref,v,d),unitId:o,subUnitId:s},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:w.id}})};return _.forEach(w=>{ne(w)}),{redos:[...P,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};G=Ge([ee(0,a.Inject(g.ISheetClipboardService)),ee(1,a.Inject(A.SheetsThreadCommentModel)),ee(2,C.IThreadCommentDataSourceService)],G);var ze=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ke=(i,t,r,e)=>{for(var n=e>1?void 0:e?Ye(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ze(t,r,n),n},Z=(i,t)=>(r,e)=>t(r,e,i);let z=class extends a.Disposable{constructor(i,t,r,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:r}=i,{unitId:e,subUnitId:n,row:o,col:s}=r,u=this._sheetsThreadCommentModel.getByLocation(e,n,o,s);if(u){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const m=this._sheetsThreadCommentModel.getComment(e,n,u);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:o,col:s,commentId:u,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};z=Ke([Z(0,a.Inject(g.HoverManagerService)),Z(1,a.Inject(c.SheetsThreadCommentPopupService)),Z(2,a.Inject(A.SheetsThreadCommentModel)),Z(3,a.Inject(g.SheetPermissionInterceptorBaseController))],z);var qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Je(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&qe(t,r,n),n},U=(i,t)=>(r,e)=>t(r,e,i);let Y=class extends a.Disposable{constructor(t,r,e,n,o,s,u,d,m,l){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=n,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=u,this._sheetSelectionService=d,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var v,_,P;const n=(v=t[0])==null?void 0:v.range,o=this._renderManagerService.getRenderById(r),s=(_=o==null?void 0:o.with(g.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:_.skeleton;if(!s||!n)return;const u=s.getCellByIndex(n.startRow,n.startColumn);if((((P=n.rangeType)!=null?P:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||n.endColumn-n.startColumn>0||n.endRow-n.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&a.Rectangle.equals(u.mergeInfo,n))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const m=u.actualRow,l=u.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:n,subUnitId:o,commentId:s}=e;r.unitId===n&&r.subUnitId===o&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:n,commentId:o,trigger:s}=t,u=this._sheetsThreadCommentModel.getComment(e,n,o);if(!u||u.resolved)return;const d=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d||d.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=d.getActiveSheet())==null?void 0:r.getSheetId())!==n&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:n}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(u.ref),{row:v,column:_}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:_,endRow:v,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(g.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:h.row,col:h.column,commentId:u.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var v,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:n}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,n);if(!o)return;const s=$.singleReferenceToGrid(o.ref),{row:u,column:d}=s;if(Number.isNaN(u)||Number.isNaN(d))return null;const m=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(u,d))!=null?_:{startColumn:d,endColumn:d,startRow:u,endRow:u},h=this._markSelectionService.addShape({range:l,style:{hasAutoFill:!1,fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Y=Qe([U(0,a.ICommandService),U(1,a.Inject(c.SheetsThreadCommentPopupService)),U(2,a.Inject(A.SheetsThreadCommentModel)),U(3,a.Inject(I.ThreadCommentPanelService)),U(4,a.IUniverInstanceService),U(5,a.Inject(g.SheetPermissionInterceptorBaseController)),U(6,g.IMarkSelectionService),U(7,a.Inject(p.SheetsSelectionsService)),U(8,g.IEditorBridgeService),U(9,re.IRenderManagerService)],Y);var Xe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(i,t,r,e)=>{for(var n=e>1?void 0:e?et(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Xe(t,r,n),n},K=(i,t)=>(r,e)=>t(r,e,i);let q=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===p.RemoveSheetCommand.id){const r=i.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const n=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(n,o),u=Array.from(s.values()).filter(v=>!v.parentId),d=u.map(v=>v.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=d.map(v=>({id:C.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:v}})),h=u.map(({children:v,..._})=>({id:C.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:{..._,children:m?v:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};q=tt([K(0,a.Inject(p.SheetInterceptorService)),K(1,a.IUniverInstanceService),K(2,a.Inject(C.ThreadCommentModel)),K(3,C.IThreadCommentDataSourceService)],q);var he=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(i,t,r)=>t in i?he(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r,it=(i,t,r,e)=>{for(var n=e>1?void 0:e?nt(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&he(t,r,n),n},te=(i,t)=>(r,e)=>t(r,e,i),le=(i,t,r)=>rt(i,typeof t!="symbol"?t+"":t,r);c.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=Ce,r,e,n){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=n;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(fe,s)}onStarting(){[[F],[x],[G],[z],[q],[Y],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(F)}onReady(){this._injector.get(x),this._injector.get(q)}onRendered(){this._injector.get(G),this._injector.get(z),this._injector.get(Y)}},le(c.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),le(c.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=it([a.DependentOn(I.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),te(1,a.Inject(a.Injector)),te(2,a.Inject(a.ICommandService)),te(3,a.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>I.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=Q,c.ShowAddSheetCommentModalOperation=B,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var Oe=E,Ee=Symbol.for("react.element"),Re=Symbol.for("react.fragment"),Ue=Object.prototype.hasOwnProperty,je=Oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,De={key:!0,ref:!0,__self:!0,__source:!0};function ue(i,t,r){var e,n={},o=null,s=null;r!==void 0&&(o=""+r),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(e in t)Ue.call(t,e)&&!De.hasOwnProperty(e)&&(n[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)n[e]===void 0&&(n[e]=t[e]);return{$$typeof:Ee,type:i,key:o,ref:s,props:n,_owner:je.current}}W.Fragment=Re,W.jsx=ue,W.jsxs=ue,de.exports=W;var me=de.exports;const Ne=()=>{const i=a.useDependency(a.IUniverInstanceService),t=a.useDependency(c.SheetsThreadCommentPopupService),r=f.useObservable(t.activePopup$),e=a.useDependency(A.SheetsThreadCommentModel);if(f.useObservable(e.commentUpdate$),!r)return null;const{row:n,col:o,unitId:s,subUnitId:d,trigger:u}=r,m=e.getByLocation(s,d,n,o),l=`${a.Tools.chatAtABC(o)}${n+1}`,h=()=>{t.hidePopup()},v=_=>{var P,M,V;return(V=(M=(P=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:P.getSheetBySheetId(_))==null?void 0:M.getName())!=null?V:""};return me.jsx(I.ThreadCommentTree,{onClick:()=>{t.persistPopup()},prefix:"cell",id:m,unitId:s,subUnitId:d,type:a.UniverInstanceType.UNIVER_SHEET,refStr:l,onClose:h,getSubUnitName:v,autoFocus:u==="context-menu"})},Ae=()=>{var w;const i=a.useDependency(g.IMarkSelectionService),t=a.useDependency(a.IUniverInstanceService),r=a.useDependency(c.SheetsThreadCommentPopupService),e=t.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=e.getUnitId(),o=a.useDependency(a.ICommandService),s=E.useMemo(()=>e.activeSheet$.pipe(k.map(S=>S==null?void 0:S.getSheetId())),[e.activeSheet$]),d=f.useObservable(s,(w=e.getActiveSheet())==null?void 0:w.getSheetId()),u=E.useRef(),m=a.useDependency(I.ThreadCommentPanelService),l=f.useObservable(m.activeCommentId$),h=f.useObservable(m.panelVisible$,m.panelVisible),v=E.useCallback(S=>{const O=e.getSheets(),T={};O.forEach((R,b)=>{T[R.getSheetId()]=b});const j=R=>R.map(b=>{var pe;const D=$.singleReferenceToGrid(b.ref),ot=[(pe=T[b.subUnitId])!=null?pe:0,D.row,D.column];return{...b,p:ot}}).sort((b,D)=>b.p[0]===D.p[0]?b.p[1]===D.p[1]?b.p[2]-D.p[2]:b.p[1]-D.p[1]:b.p[0]-D.p[0]);return[...j(S.filter(R=>!R.resolved)),...j(S.filter(R=>R.resolved))]},[e]),_=E.useCallback(S=>{var O;if(S.unitId===n&&S.subUnitId===d&&!S.resolved){const{row:T,column:j}=$.singleReferenceToGrid(S.ref),R=e.getSheetBySheetId(S.subUnitId),b=(O=R==null?void 0:R.getMergedCell(T,j))!=null?O:{startColumn:j,endColumn:j,startRow:T,endRow:T};if(!Number.isNaN(T)&&!Number.isNaN(j))return i.addShape({range:b,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null})}},[i,d,n]),P=S=>{var O,T;return(T=(O=e.getSheetBySheetId(S))==null?void 0:O.getName())!=null?T:""},M=()=>{o.executeCommand(B.id)},V=S=>{l&&l.unitId===S.unitId&&l.subUnitId===S.subUnitId&&l.commentId===S.id||(u.current&&(i.removeShape(u.current),u.current=null),u.current=_(S))},H=()=>{u.current&&(i.removeShape(u.current),u.current=null)},ne=(S,O)=>{O&&r.hidePopup()};return E.useEffect(()=>{!h&&u.current&&i.removeShape(u.current)},[i,h]),me.jsx(I.ThreadCommentPanel,{unitId:n,subUnitId$:s,type:a.UniverInstanceType.UNIVER_SHEET,onAdd:M,getSubUnitName:P,onResolve:ne,sortComments:v,onItemEnter:V,onItemLeave:H,onDeleteComment:()=>(H(),!0)})},Ve=i=>({id:B.id,type:f.MenuItemType.BUTTON,icon:J,title:"sheetThreadComment.menu.addComment",hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:g.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]})}),$e=i=>({id:I.ToggleSheetCommentPanelOperation.id,type:f.MenuItemType.BUTTON,icon:J,tooltip:"sheetThreadComment.menu.commentManagement",disabled$:g.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]}),hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}),Be={id:B.id,binding:f.KeyCode.M|f.MetaKeys.CTRL_COMMAND|f.MetaKeys.ALT,preconditions:g.whenSheetEditorFocused},ke={[f.RibbonStartGroup.OTHERS]:{[I.ToggleSheetCommentPanelOperation.id]:{order:1,menuItemFactory:$e}},[f.ContextMenuPosition.MAIN_AREA]:{[f.ContextMenuGroup.OTHERS]:{[B.id]:{order:0,menuItemFactory:Ve}}}};var He=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,xe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Le(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&He(t,r,n),n},X=(i,t)=>(r,e)=>t(r,e,i);let F=class extends a.Disposable{constructor(i,t,r){super(),this._menuManagerService=i,this._componentManager=t,this._shortcutService=r,this._initMenu(),this._initShortcut(),this._initComponent()}_initShortcut(){this._shortcutService.registerShortcut(Be)}_initMenu(){this._menuManagerService.mergeMenu(ke)}_initComponent(){[[ie,Ne],[I.THREAD_COMMENT_PANEL,Ae],[J,ce]].forEach(([i,t])=>{this._componentManager.register(i,t)})}};F=xe([X(0,f.IMenuManagerService),X(1,a.Inject(f.ComponentManager)),X(2,f.IShortcutService)],F);var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Ge=(i,t,r,e)=>{for(var n=e>1?void 0:e?Fe(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&We(t,r,n),n},ee=(i,t)=>(r,e)=>t(r,e,i);const Ze=(i,t,r)=>{const e=$.singleReferenceToGrid(i),n=r.row-t.row,o=r.column-t.column,s={startColumn:e.column+o,startRow:e.row+n,endColumn:e.column+o,endRow:e.row+n};return $.serializeRange(s)};let G=class extends a.Disposable{constructor(t,r,e){super();N(this,"_copyInfo");this._sheetClipboardService=t,this._sheetsThreadCommentModel=r,this._threadCommentDataSourceService=e,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:Q,onBeforeCopy:(t,r,e)=>{this._copyInfo={unitId:t,subUnitId:r,range:e}},onPasteCells:(t,r,e,n)=>{const{unitId:o,subUnitId:s,range:d}=r,u={row:d.rows[0],column:d.cols[0]};if(n.copyType===g.COPY_TYPE.CUT&&this._copyInfo){const{range:m,unitId:l,subUnitId:h}=this._copyInfo,v={row:m.startRow,column:m.startColumn};if(!(o===l&&s===h)){const _=[];a.Range.foreach(m,(w,S)=>{const O=this._sheetsThreadCommentModel.getAllByLocation(l,h,w,S);this._threadCommentDataSourceService.syncUpdateMutationToColla?O.forEach(T=>{_.push(T)}):O.forEach(({children:T,...j})=>{j.parentId||_.push(j)})});const P=[],M=[],V=[],H=[],ne=w=>{P.unshift({id:C.DeleteCommentMutation.id,params:{unitId:l,subUnitId:h,commentId:w.id}}),V.push({id:C.AddCommentMutation.id,params:{unitId:o,subUnitId:s,comment:{...w,ref:Ze(w.ref,v,u),unitId:o,subUnitId:s},sync:!0}}),M.push({id:C.AddCommentMutation.id,params:{unitId:l,subUnitId:h,comment:w,sync:!0}}),H.unshift({id:C.DeleteCommentMutation.id,params:{unitId:o,subUnitId:s,commentId:w.id}})};return _.forEach(w=>{ne(w)}),{redos:[...P,...V],undos:[...H,...M]}}}return{redos:[],undos:[]}}}))}};G=Ge([ee(0,a.Inject(g.ISheetClipboardService)),ee(1,a.Inject(A.SheetsThreadCommentModel)),ee(2,C.IThreadCommentDataSourceService)],G);var ze=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ke=(i,t,r,e)=>{for(var n=e>1?void 0:e?Ye(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&ze(t,r,n),n},Z=(i,t)=>(r,e)=>t(r,e,i);let z=class extends a.Disposable{constructor(i,t,r,e){super(),this._hoverManagerService=i,this._sheetsThreadCommentPopupService=t,this._sheetsThreadCommentModel=r,this._sheetPermissionInterceptorBaseController=e,this._initHoverEvent()}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(k.debounceTime(100)).subscribe(i=>{const t=this._sheetsThreadCommentPopupService.activePopup;if(i&&(t&&t.temp||!t)){const{location:r}=i,{unitId:e,subUnitId:n,row:o,col:s}=r,d=this._sheetsThreadCommentModel.getByLocation(e,n,o,s);if(d){if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:o,startColumn:s,endRow:o,endColumn:s}]))return;const m=this._sheetsThreadCommentModel.getComment(e,n,d);m&&!m.resolved&&this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:o,col:s,commentId:d,temp:!0})}else t&&this._sheetsThreadCommentPopupService.hidePopup()}}))}};z=Ke([Z(0,a.Inject(g.HoverManagerService)),Z(1,a.Inject(c.SheetsThreadCommentPopupService)),Z(2,a.Inject(A.SheetsThreadCommentModel)),Z(3,a.Inject(g.SheetPermissionInterceptorBaseController))],z);var qe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,t,r,e)=>{for(var n=e>1?void 0:e?Je(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&qe(t,r,n),n},U=(i,t)=>(r,e)=>t(r,e,i);let Y=class extends a.Disposable{constructor(t,r,e,n,o,s,d,u,m,l){super();N(this,"_isSwitchToCommenting",!1);N(this,"_selectionShapeInfo",null);this._commandService=t,this._sheetsThreadCommentPopupService=r,this._sheetsThreadCommentModel=e,this._threadCommentPanelService=n,this._univerInstanceService=o,this._sheetPermissionInterceptorBaseController=s,this._markSelectionService=d,this._sheetSelectionService=u,this._editorBridgeService=m,this._renderManagerService=l,this._initCommandListener(),this._initPanelListener(),this._initMarkSelection(),this._initSelectionUpdateListener(),this._initEditorBridge()}_handleSelectionChange(t,r,e){var v,_,P;const n=(v=t[0])==null?void 0:v.range,o=this._renderManagerService.getRenderById(r),s=(_=o==null?void 0:o.with(g.SheetSkeletonManagerService).getWorksheetSkeleton(e))==null?void 0:_.skeleton;if(!s||!n)return;const d=s.getCellWithCoordByIndex(n.startRow,n.startColumn);if((((P=n.rangeType)!=null?P:a.RANGE_TYPE.NORMAL)!==a.RANGE_TYPE.NORMAL||n.endColumn-n.startColumn>0||n.endRow-n.startRow>0)&&!((d.isMerged||d.isMergedMainCell)&&a.Rectangle.equals(d.mergeInfo,n))){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const m=d.actualRow,l=d.actualColumn;if(!this._sheetsThreadCommentModel.showCommentMarker(r,e,m,l)){this._threadCommentPanelService.activeCommentId&&this._commandService.executeCommand(I.SetActiveCommentOperation.id);return}const h=this._sheetsThreadCommentModel.getByLocation(r,e,m,l);h&&this._commandService.executeCommand(I.SetActiveCommentOperation.id,{unitId:r,subUnitId:e,commentId:h})}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(t=>{if(this._isSwitchToCommenting)return;const r=this._sheetSelectionService.currentSelectionParam;r&&this._handleSelectionChange(t,r.unitId,r.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{t.visible&&this._sheetsThreadCommentPopupService.hidePopup()}))}_initCommandListener(){this._commandService.onCommandExecuted(t=>{if(t.id===C.DeleteCommentMutation.id){const r=t.params,e=this._sheetsThreadCommentPopupService.activePopup;if(!e)return;const{unitId:n,subUnitId:o,commentId:s}=e;r.unitId===n&&r.subUnitId===o&&r.commentId===s&&this._sheetsThreadCommentPopupService.hidePopup()}})}_initPanelListener(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async t=>{var r;if(t){const{unitId:e,subUnitId:n,commentId:o,trigger:s}=t,d=this._sheetsThreadCommentModel.getComment(e,n,o);if(!d||d.resolved)return;const u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!u||u.getUnitId()!==e)return;this._isSwitchToCommenting=!0,((r=u.getActiveSheet())==null?void 0:r.getSheetId())!==n&&await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:n}),this._isSwitchToCommenting=!1;const h=$.singleReferenceToGrid(d.ref),{row:v,column:_}=h;if(!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookCommentPermission],worksheetTypes:[p.WorksheetViewPermission],rangeTypes:[p.RangeProtectionPermissionViewPoint]},[{startRow:v,startColumn:_,endRow:v,endColumn:_}]))return;const M=1;if(await this._commandService.executeCommand(g.ScrollToRangeOperation.id,{range:{startRow:Math.max(h.row-M,0),endRow:h.row+M,startColumn:Math.max(h.column-M,0),endColumn:h.column+M}}),this._editorBridgeService.isVisible().visible)return;this._sheetsThreadCommentPopupService.showPopup({unitId:e,subUnitId:n,row:h.row,col:h.column,commentId:d.id,trigger:s})}else this._sheetsThreadCommentPopupService.hidePopup()}))}_initMarkSelection(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(k.debounceTime(100)).subscribe(t=>{var v,_;if(!t){this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);return}const{unitId:r,subUnitId:e,commentId:n}=t;this._selectionShapeInfo&&(this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId),this._selectionShapeInfo=null);const o=this._sheetsThreadCommentModel.getComment(r,e,n);if(!o)return;const s=$.singleReferenceToGrid(o.ref),{row:d,column:u}=s;if(Number.isNaN(d)||Number.isNaN(u))return null;const m=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getSheetBySheetId(e),l=(_=m==null?void 0:m.getMergedCell(d,u))!=null?_:{startColumn:u,endColumn:u,startRow:d,endRow:d},h=this._markSelectionService.addShape({range:l,style:{fill:"rgb(255, 189, 55, 0.35)",strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1);h&&(this._selectionShapeInfo={...t,shapeId:h})}))}};Y=Qe([U(0,a.ICommandService),U(1,a.Inject(c.SheetsThreadCommentPopupService)),U(2,a.Inject(A.SheetsThreadCommentModel)),U(3,a.Inject(I.ThreadCommentPanelService)),U(4,a.IUniverInstanceService),U(5,a.Inject(g.SheetPermissionInterceptorBaseController)),U(6,g.IMarkSelectionService),U(7,a.Inject(p.SheetsSelectionsService)),U(8,g.IEditorBridgeService),U(9,re.IRenderManagerService)],Y);var Xe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(i,t,r,e)=>{for(var n=e>1?void 0:e?et(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&Xe(t,r,n),n},K=(i,t)=>(r,e)=>t(r,e,i);let q=class extends a.Disposable{constructor(i,t,r,e){super(),this._sheetInterceptorService=i,this._univerInstanceService=t,this._threadCommentModel=r,this._threadCommentDataSourceService=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{var t;if(i.id===p.RemoveSheetCommand.id){const r=i.params,e=r.unitId?this._univerInstanceService.getUnit(r.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const n=e.getUnitId(),o=r.subUnitId||((t=e.getActiveSheet())==null?void 0:t.getSheetId());if(!o)return{redos:[],undos:[]};const s=this._threadCommentModel.ensureMap(n,o),d=Array.from(s.values()).filter(v=>!v.parentId),u=d.map(v=>v.id),m=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=u.map(v=>({id:C.DeleteCommentMutation.id,params:{unitId:n,subUnitId:o,commentId:v}})),h=d.map(({children:v,..._})=>({id:C.AddCommentMutation.id,params:{unitId:n,subUnitId:o,comment:{..._,children:m?v:void 0},sync:!m}}));return{redos:l,undos:h}}return{redos:[],undos:[]}}}))}};q=tt([K(0,a.Inject(p.SheetInterceptorService)),K(1,a.IUniverInstanceService),K(2,a.Inject(C.ThreadCommentModel)),K(3,C.IThreadCommentDataSourceService)],q);var he=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(i,t,r)=>t in i?he(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r,it=(i,t,r,e)=>{for(var n=e>1?void 0:e?nt(t,r):t,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(e?s(t,r,n):s(n))||n);return e&&n&&he(t,r,n),n},te=(i,t)=>(r,e)=>t(r,e,i),le=(i,t,r)=>rt(i,typeof t!="symbol"?t+"":t,r);c.UniverSheetsThreadCommentUIPlugin=class extends a.Plugin{constructor(t=Ce,r,e,n){super(),this._config=t,this._injector=r,this._commandService=e,this._configService=n;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(fe,s)}onStarting(){[[F],[x],[G],[z],[q],[Y],[c.SheetsThreadCommentPopupService]].forEach(t=>{this._injector.add(t)}),[B].forEach(t=>{this._commandService.registerCommand(t)}),this._injector.get(F)}onReady(){this._injector.get(x),this._injector.get(q)}onRendered(){this._injector.get(G),this._injector.get(z),this._injector.get(Y)}},le(c.UniverSheetsThreadCommentUIPlugin,"pluginName",Q),le(c.UniverSheetsThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),c.UniverSheetsThreadCommentUIPlugin=it([a.DependentOn(I.UniverThreadCommentUIPlugin,A.UniverSheetsThreadCommentPlugin),te(1,a.Inject(a.Injector)),te(2,a.Inject(a.ICommandService)),te(3,a.IConfigService)],c.UniverSheetsThreadCommentUIPlugin),Object.defineProperty(c,"IThreadCommentMentionDataService",{enumerable:!0,get:()=>I.IThreadCommentMentionDataService}),Object.defineProperty(c,"UniverThreadCommentUIPlugin",{enumerable:!0,get:()=>I.UniverThreadCommentUIPlugin}),Object.defineProperty(c,"AddCommentCommand",{enumerable:!0,get:()=>C.AddCommentCommand}),Object.defineProperty(c,"DeleteCommentCommand",{enumerable:!0,get:()=>C.DeleteCommentCommand}),Object.defineProperty(c,"DeleteCommentTreeCommand",{enumerable:!0,get:()=>C.DeleteCommentTreeCommand}),Object.defineProperty(c,"IThreadCommentDataSourceService",{enumerable:!0,get:()=>C.IThreadCommentDataSourceService}),Object.defineProperty(c,"ResolveCommentCommand",{enumerable:!0,get:()=>C.ResolveCommentCommand}),Object.defineProperty(c,"UpdateCommentCommand",{enumerable:!0,get:()=>C.UpdateCommentCommand}),c.SHEETS_THREAD_COMMENT=Q,c.ShowAddSheetCommentModalOperation=B,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,25 +54,25 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.2.5",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
|
-
"@univerjs/core": "0.
|
|
58
|
-
"@univerjs/design": "0.
|
|
59
|
-
"@univerjs/engine-
|
|
60
|
-
"@univerjs/docs-ui": "0.
|
|
61
|
-
"@univerjs/engine-
|
|
62
|
-
"@univerjs/sheets": "0.
|
|
63
|
-
"@univerjs/sheets-thread-comment": "0.
|
|
64
|
-
"@univerjs/sheets-ui": "0.
|
|
65
|
-
"@univerjs/thread-comment": "0.
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/ui": "0.
|
|
57
|
+
"@univerjs/core": "0.5.0-beta.0",
|
|
58
|
+
"@univerjs/design": "0.5.0-beta.0",
|
|
59
|
+
"@univerjs/engine-render": "0.5.0-beta.0",
|
|
60
|
+
"@univerjs/docs-ui": "0.5.0-beta.0",
|
|
61
|
+
"@univerjs/engine-formula": "0.5.0-beta.0",
|
|
62
|
+
"@univerjs/sheets": "0.5.0-beta.0",
|
|
63
|
+
"@univerjs/sheets-thread-comment": "0.5.0-beta.0",
|
|
64
|
+
"@univerjs/sheets-ui": "0.5.0-beta.0",
|
|
65
|
+
"@univerjs/thread-comment": "0.5.0-beta.0",
|
|
66
|
+
"@univerjs/ui": "0.5.0-beta.0",
|
|
67
|
+
"@univerjs/thread-comment-ui": "0.5.0-beta.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"react": "18.3.1",
|
|
71
71
|
"rxjs": "^7.8.1",
|
|
72
72
|
"typescript": "^5.6.3",
|
|
73
|
-
"vite": "^5.4.
|
|
74
|
-
"vitest": "^2.1.
|
|
75
|
-
"@univerjs-infra/shared": "0.
|
|
73
|
+
"vite": "^5.4.11",
|
|
74
|
+
"vitest": "^2.1.5",
|
|
75
|
+
"@univerjs-infra/shared": "0.5.0-beta.0"
|
|
76
76
|
},
|
|
77
77
|
"space": {
|
|
78
78
|
".": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"test:watch": "vitest",
|
|
98
98
|
"coverage": "vitest run --coverage",
|
|
99
99
|
"lint:types": "tsc --noEmit",
|
|
100
|
-
"build": "
|
|
100
|
+
"build": "univer-cli build"
|
|
101
101
|
},
|
|
102
102
|
"module": "./lib/es/index.js"
|
|
103
103
|
}
|