@univerjs/docs-thread-comment-ui 0.4.2 → 0.5.0-beta.0

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