@univerjs/docs-thread-comment-ui 0.5.4-nightly.202501200849 → 0.5.5-experimental.20250122-3362a4a
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/cjs/index.js +2 -10
- package/lib/es/index.js +390 -411
- package/lib/types/views/doc-thread-comment-panel/index.d.ts +16 -2
- package/lib/umd/index.js +2 -10
- package/package.json +10 -10
package/lib/es/index.js
CHANGED
|
@@ -1,313 +1,288 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 { jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useMemo, useState, useEffect, forwardRef, useRef, createElement } from "react";
|
|
15
|
+
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 = {};
|
|
16
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
17
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
18
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
19
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
20
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a;
|
|
21
|
+
let DocThreadCommentService = (_a = class extends Disposable {
|
|
22
|
+
constructor(_sidebarService, _threadCommentPanelService) {
|
|
21
23
|
super();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this._sidebarService =
|
|
24
|
+
__publicField(this, "_addingComment$", new BehaviorSubject(void 0));
|
|
25
|
+
__publicField(this, "addingComment$", this._addingComment$.asObservable());
|
|
26
|
+
this._sidebarService = _sidebarService, this._threadCommentPanelService = _threadCommentPanelService, this.disposeWithMe(() => {
|
|
25
27
|
this._addingComment$.complete();
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
get addingComment() {
|
|
29
31
|
return this._addingComment$.getValue();
|
|
30
32
|
}
|
|
31
|
-
startAdd(
|
|
32
|
-
this._addingComment$.next(
|
|
33
|
+
startAdd(comment) {
|
|
34
|
+
this._addingComment$.next(comment);
|
|
33
35
|
}
|
|
34
36
|
endAdd() {
|
|
35
37
|
this._addingComment$.next(void 0);
|
|
36
38
|
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
],
|
|
42
|
-
|
|
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 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 };
|
|
63
|
-
}
|
|
64
|
-
return E.Fragment = r, E.jsx = s, E.jsxs = s, E;
|
|
65
|
-
}
|
|
66
|
-
var oe;
|
|
67
|
-
function ft() {
|
|
68
|
-
return oe || (oe = 1, z.exports = ut()), z.exports;
|
|
69
|
-
}
|
|
70
|
-
var ht = ft();
|
|
71
|
-
const ve = {
|
|
39
|
+
}, __name(_a, "DocThreadCommentService"), _a);
|
|
40
|
+
DocThreadCommentService = __decorateClass$4([
|
|
41
|
+
__decorateParam$4(0, ISidebarService),
|
|
42
|
+
__decorateParam$4(1, Inject(ThreadCommentPanelService))
|
|
43
|
+
], DocThreadCommentService);
|
|
44
|
+
const AddDocCommentComment = {
|
|
72
45
|
id: "docs.command.add-comment",
|
|
73
|
-
type:
|
|
74
|
-
async handler(
|
|
75
|
-
if (!
|
|
46
|
+
type: CommandType.COMMAND,
|
|
47
|
+
async handler(accessor, params) {
|
|
48
|
+
if (!params)
|
|
76
49
|
return !1;
|
|
77
|
-
const { comment:
|
|
78
|
-
|
|
50
|
+
const { comment: originComment, unitId } = params, comment = await accessor.get(IThreadCommentDataSourceService).addComment(originComment), commandService = accessor.get(ICommandService), doMutation = addCustomDecorationBySelectionFactory(
|
|
51
|
+
accessor,
|
|
79
52
|
{
|
|
80
|
-
id:
|
|
81
|
-
type:
|
|
82
|
-
unitId
|
|
53
|
+
id: comment.threadId,
|
|
54
|
+
type: CustomDecorationType.COMMENT,
|
|
55
|
+
unitId
|
|
83
56
|
}
|
|
84
57
|
);
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
id:
|
|
58
|
+
if (doMutation) {
|
|
59
|
+
const addComment = {
|
|
60
|
+
id: AddCommentMutation.id,
|
|
88
61
|
params: {
|
|
89
|
-
unitId
|
|
90
|
-
subUnitId:
|
|
91
|
-
comment
|
|
62
|
+
unitId,
|
|
63
|
+
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
64
|
+
comment
|
|
92
65
|
}
|
|
93
|
-
},
|
|
94
|
-
id:
|
|
66
|
+
}, activeOperation = {
|
|
67
|
+
id: SetActiveCommentOperation.id,
|
|
95
68
|
params: {
|
|
96
|
-
unitId
|
|
97
|
-
subUnitId:
|
|
98
|
-
commentId:
|
|
69
|
+
unitId,
|
|
70
|
+
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
71
|
+
commentId: comment.id
|
|
99
72
|
}
|
|
100
73
|
};
|
|
101
|
-
return (await
|
|
74
|
+
return (await sequenceExecute([addComment, doMutation, activeOperation], commandService)).result;
|
|
102
75
|
}
|
|
103
76
|
return !1;
|
|
104
77
|
}
|
|
105
|
-
},
|
|
78
|
+
}, DeleteDocCommentComment = {
|
|
106
79
|
id: "docs.command.delete-comment",
|
|
107
|
-
type:
|
|
108
|
-
async handler(
|
|
109
|
-
if (!
|
|
80
|
+
type: CommandType.COMMAND,
|
|
81
|
+
async handler(accessor, params) {
|
|
82
|
+
if (!params)
|
|
110
83
|
return !1;
|
|
111
|
-
const { commentId
|
|
112
|
-
id:
|
|
113
|
-
unitId
|
|
84
|
+
const { commentId, unitId } = params, commandService = accessor.get(ICommandService), doMutation = deleteCustomDecorationFactory(accessor, {
|
|
85
|
+
id: commentId,
|
|
86
|
+
unitId
|
|
114
87
|
});
|
|
115
|
-
return
|
|
88
|
+
return doMutation ? (await sequenceExecute([doMutation], commandService)).result : !1;
|
|
116
89
|
}
|
|
117
|
-
},
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
90
|
+
}, shouldDisableAddComment = /* @__PURE__ */ __name((accessor) => {
|
|
91
|
+
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();
|
|
92
|
+
if (editArea === DocumentEditArea.FOOTER || editArea === DocumentEditArea.HEADER)
|
|
120
93
|
return !0;
|
|
121
|
-
const
|
|
122
|
-
return !!(
|
|
123
|
-
};
|
|
124
|
-
function
|
|
94
|
+
const range = docSelectionManagerService.getActiveTextRange();
|
|
95
|
+
return !!(range == null || range.collapsed);
|
|
96
|
+
}, "shouldDisableAddComment");
|
|
97
|
+
function AddDocCommentMenuItemFactory(accessor) {
|
|
125
98
|
return {
|
|
126
|
-
id:
|
|
127
|
-
type:
|
|
99
|
+
id: StartAddCommentOperation.id,
|
|
100
|
+
type: MenuItemType.BUTTON,
|
|
128
101
|
icon: "CommentSingle",
|
|
129
102
|
title: "threadCommentUI.panel.addComment",
|
|
130
103
|
tooltip: "threadCommentUI.panel.addComment",
|
|
131
|
-
hidden$:
|
|
132
|
-
disabled$: new
|
|
133
|
-
const
|
|
134
|
-
|
|
104
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC, void 0, SHEET_EDITOR_UNITS),
|
|
105
|
+
disabled$: new Observable(function(subscribe) {
|
|
106
|
+
const observer = accessor.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe(() => {
|
|
107
|
+
subscribe.next(shouldDisableAddComment(accessor));
|
|
135
108
|
});
|
|
136
109
|
return () => {
|
|
137
|
-
|
|
110
|
+
observer.unsubscribe();
|
|
138
111
|
};
|
|
139
112
|
})
|
|
140
113
|
};
|
|
141
114
|
}
|
|
142
|
-
|
|
115
|
+
__name(AddDocCommentMenuItemFactory, "AddDocCommentMenuItemFactory");
|
|
116
|
+
function ToolbarDocCommentMenuItemFactory(accessor) {
|
|
143
117
|
return {
|
|
144
|
-
id:
|
|
145
|
-
type:
|
|
118
|
+
id: ToggleCommentPanelOperation.id,
|
|
119
|
+
type: MenuItemType.BUTTON,
|
|
146
120
|
icon: "CommentSingle",
|
|
147
121
|
title: "threadCommentUI.panel.addComment",
|
|
148
122
|
tooltip: "threadCommentUI.panel.addComment",
|
|
149
|
-
hidden$:
|
|
123
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_DOC)
|
|
150
124
|
};
|
|
151
125
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
126
|
+
__name(ToolbarDocCommentMenuItemFactory, "ToolbarDocCommentMenuItemFactory");
|
|
127
|
+
const DocThreadCommentPanel = /* @__PURE__ */ __name(() => {
|
|
128
|
+
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(
|
|
129
|
+
() => docSelectionManagerService.textSelection$.pipe(debounceTime(16)),
|
|
130
|
+
[docSelectionManagerService.textSelection$]
|
|
156
131
|
);
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
-
var
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
return
|
|
165
|
-
})) != null ?
|
|
166
|
-
const
|
|
167
|
-
var
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
return
|
|
173
|
-
})) != null ?
|
|
132
|
+
useObservable(selectionChange$);
|
|
133
|
+
const commandService = useDependency(ICommandService), docCommentService = useDependency(DocThreadCommentService), tempComment = useObservable(docCommentService.addingComment$), [commentIds, setCommentIds] = useState([]);
|
|
134
|
+
if (useEffect(() => {
|
|
135
|
+
var _a6;
|
|
136
|
+
const set = /* @__PURE__ */ new Set(), customRanges = doc == null ? void 0 : doc.getCustomDecorations();
|
|
137
|
+
setCommentIds((_a6 = customRanges == null ? void 0 : customRanges.map((r) => r.id).filter((i) => {
|
|
138
|
+
const hasRepeat = set.has(i);
|
|
139
|
+
return set.add(i), !hasRepeat;
|
|
140
|
+
})) != null ? _a6 : []);
|
|
141
|
+
const dispose = commandService.onCommandExecuted((command) => {
|
|
142
|
+
var _a7;
|
|
143
|
+
if (command.id === RichTextEditingMutation.id) {
|
|
144
|
+
const set2 = /* @__PURE__ */ new Set(), customRanges2 = doc == null ? void 0 : doc.getCustomDecorations();
|
|
145
|
+
setCommentIds((_a7 = customRanges2 == null ? void 0 : customRanges2.map((r) => r.id).filter((i) => {
|
|
146
|
+
const hasRepeat = set2.has(i);
|
|
147
|
+
return set2.add(i), !hasRepeat;
|
|
148
|
+
})) != null ? _a7 : []);
|
|
174
149
|
}
|
|
175
150
|
});
|
|
176
151
|
return () => {
|
|
177
|
-
|
|
152
|
+
dispose.dispose();
|
|
178
153
|
};
|
|
179
|
-
}, [
|
|
154
|
+
}, [commandService, doc]), !doc)
|
|
180
155
|
return null;
|
|
181
|
-
const
|
|
182
|
-
return /* @__PURE__ */
|
|
183
|
-
|
|
156
|
+
const isInValidSelection = shouldDisableAddComment(injector), unitId = doc.getUnitId();
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
ThreadCommentPanel,
|
|
184
159
|
{
|
|
185
|
-
unitId
|
|
186
|
-
subUnitId
|
|
187
|
-
type:
|
|
188
|
-
onAdd: () => {
|
|
189
|
-
|
|
190
|
-
},
|
|
191
|
-
getSubUnitName: () => "",
|
|
192
|
-
disableAdd:
|
|
193
|
-
tempComment
|
|
194
|
-
onAddComment: (
|
|
195
|
-
if (!
|
|
196
|
-
const
|
|
197
|
-
unitId
|
|
198
|
-
range:
|
|
199
|
-
comment
|
|
160
|
+
unitId,
|
|
161
|
+
subUnitId$,
|
|
162
|
+
type: UniverInstanceType.UNIVER_DOC,
|
|
163
|
+
onAdd: /* @__PURE__ */ __name(() => {
|
|
164
|
+
commandService.executeCommand(StartAddCommentOperation.id);
|
|
165
|
+
}, "onAdd"),
|
|
166
|
+
getSubUnitName: /* @__PURE__ */ __name(() => "", "getSubUnitName"),
|
|
167
|
+
disableAdd: isInValidSelection,
|
|
168
|
+
tempComment,
|
|
169
|
+
onAddComment: /* @__PURE__ */ __name((comment) => {
|
|
170
|
+
if (!comment.parentId) {
|
|
171
|
+
const params = {
|
|
172
|
+
unitId,
|
|
173
|
+
range: tempComment,
|
|
174
|
+
comment
|
|
200
175
|
};
|
|
201
|
-
return
|
|
176
|
+
return commandService.executeCommand(AddDocCommentComment.id, params), docCommentService.endAdd(), !1;
|
|
202
177
|
}
|
|
203
178
|
return !0;
|
|
204
|
-
},
|
|
205
|
-
onDeleteComment: (
|
|
206
|
-
if (!
|
|
207
|
-
const
|
|
208
|
-
unitId
|
|
209
|
-
commentId:
|
|
179
|
+
}, "onAddComment"),
|
|
180
|
+
onDeleteComment: /* @__PURE__ */ __name((comment) => {
|
|
181
|
+
if (!comment.parentId) {
|
|
182
|
+
const params = {
|
|
183
|
+
unitId,
|
|
184
|
+
commentId: comment.id
|
|
210
185
|
};
|
|
211
|
-
return
|
|
186
|
+
return commandService.executeCommand(DeleteDocCommentComment.id, params), !1;
|
|
212
187
|
}
|
|
213
188
|
return !0;
|
|
214
|
-
},
|
|
215
|
-
showComments:
|
|
189
|
+
}, "onDeleteComment"),
|
|
190
|
+
showComments: commentIds
|
|
216
191
|
}
|
|
217
192
|
);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const
|
|
193
|
+
}, "DocThreadCommentPanel");
|
|
194
|
+
DocThreadCommentPanel.componentKey = "univer.doc.thread-comment-panel";
|
|
195
|
+
const ShowCommentPanelOperation = {
|
|
221
196
|
id: "docs.operation.show-comment-panel",
|
|
222
|
-
type:
|
|
223
|
-
handler(
|
|
224
|
-
var
|
|
225
|
-
const
|
|
226
|
-
return (!
|
|
197
|
+
type: CommandType.OPERATION,
|
|
198
|
+
handler(accessor, params) {
|
|
199
|
+
var _a6;
|
|
200
|
+
const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
|
|
201
|
+
return (!panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey) && (sidebarService.open({
|
|
227
202
|
header: { title: "threadCommentUI.panel.title" },
|
|
228
|
-
children: { label:
|
|
203
|
+
children: { label: DocThreadCommentPanel.componentKey },
|
|
229
204
|
width: 320,
|
|
230
|
-
onClose: () =>
|
|
231
|
-
}),
|
|
205
|
+
onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
|
|
206
|
+
}), panelService.setPanelVisible(!0)), params && panelService.setActiveComment(params == null ? void 0 : params.activeComment), !0;
|
|
232
207
|
}
|
|
233
|
-
},
|
|
208
|
+
}, ToggleCommentPanelOperation = {
|
|
234
209
|
id: "docs.operation.toggle-comment-panel",
|
|
235
|
-
type:
|
|
236
|
-
handler(
|
|
237
|
-
var
|
|
238
|
-
const
|
|
239
|
-
return !
|
|
210
|
+
type: CommandType.OPERATION,
|
|
211
|
+
handler(accessor) {
|
|
212
|
+
var _a6;
|
|
213
|
+
const panelService = accessor.get(ThreadCommentPanelService), sidebarService = accessor.get(ISidebarService);
|
|
214
|
+
return !panelService.panelVisible || ((_a6 = sidebarService.options.children) == null ? void 0 : _a6.label) !== DocThreadCommentPanel.componentKey ? (sidebarService.open({
|
|
240
215
|
header: { title: "threadCommentUI.panel.title" },
|
|
241
|
-
children: { label:
|
|
216
|
+
children: { label: DocThreadCommentPanel.componentKey },
|
|
242
217
|
width: 320,
|
|
243
|
-
onClose: () =>
|
|
244
|
-
}),
|
|
218
|
+
onClose: /* @__PURE__ */ __name(() => panelService.setPanelVisible(!1), "onClose")
|
|
219
|
+
}), panelService.setPanelVisible(!0)) : (sidebarService.close(), panelService.setPanelVisible(!1), panelService.setActiveComment(null)), !0;
|
|
245
220
|
}
|
|
246
|
-
},
|
|
221
|
+
}, StartAddCommentOperation = {
|
|
247
222
|
id: "docs.operation.start-add-comment",
|
|
248
|
-
type:
|
|
249
|
-
handler(
|
|
250
|
-
var
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
223
|
+
type: CommandType.OPERATION,
|
|
224
|
+
handler(accessor) {
|
|
225
|
+
var _a6, _b, _c;
|
|
226
|
+
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();
|
|
227
|
+
if (!doc || !textRange)
|
|
253
228
|
return !1;
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
return
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
unitId
|
|
260
|
-
subUnitId
|
|
261
|
-
id:
|
|
262
|
-
ref:
|
|
263
|
-
dT:
|
|
264
|
-
personId:
|
|
229
|
+
const docSelectionRenderManager = (_a6 = renderManagerService.getRenderById(doc.getUnitId())) == null ? void 0 : _a6.with(DocSelectionRenderService);
|
|
230
|
+
if (docSelectionRenderManager == null || docSelectionRenderManager.setReserveRangesStatus(!0), textRange.collapsed)
|
|
231
|
+
return panelService.panelVisible ? (panelService.setPanelVisible(!1), sidebarService.close()) : commandService.executeCommand(ShowCommentPanelOperation.id), !0;
|
|
232
|
+
commandService.executeCommand(ShowCommentPanelOperation.id);
|
|
233
|
+
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 = {
|
|
234
|
+
unitId,
|
|
235
|
+
subUnitId,
|
|
236
|
+
id: commentId,
|
|
237
|
+
ref: text,
|
|
238
|
+
dT: getDT(),
|
|
239
|
+
personId: userManagerService.getCurrentUser().userID,
|
|
265
240
|
text: {
|
|
266
241
|
dataStream: `\r
|
|
267
242
|
`
|
|
268
243
|
},
|
|
269
|
-
startOffset:
|
|
270
|
-
endOffset:
|
|
244
|
+
startOffset: textRange.startOffset,
|
|
245
|
+
endOffset: textRange.endOffset,
|
|
271
246
|
collapsed: !0,
|
|
272
|
-
threadId:
|
|
247
|
+
threadId: commentId
|
|
273
248
|
};
|
|
274
|
-
return
|
|
275
|
-
unitId
|
|
276
|
-
subUnitId
|
|
277
|
-
commentId
|
|
249
|
+
return docSelectionRenderManager == null || docSelectionRenderManager.blur(), docCommentService.startAdd(comment), panelService.setActiveComment({
|
|
250
|
+
unitId,
|
|
251
|
+
subUnitId,
|
|
252
|
+
commentId
|
|
278
253
|
}), !0;
|
|
279
254
|
}
|
|
280
255
|
};
|
|
281
|
-
var
|
|
282
|
-
for (var
|
|
283
|
-
(
|
|
284
|
-
return
|
|
285
|
-
},
|
|
286
|
-
let
|
|
287
|
-
constructor(
|
|
288
|
-
super(), this._threadCommentPanelService =
|
|
256
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
257
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
258
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
259
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
260
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a2;
|
|
261
|
+
let DocThreadCommentSelectionController = (_a2 = class extends Disposable {
|
|
262
|
+
constructor(_threadCommentPanelService, _univerInstanceService, _commandService, _docThreadCommentService, _renderManagerService, _threadCommentModel) {
|
|
263
|
+
super(), this._threadCommentPanelService = _threadCommentPanelService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._docThreadCommentService = _docThreadCommentService, this._renderManagerService = _renderManagerService, this._threadCommentModel = _threadCommentModel, this._initSelectionChange(), this._initActiveCommandChange();
|
|
289
264
|
}
|
|
290
265
|
_initSelectionChange() {
|
|
291
|
-
let
|
|
266
|
+
let lastSelection;
|
|
292
267
|
this.disposeWithMe(
|
|
293
|
-
this._commandService.onCommandExecuted((
|
|
294
|
-
var
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
298
|
-
const
|
|
299
|
-
if ((
|
|
268
|
+
this._commandService.onCommandExecuted((commandInfo) => {
|
|
269
|
+
var _a6, _b, _c, _d;
|
|
270
|
+
if (commandInfo.id === SetTextSelectionsOperation.id) {
|
|
271
|
+
const params = commandInfo.params, { unitId, ranges } = params;
|
|
272
|
+
if (isInternalEditorID(unitId)) return;
|
|
273
|
+
const doc = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_DOC), primary = ranges[0];
|
|
274
|
+
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))
|
|
300
275
|
return;
|
|
301
|
-
if (
|
|
302
|
-
const { startOffset
|
|
303
|
-
let
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
276
|
+
if (lastSelection = primary, primary && doc) {
|
|
277
|
+
const { startOffset, endOffset, collapsed } = primary;
|
|
278
|
+
let customRange;
|
|
279
|
+
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) {
|
|
280
|
+
const comment = this._threadCommentModel.getComment(unitId, DEFAULT_DOC_SUBUNIT_ID, customRange.id);
|
|
281
|
+
comment && !comment.resolved && this._commandService.executeCommand(ShowCommentPanelOperation.id, {
|
|
307
282
|
activeComment: {
|
|
308
|
-
unitId
|
|
309
|
-
subUnitId:
|
|
310
|
-
commentId:
|
|
283
|
+
unitId,
|
|
284
|
+
subUnitId: DEFAULT_DOC_SUBUNIT_ID,
|
|
285
|
+
commentId: customRange.id
|
|
311
286
|
}
|
|
312
287
|
});
|
|
313
288
|
return;
|
|
@@ -315,260 +290,264 @@ let $ = class extends B {
|
|
|
315
290
|
}
|
|
316
291
|
if (!this._threadCommentPanelService.activeCommentId)
|
|
317
292
|
return;
|
|
318
|
-
this._commandService.executeCommand(
|
|
293
|
+
this._commandService.executeCommand(SetActiveCommentOperation.id);
|
|
319
294
|
}
|
|
320
295
|
})
|
|
321
296
|
);
|
|
322
297
|
}
|
|
323
298
|
_initActiveCommandChange() {
|
|
324
|
-
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((
|
|
325
|
-
var
|
|
326
|
-
if (
|
|
327
|
-
const
|
|
328
|
-
if (
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
startOffset:
|
|
332
|
-
endOffset:
|
|
299
|
+
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
|
|
300
|
+
var _a6, _b, _c, _d;
|
|
301
|
+
if (activeComment) {
|
|
302
|
+
const doc = this._univerInstanceService.getUnit(activeComment.unitId);
|
|
303
|
+
if (doc) {
|
|
304
|
+
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);
|
|
305
|
+
customRange && backScrollController && backScrollController.scrollToRange({
|
|
306
|
+
startOffset: customRange.startIndex,
|
|
307
|
+
endOffset: customRange.endIndex,
|
|
333
308
|
collapsed: !1
|
|
334
309
|
});
|
|
335
310
|
}
|
|
336
311
|
}
|
|
337
|
-
(!
|
|
312
|
+
(!activeComment || activeComment.commentId !== ((_d = this._docThreadCommentService.addingComment) == null ? void 0 : _d.id)) && this._docThreadCommentService.endAdd();
|
|
338
313
|
}));
|
|
339
314
|
}
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
],
|
|
349
|
-
var
|
|
350
|
-
return
|
|
351
|
-
for (var
|
|
352
|
-
|
|
353
|
-
for (var
|
|
315
|
+
}, __name(_a2, "DocThreadCommentSelectionController"), _a2);
|
|
316
|
+
DocThreadCommentSelectionController = __decorateClass$3([
|
|
317
|
+
__decorateParam$3(0, Inject(ThreadCommentPanelService)),
|
|
318
|
+
__decorateParam$3(1, IUniverInstanceService),
|
|
319
|
+
__decorateParam$3(2, ICommandService),
|
|
320
|
+
__decorateParam$3(3, Inject(DocThreadCommentService)),
|
|
321
|
+
__decorateParam$3(4, IRenderManagerService),
|
|
322
|
+
__decorateParam$3(5, Inject(ThreadCommentModel))
|
|
323
|
+
], DocThreadCommentSelectionController);
|
|
324
|
+
var __assign = function() {
|
|
325
|
+
return __assign = Object.assign || function(t) {
|
|
326
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
327
|
+
s = arguments[i];
|
|
328
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
354
329
|
}
|
|
355
|
-
return
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
var
|
|
359
|
-
for (var
|
|
360
|
-
if (
|
|
361
|
-
for (var i = 0,
|
|
362
|
-
|
|
363
|
-
return
|
|
364
|
-
},
|
|
365
|
-
var
|
|
366
|
-
return
|
|
330
|
+
return t;
|
|
331
|
+
}, __assign.apply(this, arguments);
|
|
332
|
+
}, __rest = function(s, e) {
|
|
333
|
+
var t = {};
|
|
334
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
335
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
336
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
337
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
338
|
+
return t;
|
|
339
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
340
|
+
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()));
|
|
341
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
367
342
|
});
|
|
368
|
-
function
|
|
369
|
-
return
|
|
370
|
-
return
|
|
343
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
344
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
345
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
371
346
|
}));
|
|
372
347
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
348
|
+
__name(render, "render");
|
|
349
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
350
|
+
var attrs = __assign({}, node.attrs);
|
|
351
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
352
|
+
var defIds = runtimeProps.defIds;
|
|
353
|
+
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) {
|
|
354
|
+
var key = _a6[0], value = _a6[1];
|
|
355
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
356
|
+
})), attrs;
|
|
381
357
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
358
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
359
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
360
|
+
var _a6, defIds = runtimeProps.defIds;
|
|
361
|
+
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) {
|
|
362
|
+
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;
|
|
363
|
+
}) }) : node;
|
|
387
364
|
}
|
|
388
|
-
|
|
365
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
366
|
+
function generateShortUuid() {
|
|
389
367
|
return Math.random().toString(36).substring(2, 8);
|
|
390
368
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
369
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
370
|
+
IconBase.displayName = "UniverIcon";
|
|
371
|
+
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) {
|
|
372
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
394
373
|
id: "comment-single",
|
|
395
|
-
ref
|
|
396
|
-
icon:
|
|
374
|
+
ref,
|
|
375
|
+
icon: element
|
|
397
376
|
}));
|
|
398
377
|
});
|
|
399
|
-
|
|
400
|
-
const
|
|
401
|
-
[
|
|
402
|
-
[
|
|
378
|
+
CommentSingle.displayName = "CommentSingle";
|
|
379
|
+
const menuSchema = {
|
|
380
|
+
[RibbonStartGroup.OTHERS]: {
|
|
381
|
+
[ToggleCommentPanelOperation.id]: {
|
|
403
382
|
order: 1,
|
|
404
|
-
menuItemFactory:
|
|
383
|
+
menuItemFactory: ToolbarDocCommentMenuItemFactory
|
|
405
384
|
}
|
|
406
385
|
},
|
|
407
|
-
[
|
|
408
|
-
[
|
|
409
|
-
[
|
|
386
|
+
[ContextMenuPosition.MAIN_AREA]: {
|
|
387
|
+
[ContextMenuGroup.DATA]: {
|
|
388
|
+
[StartAddCommentOperation.id]: {
|
|
410
389
|
order: 1,
|
|
411
|
-
menuItemFactory:
|
|
390
|
+
menuItemFactory: AddDocCommentMenuItemFactory
|
|
412
391
|
}
|
|
413
392
|
}
|
|
414
393
|
}
|
|
415
394
|
};
|
|
416
|
-
var
|
|
417
|
-
for (var
|
|
418
|
-
(
|
|
419
|
-
return
|
|
420
|
-
},
|
|
421
|
-
let
|
|
422
|
-
constructor(
|
|
423
|
-
super(), this._commandService =
|
|
395
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
396
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
397
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
398
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
399
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a3;
|
|
400
|
+
let DocThreadCommentUIController = (_a3 = class extends Disposable {
|
|
401
|
+
constructor(_commandService, _menuManagerService, _componentManager) {
|
|
402
|
+
super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._initCommands(), this._initMenus(), this._initComponents();
|
|
424
403
|
}
|
|
425
404
|
_initCommands() {
|
|
426
405
|
[
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
].forEach((
|
|
433
|
-
this.disposeWithMe(this._commandService.registerCommand(
|
|
406
|
+
AddDocCommentComment,
|
|
407
|
+
DeleteDocCommentComment,
|
|
408
|
+
ShowCommentPanelOperation,
|
|
409
|
+
StartAddCommentOperation,
|
|
410
|
+
ToggleCommentPanelOperation
|
|
411
|
+
].forEach((command) => {
|
|
412
|
+
this.disposeWithMe(this._commandService.registerCommand(command));
|
|
434
413
|
});
|
|
435
414
|
}
|
|
436
415
|
_initMenus() {
|
|
437
|
-
this._menuManagerService.mergeMenu(
|
|
416
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
438
417
|
}
|
|
439
418
|
_initComponents() {
|
|
440
|
-
[
|
|
441
|
-
this.disposeWithMe(this._componentManager.register(
|
|
442
|
-
}), this.disposeWithMe(this._componentManager.register("CommentSingle",
|
|
419
|
+
[DocThreadCommentPanel].forEach((comp) => {
|
|
420
|
+
this.disposeWithMe(this._componentManager.register(comp.componentKey, comp));
|
|
421
|
+
}), this.disposeWithMe(this._componentManager.register("CommentSingle", CommentSingle));
|
|
443
422
|
}
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
],
|
|
450
|
-
var
|
|
451
|
-
for (var
|
|
452
|
-
(
|
|
453
|
-
return
|
|
454
|
-
},
|
|
455
|
-
let
|
|
456
|
-
constructor(
|
|
457
|
-
super(), this._context =
|
|
423
|
+
}, __name(_a3, "DocThreadCommentUIController"), _a3);
|
|
424
|
+
DocThreadCommentUIController = __decorateClass$2([
|
|
425
|
+
__decorateParam$2(0, ICommandService),
|
|
426
|
+
__decorateParam$2(1, IMenuManagerService),
|
|
427
|
+
__decorateParam$2(2, Inject(ComponentManager))
|
|
428
|
+
], DocThreadCommentUIController);
|
|
429
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
430
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
431
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
432
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
433
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a4;
|
|
434
|
+
let DocThreadCommentRenderController = (_a4 = class extends Disposable {
|
|
435
|
+
constructor(_context, _docInterceptorService, _threadCommentPanelService, _docRenderController, _univerInstanceService, _threadCommentModel, _commandService) {
|
|
436
|
+
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();
|
|
458
437
|
}
|
|
459
438
|
_initReRender() {
|
|
460
|
-
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((
|
|
461
|
-
var
|
|
462
|
-
if (
|
|
463
|
-
this._docRenderController.reRender(
|
|
439
|
+
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe((activeComment) => {
|
|
440
|
+
var _a6;
|
|
441
|
+
if (activeComment) {
|
|
442
|
+
this._docRenderController.reRender(activeComment.unitId);
|
|
464
443
|
return;
|
|
465
444
|
}
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
})), this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((
|
|
469
|
-
|
|
445
|
+
const unitId = (_a6 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a6.getUnitId();
|
|
446
|
+
unitId && this._docRenderController.reRender(unitId);
|
|
447
|
+
})), this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
|
|
448
|
+
update.type === "resolve" && this._docRenderController.reRender(update.unitId);
|
|
470
449
|
}));
|
|
471
450
|
}
|
|
472
451
|
_interceptorViewModel() {
|
|
473
|
-
this._docInterceptorService.intercept(
|
|
474
|
-
handler: (
|
|
475
|
-
if (!
|
|
476
|
-
return
|
|
477
|
-
const { unitId
|
|
478
|
-
if (!
|
|
479
|
-
return
|
|
480
|
-
...
|
|
452
|
+
this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_DECORATION, {
|
|
453
|
+
handler: /* @__PURE__ */ __name((data, pos, next) => {
|
|
454
|
+
if (!data)
|
|
455
|
+
return next(data);
|
|
456
|
+
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);
|
|
457
|
+
if (!comment)
|
|
458
|
+
return next({
|
|
459
|
+
...data,
|
|
481
460
|
show: !1
|
|
482
461
|
});
|
|
483
|
-
const
|
|
484
|
-
return
|
|
485
|
-
...
|
|
486
|
-
active:
|
|
487
|
-
show: !
|
|
462
|
+
const isActiveIndex = activeCustomDecoration && index >= activeCustomDecoration.startIndex && index <= activeCustomDecoration.endIndex, isActive = commentUnitID === unitId && data.id === commentId;
|
|
463
|
+
return next({
|
|
464
|
+
...data,
|
|
465
|
+
active: isActive || isActiveIndex,
|
|
466
|
+
show: !comment.resolved
|
|
488
467
|
});
|
|
489
|
-
}
|
|
468
|
+
}, "handler")
|
|
490
469
|
});
|
|
491
470
|
}
|
|
492
471
|
_initSyncComments() {
|
|
493
|
-
var
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
this._threadCommentModel.getComment(
|
|
497
|
-
}),
|
|
498
|
-
let
|
|
499
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
500
|
-
var
|
|
501
|
-
if (
|
|
502
|
-
if (
|
|
472
|
+
var _a6, _b, _c;
|
|
473
|
+
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 : [];
|
|
474
|
+
threadIds.forEach((id) => {
|
|
475
|
+
this._threadCommentModel.getComment(unitId, subUnitId, id) || this._threadCommentModel.addComment(unitId, subUnitId, { id, threadId: id, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId, subUnitId });
|
|
476
|
+
}), threadIds.length && this._threadCommentModel.syncThreadComments(this._context.unit.getUnitId(), DEFAULT_DOC_SUBUNIT_ID, threadIds);
|
|
477
|
+
let prevThreadIds = threadIds.sort();
|
|
478
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
479
|
+
var _a7, _b2, _c2;
|
|
480
|
+
if (commandInfo.id === RichTextEditingMutation.id) {
|
|
481
|
+
if (commandInfo.params.unitId !== this._context.unit.getUnitId())
|
|
503
482
|
return;
|
|
504
|
-
const
|
|
505
|
-
if (JSON.stringify(
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}),
|
|
510
|
-
|
|
511
|
-
}),
|
|
512
|
-
this._threadCommentModel.getComment(
|
|
513
|
-
}), this._threadCommentModel.syncThreadComments(
|
|
483
|
+
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();
|
|
484
|
+
if (JSON.stringify(prevThreadIds) !== JSON.stringify(currentThreadIdsSorted)) {
|
|
485
|
+
const preIds = new Set(prevThreadIds), currentIds = new Set(currentThreadIdsSorted), addIds = /* @__PURE__ */ new Set(), deleteIds = /* @__PURE__ */ new Set();
|
|
486
|
+
currentThreadIds.forEach((id) => {
|
|
487
|
+
preIds.has(id) || addIds.add(id);
|
|
488
|
+
}), prevThreadIds.forEach((id) => {
|
|
489
|
+
currentIds.has(id) || deleteIds.add(id);
|
|
490
|
+
}), prevThreadIds = currentThreadIdsSorted, addIds.forEach((id) => {
|
|
491
|
+
this._threadCommentModel.getComment(unitId, subUnitId, id) || this._threadCommentModel.addComment(unitId, subUnitId, { id, threadId: id, ref: "", dT: "", personId: "", text: { dataStream: "" }, unitId, subUnitId });
|
|
492
|
+
}), this._threadCommentModel.syncThreadComments(unitId, subUnitId, [...addIds]);
|
|
514
493
|
}
|
|
515
494
|
}
|
|
516
495
|
}));
|
|
517
496
|
}
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
],
|
|
527
|
-
var
|
|
528
|
-
for (var
|
|
529
|
-
(
|
|
530
|
-
return
|
|
531
|
-
},
|
|
532
|
-
let
|
|
533
|
-
constructor(
|
|
534
|
-
super(), this._config =
|
|
535
|
-
const { menu
|
|
497
|
+
}, __name(_a4, "DocThreadCommentRenderController"), _a4);
|
|
498
|
+
DocThreadCommentRenderController = __decorateClass$1([
|
|
499
|
+
__decorateParam$1(1, Inject(DocInterceptorService)),
|
|
500
|
+
__decorateParam$1(2, Inject(ThreadCommentPanelService)),
|
|
501
|
+
__decorateParam$1(3, Inject(DocRenderController)),
|
|
502
|
+
__decorateParam$1(4, IUniverInstanceService),
|
|
503
|
+
__decorateParam$1(5, Inject(ThreadCommentModel)),
|
|
504
|
+
__decorateParam$1(6, ICommandService)
|
|
505
|
+
], DocThreadCommentRenderController);
|
|
506
|
+
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) => {
|
|
507
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
508
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
509
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
510
|
+
}, "__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;
|
|
511
|
+
let UniverDocsThreadCommentUIPlugin = (_a5 = class extends Plugin {
|
|
512
|
+
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
513
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._configService = _configService;
|
|
514
|
+
const { menu, ...rest } = merge(
|
|
536
515
|
{},
|
|
537
|
-
|
|
516
|
+
defaultPluginConfig,
|
|
538
517
|
this._config
|
|
539
518
|
);
|
|
540
|
-
|
|
519
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(DOCS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
541
520
|
}
|
|
542
521
|
onStarting() {
|
|
543
522
|
[
|
|
544
|
-
[
|
|
545
|
-
[
|
|
546
|
-
[
|
|
547
|
-
].forEach((
|
|
548
|
-
this._injector.add(
|
|
523
|
+
[DocThreadCommentUIController],
|
|
524
|
+
[DocThreadCommentSelectionController],
|
|
525
|
+
[DocThreadCommentService]
|
|
526
|
+
].forEach((dep) => {
|
|
527
|
+
this._injector.add(dep);
|
|
549
528
|
});
|
|
550
529
|
}
|
|
551
530
|
onRendered() {
|
|
552
|
-
this._initRenderModule(), this._injector.get(
|
|
531
|
+
this._initRenderModule(), this._injector.get(DocThreadCommentSelectionController), this._injector.get(DocThreadCommentUIController);
|
|
553
532
|
}
|
|
554
533
|
_initRenderModule() {
|
|
555
|
-
[
|
|
556
|
-
this._renderManagerSrv.registerRenderModule(
|
|
534
|
+
[DocThreadCommentRenderController].forEach((dep) => {
|
|
535
|
+
this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC, dep);
|
|
557
536
|
});
|
|
558
537
|
}
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
],
|
|
538
|
+
}, __name(_a5, "UniverDocsThreadCommentUIPlugin"), _a5);
|
|
539
|
+
__publicField2(UniverDocsThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
|
|
540
|
+
__publicField2(UniverDocsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_DOC);
|
|
541
|
+
UniverDocsThreadCommentUIPlugin = __decorateClass([
|
|
542
|
+
DependentOn(UniverThreadCommentUIPlugin),
|
|
543
|
+
__decorateParam(1, Inject(Injector)),
|
|
544
|
+
__decorateParam(2, IRenderManagerService),
|
|
545
|
+
__decorateParam(3, IConfigService)
|
|
546
|
+
], UniverDocsThreadCommentUIPlugin);
|
|
568
547
|
export {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
548
|
+
AddDocCommentComment,
|
|
549
|
+
DeleteDocCommentComment,
|
|
550
|
+
ShowCommentPanelOperation,
|
|
551
|
+
StartAddCommentOperation,
|
|
552
|
+
UniverDocsThreadCommentUIPlugin
|
|
574
553
|
};
|