@univerjs/docs-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 +176 -0
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +115 -109
- package/lib/types/services/doc-thread-comment.service.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +9 -10
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,2 +1,2 @@
|
|
|
1
|
-
"use strict";var re=Object.defineProperty;var ie=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t,r)=>ie(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),
|
|
2
|
-
`},startOffset:m.startOffset,endOffset:m.endOffset,collapsed:!0,threadId:M};return v==null||v.blur(),a.startAdd(b),t.setActiveComment({unitId:I,subUnitId:l,commentId:M}),!0}};var ue=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?ue(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},y=(e,t)=>(r,n)=>t(r,n,e);let B=class extends c.Disposable{constructor(e,t,r,n,i,o){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=o,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,o;if(t.id===_.SetTextSelectionsOperation.id){const s=t.params,{unitId:a,ranges:C}=s;if(c.isInternalEditorID(a))return;const f=this._univerInstanceService.getUnit(a,c.UniverInstanceType.UNIVER_DOC),m=C[0];if((e==null?void 0:e.startOffset)===(m==null?void 0:m.startOffset)&&(e==null?void 0:e.endOffset)===(m==null?void 0:m.endOffset))return;if(e=m,m&&f){const{startOffset:v,endOffset:I,collapsed:g}=m;let d;if(g?d=(n=(r=f.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(l=>l.startIndex<=v&&l.endIndex>=I-1):d=(o=(i=f.getBody())==null?void 0:i.customDecorations)==null?void 0:o.find(l=>l.startIndex<=v&&l.endIndex>=I-1),d){const l=this._threadCommentModel.getComment(a,D,d.id);l&&!l.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:D,commentId:d.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const o=this._univerInstanceService.getUnit(e.unitId);if(o){const s=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(V.DocBackScrollRenderController),a=(n=(r=o.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);a&&s&&s.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};B=Ce([y(0,c.Inject(O.ThreadCommentPanelService)),y(1,c.IUniverInstanceService),y(2,c.ICommandService),y(3,c.Inject(E)),y(4,x.IRenderManagerService),y(5,c.Inject(w.ThreadCommentModel))],B);var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},he=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},Q=p.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,o=e.extend,s=he(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),C=p.useRef("_".concat(ge()));return X(r,"".concat(n),{defIds:r.defIds,idSuffix:C.current},S({ref:t,className:a},s),o)});function X(e,t,r,n,i){return p.createElement(e.tag,S(S({key:t},fe(e,r,i)),n),(ve(e,r).children||[]).map(function(o,s){return X(o,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,i)}))}function fe(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];s==="mask"&&typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function ve(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function ge(){return Math.random().toString(36).substring(2,8)}Q.displayName="UniverIcon";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ee=p.forwardRef(function(e,t){return p.createElement(Q,Object.assign({},e,{id:"comment-single",ref:t,icon:Ie}))});ee.displayName="CommentSingle";const Se={[u.RibbonStartGroup.OTHERS]:{[z.id]:{order:1,menuItemFactory:le}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[j.id]:{order:1,menuItemFactory:me}}}};var pe=Object.getOwnPropertyDescriptor,_e=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},L=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[G,Z,N,j,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Se)}_initComponents(){[P].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",ee))}};q=_e([L(0,c.ICommandService),L(1,u.IMenuManagerService),L(2,c.Inject(u.ComponentManager))],q);var Oe=Object.getOwnPropertyDescriptor,Me=(e,t,r,n)=>{for(var i=n>1?void 0:n?Oe(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},U=(e,t)=>(r,n)=>t(r,n,e);let K=class extends c.Disposable{constructor(e,t,r,n,i,o,s){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=o,this._commandService=s,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(_.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:o}=t,s=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:C}=s||{},f=o.find(g=>g.id===a),m=this._threadCommentModel.getComment(n,D,e.id);if(!m)return r({...e,show:!1});const v=f&&i>=f.startIndex&&i<=f.endIndex,I=C===n&&e.id===a;return r({...e,active:I||v,show:!m.resolved})}})}_initSyncComments(){var i,o,s;const e=this._context.unit.getUnitId(),t=D,r=(s=(o=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:o.filter(a=>a.type===c.CustomDecorationType.COMMENT).map(a=>a.id))!=null?s:[];r.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),D,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var C,f,m;if(a.id===_.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const I=(m=(f=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:f.filter(d=>d.type===c.CustomDecorationType.COMMENT).map(d=>d.id))!=null?m:[],g=I.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const d=new Set(n),l=new Set(g),M=new Set,b=new Set;I.forEach(h=>{d.has(h)||M.add(h)}),n.forEach(h=>{l.has(h)||b.add(h)}),n=g,M.forEach(h=>{this._threadCommentModel.getComment(e,t,h)||this._threadCommentModel.addComment(e,t,{id:h,threadId:h,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...M])}}}))}};K=Me([U(1,c.Inject(_.DocInterceptorService)),U(2,c.Inject(O.ThreadCommentPanelService)),U(3,c.Inject(V.DocRenderController)),U(4,c.IUniverInstanceService),U(5,c.Inject(w.ThreadCommentModel)),U(6,c.ICommandService)],K);var De=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(e,t,r)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t,r,n)=>{for(var i=n>1?void 0:n?Te(t,r):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},W=(e,t)=>(r,n)=>t(r,n,e),te=(e,t,r)=>be(e,typeof t!="symbol"?t+"":t,r);exports.UniverDocsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=k,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:o,...s}=c.merge({},k,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(se,s)}onStarting(){[[q],[B],[E]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[K].forEach(t=>{this._renderManagerSrv.registerRenderModule(c.UniverInstanceType.UNIVER_DOC,t)})}};te(exports.UniverDocsThreadCommentUIPlugin,"pluginName",ce);te(exports.UniverDocsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=ye([c.DependentOn(O.UniverThreadCommentUIPlugin),W(1,c.Inject(c.Injector)),W(2,x.IRenderManagerService),W(3,c.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=G;exports.DeleteDocCommentComment=Z;exports.ShowCommentPanelOperation=N;exports.StartAddCommentOperation=j;
|
|
1
|
+
"use strict";var re=Object.defineProperty;var ie=(e,t,r)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var H=(e,t,r)=>ie(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),b=require("@univerjs/engine-render"),O=require("@univerjs/thread-comment-ui"),_=require("@univerjs/docs"),V=require("@univerjs/docs-ui"),w=require("@univerjs/thread-comment"),u=require("@univerjs/ui"),R=require("rxjs"),oe=require("react/jsx-runtime"),p=require("react"),ce="DOC_THREAD_COMMENT_UI_PLUGIN",T="default_doc",ae="docs-thread-comment-ui.config",k={};var se=Object.getOwnPropertyDescriptor,de=(e,t,r,n)=>{for(var i=n>1?void 0:n?se(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},J=(e,t)=>(r,n)=>t(r,n,e);let E=class extends c.Disposable{constructor(t,r){super();H(this,"_addingComment$",new R.BehaviorSubject(void 0));H(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=r,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};E=de([J(0,u.ISidebarService),J(1,c.Inject(O.ThreadCommentPanelService))],E);const G={id:"docs.command.add-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:r,unitId:n}=t,o=await e.get(w.IThreadCommentDataSourceService).addComment(r),a=e.get(c.ICommandService),s=V.addCustomDecorationBySelectionFactory(e,{id:o.threadId,type:c.CustomDecorationType.COMMENT,unitId:n});if(s){const C={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:T,comment:o}},v={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:T,commentId:o.id}};return(await c.sequenceExecute([C,s,v],a)).result}return!1}},Z={id:"docs.command.delete-comment",type:c.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:r,unitId:n}=t,i=e.get(c.ICommandService),o=V.deleteCustomDecorationFactory(e,{id:r,unitId:n});return o?(await c.sequenceExecute([o],i)).result:!1}},Y=e=>{var a;const t=e.get(b.IRenderManagerService),r=e.get(_.DocSelectionManagerService),n=(a=b.withCurrentTypeOfRenderer(c.UniverInstanceType.UNIVER_DOC,_.DocSkeletonManagerService,e.get(c.IUniverInstanceService),t))==null?void 0:a.getSkeleton(),i=n==null?void 0:n.getViewModel().getEditArea();if(i===b.DocumentEditArea.FOOTER||i===b.DocumentEditArea.HEADER)return!0;const o=r.getActiveTextRange();return!!(o==null||o.collapsed)};function me(e){return{id:j.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_DOC,void 0,c.SHEET_EDITOR_UNITS),disabled$:new R.Observable(function(t){const n=e.get(_.DocSelectionManagerService).textSelection$.pipe(R.debounceTime(16)).subscribe(()=>{t.next(Y(e))});return()=>{n.unsubscribe()}})}}function le(e){return{id:z.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_DOC)}}const P=()=>{const e=u.useDependency(c.IUniverInstanceService),t=u.useDependency(c.Injector),r=p.useMemo(()=>e.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_DOC).pipe(R.filter(d=>!!d&&!c.isInternalEditorID(d.getUnitId()))),[e]),n=u.useObservable(r),i=p.useMemo(()=>new R.Observable(d=>d.next(T)),[]),o=u.useDependency(_.DocSelectionManagerService),a=p.useMemo(()=>o.textSelection$.pipe(R.debounceTime(16)),[o.textSelection$]);u.useObservable(a);const s=u.useDependency(c.ICommandService),C=u.useDependency(E),v=u.useObservable(C.addingComment$),[m,f]=p.useState([]);if(p.useEffect(()=>{var y;const d=new Set,l=n==null?void 0:n.getCustomDecorations();f((y=l==null?void 0:l.map(h=>h.id).filter(h=>{const D=d.has(h);return d.add(h),!D}))!=null?y:[]);const M=s.onCommandExecuted(h=>{var D;if(h.id===_.RichTextEditingMutation.id){const A=new Set,F=n==null?void 0:n.getCustomDecorations();f((D=F==null?void 0:F.map($=>$.id).filter($=>{const ne=A.has($);return A.add($),!ne}))!=null?D:[])}});return()=>{M.dispose()}},[s,n]),!n)return null;const I=Y(t),g=n.getUnitId();return oe.jsx(O.ThreadCommentPanel,{unitId:g,subUnitId$:i,type:c.UniverInstanceType.UNIVER_DOC,onAdd:()=>{s.executeCommand(j.id)},getSubUnitName:()=>"",disableAdd:I,tempComment:v,onAddComment:d=>{if(!d.parentId){const l={unitId:g,range:v,comment:d};return s.executeCommand(G.id,l),C.endAdd(),!1}return!0},onDeleteComment:d=>{if(!d.parentId){const l={unitId:g,commentId:d.id};return s.executeCommand(Z.id,l),!1}return!0},showComments:m})};P.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:c.CommandType.OPERATION,handler(e,t){var i;const r=e.get(O.ThreadCommentPanelService),n=e.get(u.ISidebarService);return(!r.panelVisible||((i=n.options.children)==null?void 0:i.label)!==P.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:P.componentKey},width:320,onClose:()=>r.setPanelVisible(!1)}),r.setPanelVisible(!0)),t&&r.setActiveComment(t==null?void 0:t.activeComment),!0}},z={id:"docs.operation.toggle-comment-panel",type:c.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),r=e.get(u.ISidebarService);return!t.panelVisible||((n=r.options.children)==null?void 0:n.label)!==P.componentKey?(r.open({header:{title:"threadCommentUI.panel.title"},children:{label:P.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(r.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},j={id:"docs.operation.start-add-comment",type:c.CommandType.OPERATION,handler(e){var h,D,A;const t=e.get(O.ThreadCommentPanelService),n=e.get(c.IUniverInstanceService).getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC),i=e.get(_.DocSelectionManagerService),o=e.get(b.IRenderManagerService),a=e.get(c.UserManagerService),s=e.get(E),C=e.get(c.ICommandService),v=e.get(u.ISidebarService),m=i.getActiveTextRange();if(!n||!m)return!1;const f=(h=o.getRenderById(n.getUnitId()))==null?void 0:h.with(V.DocSelectionRenderService);if(f==null||f.setReserveRangesStatus(!0),m.collapsed)return t.panelVisible?(t.setPanelVisible(!1),v.close()):C.executeCommand(N.id),!0;C.executeCommand(N.id);const I=n.getUnitId(),g=((A=(D=n.getBody())==null?void 0:D.dataStream)!=null?A:"").slice(m.startOffset,m.endOffset),d=c.BuildTextUtils.transform.getPlainText(g),l=T,M="",y={unitId:I,subUnitId:l,id:M,ref:d,dT:w.getDT(),personId:a.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
+
`},startOffset:m.startOffset,endOffset:m.endOffset,collapsed:!0,threadId:M};return f==null||f.blur(),s.startAdd(y),t.setActiveComment({unitId:I,subUnitId:l,commentId:M}),!0}};var ue=Object.getOwnPropertyDescriptor,Ce=(e,t,r,n)=>{for(var i=n>1?void 0:n?ue(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},U=(e,t)=>(r,n)=>t(r,n,e);let B=class extends c.Disposable{constructor(e,t,r,n,i,o){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=r,this._docThreadCommentService=n,this._renderManagerService=i,this._threadCommentModel=o,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var r,n,i,o;if(t.id===_.SetTextSelectionsOperation.id){const a=t.params,{unitId:s,ranges:C}=a;if(c.isInternalEditorID(s))return;const v=this._univerInstanceService.getUnit(s,c.UniverInstanceType.UNIVER_DOC),m=C[0];if((e==null?void 0:e.startOffset)===(m==null?void 0:m.startOffset)&&(e==null?void 0:e.endOffset)===(m==null?void 0:m.endOffset))return;if(e=m,m&&v){const{startOffset:f,endOffset:I,collapsed:g}=m;let d;if(g?d=(n=(r=v.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(l=>l.startIndex<=f&&l.endIndex>=I-1):d=(o=(i=v.getBody())==null?void 0:i.customDecorations)==null?void 0:o.find(l=>l.startIndex<=f&&l.endIndex>=I-1),d){const l=this._threadCommentModel.getComment(s,T,d.id);l&&!l.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:s,subUnitId:T,commentId:d.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,r,n,i;if(e){const o=this._univerInstanceService.getUnit(e.unitId);if(o){const a=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(V.DocBackScrollRenderController),s=(n=(r=o.getBody())==null?void 0:r.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);s&&a&&a.scrollToRange({startOffset:s.startIndex,endOffset:s.endIndex,collapsed:!1})}}(!e||e.commentId!==((i=this._docThreadCommentService.addingComment)==null?void 0:i.id))&&this._docThreadCommentService.endAdd()}))}};B=Ce([U(0,c.Inject(O.ThreadCommentPanelService)),U(1,c.IUniverInstanceService),U(2,c.ICommandService),U(3,c.Inject(E)),U(4,b.IRenderManagerService),U(5,c.Inject(w.ThreadCommentModel))],B);var S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},S.apply(this,arguments)},he=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r},Q=p.forwardRef(function(e,t){var r=e.icon,n=e.id,i=e.className,o=e.extend,a=he(e,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),C=p.useRef("_".concat(ge()));return X(r,"".concat(n),{defIds:r.defIds,idSuffix:C.current},S({ref:t,className:s},a),o)});function X(e,t,r,n,i){return p.createElement(e.tag,S(S({key:t},ve(e,r,i)),n),(fe(e,r).children||[]).map(function(o,a){return X(o,"".concat(t,"-").concat(e.tag,"-").concat(a),r,void 0,i)}))}function ve(e,t,r){var n=S({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],s=o[1];a==="mask"&&typeof s=="string"&&(n[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(n[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function fe(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?S(S({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?S(S({},i),{attrs:S(S({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function ge(){return Math.random().toString(36).substring(2,8)}Q.displayName="UniverIcon";var Ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ee=p.forwardRef(function(e,t){return p.createElement(Q,Object.assign({},e,{id:"comment-single",ref:t,icon:Ie}))});ee.displayName="CommentSingle";const Se={[u.RibbonStartGroup.OTHERS]:{[z.id]:{order:1,menuItemFactory:le}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[j.id]:{order:1,menuItemFactory:me}}}};var pe=Object.getOwnPropertyDescriptor,_e=(e,t,r,n)=>{for(var i=n>1?void 0:n?pe(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},L=(e,t)=>(r,n)=>t(r,n,e);let q=class extends c.Disposable{constructor(e,t,r){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[G,Z,N,j,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Se)}_initComponents(){[P].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",ee))}};q=_e([L(0,c.ICommandService),L(1,u.IMenuManagerService),L(2,c.Inject(u.ComponentManager))],q);var Oe=Object.getOwnPropertyDescriptor,Me=(e,t,r,n)=>{for(var i=n>1?void 0:n?Oe(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},x=(e,t)=>(r,n)=>t(r,n,e);let K=class extends c.Disposable{constructor(e,t,r,n,i,o,a){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=r,this._docRenderController=n,this._univerInstanceService=i,this._threadCommentModel=o,this._commandService=a,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var r;if(e){this._docRenderController.reRender(e.unitId);return}const t=(r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(_.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,r)=>{if(!e)return r(e);const{unitId:n,index:i,customDecorations:o}=t,a=this._threadCommentPanelService.activeCommentId,{commentId:s,unitId:C}=a||{},v=o.find(g=>g.id===s),m=this._threadCommentModel.getComment(n,T,e.id);if(!m)return r({...e,show:!1});const f=v&&i>=v.startIndex&&i<=v.endIndex,I=C===n&&e.id===s;return r({...e,active:I||f,show:!m.resolved})}})}_initSyncComments(){var i,o,a;const e=this._context.unit.getUnitId(),t=T,r=(a=(o=(i=this._context.unit.getBody())==null?void 0:i.customDecorations)==null?void 0:o.filter(s=>s.type===c.CustomDecorationType.COMMENT).map(s=>s.id))!=null?a:[];r.forEach(s=>{this._threadCommentModel.getComment(e,t,s)||this._threadCommentModel.addComment(e,t,{id:s,threadId:s,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),r.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),T,r);let n=r.sort();this.disposeWithMe(this._commandService.onCommandExecuted(s=>{var C,v,m;if(s.id===_.RichTextEditingMutation.id){if(s.params.unitId!==this._context.unit.getUnitId())return;const I=(m=(v=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:v.filter(d=>d.type===c.CustomDecorationType.COMMENT).map(d=>d.id))!=null?m:[],g=I.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const d=new Set(n),l=new Set(g),M=new Set,y=new Set;I.forEach(h=>{d.has(h)||M.add(h)}),n.forEach(h=>{l.has(h)||y.add(h)}),n=g,M.forEach(h=>{this._threadCommentModel.getComment(e,t,h)||this._threadCommentModel.addComment(e,t,{id:h,threadId:h,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...M])}}}))}};K=Me([x(1,c.Inject(_.DocInterceptorService)),x(2,c.Inject(O.ThreadCommentPanelService)),x(3,c.Inject(V.DocRenderController)),x(4,c.IUniverInstanceService),x(5,c.Inject(w.ThreadCommentModel)),x(6,c.ICommandService)],K);var Te=Object.defineProperty,De=Object.getOwnPropertyDescriptor,be=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t,r,n)=>{for(var i=n>1?void 0:n?De(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=a(i)||i);return i},W=(e,t)=>(r,n)=>t(r,n,e),te=(e,t,r)=>be(e,typeof t!="symbol"?t+"":t,r);exports.UniverDocsThreadCommentUIPlugin=class extends c.Plugin{constructor(t=k,r,n,i){super(),this._config=t,this._injector=r,this._renderManagerSrv=n,this._configService=i;const{menu:o,...a}=c.merge({},k,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(ae,a)}onStarting(){[[q],[B],[E]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[K].forEach(t=>{this._renderManagerSrv.registerRenderModule(c.UniverInstanceType.UNIVER_DOC,t)})}};te(exports.UniverDocsThreadCommentUIPlugin,"pluginName",ce);te(exports.UniverDocsThreadCommentUIPlugin,"type",c.UniverInstanceType.UNIVER_DOC);exports.UniverDocsThreadCommentUIPlugin=ye([c.DependentOn(O.UniverThreadCommentUIPlugin),W(1,c.Inject(c.Injector)),W(2,b.IRenderManagerService),W(3,c.IConfigService)],exports.UniverDocsThreadCommentUIPlugin);exports.AddDocCommentComment=G;exports.DeleteDocCommentComment=Z;exports.ShowCommentPanelOperation=N;exports.StartAddCommentOperation=j;
|
package/lib/es/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
var Oe = Object.defineProperty;
|
|
2
2
|
var Me = (e, t, r) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var G = (e, t, r) => Me(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { Inject as _, Disposable as
|
|
5
|
-
import { IRenderManagerService as F, DocumentEditArea as X } from "@univerjs/engine-render";
|
|
6
|
-
import { ThreadCommentPanelService as U, SetActiveCommentOperation as oe, ThreadCommentPanel as
|
|
7
|
-
import { DocSelectionManagerService as H, DocSkeletonManagerService as
|
|
8
|
-
import { addCustomDecorationBySelectionFactory as
|
|
9
|
-
import { IThreadCommentDataSourceService as
|
|
10
|
-
import { ISidebarService as L, getMenuHiddenObservable as ce, MenuItemType as ae, useDependency as E, useObservable as Z, ContextMenuPosition as
|
|
11
|
-
import { BehaviorSubject as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { useMemo as z, useState as
|
|
14
|
-
const
|
|
15
|
-
var
|
|
16
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
4
|
+
import { Inject as _, Disposable as B, CommandType as P, ICommandService as M, CustomDecorationType as q, sequenceExecute as ne, UniverInstanceType as p, SHEET_EDITOR_UNITS as be, IUniverInstanceService as A, Injector as re, isInternalEditorID as ie, UserManagerService as De, BuildTextUtils as ye, DependentOn as xe, IConfigService as Te, Plugin as Ue, merge as Re } from "@univerjs/core";
|
|
5
|
+
import { IRenderManagerService as F, withCurrentTypeOfRenderer as Ee, DocumentEditArea as X } from "@univerjs/engine-render";
|
|
6
|
+
import { ThreadCommentPanelService as U, SetActiveCommentOperation as oe, ThreadCommentPanel as Pe, UniverThreadCommentUIPlugin as Ae } from "@univerjs/thread-comment-ui";
|
|
7
|
+
import { DocSelectionManagerService as H, DocSkeletonManagerService as Ne, RichTextEditingMutation as se, SetTextSelectionsOperation as we, DocInterceptorService as Ve, DOC_INTERCEPTOR_POINT as $e } from "@univerjs/docs";
|
|
8
|
+
import { addCustomDecorationBySelectionFactory as je, deleteCustomDecorationFactory as Be, DocSelectionRenderService as Fe, DocBackScrollRenderController as He, DocRenderController as Le } from "@univerjs/docs-ui";
|
|
9
|
+
import { IThreadCommentDataSourceService as We, AddCommentMutation as Ke, getDT as Ge, ThreadCommentModel as de } from "@univerjs/thread-comment";
|
|
10
|
+
import { ISidebarService as L, getMenuHiddenObservable as ce, MenuItemType as ae, useDependency as E, useObservable as Z, ContextMenuPosition as Ze, ContextMenuGroup as ze, RibbonStartGroup as ke, IMenuManagerService as Je, ComponentManager as qe } from "@univerjs/ui";
|
|
11
|
+
import { BehaviorSubject as Ye, Observable as me, debounceTime as le, filter as Qe } from "rxjs";
|
|
12
|
+
import { jsx as Xe } from "react/jsx-runtime";
|
|
13
|
+
import { useMemo as z, useState as et, useEffect as tt, forwardRef as ue, useRef as nt, createElement as fe } from "react";
|
|
14
|
+
const rt = "DOC_THREAD_COMMENT_UI_PLUGIN", S = "default_doc", it = "docs-thread-comment-ui.config", ee = {};
|
|
15
|
+
var ot = Object.getOwnPropertyDescriptor, st = (e, t, r, n) => {
|
|
16
|
+
for (var i = n > 1 ? void 0 : n ? ot(t, r) : t, o = e.length - 1, s; o >= 0; o--)
|
|
17
17
|
(s = e[o]) && (i = s(i) || i);
|
|
18
18
|
return i;
|
|
19
19
|
}, te = (e, t) => (r, n) => t(r, n, e);
|
|
20
|
-
let x = class extends
|
|
20
|
+
let x = class extends B {
|
|
21
21
|
constructor(t, r) {
|
|
22
22
|
super();
|
|
23
|
-
G(this, "_addingComment$", new
|
|
23
|
+
G(this, "_addingComment$", new Ye(void 0));
|
|
24
24
|
G(this, "addingComment$", this._addingComment$.asObservable());
|
|
25
25
|
this._sidebarService = t, this._threadCommentPanelService = r, this.disposeWithMe(() => {
|
|
26
26
|
this._addingComment$.complete();
|
|
@@ -36,7 +36,7 @@ let x = class extends j {
|
|
|
36
36
|
this._addingComment$.next(void 0);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
x =
|
|
39
|
+
x = st([
|
|
40
40
|
te(0, L),
|
|
41
41
|
te(1, _(U))
|
|
42
42
|
], x);
|
|
@@ -46,7 +46,7 @@ const he = {
|
|
|
46
46
|
async handler(e, t) {
|
|
47
47
|
if (!t)
|
|
48
48
|
return !1;
|
|
49
|
-
const { comment: r, unitId: n } = t, o = await e.get(
|
|
49
|
+
const { comment: r, unitId: n } = t, o = await e.get(We).addComment(r), s = e.get(M), d = je(
|
|
50
50
|
e,
|
|
51
51
|
{
|
|
52
52
|
id: o.threadId,
|
|
@@ -56,17 +56,17 @@ const he = {
|
|
|
56
56
|
);
|
|
57
57
|
if (d) {
|
|
58
58
|
const l = {
|
|
59
|
-
id:
|
|
59
|
+
id: Ke.id,
|
|
60
60
|
params: {
|
|
61
61
|
unitId: n,
|
|
62
|
-
subUnitId:
|
|
62
|
+
subUnitId: S,
|
|
63
63
|
comment: o
|
|
64
64
|
}
|
|
65
65
|
}, f = {
|
|
66
66
|
id: oe.id,
|
|
67
67
|
params: {
|
|
68
68
|
unitId: n,
|
|
69
|
-
subUnitId:
|
|
69
|
+
subUnitId: S,
|
|
70
70
|
commentId: o.id
|
|
71
71
|
}
|
|
72
72
|
};
|
|
@@ -80,27 +80,33 @@ const he = {
|
|
|
80
80
|
async handler(e, t) {
|
|
81
81
|
if (!t)
|
|
82
82
|
return !1;
|
|
83
|
-
const { commentId: r, unitId: n } = t, i = e.get(M), o =
|
|
83
|
+
const { commentId: r, unitId: n } = t, i = e.get(M), o = Be(e, {
|
|
84
84
|
id: r,
|
|
85
85
|
unitId: n
|
|
86
86
|
});
|
|
87
87
|
return o ? (await ne([o], i)).result : !1;
|
|
88
88
|
}
|
|
89
89
|
}, ge = (e) => {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
var s;
|
|
91
|
+
const t = e.get(F), r = e.get(H), n = (s = Ee(
|
|
92
|
+
p.UNIVER_DOC,
|
|
93
|
+
Ne,
|
|
94
|
+
e.get(A),
|
|
95
|
+
t
|
|
96
|
+
)) == null ? void 0 : s.getSkeleton(), i = n == null ? void 0 : n.getViewModel().getEditArea();
|
|
97
|
+
if (i === X.FOOTER || i === X.HEADER)
|
|
92
98
|
return !0;
|
|
93
|
-
const
|
|
94
|
-
return !!(
|
|
99
|
+
const o = r.getActiveTextRange();
|
|
100
|
+
return !!(o == null || o.collapsed);
|
|
95
101
|
};
|
|
96
|
-
function
|
|
102
|
+
function dt(e) {
|
|
97
103
|
return {
|
|
98
104
|
id: W.id,
|
|
99
105
|
type: ae.BUTTON,
|
|
100
106
|
icon: "CommentSingle",
|
|
101
107
|
title: "threadCommentUI.panel.addComment",
|
|
102
108
|
tooltip: "threadCommentUI.panel.addComment",
|
|
103
|
-
hidden$: ce(e,
|
|
109
|
+
hidden$: ce(e, p.UNIVER_DOC, void 0, be),
|
|
104
110
|
disabled$: new me(function(t) {
|
|
105
111
|
const n = e.get(H).textSelection$.pipe(le(16)).subscribe(() => {
|
|
106
112
|
t.next(ge(e));
|
|
@@ -111,52 +117,52 @@ function st(e) {
|
|
|
111
117
|
})
|
|
112
118
|
};
|
|
113
119
|
}
|
|
114
|
-
function
|
|
120
|
+
function ct(e) {
|
|
115
121
|
return {
|
|
116
122
|
id: Q.id,
|
|
117
123
|
type: ae.BUTTON,
|
|
118
124
|
icon: "CommentSingle",
|
|
119
125
|
title: "threadCommentUI.panel.addComment",
|
|
120
126
|
tooltip: "threadCommentUI.panel.addComment",
|
|
121
|
-
hidden$: ce(e,
|
|
127
|
+
hidden$: ce(e, p.UNIVER_DOC)
|
|
122
128
|
};
|
|
123
129
|
}
|
|
124
130
|
const T = () => {
|
|
125
|
-
const e = E(
|
|
131
|
+
const e = E(A), t = E(re), r = z(() => e.getCurrentTypeOfUnit$(p.UNIVER_DOC).pipe(Qe((c) => !!c && !ie(c.getUnitId()))), [e]), n = Z(r), i = z(() => new me((c) => c.next(S)), []), o = E(H), s = z(
|
|
126
132
|
() => o.textSelection$.pipe(le(16)),
|
|
127
133
|
[o.textSelection$]
|
|
128
134
|
);
|
|
129
135
|
Z(s);
|
|
130
|
-
const d = E(M), l = E(x), f = Z(l.addingComment$), [a, h] =
|
|
131
|
-
if (
|
|
136
|
+
const d = E(M), l = E(x), f = Z(l.addingComment$), [a, h] = et([]);
|
|
137
|
+
if (tt(() => {
|
|
132
138
|
var b;
|
|
133
139
|
const c = /* @__PURE__ */ new Set(), m = n == null ? void 0 : n.getCustomDecorations();
|
|
134
140
|
h((b = m == null ? void 0 : m.map((u) => u.id).filter((u) => {
|
|
135
141
|
const O = c.has(u);
|
|
136
142
|
return c.add(u), !O;
|
|
137
143
|
})) != null ? b : []);
|
|
138
|
-
const
|
|
144
|
+
const I = d.onCommandExecuted((u) => {
|
|
139
145
|
var O;
|
|
140
146
|
if (u.id === se.id) {
|
|
141
147
|
const R = /* @__PURE__ */ new Set(), K = n == null ? void 0 : n.getCustomDecorations();
|
|
142
|
-
h((O = K == null ? void 0 : K.map((
|
|
143
|
-
const Se = R.has(
|
|
144
|
-
return R.add(
|
|
148
|
+
h((O = K == null ? void 0 : K.map((N) => N.id).filter((N) => {
|
|
149
|
+
const Se = R.has(N);
|
|
150
|
+
return R.add(N), !Se;
|
|
145
151
|
})) != null ? O : []);
|
|
146
152
|
}
|
|
147
153
|
});
|
|
148
154
|
return () => {
|
|
149
|
-
|
|
155
|
+
I.dispose();
|
|
150
156
|
};
|
|
151
157
|
}, [d, n]), !n)
|
|
152
158
|
return null;
|
|
153
159
|
const g = ge(t), C = n.getUnitId();
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
|
|
160
|
+
return /* @__PURE__ */ Xe(
|
|
161
|
+
Pe,
|
|
156
162
|
{
|
|
157
163
|
unitId: C,
|
|
158
164
|
subUnitId$: i,
|
|
159
|
-
type:
|
|
165
|
+
type: p.UNIVER_DOC,
|
|
160
166
|
onAdd: () => {
|
|
161
167
|
d.executeCommand(W.id);
|
|
162
168
|
},
|
|
@@ -220,19 +226,19 @@ const w = {
|
|
|
220
226
|
type: P.OPERATION,
|
|
221
227
|
handler(e) {
|
|
222
228
|
var u, O, R;
|
|
223
|
-
const t = e.get(U), n = e.get(
|
|
229
|
+
const t = e.get(U), n = e.get(A).getCurrentUnitForType(p.UNIVER_DOC), i = e.get(H), o = e.get(F), s = e.get(De), d = e.get(x), l = e.get(M), f = e.get(L), a = i.getActiveTextRange();
|
|
224
230
|
if (!n || !a)
|
|
225
231
|
return !1;
|
|
226
|
-
const h = (u = o.getRenderById(n.getUnitId())) == null ? void 0 : u.with(
|
|
232
|
+
const h = (u = o.getRenderById(n.getUnitId())) == null ? void 0 : u.with(Fe);
|
|
227
233
|
if (h == null || h.setReserveRangesStatus(!0), a.collapsed)
|
|
228
234
|
return t.panelVisible ? (t.setPanelVisible(!1), f.close()) : l.executeCommand(w.id), !0;
|
|
229
235
|
l.executeCommand(w.id);
|
|
230
|
-
const g = n.getUnitId(), C = ((R = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? R : "").slice(a.startOffset, a.endOffset), c = ye.transform.getPlainText(C), m =
|
|
236
|
+
const g = n.getUnitId(), C = ((R = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? R : "").slice(a.startOffset, a.endOffset), c = ye.transform.getPlainText(C), m = S, I = "", b = {
|
|
231
237
|
unitId: g,
|
|
232
238
|
subUnitId: m,
|
|
233
|
-
id:
|
|
239
|
+
id: I,
|
|
234
240
|
ref: c,
|
|
235
|
-
dT:
|
|
241
|
+
dT: Ge(),
|
|
236
242
|
personId: s.getCurrentUser().userID,
|
|
237
243
|
text: {
|
|
238
244
|
dataStream: `\r
|
|
@@ -241,21 +247,21 @@ const w = {
|
|
|
241
247
|
startOffset: a.startOffset,
|
|
242
248
|
endOffset: a.endOffset,
|
|
243
249
|
collapsed: !0,
|
|
244
|
-
threadId:
|
|
250
|
+
threadId: I
|
|
245
251
|
};
|
|
246
252
|
return h == null || h.blur(), d.startAdd(b), t.setActiveComment({
|
|
247
253
|
unitId: g,
|
|
248
254
|
subUnitId: m,
|
|
249
|
-
commentId:
|
|
255
|
+
commentId: I
|
|
250
256
|
}), !0;
|
|
251
257
|
}
|
|
252
258
|
};
|
|
253
|
-
var
|
|
254
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
259
|
+
var at = Object.getOwnPropertyDescriptor, mt = (e, t, r, n) => {
|
|
260
|
+
for (var i = n > 1 ? void 0 : n ? at(t, r) : t, o = e.length - 1, s; o >= 0; o--)
|
|
255
261
|
(s = e[o]) && (i = s(i) || i);
|
|
256
262
|
return i;
|
|
257
263
|
}, D = (e, t) => (r, n) => t(r, n, e);
|
|
258
|
-
let
|
|
264
|
+
let V = class extends B {
|
|
259
265
|
constructor(e, t, r, n, i, o) {
|
|
260
266
|
super(), this._threadCommentPanelService = e, this._univerInstanceService = t, this._commandService = r, this._docThreadCommentService = n, this._renderManagerService = i, this._threadCommentModel = o, this._initSelectionChange(), this._initActiveCommandChange();
|
|
261
267
|
}
|
|
@@ -267,18 +273,18 @@ let N = class extends j {
|
|
|
267
273
|
if (t.id === we.id) {
|
|
268
274
|
const s = t.params, { unitId: d, ranges: l } = s;
|
|
269
275
|
if (ie(d)) return;
|
|
270
|
-
const f = this._univerInstanceService.getUnit(d,
|
|
276
|
+
const f = this._univerInstanceService.getUnit(d, p.UNIVER_DOC), a = l[0];
|
|
271
277
|
if ((e == null ? void 0 : e.startOffset) === (a == null ? void 0 : a.startOffset) && (e == null ? void 0 : e.endOffset) === (a == null ? void 0 : a.endOffset))
|
|
272
278
|
return;
|
|
273
279
|
if (e = a, a && f) {
|
|
274
280
|
const { startOffset: h, endOffset: g, collapsed: C } = a;
|
|
275
281
|
let c;
|
|
276
282
|
if (C ? c = (n = (r = f.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((m) => m.startIndex <= h && m.endIndex >= g - 1) : c = (o = (i = f.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.find((m) => m.startIndex <= h && m.endIndex >= g - 1), c) {
|
|
277
|
-
const m = this._threadCommentModel.getComment(d,
|
|
283
|
+
const m = this._threadCommentModel.getComment(d, S, c.id);
|
|
278
284
|
m && !m.resolved && this._commandService.executeCommand(w.id, {
|
|
279
285
|
activeComment: {
|
|
280
286
|
unitId: d,
|
|
281
|
-
subUnitId:
|
|
287
|
+
subUnitId: S,
|
|
282
288
|
commentId: c.id
|
|
283
289
|
}
|
|
284
290
|
});
|
|
@@ -298,7 +304,7 @@ let N = class extends j {
|
|
|
298
304
|
if (e) {
|
|
299
305
|
const o = this._univerInstanceService.getUnit(e.unitId);
|
|
300
306
|
if (o) {
|
|
301
|
-
const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(
|
|
307
|
+
const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(He), d = (n = (r = o.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((l) => l.id === e.commentId);
|
|
302
308
|
d && s && s.scrollToRange({
|
|
303
309
|
startOffset: d.startIndex,
|
|
304
310
|
endOffset: d.endIndex,
|
|
@@ -310,14 +316,14 @@ let N = class extends j {
|
|
|
310
316
|
}));
|
|
311
317
|
}
|
|
312
318
|
};
|
|
313
|
-
|
|
319
|
+
V = mt([
|
|
314
320
|
D(0, _(U)),
|
|
315
|
-
D(1,
|
|
321
|
+
D(1, A),
|
|
316
322
|
D(2, M),
|
|
317
323
|
D(3, _(x)),
|
|
318
324
|
D(4, F),
|
|
319
325
|
D(5, _(de))
|
|
320
|
-
],
|
|
326
|
+
], V);
|
|
321
327
|
var v = function() {
|
|
322
328
|
return v = Object.assign || function(e) {
|
|
323
329
|
for (var t, r = 1, n = arguments.length; r < n; r++) {
|
|
@@ -326,7 +332,7 @@ var v = function() {
|
|
|
326
332
|
}
|
|
327
333
|
return e;
|
|
328
334
|
}, v.apply(this, arguments);
|
|
329
|
-
},
|
|
335
|
+
}, lt = function(e, t) {
|
|
330
336
|
var r = {};
|
|
331
337
|
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
332
338
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -334,15 +340,15 @@ var v = function() {
|
|
|
334
340
|
t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (r[n[i]] = e[n[i]]);
|
|
335
341
|
return r;
|
|
336
342
|
}, ve = ue(function(e, t) {
|
|
337
|
-
var r = e.icon, n = e.id, i = e.className, o = e.extend, s =
|
|
343
|
+
var r = e.icon, n = e.id, i = e.className, o = e.extend, s = lt(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(i || "").trim(), l = nt("_".concat(ht()));
|
|
338
344
|
return _e(r, "".concat(n), { defIds: r.defIds, idSuffix: l.current }, v({ ref: t, className: d }, s), o);
|
|
339
345
|
});
|
|
340
346
|
function _e(e, t, r, n, i) {
|
|
341
|
-
return fe(e.tag, v(v({ key: t },
|
|
347
|
+
return fe(e.tag, v(v({ key: t }, ut(e, r, i)), n), (ft(e, r).children || []).map(function(o, s) {
|
|
342
348
|
return _e(o, "".concat(t, "-").concat(e.tag, "-").concat(s), r, void 0, i);
|
|
343
349
|
}));
|
|
344
350
|
}
|
|
345
|
-
function
|
|
351
|
+
function ut(e, t, r) {
|
|
346
352
|
var n = v({}, e.attrs);
|
|
347
353
|
r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(function(o) {
|
|
348
354
|
var s = o[0], d = o[1];
|
|
@@ -354,46 +360,46 @@ function lt(e, t, r) {
|
|
|
354
360
|
typeof d == "string" && (n[s] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
|
|
355
361
|
})), n;
|
|
356
362
|
}
|
|
357
|
-
function
|
|
363
|
+
function ft(e, t) {
|
|
358
364
|
var r, n = t.defIds;
|
|
359
365
|
return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? v(v({}, e), { children: e.children.map(function(i) {
|
|
360
366
|
return typeof i.attrs.id == "string" && n && n.indexOf(i.attrs.id) > -1 ? v(v({}, i), { attrs: v(v({}, i.attrs), { id: i.attrs.id + t.idSuffix }) }) : i;
|
|
361
367
|
}) }) : e;
|
|
362
368
|
}
|
|
363
|
-
function
|
|
369
|
+
function ht() {
|
|
364
370
|
return Math.random().toString(36).substring(2, 8);
|
|
365
371
|
}
|
|
366
372
|
ve.displayName = "UniverIcon";
|
|
367
|
-
var
|
|
373
|
+
var Ct = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, pe = ue(function(e, t) {
|
|
368
374
|
return fe(ve, Object.assign({}, e, {
|
|
369
375
|
id: "comment-single",
|
|
370
376
|
ref: t,
|
|
371
|
-
icon:
|
|
377
|
+
icon: Ct
|
|
372
378
|
}));
|
|
373
379
|
});
|
|
374
380
|
pe.displayName = "CommentSingle";
|
|
375
|
-
const
|
|
376
|
-
[
|
|
381
|
+
const gt = {
|
|
382
|
+
[ke.OTHERS]: {
|
|
377
383
|
[Q.id]: {
|
|
378
384
|
order: 1,
|
|
379
|
-
menuItemFactory:
|
|
385
|
+
menuItemFactory: ct
|
|
380
386
|
}
|
|
381
387
|
},
|
|
382
|
-
[
|
|
383
|
-
[
|
|
388
|
+
[Ze.MAIN_AREA]: {
|
|
389
|
+
[ze.DATA]: {
|
|
384
390
|
[W.id]: {
|
|
385
391
|
order: 1,
|
|
386
|
-
menuItemFactory:
|
|
392
|
+
menuItemFactory: dt
|
|
387
393
|
}
|
|
388
394
|
}
|
|
389
395
|
}
|
|
390
396
|
};
|
|
391
|
-
var
|
|
392
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
397
|
+
var vt = Object.getOwnPropertyDescriptor, _t = (e, t, r, n) => {
|
|
398
|
+
for (var i = n > 1 ? void 0 : n ? vt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
|
|
393
399
|
(s = e[o]) && (i = s(i) || i);
|
|
394
400
|
return i;
|
|
395
401
|
}, k = (e, t) => (r, n) => t(r, n, e);
|
|
396
|
-
let
|
|
402
|
+
let $ = class extends B {
|
|
397
403
|
constructor(e, t, r) {
|
|
398
404
|
super(), this._commandService = e, this._menuManagerService = t, this._componentManager = r, this._initCommands(), this._initMenus(), this._initComponents();
|
|
399
405
|
}
|
|
@@ -409,7 +415,7 @@ let V = class extends j {
|
|
|
409
415
|
});
|
|
410
416
|
}
|
|
411
417
|
_initMenus() {
|
|
412
|
-
this._menuManagerService.mergeMenu(
|
|
418
|
+
this._menuManagerService.mergeMenu(gt);
|
|
413
419
|
}
|
|
414
420
|
_initComponents() {
|
|
415
421
|
[T].forEach((e) => {
|
|
@@ -417,17 +423,17 @@ let V = class extends j {
|
|
|
417
423
|
}), this.disposeWithMe(this._componentManager.register("CommentSingle", pe));
|
|
418
424
|
}
|
|
419
425
|
};
|
|
420
|
-
|
|
426
|
+
$ = _t([
|
|
421
427
|
k(0, M),
|
|
422
|
-
k(1,
|
|
423
|
-
k(2, _(
|
|
424
|
-
],
|
|
425
|
-
var
|
|
426
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
428
|
+
k(1, Je),
|
|
429
|
+
k(2, _(qe))
|
|
430
|
+
], $);
|
|
431
|
+
var pt = Object.getOwnPropertyDescriptor, It = (e, t, r, n) => {
|
|
432
|
+
for (var i = n > 1 ? void 0 : n ? pt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
|
|
427
433
|
(s = e[o]) && (i = s(i) || i);
|
|
428
434
|
return i;
|
|
429
435
|
}, y = (e, t) => (r, n) => t(r, n, e);
|
|
430
|
-
let Y = class extends
|
|
436
|
+
let Y = class extends B {
|
|
431
437
|
constructor(e, t, r, n, i, o, s) {
|
|
432
438
|
super(), this._context = e, this._docInterceptorService = t, this._threadCommentPanelService = r, this._docRenderController = n, this._univerInstanceService = i, this._threadCommentModel = o, this._commandService = s, this._interceptorViewModel(), this._initReRender(), this._initSyncComments();
|
|
433
439
|
}
|
|
@@ -438,18 +444,18 @@ let Y = class extends j {
|
|
|
438
444
|
this._docRenderController.reRender(e.unitId);
|
|
439
445
|
return;
|
|
440
446
|
}
|
|
441
|
-
const t = (r = this._univerInstanceService.getCurrentUnitForType(
|
|
447
|
+
const t = (r = this._univerInstanceService.getCurrentUnitForType(p.UNIVER_DOC)) == null ? void 0 : r.getUnitId();
|
|
442
448
|
t && this._docRenderController.reRender(t);
|
|
443
449
|
})), this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((e) => {
|
|
444
450
|
e.type === "resolve" && this._docRenderController.reRender(e.unitId);
|
|
445
451
|
}));
|
|
446
452
|
}
|
|
447
453
|
_interceptorViewModel() {
|
|
448
|
-
this._docInterceptorService.intercept(
|
|
454
|
+
this._docInterceptorService.intercept($e.CUSTOM_DECORATION, {
|
|
449
455
|
handler: (e, t, r) => {
|
|
450
456
|
if (!e)
|
|
451
457
|
return r(e);
|
|
452
|
-
const { unitId: n, index: i, customDecorations: o } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: l } = s || {}, f = o.find((C) => C.id === d), a = this._threadCommentModel.getComment(n,
|
|
458
|
+
const { unitId: n, index: i, customDecorations: o } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: l } = s || {}, f = o.find((C) => C.id === d), a = this._threadCommentModel.getComment(n, S, e.id);
|
|
453
459
|
if (!a)
|
|
454
460
|
return r({
|
|
455
461
|
...e,
|
|
@@ -466,10 +472,10 @@ let Y = class extends j {
|
|
|
466
472
|
}
|
|
467
473
|
_initSyncComments() {
|
|
468
474
|
var i, o, s;
|
|
469
|
-
const e = this._context.unit.getUnitId(), t =
|
|
475
|
+
const e = this._context.unit.getUnitId(), t = S, r = (s = (o = (i = this._context.unit.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.filter((d) => d.type === q.COMMENT).map((d) => d.id)) != null ? s : [];
|
|
470
476
|
r.forEach((d) => {
|
|
471
477
|
this._threadCommentModel.getComment(e, t, d) || this._threadCommentModel.addComment(e, t, { id: d, threadId: d, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId: e, subUnitId: t });
|
|
472
|
-
}), r.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),
|
|
478
|
+
}), r.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), S, r);
|
|
473
479
|
let n = r.sort();
|
|
474
480
|
this.disposeWithMe(this._commandService.onCommandExecuted((d) => {
|
|
475
481
|
var l, f, a;
|
|
@@ -478,33 +484,33 @@ let Y = class extends j {
|
|
|
478
484
|
return;
|
|
479
485
|
const g = (a = (f = (l = this._context.unit.getBody()) == null ? void 0 : l.customDecorations) == null ? void 0 : f.filter((c) => c.type === q.COMMENT).map((c) => c.id)) != null ? a : [], C = g.sort();
|
|
480
486
|
if (JSON.stringify(n) !== JSON.stringify(C)) {
|
|
481
|
-
const c = new Set(n), m = new Set(C),
|
|
487
|
+
const c = new Set(n), m = new Set(C), I = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
|
|
482
488
|
g.forEach((u) => {
|
|
483
|
-
c.has(u) ||
|
|
489
|
+
c.has(u) || I.add(u);
|
|
484
490
|
}), n.forEach((u) => {
|
|
485
491
|
m.has(u) || b.add(u);
|
|
486
|
-
}), n = C,
|
|
492
|
+
}), n = C, I.forEach((u) => {
|
|
487
493
|
this._threadCommentModel.getComment(e, t, u) || this._threadCommentModel.addComment(e, t, { id: u, threadId: u, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId: e, subUnitId: t });
|
|
488
|
-
}), this._threadCommentModel.syncThreadComments(e, t, [...
|
|
494
|
+
}), this._threadCommentModel.syncThreadComments(e, t, [...I]);
|
|
489
495
|
}
|
|
490
496
|
}
|
|
491
497
|
}));
|
|
492
498
|
}
|
|
493
499
|
};
|
|
494
|
-
Y =
|
|
495
|
-
y(1, _(
|
|
500
|
+
Y = It([
|
|
501
|
+
y(1, _(Ve)),
|
|
496
502
|
y(2, _(U)),
|
|
497
|
-
y(3, _(
|
|
498
|
-
y(4,
|
|
503
|
+
y(3, _(Le)),
|
|
504
|
+
y(4, A),
|
|
499
505
|
y(5, _(de)),
|
|
500
506
|
y(6, M)
|
|
501
507
|
], Y);
|
|
502
|
-
var
|
|
503
|
-
for (var i = n > 1 ? void 0 : n ?
|
|
508
|
+
var St = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Mt = (e, t, r) => t in e ? St(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, bt = (e, t, r, n) => {
|
|
509
|
+
for (var i = n > 1 ? void 0 : n ? Ot(t, r) : t, o = e.length - 1, s; o >= 0; o--)
|
|
504
510
|
(s = e[o]) && (i = s(i) || i);
|
|
505
511
|
return i;
|
|
506
|
-
}, J = (e, t) => (r, n) => t(r, n, e), Ie = (e, t, r) =>
|
|
507
|
-
let
|
|
512
|
+
}, J = (e, t) => (r, n) => t(r, n, e), Ie = (e, t, r) => Mt(e, typeof t != "symbol" ? t + "" : t, r);
|
|
513
|
+
let j = class extends Ue {
|
|
508
514
|
constructor(e = ee, t, r, n) {
|
|
509
515
|
super(), this._config = e, this._injector = t, this._renderManagerSrv = r, this._configService = n;
|
|
510
516
|
const { menu: i, ...o } = Re(
|
|
@@ -512,38 +518,38 @@ let $ = class extends Ue {
|
|
|
512
518
|
ee,
|
|
513
519
|
this._config
|
|
514
520
|
);
|
|
515
|
-
i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(
|
|
521
|
+
i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(it, o);
|
|
516
522
|
}
|
|
517
523
|
onStarting() {
|
|
518
524
|
[
|
|
525
|
+
[$],
|
|
519
526
|
[V],
|
|
520
|
-
[N],
|
|
521
527
|
[x]
|
|
522
528
|
].forEach((e) => {
|
|
523
529
|
this._injector.add(e);
|
|
524
530
|
});
|
|
525
531
|
}
|
|
526
532
|
onRendered() {
|
|
527
|
-
this._initRenderModule(), this._injector.get(
|
|
533
|
+
this._initRenderModule(), this._injector.get(V), this._injector.get($);
|
|
528
534
|
}
|
|
529
535
|
_initRenderModule() {
|
|
530
536
|
[Y].forEach((e) => {
|
|
531
|
-
this._renderManagerSrv.registerRenderModule(
|
|
537
|
+
this._renderManagerSrv.registerRenderModule(p.UNIVER_DOC, e);
|
|
532
538
|
});
|
|
533
539
|
}
|
|
534
540
|
};
|
|
535
|
-
Ie(
|
|
536
|
-
Ie(
|
|
537
|
-
|
|
538
|
-
xe(
|
|
541
|
+
Ie(j, "pluginName", rt);
|
|
542
|
+
Ie(j, "type", p.UNIVER_DOC);
|
|
543
|
+
j = bt([
|
|
544
|
+
xe(Ae),
|
|
539
545
|
J(1, _(re)),
|
|
540
546
|
J(2, F),
|
|
541
547
|
J(3, Te)
|
|
542
|
-
],
|
|
548
|
+
], j);
|
|
543
549
|
export {
|
|
544
550
|
he as AddDocCommentComment,
|
|
545
551
|
Ce as DeleteDocCommentComment,
|
|
546
552
|
w as ShowCommentPanelOperation,
|
|
547
553
|
W as StartAddCommentOperation,
|
|
548
|
-
|
|
554
|
+
j as UniverDocsThreadCommentUIPlugin
|
|
549
555
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITextRange, Nullable, Disposable } from '@univerjs/core';
|
|
2
2
|
import { IThreadComment } from '@univerjs/thread-comment';
|
|
3
3
|
import { ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
|
|
4
4
|
import { ISidebarService } from '@univerjs/ui';
|
package/lib/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","react"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverDocsThreadCommentUi={},c.UniverCore,c.UniverEngineRender,c.UniverThreadCommentUi,c.UniverDocs,c.UniverDocsUi,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.React))})(this,function(c,o,
|
|
2
|
-
`},startOffset:l.startOffset,endOffset:l.endOffset,collapsed:!0,threadId:y};return I==null||I.blur(),a.startAdd(j),t.setActiveComment({unitId:p,subUnitId:v,commentId:y}),!0}};var me=Object.getOwnPropertyDescriptor,le=(e,t,i,n)=>{for(var r=n>1?void 0:n?me(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},E=(e,t)=>(i,n)=>t(i,n,e);let B=class extends o.Disposable{constructor(e,t,i,n,r,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=i,this._docThreadCommentService=n,this._renderManagerService=r,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var i,n,r,s;if(t.id===T.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:C}=d;if(o.isInternalEditorID(a))return;const h=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),l=C[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&h){const{startOffset:I,endOffset:p,collapsed:g}=l;let m;if(g?m=(n=(i=h.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(v=>v.startIndex<=I&&v.endIndex>=p-1):m=(s=(r=h.getBody())==null?void 0:r.customDecorations)==null?void 0:s.find(v=>v.startIndex<=I&&v.endIndex>=p-1),m){const v=this._threadCommentModel.getComment(a,M,m.id);v&&!v.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:M,commentId:m.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,i,n,r;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(A.DocBackScrollRenderController),a=(n=(i=s.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((r=this._docThreadCommentService.addingComment)==null?void 0:r.id))&&this._docThreadCommentService.endAdd()}))}};B=le([E(0,o.Inject(O.ThreadCommentPanelService)),E(1,o.IUniverInstanceService),E(2,o.ICommandService),E(3,o.Inject(x)),E(4,_.IRenderManagerService),E(5,o.Inject(w.ThreadCommentModel))],B);var S=function(){return S=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)},ue=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},X=D.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,s=e.extend,d=ue(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),C=D.useRef("_".concat(fe()));return ee(i,"".concat(n),{defIds:i.defIds,idSuffix:C.current},S({ref:t,className:a},d),s)});function ee(e,t,i,n,r){return D.createElement(e.tag,S(S({key:t},ve(e,i,r)),n),(Ce(e,i).children||[]).map(function(s,d){return ee(s,"".concat(t,"-").concat(e.tag,"-").concat(d),i,void 0,r)}))}function ve(e,t,i){var n=S({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];d==="mask"&&typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ce(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?S(S({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?S(S({},r),{attrs:S(S({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function fe(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var he={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},te=D.forwardRef(function(e,t){return D.createElement(X,Object.assign({},e,{id:"comment-single",ref:t,icon:he}))});te.displayName="CommentSingle";const Ie={[u.RibbonStartGroup.OTHERS]:{[W.id]:{order:1,menuItemFactory:ce}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:ae}}}};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,i,n)=>{for(var r=n>1?void 0:n?ge(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},K=(e,t)=>(i,n)=>t(i,n,e);let q=class extends o.Disposable{constructor(e,t,i){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=i,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[H,L,N,V,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ie)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",te))}};q=Se([K(0,o.ICommandService),K(1,u.IMenuManagerService),K(2,o.Inject(u.ComponentManager))],q);var pe=Object.getOwnPropertyDescriptor,_e=(e,t,i,n)=>{for(var r=n>1?void 0:n?pe(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},P=(e,t)=>(i,n)=>t(i,n,e);let G=class extends o.Disposable{constructor(e,t,i,n,r,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=i,this._docRenderController=n,this._univerInstanceService=r,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var i;if(e){this._docRenderController.reRender(e.unitId);return}const t=(i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:i.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(T.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,i)=>{if(!e)return i(e);const{unitId:n,index:r,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:C}=d||{},h=s.find(g=>g.id===a),l=this._threadCommentModel.getComment(n,M,e.id);if(!l)return i({...e,show:!1});const I=h&&r>=h.startIndex&&r<=h.endIndex,p=C===n&&e.id===a;return i({...e,active:p||I,show:!l.resolved})}})}_initSyncComments(){var r,s,d;const e=this._context.unit.getUnitId(),t=M,i=(d=(s=(r=this._context.unit.getBody())==null?void 0:r.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];i.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,i);let n=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var C,h,l;if(a.id===T.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const p=(l=(h=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:h.filter(m=>m.type===o.CustomDecorationType.COMMENT).map(m=>m.id))!=null?l:[],g=p.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const m=new Set(n),v=new Set(g),y=new Set,j=new Set;p.forEach(f=>{m.has(f)||y.add(f)}),n.forEach(f=>{v.has(f)||j.add(f)}),n=g,y.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};G=_e([P(1,o.Inject(T.DocInterceptorService)),P(2,o.Inject(O.ThreadCommentPanelService)),P(3,o.Inject(A.DocRenderController)),P(4,o.IUniverInstanceService),P(5,o.Inject(w.ThreadCommentModel)),P(6,o.ICommandService)],G);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,De=(e,t,i)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Me=(e,t,i,n)=>{for(var r=n>1?void 0:n?Te(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Z=(e,t)=>(i,n)=>t(i,n,e),ne=(e,t,i)=>De(e,typeof t!="symbol"?t+"":t,i);c.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=J,i,n,r){super(),this._config=t,this._injector=i,this._renderManagerSrv=n,this._configService=r;const{menu:s,...d}=o.merge({},J,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(oe,d)}onStarting(){[[q],[B],[x]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},ne(c.UniverDocsThreadCommentUIPlugin,"pluginName",re),ne(c.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),c.UniverDocsThreadCommentUIPlugin=Me([o.DependentOn(O.UniverThreadCommentUIPlugin),Z(1,o.Inject(o.Injector)),Z(2,_.IRenderManagerService),Z(3,o.IConfigService)],c.UniverDocsThreadCommentUIPlugin),c.AddDocCommentComment=H,c.DeleteDocCommentComment=L,c.ShowCommentPanelOperation=N,c.StartAddCommentOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/thread-comment-ui"),require("@univerjs/docs"),require("@univerjs/docs-ui"),require("@univerjs/thread-comment"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/thread-comment-ui","@univerjs/docs","@univerjs/docs-ui","@univerjs/thread-comment","@univerjs/ui","rxjs","react/jsx-runtime","react"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverDocsThreadCommentUi={},c.UniverCore,c.UniverEngineRender,c.UniverThreadCommentUi,c.UniverDocs,c.UniverDocsUi,c.UniverThreadComment,c.UniverUi,c.rxjs,c.React,c.React))})(this,function(c,o,S,O,T,A,w,u,U,ie,D){"use strict";var be=Object.defineProperty;var Ue=(c,o,S)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:S}):c[o]=S;var k=(c,o,S)=>Ue(c,typeof o!="symbol"?o+"":o,S);const re="DOC_THREAD_COMMENT_UI_PLUGIN",M="default_doc",oe="docs-thread-comment-ui.config",J={};var se=Object.getOwnPropertyDescriptor,de=(e,t,i,n)=>{for(var r=n>1?void 0:n?se(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Y=(e,t)=>(i,n)=>t(i,n,e);let x=class extends o.Disposable{constructor(t,i){super();k(this,"_addingComment$",new U.BehaviorSubject(void 0));k(this,"addingComment$",this._addingComment$.asObservable());this._sidebarService=t,this._threadCommentPanelService=i,this.disposeWithMe(()=>{this._addingComment$.complete()})}get addingComment(){return this._addingComment$.getValue()}startAdd(t){this._addingComment$.next(t)}endAdd(){this._addingComment$.next(void 0)}};x=de([Y(0,u.ISidebarService),Y(1,o.Inject(O.ThreadCommentPanelService))],x);const H={id:"docs.command.add-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{comment:i,unitId:n}=t,s=await e.get(w.IThreadCommentDataSourceService).addComment(i),d=e.get(o.ICommandService),a=A.addCustomDecorationBySelectionFactory(e,{id:s.threadId,type:o.CustomDecorationType.COMMENT,unitId:n});if(a){const C={id:w.AddCommentMutation.id,params:{unitId:n,subUnitId:M,comment:s}},h={id:O.SetActiveCommentOperation.id,params:{unitId:n,subUnitId:M,commentId:s.id}};return(await o.sequenceExecute([C,a,h],d)).result}return!1}},L={id:"docs.command.delete-comment",type:o.CommandType.COMMAND,async handler(e,t){if(!t)return!1;const{commentId:i,unitId:n}=t,r=e.get(o.ICommandService),s=A.deleteCustomDecorationFactory(e,{id:i,unitId:n});return s?(await o.sequenceExecute([s],r)).result:!1}},Q=e=>{var d;const t=e.get(S.IRenderManagerService),i=e.get(T.DocSelectionManagerService),n=(d=S.withCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_DOC,T.DocSkeletonManagerService,e.get(o.IUniverInstanceService),t))==null?void 0:d.getSkeleton(),r=n==null?void 0:n.getViewModel().getEditArea();if(r===S.DocumentEditArea.FOOTER||r===S.DocumentEditArea.HEADER)return!0;const s=i.getActiveTextRange();return!!(s==null||s.collapsed)};function ae(e){return{id:V.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,void 0,o.SHEET_EDITOR_UNITS),disabled$:new U.Observable(function(t){const n=e.get(T.DocSelectionManagerService).textSelection$.pipe(U.debounceTime(16)).subscribe(()=>{t.next(Q(e))});return()=>{n.unsubscribe()}})}}function ce(e){return{id:W.id,type:u.MenuItemType.BUTTON,icon:"CommentSingle",title:"threadCommentUI.panel.addComment",tooltip:"threadCommentUI.panel.addComment",hidden$:u.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC)}}const R=()=>{const e=u.useDependency(o.IUniverInstanceService),t=u.useDependency(o.Injector),i=D.useMemo(()=>e.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_DOC).pipe(U.filter(m=>!!m&&!o.isInternalEditorID(m.getUnitId()))),[e]),n=u.useObservable(i),r=D.useMemo(()=>new U.Observable(m=>m.next(M)),[]),s=u.useDependency(T.DocSelectionManagerService),d=D.useMemo(()=>s.textSelection$.pipe(U.debounceTime(16)),[s.textSelection$]);u.useObservable(d);const a=u.useDependency(o.ICommandService),C=u.useDependency(x),h=u.useObservable(C.addingComment$),[l,I]=D.useState([]);if(D.useEffect(()=>{var j;const m=new Set,v=n==null?void 0:n.getCustomDecorations();I((j=v==null?void 0:v.map(f=>f.id).filter(f=>{const b=m.has(f);return m.add(f),!b}))!=null?j:[]);const y=a.onCommandExecuted(f=>{var b;if(f.id===T.RichTextEditingMutation.id){const $=new Set,z=n==null?void 0:n.getCustomDecorations();I((b=z==null?void 0:z.map(F=>F.id).filter(F=>{const ye=$.has(F);return $.add(F),!ye}))!=null?b:[])}});return()=>{y.dispose()}},[a,n]),!n)return null;const _=Q(t),g=n.getUnitId();return ie.jsx(O.ThreadCommentPanel,{unitId:g,subUnitId$:r,type:o.UniverInstanceType.UNIVER_DOC,onAdd:()=>{a.executeCommand(V.id)},getSubUnitName:()=>"",disableAdd:_,tempComment:h,onAddComment:m=>{if(!m.parentId){const v={unitId:g,range:h,comment:m};return a.executeCommand(H.id,v),C.endAdd(),!1}return!0},onDeleteComment:m=>{if(!m.parentId){const v={unitId:g,commentId:m.id};return a.executeCommand(L.id,v),!1}return!0},showComments:l})};R.componentKey="univer.doc.thread-comment-panel";const N={id:"docs.operation.show-comment-panel",type:o.CommandType.OPERATION,handler(e,t){var r;const i=e.get(O.ThreadCommentPanelService),n=e.get(u.ISidebarService);return(!i.panelVisible||((r=n.options.children)==null?void 0:r.label)!==R.componentKey)&&(n.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>i.setPanelVisible(!1)}),i.setPanelVisible(!0)),t&&i.setActiveComment(t==null?void 0:t.activeComment),!0}},W={id:"docs.operation.toggle-comment-panel",type:o.CommandType.OPERATION,handler(e){var n;const t=e.get(O.ThreadCommentPanelService),i=e.get(u.ISidebarService);return!t.panelVisible||((n=i.options.children)==null?void 0:n.label)!==R.componentKey?(i.open({header:{title:"threadCommentUI.panel.title"},children:{label:R.componentKey},width:320,onClose:()=>t.setPanelVisible(!1)}),t.setPanelVisible(!0)):(i.close(),t.setPanelVisible(!1),t.setActiveComment(null)),!0}},V={id:"docs.operation.start-add-comment",type:o.CommandType.OPERATION,handler(e){var f,b,$;const t=e.get(O.ThreadCommentPanelService),n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),r=e.get(T.DocSelectionManagerService),s=e.get(S.IRenderManagerService),d=e.get(o.UserManagerService),a=e.get(x),C=e.get(o.ICommandService),h=e.get(u.ISidebarService),l=r.getActiveTextRange();if(!n||!l)return!1;const I=(f=s.getRenderById(n.getUnitId()))==null?void 0:f.with(A.DocSelectionRenderService);if(I==null||I.setReserveRangesStatus(!0),l.collapsed)return t.panelVisible?(t.setPanelVisible(!1),h.close()):C.executeCommand(N.id),!0;C.executeCommand(N.id);const _=n.getUnitId(),g=(($=(b=n.getBody())==null?void 0:b.dataStream)!=null?$:"").slice(l.startOffset,l.endOffset),m=o.BuildTextUtils.transform.getPlainText(g),v=M,y="",j={unitId:_,subUnitId:v,id:y,ref:m,dT:w.getDT(),personId:d.getCurrentUser().userID,text:{dataStream:`\r
|
|
2
|
+
`},startOffset:l.startOffset,endOffset:l.endOffset,collapsed:!0,threadId:y};return I==null||I.blur(),a.startAdd(j),t.setActiveComment({unitId:_,subUnitId:v,commentId:y}),!0}};var me=Object.getOwnPropertyDescriptor,le=(e,t,i,n)=>{for(var r=n>1?void 0:n?me(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},E=(e,t)=>(i,n)=>t(i,n,e);let B=class extends o.Disposable{constructor(e,t,i,n,r,s){super(),this._threadCommentPanelService=e,this._univerInstanceService=t,this._commandService=i,this._docThreadCommentService=n,this._renderManagerService=r,this._threadCommentModel=s,this._initSelectionChange(),this._initActiveCommandChange()}_initSelectionChange(){let e;this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var i,n,r,s;if(t.id===T.SetTextSelectionsOperation.id){const d=t.params,{unitId:a,ranges:C}=d;if(o.isInternalEditorID(a))return;const h=this._univerInstanceService.getUnit(a,o.UniverInstanceType.UNIVER_DOC),l=C[0];if((e==null?void 0:e.startOffset)===(l==null?void 0:l.startOffset)&&(e==null?void 0:e.endOffset)===(l==null?void 0:l.endOffset))return;if(e=l,l&&h){const{startOffset:I,endOffset:_,collapsed:g}=l;let m;if(g?m=(n=(i=h.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(v=>v.startIndex<=I&&v.endIndex>=_-1):m=(s=(r=h.getBody())==null?void 0:r.customDecorations)==null?void 0:s.find(v=>v.startIndex<=I&&v.endIndex>=_-1),m){const v=this._threadCommentModel.getComment(a,M,m.id);v&&!v.resolved&&this._commandService.executeCommand(N.id,{activeComment:{unitId:a,subUnitId:M,commentId:m.id}});return}}if(!this._threadCommentPanelService.activeCommentId)return;this._commandService.executeCommand(O.SetActiveCommentOperation.id)}}))}_initActiveCommandChange(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var t,i,n,r;if(e){const s=this._univerInstanceService.getUnit(e.unitId);if(s){const d=(t=this._renderManagerService.getRenderById(e.unitId))==null?void 0:t.with(A.DocBackScrollRenderController),a=(n=(i=s.getBody())==null?void 0:i.customDecorations)==null?void 0:n.find(C=>C.id===e.commentId);a&&d&&d.scrollToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1})}}(!e||e.commentId!==((r=this._docThreadCommentService.addingComment)==null?void 0:r.id))&&this._docThreadCommentService.endAdd()}))}};B=le([E(0,o.Inject(O.ThreadCommentPanelService)),E(1,o.IUniverInstanceService),E(2,o.ICommandService),E(3,o.Inject(x)),E(4,S.IRenderManagerService),E(5,o.Inject(w.ThreadCommentModel))],B);var p=function(){return p=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},p.apply(this,arguments)},ue=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(i[n[r]]=e[n[r]]);return i},X=D.forwardRef(function(e,t){var i=e.icon,n=e.id,r=e.className,s=e.extend,d=ue(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),C=D.useRef("_".concat(fe()));return ee(i,"".concat(n),{defIds:i.defIds,idSuffix:C.current},p({ref:t,className:a},d),s)});function ee(e,t,i,n,r){return D.createElement(e.tag,p(p({key:t},ve(e,i,r)),n),(Ce(e,i).children||[]).map(function(s,d){return ee(s,"".concat(t,"-").concat(e.tag,"-").concat(d),i,void 0,r)}))}function ve(e,t,i){var n=p({},e.attrs);i!=null&&i.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=i.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];d==="mask"&&typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var d=s[0],a=s[1];typeof a=="string"&&(n[d]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ce(e,t){var i,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((i=e.children)===null||i===void 0)&&i.length)?p(p({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?p(p({},r),{attrs:p(p({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function fe(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var he={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z",fillRule:"evenodd",clipRule:"evenodd"}}]},te=D.forwardRef(function(e,t){return D.createElement(X,Object.assign({},e,{id:"comment-single",ref:t,icon:he}))});te.displayName="CommentSingle";const Ie={[u.RibbonStartGroup.OTHERS]:{[W.id]:{order:1,menuItemFactory:ce}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[V.id]:{order:1,menuItemFactory:ae}}}};var ge=Object.getOwnPropertyDescriptor,Se=(e,t,i,n)=>{for(var r=n>1?void 0:n?ge(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},K=(e,t)=>(i,n)=>t(i,n,e);let q=class extends o.Disposable{constructor(e,t,i){super(),this._commandService=e,this._menuManagerService=t,this._componentManager=i,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[H,L,N,V,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenus(){this._menuManagerService.mergeMenu(Ie)}_initComponents(){[R].forEach(e=>{this.disposeWithMe(this._componentManager.register(e.componentKey,e))}),this.disposeWithMe(this._componentManager.register("CommentSingle",te))}};q=Se([K(0,o.ICommandService),K(1,u.IMenuManagerService),K(2,o.Inject(u.ComponentManager))],q);var pe=Object.getOwnPropertyDescriptor,_e=(e,t,i,n)=>{for(var r=n>1?void 0:n?pe(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},P=(e,t)=>(i,n)=>t(i,n,e);let G=class extends o.Disposable{constructor(e,t,i,n,r,s,d){super(),this._context=e,this._docInterceptorService=t,this._threadCommentPanelService=i,this._docRenderController=n,this._univerInstanceService=r,this._threadCommentModel=s,this._commandService=d,this._interceptorViewModel(),this._initReRender(),this._initSyncComments()}_initReRender(){this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(e=>{var i;if(e){this._docRenderController.reRender(e.unitId);return}const t=(i=this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC))==null?void 0:i.getUnitId();t&&this._docRenderController.reRender(t)})),this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{e.type==="resolve"&&this._docRenderController.reRender(e.unitId)}))}_interceptorViewModel(){this._docInterceptorService.intercept(T.DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION,{handler:(e,t,i)=>{if(!e)return i(e);const{unitId:n,index:r,customDecorations:s}=t,d=this._threadCommentPanelService.activeCommentId,{commentId:a,unitId:C}=d||{},h=s.find(g=>g.id===a),l=this._threadCommentModel.getComment(n,M,e.id);if(!l)return i({...e,show:!1});const I=h&&r>=h.startIndex&&r<=h.endIndex,_=C===n&&e.id===a;return i({...e,active:_||I,show:!l.resolved})}})}_initSyncComments(){var r,s,d;const e=this._context.unit.getUnitId(),t=M,i=(d=(s=(r=this._context.unit.getBody())==null?void 0:r.customDecorations)==null?void 0:s.filter(a=>a.type===o.CustomDecorationType.COMMENT).map(a=>a.id))!=null?d:[];i.forEach(a=>{this._threadCommentModel.getComment(e,t,a)||this._threadCommentModel.addComment(e,t,{id:a,threadId:a,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),i.length&&this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(),M,i);let n=i.sort();this.disposeWithMe(this._commandService.onCommandExecuted(a=>{var C,h,l;if(a.id===T.RichTextEditingMutation.id){if(a.params.unitId!==this._context.unit.getUnitId())return;const _=(l=(h=(C=this._context.unit.getBody())==null?void 0:C.customDecorations)==null?void 0:h.filter(m=>m.type===o.CustomDecorationType.COMMENT).map(m=>m.id))!=null?l:[],g=_.sort();if(JSON.stringify(n)!==JSON.stringify(g)){const m=new Set(n),v=new Set(g),y=new Set,j=new Set;_.forEach(f=>{m.has(f)||y.add(f)}),n.forEach(f=>{v.has(f)||j.add(f)}),n=g,y.forEach(f=>{this._threadCommentModel.getComment(e,t,f)||this._threadCommentModel.addComment(e,t,{id:f,threadId:f,ref:"",dT:"",personId:"",text:{dataStream:""},unitId:e,subUnitId:t})}),this._threadCommentModel.syncThreadComments(e,t,[...y])}}}))}};G=_e([P(1,o.Inject(T.DocInterceptorService)),P(2,o.Inject(O.ThreadCommentPanelService)),P(3,o.Inject(A.DocRenderController)),P(4,o.IUniverInstanceService),P(5,o.Inject(w.ThreadCommentModel)),P(6,o.ICommandService)],G);var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,De=(e,t,i)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Me=(e,t,i,n)=>{for(var r=n>1?void 0:n?Te(t,i):t,s=e.length-1,d;s>=0;s--)(d=e[s])&&(r=d(r)||r);return r},Z=(e,t)=>(i,n)=>t(i,n,e),ne=(e,t,i)=>De(e,typeof t!="symbol"?t+"":t,i);c.UniverDocsThreadCommentUIPlugin=class extends o.Plugin{constructor(t=J,i,n,r){super(),this._config=t,this._injector=i,this._renderManagerSrv=n,this._configService=r;const{menu:s,...d}=o.merge({},J,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(oe,d)}onStarting(){[[q],[B],[x]].forEach(t=>{this._injector.add(t)})}onRendered(){this._initRenderModule(),this._injector.get(B),this._injector.get(q)}_initRenderModule(){[G].forEach(t=>{this._renderManagerSrv.registerRenderModule(o.UniverInstanceType.UNIVER_DOC,t)})}},ne(c.UniverDocsThreadCommentUIPlugin,"pluginName",re),ne(c.UniverDocsThreadCommentUIPlugin,"type",o.UniverInstanceType.UNIVER_DOC),c.UniverDocsThreadCommentUIPlugin=Me([o.DependentOn(O.UniverThreadCommentUIPlugin),Z(1,o.Inject(o.Injector)),Z(2,S.IRenderManagerService),Z(3,o.IConfigService)],c.UniverDocsThreadCommentUIPlugin),c.AddDocCommentComment=H,c.DeleteDocCommentComment=L,c.ShowCommentPanelOperation=N,c.StartAddCommentOperation=V,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/docs-thread-comment-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer thread comment plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,14 +48,13 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@univerjs/icons": "^0.2.20",
|
|
51
|
-
"
|
|
52
|
-
"@univerjs/
|
|
53
|
-
"@univerjs/
|
|
54
|
-
"@univerjs/
|
|
55
|
-
"@univerjs/
|
|
56
|
-
"@univerjs/thread-comment-ui": "0.6.
|
|
57
|
-
"@univerjs/ui": "0.6.
|
|
58
|
-
"@univerjs/thread-comment": "0.6.1-nightly.202502261607"
|
|
51
|
+
"@univerjs/core": "0.6.2",
|
|
52
|
+
"@univerjs/docs": "0.6.2",
|
|
53
|
+
"@univerjs/thread-comment": "0.6.2",
|
|
54
|
+
"@univerjs/engine-render": "0.6.2",
|
|
55
|
+
"@univerjs/docs-ui": "0.6.2",
|
|
56
|
+
"@univerjs/thread-comment-ui": "0.6.2",
|
|
57
|
+
"@univerjs/ui": "0.6.2"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
61
60
|
"postcss": "^8.5.3",
|
|
@@ -65,7 +64,7 @@
|
|
|
65
64
|
"typescript": "^5.7.3",
|
|
66
65
|
"vite": "^6.2.0",
|
|
67
66
|
"vitest": "^3.0.7",
|
|
68
|
-
"@univerjs-infra/shared": "0.6.
|
|
67
|
+
"@univerjs-infra/shared": "0.6.2"
|
|
69
68
|
},
|
|
70
69
|
"scripts": {
|
|
71
70
|
"test": "vitest run",
|