@univerjs/sheets-thread-comment 0.25.0-insiders.20260623-012b5a8 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/lib/cjs/facade.js +33 -30
- package/lib/cjs/index.js +7 -7
- package/lib/es/facade.js +33 -30
- package/lib/es/index.js +7 -7
- package/lib/facade.js +33 -30
- package/lib/index.js +7 -7
- package/lib/types/facade/f-univer.d.ts +1 -0
- package/lib/types/facade/f-workbook.d.ts +5 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/lib/cjs/facade.js
CHANGED
|
@@ -7,7 +7,7 @@ let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
|
7
7
|
let rxjs = require("rxjs");
|
|
8
8
|
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
9
9
|
|
|
10
|
-
//#region \0@oxc-project+runtime@0.
|
|
10
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
11
11
|
function _typeof(o) {
|
|
12
12
|
"@babel/helpers - typeof";
|
|
13
13
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -18,7 +18,7 @@ function _typeof(o) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
|
-
//#region \0@oxc-project+runtime@0.
|
|
21
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
22
22
|
function toPrimitive(t, r) {
|
|
23
23
|
if ("object" != _typeof(t) || !t) return t;
|
|
24
24
|
var e = t[Symbol.toPrimitive];
|
|
@@ -31,14 +31,14 @@ function toPrimitive(t, r) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region \0@oxc-project+runtime@0.
|
|
34
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
35
35
|
function toPropertyKey(t) {
|
|
36
36
|
var i = toPrimitive(t, "string");
|
|
37
37
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
42
42
|
function _defineProperty(e, r, t) {
|
|
43
43
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
44
44
|
value: t,
|
|
@@ -49,7 +49,7 @@ function _defineProperty(e, r, t) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
53
53
|
function __decorateParam(paramIndex, decorator) {
|
|
54
54
|
return function(target, key) {
|
|
55
55
|
decorator(target, key, paramIndex);
|
|
@@ -57,7 +57,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
61
61
|
function __decorate(decorators, target, key, desc) {
|
|
62
62
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
63
63
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -858,16 +858,26 @@ _univerjs_core_facade.FEventName.extend(FSheetsThreadCommentEventNameMixin);
|
|
|
858
858
|
* @ignore
|
|
859
859
|
*/
|
|
860
860
|
var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUniver {
|
|
861
|
+
_getTargetSheet(params = {}) {
|
|
862
|
+
var _this$getActiveWorkbo;
|
|
863
|
+
const workbook = params.unitId ? this.getUniverSheet(params.unitId) : (_this$getActiveWorkbo = this.getActiveWorkbook) === null || _this$getActiveWorkbo === void 0 ? void 0 : _this$getActiveWorkbo.call(this);
|
|
864
|
+
if (!workbook) return null;
|
|
865
|
+
const worksheet = params.subUnitId ? workbook.getSheetBySheetId(params.subUnitId) : workbook.getActiveSheet();
|
|
866
|
+
if (!worksheet) return null;
|
|
867
|
+
return {
|
|
868
|
+
workbook,
|
|
869
|
+
worksheet
|
|
870
|
+
};
|
|
871
|
+
}
|
|
861
872
|
_initialize(injector) {
|
|
862
873
|
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
863
874
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded, () => commandService.onCommandExecuted((commandInfo) => {
|
|
864
875
|
var _threadComment$getRan, _threadComment$getRan2, _threadComment$getRan3, _threadComment$getRan4;
|
|
865
876
|
if (commandInfo.id !== _univerjs_thread_comment.AddCommentCommand.id) return;
|
|
866
|
-
const
|
|
867
|
-
const target = this.getSheetCommandTarget(params);
|
|
877
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
868
878
|
if (!target) return;
|
|
869
879
|
const { workbook, worksheet } = target;
|
|
870
|
-
const { comment } = params;
|
|
880
|
+
const { comment } = commandInfo.params;
|
|
871
881
|
const threadComment = worksheet.getCommentById(comment.id);
|
|
872
882
|
if (!threadComment) return;
|
|
873
883
|
const eventParams = {
|
|
@@ -882,11 +892,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
882
892
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated, () => commandService.onCommandExecuted((commandInfo) => {
|
|
883
893
|
var _threadComment$getRan5, _threadComment$getRan6, _threadComment$getRan7, _threadComment$getRan8;
|
|
884
894
|
if (commandInfo.id !== _univerjs_thread_comment.UpdateCommentCommand.id) return;
|
|
885
|
-
const
|
|
886
|
-
const target = this.getSheetCommandTarget(params);
|
|
895
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
887
896
|
if (!target) return;
|
|
888
897
|
const { workbook, worksheet } = target;
|
|
889
|
-
const { payload } = params;
|
|
898
|
+
const { payload } = commandInfo.params;
|
|
890
899
|
const threadComment = worksheet.getCommentById(payload.commentId);
|
|
891
900
|
if (!threadComment) return;
|
|
892
901
|
const eventParams = {
|
|
@@ -900,11 +909,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
900
909
|
})));
|
|
901
910
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted, () => commandService.onCommandExecuted((commandInfo) => {
|
|
902
911
|
if (commandInfo.id !== _univerjs_thread_comment.DeleteCommentCommand.id && commandInfo.id !== _univerjs_thread_comment.DeleteCommentTreeCommand.id) return;
|
|
903
|
-
const
|
|
904
|
-
const target = this.getSheetCommandTarget(params);
|
|
912
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
905
913
|
if (!target) return;
|
|
906
914
|
const { workbook, worksheet } = target;
|
|
907
|
-
const { commentId } = params;
|
|
915
|
+
const { commentId } = commandInfo.params;
|
|
908
916
|
const eventParams = {
|
|
909
917
|
workbook,
|
|
910
918
|
worksheet,
|
|
@@ -915,11 +923,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
915
923
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved, () => commandService.onCommandExecuted((commandInfo) => {
|
|
916
924
|
var _threadComment$getRan9, _threadComment$getRan10, _threadComment$getRan11, _threadComment$getRan12;
|
|
917
925
|
if (commandInfo.id !== _univerjs_thread_comment.ResolveCommentCommand.id) return;
|
|
918
|
-
const
|
|
919
|
-
const target = this.getSheetCommandTarget(params);
|
|
926
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
920
927
|
if (!target) return;
|
|
921
928
|
const { workbook, worksheet } = target;
|
|
922
|
-
const { commentId, resolved } = params;
|
|
929
|
+
const { commentId, resolved } = commandInfo.params;
|
|
923
930
|
const threadComment = worksheet.getCommentById(commentId);
|
|
924
931
|
if (!threadComment) return;
|
|
925
932
|
const eventParams = {
|
|
@@ -934,11 +941,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
934
941
|
})));
|
|
935
942
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
936
943
|
if (commandInfo.id !== _univerjs_thread_comment.AddCommentCommand.id) return;
|
|
937
|
-
const
|
|
938
|
-
const target = this.getSheetCommandTarget(params);
|
|
944
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
939
945
|
if (!target) return;
|
|
940
946
|
const { workbook, worksheet } = target;
|
|
941
|
-
const { comment } = params;
|
|
947
|
+
const { comment } = commandInfo.params;
|
|
942
948
|
const { range } = (0, _univerjs_engine_formula.deserializeRangeWithSheet)(comment.ref);
|
|
943
949
|
const eventParams = {
|
|
944
950
|
workbook,
|
|
@@ -953,11 +959,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
953
959
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
954
960
|
var _threadComment$getRan13, _threadComment$getRan14, _threadComment$getRan15, _threadComment$getRan16;
|
|
955
961
|
if (commandInfo.id !== _univerjs_thread_comment.UpdateCommentCommand.id) return;
|
|
956
|
-
const
|
|
957
|
-
const target = this.getSheetCommandTarget(params);
|
|
962
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
958
963
|
if (!target) return;
|
|
959
964
|
const { workbook, worksheet } = target;
|
|
960
|
-
const { payload } = params;
|
|
965
|
+
const { payload } = commandInfo.params;
|
|
961
966
|
const threadComment = worksheet.getCommentById(payload.commentId);
|
|
962
967
|
if (!threadComment) return;
|
|
963
968
|
const eventParams = {
|
|
@@ -974,11 +979,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
974
979
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
975
980
|
var _threadComment$getRan17, _threadComment$getRan18, _threadComment$getRan19, _threadComment$getRan20;
|
|
976
981
|
if (commandInfo.id !== _univerjs_thread_comment.DeleteCommentCommand.id && commandInfo.id !== _univerjs_thread_comment.DeleteCommentTreeCommand.id) return;
|
|
977
|
-
const
|
|
978
|
-
const target = this.getSheetCommandTarget(params);
|
|
982
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
979
983
|
if (!target) return;
|
|
980
984
|
const { workbook, worksheet } = target;
|
|
981
|
-
const { commentId } = params;
|
|
985
|
+
const { commentId } = commandInfo.params;
|
|
982
986
|
const threadComment = worksheet.getCommentById(commentId);
|
|
983
987
|
if (!threadComment) return;
|
|
984
988
|
const eventParams = {
|
|
@@ -994,11 +998,10 @@ var FUniverSheetsThreadCommentMixin = class extends _univerjs_core_facade.FUnive
|
|
|
994
998
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
995
999
|
var _getRow, _getColumn;
|
|
996
1000
|
if (commandInfo.id !== _univerjs_thread_comment.ResolveCommentCommand.id) return;
|
|
997
|
-
const
|
|
998
|
-
const target = this.getSheetCommandTarget(params);
|
|
1001
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
999
1002
|
if (!target) return;
|
|
1000
1003
|
const { workbook, worksheet } = target;
|
|
1001
|
-
const { commentId, resolved } = params;
|
|
1004
|
+
const { commentId, resolved } = commandInfo.params;
|
|
1002
1005
|
const threadComment = worksheet.getCommentById(commentId);
|
|
1003
1006
|
if (!threadComment) return;
|
|
1004
1007
|
const eventParams = {
|
package/lib/cjs/index.js
CHANGED
|
@@ -5,7 +5,7 @@ let _univerjs_sheets = require("@univerjs/sheets");
|
|
|
5
5
|
let _univerjs_thread_comment = require("@univerjs/thread-comment");
|
|
6
6
|
let rxjs = require("rxjs");
|
|
7
7
|
|
|
8
|
-
//#region \0@oxc-project+runtime@0.
|
|
8
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
9
9
|
function _typeof(o) {
|
|
10
10
|
"@babel/helpers - typeof";
|
|
11
11
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -16,7 +16,7 @@ function _typeof(o) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
|
-
//#region \0@oxc-project+runtime@0.
|
|
19
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
20
20
|
function toPrimitive(t, r) {
|
|
21
21
|
if ("object" != _typeof(t) || !t) return t;
|
|
22
22
|
var e = t[Symbol.toPrimitive];
|
|
@@ -29,14 +29,14 @@ function toPrimitive(t, r) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
|
-
//#region \0@oxc-project+runtime@0.
|
|
32
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
33
33
|
function toPropertyKey(t) {
|
|
34
34
|
var i = toPrimitive(t, "string");
|
|
35
35
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
|
-
//#region \0@oxc-project+runtime@0.
|
|
39
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
40
40
|
function _defineProperty(e, r, t) {
|
|
41
41
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
42
|
value: t,
|
|
@@ -47,7 +47,7 @@ function _defineProperty(e, r, t) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region \0@oxc-project+runtime@0.
|
|
50
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
51
51
|
function __decorateParam(paramIndex, decorator) {
|
|
52
52
|
return function(target, key) {
|
|
53
53
|
decorator(target, key, paramIndex);
|
|
@@ -55,7 +55,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
59
59
|
function __decorate(decorators, target, key, desc) {
|
|
60
60
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
61
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -450,7 +450,7 @@ SheetsThreadCommentRefRangeController = __decorate([
|
|
|
450
450
|
//#endregion
|
|
451
451
|
//#region package.json
|
|
452
452
|
var name = "@univerjs/sheets-thread-comment";
|
|
453
|
-
var version = "0.25.
|
|
453
|
+
var version = "0.25.1";
|
|
454
454
|
|
|
455
455
|
//#endregion
|
|
456
456
|
//#region src/config/config.ts
|
package/lib/es/facade.js
CHANGED
|
@@ -6,7 +6,7 @@ import { deserializeRangeWithSheet } from "@univerjs/engine-formula";
|
|
|
6
6
|
import { filter } from "rxjs";
|
|
7
7
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
8
8
|
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
10
10
|
function _typeof(o) {
|
|
11
11
|
"@babel/helpers - typeof";
|
|
12
12
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -17,7 +17,7 @@ function _typeof(o) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
20
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
21
21
|
function toPrimitive(t, r) {
|
|
22
22
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
23
|
var e = t[Symbol.toPrimitive];
|
|
@@ -30,14 +30,14 @@ function toPrimitive(t, r) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
|
-
//#region \0@oxc-project+runtime@0.
|
|
33
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
34
34
|
function toPropertyKey(t) {
|
|
35
35
|
var i = toPrimitive(t, "string");
|
|
36
36
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region \0@oxc-project+runtime@0.
|
|
40
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
41
41
|
function _defineProperty(e, r, t) {
|
|
42
42
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
43
|
value: t,
|
|
@@ -48,7 +48,7 @@ function _defineProperty(e, r, t) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region \0@oxc-project+runtime@0.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
52
52
|
function __decorateParam(paramIndex, decorator) {
|
|
53
53
|
return function(target, key) {
|
|
54
54
|
decorator(target, key, paramIndex);
|
|
@@ -56,7 +56,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
60
60
|
function __decorate(decorators, target, key, desc) {
|
|
61
61
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
62
62
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -857,16 +857,26 @@ FEventName.extend(FSheetsThreadCommentEventNameMixin);
|
|
|
857
857
|
* @ignore
|
|
858
858
|
*/
|
|
859
859
|
var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
860
|
+
_getTargetSheet(params = {}) {
|
|
861
|
+
var _this$getActiveWorkbo;
|
|
862
|
+
const workbook = params.unitId ? this.getUniverSheet(params.unitId) : (_this$getActiveWorkbo = this.getActiveWorkbook) === null || _this$getActiveWorkbo === void 0 ? void 0 : _this$getActiveWorkbo.call(this);
|
|
863
|
+
if (!workbook) return null;
|
|
864
|
+
const worksheet = params.subUnitId ? workbook.getSheetBySheetId(params.subUnitId) : workbook.getActiveSheet();
|
|
865
|
+
if (!worksheet) return null;
|
|
866
|
+
return {
|
|
867
|
+
workbook,
|
|
868
|
+
worksheet
|
|
869
|
+
};
|
|
870
|
+
}
|
|
860
871
|
_initialize(injector) {
|
|
861
872
|
const commandService = injector.get(ICommandService);
|
|
862
873
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded, () => commandService.onCommandExecuted((commandInfo) => {
|
|
863
874
|
var _threadComment$getRan, _threadComment$getRan2, _threadComment$getRan3, _threadComment$getRan4;
|
|
864
875
|
if (commandInfo.id !== AddCommentCommand.id) return;
|
|
865
|
-
const
|
|
866
|
-
const target = this.getSheetCommandTarget(params);
|
|
876
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
867
877
|
if (!target) return;
|
|
868
878
|
const { workbook, worksheet } = target;
|
|
869
|
-
const { comment } = params;
|
|
879
|
+
const { comment } = commandInfo.params;
|
|
870
880
|
const threadComment = worksheet.getCommentById(comment.id);
|
|
871
881
|
if (!threadComment) return;
|
|
872
882
|
const eventParams = {
|
|
@@ -881,11 +891,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
881
891
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated, () => commandService.onCommandExecuted((commandInfo) => {
|
|
882
892
|
var _threadComment$getRan5, _threadComment$getRan6, _threadComment$getRan7, _threadComment$getRan8;
|
|
883
893
|
if (commandInfo.id !== UpdateCommentCommand.id) return;
|
|
884
|
-
const
|
|
885
|
-
const target = this.getSheetCommandTarget(params);
|
|
894
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
886
895
|
if (!target) return;
|
|
887
896
|
const { workbook, worksheet } = target;
|
|
888
|
-
const { payload } = params;
|
|
897
|
+
const { payload } = commandInfo.params;
|
|
889
898
|
const threadComment = worksheet.getCommentById(payload.commentId);
|
|
890
899
|
if (!threadComment) return;
|
|
891
900
|
const eventParams = {
|
|
@@ -899,11 +908,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
899
908
|
})));
|
|
900
909
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted, () => commandService.onCommandExecuted((commandInfo) => {
|
|
901
910
|
if (commandInfo.id !== DeleteCommentCommand.id && commandInfo.id !== DeleteCommentTreeCommand.id) return;
|
|
902
|
-
const
|
|
903
|
-
const target = this.getSheetCommandTarget(params);
|
|
911
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
904
912
|
if (!target) return;
|
|
905
913
|
const { workbook, worksheet } = target;
|
|
906
|
-
const { commentId } = params;
|
|
914
|
+
const { commentId } = commandInfo.params;
|
|
907
915
|
const eventParams = {
|
|
908
916
|
workbook,
|
|
909
917
|
worksheet,
|
|
@@ -914,11 +922,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
914
922
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved, () => commandService.onCommandExecuted((commandInfo) => {
|
|
915
923
|
var _threadComment$getRan9, _threadComment$getRan10, _threadComment$getRan11, _threadComment$getRan12;
|
|
916
924
|
if (commandInfo.id !== ResolveCommentCommand.id) return;
|
|
917
|
-
const
|
|
918
|
-
const target = this.getSheetCommandTarget(params);
|
|
925
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
919
926
|
if (!target) return;
|
|
920
927
|
const { workbook, worksheet } = target;
|
|
921
|
-
const { commentId, resolved } = params;
|
|
928
|
+
const { commentId, resolved } = commandInfo.params;
|
|
922
929
|
const threadComment = worksheet.getCommentById(commentId);
|
|
923
930
|
if (!threadComment) return;
|
|
924
931
|
const eventParams = {
|
|
@@ -933,11 +940,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
933
940
|
})));
|
|
934
941
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
935
942
|
if (commandInfo.id !== AddCommentCommand.id) return;
|
|
936
|
-
const
|
|
937
|
-
const target = this.getSheetCommandTarget(params);
|
|
943
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
938
944
|
if (!target) return;
|
|
939
945
|
const { workbook, worksheet } = target;
|
|
940
|
-
const { comment } = params;
|
|
946
|
+
const { comment } = commandInfo.params;
|
|
941
947
|
const { range } = deserializeRangeWithSheet(comment.ref);
|
|
942
948
|
const eventParams = {
|
|
943
949
|
workbook,
|
|
@@ -952,11 +958,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
952
958
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
953
959
|
var _threadComment$getRan13, _threadComment$getRan14, _threadComment$getRan15, _threadComment$getRan16;
|
|
954
960
|
if (commandInfo.id !== UpdateCommentCommand.id) return;
|
|
955
|
-
const
|
|
956
|
-
const target = this.getSheetCommandTarget(params);
|
|
961
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
957
962
|
if (!target) return;
|
|
958
963
|
const { workbook, worksheet } = target;
|
|
959
|
-
const { payload } = params;
|
|
964
|
+
const { payload } = commandInfo.params;
|
|
960
965
|
const threadComment = worksheet.getCommentById(payload.commentId);
|
|
961
966
|
if (!threadComment) return;
|
|
962
967
|
const eventParams = {
|
|
@@ -973,11 +978,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
973
978
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
974
979
|
var _threadComment$getRan17, _threadComment$getRan18, _threadComment$getRan19, _threadComment$getRan20;
|
|
975
980
|
if (commandInfo.id !== DeleteCommentCommand.id && commandInfo.id !== DeleteCommentTreeCommand.id) return;
|
|
976
|
-
const
|
|
977
|
-
const target = this.getSheetCommandTarget(params);
|
|
981
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
978
982
|
if (!target) return;
|
|
979
983
|
const { workbook, worksheet } = target;
|
|
980
|
-
const { commentId } = params;
|
|
984
|
+
const { commentId } = commandInfo.params;
|
|
981
985
|
const threadComment = worksheet.getCommentById(commentId);
|
|
982
986
|
if (!threadComment) return;
|
|
983
987
|
const eventParams = {
|
|
@@ -993,11 +997,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
993
997
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
994
998
|
var _getRow, _getColumn;
|
|
995
999
|
if (commandInfo.id !== ResolveCommentCommand.id) return;
|
|
996
|
-
const
|
|
997
|
-
const target = this.getSheetCommandTarget(params);
|
|
1000
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
998
1001
|
if (!target) return;
|
|
999
1002
|
const { workbook, worksheet } = target;
|
|
1000
|
-
const { commentId, resolved } = params;
|
|
1003
|
+
const { commentId, resolved } = commandInfo.params;
|
|
1001
1004
|
const threadComment = worksheet.getCommentById(commentId);
|
|
1002
1005
|
if (!threadComment) return;
|
|
1003
1006
|
const eventParams = {
|
package/lib/es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptor
|
|
|
4
4
|
import { AddCommentMutation, DeleteCommentMutation, IThreadCommentDataSourceService, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentRefMutation } from "@univerjs/thread-comment";
|
|
5
5
|
import { Subject } from "rxjs";
|
|
6
6
|
|
|
7
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -449,7 +449,7 @@ SheetsThreadCommentRefRangeController = __decorate([
|
|
|
449
449
|
//#endregion
|
|
450
450
|
//#region package.json
|
|
451
451
|
var name = "@univerjs/sheets-thread-comment";
|
|
452
|
-
var version = "0.25.
|
|
452
|
+
var version = "0.25.1";
|
|
453
453
|
|
|
454
454
|
//#endregion
|
|
455
455
|
//#region src/config/config.ts
|
package/lib/facade.js
CHANGED
|
@@ -6,7 +6,7 @@ import { deserializeRangeWithSheet } from "@univerjs/engine-formula";
|
|
|
6
6
|
import { filter } from "rxjs";
|
|
7
7
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
8
8
|
|
|
9
|
-
//#region \0@oxc-project+runtime@0.
|
|
9
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
10
10
|
function _typeof(o) {
|
|
11
11
|
"@babel/helpers - typeof";
|
|
12
12
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -17,7 +17,7 @@ function _typeof(o) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region \0@oxc-project+runtime@0.
|
|
20
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
21
21
|
function toPrimitive(t, r) {
|
|
22
22
|
if ("object" != _typeof(t) || !t) return t;
|
|
23
23
|
var e = t[Symbol.toPrimitive];
|
|
@@ -30,14 +30,14 @@ function toPrimitive(t, r) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
|
-
//#region \0@oxc-project+runtime@0.
|
|
33
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
34
34
|
function toPropertyKey(t) {
|
|
35
35
|
var i = toPrimitive(t, "string");
|
|
36
36
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region \0@oxc-project+runtime@0.
|
|
40
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
41
41
|
function _defineProperty(e, r, t) {
|
|
42
42
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
43
43
|
value: t,
|
|
@@ -48,7 +48,7 @@ function _defineProperty(e, r, t) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region \0@oxc-project+runtime@0.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
52
52
|
function __decorateParam(paramIndex, decorator) {
|
|
53
53
|
return function(target, key) {
|
|
54
54
|
decorator(target, key, paramIndex);
|
|
@@ -56,7 +56,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
60
60
|
function __decorate(decorators, target, key, desc) {
|
|
61
61
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
62
62
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -857,16 +857,26 @@ FEventName.extend(FSheetsThreadCommentEventNameMixin);
|
|
|
857
857
|
* @ignore
|
|
858
858
|
*/
|
|
859
859
|
var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
860
|
+
_getTargetSheet(params = {}) {
|
|
861
|
+
var _this$getActiveWorkbo;
|
|
862
|
+
const workbook = params.unitId ? this.getUniverSheet(params.unitId) : (_this$getActiveWorkbo = this.getActiveWorkbook) === null || _this$getActiveWorkbo === void 0 ? void 0 : _this$getActiveWorkbo.call(this);
|
|
863
|
+
if (!workbook) return null;
|
|
864
|
+
const worksheet = params.subUnitId ? workbook.getSheetBySheetId(params.subUnitId) : workbook.getActiveSheet();
|
|
865
|
+
if (!worksheet) return null;
|
|
866
|
+
return {
|
|
867
|
+
workbook,
|
|
868
|
+
worksheet
|
|
869
|
+
};
|
|
870
|
+
}
|
|
860
871
|
_initialize(injector) {
|
|
861
872
|
const commandService = injector.get(ICommandService);
|
|
862
873
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded, () => commandService.onCommandExecuted((commandInfo) => {
|
|
863
874
|
var _threadComment$getRan, _threadComment$getRan2, _threadComment$getRan3, _threadComment$getRan4;
|
|
864
875
|
if (commandInfo.id !== AddCommentCommand.id) return;
|
|
865
|
-
const
|
|
866
|
-
const target = this.getSheetCommandTarget(params);
|
|
876
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
867
877
|
if (!target) return;
|
|
868
878
|
const { workbook, worksheet } = target;
|
|
869
|
-
const { comment } = params;
|
|
879
|
+
const { comment } = commandInfo.params;
|
|
870
880
|
const threadComment = worksheet.getCommentById(comment.id);
|
|
871
881
|
if (!threadComment) return;
|
|
872
882
|
const eventParams = {
|
|
@@ -881,11 +891,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
881
891
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated, () => commandService.onCommandExecuted((commandInfo) => {
|
|
882
892
|
var _threadComment$getRan5, _threadComment$getRan6, _threadComment$getRan7, _threadComment$getRan8;
|
|
883
893
|
if (commandInfo.id !== UpdateCommentCommand.id) return;
|
|
884
|
-
const
|
|
885
|
-
const target = this.getSheetCommandTarget(params);
|
|
894
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
886
895
|
if (!target) return;
|
|
887
896
|
const { workbook, worksheet } = target;
|
|
888
|
-
const { payload } = params;
|
|
897
|
+
const { payload } = commandInfo.params;
|
|
889
898
|
const threadComment = worksheet.getCommentById(payload.commentId);
|
|
890
899
|
if (!threadComment) return;
|
|
891
900
|
const eventParams = {
|
|
@@ -899,11 +908,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
899
908
|
})));
|
|
900
909
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted, () => commandService.onCommandExecuted((commandInfo) => {
|
|
901
910
|
if (commandInfo.id !== DeleteCommentCommand.id && commandInfo.id !== DeleteCommentTreeCommand.id) return;
|
|
902
|
-
const
|
|
903
|
-
const target = this.getSheetCommandTarget(params);
|
|
911
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
904
912
|
if (!target) return;
|
|
905
913
|
const { workbook, worksheet } = target;
|
|
906
|
-
const { commentId } = params;
|
|
914
|
+
const { commentId } = commandInfo.params;
|
|
907
915
|
const eventParams = {
|
|
908
916
|
workbook,
|
|
909
917
|
worksheet,
|
|
@@ -914,11 +922,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
914
922
|
this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved, () => commandService.onCommandExecuted((commandInfo) => {
|
|
915
923
|
var _threadComment$getRan9, _threadComment$getRan10, _threadComment$getRan11, _threadComment$getRan12;
|
|
916
924
|
if (commandInfo.id !== ResolveCommentCommand.id) return;
|
|
917
|
-
const
|
|
918
|
-
const target = this.getSheetCommandTarget(params);
|
|
925
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
919
926
|
if (!target) return;
|
|
920
927
|
const { workbook, worksheet } = target;
|
|
921
|
-
const { commentId, resolved } = params;
|
|
928
|
+
const { commentId, resolved } = commandInfo.params;
|
|
922
929
|
const threadComment = worksheet.getCommentById(commentId);
|
|
923
930
|
if (!threadComment) return;
|
|
924
931
|
const eventParams = {
|
|
@@ -933,11 +940,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
933
940
|
})));
|
|
934
941
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
935
942
|
if (commandInfo.id !== AddCommentCommand.id) return;
|
|
936
|
-
const
|
|
937
|
-
const target = this.getSheetCommandTarget(params);
|
|
943
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
938
944
|
if (!target) return;
|
|
939
945
|
const { workbook, worksheet } = target;
|
|
940
|
-
const { comment } = params;
|
|
946
|
+
const { comment } = commandInfo.params;
|
|
941
947
|
const { range } = deserializeRangeWithSheet(comment.ref);
|
|
942
948
|
const eventParams = {
|
|
943
949
|
workbook,
|
|
@@ -952,11 +958,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
952
958
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
953
959
|
var _threadComment$getRan13, _threadComment$getRan14, _threadComment$getRan15, _threadComment$getRan16;
|
|
954
960
|
if (commandInfo.id !== UpdateCommentCommand.id) return;
|
|
955
|
-
const
|
|
956
|
-
const target = this.getSheetCommandTarget(params);
|
|
961
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
957
962
|
if (!target) return;
|
|
958
963
|
const { workbook, worksheet } = target;
|
|
959
|
-
const { payload } = params;
|
|
964
|
+
const { payload } = commandInfo.params;
|
|
960
965
|
const threadComment = worksheet.getCommentById(payload.commentId);
|
|
961
966
|
if (!threadComment) return;
|
|
962
967
|
const eventParams = {
|
|
@@ -973,11 +978,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
973
978
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
974
979
|
var _threadComment$getRan17, _threadComment$getRan18, _threadComment$getRan19, _threadComment$getRan20;
|
|
975
980
|
if (commandInfo.id !== DeleteCommentCommand.id && commandInfo.id !== DeleteCommentTreeCommand.id) return;
|
|
976
|
-
const
|
|
977
|
-
const target = this.getSheetCommandTarget(params);
|
|
981
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
978
982
|
if (!target) return;
|
|
979
983
|
const { workbook, worksheet } = target;
|
|
980
|
-
const { commentId } = params;
|
|
984
|
+
const { commentId } = commandInfo.params;
|
|
981
985
|
const threadComment = worksheet.getCommentById(commentId);
|
|
982
986
|
if (!threadComment) return;
|
|
983
987
|
const eventParams = {
|
|
@@ -993,11 +997,10 @@ var FUniverSheetsThreadCommentMixin = class extends FUniver {
|
|
|
993
997
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
994
998
|
var _getRow, _getColumn;
|
|
995
999
|
if (commandInfo.id !== ResolveCommentCommand.id) return;
|
|
996
|
-
const
|
|
997
|
-
const target = this.getSheetCommandTarget(params);
|
|
1000
|
+
const target = this._getTargetSheet(commandInfo.params);
|
|
998
1001
|
if (!target) return;
|
|
999
1002
|
const { workbook, worksheet } = target;
|
|
1000
|
-
const { commentId, resolved } = params;
|
|
1003
|
+
const { commentId, resolved } = commandInfo.params;
|
|
1001
1004
|
const threadComment = worksheet.getCommentById(commentId);
|
|
1002
1005
|
if (!threadComment) return;
|
|
1003
1006
|
const eventParams = {
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptor
|
|
|
4
4
|
import { AddCommentMutation, DeleteCommentMutation, IThreadCommentDataSourceService, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentRefMutation } from "@univerjs/thread-comment";
|
|
5
5
|
import { Subject } from "rxjs";
|
|
6
6
|
|
|
7
|
-
//#region \0@oxc-project+runtime@0.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
8
8
|
function _typeof(o) {
|
|
9
9
|
"@babel/helpers - typeof";
|
|
10
10
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -15,7 +15,7 @@ function _typeof(o) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
19
19
|
function toPrimitive(t, r) {
|
|
20
20
|
if ("object" != _typeof(t) || !t) return t;
|
|
21
21
|
var e = t[Symbol.toPrimitive];
|
|
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
//#region \0@oxc-project+runtime@0.
|
|
31
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
32
32
|
function toPropertyKey(t) {
|
|
33
33
|
var i = toPrimitive(t, "string");
|
|
34
34
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
39
39
|
function _defineProperty(e, r, t) {
|
|
40
40
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
41
41
|
value: t,
|
|
@@ -46,7 +46,7 @@ function _defineProperty(e, r, t) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
50
50
|
function __decorateParam(paramIndex, decorator) {
|
|
51
51
|
return function(target, key) {
|
|
52
52
|
decorator(target, key, paramIndex);
|
|
@@ -54,7 +54,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
58
58
|
function __decorate(decorators, target, key, desc) {
|
|
59
59
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
60
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -449,7 +449,7 @@ SheetsThreadCommentRefRangeController = __decorate([
|
|
|
449
449
|
//#endregion
|
|
450
450
|
//#region package.json
|
|
451
451
|
var name = "@univerjs/sheets-thread-comment";
|
|
452
|
-
var version = "0.25.
|
|
452
|
+
var version = "0.25.1";
|
|
453
453
|
|
|
454
454
|
//#endregion
|
|
455
455
|
//#region src/config/config.ts
|
|
@@ -50,6 +50,7 @@ export interface IFUniverSheetsThreadCommentMixin {
|
|
|
50
50
|
* @ignore
|
|
51
51
|
*/
|
|
52
52
|
export declare class FUniverSheetsThreadCommentMixin extends FUniver implements IFUniverSheetsThreadCommentMixin {
|
|
53
|
+
private _getTargetSheet;
|
|
53
54
|
_initialize(injector: Injector): void;
|
|
54
55
|
/**
|
|
55
56
|
* @ignore
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IDisposable, IExecutionOptions } from '@univerjs/core';
|
|
17
|
-
import type { CommentUpdate, IAddCommentCommandParams, IDeleteCommentCommandParams
|
|
17
|
+
import type { CommentUpdate, IAddCommentCommandParams, IDeleteCommentCommandParams } from '@univerjs/thread-comment';
|
|
18
18
|
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
19
19
|
import { ThreadCommentModel } from '@univerjs/thread-comment';
|
|
20
20
|
import { FThreadComment } from './f-thread-comment';
|
|
21
|
+
type IUpdateCommandParams = any;
|
|
21
22
|
/**
|
|
22
23
|
* @ignore
|
|
23
24
|
*/
|
|
@@ -66,7 +67,7 @@ export interface IFWorkbookSheetsThreadCommentMixin {
|
|
|
66
67
|
/**
|
|
67
68
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommentUpdate, (params) => {})` as instead
|
|
68
69
|
*/
|
|
69
|
-
onBeforeUpdateThreadComment(this: FWorkbook, callback: (params:
|
|
70
|
+
onBeforeUpdateThreadComment(this: FWorkbook, callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
70
71
|
/**
|
|
71
72
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommentDelete, (params) => {})` as instead
|
|
72
73
|
*/
|
|
@@ -97,7 +98,7 @@ export declare class FWorkbookSheetsThreadCommentMixin extends FWorkbook impleme
|
|
|
97
98
|
* @param callback
|
|
98
99
|
* @deprecated
|
|
99
100
|
*/
|
|
100
|
-
onBeforeUpdateThreadComment(callback: (params:
|
|
101
|
+
onBeforeUpdateThreadComment(callback: (params: IUpdateCommandParams, options: IExecutionOptions | undefined) => void | false): IDisposable;
|
|
101
102
|
/**
|
|
102
103
|
* @param callback
|
|
103
104
|
* @deprecated
|
|
@@ -108,3 +109,4 @@ declare module '@univerjs/sheets/facade' {
|
|
|
108
109
|
interface FWorkbook extends IFWorkbookSheetsThreadCommentMixin {
|
|
109
110
|
}
|
|
110
111
|
}
|
|
112
|
+
export {};
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-thread-comment`,`@univerjs/sheets/facade`,`@univerjs/thread-comment`,`@univerjs/engine-formula`,`rxjs`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadCommentFacade={},e.UniverCore,e.UniverSheetsThreadComment,e.UniverSheetsFacade,e.UniverThreadComment,e.UniverEngineFormula,e.rxjs,e.UniverCoreFacade))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){return function(n,r){t(n,r,e)}}function p(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var m,h=class e{static create(t){return new e(t)}constructor(e){d(this,`_comment`,{id:(0,t.generateRandomId)(),ref:``,threadId:``,dT:``,personId:``,text:t.RichTextBuilder.newEmptyData().body,attachments:[],unitId:``,subUnitId:``}),e&&(this._comment=e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return t.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return g.create(t.Tools.deepClone(this._comment))}},g=class e extends h{static create(t){return new e(t)}setContent(e){return e instanceof t.RichTextValue?this._comment.text=e.getData().body:this._comment.text=e,this}setPersonId(e){return this._comment.personId=e,this}setDateTime(e){return this._comment.dT=(0,i.getDT)(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}};let _=m=class{constructor(e,t,n,r,i,a,o){this._thread=e,this._parent=t,this._injector=n,this._commandService=r,this._univerInstanceService=i,this._threadCommentModel=a,this._userManagerService=o}_getRef(){var e;return(0,a.deserializeRangeWithSheet)(((e=this._parent)==null?void 0:e.ref)||this._thread.ref).range}getIsRoot(){return!this._parent}getCommentData(){let{children:e,...t}=this._thread;return t}getReplies(){var e;let t=this._getRef(),n=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return n==null||(e=n.children)==null?void 0:e.map(e=>this._injector.createInstance(m,e))}getRange(){let e=this._univerInstanceService.getUnit(this._thread.unitId,t.UniverInstanceType.UNIVER_SHEET);if(!e)return null;let n=e.getSheetBySheetId(this._thread.subUnitId);if(!n)return null;let i=this._getRef();return this._injector.createInstance(r.FRange,e,n,i)}getContent(){return this._thread.text}getRichText(){let e=this._thread.text;return t.RichTextValue.create({body:e,documentStyle:{},id:`d`})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?i.DeleteCommentTreeCommand.id:i.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(e){return this.updateAsync(e)}async updateAsync(e){let n=e instanceof t.RichTextValue?e.getData().body:e,r=(0,i.getDT)();return await this._commandService.executeCommand(i.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:n,updated:!0,updateT:r}})}resolve(e){return this.resolveAsync(e)}resolveAsync(e){return this._commandService.executeCommand(i.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:e==null?!this._thread.resolved:e})}replyAsync(e){var n;let r=e.build();return this._commandService.executeCommand(i.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:(0,t.generateRandomId)(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((n=this._parent)==null?void 0:n.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||(0,i.getDT)(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}};_=m=p([f(2,(0,t.Inject)(t.Injector)),f(3,t.ICommandService),f(4,t.IUniverInstanceService),f(5,(0,t.Inject)(n.SheetsThreadCommentModel)),f(6,(0,t.Inject)(t.UserManagerService))],_);var v=class extends r.FRange{getComment(){let e=this._injector.get(n.SheetsThreadCommentModel),t=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),i=e.getByLocation(t,r,this._range.startRow,this._range.startColumn);if(!i)return null;let a=e.getComment(t,r,i);return a?this._injector.createInstance(_,a):null}getComments(){let e=this._injector.get(n.SheetsThreadCommentModel),r=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),a=[];return t.Range.foreach(this._range,(t,n)=>{let o=e.getByLocation(r,i,t,n);if(o){let t=e.getComment(r,i,o);t&&a.push(this._injector.createInstance(_,t))}}),a}addComment(e){var n;let r=this._injector,a=(n=this.getComment())==null?void 0:n.getCommentData(),o=r.get(t.ICommandService),s=r.get(t.UserManagerService),c=this._workbook.getUnitId(),l=this._worksheet.getSheetId(),u=`${t.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,d=s.getCurrentUser(),f=e instanceof g?e.build():{text:e};return o.executeCommand(i.AddCommentCommand.id,{unitId:c,subUnitId:l,comment:{text:f.text,dT:f.dT||(0,i.getDT)(),attachments:[],id:f.id||(0,t.generateRandomId)(),ref:u,personId:f.personId||d.userID,parentId:a==null?void 0:a.id,unitId:c,subUnitId:l,threadId:(a==null?void 0:a.threadId)||(0,t.generateRandomId)()}})}clearComment(){var e;let n=this._injector,r=(e=this.getComment())==null?void 0:e.getCommentData(),a=n.get(t.ICommandService),o=this._workbook.getUnitId(),s=this._worksheet.getSheetId();return r?a.executeCommand(i.DeleteCommentTreeCommand.id,{unitId:o,subUnitId:s,threadId:r.threadId,commentId:r.id}):Promise.resolve(!0)}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}addCommentAsync(e){return this.addComment(e)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}};r.FRange.extend(v);var y=class extends r.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(i.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(_,e.root))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onThreadCommentChange(e){return(0,t.toDisposable)(this._threadCommentModel.commentUpdate$.pipe((0,o.filter)(e=>e.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddThreadComment(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===i.AddCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeAddThreadComment`)}}))}onBeforeUpdateThreadComment(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===i.UpdateCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeUpdateThreadComment`)}}))}onBeforeDeleteThreadComment(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===i.DeleteCommentCommand.id||t.id===i.DeleteCommentTreeCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeDeleteThreadComment`)}}))}};r.FWorkbook.extend(y);var b=class extends r.FWorksheet{getComments(){return this._injector.get(n.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(_,e))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onCommented(e){return this._injector.get(t.ICommandService).onCommandExecuted(t=>{if(t.id===i.AddCommentCommand.id){let n=t.params;e(n)}})}getCommentById(e){let t=this._injector.get(n.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(_,t)}};r.FWorksheet.extend(b);var x=class extends s.FEventName{get CommentAdded(){return`CommentAdded`}get BeforeCommentAdd(){return`BeforeCommentAdd`}get CommentUpdated(){return`CommentUpdated`}get BeforeCommentUpdate(){return`BeforeCommentUpdate`}get CommentDeleted(){return`CommentDeleted`}get BeforeCommentDelete(){return`BeforeCommentDelete`}get CommentResolved(){return`CommentResolved`}get BeforeCommentResolve(){return`BeforeCommentResolve`}};s.FEventName.extend(x);var S=class extends s.FUniver{_initialize(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded,()=>n.onCommandExecuted(e=>{var t,n,r,a;if(e.id!==i.AddCommentCommand.id)return;let o=e.params,s=this.getSheetCommandTarget(o);if(!s)return;let{workbook:c,worksheet:l}=s,{comment:u}=o,d=l.getCommentById(u.id);if(!d)return;let f={workbook:c,worksheet:l,row:(t=(n=d.getRange())==null?void 0:n.getRow())==null?0:t,col:(r=(a=d.getRange())==null?void 0:a.getColumn())==null?0:r,comment:d};this.fireEvent(this.Event.CommentAdded,f)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated,()=>n.onCommandExecuted(e=>{var t,n,r,a;if(e.id!==i.UpdateCommentCommand.id)return;let o=e.params,s=this.getSheetCommandTarget(o);if(!s)return;let{workbook:c,worksheet:l}=s,{payload:u}=o,d=l.getCommentById(u.commentId);if(!d)return;let f={workbook:c,worksheet:l,row:(t=(n=d.getRange())==null?void 0:n.getRow())==null?0:t,col:(r=(a=d.getRange())==null?void 0:a.getColumn())==null?0:r,comment:d};this.fireEvent(this.Event.CommentUpdated,f)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let t=e.params,n=this.getSheetCommandTarget(t);if(!n)return;let{workbook:r,worksheet:a}=n,{commentId:o}=t,s={workbook:r,worksheet:a,commentId:o};this.fireEvent(this.Event.CommentDeleted,s)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved,()=>n.onCommandExecuted(e=>{var t,n,r,a;if(e.id!==i.ResolveCommentCommand.id)return;let o=e.params,s=this.getSheetCommandTarget(o);if(!s)return;let{workbook:c,worksheet:l}=s,{commentId:u,resolved:d}=o,f=l.getCommentById(u);if(!f)return;let p={workbook:c,worksheet:l,row:(t=(n=f.getRange())==null?void 0:n.getRow())==null?0:t,col:(r=(a=f.getRange())==null?void 0:a.getColumn())==null?0:r,comment:f,resolved:d};this.fireEvent(this.Event.CommentResolved,p)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==i.AddCommentCommand.id)return;let n=e.params,r=this.getSheetCommandTarget(n);if(!r)return;let{workbook:o,worksheet:s}=r,{comment:c}=n,{range:l}=(0,a.deserializeRangeWithSheet)(c.ref),u={workbook:o,worksheet:s,row:l.startRow,col:l.startColumn,comment:h.create(c)};if(this.fireEvent(this.Event.BeforeCommentAdd,u),u.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>n.beforeCommandExecuted(e=>{var n,r,a,o;if(e.id!==i.UpdateCommentCommand.id)return;let s=e.params,c=this.getSheetCommandTarget(s);if(!c)return;let{workbook:l,worksheet:u}=c,{payload:d}=s,f=u.getCommentById(d.commentId);if(!f)return;let p={workbook:l,worksheet:u,row:(n=(r=f.getRange())==null?void 0:r.getRow())==null?0:n,col:(a=(o=f.getRange())==null?void 0:o.getColumn())==null?0:a,comment:f,newContent:t.RichTextValue.createByBody(d.text)};if(this.fireEvent(this.Event.BeforeCommentUpdate,p),p.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete,()=>n.beforeCommandExecuted(e=>{var n,r,a,o;if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let s=e.params,c=this.getSheetCommandTarget(s);if(!c)return;let{workbook:l,worksheet:u}=c,{commentId:d}=s,f=u.getCommentById(d);if(!f)return;let p={workbook:l,worksheet:u,row:(n=(r=f.getRange())==null?void 0:r.getRow())==null?0:n,col:(a=(o=f.getRange())==null?void 0:o.getColumn())==null?0:a,comment:f};if(this.fireEvent(this.Event.BeforeCommentDelete,p),p.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve,()=>n.beforeCommandExecuted(e=>{var n,r;if(e.id!==i.ResolveCommentCommand.id)return;let a=e.params,o=this.getSheetCommandTarget(a);if(!o)return;let{workbook:s,worksheet:c}=o,{commentId:l,resolved:u}=a,d=c.getCommentById(l);if(!d)return;let f={workbook:s,worksheet:c,row:(n=d.getRange().getRow())==null?0:n,col:(r=d.getRange().getColumn())==null?0:r,comment:d,resolved:u};if(this.fireEvent(this.Event.BeforeCommentResolve,f),f.cancel)throw new t.CanceledError})))}newTheadComment(e){return new g(e)}};s.FUniver.extend(S),Object.defineProperty(e,"FThreadComment",{enumerable:!0,get:function(){return _}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets-thread-comment"),require("@univerjs/sheets/facade"),require("@univerjs/thread-comment"),require("@univerjs/engine-formula"),require("rxjs"),require("@univerjs/core/facade")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets-thread-comment`,`@univerjs/sheets/facade`,`@univerjs/thread-comment`,`@univerjs/engine-formula`,`rxjs`,`@univerjs/core/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadCommentFacade={},e.UniverCore,e.UniverSheetsThreadComment,e.UniverSheetsFacade,e.UniverThreadComment,e.UniverEngineFormula,e.rxjs,e.UniverCoreFacade))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function c(e){"@babel/helpers - typeof";return c=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},c(e)}function l(e,t){if(c(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(c(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function u(e){var t=l(e,`string`);return c(t)==`symbol`?t:t+``}function d(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t){return function(n,r){t(n,r,e)}}function p(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var m,h=class e{static create(t){return new e(t)}constructor(e){d(this,`_comment`,{id:(0,t.generateRandomId)(),ref:``,threadId:``,dT:``,personId:``,text:t.RichTextBuilder.newEmptyData().body,attachments:[],unitId:``,subUnitId:``}),e&&(this._comment=e)}get personId(){return this._comment.personId}get dateTime(){return this._comment.dT}get content(){return t.RichTextValue.createByBody(this._comment.text)}get id(){return this._comment.id}get threadId(){return this._comment.threadId}copy(){return g.create(t.Tools.deepClone(this._comment))}},g=class e extends h{static create(t){return new e(t)}setContent(e){return e instanceof t.RichTextValue?this._comment.text=e.getData().body:this._comment.text=e,this}setPersonId(e){return this._comment.personId=e,this}setDateTime(e){return this._comment.dT=(0,i.getDT)(e),this}setId(e){return this._comment.id=e,this}setThreadId(e){return this._comment.threadId=e,this}build(){return this._comment}};let _=m=class{constructor(e,t,n,r,i,a,o){this._thread=e,this._parent=t,this._injector=n,this._commandService=r,this._univerInstanceService=i,this._threadCommentModel=a,this._userManagerService=o}_getRef(){var e;return(0,a.deserializeRangeWithSheet)(((e=this._parent)==null?void 0:e.ref)||this._thread.ref).range}getIsRoot(){return!this._parent}getCommentData(){let{children:e,...t}=this._thread;return t}getReplies(){var e;let t=this._getRef(),n=this._threadCommentModel.getCommentWithChildren(this._thread.unitId,this._thread.subUnitId,t.startRow,t.startColumn);return n==null||(e=n.children)==null?void 0:e.map(e=>this._injector.createInstance(m,e))}getRange(){let e=this._univerInstanceService.getUnit(this._thread.unitId,t.UniverInstanceType.UNIVER_SHEET);if(!e)return null;let n=e.getSheetBySheetId(this._thread.subUnitId);if(!n)return null;let i=this._getRef();return this._injector.createInstance(r.FRange,e,n,i)}getContent(){return this._thread.text}getRichText(){let e=this._thread.text;return t.RichTextValue.create({body:e,documentStyle:{},id:`d`})}deleteAsync(){return this._commandService.executeCommand(this.getIsRoot()?i.DeleteCommentTreeCommand.id:i.DeleteCommentCommand.id,{commentId:this._thread.id,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId})}delete(){return this.deleteAsync()}async update(e){return this.updateAsync(e)}async updateAsync(e){let n=e instanceof t.RichTextValue?e.getData().body:e,r=(0,i.getDT)();return await this._commandService.executeCommand(i.UpdateCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,payload:{commentId:this._thread.id,text:n,updated:!0,updateT:r}})}resolve(e){return this.resolveAsync(e)}resolveAsync(e){return this._commandService.executeCommand(i.ResolveCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,commentId:this._thread.id,resolved:e==null?!this._thread.resolved:e})}replyAsync(e){var n;let r=e.build();return this._commandService.executeCommand(i.AddCommentCommand.id,{unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,comment:{id:(0,t.generateRandomId)(),parentId:this._thread.id,threadId:this._thread.threadId,ref:((n=this._parent)==null?void 0:n.ref)||this._thread.ref,unitId:this._thread.unitId,subUnitId:this._thread.subUnitId,text:r.text,attachments:r.attachments,dT:r.dT||(0,i.getDT)(),personId:r.personId||this._userManagerService.getCurrentUser().userID}})}};_=m=p([f(2,(0,t.Inject)(t.Injector)),f(3,t.ICommandService),f(4,t.IUniverInstanceService),f(5,(0,t.Inject)(n.SheetsThreadCommentModel)),f(6,(0,t.Inject)(t.UserManagerService))],_);var v=class extends r.FRange{getComment(){let e=this._injector.get(n.SheetsThreadCommentModel),t=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),i=e.getByLocation(t,r,this._range.startRow,this._range.startColumn);if(!i)return null;let a=e.getComment(t,r,i);return a?this._injector.createInstance(_,a):null}getComments(){let e=this._injector.get(n.SheetsThreadCommentModel),r=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),a=[];return t.Range.foreach(this._range,(t,n)=>{let o=e.getByLocation(r,i,t,n);if(o){let t=e.getComment(r,i,o);t&&a.push(this._injector.createInstance(_,t))}}),a}addComment(e){var n;let r=this._injector,a=(n=this.getComment())==null?void 0:n.getCommentData(),o=r.get(t.ICommandService),s=r.get(t.UserManagerService),c=this._workbook.getUnitId(),l=this._worksheet.getSheetId(),u=`${t.Tools.chatAtABC(this._range.startColumn)}${this._range.startRow+1}`,d=s.getCurrentUser(),f=e instanceof g?e.build():{text:e};return o.executeCommand(i.AddCommentCommand.id,{unitId:c,subUnitId:l,comment:{text:f.text,dT:f.dT||(0,i.getDT)(),attachments:[],id:f.id||(0,t.generateRandomId)(),ref:u,personId:f.personId||d.userID,parentId:a==null?void 0:a.id,unitId:c,subUnitId:l,threadId:(a==null?void 0:a.threadId)||(0,t.generateRandomId)()}})}clearComment(){var e;let n=this._injector,r=(e=this.getComment())==null?void 0:e.getCommentData(),a=n.get(t.ICommandService),o=this._workbook.getUnitId(),s=this._worksheet.getSheetId();return r?a.executeCommand(i.DeleteCommentTreeCommand.id,{unitId:o,subUnitId:s,threadId:r.threadId,commentId:r.id}):Promise.resolve(!0)}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}addCommentAsync(e){return this.addComment(e)}clearCommentAsync(){return this.clearComment()}clearCommentsAsync(){return this.clearComments()}};r.FRange.extend(v);var y=class extends r.FWorkbook{_initialize(){Object.defineProperty(this,"_threadCommentModel",{get(){return this._injector.get(i.ThreadCommentModel)}})}getComments(){return this._threadCommentModel.getUnit(this._workbook.getUnitId()).map(e=>this._injector.createInstance(_,e.root))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onThreadCommentChange(e){return(0,t.toDisposable)(this._threadCommentModel.commentUpdate$.pipe((0,o.filter)(e=>e.unitId===this._workbook.getUnitId())).subscribe(e))}onBeforeAddThreadComment(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===i.AddCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeAddThreadComment`)}}))}onBeforeUpdateThreadComment(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===i.UpdateCommentCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeUpdateThreadComment`)}}))}onBeforeDeleteThreadComment(e){return(0,t.toDisposable)(this._commandService.beforeCommandExecuted((t,n)=>{let r=t.params;if(t.id===i.DeleteCommentCommand.id||t.id===i.DeleteCommentTreeCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(e(r,n)===!1)throw Error(`Command is stopped by the hook onBeforeDeleteThreadComment`)}}))}};r.FWorkbook.extend(y);var b=class extends r.FWorksheet{getComments(){return this._injector.get(n.SheetsThreadCommentModel).getSubUnitAll(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>this._injector.createInstance(_,e))}clearComments(){let e=this.getComments().map(e=>e.deleteAsync());return Promise.all(e).then(()=>!0)}onCommented(e){return this._injector.get(t.ICommandService).onCommandExecuted(t=>{if(t.id===i.AddCommentCommand.id){let n=t.params;e(n)}})}getCommentById(e){let t=this._injector.get(n.SheetsThreadCommentModel).getComment(this._workbook.getUnitId(),this._worksheet.getSheetId(),e);if(t)return this._injector.createInstance(_,t)}};r.FWorksheet.extend(b);var x=class extends s.FEventName{get CommentAdded(){return`CommentAdded`}get BeforeCommentAdd(){return`BeforeCommentAdd`}get CommentUpdated(){return`CommentUpdated`}get BeforeCommentUpdate(){return`BeforeCommentUpdate`}get CommentDeleted(){return`CommentDeleted`}get BeforeCommentDelete(){return`BeforeCommentDelete`}get CommentResolved(){return`CommentResolved`}get BeforeCommentResolve(){return`BeforeCommentResolve`}};s.FEventName.extend(x);var S=class extends s.FUniver{_getTargetSheet(e={}){var t;let n=e.unitId?this.getUniverSheet(e.unitId):(t=this.getActiveWorkbook)==null?void 0:t.call(this);if(!n)return null;let r=e.subUnitId?n.getSheetBySheetId(e.subUnitId):n.getActiveSheet();return r?{workbook:n,worksheet:r}:null}_initialize(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.CommentAdded,()=>n.onCommandExecuted(e=>{var t,n,r,a;if(e.id!==i.AddCommentCommand.id)return;let o=this._getTargetSheet(e.params);if(!o)return;let{workbook:s,worksheet:c}=o,{comment:l}=e.params,u=c.getCommentById(l.id);if(!u)return;let d={workbook:s,worksheet:c,row:(t=(n=u.getRange())==null?void 0:n.getRow())==null?0:t,col:(r=(a=u.getRange())==null?void 0:a.getColumn())==null?0:r,comment:u};this.fireEvent(this.Event.CommentAdded,d)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentUpdated,()=>n.onCommandExecuted(e=>{var t,n,r,a;if(e.id!==i.UpdateCommentCommand.id)return;let o=this._getTargetSheet(e.params);if(!o)return;let{workbook:s,worksheet:c}=o,{payload:l}=e.params,u=c.getCommentById(l.commentId);if(!u)return;let d={workbook:s,worksheet:c,row:(t=(n=u.getRange())==null?void 0:n.getRow())==null?0:t,col:(r=(a=u.getRange())==null?void 0:a.getColumn())==null?0:r,comment:u};this.fireEvent(this.Event.CommentUpdated,d)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentDeleted,()=>n.onCommandExecuted(e=>{if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let t=this._getTargetSheet(e.params);if(!t)return;let{workbook:n,worksheet:r}=t,{commentId:a}=e.params,o={workbook:n,worksheet:r,commentId:a};this.fireEvent(this.Event.CommentDeleted,o)}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommentResolved,()=>n.onCommandExecuted(e=>{var t,n,r,a;if(e.id!==i.ResolveCommentCommand.id)return;let o=this._getTargetSheet(e.params);if(!o)return;let{workbook:s,worksheet:c}=o,{commentId:l,resolved:u}=e.params,d=c.getCommentById(l);if(!d)return;let f={workbook:s,worksheet:c,row:(t=(n=d.getRange())==null?void 0:n.getRow())==null?0:t,col:(r=(a=d.getRange())==null?void 0:a.getColumn())==null?0:r,comment:d,resolved:u};this.fireEvent(this.Event.CommentResolved,f)}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentAdd,()=>n.beforeCommandExecuted(e=>{if(e.id!==i.AddCommentCommand.id)return;let n=this._getTargetSheet(e.params);if(!n)return;let{workbook:r,worksheet:o}=n,{comment:s}=e.params,{range:c}=(0,a.deserializeRangeWithSheet)(s.ref),l={workbook:r,worksheet:o,row:c.startRow,col:c.startColumn,comment:h.create(s)};if(this.fireEvent(this.Event.BeforeCommentAdd,l),l.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentUpdate,()=>n.beforeCommandExecuted(e=>{var n,r,a,o;if(e.id!==i.UpdateCommentCommand.id)return;let s=this._getTargetSheet(e.params);if(!s)return;let{workbook:c,worksheet:l}=s,{payload:u}=e.params,d=l.getCommentById(u.commentId);if(!d)return;let f={workbook:c,worksheet:l,row:(n=(r=d.getRange())==null?void 0:r.getRow())==null?0:n,col:(a=(o=d.getRange())==null?void 0:o.getColumn())==null?0:a,comment:d,newContent:t.RichTextValue.createByBody(u.text)};if(this.fireEvent(this.Event.BeforeCommentUpdate,f),f.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentDelete,()=>n.beforeCommandExecuted(e=>{var n,r,a,o;if(e.id!==i.DeleteCommentCommand.id&&e.id!==i.DeleteCommentTreeCommand.id)return;let s=this._getTargetSheet(e.params);if(!s)return;let{workbook:c,worksheet:l}=s,{commentId:u}=e.params,d=l.getCommentById(u);if(!d)return;let f={workbook:c,worksheet:l,row:(n=(r=d.getRange())==null?void 0:r.getRow())==null?0:n,col:(a=(o=d.getRange())==null?void 0:o.getColumn())==null?0:a,comment:d};if(this.fireEvent(this.Event.BeforeCommentDelete,f),f.cancel)throw new t.CanceledError}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommentResolve,()=>n.beforeCommandExecuted(e=>{var n,r;if(e.id!==i.ResolveCommentCommand.id)return;let a=this._getTargetSheet(e.params);if(!a)return;let{workbook:o,worksheet:s}=a,{commentId:c,resolved:l}=e.params,u=s.getCommentById(c);if(!u)return;let d={workbook:o,worksheet:s,row:(n=u.getRange().getRow())==null?0:n,col:(r=u.getRange().getColumn())==null?0:r,comment:u,resolved:l};if(this.fireEvent(this.Event.BeforeCommentResolve,d),d.cancel)throw new t.CanceledError})))}newTheadComment(e){return new g(e)}};s.FUniver.extend(S),Object.defineProperty(e,"FThreadComment",{enumerable:!0,get:function(){return _}})});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-formula`,`@univerjs/sheets`,`@univerjs/thread-comment`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadComment={},e.UniverCore,e.UniverEngineFormula,e.UniverSheets,e.UniverThreadComment,e.rxjs))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let f=class extends t.Disposable{constructor(e,t){super(),this._threadCommentModel=e,this._univerInstanceService=t,l(this,`_matrixMap`,new Map),l(this,`_locationMap`,new Map),l(this,`_commentUpdate$`,new a.Subject),l(this,`commentUpdate$`,this._commentUpdate$.asObservable()),this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let r=this._matrixMap.get(e);r||(r=new Map,this._matrixMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_ensureCommentLocationMap(e,t){let n=this._locationMap.get(e);n||(n=new Map,this._locationMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_addCommentToMatrix(e,t,n,r){var i;let a=(i=e.getValue(t,n))==null?new Set:i;a.add(r),e.setValue(t,n,a)}_deleteCommentFromMatrix(e,t,n,r){if(t>=0&&n>=0){let i=e.getValue(t,n);i&&i.has(r)&&(i.delete(r),i.size===0&&e.realDeleteValue(t,n))}}_ensure(e,t){return{matrix:this._ensureCommentMatrix(e,t),locationMap:this._ensureCommentLocationMap(e,t)}}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:n,root:r}=e;this._addComment(t,n,r)}}_addComment(e,t,r){let i=(0,n.singleReferenceToGrid)(r.ref),a=r.parentId,{row:o,column:s}=i,c=r.id,{matrix:l,locationMap:u}=this._ensure(e,t);!a&&o>=0&&s>=0&&(this._addCommentToMatrix(l,o,s,c),u.set(c,{row:o,column:s})),a||this._commentUpdate$.next({unitId:e,subUnitId:t,payload:r,type:`add`,isRoot:!a,...i})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:r,subUnitId:i}=e;try{if(this._univerInstanceService.getUnitType(r)!==t.UniverInstanceType.UNIVER_SHEET)return}catch{}let{matrix:a,locationMap:o}=this._ensure(r,i);switch(e.type){case`add`:this._addComment(e.unitId,e.subUnitId,e.payload);break;case`delete`:{let{isRoot:t,comment:r}=e.payload;if(t){let t=(0,n.singleReferenceToGrid)(r.ref),{row:i,column:o}=t;this._deleteCommentFromMatrix(a,i,o,r.id),this._commentUpdate$.next({...e,...t})}break}case`update`:{let{commentId:t}=e.payload,a=this._threadCommentModel.getComment(r,i,t);if(!a)return;let o=(0,n.singleReferenceToGrid)(a.ref);this._commentUpdate$.next({...e,...o});break}case`updateRef`:{let t=(0,n.singleReferenceToGrid)(e.payload.ref),{commentId:r}=e.payload,i=o.get(r);if(!i)return;let{row:s,column:c}=i;this._deleteCommentFromMatrix(a,s,c,r),o.delete(r),t.row>=0&&t.column>=0&&(this._addCommentToMatrix(a,t.row,t.column,r),o.set(r,{row:t.row,column:t.column})),this._commentUpdate$.next({...e,...t});break}case`resolve`:{let{unitId:t,subUnitId:n,payload:r}=e,{locationMap:i}=this._ensure(t,n),a=i.get(r.commentId);a&&this._commentUpdate$.next({...e,...a});break}default:break}}))}getByLocation(e,t,n,r){var i;return(i=this.getAllByLocation(e,t,n,r).filter(e=>!e.resolved)[0])==null?void 0:i.id}getAllByLocation(e,t,n,r){let i=this._ensureCommentMatrix(e,t).getValue(n,r);if(!i)return[];let a=[];for(let n of i){let r=this.getComment(e,t,n);r&&a.push(r)}return a}getComment(e,t,n){return this._threadCommentModel.getComment(e,t,n)}getCommentWithChildren(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return;let a=this.getComment(e,t,i);if(a)return this._threadCommentModel.getThread(e,t,a.threadId)}showCommentMarker(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return!1;let a=this.getComment(e,t,i);return!!(a&&!a.resolved)}getSubUnitAll(e,t){return this._threadCommentModel.getUnit(e).filter(e=>e.subUnitId===t).map(e=>e.root)}};f=d([u(0,(0,t.Inject)(i.ThreadCommentModel)),u(1,t.IUniverInstanceService)],f);let p=class extends t.Disposable{constructor(e,t,r,a,o){super(),this._refRangeService=e,this._sheetsThreadCommentModel=t,this._threadCommentModel=r,this._selectionManagerService=a,this._commandService=o,l(this,`_disposableMap`,new Map),l(this,`_watcherMap`,new Map),l(this,`_handleRangeChange`,(e,t,r,a,o)=>{let s=r.id,c={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};return a?{redos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(a),commentId:s},silent:o}}],undos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(c),commentId:s},silent:o}}]}:{redos:[{id:i.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:s}}],undos:[{id:i.AddCommentMutation.id,params:{unitId:e,subUnitId:t,comment:r,sync:!0}}]}}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}-${t}-${n}`}_register(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(this._getIdWithUnitId(e,t,i),this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,n,s,!1)},e,t))}_watch(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watcherMap.set(this._getIdWithUnitId(e,n,i),this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._watcherMap.get(i))==null||r.dispose(),this._watcherMap.delete(i)}_unregister(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._disposableMap.get(i))==null||r.dispose(),this._disposableMap.delete(i)}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:r,root:i}=e,a=(0,n.singleReferenceToGrid)(i.ref),o={...i,...a};this._register(t,r,o),this._watch(t,r,o)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n}=e;switch(e.type){case`add`:{if(e.payload.parentId)return;let t={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,t),this._watch(e.unitId,e.subUnitId,t);break}case`delete`:this._unregister(t,n,e.payload.commentId),this._unwatch(t,n,e.payload.commentId);break;case`updateRef`:{let r=this._sheetsThreadCommentModel.getComment(t,n,e.payload.commentId);if(!r)return;this._unregister(t,n,e.payload.commentId);let i={...r,row:e.row,column:e.column};e.silent||(this._unwatch(t,n,e.payload.commentId),this._watch(t,n,i)),this._register(e.unitId,e.subUnitId,i);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};p=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(i.ThreadCommentModel)),u(3,(0,t.Inject)(r.SheetsSelectionsService)),u(4,t.ICommandService)],p);var m=`@univerjs/sheets-thread-comment`,h=`0.25.0-insiders.20260623-012b5a8`;let g={},_=class extends t.Disposable{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._sheetInterceptorService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=r,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,a=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!a||!o)return{redos:[],undos:[]};let s=this._threadCommentModel.ensureMap(a,o),c=Array.from(s.values()).filter(e=>!e.parentId),l=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=[],d=[];return c.forEach(({children:e,...t})=>{u.push({id:i.DeleteCommentMutation.id,params:{unitId:a,subUnitId:o,commentId:t.id}}),d.push({id:i.AddCommentMutation.id,params:{unitId:a,subUnitId:o,comment:{...t,children:l?e:void 0},sync:!l}})}),{redos:u,undos:d}}else if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:a}=e.params;if(!n||!r||!a)return{redos:[],undos:[]};let o=this._threadCommentModel.ensureMap(n,r),s=Array.from(o.values()).map(e=>({...e,subUnitId:a,id:(0,t.generateRandomId)(),threadId:(0,t.generateRandomId)()})).filter(e=>!e.parentId),c=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=[],u=[];return s.forEach(({children:e,...t})=>{l.push({id:i.AddCommentMutation.id,params:{unitId:n,subUnitId:a,comment:{...t,children:c?e:void 0},sync:!c}}),u.push({id:i.DeleteCommentMutation.id,params:{unitId:n,subUnitId:a,commentId:t.id}})}),{redos:l,undos:u}}return{redos:[],undos:[]}}}))}};_=d([u(0,t.IUniverInstanceService),u(1,(0,t.Inject)(r.SheetInterceptorService)),u(2,(0,t.Inject)(i.ThreadCommentModel)),u(3,i.IThreadCommentDataSourceService)],_);let v=class extends t.Plugin{constructor(e=g,t,n){super(),this._config=e,this._injector=t,this._commandService=n}onStarting(){[[f],[p],[_]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[p],[_]])}};l(v,`pluginName`,`SHEET_THREAD_COMMENT_BASE_PLUGIN`),l(v,`packageName`,m),l(v,`version`,h),l(v,`type`,t.UniverInstanceType.UNIVER_SHEET),v=d([(0,t.DependentOn)(i.UniverThreadCommentPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,(0,t.Inject)(t.ICommandService))],v),Object.defineProperty(e,"SheetsThreadCommentModel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SheetsThreadCommentRefRangeController",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"UniverSheetsThreadCommentPlugin",{enumerable:!0,get:function(){return v}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("@univerjs/thread-comment"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-formula`,`@univerjs/sheets`,`@univerjs/thread-comment`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsThreadComment={},e.UniverCore,e.UniverEngineFormula,e.UniverSheets,e.UniverThreadComment,e.rxjs))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function o(e){"@babel/helpers - typeof";return o=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let f=class extends t.Disposable{constructor(e,t){super(),this._threadCommentModel=e,this._univerInstanceService=t,l(this,`_matrixMap`,new Map),l(this,`_locationMap`,new Map),l(this,`_commentUpdate$`,new a.Subject),l(this,`commentUpdate$`,this._commentUpdate$.asObservable()),this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,n){let r=this._matrixMap.get(e);r||(r=new Map,this._matrixMap.set(e,r));let i=r.get(n);return i||(i=new t.ObjectMatrix,r.set(n,i)),i}_ensureCommentLocationMap(e,t){let n=this._locationMap.get(e);n||(n=new Map,this._locationMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_addCommentToMatrix(e,t,n,r){var i;let a=(i=e.getValue(t,n))==null?new Set:i;a.add(r),e.setValue(t,n,a)}_deleteCommentFromMatrix(e,t,n,r){if(t>=0&&n>=0){let i=e.getValue(t,n);i&&i.has(r)&&(i.delete(r),i.size===0&&e.realDeleteValue(t,n))}}_ensure(e,t){return{matrix:this._ensureCommentMatrix(e,t),locationMap:this._ensureCommentLocationMap(e,t)}}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:n,root:r}=e;this._addComment(t,n,r)}}_addComment(e,t,r){let i=(0,n.singleReferenceToGrid)(r.ref),a=r.parentId,{row:o,column:s}=i,c=r.id,{matrix:l,locationMap:u}=this._ensure(e,t);!a&&o>=0&&s>=0&&(this._addCommentToMatrix(l,o,s,c),u.set(c,{row:o,column:s})),a||this._commentUpdate$.next({unitId:e,subUnitId:t,payload:r,type:`add`,isRoot:!a,...i})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:r,subUnitId:i}=e;try{if(this._univerInstanceService.getUnitType(r)!==t.UniverInstanceType.UNIVER_SHEET)return}catch{}let{matrix:a,locationMap:o}=this._ensure(r,i);switch(e.type){case`add`:this._addComment(e.unitId,e.subUnitId,e.payload);break;case`delete`:{let{isRoot:t,comment:r}=e.payload;if(t){let t=(0,n.singleReferenceToGrid)(r.ref),{row:i,column:o}=t;this._deleteCommentFromMatrix(a,i,o,r.id),this._commentUpdate$.next({...e,...t})}break}case`update`:{let{commentId:t}=e.payload,a=this._threadCommentModel.getComment(r,i,t);if(!a)return;let o=(0,n.singleReferenceToGrid)(a.ref);this._commentUpdate$.next({...e,...o});break}case`updateRef`:{let t=(0,n.singleReferenceToGrid)(e.payload.ref),{commentId:r}=e.payload,i=o.get(r);if(!i)return;let{row:s,column:c}=i;this._deleteCommentFromMatrix(a,s,c,r),o.delete(r),t.row>=0&&t.column>=0&&(this._addCommentToMatrix(a,t.row,t.column,r),o.set(r,{row:t.row,column:t.column})),this._commentUpdate$.next({...e,...t});break}case`resolve`:{let{unitId:t,subUnitId:n,payload:r}=e,{locationMap:i}=this._ensure(t,n),a=i.get(r.commentId);a&&this._commentUpdate$.next({...e,...a});break}default:break}}))}getByLocation(e,t,n,r){var i;return(i=this.getAllByLocation(e,t,n,r).filter(e=>!e.resolved)[0])==null?void 0:i.id}getAllByLocation(e,t,n,r){let i=this._ensureCommentMatrix(e,t).getValue(n,r);if(!i)return[];let a=[];for(let n of i){let r=this.getComment(e,t,n);r&&a.push(r)}return a}getComment(e,t,n){return this._threadCommentModel.getComment(e,t,n)}getCommentWithChildren(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return;let a=this.getComment(e,t,i);if(a)return this._threadCommentModel.getThread(e,t,a.threadId)}showCommentMarker(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return!1;let a=this.getComment(e,t,i);return!!(a&&!a.resolved)}getSubUnitAll(e,t){return this._threadCommentModel.getUnit(e).filter(e=>e.subUnitId===t).map(e=>e.root)}};f=d([u(0,(0,t.Inject)(i.ThreadCommentModel)),u(1,t.IUniverInstanceService)],f);let p=class extends t.Disposable{constructor(e,t,r,a,o){super(),this._refRangeService=e,this._sheetsThreadCommentModel=t,this._threadCommentModel=r,this._selectionManagerService=a,this._commandService=o,l(this,`_disposableMap`,new Map),l(this,`_watcherMap`,new Map),l(this,`_handleRangeChange`,(e,t,r,a,o)=>{let s=r.id,c={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};return a?{redos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(a),commentId:s},silent:o}}],undos:[{id:i.UpdateCommentRefMutation.id,params:{unitId:e,subUnitId:t,payload:{ref:(0,n.serializeRange)(c),commentId:s},silent:o}}]}:{redos:[{id:i.DeleteCommentMutation.id,params:{unitId:e,subUnitId:t,commentId:s}}],undos:[{id:i.AddCommentMutation.id,params:{unitId:e,subUnitId:t,comment:r,sync:!0}}]}}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}-${t}-${n}`}_register(e,t,n){let i=n.id,a={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(this._getIdWithUnitId(e,t,i),this._refRangeService.registerRefRange(a,i=>{let o=(0,r.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(a,i,{selectionManagerService:this._selectionManagerService}),s=Array.isArray(o)?o[0]:o;return s&&s.startColumn===a.startColumn&&s.startRow===a.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,n,s,!1)},e,t))}_watch(e,n,r){let i=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row};this._watcherMap.set(this._getIdWithUnitId(e,n,i),this._refRangeService.watchRange(e,n,a,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._watcherMap.get(i))==null||r.dispose(),this._watcherMap.delete(i)}_unregister(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._disposableMap.get(i))==null||r.dispose(),this._disposableMap.delete(i)}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:r,root:i}=e,a=(0,n.singleReferenceToGrid)(i.ref),o={...i,...a};this._register(t,r,o),this._watch(t,r,o)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n}=e;switch(e.type){case`add`:{if(e.payload.parentId)return;let t={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,t),this._watch(e.unitId,e.subUnitId,t);break}case`delete`:this._unregister(t,n,e.payload.commentId),this._unwatch(t,n,e.payload.commentId);break;case`updateRef`:{let r=this._sheetsThreadCommentModel.getComment(t,n,e.payload.commentId);if(!r)return;this._unregister(t,n,e.payload.commentId);let i={...r,row:e.row,column:e.column};e.silent||(this._unwatch(t,n,e.payload.commentId),this._watch(t,n,i)),this._register(e.unitId,e.subUnitId,i);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};p=d([u(0,(0,t.Inject)(r.RefRangeService)),u(1,(0,t.Inject)(f)),u(2,(0,t.Inject)(i.ThreadCommentModel)),u(3,(0,t.Inject)(r.SheetsSelectionsService)),u(4,t.ICommandService)],p);var m=`@univerjs/sheets-thread-comment`,h=`0.25.1`;let g={},_=class extends t.Disposable{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._sheetInterceptorService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=r,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===r.RemoveSheetCommand.id){var n;let r=e.params,a=r.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=r.subUnitId||((n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId());if(!a||!o)return{redos:[],undos:[]};let s=this._threadCommentModel.ensureMap(a,o),c=Array.from(s.values()).filter(e=>!e.parentId),l=this._threadCommentDataSourceService.syncUpdateMutationToColla,u=[],d=[];return c.forEach(({children:e,...t})=>{u.push({id:i.DeleteCommentMutation.id,params:{unitId:a,subUnitId:o,commentId:t.id}}),d.push({id:i.AddCommentMutation.id,params:{unitId:a,subUnitId:o,comment:{...t,children:l?e:void 0},sync:!l}})}),{redos:u,undos:d}}else if(e.id===r.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:a}=e.params;if(!n||!r||!a)return{redos:[],undos:[]};let o=this._threadCommentModel.ensureMap(n,r),s=Array.from(o.values()).map(e=>({...e,subUnitId:a,id:(0,t.generateRandomId)(),threadId:(0,t.generateRandomId)()})).filter(e=>!e.parentId),c=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=[],u=[];return s.forEach(({children:e,...t})=>{l.push({id:i.AddCommentMutation.id,params:{unitId:n,subUnitId:a,comment:{...t,children:c?e:void 0},sync:!c}}),u.push({id:i.DeleteCommentMutation.id,params:{unitId:n,subUnitId:a,commentId:t.id}})}),{redos:l,undos:u}}return{redos:[],undos:[]}}}))}};_=d([u(0,t.IUniverInstanceService),u(1,(0,t.Inject)(r.SheetInterceptorService)),u(2,(0,t.Inject)(i.ThreadCommentModel)),u(3,i.IThreadCommentDataSourceService)],_);let v=class extends t.Plugin{constructor(e=g,t,n){super(),this._config=e,this._injector=t,this._commandService=n}onStarting(){[[f],[p],[_]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[p],[_]])}};l(v,`pluginName`,`SHEET_THREAD_COMMENT_BASE_PLUGIN`),l(v,`packageName`,m),l(v,`version`,h),l(v,`type`,t.UniverInstanceType.UNIVER_SHEET),v=d([(0,t.DependentOn)(i.UniverThreadCommentPlugin),u(1,(0,t.Inject)(t.Injector)),u(2,(0,t.Inject)(t.ICommandService))],v),Object.defineProperty(e,"SheetsThreadCommentModel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"SheetsThreadCommentRefRangeController",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"UniverSheetsThreadCommentPlugin",{enumerable:!0,get:function(){return v}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-thread-comment",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Thread comment integration for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -62,16 +62,16 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/core": "0.25.
|
|
66
|
-
"@univerjs/engine-formula": "0.25.
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/
|
|
65
|
+
"@univerjs/core": "0.25.1",
|
|
66
|
+
"@univerjs/engine-formula": "0.25.1",
|
|
67
|
+
"@univerjs/sheets": "0.25.1",
|
|
68
|
+
"@univerjs/thread-comment": "0.25.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"rxjs": "^7.8.2",
|
|
72
72
|
"typescript": "^6.0.3",
|
|
73
|
-
"vitest": "^4.1.
|
|
74
|
-
"@univerjs-infra/shared": "0.25.
|
|
73
|
+
"vitest": "^4.1.7",
|
|
74
|
+
"@univerjs-infra/shared": "0.25.1"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"test": "vitest run",
|