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