@univerjs/docs-thread-comment-ui 0.5.5-nightly.202501211606 → 0.5.5

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.
Files changed (3) hide show
  1. package/LICENSE +176 -0
  2. package/lib/es/index.js +399 -408
  3. package/package.json +8 -8
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/es/index.js CHANGED
@@ -1,46 +1,45 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { Inject, Disposable, CommandType, ICommandService, CustomDecorationType, sequenceExecute, UniverInstanceType, SHEET_EDITOR_UNITS, useDependency, IUniverInstanceService, Injector, isInternalEditorID, useObservable, UserManagerService, BuildTextUtils, DependentOn, Plugin, merge, IConfigService } from "@univerjs/core";
6
- import { IRenderManagerService, DocumentEditArea } from "@univerjs/engine-render";
7
- import { ThreadCommentPanelService, SetActiveCommentOperation, ThreadCommentPanel, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
8
- import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation, DocInterceptorService, DOC_INTERCEPTOR_POINT } from "@univerjs/docs";
9
- import { addCustomDecorationBySelectionFactory, deleteCustomDecorationFactory, DocSelectionRenderService, DocBackScrollRenderController, DocRenderController } from "@univerjs/docs-ui";
10
- import { IThreadCommentDataSourceService, AddCommentMutation, getDT, ThreadCommentModel } from "@univerjs/thread-comment";
11
- import { ISidebarService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService } from "@univerjs/ui";
12
- import { BehaviorSubject, Observable, debounceTime, filter } from "rxjs";
13
- import require$$0, { useMemo, useState, useEffect, forwardRef, useRef, createElement } from "react";
14
- const PLUGIN_NAME = "DOC_THREAD_COMMENT_UI_PLUGIN", DEFAULT_DOC_SUBUNIT_ID = "default_doc", DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "docs-thread-comment-ui.config", defaultPluginConfig = {};
15
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
16
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
17
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
18
- return kind && result && __defProp$4(target, key, result), result;
19
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
20
- let DocThreadCommentService = (_a = class extends Disposable {
21
- constructor(_sidebarService, _threadCommentPanelService) {
1
+ var Re = Object.defineProperty;
2
+ var ye = (e, t, r) => t in e ? Re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var K = (e, t, r) => ye(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { Inject as v, Disposable as B, CommandType as w, ICommandService as M, CustomDecorationType as X, sequenceExecute as se, UniverInstanceType as S, SHEET_EDITOR_UNITS as Te, useDependency as P, IUniverInstanceService as F, Injector as de, isInternalEditorID as ce, useObservable as G, UserManagerService as Ue, BuildTextUtils as Pe, DependentOn as Ee, Plugin as we, merge as Ne, IConfigService as Ae } from "@univerjs/core";
5
+ import { IRenderManagerService as L, DocumentEditArea as te } from "@univerjs/engine-render";
6
+ import { ThreadCommentPanelService as T, SetActiveCommentOperation as ae, ThreadCommentPanel as $e, UniverThreadCommentUIPlugin as Ve } from "@univerjs/thread-comment-ui";
7
+ import { DocSelectionManagerService as H, DocSkeletonManagerService as je, RichTextEditingMutation as me, SetTextSelectionsOperation as Be, DocInterceptorService as Fe, DOC_INTERCEPTOR_POINT as Le } from "@univerjs/docs";
8
+ import { addCustomDecorationBySelectionFactory as He, deleteCustomDecorationFactory as We, DocSelectionRenderService as qe, DocBackScrollRenderController as Je, DocRenderController as Ke } from "@univerjs/docs-ui";
9
+ import { IThreadCommentDataSourceService as Ge, AddCommentMutation as Ze, getDT as ze, ThreadCommentModel as le } from "@univerjs/thread-comment";
10
+ import { ISidebarService as W, MenuItemType as ue, getMenuHiddenObservable as fe, RibbonStartGroup as Ye, ContextMenuPosition as Qe, ContextMenuGroup as Xe, ComponentManager as ke, IMenuManagerService as et } from "@univerjs/ui";
11
+ import { BehaviorSubject as tt, Observable as he, debounceTime as Ce, filter as nt } from "rxjs";
12
+ import rt, { useMemo as Z, useState as it, useEffect as ot, forwardRef as _e, useRef as st, createElement as pe } from "react";
13
+ const dt = "DOC_THREAD_COMMENT_UI_PLUGIN", I = "default_doc", ct = "docs-thread-comment-ui.config", ne = {};
14
+ var at = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, lt = (e, t, r, n) => {
15
+ for (var i = n > 1 ? void 0 : n ? mt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
16
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
17
+ return n && i && at(t, r, i), i;
18
+ }, re = (e, t) => (r, n) => t(r, n, e);
19
+ let R = class extends B {
20
+ constructor(t, r) {
22
21
  super();
23
- __publicField(this, "_addingComment$", new BehaviorSubject(void 0));
24
- __publicField(this, "addingComment$", this._addingComment$.asObservable());
25
- this._sidebarService = _sidebarService, this._threadCommentPanelService = _threadCommentPanelService, this.disposeWithMe(() => {
22
+ K(this, "_addingComment$", new tt(void 0));
23
+ K(this, "addingComment$", this._addingComment$.asObservable());
24
+ this._sidebarService = t, this._threadCommentPanelService = r, this.disposeWithMe(() => {
26
25
  this._addingComment$.complete();
27
26
  });
28
27
  }
29
28
  get addingComment() {
30
29
  return this._addingComment$.getValue();
31
30
  }
32
- startAdd(comment) {
33
- this._addingComment$.next(comment);
31
+ startAdd(t) {
32
+ this._addingComment$.next(t);
34
33
  }
35
34
  endAdd() {
36
35
  this._addingComment$.next(void 0);
37
36
  }
38
- }, __name(_a, "DocThreadCommentService"), _a);
39
- DocThreadCommentService = __decorateClass$4([
40
- __decorateParam$4(0, ISidebarService),
41
- __decorateParam$4(1, Inject(ThreadCommentPanelService))
42
- ], DocThreadCommentService);
43
- var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
37
+ };
38
+ R = lt([
39
+ re(0, W),
40
+ re(1, v(T))
41
+ ], R);
42
+ var z = { exports: {} }, E = {};
44
43
  /**
45
44
  * @license React
46
45
  * react-jsx-runtime.production.min.js
@@ -50,269 +49,265 @@ var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
50
49
  * This source code is licensed under the MIT license found in the
51
50
  * LICENSE file in the root directory of this source tree.
52
51
  */
53
- var hasRequiredReactJsxRuntime_production_min;
54
- function requireReactJsxRuntime_production_min() {
55
- if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
56
- hasRequiredReactJsxRuntime_production_min = 1;
57
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
58
- function q(c, a, g) {
59
- var b, d = {}, e = null, h = null;
60
- g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
61
- for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
62
- if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
63
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
52
+ var ie;
53
+ function ut() {
54
+ if (ie) return E;
55
+ ie = 1;
56
+ var e = rt, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, i = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
57
+ function s(d, a, u) {
58
+ var c, f = {}, C = null, _ = null;
59
+ u !== void 0 && (C = "" + u), a.key !== void 0 && (C = "" + a.key), a.ref !== void 0 && (_ = a.ref);
60
+ for (c in a) n.call(a, c) && !o.hasOwnProperty(c) && (f[c] = a[c]);
61
+ if (d && d.defaultProps) for (c in a = d.defaultProps, a) f[c] === void 0 && (f[c] = a[c]);
62
+ return { $$typeof: t, type: d, key: C, ref: _, props: f, _owner: i.current };
64
63
  }
65
- return __name(q, "q"), reactJsxRuntime_production_min.Fragment = l, reactJsxRuntime_production_min.jsx = q, reactJsxRuntime_production_min.jsxs = q, reactJsxRuntime_production_min;
64
+ return E.Fragment = r, E.jsx = s, E.jsxs = s, E;
66
65
  }
67
- __name(requireReactJsxRuntime_production_min, "requireReactJsxRuntime_production_min");
68
- var hasRequiredJsxRuntime;
69
- function requireJsxRuntime() {
70
- return hasRequiredJsxRuntime || (hasRequiredJsxRuntime = 1, jsxRuntime.exports = requireReactJsxRuntime_production_min()), jsxRuntime.exports;
66
+ var oe;
67
+ function ft() {
68
+ return oe || (oe = 1, z.exports = ut()), z.exports;
71
69
  }
72
- __name(requireJsxRuntime, "requireJsxRuntime");
73
- var jsxRuntimeExports = requireJsxRuntime();
74
- const AddDocCommentComment = {
70
+ var ht = ft();
71
+ const ve = {
75
72
  id: "docs.command.add-comment",
76
- type: CommandType.COMMAND,
77
- async handler(accessor, params) {
78
- if (!params)
73
+ type: w.COMMAND,
74
+ async handler(e, t) {
75
+ if (!t)
79
76
  return !1;
80
- const { comment: originComment, unitId } = params, comment = await accessor.get(IThreadCommentDataSourceService).addComment(originComment), commandService = accessor.get(ICommandService), doMutation = addCustomDecorationBySelectionFactory(
81
- accessor,
77
+ const { comment: r, unitId: n } = t, o = await e.get(Ge).addComment(r), s = e.get(M), d = He(
78
+ e,
82
79
  {
83
- id: comment.threadId,
84
- type: CustomDecorationType.COMMENT,
85
- unitId
80
+ id: o.threadId,
81
+ type: X.COMMENT,
82
+ unitId: n
86
83
  }
87
84
  );
88
- if (doMutation) {
89
- const addComment = {
90
- id: AddCommentMutation.id,
85
+ if (d) {
86
+ const a = {
87
+ id: Ze.id,
91
88
  params: {
92
- unitId,
93
- subUnitId: DEFAULT_DOC_SUBUNIT_ID,
94
- comment
89
+ unitId: n,
90
+ subUnitId: I,
91
+ comment: o
95
92
  }
96
- }, activeOperation = {
97
- id: SetActiveCommentOperation.id,
93
+ }, u = {
94
+ id: ae.id,
98
95
  params: {
99
- unitId,
100
- subUnitId: DEFAULT_DOC_SUBUNIT_ID,
101
- commentId: comment.id
96
+ unitId: n,
97
+ subUnitId: I,
98
+ commentId: o.id
102
99
  }
103
100
  };
104
- return (await sequenceExecute([addComment, doMutation, activeOperation], commandService)).result;
101
+ return (await se([a, d, u], s)).result;
105
102
  }
106
103
  return !1;
107
104
  }
108
- }, DeleteDocCommentComment = {
105
+ }, ge = {
109
106
  id: "docs.command.delete-comment",
110
- type: CommandType.COMMAND,
111
- async handler(accessor, params) {
112
- if (!params)
107
+ type: w.COMMAND,
108
+ async handler(e, t) {
109
+ if (!t)
113
110
  return !1;
114
- const { commentId, unitId } = params, commandService = accessor.get(ICommandService), doMutation = deleteCustomDecorationFactory(accessor, {
115
- id: commentId,
116
- unitId
111
+ const { commentId: r, unitId: n } = t, i = e.get(M), o = We(e, {
112
+ id: r,
113
+ unitId: n
117
114
  });
118
- return doMutation ? (await sequenceExecute([doMutation], commandService)).result : !1;
115
+ return o ? (await se([o], i)).result : !1;
119
116
  }
120
- }, shouldDisableAddComment = /* @__PURE__ */ __name((accessor) => {
121
- const renderManagerService = accessor.get(IRenderManagerService), docSelectionManagerService = accessor.get(DocSelectionManagerService), render2 = renderManagerService.getCurrent(), skeleton = render2 == null ? void 0 : render2.with(DocSkeletonManagerService).getSkeleton(), editArea = skeleton == null ? void 0 : skeleton.getViewModel().getEditArea();
122
- if (editArea === DocumentEditArea.FOOTER || editArea === DocumentEditArea.HEADER)
117
+ }, Ie = (e) => {
118
+ const t = e.get(L), r = e.get(H), n = t.getCurrent(), i = n == null ? void 0 : n.with(je).getSkeleton(), o = i == null ? void 0 : i.getViewModel().getEditArea();
119
+ if (o === te.FOOTER || o === te.HEADER)
123
120
  return !0;
124
- const range = docSelectionManagerService.getActiveTextRange();
125
- return !!(range == null || range.collapsed);
126
- }, "shouldDisableAddComment");
127
- function AddDocCommentMenuItemFactory(accessor) {
121
+ const s = r.getActiveTextRange();
122
+ return !!(s == null || s.collapsed);
123
+ };
124
+ function Ct(e) {
128
125
  return {
129
- id: StartAddCommentOperation.id,
130
- type: MenuItemType.BUTTON,
126
+ id: q.id,
127
+ type: ue.BUTTON,
131
128
  icon: "CommentSingle",
132
129
  title: "threadCommentUI.panel.addComment",
133
130
  tooltip: "threadCommentUI.panel.addComment",
134
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, void 0, SHEET_EDITOR_UNITS),
135
- disabled$: new Observable(function(subscribe) {
136
- const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
137
- subscribe.next(shouldDisableAddComment(accessor));
131
+ hidden$: fe(e, S.UNIVER_DOC, void 0, Te),
132
+ disabled$: new he(function(t) {
133
+ const n = e.get(H).textSelection$.pipe(Ce(16)).subscribe(() => {
134
+ t.next(Ie(e));
138
135
  });
139
136
  return () => {
140
- observer.unsubscribe();
137
+ n.unsubscribe();
141
138
  };
142
139
  })
143
140
  };
144
141
  }
145
- __name(AddDocCommentMenuItemFactory, "AddDocCommentMenuItemFactory");
146
- function ToolbarDocCommentMenuItemFactory(accessor) {
142
+ function _t(e) {
147
143
  return {
148
- id: ToggleCommentPanelOperation.id,
149
- type: MenuItemType.BUTTON,
144
+ id: ee.id,
145
+ type: ue.BUTTON,
150
146
  icon: "CommentSingle",
151
147
  title: "threadCommentUI.panel.addComment",
152
148
  tooltip: "threadCommentUI.panel.addComment",
153
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
149
+ hidden$: fe(e, S.UNIVER_DOC)
154
150
  };
155
151
  }
156
- __name(ToolbarDocCommentMenuItemFactory, "ToolbarDocCommentMenuItemFactory");
157
- const DocThreadCommentPanel = /* @__PURE__ */ __name(() => {
158
- const univerInstanceService = useDependency(IUniverInstanceService), injector = useDependency(Injector), doc$ = useMemo(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).pipe(filter((doc2) => !!doc2 && !isInternalEditorID(doc2.getUnitId()))), [univerInstanceService]), doc = useObservable(doc$), subUnitId$ = useMemo(() => new Observable((sub) => sub.next(DEFAULT_DOC_SUBUNIT_ID)), []), docSelectionManagerService = useDependency(DocSelectionManagerService), selectionChange$ = useMemo(
159
- () => docSelectionManagerService.textSelection$.pipe(debounceTime(16)),
160
- [docSelectionManagerService.textSelection$]
152
+ const y = () => {
153
+ const e = P(F), t = P(de), r = Z(() => e.getCurrentTypeOfUnit$(S.UNIVER_DOC).pipe(nt((m) => !!m && !ce(m.getUnitId()))), [e]), n = G(r), i = Z(() => new he((m) => m.next(I)), []), o = P(H), s = Z(
154
+ () => o.textSelection$.pipe(Ce(16)),
155
+ [o.textSelection$]
161
156
  );
162
- useObservable(selectionChange$);
163
- const commandService = useDependency(ICommandService), docCommentService = useDependency(DocThreadCommentService), tempComment = useObservable(docCommentService.addingComment$), [commentIds, setCommentIds] = useState([]);
164
- if (useEffect(() => {
165
- var _a6;
166
- const set = /* @__PURE__ */ new Set(), customRanges = doc == null ? void 0 : doc.getCustomDecorations();
167
- setCommentIds((_a6 = customRanges == null ? void 0 : customRanges.map((r) => r.id).filter((i) => {
168
- const hasRepeat = set.has(i);
169
- return set.add(i), !hasRepeat;
170
- })) != null ? _a6 : []);
171
- const dispose = commandService.onCommandExecuted((command) => {
172
- var _a7;
173
- if (command.id === RichTextEditingMutation.id) {
174
- const set2 = /* @__PURE__ */ new Set(), customRanges2 = doc == null ? void 0 : doc.getCustomDecorations();
175
- setCommentIds((_a7 = customRanges2 == null ? void 0 : customRanges2.map((r) => r.id).filter((i) => {
176
- const hasRepeat = set2.has(i);
177
- return set2.add(i), !hasRepeat;
178
- })) != null ? _a7 : []);
157
+ G(s);
158
+ const d = P(M), a = P(R), u = G(a.addingComment$), [c, f] = it([]);
159
+ if (ot(() => {
160
+ var b;
161
+ const m = /* @__PURE__ */ new Set(), l = n == null ? void 0 : n.getCustomDecorations();
162
+ f((b = l == null ? void 0 : l.map((h) => h.id).filter((h) => {
163
+ const O = m.has(h);
164
+ return m.add(h), !O;
165
+ })) != null ? b : []);
166
+ const g = d.onCommandExecuted((h) => {
167
+ var O;
168
+ if (h.id === me.id) {
169
+ const U = /* @__PURE__ */ new Set(), J = n == null ? void 0 : n.getCustomDecorations();
170
+ f((O = J == null ? void 0 : J.map((N) => N.id).filter((N) => {
171
+ const De = U.has(N);
172
+ return U.add(N), !De;
173
+ })) != null ? O : []);
179
174
  }
180
175
  });
181
176
  return () => {
182
- dispose.dispose();
177
+ g.dispose();
183
178
  };
184
- }, [commandService, doc]), !doc)
179
+ }, [d, n]), !n)
185
180
  return null;
186
- const isInValidSelection = shouldDisableAddComment(injector), unitId = doc.getUnitId();
187
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
188
- ThreadCommentPanel,
181
+ const C = Ie(t), _ = n.getUnitId();
182
+ return /* @__PURE__ */ ht.jsx(
183
+ $e,
189
184
  {
190
- unitId,
191
- subUnitId$,
192
- type: UniverInstanceType.UNIVER_DOC,
193
- onAdd: /* @__PURE__ */ __name(() => {
194
- commandService.executeCommand(StartAddCommentOperation.id);
195
- }, "onAdd"),
196
- getSubUnitName: /* @__PURE__ */ __name(() => "", "getSubUnitName"),
197
- disableAdd: isInValidSelection,
198
- tempComment,
199
- onAddComment: /* @__PURE__ */ __name((comment) => {
200
- if (!comment.parentId) {
201
- const params = {
202
- unitId,
203
- range: tempComment,
204
- comment
185
+ unitId: _,
186
+ subUnitId$: i,
187
+ type: S.UNIVER_DOC,
188
+ onAdd: () => {
189
+ d.executeCommand(q.id);
190
+ },
191
+ getSubUnitName: () => "",
192
+ disableAdd: C,
193
+ tempComment: u,
194
+ onAddComment: (m) => {
195
+ if (!m.parentId) {
196
+ const l = {
197
+ unitId: _,
198
+ range: u,
199
+ comment: m
205
200
  };
206
- return commandService.executeCommand(AddDocCommentComment.id, params), docCommentService.endAdd(), !1;
201
+ return d.executeCommand(ve.id, l), a.endAdd(), !1;
207
202
  }
208
203
  return !0;
209
- }, "onAddComment"),
210
- onDeleteComment: /* @__PURE__ */ __name((comment) => {
211
- if (!comment.parentId) {
212
- const params = {
213
- unitId,
214
- commentId: comment.id
204
+ },
205
+ onDeleteComment: (m) => {
206
+ if (!m.parentId) {
207
+ const l = {
208
+ unitId: _,
209
+ commentId: m.id
215
210
  };
216
- return commandService.executeCommand(DeleteDocCommentComment.id, params), !1;
211
+ return d.executeCommand(ge.id, l), !1;
217
212
  }
218
213
  return !0;
219
- }, "onDeleteComment"),
220
- showComments: commentIds
214
+ },
215
+ showComments: c
221
216
  }
222
217
  );
223
- }, "DocThreadCommentPanel");
224
- DocThreadCommentPanel.componentKey = "univer.doc.thread-comment-panel";
225
- const ShowCommentPanelOperation = {
218
+ };
219
+ y.componentKey = "univer.doc.thread-comment-panel";
220
+ const A = {
226
221
  id: "docs.operation.show-comment-panel",
227
- type: CommandType.OPERATION,
228
- handler(accessor, params) {
229
- var _a6;
230
- const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
231
- return (!panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey) && (sidebarService.open({
222
+ type: w.OPERATION,
223
+ handler(e, t) {
224
+ var i;
225
+ const r = e.get(T), n = e.get(W);
226
+ return (!r.panelVisible || ((i = n.options.children) == null ? void 0 : i.label) !== y.componentKey) && (n.open({
232
227
  header: { title: "threadCommentUI.panel.title" },
233
- children: { label: DocThreadCommentPanel.componentKey },
228
+ children: { label: y.componentKey },
234
229
  width: 320,
235
- onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
236
- }), panelService.setPanelVisible(!0)), params && panelService.setActiveComment(params == null ? void 0 : params.activeComment), !0;
230
+ onClose: () => r.setPanelVisible(!1)
231
+ }), r.setPanelVisible(!0)), t && r.setActiveComment(t == null ? void 0 : t.activeComment), !0;
237
232
  }
238
- }, ToggleCommentPanelOperation = {
233
+ }, ee = {
239
234
  id: "docs.operation.toggle-comment-panel",
240
- type: CommandType.OPERATION,
241
- handler(accessor) {
242
- var _a6;
243
- const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
244
- return !panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey ? (sidebarService.open({
235
+ type: w.OPERATION,
236
+ handler(e) {
237
+ var n;
238
+ const t = e.get(T), r = e.get(W);
239
+ return !t.panelVisible || ((n = r.options.children) == null ? void 0 : n.label) !== y.componentKey ? (r.open({
245
240
  header: { title: "threadCommentUI.panel.title" },
246
- children: { label: DocThreadCommentPanel.componentKey },
241
+ children: { label: y.componentKey },
247
242
  width: 320,
248
- onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
249
- }), panelService.setPanelVisible(!0)) : (sidebarService.close(), panelService.setPanelVisible(!1), panelService.setActiveComment(null)), !0;
243
+ onClose: () => t.setPanelVisible(!1)
244
+ }), t.setPanelVisible(!0)) : (r.close(), t.setPanelVisible(!1), t.setActiveComment(null)), !0;
250
245
  }
251
- }, StartAddCommentOperation = {
246
+ }, q = {
252
247
  id: "docs.operation.start-add-comment",
253
- type: CommandType.OPERATION,
254
- handler(accessor) {
255
- var _a6, _b, _c;
256
- const panelService = accessor.get(ThreadCommentPanelService), doc = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_DOC), docSelectionManagerService = accessor.get(DocSelectionManagerService), renderManagerService = accessor.get(IRenderManagerService), userManagerService = accessor.get(UserManagerService), docCommentService = accessor.get(DocThreadCommentService), commandService = accessor.get(ICommandService), sidebarService = accessor.get(ISidebarService), textRange = docSelectionManagerService.getActiveTextRange();
257
- if (!doc || !textRange)
248
+ type: w.OPERATION,
249
+ handler(e) {
250
+ var h, O, U;
251
+ const t = e.get(T), n = e.get(F).getCurrentUnitForType(S.UNIVER_DOC), i = e.get(H), o = e.get(L), s = e.get(Ue), d = e.get(R), a = e.get(M), u = e.get(W), c = i.getActiveTextRange();
252
+ if (!n || !c)
258
253
  return !1;
259
- const docSelectionRenderManager = (_a6 = renderManagerService.getRenderById(doc.getUnitId())) == null ? void 0 : _a6.with(DocSelectionRenderService);
260
- if (docSelectionRenderManager == null || docSelectionRenderManager.setReserveRangesStatus(!0), textRange.collapsed)
261
- return panelService.panelVisible ? (panelService.setPanelVisible(!1), sidebarService.close()) : commandService.executeCommand(ShowCommentPanelOperation.id), !0;
262
- commandService.executeCommand(ShowCommentPanelOperation.id);
263
- const unitId = doc.getUnitId(), dataStream = ((_c = (_b = doc.getBody()) == null ? void 0 : _b.dataStream) != null ? _c : "").slice(textRange.startOffset, textRange.endOffset), text = BuildTextUtils.transform.getPlainText(dataStream), subUnitId = DEFAULT_DOC_SUBUNIT_ID, commentId = "", comment = {
264
- unitId,
265
- subUnitId,
266
- id: commentId,
267
- ref: text,
268
- dT: getDT(),
269
- personId: userManagerService.getCurrentUser().userID,
254
+ const f = (h = o.getRenderById(n.getUnitId())) == null ? void 0 : h.with(qe);
255
+ if (f == null || f.setReserveRangesStatus(!0), c.collapsed)
256
+ return t.panelVisible ? (t.setPanelVisible(!1), u.close()) : a.executeCommand(A.id), !0;
257
+ a.executeCommand(A.id);
258
+ const C = n.getUnitId(), _ = ((U = (O = n.getBody()) == null ? void 0 : O.dataStream) != null ? U : "").slice(c.startOffset, c.endOffset), m = Pe.transform.getPlainText(_), l = I, g = "", b = {
259
+ unitId: C,
260
+ subUnitId: l,
261
+ id: g,
262
+ ref: m,
263
+ dT: ze(),
264
+ personId: s.getCurrentUser().userID,
270
265
  text: {
271
266
  dataStream: `\r
272
267
  `
273
268
  },
274
- startOffset: textRange.startOffset,
275
- endOffset: textRange.endOffset,
269
+ startOffset: c.startOffset,
270
+ endOffset: c.endOffset,
276
271
  collapsed: !0,
277
- threadId: commentId
272
+ threadId: g
278
273
  };
279
- return docSelectionRenderManager == null || docSelectionRenderManager.blur(), docCommentService.startAdd(comment), panelService.setActiveComment({
280
- unitId,
281
- subUnitId,
282
- commentId
274
+ return f == null || f.blur(), d.startAdd(b), t.setActiveComment({
275
+ unitId: C,
276
+ subUnitId: l,
277
+ commentId: g
283
278
  }), !0;
284
279
  }
285
280
  };
286
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
287
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
288
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
289
- return kind && result && __defProp$3(target, key, result), result;
290
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a2;
291
- let DocThreadCommentSelectionController = (_a2 = class extends Disposable {
292
- constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
293
- super(), this._threadCommentPanelService = _threadCommentPanelService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._docThreadCommentService = _docThreadCommentService, this._renderManagerService = _renderManagerService, this._threadCommentModel = _threadCommentModel, this._initSelectionChange(), this._initActiveCommandChange();
281
+ var pt = Object.defineProperty, vt = Object.getOwnPropertyDescriptor, gt = (e, t, r, n) => {
282
+ for (var i = n > 1 ? void 0 : n ? vt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
283
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
284
+ return n && i && pt(t, r, i), i;
285
+ }, x = (e, t) => (r, n) => t(r, n, e);
286
+ let $ = class extends B {
287
+ constructor(e, t, r, n, i, o) {
288
+ super(), this._threadCommentPanelService = e, this._univerInstanceService = t, this._commandService = r, this._docThreadCommentService = n, this._renderManagerService = i, this._threadCommentModel = o, this._initSelectionChange(), this._initActiveCommandChange();
294
289
  }
295
290
  _initSelectionChange() {
296
- let lastSelection;
291
+ let e;
297
292
  this.disposeWithMe(
298
- this._commandService.onCommandExecuted((commandInfo) => {
299
- var _a6, _b, _c, _d;
300
- if (commandInfo.id === SetTextSelectionsOperation.id) {
301
- const params = commandInfo.params, { unitId, ranges } = params;
302
- if (isInternalEditorID(unitId)) return;
303
- const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), primary = ranges[0];
304
- if ((lastSelection == null ? void 0 : lastSelection.startOffset) === (primary == null ? void 0 : primary.startOffset) && (lastSelection == null ? void 0 : lastSelection.endOffset) === (primary == null ? void 0 : primary.endOffset))
293
+ this._commandService.onCommandExecuted((t) => {
294
+ var r, n, i, o;
295
+ if (t.id === Be.id) {
296
+ const s = t.params, { unitId: d, ranges: a } = s;
297
+ if (ce(d)) return;
298
+ const u = this._univerInstanceService.getUnit(d, S.UNIVER_DOC), c = a[0];
299
+ if ((e == null ? void 0 : e.startOffset) === (c == null ? void 0 : c.startOffset) && (e == null ? void 0 : e.endOffset) === (c == null ? void 0 : c.endOffset))
305
300
  return;
306
- if (lastSelection = primary, primary && doc) {
307
- const { startOffset, endOffset, collapsed } = primary;
308
- let customRange;
309
- if (collapsed ? customRange = (_b = (_a6 = doc.getBody()) == null ? void 0 : _a6.customDecorations) == null ? void 0 : _b.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1) : customRange = (_d = (_c = doc.getBody()) == null ? void 0 : _c.customDecorations) == null ? void 0 : _d.find((value) => value.startIndex <= startOffset && value.endIndex >= endOffset - 1), customRange) {
310
- const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, customRange.id);
311
- comment && !comment.resolved && this._commandService.executeCommand(ShowCommentPanelOperation.id, {
301
+ if (e = c, c && u) {
302
+ const { startOffset: f, endOffset: C, collapsed: _ } = c;
303
+ let m;
304
+ if (_ ? m = (n = (r = u.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((l) => l.startIndex <= f && l.endIndex >= C - 1) : m = (o = (i = u.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.find((l) => l.startIndex <= f && l.endIndex >= C - 1), m) {
305
+ const l = this._threadCommentModel.getComment(d, I, m.id);
306
+ l && !l.resolved && this._commandService.executeCommand(A.id, {
312
307
  activeComment: {
313
- unitId,
314
- subUnitId: DEFAULT_DOC_SUBUNIT_ID,
315
- commentId: customRange.id
308
+ unitId: d,
309
+ subUnitId: I,
310
+ commentId: m.id
316
311
  }
317
312
  });
318
313
  return;
@@ -320,264 +315,260 @@ let DocThreadCommentSelectionController = (_a2 = class extends Disposable {
320
315
  }
321
316
  if (!this._threadCommentPanelService.activeCommentId)
322
317
  return;
323
- this._commandService.executeCommand(SetActiveCommentOperation.id);
318
+ this._commandService.executeCommand(ae.id);
324
319
  }
325
320
  })
326
321
  );
327
322
  }
328
323
  _initActiveCommandChange() {
329
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
330
- var _a6, _b, _c, _d;
331
- if (activeComment) {
332
- const doc = this._univerInstanceService.getUnit(activeComment.unitId);
333
- if (doc) {
334
- const backScrollController = (_a6 = this._renderManagerService.getRenderById(activeComment.unitId)) == null ? void 0 : _a6.with(DocBackScrollRenderController), customRange = (_c = (_b = doc.getBody()) == null ? void 0 : _b.customDecorations) == null ? void 0 : _c.find((range) => range.id === activeComment.commentId);
335
- customRange && backScrollController && backScrollController.scrollToRange({
336
- startOffset: customRange.startIndex,
337
- endOffset: customRange.endIndex,
324
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
325
+ var t, r, n, i;
326
+ if (e) {
327
+ const o = this._univerInstanceService.getUnit(e.unitId);
328
+ if (o) {
329
+ const s = (t = this._renderManagerService.getRenderById(e.unitId)) == null ? void 0 : t.with(Je), d = (n = (r = o.getBody()) == null ? void 0 : r.customDecorations) == null ? void 0 : n.find((a) => a.id === e.commentId);
330
+ d && s && s.scrollToRange({
331
+ startOffset: d.startIndex,
332
+ endOffset: d.endIndex,
338
333
  collapsed: !1
339
334
  });
340
335
  }
341
336
  }
342
- (!activeComment || activeComment.commentId !== ((_d = this._docThreadCommentService.addingComment) == null ? void 0 : _d.id)) && this._docThreadCommentService.endAdd();
337
+ (!e || e.commentId !== ((i = this._docThreadCommentService.addingComment) == null ? void 0 : i.id)) && this._docThreadCommentService.endAdd();
343
338
  }));
344
339
  }
345
- }, __name(_a2, "DocThreadCommentSelectionController"), _a2);
346
- DocThreadCommentSelectionController = __decorateClass$3([
347
- __decorateParam$3(0, Inject(ThreadCommentPanelService)),
348
- __decorateParam$3(1, IUniverInstanceService),
349
- __decorateParam$3(2, ICommandService),
350
- __decorateParam$3(3, Inject(DocThreadCommentService)),
351
- __decorateParam$3(4, IRenderManagerService),
352
- __decorateParam$3(5, Inject(ThreadCommentModel))
353
- ], DocThreadCommentSelectionController);
354
- var __assign = function() {
355
- return __assign = Object.assign || function(t) {
356
- for (var s, i = 1, n = arguments.length; i < n; i++) {
357
- s = arguments[i];
358
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
340
+ };
341
+ $ = gt([
342
+ x(0, v(T)),
343
+ x(1, F),
344
+ x(2, M),
345
+ x(3, v(R)),
346
+ x(4, L),
347
+ x(5, v(le))
348
+ ], $);
349
+ var p = function() {
350
+ return p = Object.assign || function(e) {
351
+ for (var t, r = 1, n = arguments.length; r < n; r++) {
352
+ t = arguments[r];
353
+ for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
359
354
  }
360
- return t;
361
- }, __assign.apply(this, arguments);
362
- }, __rest = function(s, e) {
363
- var t = {};
364
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
365
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
366
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
367
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
368
- return t;
369
- }, IconBase = forwardRef(function(props, ref) {
370
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
371
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
355
+ return e;
356
+ }, p.apply(this, arguments);
357
+ }, It = function(e, t) {
358
+ var r = {};
359
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
360
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
361
+ for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
362
+ t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (r[n[i]] = e[n[i]]);
363
+ return r;
364
+ }, Se = _e(function(e, t) {
365
+ var r = e.icon, n = e.id, i = e.className, o = e.extend, s = It(e, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(n, " ").concat(i || "").trim(), a = st("_".concat(Mt()));
366
+ return Oe(r, "".concat(n), { defIds: r.defIds, idSuffix: a.current }, p({ ref: t, className: d }, s), o);
372
367
  });
373
- function render(node, id, runtimeProps, rootProps, extend) {
374
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
375
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
368
+ function Oe(e, t, r, n, i) {
369
+ return pe(e.tag, p(p({ key: t }, St(e, r, i)), n), (Ot(e, r).children || []).map(function(o, s) {
370
+ return Oe(o, "".concat(t, "-").concat(e.tag, "-").concat(s), r, void 0, i);
376
371
  }));
377
372
  }
378
- __name(render, "render");
379
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
380
- var attrs = __assign({}, node.attrs);
381
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
382
- var defIds = runtimeProps.defIds;
383
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a6) {
384
- var key = _a6[0], value = _a6[1];
385
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
386
- })), attrs;
373
+ function St(e, t, r) {
374
+ var n = p({}, e.attrs);
375
+ r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
376
+ var i = t.defIds;
377
+ return !i || i.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(function(o) {
378
+ var s = o[0], d = o[1];
379
+ typeof d == "string" && (n[s] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
380
+ })), n;
387
381
  }
388
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
389
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
390
- var _a6, defIds = runtimeProps.defIds;
391
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a6 = node.children) === null || _a6 === void 0) && _a6.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
392
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
393
- }) }) : node;
382
+ function Ot(e, t) {
383
+ var r, n = t.defIds;
384
+ return !n || n.length === 0 ? e : e.tag === "defs" && (!((r = e.children) === null || r === void 0) && r.length) ? p(p({}, e), { children: e.children.map(function(i) {
385
+ return typeof i.attrs.id == "string" && n && n.indexOf(i.attrs.id) > -1 ? p(p({}, i), { attrs: p(p({}, i.attrs), { id: i.attrs.id + t.idSuffix }) }) : i;
386
+ }) }) : e;
394
387
  }
395
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
396
- function generateShortUuid() {
388
+ function Mt() {
397
389
  return Math.random().toString(36).substring(2, 8);
398
390
  }
399
- __name(generateShortUuid, "generateShortUuid");
400
- IconBase.displayName = "UniverIcon";
401
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CommentSingle = forwardRef(function(props, ref) {
402
- return createElement(IconBase, Object.assign({}, props, {
391
+ Se.displayName = "UniverIcon";
392
+ var bt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Me = _e(function(e, t) {
393
+ return pe(Se, Object.assign({}, e, {
403
394
  id: "comment-single",
404
- ref,
405
- icon: element
395
+ ref: t,
396
+ icon: bt
406
397
  }));
407
398
  });
408
- CommentSingle.displayName = "CommentSingle";
409
- const menuSchema = {
410
- [RibbonStartGroup.OTHERS]: {
411
- [ToggleCommentPanelOperation.id]: {
399
+ Me.displayName = "CommentSingle";
400
+ const xt = {
401
+ [Ye.OTHERS]: {
402
+ [ee.id]: {
412
403
  order: 1,
413
- menuItemFactory: ToolbarDocCommentMenuItemFactory
404
+ menuItemFactory: _t
414
405
  }
415
406
  },
416
- [ContextMenuPosition.MAIN_AREA]: {
417
- [ContextMenuGroup.DATA]: {
418
- [StartAddCommentOperation.id]: {
407
+ [Qe.MAIN_AREA]: {
408
+ [Xe.DATA]: {
409
+ [q.id]: {
419
410
  order: 1,
420
- menuItemFactory: AddDocCommentMenuItemFactory
411
+ menuItemFactory: Ct
421
412
  }
422
413
  }
423
414
  }
424
415
  };
425
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
426
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
427
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
428
- return kind && result && __defProp$2(target, key, result), result;
429
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
430
- let DocThreadCommentUIController = (_a3 = class extends Disposable {
431
- constructor(_commandService, _menuManagerService, _componentManager) {
432
- super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._initCommands(), this._initMenus(), this._initComponents();
416
+ var Dt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, yt = (e, t, r, n) => {
417
+ for (var i = n > 1 ? void 0 : n ? Rt(t, r) : t, o = e.length - 1, s; o >= 0; o--)
418
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
419
+ return n && i && Dt(t, r, i), i;
420
+ }, Y = (e, t) => (r, n) => t(r, n, e);
421
+ let V = class extends B {
422
+ constructor(e, t, r) {
423
+ super(), this._commandService = e, this._menuManagerService = t, this._componentManager = r, this._initCommands(), this._initMenus(), this._initComponents();
433
424
  }
434
425
  _initCommands() {
435
426
  [
436
- AddDocCommentComment,
437
- DeleteDocCommentComment,
438
- ShowCommentPanelOperation,
439
- StartAddCommentOperation,
440
- ToggleCommentPanelOperation
441
- ].forEach((command) => {
442
- this.disposeWithMe(this._commandService.registerCommand(command));
427
+ ve,
428
+ ge,
429
+ A,
430
+ q,
431
+ ee
432
+ ].forEach((e) => {
433
+ this.disposeWithMe(this._commandService.registerCommand(e));
443
434
  });
444
435
  }
445
436
  _initMenus() {
446
- this._menuManagerService.mergeMenu(menuSchema);
437
+ this._menuManagerService.mergeMenu(xt);
447
438
  }
448
439
  _initComponents() {
449
- [DocThreadCommentPanel].forEach((comp) => {
450
- this.disposeWithMe(this._componentManager.register(comp.componentKey, comp));
451
- }), this.disposeWithMe(this._componentManager.register("CommentSingle", CommentSingle));
440
+ [y].forEach((e) => {
441
+ this.disposeWithMe(this._componentManager.register(e.componentKey, e));
442
+ }), this.disposeWithMe(this._componentManager.register("CommentSingle", Me));
452
443
  }
453
- }, __name(_a3, "DocThreadCommentUIController"), _a3);
454
- DocThreadCommentUIController = __decorateClass$2([
455
- __decorateParam$2(0, ICommandService),
456
- __decorateParam$2(1, IMenuManagerService),
457
- __decorateParam$2(2, Inject(ComponentManager))
458
- ], DocThreadCommentUIController);
459
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
460
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
461
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
462
- return kind && result && __defProp$1(target, key, result), result;
463
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a4;
464
- let DocThreadCommentRenderController = (_a4 = class extends Disposable {
465
- constructor(_context, _docInterceptorService, _threadCommentPanelService, _docRenderController, _univerInstanceService, _threadCommentModel, _commandService) {
466
- super(), this._context = _context, this._docInterceptorService = _docInterceptorService, this._threadCommentPanelService = _threadCommentPanelService, this._docRenderController = _docRenderController, this._univerInstanceService = _univerInstanceService, this._threadCommentModel = _threadCommentModel, this._commandService = _commandService, this._interceptorViewModel(), this._initReRender(), this._initSyncComments();
444
+ };
445
+ V = yt([
446
+ Y(0, M),
447
+ Y(1, et),
448
+ Y(2, v(ke))
449
+ ], V);
450
+ var Tt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, Pt = (e, t, r, n) => {
451
+ for (var i = n > 1 ? void 0 : n ? Ut(t, r) : t, o = e.length - 1, s; o >= 0; o--)
452
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
453
+ return n && i && Tt(t, r, i), i;
454
+ }, D = (e, t) => (r, n) => t(r, n, e);
455
+ let k = class extends B {
456
+ constructor(e, t, r, n, i, o, s) {
457
+ super(), this._context = e, this._docInterceptorService = t, this._threadCommentPanelService = r, this._docRenderController = n, this._univerInstanceService = i, this._threadCommentModel = o, this._commandService = s, this._interceptorViewModel(), this._initReRender(), this._initSyncComments();
467
458
  }
468
459
  _initReRender() {
469
- this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
470
- var _a6;
471
- if (activeComment) {
472
- this._docRenderController.reRender(activeComment.unitId);
460
+ this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((e) => {
461
+ var r;
462
+ if (e) {
463
+ this._docRenderController.reRender(e.unitId);
473
464
  return;
474
465
  }
475
- const unitId = (_a6 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a6.getUnitId();
476
- unitId && this._docRenderController.reRender(unitId);
477
- })), this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
478
- update.type === "resolve" && this._docRenderController.reRender(update.unitId);
466
+ const t = (r = this._univerInstanceService.getCurrentUnitForType(S.UNIVER_DOC)) == null ? void 0 : r.getUnitId();
467
+ t && this._docRenderController.reRender(t);
468
+ })), this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((e) => {
469
+ e.type === "resolve" && this._docRenderController.reRender(e.unitId);
479
470
  }));
480
471
  }
481
472
  _interceptorViewModel() {
482
- this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION, {
483
- handler: /* @__PURE__ */ __name((data, pos, next) => {
484
- if (!data)
485
- return next(data);
486
- const { unitId, index, customDecorations } = pos, activeComment = this._threadCommentPanelService.activeCommentId, { commentId, unitId: commentUnitID } = activeComment || {}, activeCustomDecoration = customDecorations.find((i) => i.id === commentId), comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, data.id);
487
- if (!comment)
488
- return next({
489
- ...data,
473
+ this._docInterceptorService.intercept(Le.CUSTOM_DECORATION, {
474
+ handler: (e, t, r) => {
475
+ if (!e)
476
+ return r(e);
477
+ const { unitId: n, index: i, customDecorations: o } = t, s = this._threadCommentPanelService.activeCommentId, { commentId: d, unitId: a } = s || {}, u = o.find((_) => _.id === d), c = this._threadCommentModel.getComment(n, I, e.id);
478
+ if (!c)
479
+ return r({
480
+ ...e,
490
481
  show: !1
491
482
  });
492
- const isActiveIndex = activeCustomDecoration && index >= activeCustomDecoration.startIndex && index <= activeCustomDecoration.endIndex, isActive = commentUnitID === unitId && data.id === commentId;
493
- return next({
494
- ...data,
495
- active: isActive || isActiveIndex,
496
- show: !comment.resolved
483
+ const f = u && i >= u.startIndex && i <= u.endIndex, C = a === n && e.id === d;
484
+ return r({
485
+ ...e,
486
+ active: C || f,
487
+ show: !c.resolved
497
488
  });
498
- }, "handler")
489
+ }
499
490
  });
500
491
  }
501
492
  _initSyncComments() {
502
- var _a6, _b, _c;
503
- const unitId = this._context.unit.getUnitId(), subUnitId = DEFAULT_DOC_SUBUNIT_ID, threadIds = (_c = (_b = (_a6 = this._context.unit.getBody()) == null ? void 0 : _a6.customDecorations) == null ? void 0 : _b.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) != null ? _c : [];
504
- threadIds.forEach((id) => {
505
- this._threadCommentModel.getComment(unitId, subUnitId, id) || this._threadCommentModel.addComment(unitId, subUnitId, { id, threadId: id, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId, subUnitId });
506
- }), threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), DEFAULT_DOC_SUBUNIT_ID, threadIds);
507
- let prevThreadIds = threadIds.sort();
508
- this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
509
- var _a7, _b2, _c2;
510
- if (commandInfo.id === RichTextEditingMutation.id) {
511
- if (commandInfo.params.unitId !== this._context.unit.getUnitId())
493
+ var i, o, s;
494
+ const e = this._context.unit.getUnitId(), t = I, r = (s = (o = (i = this._context.unit.getBody()) == null ? void 0 : i.customDecorations) == null ? void 0 : o.filter((d) => d.type === X.COMMENT).map((d) => d.id)) != null ? s : [];
495
+ r.forEach((d) => {
496
+ this._threadCommentModel.getComment(e, t, d) || this._threadCommentModel.addComment(e, t, { id: d, threadId: d, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId: e, subUnitId: t });
497
+ }), r.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), I, r);
498
+ let n = r.sort();
499
+ this.disposeWithMe(this._commandService.onCommandExecuted((d) => {
500
+ var a, u, c;
501
+ if (d.id === me.id) {
502
+ if (d.params.unitId !== this._context.unit.getUnitId())
512
503
  return;
513
- const currentThreadIds = (_c2 = (_b2 = (_a7 = this._context.unit.getBody()) == null ? void 0 : _a7.customDecorations) == null ? void 0 : _b2.filter((i) => i.type === CustomDecorationType.COMMENT).map((i) => i.id)) != null ? _c2 : [], currentThreadIdsSorted = currentThreadIds.sort();
514
- if (JSON.stringify(prevThreadIds) !== JSON.stringify(currentThreadIdsSorted)) {
515
- const preIds = new Set(prevThreadIds), currentIds = new Set(currentThreadIdsSorted), addIds = /* @__PURE__ */ new Set(), deleteIds = /* @__PURE__ */ new Set();
516
- currentThreadIds.forEach((id) => {
517
- preIds.has(id) || addIds.add(id);
518
- }), prevThreadIds.forEach((id) => {
519
- currentIds.has(id) || deleteIds.add(id);
520
- }), prevThreadIds = currentThreadIdsSorted, addIds.forEach((id) => {
521
- this._threadCommentModel.getComment(unitId, subUnitId, id) || this._threadCommentModel.addComment(unitId, subUnitId, { id, threadId: id, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId, subUnitId });
522
- }), this._threadCommentModel.syncThreadComments(unitId, subUnitId, [...addIds]);
504
+ const C = (c = (u = (a = this._context.unit.getBody()) == null ? void 0 : a.customDecorations) == null ? void 0 : u.filter((m) => m.type === X.COMMENT).map((m) => m.id)) != null ? c : [], _ = C.sort();
505
+ if (JSON.stringify(n) !== JSON.stringify(_)) {
506
+ const m = new Set(n), l = new Set(_), g = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
507
+ C.forEach((h) => {
508
+ m.has(h) || g.add(h);
509
+ }), n.forEach((h) => {
510
+ l.has(h) || b.add(h);
511
+ }), n = _, g.forEach((h) => {
512
+ this._threadCommentModel.getComment(e, t, h) || this._threadCommentModel.addComment(e, t, { id: h, threadId: h, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId: e, subUnitId: t });
513
+ }), this._threadCommentModel.syncThreadComments(e, t, [...g]);
523
514
  }
524
515
  }
525
516
  }));
526
517
  }
527
- }, __name(_a4, "DocThreadCommentRenderController"), _a4);
528
- DocThreadCommentRenderController = __decorateClass$1([
529
- __decorateParam$1(1, Inject(DocInterceptorService)),
530
- __decorateParam$1(2, Inject(ThreadCommentPanelService)),
531
- __decorateParam$1(3, Inject(DocRenderController)),
532
- __decorateParam$1(4, IUniverInstanceService),
533
- __decorateParam$1(5, Inject(ThreadCommentModel)),
534
- __decorateParam$1(6, ICommandService)
535
- ], DocThreadCommentRenderController);
536
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
537
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
538
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
539
- return kind && result && __defProp2(target, key, result), result;
540
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a5;
541
- let UniverDocsThreadCommentUIPlugin = (_a5 = class extends Plugin {
542
- constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
543
- super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._configService = _configService;
544
- const { menu, ...rest } = merge(
518
+ };
519
+ k = Pt([
520
+ D(1, v(Fe)),
521
+ D(2, v(T)),
522
+ D(3, v(Ke)),
523
+ D(4, F),
524
+ D(5, v(le)),
525
+ D(6, M)
526
+ ], k);
527
+ var be = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, wt = (e, t, r) => t in e ? be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, Nt = (e, t, r, n) => {
528
+ for (var i = n > 1 ? void 0 : n ? Et(t, r) : t, o = e.length - 1, s; o >= 0; o--)
529
+ (s = e[o]) && (i = (n ? s(t, r, i) : s(i)) || i);
530
+ return n && i && be(t, r, i), i;
531
+ }, Q = (e, t) => (r, n) => t(r, n, e), xe = (e, t, r) => wt(e, typeof t != "symbol" ? t + "" : t, r);
532
+ let j = class extends we {
533
+ constructor(e = ne, t, r, n) {
534
+ super(), this._config = e, this._injector = t, this._renderManagerSrv = r, this._configService = n;
535
+ const { menu: i, ...o } = Ne(
545
536
  {},
546
- defaultPluginConfig,
537
+ ne,
547
538
  this._config
548
539
  );
549
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
540
+ i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(ct, o);
550
541
  }
551
542
  onStarting() {
552
543
  [
553
- [DocThreadCommentUIController],
554
- [DocThreadCommentSelectionController],
555
- [DocThreadCommentService]
556
- ].forEach((dep) => {
557
- this._injector.add(dep);
544
+ [V],
545
+ [$],
546
+ [R]
547
+ ].forEach((e) => {
548
+ this._injector.add(e);
558
549
  });
559
550
  }
560
551
  onRendered() {
561
- this._initRenderModule(), this._injector.get(DocThreadCommentSelectionController), this._injector.get(DocThreadCommentUIController);
552
+ this._initRenderModule(), this._injector.get($), this._injector.get(V);
562
553
  }
563
554
  _initRenderModule() {
564
- [DocThreadCommentRenderController].forEach((dep) => {
565
- this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, dep);
555
+ [k].forEach((e) => {
556
+ this._renderManagerSrv.registerRenderModule(S.UNIVER_DOC, e);
566
557
  });
567
558
  }
568
- }, __name(_a5, "UniverDocsThreadCommentUIPlugin"), _a5);
569
- __publicField2(UniverDocsThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
570
- __publicField2(UniverDocsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
571
- UniverDocsThreadCommentUIPlugin = __decorateClass([
572
- DependentOn(UniverThreadCommentUIPlugin),
573
- __decorateParam(1, Inject(Injector)),
574
- __decorateParam(2, IRenderManagerService),
575
- __decorateParam(3, IConfigService)
576
- ], UniverDocsThreadCommentUIPlugin);
559
+ };
560
+ xe(j, "pluginName", dt);
561
+ xe(j, "type", S.UNIVER_DOC);
562
+ j = Nt([
563
+ Ee(Ve),
564
+ Q(1, v(de)),
565
+ Q(2, L),
566
+ Q(3, Ae)
567
+ ], j);
577
568
  export {
578
- AddDocCommentComment,
579
- DeleteDocCommentComment,
580
- ShowCommentPanelOperation,
581
- StartAddCommentOperation,
582
- UniverDocsThreadCommentUIPlugin
569
+ ve as AddDocCommentComment,
570
+ ge as DeleteDocCommentComment,
571
+ A as ShowCommentPanelOperation,
572
+ q as StartAddCommentOperation,
573
+ j as UniverDocsThreadCommentUIPlugin
583
574
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/docs-thread-comment-ui",
3
- "version": "0.5.5-nightly.202501211606",
3
+ "version": "0.5.5",
4
4
  "private": false,
5
5
  "description": "Univer thread comment plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -49,13 +49,13 @@
49
49
  "dependencies": {
50
50
  "@univerjs/icons": "^0.2.12",
51
51
  "clsx": "^2.1.1",
52
- "@univerjs/core": "0.5.5-nightly.202501211606",
53
- "@univerjs/docs-ui": "0.5.5-nightly.202501211606",
54
- "@univerjs/engine-render": "0.5.5-nightly.202501211606",
55
- "@univerjs/docs": "0.5.5-nightly.202501211606",
56
- "@univerjs/thread-comment": "0.5.5-nightly.202501211606",
57
- "@univerjs/thread-comment-ui": "0.5.5-nightly.202501211606",
58
- "@univerjs/ui": "0.5.5-nightly.202501211606"
52
+ "@univerjs/docs-ui": "0.5.5",
53
+ "@univerjs/docs": "0.5.5",
54
+ "@univerjs/engine-render": "0.5.5",
55
+ "@univerjs/thread-comment": "0.5.5",
56
+ "@univerjs/thread-comment-ui": "0.5.5",
57
+ "@univerjs/core": "0.5.5",
58
+ "@univerjs/ui": "0.5.5"
59
59
  },
60
60
  "devDependencies": {
61
61
  "postcss": "^8.4.49",