@univerjs/thread-comment-ui 0.6.1-nightly.202502261607 → 0.6.2

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 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,8 +1,8 @@
1
- "use strict";var je=Object.defineProperty;var Ue=(n,e,t)=>e in n?je(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var F=(n,e,t)=>Ue(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),k=require("@univerjs/thread-comment"),v=require("@univerjs/ui"),oe=require("rxjs"),o=require("react/jsx-runtime"),V=require("@univerjs/design"),d=require("react"),ae=require("@univerjs/docs-ui");var Ne=Object.getOwnPropertyDescriptor,Ee=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ne(e,t):e,s=n.length-1,m;s>=0;s--)(m=n[s])&&(i=m(i)||i);return i},le=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();F(this,"_panelVisible",!1);F(this,"_panelVisible$",new oe.BehaviorSubject(!1));F(this,"_activeCommentId");F(this,"_activeCommentId$",new oe.BehaviorSubject(void 0));F(this,"panelVisible$",this._panelVisible$.asObservable());F(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}};exports.ThreadCommentPanelService=Ee([le(0,c.Inject(v.ISidebarService)),le(1,c.IUniverInstanceService)],exports.ThreadCommentPanelService);const ue="thread-comment-panel",Pe="UNIVER_THREAD_COMMENT_UI_PLUGIN",he={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(v.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ue},width:330}),t.setPanelVisible(!0)),!0}},B={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}},Oe="thread-comment-ui.config",de={};var De=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Me=(n,e,t)=>e in n?De(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Re(e,t):e,s=n.length-1,m;s>=0;s--)(m=n[s])&&(i=m(i)||i);return i},se=(n,e)=>(t,r)=>e(t,r,n),ve=(n,e,t)=>Me(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends c.Plugin{constructor(e=de,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:s,...m}=c.merge({},de,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Oe,m)}onStarting(){var e;c.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[he,B].forEach(t=>{this._commandService.registerCommand(t)})}};ve(exports.UniverThreadCommentUIPlugin,"pluginName",Pe);ve(exports.UniverThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=we([c.DependentOn(k.UniverThreadCommentPlugin),se(1,c.Inject(c.Injector)),se(2,c.ICommandService),se(3,c.IConfigService)],exports.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},$e=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},q=d.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,m=$e(n,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),S=d.useRef("_".concat(Le()));return Ce(t,"".concat(r),{defIds:t.defIds,idSuffix:S.current},M({ref:e,className:p},m),s)});function Ce(n,e,t,r,i){return d.createElement(n.tag,M(M({key:e},He(n,t,i)),r),(ke(n,t).children||[]).map(function(s,m){return Ce(s,"".concat(e,"-").concat(n.tag,"-").concat(m),t,void 0,i)}))}function He(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(s){var m=s[0],p=s[1];m==="mask"&&typeof p=="string"&&(r[m]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var m=s[0],p=s[1];typeof p=="string"&&(r[m]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function ke(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Le(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fe=d.forwardRef(function(n,e){return d.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Ae}))});fe.displayName="DeleteSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},pe=d.forwardRef(function(n,e){return d.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Ve}))});pe.displayName="IncreaseSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},ge=d.forwardRef(function(n,e){return d.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Be}))});ge.displayName="MoreHorizontalSingle";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},Ie=d.forwardRef(function(n,e){return d.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:We}))});Ie.displayName="ReplyToCommentSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xe=d.forwardRef(function(n,e){return d.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:Fe}))});xe.displayName="ResolvedSingle";var qe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Se=d.forwardRef(function(n,e){return d.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:qe}))});Se.displayName="SolveSingle";function be(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=be(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ze(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=be(n))&&(r&&(r+=" "),r+=e);return r}const Ke="univer-thread-comment-editor-buttons",ce={threadCommentEditorButtons:Ke};function me(n){return{id:"d",body:n,documentStyle:{}}}const ye=d.forwardRef((n,e)=>{var H;const{comment:t,onSave:r,id:i,onCancel:s,autoFocus:m,unitId:p,type:S}=n,U=v.useDependency(c.ICommandService),P=v.useDependency(c.LocaleService),[L,O]=d.useState(!1),N=v.useDependency(ae.IEditorService),h=d.useRef(null),I=S===c.UniverInstanceType.UNIVER_SHEET?c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:p,[D,T]=d.useState(()=>{var u,C,x;return c.BuildTextUtils.transform.getPlainText((x=(C=(u=h.current)==null?void 0:u.getDocumentData().body)==null?void 0:C.dataStream)!=null?x:"")});d.useEffect(()=>{var C,x,l,f;T(c.BuildTextUtils.transform.getPlainText((l=(x=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:x.dataStream)!=null?l:""));const u=(f=h.current)==null?void 0:f.selectionChange$.subscribe(()=>{var z,_,y;T(c.BuildTextUtils.transform.getPlainText((y=(_=(z=h.current)==null?void 0:z.getDocumentData().body)==null?void 0:_.dataStream)!=null?y:""))});return()=>u==null?void 0:u.unsubscribe()},[(H=h.current)==null?void 0:H.selectionChange$]);const w=d.useMemo(()=>({keyCodes:[{keyCode:v.KeyCode.ENTER}],handler:u=>{u===v.KeyCode.ENTER&&U.executeCommand(ae.BreakLineCommand.id)}}),[U]);d.useImperativeHandle(e,()=>({reply(u){var C,x;(C=h.current)==null||C.focus(),(x=h.current)==null||x.setDocumentData(me(u))}}));const b=()=>{if(h.current){const u=c.Tools.deepClone(h.current.getDocumentData().body);O(!1),r==null||r({...t,text:u}),h.current.replaceText(""),setTimeout(()=>{var C,x;(C=h.current)==null||C.setSelectionRanges([]),(x=h.current)==null||x.blur()},10)}};return o.jsxs("div",{className:ce.threadCommentEditor,onClick:u=>u.preventDefault(),children:[o.jsx(ae.RichTextEditor,{editorRef:h,autoFocus:m,style:{width:"100%"},keyboardEventConfig:w,placeholder:P.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&me(t.text),onFocusChange:u=>u&&O(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{N.focus(I)},30)}}),L?o.jsxs("div",{className:ce.threadCommentEditorButtons,children:[o.jsx(V.Button,{style:{marginRight:12},onClick:()=>{var u;s==null||s(),O(!1),(u=h.current)==null||u.replaceText("",!0),U.executeCommand(B.id)},children:P.t("threadCommentUI.editor.cancel")}),o.jsx(V.Button,{type:"primary",disabled:!D,onClick:b,children:P.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ze=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
2
- `)?e.length-2:e.length,i=[];let s=0;return t==null||t.forEach(m=>{s<m.startIndex&&i.push({type:"text",content:e.slice(s,m.startIndex)}),i.push({type:"mention",content:{label:e.slice(m.startIndex,m.endIndex+1),id:m.rangeId}}),s=m.endIndex+1}),i.push({type:"text",content:e.slice(s,r)}),i},Ge=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=c.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ze(i)})},Ye=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const s=e.length-1;t.push({rangeId:r.content.id,rangeType:c.CustomRangeType.MENTION,startIndex:i,endIndex:s,properties:{}});break}}}),e+=`
3
- \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},Je="univer-thread-comment",Qe="univer-thread-comment-active",Xe="univer-thread-comment-content",et="univer-thread-comment-highlight",tt="univer-thread-comment-icon-container",nt="univer-thread-comment-icon",rt="univer-thread-comment-title",it="univer-thread-comment-title-position",ot="univer-thread-comment-title-highlight",at="univer-thread-comment-title-position-text",st="univer-thread-comment-username",lt="univer-thread-comment-item",dt="univer-thread-comment-item-head",ct="univer-thread-comment-item-title",mt="univer-thread-comment-item-time",ut="univer-thread-comment-item-content",ht="univer-thread-comment-item-at",g={threadComment:Je,threadCommentActive:Qe,threadCommentContent:Xe,threadCommentHighlight:et,threadCommentIconContainer:tt,threadCommentIcon:nt,threadCommentTitle:rt,threadCommentTitlePosition:it,threadCommentTitleHighlight:ot,threadCommentTitlePositionText:at,threadCommentUsername:st,threadCommentItem:lt,threadCommentItemHead:dt,threadCommentItemTitle:ct,threadCommentItemTime:mt,threadCommentItemContent:ut,threadCommentItemAt:ht},Te="__mock__",vt=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:s,onReply:m,resolved:p,isRoot:S,onClose:U,onDeleteComment:P,type:L}=n,O=v.useDependency(c.ICommandService),N=v.useDependency(c.LocaleService),h=v.useDependency(c.UserManagerService),I=h.getUser(e.personId),D=v.useObservable(h.currentUser$),T=(D==null?void 0:D.userID)===e.personId,w=e.id===Te,[b,H]=d.useState(!1),u=()=>{(P==null?void 0:P(e))!==!1&&(O.executeCommand(S?k.DeleteCommentTreeCommand.id:k.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),S&&(U==null||U()))};return o.jsxs("div",{className:g.threadCommentItem,onMouseLeave:()=>H(!1),onMouseEnter:()=>H(!0),children:[o.jsx("img",{className:g.threadCommentItemHead,src:I==null?void 0:I.avatar}),o.jsxs("div",{className:g.threadCommentItemTitle,children:[o.jsx("div",{className:g.threadCommentUsername,children:(I==null?void 0:I.name)||" "}),o.jsxs("div",{children:[w||p?null:b?o.jsx("div",{className:g.threadCommentIcon,onClick:()=>m(I),children:o.jsx(Ie,{})}):null,T&&!w&&!p?o.jsx(V.Dropdown,{overlay:o.jsx("div",{className:"univer-rounded-lg univer-p-4 univer-theme",children:o.jsxs("ul",{className:`
1
+ "use strict";var _e=Object.defineProperty;var je=(n,e,t)=>e in n?_e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var F=(n,e,t)=>je(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),k=require("@univerjs/thread-comment"),v=require("@univerjs/ui"),oe=require("rxjs"),o=require("react/jsx-runtime"),V=require("@univerjs/design"),l=require("react"),ae=require("@univerjs/docs-ui");var Ue=Object.getOwnPropertyDescriptor,Ne=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ue(e,t):e,s=n.length-1,m;s>=0;s--)(m=n[s])&&(i=m(i)||i);return i},de=(n,e)=>(t,r)=>e(t,r,n);exports.ThreadCommentPanelService=class extends c.Disposable{constructor(t,r){super();F(this,"_panelVisible",!1);F(this,"_panelVisible$",new oe.BehaviorSubject(!1));F(this,"_activeCommentId");F(this,"_activeCommentId$",new oe.BehaviorSubject(void 0));F(this,"panelVisible$",this._panelVisible$.asObservable());F(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}};exports.ThreadCommentPanelService=Ne([de(0,c.Inject(v.ISidebarService)),de(1,c.IUniverInstanceService)],exports.ThreadCommentPanelService);const ue="thread-comment-panel",Ee="UNIVER_THREAD_COMMENT_UI_PLUGIN",he={id:"thread-comment-ui.operation.toggle-panel",type:c.CommandType.OPERATION,handler(n){const e=n.get(v.ISidebarService),t=n.get(exports.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:ue},width:330}),t.setPanelVisible(!0)),!0}},B={id:"thread-comment-ui.operation.set-active-comment",type:c.CommandType.OPERATION,handler(n,e){return n.get(exports.ThreadCommentPanelService).setActiveComment(e),!0}},Pe="thread-comment-ui.config",le={};var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Re=(n,e,t)=>e in n?Oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Me=(n,e,t,r)=>{for(var i=r>1?void 0:r?De(e,t):e,s=n.length-1,m;s>=0;s--)(m=n[s])&&(i=m(i)||i);return i},se=(n,e)=>(t,r)=>e(t,r,n),ve=(n,e,t)=>Re(n,typeof e!="symbol"?e+"":e,t);exports.UniverThreadCommentUIPlugin=class extends c.Plugin{constructor(e=le,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:s,...m}=c.merge({},le,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Pe,m)}onStarting(){var e;c.mergeOverrideWithDependencies([[exports.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[he,B].forEach(t=>{this._commandService.registerCommand(t)})}};ve(exports.UniverThreadCommentUIPlugin,"pluginName",Ee);ve(exports.UniverThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_UNKNOWN);exports.UniverThreadCommentUIPlugin=Me([c.DependentOn(k.UniverThreadCommentPlugin),se(1,c.Inject(c.Injector)),se(2,c.ICommandService),se(3,c.IConfigService)],exports.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},we=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},q=l.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,m=we(n,["icon","id","className","extend"]),p="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),S=l.useRef("_".concat(ke()));return Ce(t,"".concat(r),{defIds:t.defIds,idSuffix:S.current},M({ref:e,className:p},m),s)});function Ce(n,e,t,r,i){return l.createElement(n.tag,M(M({key:e},$e(n,t,i)),r),(He(n,t).children||[]).map(function(s,m){return Ce(s,"".concat(e,"-").concat(n.tag,"-").concat(m),t,void 0,i)}))}function $e(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(s){var m=s[0],p=s[1];m==="mask"&&typeof p=="string"&&(r[m]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var m=s[0],p=s[1];typeof p=="string"&&(r[m]=p.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function He(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function ke(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fe=l.forwardRef(function(n,e){return l.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});fe.displayName="DeleteSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},pe=l.forwardRef(function(n,e){return l.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Ve}))});pe.displayName="IncreaseSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},ge=l.forwardRef(function(n,e){return l.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ae}))});ge.displayName="MoreHorizontalSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},Ie=l.forwardRef(function(n,e){return l.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Be}))});Ie.displayName="ReplyToCommentSingle";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xe=l.forwardRef(function(n,e){return l.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:We}))});xe.displayName="ResolvedSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Se=l.forwardRef(function(n,e){return l.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:Fe}))});Se.displayName="SolveSingle";const qe="univer-thread-comment-editor-buttons",ce={threadCommentEditorButtons:qe};function me(n){return{id:"d",body:n,documentStyle:{}}}const be=l.forwardRef((n,e)=>{var H;const{comment:t,onSave:r,id:i,onCancel:s,autoFocus:m,unitId:p,type:S}=n,U=v.useDependency(c.ICommandService),P=v.useDependency(c.LocaleService),[L,O]=l.useState(!1),N=v.useDependency(ae.IEditorService),h=l.useRef(null),I=S===c.UniverInstanceType.UNIVER_SHEET?c.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:p,[D,T]=l.useState(()=>{var u,C,x;return c.BuildTextUtils.transform.getPlainText((x=(C=(u=h.current)==null?void 0:u.getDocumentData().body)==null?void 0:C.dataStream)!=null?x:"")});l.useEffect(()=>{var C,x,d,f;T(c.BuildTextUtils.transform.getPlainText((d=(x=(C=h.current)==null?void 0:C.getDocumentData().body)==null?void 0:x.dataStream)!=null?d:""));const u=(f=h.current)==null?void 0:f.selectionChange$.subscribe(()=>{var z,_,y;T(c.BuildTextUtils.transform.getPlainText((y=(_=(z=h.current)==null?void 0:z.getDocumentData().body)==null?void 0:_.dataStream)!=null?y:""))});return()=>u==null?void 0:u.unsubscribe()},[(H=h.current)==null?void 0:H.selectionChange$]);const w=l.useMemo(()=>({keyCodes:[{keyCode:v.KeyCode.ENTER}],handler:u=>{u===v.KeyCode.ENTER&&U.executeCommand(ae.BreakLineCommand.id)}}),[U]);l.useImperativeHandle(e,()=>({reply(u){var C,x;(C=h.current)==null||C.focus(),(x=h.current)==null||x.setDocumentData(me(u))}}));const b=()=>{if(h.current){const u=c.Tools.deepClone(h.current.getDocumentData().body);O(!1),r==null||r({...t,text:u}),h.current.replaceText(""),setTimeout(()=>{var C,x;(C=h.current)==null||C.setSelectionRanges([]),(x=h.current)==null||x.blur()},10)}};return o.jsxs("div",{className:ce.threadCommentEditor,onClick:u=>u.preventDefault(),children:[o.jsx(ae.RichTextEditor,{editorRef:h,autoFocus:m,style:{width:"100%"},keyboardEventConfig:w,placeholder:P.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&me(t.text),onFocusChange:u=>u&&O(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{N.focus(I)},30)}}),L?o.jsxs("div",{className:ce.threadCommentEditorButtons,children:[o.jsx(V.Button,{style:{marginRight:12},onClick:()=>{var u;s==null||s(),O(!1),(u=h.current)==null||u.replaceText("",!0),U.executeCommand(B.id)},children:P.t("threadCommentUI.editor.cancel")}),o.jsx(V.Button,{type:"primary",disabled:!D,onClick:b,children:P.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),ze=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
2
+ `)?e.length-2:e.length,i=[];let s=0;return t==null||t.forEach(m=>{s<m.startIndex&&i.push({type:"text",content:e.slice(s,m.startIndex)}),i.push({type:"mention",content:{label:e.slice(m.startIndex,m.endIndex+1),id:m.rangeId}}),s=m.endIndex+1}),i.push({type:"text",content:e.slice(s,r)}),i},Ke=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=c.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,ze(i)})},Ze=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const s=e.length-1;t.push({rangeId:r.content.id,rangeType:c.CustomRangeType.MENTION,startIndex:i,endIndex:s,properties:{}});break}}}),e+=`
3
+ \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},Ge="univer-thread-comment",Ye="univer-thread-comment-active",Je="univer-thread-comment-content",Qe="univer-thread-comment-highlight",Xe="univer-thread-comment-icon-container",et="univer-thread-comment-icon",tt="univer-thread-comment-title",nt="univer-thread-comment-title-position",rt="univer-thread-comment-title-highlight",it="univer-thread-comment-title-position-text",ot="univer-thread-comment-username",at="univer-thread-comment-item",st="univer-thread-comment-item-head",dt="univer-thread-comment-item-title",lt="univer-thread-comment-item-time",ct="univer-thread-comment-item-content",mt="univer-thread-comment-item-at",g={threadComment:Ge,threadCommentActive:Ye,threadCommentContent:Je,threadCommentHighlight:Qe,threadCommentIconContainer:Xe,threadCommentIcon:et,threadCommentTitle:tt,threadCommentTitlePosition:nt,threadCommentTitleHighlight:rt,threadCommentTitlePositionText:it,threadCommentUsername:ot,threadCommentItem:at,threadCommentItemHead:st,threadCommentItemTitle:dt,threadCommentItemTime:lt,threadCommentItemContent:ct,threadCommentItemAt:mt},ye="__mock__",ut=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:s,onReply:m,resolved:p,isRoot:S,onClose:U,onDeleteComment:P,type:L}=n,O=v.useDependency(c.ICommandService),N=v.useDependency(c.LocaleService),h=v.useDependency(c.UserManagerService),I=h.getUser(e.personId),D=v.useObservable(h.currentUser$),T=(D==null?void 0:D.userID)===e.personId,w=e.id===ye,[b,H]=l.useState(!1),u=()=>{(P==null?void 0:P(e))!==!1&&(O.executeCommand(S?k.DeleteCommentTreeCommand.id:k.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),S&&(U==null||U()))};return o.jsxs("div",{className:g.threadCommentItem,onMouseLeave:()=>H(!1),onMouseEnter:()=>H(!0),children:[o.jsx("img",{className:g.threadCommentItemHead,src:I==null?void 0:I.avatar}),o.jsxs("div",{className:g.threadCommentItemTitle,children:[o.jsx("div",{className:g.threadCommentUsername,children:(I==null?void 0:I.name)||" "}),o.jsxs("div",{children:[w||p?null:b?o.jsx("div",{className:g.threadCommentIcon,onClick:()=>m(I),children:o.jsx(Ie,{})}):null,T&&!w&&!p?o.jsx(V.Dropdown,{overlay:o.jsx("div",{className:"univer-rounded-lg univer-p-4 univer-theme",children:o.jsxs("ul",{className:`
4
4
  univer-m-0 univer-grid univer-list-none univer-gap-2 univer-p-0
5
5
  univer-text-sm
6
6
  [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-p-1
7
- `,children:[o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>s==null?void 0:s(!0),children:N.t("threadCommentUI.item.edit")})}),o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:u,children:N.t("threadCommentUI.item.delete")})})]})}),children:o.jsx("div",{className:g.threadCommentIcon,children:o.jsx(ge,{})})}):null]})]}),o.jsx("div",{className:g.threadCommentItemTime,children:e.dT}),i?o.jsx(ye,{type:L,id:e.id,comment:e,onCancel:()=>s==null?void 0:s(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:C,attachments:x})=>{s==null||s(!1),O.executeCommand(k.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:C,attachments:x}})}}):o.jsx("div",{className:g.threadCommentItemContent,children:Ge(e.text).map((C,x)=>o.jsx("div",{children:C.map((l,f)=>{switch(l.type){case"mention":return o.jsxs("a",{className:g.threadCommentItemAt,children:[l.content.label," "]},f);default:return l.content}})},x))})]})},_e=n=>{var J,Q,ne;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:s=!0,onClick:m,showHighlight:p,onClose:S,getSubUnitName:U,prefix:P,autoFocus:L,onMouseEnter:O,onMouseLeave:N,onAddComment:h,onDeleteComment:I,onResolve:D,type:T}=n,w=v.useDependency(k.ThreadCommentModel),[b,H]=d.useState(!1),[u,C]=d.useState(""),x=d.useMemo(()=>w.commentUpdate$.pipe(oe.debounceTime(16)),[w]);v.useObservable(x);const l=e?w.getCommentWithChildren(t,r,e):null,f=v.useDependency(c.ICommandService),z=v.useDependency(c.UserManagerService),_=l==null?void 0:l.root.resolved,y=v.useObservable(z.currentUser$),K=d.useRef(null),ee=[...l?[l.root]:[{id:Te,text:{dataStream:`
8
- \r`},personId:(J=y==null?void 0:y.userID)!=null?J:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Q=l==null?void 0:l.children)!=null?Q:[]],R=d.useRef(null),Z=j=>{j.stopPropagation(),_?f.executeCommand(B.id,{unitId:t,subUnitId:r,commentId:e}):f.executeCommand(B.id),f.executeCommand(k.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!_}),D==null||D(!_)},A=j=>{j.stopPropagation(),f.executeCommand(B.id),!(l!=null&&l.root&&(I==null?void 0:I(l.root))===!1)&&(f.executeCommand(k.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),S==null||S())};d.useEffect(()=>N==null?void 0:N(),[]);const G=U((ne=l==null?void 0:l.root.subUnitId)!=null?ne:r),Y=s&&!u&&!_,te=`${i||(l==null?void 0:l.root.ref)||""}${G?" · ":""}${G}`;return o.jsxs("div",{className:ze(g.threadComment,{[g.threadCommentActive]:!_&&(p||b||P==="cell")}),onClick:m,id:`${P}-${t}-${r}-${e}`,onMouseEnter:()=>{O==null||O(),H(!0)},onMouseLeave:()=>{N==null||N(),H(!1)},children:[!_&&p?o.jsx("div",{className:g.threadCommentHighlight}):null,o.jsxs("div",{className:g.threadCommentTitle,children:[o.jsxs("div",{className:g.threadCommentTitlePosition,children:[o.jsx("div",{className:g.threadCommentTitleHighlight}),o.jsx(V.Tooltip,{showIfEllipsis:!0,title:te,children:o.jsx("div",{className:g.threadCommentTitlePositionText,children:te})})]}),l?o.jsxs("div",{className:g.threadCommentIconContainer,children:[o.jsx("div",{onClick:Z,className:g.threadCommentIcon,style:{color:_?"rgb(var(--green-500))":""},children:_?o.jsx(xe,{}):o.jsx(Se,{})}),(y==null?void 0:y.userID)===l.root.personId?o.jsx("div",{className:g.threadCommentIcon,onClick:A,children:o.jsx(fe,{})}):null]}):null]}),o.jsx("div",{className:g.threadCommentContent,ref:R,children:ee.map(j=>o.jsx(vt,{onClose:S,unitId:t,subUnitId:r,item:j,isRoot:j.id===(l==null?void 0:l.root.id),editing:u===j.id,resolved:l==null?void 0:l.root.resolved,type:T,onEditingChange:a=>{C(a?j.id:"")},onReply:a=>{a&&requestAnimationFrame(()=>{var $;($=K.current)==null||$.reply(Ye([{type:"mention",content:{id:a.userID,label:a.name}}]))})},onAddComment:h,onDeleteComment:I},j.id))}),Y?o.jsx("div",{children:o.jsx(ye,{ref:K,type:T,unitId:t,subUnitId:r,onSave:async({text:j,attachments:a})=>{const $={text:j,attachments:a,dT:k.getDT(),id:c.generateRandomId(),ref:i,personId:y==null?void 0:y.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(h==null?void 0:h($))!==!1&&(await f.executeCommand(k.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:$}),R.current&&(R.current.scrollTop=R.current.scrollHeight))},autoFocus:L||!l,onCancel:()=>{l||S==null||S()}},`${L}`)}):null]})},Ct="univer-thread-comment-panel",ft="univer-thread-comment-panel-forms",pt="univer-thread-comment-panel-empty",gt="univer-thread-comment-panel-add",It="univer-thread-comment-panel-solved",X={threadCommentPanel:Ct,threadCommentPanelForms:ft,threadCommentPanelEmpty:pt,threadCommentPanelAdd:gt,threadCommentPanelSolved:It},xt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:s,onResolve:m,sortComments:p,onItemLeave:S,onItemEnter:U,disableAdd:P,tempComment:L,onAddComment:O,onDeleteComment:N,showComments:h}=n,[I,D]=d.useState("all"),[T,w]=d.useState("all"),b=v.useDependency(c.LocaleService),H=v.useDependency(c.UserManagerService),u=v.useDependency(k.ThreadCommentModel),[C,x]=d.useState(()=>u.getUnit(e)),l=v.useDependency(exports.ThreadCommentPanelService),f=v.useObservable(l.activeCommentId$),z=v.useObservable(u.commentUpdate$),_=v.useDependency(c.ICommandService),y=v.useObservable(t),K=d.useRef(!0),ee="panel",R=v.useObservable(H.currentUser$),Z=d.useMemo(()=>{var ie;const a=I==="all"?C:(ie=C.filter(E=>E.subUnitId===y))!=null?ie:[],$=p!=null?p:E=>E,re=a.map(E=>{var W;return{...E.root,children:(W=E.children)!=null?W:[],users:E.relativeUsers}});if(h){const E=new Map;return re.forEach(W=>{E.set(W.id,W)}),[...h,""].map(W=>E.get(W)).filter(Boolean)}else return $(re)},[h,I,C,p,y]),A=d.useMemo(()=>[...Z.filter(a=>!a.resolved),...Z.filter(a=>a.resolved)],[Z]),G=d.useMemo(()=>T==="resolved"?A.filter(a=>a.resolved):T==="unsolved"?A.filter(a=>!a.resolved):T==="concern_me"&&R!=null&&R.userID?A.filter(a=>a==null?void 0:a.users.has(R.userID)):A,[A,R==null?void 0:R.userID,T]),Y=L?[L,...G]:G,te=Y.filter(a=>!a.resolved),J=Y.filter(a=>a.resolved),Q=T!=="all"||I!=="all",ne=()=>{w("all"),D("all")};d.useEffect(()=>{e&&x(u.getUnit(e))},[e,u,z]),d.useEffect(()=>{var E;if(!f)return;if(!K.current){K.current=!0;return}const{unitId:a,subUnitId:$,commentId:re}=f,ie=`${ee}-${a}-${$}-${re}`;(E=document.getElementById(ie))==null||E.scrollIntoView({block:"center"})},[f]);const j=a=>o.jsx(_e,{prefix:ee,getSubUnitName:s,id:a.id,unitId:a.unitId,subUnitId:a.subUnitId,refStr:a.ref,type:r,showEdit:(f==null?void 0:f.commentId)===a.id,showHighlight:(f==null?void 0:f.commentId)===a.id,onClick:()=>{K.current=!1,a.resolved?_.executeCommand(B.id):_.executeCommand(B.id,{unitId:a.unitId,subUnitId:a.subUnitId,commentId:a.id,temp:!1})},onMouseEnter:()=>U==null?void 0:U(a),onMouseLeave:()=>S==null?void 0:S(a),onAddComment:O,onDeleteComment:N,onResolve:$=>m==null?void 0:m(a.id,$)},a.id);return o.jsxs("div",{className:X.threadCommentPanel,children:[o.jsxs("div",{className:X.threadCommentPanelForms,children:[r===c.UniverInstanceType.UNIVER_SHEET?o.jsx(V.Select,{borderless:!0,value:I,onChange:a=>D(a),options:[{value:"current",label:b.t("threadCommentUI.filter.sheet.current")},{value:"all",label:b.t("threadCommentUI.filter.sheet.all")}]}):null,o.jsx(V.Select,{borderless:!0,value:T,onChange:a=>w(a),options:[{value:"all",label:b.t("threadCommentUI.filter.status.all")},{value:"resolved",label:b.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:b.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:b.t("threadCommentUI.filter.status.concernMe")}]})]}),te.map(j),J.length?o.jsx("div",{className:X.threadCommentPanelSolved,children:"已解决"}):null,J.map(j),Y.length?null:o.jsxs("div",{className:X.threadCommentPanelEmpty,children:[Q?b.t("threadCommentUI.panel.filterEmpty"):b.t("threadCommentUI.panel.empty"),Q?o.jsx(V.Button,{onClick:ne,type:"link",children:b.t("threadCommentUI.panel.reset")}):o.jsxs(V.Button,{id:"thread-comment-add",className:X.threadCommentPanelAdd,type:"primary",onClick:i,disabled:P,children:[o.jsx(pe,{}),b.t("threadCommentUI.panel.addComment")]})]})]})};exports.SetActiveCommentOperation=B;exports.THREAD_COMMENT_PANEL=ue;exports.ThreadCommentPanel=xt;exports.ThreadCommentTree=_e;exports.ToggleSheetCommentPanelOperation=he;
7
+ `,children:[o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>s==null?void 0:s(!0),children:N.t("threadCommentUI.item.edit")})}),o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:u,children:N.t("threadCommentUI.item.delete")})})]})}),children:o.jsx("div",{className:g.threadCommentIcon,children:o.jsx(ge,{})})}):null]})]}),o.jsx("div",{className:g.threadCommentItemTime,children:e.dT}),i?o.jsx(be,{type:L,id:e.id,comment:e,onCancel:()=>s==null?void 0:s(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:C,attachments:x})=>{s==null||s(!1),O.executeCommand(k.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:C,attachments:x}})}}):o.jsx("div",{className:g.threadCommentItemContent,children:Ke(e.text).map((C,x)=>o.jsx("div",{children:C.map((d,f)=>{switch(d.type){case"mention":return o.jsxs("a",{className:g.threadCommentItemAt,children:[d.content.label," "]},f);default:return d.content}})},x))})]})},Te=n=>{var J,Q,ne;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:s=!0,onClick:m,showHighlight:p,onClose:S,getSubUnitName:U,prefix:P,autoFocus:L,onMouseEnter:O,onMouseLeave:N,onAddComment:h,onDeleteComment:I,onResolve:D,type:T}=n,w=v.useDependency(k.ThreadCommentModel),[b,H]=l.useState(!1),[u,C]=l.useState(""),x=l.useMemo(()=>w.commentUpdate$.pipe(oe.debounceTime(16)),[w]);v.useObservable(x);const d=e?w.getCommentWithChildren(t,r,e):null,f=v.useDependency(c.ICommandService),z=v.useDependency(c.UserManagerService),_=d==null?void 0:d.root.resolved,y=v.useObservable(z.currentUser$),K=l.useRef(null),ee=[...d?[d.root]:[{id:ye,text:{dataStream:`
8
+ \r`},personId:(J=y==null?void 0:y.userID)!=null?J:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(Q=d==null?void 0:d.children)!=null?Q:[]],R=l.useRef(null),Z=j=>{j.stopPropagation(),_?f.executeCommand(B.id,{unitId:t,subUnitId:r,commentId:e}):f.executeCommand(B.id),f.executeCommand(k.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!_}),D==null||D(!_)},A=j=>{j.stopPropagation(),f.executeCommand(B.id),!(d!=null&&d.root&&(I==null?void 0:I(d.root))===!1)&&(f.executeCommand(k.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),S==null||S())};l.useEffect(()=>N==null?void 0:N(),[]);const G=U((ne=d==null?void 0:d.root.subUnitId)!=null?ne:r),Y=s&&!u&&!_,te=`${i||(d==null?void 0:d.root.ref)||""}${G?" · ":""}${G}`;return o.jsxs("div",{className:V.clsx(g.threadComment,{[g.threadCommentActive]:!_&&(p||b||P==="cell")}),onClick:m,id:`${P}-${t}-${r}-${e}`,onMouseEnter:()=>{O==null||O(),H(!0)},onMouseLeave:()=>{N==null||N(),H(!1)},children:[!_&&p?o.jsx("div",{className:g.threadCommentHighlight}):null,o.jsxs("div",{className:g.threadCommentTitle,children:[o.jsxs("div",{className:g.threadCommentTitlePosition,children:[o.jsx("div",{className:g.threadCommentTitleHighlight}),o.jsx(V.Tooltip,{showIfEllipsis:!0,title:te,children:o.jsx("div",{className:g.threadCommentTitlePositionText,children:te})})]}),d?o.jsxs("div",{className:g.threadCommentIconContainer,children:[o.jsx("div",{onClick:Z,className:g.threadCommentIcon,style:{color:_?"rgb(var(--green-500))":""},children:_?o.jsx(xe,{}):o.jsx(Se,{})}),(y==null?void 0:y.userID)===d.root.personId?o.jsx("div",{className:g.threadCommentIcon,onClick:A,children:o.jsx(fe,{})}):null]}):null]}),o.jsx("div",{className:g.threadCommentContent,ref:R,children:ee.map(j=>o.jsx(ut,{onClose:S,unitId:t,subUnitId:r,item:j,isRoot:j.id===(d==null?void 0:d.root.id),editing:u===j.id,resolved:d==null?void 0:d.root.resolved,type:T,onEditingChange:a=>{C(a?j.id:"")},onReply:a=>{a&&requestAnimationFrame(()=>{var $;($=K.current)==null||$.reply(Ze([{type:"mention",content:{id:a.userID,label:a.name}}]))})},onAddComment:h,onDeleteComment:I},j.id))}),Y?o.jsx("div",{children:o.jsx(be,{ref:K,type:T,unitId:t,subUnitId:r,onSave:async({text:j,attachments:a})=>{const $={text:j,attachments:a,dT:k.getDT(),id:c.generateRandomId(),ref:i,personId:y==null?void 0:y.userID,parentId:d==null?void 0:d.root.id,unitId:t,subUnitId:r,threadId:d==null?void 0:d.root.threadId};(h==null?void 0:h($))!==!1&&(await f.executeCommand(k.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:$}),R.current&&(R.current.scrollTop=R.current.scrollHeight))},autoFocus:L||!d,onCancel:()=>{d||S==null||S()}},`${L}`)}):null]})},ht="univer-thread-comment-panel",vt="univer-thread-comment-panel-forms",Ct="univer-thread-comment-panel-empty",ft="univer-thread-comment-panel-add",pt="univer-thread-comment-panel-solved",X={threadCommentPanel:ht,threadCommentPanelForms:vt,threadCommentPanelEmpty:Ct,threadCommentPanelAdd:ft,threadCommentPanelSolved:pt},gt=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:s,onResolve:m,sortComments:p,onItemLeave:S,onItemEnter:U,disableAdd:P,tempComment:L,onAddComment:O,onDeleteComment:N,showComments:h}=n,[I,D]=l.useState("all"),[T,w]=l.useState("all"),b=v.useDependency(c.LocaleService),H=v.useDependency(c.UserManagerService),u=v.useDependency(k.ThreadCommentModel),[C,x]=l.useState(()=>u.getUnit(e)),d=v.useDependency(exports.ThreadCommentPanelService),f=v.useObservable(d.activeCommentId$),z=v.useObservable(u.commentUpdate$),_=v.useDependency(c.ICommandService),y=v.useObservable(t),K=l.useRef(!0),ee="panel",R=v.useObservable(H.currentUser$),Z=l.useMemo(()=>{var ie;const a=I==="all"?C:(ie=C.filter(E=>E.subUnitId===y))!=null?ie:[],$=p!=null?p:E=>E,re=a.map(E=>{var W;return{...E.root,children:(W=E.children)!=null?W:[],users:E.relativeUsers}});if(h){const E=new Map;return re.forEach(W=>{E.set(W.id,W)}),[...h,""].map(W=>E.get(W)).filter(Boolean)}else return $(re)},[h,I,C,p,y]),A=l.useMemo(()=>[...Z.filter(a=>!a.resolved),...Z.filter(a=>a.resolved)],[Z]),G=l.useMemo(()=>T==="resolved"?A.filter(a=>a.resolved):T==="unsolved"?A.filter(a=>!a.resolved):T==="concern_me"&&R!=null&&R.userID?A.filter(a=>a==null?void 0:a.users.has(R.userID)):A,[A,R==null?void 0:R.userID,T]),Y=L?[L,...G]:G,te=Y.filter(a=>!a.resolved),J=Y.filter(a=>a.resolved),Q=T!=="all"||I!=="all",ne=()=>{w("all"),D("all")};l.useEffect(()=>{e&&x(u.getUnit(e))},[e,u,z]),l.useEffect(()=>{var E;if(!f)return;if(!K.current){K.current=!0;return}const{unitId:a,subUnitId:$,commentId:re}=f,ie=`${ee}-${a}-${$}-${re}`;(E=document.getElementById(ie))==null||E.scrollIntoView({block:"center"})},[f]);const j=a=>o.jsx(Te,{prefix:ee,getSubUnitName:s,id:a.id,unitId:a.unitId,subUnitId:a.subUnitId,refStr:a.ref,type:r,showEdit:(f==null?void 0:f.commentId)===a.id,showHighlight:(f==null?void 0:f.commentId)===a.id,onClick:()=>{K.current=!1,a.resolved?_.executeCommand(B.id):_.executeCommand(B.id,{unitId:a.unitId,subUnitId:a.subUnitId,commentId:a.id,temp:!1})},onMouseEnter:()=>U==null?void 0:U(a),onMouseLeave:()=>S==null?void 0:S(a),onAddComment:O,onDeleteComment:N,onResolve:$=>m==null?void 0:m(a.id,$)},a.id);return o.jsxs("div",{className:X.threadCommentPanel,children:[o.jsxs("div",{className:X.threadCommentPanelForms,children:[r===c.UniverInstanceType.UNIVER_SHEET?o.jsx(V.Select,{borderless:!0,value:I,onChange:a=>D(a),options:[{value:"current",label:b.t("threadCommentUI.filter.sheet.current")},{value:"all",label:b.t("threadCommentUI.filter.sheet.all")}]}):null,o.jsx(V.Select,{borderless:!0,value:T,onChange:a=>w(a),options:[{value:"all",label:b.t("threadCommentUI.filter.status.all")},{value:"resolved",label:b.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:b.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:b.t("threadCommentUI.filter.status.concernMe")}]})]}),te.map(j),J.length?o.jsx("div",{className:X.threadCommentPanelSolved,children:"已解决"}):null,J.map(j),Y.length?null:o.jsxs("div",{className:X.threadCommentPanelEmpty,children:[Q?b.t("threadCommentUI.panel.filterEmpty"):b.t("threadCommentUI.panel.empty"),Q?o.jsx(V.Button,{onClick:ne,type:"link",children:b.t("threadCommentUI.panel.reset")}):o.jsxs(V.Button,{id:"thread-comment-add",className:X.threadCommentPanelAdd,type:"primary",onClick:i,disabled:P,children:[o.jsx(pe,{}),b.t("threadCommentUI.panel.addComment")]})]})]})};exports.SetActiveCommentOperation=B;exports.THREAD_COMMENT_PANEL=ue;exports.ThreadCommentPanel=gt;exports.ThreadCommentTree=Te;exports.ToggleSheetCommentPanelOperation=he;
package/lib/es/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var Ae = Object.defineProperty;
2
- var Be = (t, e, r) => e in t ? Ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var B = (t, e, r) => Be(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { Inject as Te, IUniverInstanceService as We, Disposable as Fe, UniverInstanceType as he, CommandType as Ne, DependentOn as ze, Injector as Ze, ICommandService as ie, IConfigService as Ke, Plugin as Ge, merge as Ye, mergeOverrideWithDependencies as qe, LocaleService as fe, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Je, BuildTextUtils as Ce, Tools as Qe, CustomRangeType as Xe, getBodySlice as et, UserManagerService as pe, generateRandomId as tt } from "@univerjs/core";
5
- import { UniverThreadCommentPlugin as nt, ThreadCommentModel as Ue, getDT as rt, AddCommentCommand as it, ResolveCommentCommand as ot, DeleteCommentTreeCommand as Ee, UpdateCommentCommand as at, DeleteCommentCommand as st } from "@univerjs/thread-comment";
1
+ var je = Object.defineProperty;
2
+ var Ae = (t, e, n) => e in t ? je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var B = (t, e, n) => Ae(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { Inject as Te, IUniverInstanceService as Be, Disposable as We, UniverInstanceType as he, CommandType as Ne, DependentOn as Fe, Injector as ze, ICommandService as ie, IConfigService as Ze, Plugin as Ke, merge as Ge, mergeOverrideWithDependencies as Ye, LocaleService as fe, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as qe, BuildTextUtils as Ce, Tools as Je, CustomRangeType as Qe, getBodySlice as Xe, UserManagerService as pe, generateRandomId as et } from "@univerjs/core";
5
+ import { UniverThreadCommentPlugin as tt, ThreadCommentModel as Ue, getDT as nt, AddCommentCommand as rt, ResolveCommentCommand as it, DeleteCommentTreeCommand as Ee, UpdateCommentCommand as ot, DeleteCommentCommand as at } from "@univerjs/thread-comment";
6
6
  import { ISidebarService as Oe, useDependency as T, KeyCode as ge, useObservable as W } from "@univerjs/ui";
7
- import { BehaviorSubject as Ie, filter as lt, debounceTime as dt } from "rxjs";
8
- import { jsxs as y, jsx as l } from "react/jsx-runtime";
9
- import { Button as ce, Tooltip as ct, Dropdown as mt, Select as be } from "@univerjs/design";
7
+ import { BehaviorSubject as Ie, filter as st, debounceTime as lt } from "rxjs";
8
+ import { jsxs as S, jsx as l } from "react/jsx-runtime";
9
+ import { Button as ce, clsx as dt, Tooltip as ct, Dropdown as mt, Select as be } from "@univerjs/design";
10
10
  import { forwardRef as j, useRef as re, createElement as z, useState as V, useEffect as me, useMemo as ne, useImperativeHandle as ut } from "react";
11
11
  import { IEditorService as ht, BreakLineCommand as Ct, RichTextEditor as vt } from "@univerjs/docs-ui";
12
- var ft = Object.getOwnPropertyDescriptor, pt = (t, e, r, n) => {
13
- for (var i = n > 1 ? void 0 : n ? ft(e, r) : e, a = t.length - 1, d; a >= 0; a--)
12
+ var ft = Object.getOwnPropertyDescriptor, pt = (t, e, n, r) => {
13
+ for (var i = r > 1 ? void 0 : r ? ft(e, n) : e, a = t.length - 1, d; a >= 0; a--)
14
14
  (d = t[a]) && (i = d(i) || i);
15
15
  return i;
16
- }, ye = (t, e) => (r, n) => e(r, n, t);
17
- let Y = class extends Fe {
18
- constructor(e, r) {
16
+ }, Se = (t, e) => (n, r) => e(n, r, t);
17
+ let Y = class extends We {
18
+ constructor(e, n) {
19
19
  super();
20
20
  B(this, "_panelVisible", !1);
21
21
  B(this, "_panelVisible$", new Ie(!1));
@@ -23,7 +23,7 @@ let Y = class extends Fe {
23
23
  B(this, "_activeCommentId$", new Ie(void 0));
24
24
  B(this, "panelVisible$", this._panelVisible$.asObservable());
25
25
  B(this, "activeCommentId$", this._activeCommentId$.asObservable());
26
- this._sidebarService = e, this._univerInstanceService = r, this._init(), this.disposeWithMe(() => {
26
+ this._sidebarService = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
27
27
  this._activeCommentId$.complete(), this._panelVisible$.complete();
28
28
  });
29
29
  }
@@ -33,7 +33,7 @@ let Y = class extends Fe {
33
33
  e.visible || this.setPanelVisible(!1);
34
34
  })
35
35
  ), this.disposeWithMe(
36
- this._univerInstanceService.getCurrentTypeOfUnit$(he.UNIVER_SHEET).pipe(lt((e) => !e)).subscribe(() => {
36
+ this._univerInstanceService.getCurrentTypeOfUnit$(he.UNIVER_SHEET).pipe(st((e) => !e)).subscribe(() => {
37
37
  this._sidebarService.close();
38
38
  })
39
39
  );
@@ -52,19 +52,19 @@ let Y = class extends Fe {
52
52
  }
53
53
  };
54
54
  Y = pt([
55
- ye(0, Te(Oe)),
56
- ye(1, We)
55
+ Se(0, Te(Oe)),
56
+ Se(1, Be)
57
57
  ], Y);
58
58
  const gt = "thread-comment-panel", It = "UNIVER_THREAD_COMMENT_UI_PLUGIN", bt = {
59
59
  id: "thread-comment-ui.operation.toggle-panel",
60
60
  type: Ne.OPERATION,
61
61
  handler(t) {
62
- const e = t.get(Oe), r = t.get(Y);
63
- return r.panelVisible ? (e.close(), r.setPanelVisible(!1)) : (e.open({
62
+ const e = t.get(Oe), n = t.get(Y);
63
+ return n.panelVisible ? (e.close(), n.setPanelVisible(!1)) : (e.open({
64
64
  header: { title: "threadCommentUI.panel.title" },
65
65
  children: { label: gt },
66
66
  width: 330
67
- }), r.setPanelVisible(!0)), !0;
67
+ }), n.setPanelVisible(!0)), !0;
68
68
  }
69
69
  }, F = {
70
70
  id: "thread-comment-ui.operation.set-active-comment",
@@ -72,25 +72,25 @@ const gt = "thread-comment-panel", It = "UNIVER_THREAD_COMMENT_UI_PLUGIN", bt =
72
72
  handler(t, e) {
73
73
  return t.get(Y).setActiveComment(e), !0;
74
74
  }
75
- }, yt = "thread-comment-ui.config", Se = {};
76
- var St = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, xt = (t, e, r) => e in t ? St(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Tt = (t, e, r, n) => {
77
- for (var i = n > 1 ? void 0 : n ? _t(e, r) : e, a = t.length - 1, d; a >= 0; a--)
75
+ }, St = "thread-comment-ui.config", ye = {};
76
+ var yt = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, xt = (t, e, n) => e in t ? yt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Tt = (t, e, n, r) => {
77
+ for (var i = r > 1 ? void 0 : r ? _t(e, n) : e, a = t.length - 1, d; a >= 0; a--)
78
78
  (d = t[a]) && (i = d(i) || i);
79
79
  return i;
80
- }, ve = (t, e) => (r, n) => e(r, n, t), Pe = (t, e, r) => xt(t, typeof e != "symbol" ? e + "" : e, r);
81
- let ue = class extends Ge {
82
- constructor(t = Se, e, r, n) {
83
- super(), this._config = t, this._injector = e, this._commandService = r, this._configService = n;
84
- const { menu: i, ...a } = Ye(
80
+ }, ve = (t, e) => (n, r) => e(n, r, t), Pe = (t, e, n) => xt(t, typeof e != "symbol" ? e + "" : e, n);
81
+ let ue = class extends Ke {
82
+ constructor(t = ye, e, n, r) {
83
+ super(), this._config = t, this._injector = e, this._commandService = n, this._configService = r;
84
+ const { menu: i, ...a } = Ge(
85
85
  {},
86
- Se,
86
+ ye,
87
87
  this._config
88
88
  );
89
- i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(yt, a);
89
+ i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(St, a);
90
90
  }
91
91
  onStarting() {
92
92
  var t;
93
- qe([
93
+ Ye([
94
94
  [Y]
95
95
  ], (t = this._config) == null ? void 0 : t.overrides).forEach((e) => {
96
96
  this._injector.add(e);
@@ -102,51 +102,51 @@ let ue = class extends Ge {
102
102
  Pe(ue, "pluginName", It);
103
103
  Pe(ue, "type", he.UNIVER_UNKNOWN);
104
104
  ue = Tt([
105
- ze(nt),
106
- ve(1, Te(Ze)),
105
+ Fe(tt),
106
+ ve(1, Te(ze)),
107
107
  ve(2, ie),
108
- ve(3, Ke)
108
+ ve(3, Ze)
109
109
  ], ue);
110
110
  var H = function() {
111
111
  return H = Object.assign || function(t) {
112
- for (var e, r = 1, n = arguments.length; r < n; r++) {
113
- e = arguments[r];
112
+ for (var e, n = 1, r = arguments.length; n < r; n++) {
113
+ e = arguments[n];
114
114
  for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
115
115
  }
116
116
  return t;
117
117
  }, H.apply(this, arguments);
118
118
  }, Nt = function(t, e) {
119
- var r = {};
120
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]);
119
+ var n = {};
120
+ for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
121
121
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
122
- for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++)
123
- e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]);
124
- return r;
122
+ for (var i = 0, r = Object.getOwnPropertySymbols(t); i < r.length; i++)
123
+ e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
124
+ return n;
125
125
  }, Z = j(function(t, e) {
126
- var r = t.icon, n = t.id, i = t.className, a = t.extend, d = Nt(t, ["icon", "id", "className", "extend"]), C = "univerjs-icon univerjs-icon-".concat(n, " ").concat(i || "").trim(), g = re("_".concat(Ot()));
127
- return $e(r, "".concat(n), { defIds: r.defIds, idSuffix: g.current }, H({ ref: e, className: C }, d), a);
126
+ var n = t.icon, r = t.id, i = t.className, a = t.extend, d = Nt(t, ["icon", "id", "className", "extend"]), C = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), g = re("_".concat(Ot()));
127
+ return $e(n, "".concat(r), { defIds: n.defIds, idSuffix: g.current }, H({ ref: e, className: C }, d), a);
128
128
  });
129
- function $e(t, e, r, n, i) {
130
- return z(t.tag, H(H({ key: e }, Ut(t, r, i)), n), (Et(t, r).children || []).map(function(a, d) {
131
- return $e(a, "".concat(e, "-").concat(t.tag, "-").concat(d), r, void 0, i);
129
+ function $e(t, e, n, r, i) {
130
+ return z(t.tag, H(H({ key: e }, Ut(t, n, i)), r), (Et(t, n).children || []).map(function(a, d) {
131
+ return $e(a, "".concat(e, "-").concat(t.tag, "-").concat(d), n, void 0, i);
132
132
  }));
133
133
  }
134
- function Ut(t, e, r) {
135
- var n = H({}, t.attrs);
136
- r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), t.tag === "mask" && n.id && (n.id = n.id + e.idSuffix), Object.entries(n).forEach(function(a) {
134
+ function Ut(t, e, n) {
135
+ var r = H({}, t.attrs);
136
+ n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1), t.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(a) {
137
137
  var d = a[0], C = a[1];
138
- d === "mask" && typeof C == "string" && (n[d] = C.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
138
+ d === "mask" && typeof C == "string" && (r[d] = C.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
139
139
  });
140
140
  var i = e.defIds;
141
- return !i || i.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(a) {
141
+ return !i || i.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(a) {
142
142
  var d = a[0], C = a[1];
143
- typeof C == "string" && (n[d] = C.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
144
- })), n;
143
+ typeof C == "string" && (r[d] = C.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
144
+ })), r;
145
145
  }
146
146
  function Et(t, e) {
147
- var r, n = e.defIds;
148
- return !n || n.length === 0 ? t : t.tag === "defs" && (!((r = t.children) === null || r === void 0) && r.length) ? H(H({}, t), { children: t.children.map(function(i) {
149
- return typeof i.attrs.id == "string" && n && n.indexOf(i.attrs.id) > -1 ? H(H({}, i), { attrs: H(H({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
147
+ var n, r = e.defIds;
148
+ return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? H(H({}, t), { children: t.children.map(function(i) {
149
+ return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? H(H({}, i), { attrs: H(H({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
150
150
  }) }) : t;
151
151
  }
152
152
  function Ot() {
@@ -201,21 +201,8 @@ var kt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em"
201
201
  }));
202
202
  });
203
203
  we.displayName = "SolveSingle";
204
- function Le(t) {
205
- var e, r, n = "";
206
- if (typeof t == "string" || typeof t == "number") n += t;
207
- else if (typeof t == "object") if (Array.isArray(t)) {
208
- var i = t.length;
209
- for (e = 0; e < i; e++) t[e] && (r = Le(t[e])) && (n && (n += " "), n += r);
210
- } else for (r in t) t[r] && (n && (n += " "), n += r);
211
- return n;
212
- }
213
- function Rt() {
214
- for (var t, e, r = 0, n = "", i = arguments.length; r < i; r++) (t = arguments[r]) && (e = Le(t)) && (n && (n += " "), n += e);
215
- return n;
216
- }
217
- const wt = "univer-thread-comment-editor-buttons", _e = {
218
- threadCommentEditorButtons: wt
204
+ const Rt = "univer-thread-comment-editor-buttons", _e = {
205
+ threadCommentEditorButtons: Rt
219
206
  };
220
207
  function xe(t) {
221
208
  return {
@@ -224,18 +211,18 @@ function xe(t) {
224
211
  documentStyle: {}
225
212
  };
226
213
  }
227
- const Ve = j((t, e) => {
214
+ const Le = j((t, e) => {
228
215
  var R;
229
- const { comment: r, onSave: n, id: i, onCancel: a, autoFocus: d, unitId: C, type: g } = t, N = T(ie), O = T(fe), [w, P] = V(!1), U = T(ht), m = re(null), f = g === he.UNIVER_SHEET ? Je : C, [$, S] = V(() => {
216
+ const { comment: n, onSave: r, id: i, onCancel: a, autoFocus: d, unitId: C, type: g } = t, N = T(ie), O = T(fe), [w, P] = V(!1), U = T(ht), m = re(null), f = g === he.UNIVER_SHEET ? qe : C, [$, y] = V(() => {
230
217
  var c, u, p;
231
218
  return Ce.transform.getPlainText((p = (u = (c = m.current) == null ? void 0 : c.getDocumentData().body) == null ? void 0 : u.dataStream) != null ? p : "");
232
219
  });
233
220
  me(() => {
234
221
  var u, p, s, h;
235
- S(Ce.transform.getPlainText((s = (p = (u = m.current) == null ? void 0 : u.getDocumentData().body) == null ? void 0 : p.dataStream) != null ? s : ""));
222
+ y(Ce.transform.getPlainText((s = (p = (u = m.current) == null ? void 0 : u.getDocumentData().body) == null ? void 0 : p.dataStream) != null ? s : ""));
236
223
  const c = (h = m.current) == null ? void 0 : h.selectionChange$.subscribe(() => {
237
224
  var K, _, b;
238
- S(Ce.transform.getPlainText((b = (_ = (K = m.current) == null ? void 0 : K.getDocumentData().body) == null ? void 0 : _.dataStream) != null ? b : ""));
225
+ y(Ce.transform.getPlainText((b = (_ = (K = m.current) == null ? void 0 : K.getDocumentData().body) == null ? void 0 : _.dataStream) != null ? b : ""));
239
226
  });
240
227
  return () => c == null ? void 0 : c.unsubscribe();
241
228
  }, [(R = m.current) == null ? void 0 : R.selectionChange$]);
@@ -255,9 +242,9 @@ const Ve = j((t, e) => {
255
242
  }));
256
243
  const I = () => {
257
244
  if (m.current) {
258
- const c = Qe.deepClone(m.current.getDocumentData().body);
259
- P(!1), n == null || n({
260
- ...r,
245
+ const c = Je.deepClone(m.current.getDocumentData().body);
246
+ P(!1), r == null || r({
247
+ ...n,
261
248
  text: c
262
249
  }), m.current.replaceText(""), setTimeout(() => {
263
250
  var u, p;
@@ -265,7 +252,7 @@ const Ve = j((t, e) => {
265
252
  }, 10);
266
253
  }
267
254
  };
268
- return /* @__PURE__ */ y("div", { className: _e.threadCommentEditor, onClick: (c) => c.preventDefault(), children: [
255
+ return /* @__PURE__ */ S("div", { className: _e.threadCommentEditor, onClick: (c) => c.preventDefault(), children: [
269
256
  /* @__PURE__ */ l(
270
257
  vt,
271
258
  {
@@ -274,7 +261,7 @@ const Ve = j((t, e) => {
274
261
  style: { width: "100%" },
275
262
  keyboardEventConfig: M,
276
263
  placeholder: O.t("threadCommentUI.editor.placeholder"),
277
- initialValue: (r == null ? void 0 : r.text) && xe(r.text),
264
+ initialValue: (n == null ? void 0 : n.text) && xe(n.text),
278
265
  onFocusChange: (c) => c && P(c),
279
266
  isSingle: !1,
280
267
  maxHeight: 64,
@@ -285,7 +272,7 @@ const Ve = j((t, e) => {
285
272
  }
286
273
  }
287
274
  ),
288
- w ? /* @__PURE__ */ y("div", { className: _e.threadCommentEditorButtons, children: [
275
+ w ? /* @__PURE__ */ S("div", { className: _e.threadCommentEditorButtons, children: [
289
276
  /* @__PURE__ */ l(
290
277
  ce,
291
278
  {
@@ -308,11 +295,11 @@ const Ve = j((t, e) => {
308
295
  )
309
296
  ] }) : null
310
297
  ] });
311
- }), Lt = (t) => {
312
- const { dataStream: e, customRanges: r } = t, n = e.endsWith(`\r
298
+ }), wt = (t) => {
299
+ const { dataStream: e, customRanges: n } = t, r = e.endsWith(`\r
313
300
  `) ? e.length - 2 : e.length, i = [];
314
301
  let a = 0;
315
- return r == null || r.forEach((d) => {
302
+ return n == null || n.forEach((d) => {
316
303
  a < d.startIndex && i.push({
317
304
  type: "text",
318
305
  content: e.slice(a, d.startIndex)
@@ -325,30 +312,30 @@ const Ve = j((t, e) => {
325
312
  }), a = d.endIndex + 1;
326
313
  }), i.push({
327
314
  type: "text",
328
- content: e.slice(a, n)
315
+ content: e.slice(a, r)
329
316
  }), i;
330
- }, Vt = (t) => {
317
+ }, Lt = (t) => {
331
318
  const { paragraphs: e = [] } = t;
332
- let r = 0;
333
- return e.map((n) => {
334
- const i = et(t, r, n.startIndex);
335
- return r = n.startIndex + 1, Lt(i);
319
+ let n = 0;
320
+ return e.map((r) => {
321
+ const i = Xe(t, n, r.startIndex);
322
+ return n = r.startIndex + 1, wt(i);
336
323
  });
337
- }, jt = (t) => {
324
+ }, Vt = (t) => {
338
325
  let e = "";
339
- const r = [];
340
- return t.forEach((n) => {
341
- switch (n.type) {
326
+ const n = [];
327
+ return t.forEach((r) => {
328
+ switch (r.type) {
342
329
  case "text":
343
- e += n.content;
330
+ e += r.content;
344
331
  break;
345
332
  case "mention": {
346
333
  const i = e.length;
347
- e += n.content.label;
334
+ e += r.content.label;
348
335
  const a = e.length - 1;
349
- r.push({
350
- rangeId: n.content.id,
351
- rangeType: Xe.MENTION,
336
+ n.push({
337
+ rangeId: r.content.id,
338
+ rangeType: Qe.MENTION,
352
339
  startIndex: i,
353
340
  endIndex: a,
354
341
  properties: {}
@@ -371,47 +358,47 @@ const Ve = j((t, e) => {
371
358
  }
372
359
  ],
373
360
  dataStream: e,
374
- customRanges: r
361
+ customRanges: n
375
362
  };
376
- }, At = "univer-thread-comment", Bt = "univer-thread-comment-active", Wt = "univer-thread-comment-content", Ft = "univer-thread-comment-highlight", zt = "univer-thread-comment-icon-container", Zt = "univer-thread-comment-icon", Kt = "univer-thread-comment-title", Gt = "univer-thread-comment-title-position", Yt = "univer-thread-comment-title-highlight", qt = "univer-thread-comment-title-position-text", Jt = "univer-thread-comment-username", Qt = "univer-thread-comment-item", Xt = "univer-thread-comment-item-head", en = "univer-thread-comment-item-title", tn = "univer-thread-comment-item-time", nn = "univer-thread-comment-item-content", rn = "univer-thread-comment-item-at", v = {
377
- threadComment: At,
378
- threadCommentActive: Bt,
379
- threadCommentContent: Wt,
380
- threadCommentHighlight: Ft,
381
- threadCommentIconContainer: zt,
382
- threadCommentIcon: Zt,
383
- threadCommentTitle: Kt,
384
- threadCommentTitlePosition: Gt,
385
- threadCommentTitleHighlight: Yt,
386
- threadCommentTitlePositionText: qt,
387
- threadCommentUsername: Jt,
388
- threadCommentItem: Qt,
389
- threadCommentItemHead: Xt,
390
- threadCommentItemTitle: en,
391
- threadCommentItemTime: tn,
392
- threadCommentItemContent: nn,
393
- threadCommentItemAt: rn
394
- }, je = "__mock__", on = (t) => {
395
- const { item: e, unitId: r, subUnitId: n, editing: i, onEditingChange: a, onReply: d, resolved: C, isRoot: g, onClose: N, onDeleteComment: O, type: w } = t, P = T(ie), U = T(fe), m = T(pe), f = m.getUser(e.personId), $ = W(m.currentUser$), S = ($ == null ? void 0 : $.userID) === e.personId, M = e.id === je, [I, R] = V(!1), c = () => {
363
+ }, jt = "univer-thread-comment", At = "univer-thread-comment-active", Bt = "univer-thread-comment-content", Wt = "univer-thread-comment-highlight", Ft = "univer-thread-comment-icon-container", zt = "univer-thread-comment-icon", Zt = "univer-thread-comment-title", Kt = "univer-thread-comment-title-position", Gt = "univer-thread-comment-title-highlight", Yt = "univer-thread-comment-title-position-text", qt = "univer-thread-comment-username", Jt = "univer-thread-comment-item", Qt = "univer-thread-comment-item-head", Xt = "univer-thread-comment-item-title", en = "univer-thread-comment-item-time", tn = "univer-thread-comment-item-content", nn = "univer-thread-comment-item-at", v = {
364
+ threadComment: jt,
365
+ threadCommentActive: At,
366
+ threadCommentContent: Bt,
367
+ threadCommentHighlight: Wt,
368
+ threadCommentIconContainer: Ft,
369
+ threadCommentIcon: zt,
370
+ threadCommentTitle: Zt,
371
+ threadCommentTitlePosition: Kt,
372
+ threadCommentTitleHighlight: Gt,
373
+ threadCommentTitlePositionText: Yt,
374
+ threadCommentUsername: qt,
375
+ threadCommentItem: Jt,
376
+ threadCommentItemHead: Qt,
377
+ threadCommentItemTitle: Xt,
378
+ threadCommentItemTime: en,
379
+ threadCommentItemContent: tn,
380
+ threadCommentItemAt: nn
381
+ }, Ve = "__mock__", rn = (t) => {
382
+ const { item: e, unitId: n, subUnitId: r, editing: i, onEditingChange: a, onReply: d, resolved: C, isRoot: g, onClose: N, onDeleteComment: O, type: w } = t, P = T(ie), U = T(fe), m = T(pe), f = m.getUser(e.personId), $ = W(m.currentUser$), y = ($ == null ? void 0 : $.userID) === e.personId, M = e.id === Ve, [I, R] = V(!1), c = () => {
396
383
  (O == null ? void 0 : O(e)) !== !1 && (P.executeCommand(
397
- g ? Ee.id : st.id,
384
+ g ? Ee.id : at.id,
398
385
  {
399
- unitId: r,
400
- subUnitId: n,
386
+ unitId: n,
387
+ subUnitId: r,
401
388
  commentId: e.id
402
389
  }
403
390
  ), g && (N == null || N()));
404
391
  };
405
- return /* @__PURE__ */ y("div", { className: v.threadCommentItem, onMouseLeave: () => R(!1), onMouseEnter: () => R(!0), children: [
392
+ return /* @__PURE__ */ S("div", { className: v.threadCommentItem, onMouseLeave: () => R(!1), onMouseEnter: () => R(!0), children: [
406
393
  /* @__PURE__ */ l("img", { className: v.threadCommentItemHead, src: f == null ? void 0 : f.avatar }),
407
- /* @__PURE__ */ y("div", { className: v.threadCommentItemTitle, children: [
394
+ /* @__PURE__ */ S("div", { className: v.threadCommentItemTitle, children: [
408
395
  /* @__PURE__ */ l("div", { className: v.threadCommentUsername, children: (f == null ? void 0 : f.name) || " " }),
409
- /* @__PURE__ */ y("div", { children: [
396
+ /* @__PURE__ */ S("div", { children: [
410
397
  M || C ? null : I ? /* @__PURE__ */ l("div", { className: v.threadCommentIcon, onClick: () => d(f), children: /* @__PURE__ */ l(ke, {}) }) : null,
411
- S && !M && !C ? /* @__PURE__ */ l(
398
+ y && !M && !C ? /* @__PURE__ */ l(
412
399
  mt,
413
400
  {
414
- overlay: /* @__PURE__ */ l("div", { className: "univer-rounded-lg univer-p-4 univer-theme", children: /* @__PURE__ */ y(
401
+ overlay: /* @__PURE__ */ l("div", { className: "univer-rounded-lg univer-p-4 univer-theme", children: /* @__PURE__ */ S(
415
402
  "ul",
416
403
  {
417
404
  className: `
@@ -446,21 +433,21 @@ const Ve = j((t, e) => {
446
433
  ] }),
447
434
  /* @__PURE__ */ l("div", { className: v.threadCommentItemTime, children: e.dT }),
448
435
  i ? /* @__PURE__ */ l(
449
- Ve,
436
+ Le,
450
437
  {
451
438
  type: w,
452
439
  id: e.id,
453
440
  comment: e,
454
441
  onCancel: () => a == null ? void 0 : a(!1),
455
442
  autoFocus: !0,
456
- unitId: r,
457
- subUnitId: n,
443
+ unitId: n,
444
+ subUnitId: r,
458
445
  onSave: ({ text: u, attachments: p }) => {
459
446
  a == null || a(!1), P.executeCommand(
460
- at.id,
447
+ ot.id,
461
448
  {
462
- unitId: r,
463
- subUnitId: n,
449
+ unitId: n,
450
+ subUnitId: r,
464
451
  payload: {
465
452
  commentId: e.id,
466
453
  text: u,
@@ -470,10 +457,10 @@ const Ve = j((t, e) => {
470
457
  );
471
458
  }
472
459
  }
473
- ) : /* @__PURE__ */ l("div", { className: v.threadCommentItemContent, children: Vt(e.text).map((u, p) => /* @__PURE__ */ l("div", { children: u.map((s, h) => {
460
+ ) : /* @__PURE__ */ l("div", { className: v.threadCommentItemContent, children: Lt(e.text).map((u, p) => /* @__PURE__ */ l("div", { children: u.map((s, h) => {
474
461
  switch (s.type) {
475
462
  case "mention":
476
- return /* @__PURE__ */ y("a", { className: v.threadCommentItemAt, children: [
463
+ return /* @__PURE__ */ S("a", { className: v.threadCommentItemAt, children: [
477
464
  s.content.label,
478
465
  " "
479
466
  ] }, h);
@@ -482,12 +469,12 @@ const Ve = j((t, e) => {
482
469
  }
483
470
  }) }, p)) })
484
471
  ] });
485
- }, an = (t) => {
472
+ }, on = (t) => {
486
473
  var X, ee, se;
487
474
  const {
488
475
  id: e,
489
- unitId: r,
490
- subUnitId: n,
476
+ unitId: n,
477
+ subUnitId: r,
491
478
  refStr: i,
492
479
  showEdit: a = !0,
493
480
  onClick: d,
@@ -501,14 +488,14 @@ const Ve = j((t, e) => {
501
488
  onAddComment: m,
502
489
  onDeleteComment: f,
503
490
  onResolve: $,
504
- type: S
505
- } = t, M = T(Ue), [I, R] = V(!1), [c, u] = V(""), p = ne(() => M.commentUpdate$.pipe(dt(16)), [M]);
491
+ type: y
492
+ } = t, M = T(Ue), [I, R] = V(!1), [c, u] = V(""), p = ne(() => M.commentUpdate$.pipe(lt(16)), [M]);
506
493
  W(p);
507
- const s = e ? M.getCommentWithChildren(r, n, e) : null, h = T(ie), K = T(pe), _ = s == null ? void 0 : s.root.resolved, b = W(K.currentUser$), G = re(null), oe = [
494
+ const s = e ? M.getCommentWithChildren(n, r, e) : null, h = T(ie), K = T(pe), _ = s == null ? void 0 : s.root.resolved, b = W(K.currentUser$), G = re(null), oe = [
508
495
  ...s ? [s.root] : (
509
496
  // mock empty comment
510
497
  [{
511
- id: je,
498
+ id: Ve,
512
499
  text: {
513
500
  dataStream: `
514
501
  \r`
@@ -516,20 +503,20 @@ const Ve = j((t, e) => {
516
503
  personId: (X = b == null ? void 0 : b.userID) != null ? X : "",
517
504
  ref: i != null ? i : "",
518
505
  dT: "",
519
- unitId: r,
520
- subUnitId: n,
506
+ unitId: n,
507
+ subUnitId: r,
521
508
  threadId: ""
522
509
  }]
523
510
  ),
524
511
  ...(ee = s == null ? void 0 : s.children) != null ? ee : []
525
512
  ], D = re(null), q = (x) => {
526
513
  x.stopPropagation(), _ ? h.executeCommand(F.id, {
527
- unitId: r,
528
- subUnitId: n,
514
+ unitId: n,
515
+ subUnitId: r,
529
516
  commentId: e
530
- }) : h.executeCommand(F.id), h.executeCommand(ot.id, {
531
- unitId: r,
532
- subUnitId: n,
517
+ }) : h.executeCommand(F.id), h.executeCommand(it.id, {
518
+ unitId: n,
519
+ subUnitId: r,
533
520
  commentId: e,
534
521
  resolved: !_
535
522
  }), $ == null || $(!_);
@@ -537,22 +524,22 @@ const Ve = j((t, e) => {
537
524
  x.stopPropagation(), h.executeCommand(F.id), !(s != null && s.root && (f == null ? void 0 : f(s.root)) === !1) && (h.executeCommand(
538
525
  Ee.id,
539
526
  {
540
- unitId: r,
541
- subUnitId: n,
527
+ unitId: n,
528
+ subUnitId: r,
542
529
  commentId: e
543
530
  }
544
531
  ), g == null || g());
545
532
  };
546
533
  me(() => U == null ? void 0 : U(), []);
547
- const J = N((se = s == null ? void 0 : s.root.subUnitId) != null ? se : n), Q = a && !c && !_, ae = `${i || (s == null ? void 0 : s.root.ref) || ""}${J ? " · " : ""}${J}`;
548
- return /* @__PURE__ */ y(
534
+ const J = N((se = s == null ? void 0 : s.root.subUnitId) != null ? se : r), Q = a && !c && !_, ae = `${i || (s == null ? void 0 : s.root.ref) || ""}${J ? " · " : ""}${J}`;
535
+ return /* @__PURE__ */ S(
549
536
  "div",
550
537
  {
551
- className: Rt(v.threadComment, {
538
+ className: dt(v.threadComment, {
552
539
  [v.threadCommentActive]: !_ && (C || I || O === "cell")
553
540
  }),
554
541
  onClick: d,
555
- id: `${O}-${r}-${n}-${e}`,
542
+ id: `${O}-${n}-${r}-${e}`,
556
543
  onMouseEnter: () => {
557
544
  P == null || P(), R(!0);
558
545
  },
@@ -561,12 +548,12 @@ const Ve = j((t, e) => {
561
548
  },
562
549
  children: [
563
550
  !_ && C ? /* @__PURE__ */ l("div", { className: v.threadCommentHighlight }) : null,
564
- /* @__PURE__ */ y("div", { className: v.threadCommentTitle, children: [
565
- /* @__PURE__ */ y("div", { className: v.threadCommentTitlePosition, children: [
551
+ /* @__PURE__ */ S("div", { className: v.threadCommentTitle, children: [
552
+ /* @__PURE__ */ S("div", { className: v.threadCommentTitlePosition, children: [
566
553
  /* @__PURE__ */ l("div", { className: v.threadCommentTitleHighlight }),
567
554
  /* @__PURE__ */ l(ct, { showIfEllipsis: !0, title: ae, children: /* @__PURE__ */ l("div", { className: v.threadCommentTitlePositionText, children: ae }) })
568
555
  ] }),
569
- s ? /* @__PURE__ */ y("div", { className: v.threadCommentIconContainer, children: [
556
+ s ? /* @__PURE__ */ S("div", { className: v.threadCommentIconContainer, children: [
570
557
  /* @__PURE__ */ l(
571
558
  "div",
572
559
  {
@@ -581,23 +568,23 @@ const Ve = j((t, e) => {
581
568
  ] }),
582
569
  /* @__PURE__ */ l("div", { className: v.threadCommentContent, ref: D, children: oe.map(
583
570
  (x) => /* @__PURE__ */ l(
584
- on,
571
+ rn,
585
572
  {
586
573
  onClose: g,
587
- unitId: r,
588
- subUnitId: n,
574
+ unitId: n,
575
+ subUnitId: r,
589
576
  item: x,
590
577
  isRoot: x.id === (s == null ? void 0 : s.root.id),
591
578
  editing: c === x.id,
592
579
  resolved: s == null ? void 0 : s.root.resolved,
593
- type: S,
580
+ type: y,
594
581
  onEditingChange: (o) => {
595
582
  u(o ? x.id : "");
596
583
  },
597
584
  onReply: (o) => {
598
585
  o && requestAnimationFrame(() => {
599
586
  var k;
600
- (k = G.current) == null || k.reply(jt([{
587
+ (k = G.current) == null || k.reply(Vt([{
601
588
  type: "mention",
602
589
  content: {
603
590
  id: o.userID,
@@ -613,30 +600,30 @@ const Ve = j((t, e) => {
613
600
  )
614
601
  ) }),
615
602
  Q ? /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l(
616
- Ve,
603
+ Le,
617
604
  {
618
605
  ref: G,
619
- type: S,
620
- unitId: r,
621
- subUnitId: n,
606
+ type: y,
607
+ unitId: n,
608
+ subUnitId: r,
622
609
  onSave: async ({ text: x, attachments: o }) => {
623
610
  const k = {
624
611
  text: x,
625
612
  attachments: o,
626
- dT: rt(),
627
- id: tt(),
613
+ dT: nt(),
614
+ id: et(),
628
615
  ref: i,
629
616
  personId: b == null ? void 0 : b.userID,
630
617
  parentId: s == null ? void 0 : s.root.id,
631
- unitId: r,
632
- subUnitId: n,
618
+ unitId: n,
619
+ subUnitId: r,
633
620
  threadId: s == null ? void 0 : s.root.threadId
634
621
  };
635
622
  (m == null ? void 0 : m(k)) !== !1 && (await h.executeCommand(
636
- it.id,
623
+ rt.id,
637
624
  {
638
- unitId: r,
639
- subUnitId: n,
625
+ unitId: n,
626
+ subUnitId: r,
640
627
  comment: k
641
628
  }
642
629
  ), D.current && (D.current.scrollTop = D.current.scrollHeight));
@@ -651,17 +638,17 @@ const Ve = j((t, e) => {
651
638
  ]
652
639
  }
653
640
  );
654
- }, sn = "univer-thread-comment-panel", ln = "univer-thread-comment-panel-forms", dn = "univer-thread-comment-panel-empty", cn = "univer-thread-comment-panel-add", mn = "univer-thread-comment-panel-solved", te = {
655
- threadCommentPanel: sn,
656
- threadCommentPanelForms: ln,
657
- threadCommentPanelEmpty: dn,
658
- threadCommentPanelAdd: cn,
659
- threadCommentPanelSolved: mn
660
- }, yn = (t) => {
641
+ }, an = "univer-thread-comment-panel", sn = "univer-thread-comment-panel-forms", ln = "univer-thread-comment-panel-empty", dn = "univer-thread-comment-panel-add", cn = "univer-thread-comment-panel-solved", te = {
642
+ threadCommentPanel: an,
643
+ threadCommentPanelForms: sn,
644
+ threadCommentPanelEmpty: ln,
645
+ threadCommentPanelAdd: dn,
646
+ threadCommentPanelSolved: cn
647
+ }, bn = (t) => {
661
648
  const {
662
649
  unitId: e,
663
- subUnitId$: r,
664
- type: n,
650
+ subUnitId$: n,
651
+ type: r,
665
652
  onAdd: i,
666
653
  getSubUnitName: a,
667
654
  onResolve: d,
@@ -673,7 +660,7 @@ const Ve = j((t, e) => {
673
660
  onAddComment: P,
674
661
  onDeleteComment: U,
675
662
  showComments: m
676
- } = t, [f, $] = V("all"), [S, M] = V("all"), I = T(fe), R = T(pe), c = T(Ue), [u, p] = V(() => c.getUnit(e)), s = T(Y), h = W(s.activeCommentId$), K = W(c.commentUpdate$), _ = T(ie), b = W(r), G = re(!0), oe = "panel", D = W(R.currentUser$), q = ne(() => {
663
+ } = t, [f, $] = V("all"), [y, M] = V("all"), I = T(fe), R = T(pe), c = T(Ue), [u, p] = V(() => c.getUnit(e)), s = T(Y), h = W(s.activeCommentId$), K = W(c.commentUpdate$), _ = T(ie), b = W(n), G = re(!0), oe = "panel", D = W(R.currentUser$), q = ne(() => {
677
664
  var de;
678
665
  const o = f === "all" ? u : (de = u.filter((E) => E.subUnitId === b)) != null ? de : [], k = C != null ? C : (E) => E, le = o.map((E) => {
679
666
  var A;
@@ -689,7 +676,7 @@ const Ve = j((t, e) => {
689
676
  }, [m, f, u, C, b]), L = ne(() => [
690
677
  ...q.filter((o) => !o.resolved),
691
678
  ...q.filter((o) => o.resolved)
692
- ], [q]), J = ne(() => S === "resolved" ? L.filter((o) => o.resolved) : S === "unsolved" ? L.filter((o) => !o.resolved) : S === "concern_me" && D != null && D.userID ? L.filter((o) => o == null ? void 0 : o.users.has(D.userID)) : L, [L, D == null ? void 0 : D.userID, S]), Q = w ? [w, ...J] : J, ae = Q.filter((o) => !o.resolved), X = Q.filter((o) => o.resolved), ee = S !== "all" || f !== "all", se = () => {
679
+ ], [q]), J = ne(() => y === "resolved" ? L.filter((o) => o.resolved) : y === "unsolved" ? L.filter((o) => !o.resolved) : y === "concern_me" && D != null && D.userID ? L.filter((o) => o == null ? void 0 : o.users.has(D.userID)) : L, [L, D == null ? void 0 : D.userID, y]), Q = w ? [w, ...J] : J, ae = Q.filter((o) => !o.resolved), X = Q.filter((o) => o.resolved), ee = y !== "all" || f !== "all", se = () => {
693
680
  M("all"), $("all");
694
681
  };
695
682
  me(() => {
@@ -708,7 +695,7 @@ const Ve = j((t, e) => {
708
695
  (E = document.getElementById(de)) == null || E.scrollIntoView({ block: "center" });
709
696
  }, [h]);
710
697
  const x = (o) => /* @__PURE__ */ l(
711
- an,
698
+ on,
712
699
  {
713
700
  prefix: oe,
714
701
  getSubUnitName: a,
@@ -716,7 +703,7 @@ const Ve = j((t, e) => {
716
703
  unitId: o.unitId,
717
704
  subUnitId: o.subUnitId,
718
705
  refStr: o.ref,
719
- type: n,
706
+ type: r,
720
707
  showEdit: (h == null ? void 0 : h.commentId) === o.id,
721
708
  showHighlight: (h == null ? void 0 : h.commentId) === o.id,
722
709
  onClick: () => {
@@ -738,9 +725,9 @@ const Ve = j((t, e) => {
738
725
  },
739
726
  o.id
740
727
  );
741
- return /* @__PURE__ */ y("div", { className: te.threadCommentPanel, children: [
742
- /* @__PURE__ */ y("div", { className: te.threadCommentPanelForms, children: [
743
- n === he.UNIVER_SHEET ? /* @__PURE__ */ l(
728
+ return /* @__PURE__ */ S("div", { className: te.threadCommentPanel, children: [
729
+ /* @__PURE__ */ S("div", { className: te.threadCommentPanelForms, children: [
730
+ r === he.UNIVER_SHEET ? /* @__PURE__ */ l(
744
731
  be,
745
732
  {
746
733
  borderless: !0,
@@ -762,7 +749,7 @@ const Ve = j((t, e) => {
762
749
  be,
763
750
  {
764
751
  borderless: !0,
765
- value: S,
752
+ value: y,
766
753
  onChange: (o) => M(o),
767
754
  options: [
768
755
  {
@@ -788,7 +775,7 @@ const Ve = j((t, e) => {
788
775
  ae.map(x),
789
776
  X.length ? /* @__PURE__ */ l("div", { className: te.threadCommentPanelSolved, children: "已解决" }) : null,
790
777
  X.map(x),
791
- Q.length ? null : /* @__PURE__ */ y("div", { className: te.threadCommentPanelEmpty, children: [
778
+ Q.length ? null : /* @__PURE__ */ S("div", { className: te.threadCommentPanelEmpty, children: [
792
779
  ee ? I.t("threadCommentUI.panel.filterEmpty") : I.t("threadCommentUI.panel.empty"),
793
780
  ee ? /* @__PURE__ */ l(
794
781
  ce,
@@ -797,7 +784,7 @@ const Ve = j((t, e) => {
797
784
  type: "link",
798
785
  children: I.t("threadCommentUI.panel.reset")
799
786
  }
800
- ) : /* @__PURE__ */ y(
787
+ ) : /* @__PURE__ */ S(
801
788
  ce,
802
789
  {
803
790
  id: "thread-comment-add",
@@ -817,9 +804,9 @@ const Ve = j((t, e) => {
817
804
  export {
818
805
  F as SetActiveCommentOperation,
819
806
  gt as THREAD_COMMENT_PANEL,
820
- yn as ThreadCommentPanel,
807
+ bn as ThreadCommentPanel,
821
808
  Y as ThreadCommentPanelService,
822
- an as ThreadCommentTree,
809
+ on as ThreadCommentTree,
823
810
  bt as ToggleSheetCommentPanelOperation,
824
811
  ue as UniverThreadCommentUIPlugin
825
812
  };
package/lib/umd/index.js CHANGED
@@ -1,8 +1,8 @@
1
- (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,C,te,o,B,m,se){"use strict";var Je=Object.defineProperty;var Qe=(c,a,_)=>a in c?Je(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var K=(c,a,_)=>Qe(c,typeof a!="symbol"?a+"":a,_);var Pe=Object.getOwnPropertyDescriptor,xe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Pe(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},le=(n,e)=>(t,r)=>e(t,r,n);c.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();K(this,"_panelVisible",!1);K(this,"_panelVisible$",new te.BehaviorSubject(!1));K(this,"_activeCommentId");K(this,"_activeCommentId$",new te.BehaviorSubject(void 0));K(this,"panelVisible$",this._panelVisible$.asObservable());K(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(te.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},c.ThreadCommentPanelService=xe([le(0,a.Inject(C.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const me="thread-comment-panel",Ee="UNIVER_THREAD_COMMENT_UI_PLUGIN",ce={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(C.ISidebarService),t=n.get(c.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:me},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},De="thread-comment-ui.config",he={};var Oe=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,He=(n,e,t)=>e in n?Oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,we=(n,e,t,r)=>{for(var i=r>1?void 0:r?Me(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},de=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=he,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:d,...h}=a.merge({},he,this._config);d&&this._configService.setConfig("menu",d,{merge:!0}),this._configService.setConfig(De,h)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ce,F].forEach(t=>{this._commandService.registerCommand(t)})}},ue(c.UniverThreadCommentUIPlugin,"pluginName",Ee),ue(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=we([a.DependentOn(_.UniverThreadCommentPlugin),de(1,a.Inject(a.Injector)),de(2,a.ICommandService),de(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},je=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},q=m.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,d=n.extend,h=je(n,["icon","id","className","extend"]),I="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),b=m.useRef("_".concat(Ae()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:b.current},M({ref:e,className:I},h),d)});function ve(n,e,t,r,i){return m.createElement(n.tag,M(M({key:e},ke(n,t,i)),r),($e(n,t).children||[]).map(function(d,h){return ve(d,"".concat(e,"-").concat(n.tag,"-").concat(h),t,void 0,i)}))}function ke(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],I=d[1];h==="mask"&&typeof I=="string"&&(r[h]=I.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],I=d[1];typeof I=="string"&&(r[h]=I.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function $e(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Ae(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});Ce.displayName="DeleteSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Ve}))});fe.displayName="IncreaseSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},pe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Be}))});pe.displayName="MoreHorizontalSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},ge=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Fe}))});ge.displayName="ReplyToCommentSingle";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ie=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:We}))});Ie.displayName="ResolvedSingle";var qe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Se=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:qe}))});Se.displayName="SolveSingle";function ye(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=ye(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ze(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=ye(n))&&(r&&(r+=" "),r+=e);return r}const be={threadCommentEditorButtons:"univer-thread-comment-editor-buttons"};function Te(n){return{id:"d",body:n,documentStyle:{}}}const _e=m.forwardRef((n,e)=>{var L;const{comment:t,onSave:r,id:i,onCancel:d,autoFocus:h,unitId:I,type:b}=n,E=C.useDependency(a.ICommandService),H=C.useDependency(a.LocaleService),[V,w]=m.useState(!1),D=C.useDependency(se.IEditorService),v=m.useRef(null),S=b===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:I,[j,N]=m.useState(()=>{var u,f,y;return a.BuildTextUtils.transform.getPlainText((y=(f=(u=v.current)==null?void 0:u.getDocumentData().body)==null?void 0:f.dataStream)!=null?y:"")});m.useEffect(()=>{var f,y,l,p;N(a.BuildTextUtils.transform.getPlainText((l=(y=(f=v.current)==null?void 0:f.getDocumentData().body)==null?void 0:y.dataStream)!=null?l:""));const u=(p=v.current)==null?void 0:p.selectionChange$.subscribe(()=>{var Z,P,U;N(a.BuildTextUtils.transform.getPlainText((U=(P=(Z=v.current)==null?void 0:Z.getDocumentData().body)==null?void 0:P.dataStream)!=null?U:""))});return()=>u==null?void 0:u.unsubscribe()},[(L=v.current)==null?void 0:L.selectionChange$]);const $=m.useMemo(()=>({keyCodes:[{keyCode:C.KeyCode.ENTER}],handler:u=>{u===C.KeyCode.ENTER&&E.executeCommand(se.BreakLineCommand.id)}}),[E]);m.useImperativeHandle(e,()=>({reply(u){var f,y;(f=v.current)==null||f.focus(),(y=v.current)==null||y.setDocumentData(Te(u))}}));const T=()=>{if(v.current){const u=a.Tools.deepClone(v.current.getDocumentData().body);w(!1),r==null||r({...t,text:u}),v.current.replaceText(""),setTimeout(()=>{var f,y;(f=v.current)==null||f.setSelectionRanges([]),(y=v.current)==null||y.blur()},10)}};return o.jsxs("div",{className:be.threadCommentEditor,onClick:u=>u.preventDefault(),children:[o.jsx(se.RichTextEditor,{editorRef:v,autoFocus:h,style:{width:"100%"},keyboardEventConfig:$,placeholder:H.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&Te(t.text),onFocusChange:u=>u&&w(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{D.focus(S)},30)}}),V?o.jsxs("div",{className:be.threadCommentEditorButtons,children:[o.jsx(B.Button,{style:{marginRight:12},onClick:()=>{var u;d==null||d(),w(!1),(u=v.current)==null||u.replaceText("",!0),E.executeCommand(F.id)},children:H.t("threadCommentUI.editor.cancel")}),o.jsx(B.Button,{type:"primary",disabled:!j,onClick:T,children:H.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),Ke=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
2
- `)?e.length-2:e.length,i=[];let d=0;return t==null||t.forEach(h=>{d<h.startIndex&&i.push({type:"text",content:e.slice(d,h.startIndex)}),i.push({type:"mention",content:{label:e.slice(h.startIndex,h.endIndex+1),id:h.rangeId}}),d=h.endIndex+1}),i.push({type:"text",content:e.slice(d,r)}),i},Ze=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,Ke(i)})},Re=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const d=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:d,properties:{}});break}}}),e+=`
3
- \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},g={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},Ue="__mock__",Ge=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:d,onReply:h,resolved:I,isRoot:b,onClose:E,onDeleteComment:H,type:V}=n,w=C.useDependency(a.ICommandService),D=C.useDependency(a.LocaleService),v=C.useDependency(a.UserManagerService),S=v.getUser(e.personId),j=C.useObservable(v.currentUser$),N=(j==null?void 0:j.userID)===e.personId,$=e.id===Ue,[T,L]=m.useState(!1),u=()=>{(H==null?void 0:H(e))!==!1&&(w.executeCommand(b?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),b&&(E==null||E()))};return o.jsxs("div",{className:g.threadCommentItem,onMouseLeave:()=>L(!1),onMouseEnter:()=>L(!0),children:[o.jsx("img",{className:g.threadCommentItemHead,src:S==null?void 0:S.avatar}),o.jsxs("div",{className:g.threadCommentItemTitle,children:[o.jsx("div",{className:g.threadCommentUsername,children:(S==null?void 0:S.name)||" "}),o.jsxs("div",{children:[$||I?null:T?o.jsx("div",{className:g.threadCommentIcon,onClick:()=>h(S),children:o.jsx(ge,{})}):null,N&&!$&&!I?o.jsx(B.Dropdown,{overlay:o.jsx("div",{className:"univer-rounded-lg univer-p-4 univer-theme",children:o.jsxs("ul",{className:`
1
+ (function(c,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/docs-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/docs-ui"],a):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverThreadCommentUi={},c.UniverCore,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.UniverDesign,c.React,c.UniverDocsUi))})(this,function(c,a,_,C,te,o,V,m,se){"use strict";var Ge=Object.defineProperty;var Ye=(c,a,_)=>a in c?Ge(c,a,{enumerable:!0,configurable:!0,writable:!0,value:_}):c[a]=_;var K=(c,a,_)=>Ye(c,typeof a!="symbol"?a+"":a,_);var Ne=Object.getOwnPropertyDescriptor,Pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ne(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},le=(n,e)=>(t,r)=>e(t,r,n);c.ThreadCommentPanelService=class extends a.Disposable{constructor(t,r){super();K(this,"_panelVisible",!1);K(this,"_panelVisible$",new te.BehaviorSubject(!1));K(this,"_activeCommentId");K(this,"_activeCommentId$",new te.BehaviorSubject(void 0));K(this,"panelVisible$",this._panelVisible$.asObservable());K(this,"activeCommentId$",this._activeCommentId$.asObservable());this._sidebarService=t,this._univerInstanceService=r,this._init(),this.disposeWithMe(()=>{this._activeCommentId$.complete(),this._panelVisible$.complete()})}_init(){this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(t=>{t.visible||this.setPanelVisible(!1)})),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(te.filter(t=>!t)).subscribe(()=>{this._sidebarService.close()}))}get panelVisible(){return this._panelVisible}get activeCommentId(){return this._activeCommentId}setPanelVisible(t){this._panelVisible=t,this._panelVisible$.next(t)}setActiveComment(t){this._activeCommentId=t,this._activeCommentId$.next(t)}},c.ThreadCommentPanelService=Pe([le(0,a.Inject(C.ISidebarService)),le(1,a.IUniverInstanceService)],c.ThreadCommentPanelService);const me="thread-comment-panel",xe="UNIVER_THREAD_COMMENT_UI_PLUGIN",ce={id:"thread-comment-ui.operation.toggle-panel",type:a.CommandType.OPERATION,handler(n){const e=n.get(C.ISidebarService),t=n.get(c.ThreadCommentPanelService);return t.panelVisible?(e.close(),t.setPanelVisible(!1)):(e.open({header:{title:"threadCommentUI.panel.title"},children:{label:me},width:330}),t.setPanelVisible(!0)),!0}},F={id:"thread-comment-ui.operation.set-active-comment",type:a.CommandType.OPERATION,handler(n,e){return n.get(c.ThreadCommentPanelService).setActiveComment(e),!0}},Ee="thread-comment-ui.config",he={};var De=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Me=(n,e,t)=>e in n?De(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,He=(n,e,t,r)=>{for(var i=r>1?void 0:r?Oe(e,t):e,d=n.length-1,h;d>=0;d--)(h=n[d])&&(i=h(i)||i);return i},de=(n,e)=>(t,r)=>e(t,r,n),ue=(n,e,t)=>Me(n,typeof e!="symbol"?e+"":e,t);c.UniverThreadCommentUIPlugin=class extends a.Plugin{constructor(e=he,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;const{menu:d,...h}=a.merge({},he,this._config);d&&this._configService.setConfig("menu",d,{merge:!0}),this._configService.setConfig(Ee,h)}onStarting(){var e;a.mergeOverrideWithDependencies([[c.ThreadCommentPanelService]],(e=this._config)==null?void 0:e.overrides).forEach(t=>{this._injector.add(t)}),[ce,F].forEach(t=>{this._commandService.registerCommand(t)})}},ue(c.UniverThreadCommentUIPlugin,"pluginName",xe),ue(c.UniverThreadCommentUIPlugin,"type",a.UniverInstanceType.UNIVER_UNKNOWN),c.UniverThreadCommentUIPlugin=He([a.DependentOn(_.UniverThreadCommentPlugin),de(1,a.Inject(a.Injector)),de(2,a.ICommandService),de(3,a.IConfigService)],c.UniverThreadCommentUIPlugin);var M=function(){return M=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},M.apply(this,arguments)},we=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},q=m.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,d=n.extend,h=we(n,["icon","id","className","extend"]),g="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),y=m.useRef("_".concat($e()));return ve(t,"".concat(r),{defIds:t.defIds,idSuffix:y.current},M({ref:e,className:g},h),d)});function ve(n,e,t,r,i){return m.createElement(n.tag,M(M({key:e},ke(n,t,i)),r),(je(n,t).children||[]).map(function(d,h){return ve(d,"".concat(e,"-").concat(n.tag,"-").concat(h),t,void 0,i)}))}function ke(n,e,t){var r=M({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],g=d[1];h==="mask"&&typeof g=="string"&&(r[h]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(d){var h=d[0],g=d[1];typeof g=="string"&&(r[h]=g.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function je(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?M(M({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?M(M({},i),{attrs:M(M({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function $e(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"delete-single",ref:e,icon:Le}))});Ce.displayName="DeleteSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},fe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"increase-single",ref:e,icon:Ae}))});fe.displayName="IncreaseSingle";var Ve={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z"}}]},pe=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"more-horizontal-single",ref:e,icon:Ve}))});pe.displayName="MoreHorizontalSingle";var Be={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252",strokeLinecap:"round",strokeWidth:1.2}}]},Ie=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"reply-to-comment-single",ref:e,icon:Be}))});Ie.displayName="ReplyToCommentSingle";var Fe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"resolved-single",ref:e,icon:Fe}))});ge.displayName="ResolvedSingle";var We={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"circle",attrs:{cx:8.73,cy:8.4,r:6.4,stroke:"currentColor",strokeWidth:1.2}},{tag:"path",attrs:{stroke:"currentColor",d:"M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.2}}]},Se=m.forwardRef(function(n,e){return m.createElement(q,Object.assign({},n,{id:"solve-single",ref:e,icon:We}))});Se.displayName="SolveSingle";const be={threadCommentEditorButtons:"univer-thread-comment-editor-buttons"};function ye(n){return{id:"d",body:n,documentStyle:{}}}const Te=m.forwardRef((n,e)=>{var A;const{comment:t,onSave:r,id:i,onCancel:d,autoFocus:h,unitId:g,type:y}=n,E=C.useDependency(a.ICommandService),H=C.useDependency(a.LocaleService),[B,w]=m.useState(!1),D=C.useDependency(se.IEditorService),v=m.useRef(null),S=y===a.UniverInstanceType.UNIVER_SHEET?a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:g,[k,N]=m.useState(()=>{var u,f,b;return a.BuildTextUtils.transform.getPlainText((b=(f=(u=v.current)==null?void 0:u.getDocumentData().body)==null?void 0:f.dataStream)!=null?b:"")});m.useEffect(()=>{var f,b,l,p;N(a.BuildTextUtils.transform.getPlainText((l=(b=(f=v.current)==null?void 0:f.getDocumentData().body)==null?void 0:b.dataStream)!=null?l:""));const u=(p=v.current)==null?void 0:p.selectionChange$.subscribe(()=>{var Z,P,U;N(a.BuildTextUtils.transform.getPlainText((U=(P=(Z=v.current)==null?void 0:Z.getDocumentData().body)==null?void 0:P.dataStream)!=null?U:""))});return()=>u==null?void 0:u.unsubscribe()},[(A=v.current)==null?void 0:A.selectionChange$]);const $=m.useMemo(()=>({keyCodes:[{keyCode:C.KeyCode.ENTER}],handler:u=>{u===C.KeyCode.ENTER&&E.executeCommand(se.BreakLineCommand.id)}}),[E]);m.useImperativeHandle(e,()=>({reply(u){var f,b;(f=v.current)==null||f.focus(),(b=v.current)==null||b.setDocumentData(ye(u))}}));const T=()=>{if(v.current){const u=a.Tools.deepClone(v.current.getDocumentData().body);w(!1),r==null||r({...t,text:u}),v.current.replaceText(""),setTimeout(()=>{var f,b;(f=v.current)==null||f.setSelectionRanges([]),(b=v.current)==null||b.blur()},10)}};return o.jsxs("div",{className:be.threadCommentEditor,onClick:u=>u.preventDefault(),children:[o.jsx(se.RichTextEditor,{editorRef:v,autoFocus:h,style:{width:"100%"},keyboardEventConfig:$,placeholder:H.t("threadCommentUI.editor.placeholder"),initialValue:(t==null?void 0:t.text)&&ye(t.text),onFocusChange:u=>u&&w(u),isSingle:!1,maxHeight:64,onClickOutside:()=>{setTimeout(()=>{D.focus(S)},30)}}),B?o.jsxs("div",{className:be.threadCommentEditorButtons,children:[o.jsx(V.Button,{style:{marginRight:12},onClick:()=>{var u;d==null||d(),w(!1),(u=v.current)==null||u.replaceText("",!0),E.executeCommand(F.id)},children:H.t("threadCommentUI.editor.cancel")}),o.jsx(V.Button,{type:"primary",disabled:!k,onClick:T,children:H.t(i?"threadCommentUI.editor.save":"threadCommentUI.editor.reply")})]}):null]})}),qe=n=>{const{dataStream:e,customRanges:t}=n,r=e.endsWith(`\r
2
+ `)?e.length-2:e.length,i=[];let d=0;return t==null||t.forEach(h=>{d<h.startIndex&&i.push({type:"text",content:e.slice(d,h.startIndex)}),i.push({type:"mention",content:{label:e.slice(h.startIndex,h.endIndex+1),id:h.rangeId}}),d=h.endIndex+1}),i.push({type:"text",content:e.slice(d,r)}),i},ze=n=>{const{paragraphs:e=[]}=n;let t=0;return e.map(r=>{const i=a.getBodySlice(n,t,r.startIndex);return t=r.startIndex+1,qe(i)})},Ke=n=>{let e="";const t=[];return n.forEach(r=>{switch(r.type){case"text":e+=r.content;break;case"mention":{const i=e.length;e+=r.content.label;const d=e.length-1;t.push({rangeId:r.content.id,rangeType:a.CustomRangeType.MENTION,startIndex:i,endIndex:d,properties:{}});break}}}),e+=`
3
+ \r`,{textRuns:[],paragraphs:[{startIndex:e.length-2,paragraphStyle:{}}],sectionBreaks:[{startIndex:e.length-1}],dataStream:e,customRanges:t}},I={threadComment:"univer-thread-comment",threadCommentActive:"univer-thread-comment-active",threadCommentContent:"univer-thread-comment-content",threadCommentHighlight:"univer-thread-comment-highlight",threadCommentIconContainer:"univer-thread-comment-icon-container",threadCommentIcon:"univer-thread-comment-icon",threadCommentTitle:"univer-thread-comment-title",threadCommentTitlePosition:"univer-thread-comment-title-position",threadCommentTitleHighlight:"univer-thread-comment-title-highlight",threadCommentTitlePositionText:"univer-thread-comment-title-position-text",threadCommentUsername:"univer-thread-comment-username",threadCommentItem:"univer-thread-comment-item",threadCommentItemHead:"univer-thread-comment-item-head",threadCommentItemTitle:"univer-thread-comment-item-title",threadCommentItemTime:"univer-thread-comment-item-time",threadCommentItemContent:"univer-thread-comment-item-content",threadCommentItemAt:"univer-thread-comment-item-at"},_e="__mock__",Ze=n=>{const{item:e,unitId:t,subUnitId:r,editing:i,onEditingChange:d,onReply:h,resolved:g,isRoot:y,onClose:E,onDeleteComment:H,type:B}=n,w=C.useDependency(a.ICommandService),D=C.useDependency(a.LocaleService),v=C.useDependency(a.UserManagerService),S=v.getUser(e.personId),k=C.useObservable(v.currentUser$),N=(k==null?void 0:k.userID)===e.personId,$=e.id===_e,[T,A]=m.useState(!1),u=()=>{(H==null?void 0:H(e))!==!1&&(w.executeCommand(y?_.DeleteCommentTreeCommand.id:_.DeleteCommentCommand.id,{unitId:t,subUnitId:r,commentId:e.id}),y&&(E==null||E()))};return o.jsxs("div",{className:I.threadCommentItem,onMouseLeave:()=>A(!1),onMouseEnter:()=>A(!0),children:[o.jsx("img",{className:I.threadCommentItemHead,src:S==null?void 0:S.avatar}),o.jsxs("div",{className:I.threadCommentItemTitle,children:[o.jsx("div",{className:I.threadCommentUsername,children:(S==null?void 0:S.name)||" "}),o.jsxs("div",{children:[$||g?null:T?o.jsx("div",{className:I.threadCommentIcon,onClick:()=>h(S),children:o.jsx(Ie,{})}):null,N&&!$&&!g?o.jsx(V.Dropdown,{overlay:o.jsx("div",{className:"univer-rounded-lg univer-p-4 univer-theme",children:o.jsxs("ul",{className:`
4
4
  univer-m-0 univer-grid univer-list-none univer-gap-2 univer-p-0
5
5
  univer-text-sm
6
6
  [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-p-1
7
- `,children:[o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>d==null?void 0:d(!0),children:D.t("threadCommentUI.item.edit")})}),o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:u,children:D.t("threadCommentUI.item.delete")})})]})}),children:o.jsx("div",{className:g.threadCommentIcon,children:o.jsx(pe,{})})}):null]})]}),o.jsx("div",{className:g.threadCommentItemTime,children:e.dT}),i?o.jsx(_e,{type:V,id:e.id,comment:e,onCancel:()=>d==null?void 0:d(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:f,attachments:y})=>{d==null||d(!1),w.executeCommand(_.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:f,attachments:y}})}}):o.jsx("div",{className:g.threadCommentItemContent,children:Ze(e.text).map((f,y)=>o.jsx("div",{children:f.map((l,p)=>{switch(l.type){case"mention":return o.jsxs("a",{className:g.threadCommentItemAt,children:[l.content.label," "]},p);default:return l.content}})},y))})]})},Ne=n=>{var X,ee,ie;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:d=!0,onClick:h,showHighlight:I,onClose:b,getSubUnitName:E,prefix:H,autoFocus:V,onMouseEnter:w,onMouseLeave:D,onAddComment:v,onDeleteComment:S,onResolve:j,type:N}=n,$=C.useDependency(_.ThreadCommentModel),[T,L]=m.useState(!1),[u,f]=m.useState(""),y=m.useMemo(()=>$.commentUpdate$.pipe(te.debounceTime(16)),[$]);C.useObservable(y);const l=e?$.getCommentWithChildren(t,r,e):null,p=C.useDependency(a.ICommandService),Z=C.useDependency(a.UserManagerService),P=l==null?void 0:l.root.resolved,U=C.useObservable(Z.currentUser$),R=m.useRef(null),ne=[...l?[l.root]:[{id:Ue,text:{dataStream:`
8
- \r`},personId:(X=U==null?void 0:U.userID)!=null?X:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(ee=l==null?void 0:l.children)!=null?ee:[]],k=m.useRef(null),Y=x=>{x.stopPropagation(),P?p.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):p.executeCommand(F.id),p.executeCommand(_.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!P}),j==null||j(!P)},W=x=>{x.stopPropagation(),p.executeCommand(F.id),!(l!=null&&l.root&&(S==null?void 0:S(l.root))===!1)&&(p.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),b==null||b())};m.useEffect(()=>D==null?void 0:D(),[]);const J=E((ie=l==null?void 0:l.root.subUnitId)!=null?ie:r),Q=d&&!u&&!P,re=`${i||(l==null?void 0:l.root.ref)||""}${J?" · ":""}${J}`;return o.jsxs("div",{className:ze(g.threadComment,{[g.threadCommentActive]:!P&&(I||T||H==="cell")}),onClick:h,id:`${H}-${t}-${r}-${e}`,onMouseEnter:()=>{w==null||w(),L(!0)},onMouseLeave:()=>{D==null||D(),L(!1)},children:[!P&&I?o.jsx("div",{className:g.threadCommentHighlight}):null,o.jsxs("div",{className:g.threadCommentTitle,children:[o.jsxs("div",{className:g.threadCommentTitlePosition,children:[o.jsx("div",{className:g.threadCommentTitleHighlight}),o.jsx(B.Tooltip,{showIfEllipsis:!0,title:re,children:o.jsx("div",{className:g.threadCommentTitlePositionText,children:re})})]}),l?o.jsxs("div",{className:g.threadCommentIconContainer,children:[o.jsx("div",{onClick:Y,className:g.threadCommentIcon,style:{color:P?"rgb(var(--green-500))":""},children:P?o.jsx(Ie,{}):o.jsx(Se,{})}),(U==null?void 0:U.userID)===l.root.personId?o.jsx("div",{className:g.threadCommentIcon,onClick:W,children:o.jsx(Ce,{})}):null]}):null]}),o.jsx("div",{className:g.threadCommentContent,ref:k,children:ne.map(x=>o.jsx(Ge,{onClose:b,unitId:t,subUnitId:r,item:x,isRoot:x.id===(l==null?void 0:l.root.id),editing:u===x.id,resolved:l==null?void 0:l.root.resolved,type:N,onEditingChange:s=>{f(s?x.id:"")},onReply:s=>{s&&requestAnimationFrame(()=>{var A;(A=R.current)==null||A.reply(Re([{type:"mention",content:{id:s.userID,label:s.name}}]))})},onAddComment:v,onDeleteComment:S},x.id))}),Q?o.jsx("div",{children:o.jsx(_e,{ref:R,type:N,unitId:t,subUnitId:r,onSave:async({text:x,attachments:s})=>{const A={text:x,attachments:s,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:U==null?void 0:U.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(v==null?void 0:v(A))!==!1&&(await p.executeCommand(_.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:A}),k.current&&(k.current.scrollTop=k.current.scrollHeight))},autoFocus:V||!l,onCancel:()=>{l||b==null||b()}},`${V}`)}):null]})},G={threadCommentPanel:"univer-thread-comment-panel",threadCommentPanelForms:"univer-thread-comment-panel-forms",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},Ye=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:d,onResolve:h,sortComments:I,onItemLeave:b,onItemEnter:E,disableAdd:H,tempComment:V,onAddComment:w,onDeleteComment:D,showComments:v}=n,[S,j]=m.useState("all"),[N,$]=m.useState("all"),T=C.useDependency(a.LocaleService),L=C.useDependency(a.UserManagerService),u=C.useDependency(_.ThreadCommentModel),[f,y]=m.useState(()=>u.getUnit(e)),l=C.useDependency(c.ThreadCommentPanelService),p=C.useObservable(l.activeCommentId$),Z=C.useObservable(u.commentUpdate$),P=C.useDependency(a.ICommandService),U=C.useObservable(t),R=m.useRef(!0),ne="panel",k=C.useObservable(L.currentUser$),Y=m.useMemo(()=>{var ae;const s=S==="all"?f:(ae=f.filter(O=>O.subUnitId===U))!=null?ae:[],A=I!=null?I:O=>O,oe=s.map(O=>{var z;return{...O.root,children:(z=O.children)!=null?z:[],users:O.relativeUsers}});if(v){const O=new Map;return oe.forEach(z=>{O.set(z.id,z)}),[...v,""].map(z=>O.get(z)).filter(Boolean)}else return A(oe)},[v,S,f,I,U]),W=m.useMemo(()=>[...Y.filter(s=>!s.resolved),...Y.filter(s=>s.resolved)],[Y]),J=m.useMemo(()=>N==="resolved"?W.filter(s=>s.resolved):N==="unsolved"?W.filter(s=>!s.resolved):N==="concern_me"&&k!=null&&k.userID?W.filter(s=>s==null?void 0:s.users.has(k.userID)):W,[W,k==null?void 0:k.userID,N]),Q=V?[V,...J]:J,re=Q.filter(s=>!s.resolved),X=Q.filter(s=>s.resolved),ee=N!=="all"||S!=="all",ie=()=>{$("all"),j("all")};m.useEffect(()=>{e&&y(u.getUnit(e))},[e,u,Z]),m.useEffect(()=>{var O;if(!p)return;if(!R.current){R.current=!0;return}const{unitId:s,subUnitId:A,commentId:oe}=p,ae=`${ne}-${s}-${A}-${oe}`;(O=document.getElementById(ae))==null||O.scrollIntoView({block:"center"})},[p]);const x=s=>o.jsx(Ne,{prefix:ne,getSubUnitName:d,id:s.id,unitId:s.unitId,subUnitId:s.subUnitId,refStr:s.ref,type:r,showEdit:(p==null?void 0:p.commentId)===s.id,showHighlight:(p==null?void 0:p.commentId)===s.id,onClick:()=>{R.current=!1,s.resolved?P.executeCommand(F.id):P.executeCommand(F.id,{unitId:s.unitId,subUnitId:s.subUnitId,commentId:s.id,temp:!1})},onMouseEnter:()=>E==null?void 0:E(s),onMouseLeave:()=>b==null?void 0:b(s),onAddComment:w,onDeleteComment:D,onResolve:A=>h==null?void 0:h(s.id,A)},s.id);return o.jsxs("div",{className:G.threadCommentPanel,children:[o.jsxs("div",{className:G.threadCommentPanelForms,children:[r===a.UniverInstanceType.UNIVER_SHEET?o.jsx(B.Select,{borderless:!0,value:S,onChange:s=>j(s),options:[{value:"current",label:T.t("threadCommentUI.filter.sheet.current")},{value:"all",label:T.t("threadCommentUI.filter.sheet.all")}]}):null,o.jsx(B.Select,{borderless:!0,value:N,onChange:s=>$(s),options:[{value:"all",label:T.t("threadCommentUI.filter.status.all")},{value:"resolved",label:T.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:T.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:T.t("threadCommentUI.filter.status.concernMe")}]})]}),re.map(x),X.length?o.jsx("div",{className:G.threadCommentPanelSolved,children:"已解决"}):null,X.map(x),Q.length?null:o.jsxs("div",{className:G.threadCommentPanelEmpty,children:[ee?T.t("threadCommentUI.panel.filterEmpty"):T.t("threadCommentUI.panel.empty"),ee?o.jsx(B.Button,{onClick:ie,type:"link",children:T.t("threadCommentUI.panel.reset")}):o.jsxs(B.Button,{id:"thread-comment-add",className:G.threadCommentPanelAdd,type:"primary",onClick:i,disabled:H,children:[o.jsx(fe,{}),T.t("threadCommentUI.panel.addComment")]})]})]})};c.SetActiveCommentOperation=F,c.THREAD_COMMENT_PANEL=me,c.ThreadCommentPanel=Ye,c.ThreadCommentTree=Ne,c.ToggleSheetCommentPanelOperation=ce,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
7
+ `,children:[o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>d==null?void 0:d(!0),children:D.t("threadCommentUI.item.edit")})}),o.jsx("li",{children:o.jsx("a",{className:"hover:univer-bg-gray-200",onClick:u,children:D.t("threadCommentUI.item.delete")})})]})}),children:o.jsx("div",{className:I.threadCommentIcon,children:o.jsx(pe,{})})}):null]})]}),o.jsx("div",{className:I.threadCommentItemTime,children:e.dT}),i?o.jsx(Te,{type:B,id:e.id,comment:e,onCancel:()=>d==null?void 0:d(!1),autoFocus:!0,unitId:t,subUnitId:r,onSave:({text:f,attachments:b})=>{d==null||d(!1),w.executeCommand(_.UpdateCommentCommand.id,{unitId:t,subUnitId:r,payload:{commentId:e.id,text:f,attachments:b}})}}):o.jsx("div",{className:I.threadCommentItemContent,children:ze(e.text).map((f,b)=>o.jsx("div",{children:f.map((l,p)=>{switch(l.type){case"mention":return o.jsxs("a",{className:I.threadCommentItemAt,children:[l.content.label," "]},p);default:return l.content}})},b))})]})},Ue=n=>{var X,ee,ie;const{id:e,unitId:t,subUnitId:r,refStr:i,showEdit:d=!0,onClick:h,showHighlight:g,onClose:y,getSubUnitName:E,prefix:H,autoFocus:B,onMouseEnter:w,onMouseLeave:D,onAddComment:v,onDeleteComment:S,onResolve:k,type:N}=n,$=C.useDependency(_.ThreadCommentModel),[T,A]=m.useState(!1),[u,f]=m.useState(""),b=m.useMemo(()=>$.commentUpdate$.pipe(te.debounceTime(16)),[$]);C.useObservable(b);const l=e?$.getCommentWithChildren(t,r,e):null,p=C.useDependency(a.ICommandService),Z=C.useDependency(a.UserManagerService),P=l==null?void 0:l.root.resolved,U=C.useObservable(Z.currentUser$),R=m.useRef(null),ne=[...l?[l.root]:[{id:_e,text:{dataStream:`
8
+ \r`},personId:(X=U==null?void 0:U.userID)!=null?X:"",ref:i!=null?i:"",dT:"",unitId:t,subUnitId:r,threadId:""}],...(ee=l==null?void 0:l.children)!=null?ee:[]],j=m.useRef(null),Y=x=>{x.stopPropagation(),P?p.executeCommand(F.id,{unitId:t,subUnitId:r,commentId:e}):p.executeCommand(F.id),p.executeCommand(_.ResolveCommentCommand.id,{unitId:t,subUnitId:r,commentId:e,resolved:!P}),k==null||k(!P)},W=x=>{x.stopPropagation(),p.executeCommand(F.id),!(l!=null&&l.root&&(S==null?void 0:S(l.root))===!1)&&(p.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:t,subUnitId:r,commentId:e}),y==null||y())};m.useEffect(()=>D==null?void 0:D(),[]);const J=E((ie=l==null?void 0:l.root.subUnitId)!=null?ie:r),Q=d&&!u&&!P,re=`${i||(l==null?void 0:l.root.ref)||""}${J?" · ":""}${J}`;return o.jsxs("div",{className:V.clsx(I.threadComment,{[I.threadCommentActive]:!P&&(g||T||H==="cell")}),onClick:h,id:`${H}-${t}-${r}-${e}`,onMouseEnter:()=>{w==null||w(),A(!0)},onMouseLeave:()=>{D==null||D(),A(!1)},children:[!P&&g?o.jsx("div",{className:I.threadCommentHighlight}):null,o.jsxs("div",{className:I.threadCommentTitle,children:[o.jsxs("div",{className:I.threadCommentTitlePosition,children:[o.jsx("div",{className:I.threadCommentTitleHighlight}),o.jsx(V.Tooltip,{showIfEllipsis:!0,title:re,children:o.jsx("div",{className:I.threadCommentTitlePositionText,children:re})})]}),l?o.jsxs("div",{className:I.threadCommentIconContainer,children:[o.jsx("div",{onClick:Y,className:I.threadCommentIcon,style:{color:P?"rgb(var(--green-500))":""},children:P?o.jsx(ge,{}):o.jsx(Se,{})}),(U==null?void 0:U.userID)===l.root.personId?o.jsx("div",{className:I.threadCommentIcon,onClick:W,children:o.jsx(Ce,{})}):null]}):null]}),o.jsx("div",{className:I.threadCommentContent,ref:j,children:ne.map(x=>o.jsx(Ze,{onClose:y,unitId:t,subUnitId:r,item:x,isRoot:x.id===(l==null?void 0:l.root.id),editing:u===x.id,resolved:l==null?void 0:l.root.resolved,type:N,onEditingChange:s=>{f(s?x.id:"")},onReply:s=>{s&&requestAnimationFrame(()=>{var L;(L=R.current)==null||L.reply(Ke([{type:"mention",content:{id:s.userID,label:s.name}}]))})},onAddComment:v,onDeleteComment:S},x.id))}),Q?o.jsx("div",{children:o.jsx(Te,{ref:R,type:N,unitId:t,subUnitId:r,onSave:async({text:x,attachments:s})=>{const L={text:x,attachments:s,dT:_.getDT(),id:a.generateRandomId(),ref:i,personId:U==null?void 0:U.userID,parentId:l==null?void 0:l.root.id,unitId:t,subUnitId:r,threadId:l==null?void 0:l.root.threadId};(v==null?void 0:v(L))!==!1&&(await p.executeCommand(_.AddCommentCommand.id,{unitId:t,subUnitId:r,comment:L}),j.current&&(j.current.scrollTop=j.current.scrollHeight))},autoFocus:B||!l,onCancel:()=>{l||y==null||y()}},`${B}`)}):null]})},G={threadCommentPanel:"univer-thread-comment-panel",threadCommentPanelForms:"univer-thread-comment-panel-forms",threadCommentPanelEmpty:"univer-thread-comment-panel-empty",threadCommentPanelAdd:"univer-thread-comment-panel-add",threadCommentPanelSolved:"univer-thread-comment-panel-solved"},Re=n=>{const{unitId:e,subUnitId$:t,type:r,onAdd:i,getSubUnitName:d,onResolve:h,sortComments:g,onItemLeave:y,onItemEnter:E,disableAdd:H,tempComment:B,onAddComment:w,onDeleteComment:D,showComments:v}=n,[S,k]=m.useState("all"),[N,$]=m.useState("all"),T=C.useDependency(a.LocaleService),A=C.useDependency(a.UserManagerService),u=C.useDependency(_.ThreadCommentModel),[f,b]=m.useState(()=>u.getUnit(e)),l=C.useDependency(c.ThreadCommentPanelService),p=C.useObservable(l.activeCommentId$),Z=C.useObservable(u.commentUpdate$),P=C.useDependency(a.ICommandService),U=C.useObservable(t),R=m.useRef(!0),ne="panel",j=C.useObservable(A.currentUser$),Y=m.useMemo(()=>{var ae;const s=S==="all"?f:(ae=f.filter(O=>O.subUnitId===U))!=null?ae:[],L=g!=null?g:O=>O,oe=s.map(O=>{var z;return{...O.root,children:(z=O.children)!=null?z:[],users:O.relativeUsers}});if(v){const O=new Map;return oe.forEach(z=>{O.set(z.id,z)}),[...v,""].map(z=>O.get(z)).filter(Boolean)}else return L(oe)},[v,S,f,g,U]),W=m.useMemo(()=>[...Y.filter(s=>!s.resolved),...Y.filter(s=>s.resolved)],[Y]),J=m.useMemo(()=>N==="resolved"?W.filter(s=>s.resolved):N==="unsolved"?W.filter(s=>!s.resolved):N==="concern_me"&&j!=null&&j.userID?W.filter(s=>s==null?void 0:s.users.has(j.userID)):W,[W,j==null?void 0:j.userID,N]),Q=B?[B,...J]:J,re=Q.filter(s=>!s.resolved),X=Q.filter(s=>s.resolved),ee=N!=="all"||S!=="all",ie=()=>{$("all"),k("all")};m.useEffect(()=>{e&&b(u.getUnit(e))},[e,u,Z]),m.useEffect(()=>{var O;if(!p)return;if(!R.current){R.current=!0;return}const{unitId:s,subUnitId:L,commentId:oe}=p,ae=`${ne}-${s}-${L}-${oe}`;(O=document.getElementById(ae))==null||O.scrollIntoView({block:"center"})},[p]);const x=s=>o.jsx(Ue,{prefix:ne,getSubUnitName:d,id:s.id,unitId:s.unitId,subUnitId:s.subUnitId,refStr:s.ref,type:r,showEdit:(p==null?void 0:p.commentId)===s.id,showHighlight:(p==null?void 0:p.commentId)===s.id,onClick:()=>{R.current=!1,s.resolved?P.executeCommand(F.id):P.executeCommand(F.id,{unitId:s.unitId,subUnitId:s.subUnitId,commentId:s.id,temp:!1})},onMouseEnter:()=>E==null?void 0:E(s),onMouseLeave:()=>y==null?void 0:y(s),onAddComment:w,onDeleteComment:D,onResolve:L=>h==null?void 0:h(s.id,L)},s.id);return o.jsxs("div",{className:G.threadCommentPanel,children:[o.jsxs("div",{className:G.threadCommentPanelForms,children:[r===a.UniverInstanceType.UNIVER_SHEET?o.jsx(V.Select,{borderless:!0,value:S,onChange:s=>k(s),options:[{value:"current",label:T.t("threadCommentUI.filter.sheet.current")},{value:"all",label:T.t("threadCommentUI.filter.sheet.all")}]}):null,o.jsx(V.Select,{borderless:!0,value:N,onChange:s=>$(s),options:[{value:"all",label:T.t("threadCommentUI.filter.status.all")},{value:"resolved",label:T.t("threadCommentUI.filter.status.resolved")},{value:"unsolved",label:T.t("threadCommentUI.filter.status.unsolved")},{value:"concern_me",label:T.t("threadCommentUI.filter.status.concernMe")}]})]}),re.map(x),X.length?o.jsx("div",{className:G.threadCommentPanelSolved,children:"已解决"}):null,X.map(x),Q.length?null:o.jsxs("div",{className:G.threadCommentPanelEmpty,children:[ee?T.t("threadCommentUI.panel.filterEmpty"):T.t("threadCommentUI.panel.empty"),ee?o.jsx(V.Button,{onClick:ie,type:"link",children:T.t("threadCommentUI.panel.reset")}):o.jsxs(V.Button,{id:"thread-comment-add",className:G.threadCommentPanelAdd,type:"primary",onClick:i,disabled:H,children:[o.jsx(fe,{}),T.t("threadCommentUI.panel.addComment")]})]})]})};c.SetActiveCommentOperation=F,c.THREAD_COMMENT_PANEL=me,c.ThreadCommentPanel=Re,c.ThreadCommentTree=Ue,c.ToggleSheetCommentPanelOperation=ce,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/thread-comment-ui",
3
- "version": "0.6.1-nightly.202502261607",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "description": "Univer common thread comment UI plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,12 +53,11 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.2.20",
56
- "clsx": "^2.1.1",
57
- "@univerjs/core": "0.6.1-nightly.202502261607",
58
- "@univerjs/docs-ui": "0.6.1-nightly.202502261607",
59
- "@univerjs/ui": "0.6.1-nightly.202502261607",
60
- "@univerjs/design": "0.6.1-nightly.202502261607",
61
- "@univerjs/thread-comment": "0.6.1-nightly.202502261607"
56
+ "@univerjs/core": "0.6.2",
57
+ "@univerjs/design": "0.6.2",
58
+ "@univerjs/docs-ui": "0.6.2",
59
+ "@univerjs/thread-comment": "0.6.2",
60
+ "@univerjs/ui": "0.6.2"
62
61
  },
63
62
  "devDependencies": {
64
63
  "less": "^4.2.2",
@@ -69,7 +68,7 @@
69
68
  "typescript": "^5.7.3",
70
69
  "vite": "^6.2.0",
71
70
  "vitest": "^3.0.7",
72
- "@univerjs-infra/shared": "0.6.1"
71
+ "@univerjs-infra/shared": "0.6.2"
73
72
  },
74
73
  "scripts": {
75
74
  "test": "vitest run",