@univerjs/thread-comment-ui 0.7.0-beta.0 → 0.7.0-nightly.202504301607
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 +16 -14
- package/lib/es/index.js +67 -65
- package/lib/index.css +1 -1
- package/lib/index.js +67 -65
- package/lib/umd/index.js +8 -6
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/index.js
CHANGED
|
@@ -3,15 +3,15 @@ var Pe = (t, e, n) => e in t ? Le(t, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var z = (t, e, n) => Pe(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { Inject as Se, IUniverInstanceService as Ve, Disposable as Ae, UniverInstanceType as ce, CommandType as _e, DependentOn as Be, Injector as We, ICommandService as ne, IConfigService as Fe, Plugin as ze, merge as Ge, mergeOverrideWithDependencies as Ke, LocaleService as fe, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Ze, BuildTextUtils as ve, Tools as Ye, CustomRangeType as qe, getBodySlice as Je, UserManagerService as he, generateRandomId as Qe } from "@univerjs/core";
|
|
5
5
|
import { UniverThreadCommentPlugin as Xe, ThreadCommentModel as Ne, getDT as et, AddCommentCommand as tt, ResolveCommentCommand as nt, DeleteCommentTreeCommand as we, UpdateCommentCommand as rt, DeleteCommentCommand as it } from "@univerjs/thread-comment";
|
|
6
|
-
import { ISidebarService as Ue, useDependency as N, KeyCode as pe, useObservable as G, useConfigValue as
|
|
6
|
+
import { ISidebarService as Ue, useDependency as N, KeyCode as pe, useObservable as G, useConfigValue as ot, UI_PLUGIN_CONFIG_KEY as lt } from "@univerjs/ui";
|
|
7
7
|
import { BehaviorSubject as ge, filter as at, debounceTime as st } from "rxjs";
|
|
8
8
|
import { jsxs as x, jsx as a } from "react/jsx-runtime";
|
|
9
9
|
import { Button as se, clsx as Ce, Tooltip as dt, Dropdown as ut, Select as Ie } from "@univerjs/design";
|
|
10
10
|
import { forwardRef as B, useRef as te, createElement as Z, useState as A, useEffect as de, useMemo as ee, useImperativeHandle as ct } from "react";
|
|
11
11
|
import { IEditorService as vt, BreakLineCommand as mt, RichTextEditor as ft } from "@univerjs/docs-ui";
|
|
12
12
|
var ht = Object.getOwnPropertyDescriptor, pt = (t, e, n, r) => {
|
|
13
|
-
for (var i = r > 1 ? void 0 : r ? ht(e, n) : e,
|
|
14
|
-
(d = t[
|
|
13
|
+
for (var i = r > 1 ? void 0 : r ? ht(e, n) : e, o = t.length - 1, d; o >= 0; o--)
|
|
14
|
+
(d = t[o]) && (i = d(i) || i);
|
|
15
15
|
return i;
|
|
16
16
|
}, xe = (t, e) => (n, r) => e(n, r, t);
|
|
17
17
|
let q = class extends Ae {
|
|
@@ -74,19 +74,19 @@ const gt = "thread-comment-panel", Ct = "UNIVER_THREAD_COMMENT_UI_PLUGIN", It =
|
|
|
74
74
|
}
|
|
75
75
|
}, xt = "thread-comment-ui.config", be = {};
|
|
76
76
|
var bt = Object.defineProperty, yt = Object.getOwnPropertyDescriptor, St = (t, e, n) => e in t ? bt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, _t = (t, e, n, r) => {
|
|
77
|
-
for (var i = r > 1 ? void 0 : r ? yt(e, n) : e,
|
|
78
|
-
(d = t[
|
|
77
|
+
for (var i = r > 1 ? void 0 : r ? yt(e, n) : e, o = t.length - 1, d; o >= 0; o--)
|
|
78
|
+
(d = t[o]) && (i = d(i) || i);
|
|
79
79
|
return i;
|
|
80
80
|
}, me = (t, e) => (n, r) => e(n, r, t), Oe = (t, e, n) => St(t, typeof e != "symbol" ? e + "" : e, n);
|
|
81
81
|
let ue = class extends ze {
|
|
82
82
|
constructor(t = be, e, n, r) {
|
|
83
83
|
super(), this._config = t, this._injector = e, this._commandService = n, this._configService = r;
|
|
84
|
-
const { menu: i, ...
|
|
84
|
+
const { menu: i, ...o } = Ge(
|
|
85
85
|
{},
|
|
86
86
|
be,
|
|
87
87
|
this._config
|
|
88
88
|
);
|
|
89
|
-
i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(xt,
|
|
89
|
+
i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig(xt, o);
|
|
90
90
|
}
|
|
91
91
|
onStarting() {
|
|
92
92
|
var t;
|
|
@@ -123,23 +123,23 @@ var M = function() {
|
|
|
123
123
|
e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
|
|
124
124
|
return n;
|
|
125
125
|
}, Y = B(function(t, e) {
|
|
126
|
-
var n = t.icon, r = t.id, i = t.className,
|
|
127
|
-
return Te(n, "".concat(r), { defIds: n.defIds, idSuffix: h.current }, M({ ref: e, className: f }, d),
|
|
126
|
+
var n = t.icon, r = t.id, i = t.className, o = t.extend, d = Nt(t, ["icon", "id", "className", "extend"]), f = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = te("_".concat(Ot()));
|
|
127
|
+
return Te(n, "".concat(r), { defIds: n.defIds, idSuffix: h.current }, M({ ref: e, className: f }, d), o);
|
|
128
128
|
});
|
|
129
129
|
function Te(t, e, n, r, i) {
|
|
130
|
-
return Z(t.tag, M(M({ key: e }, wt(t, n, i)), r), (Ut(t, n).children || []).map(function(
|
|
131
|
-
return Te(
|
|
130
|
+
return Z(t.tag, M(M({ key: e }, wt(t, n, i)), r), (Ut(t, n).children || []).map(function(o, d) {
|
|
131
|
+
return Te(o, "".concat(e, "-").concat(t.tag, "-").concat(d), n, void 0, i);
|
|
132
132
|
}));
|
|
133
133
|
}
|
|
134
134
|
function wt(t, e, n) {
|
|
135
135
|
var r = M({}, t.attrs);
|
|
136
|
-
n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1), t.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(
|
|
137
|
-
var d =
|
|
136
|
+
n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1), t.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(o) {
|
|
137
|
+
var d = o[0], f = o[1];
|
|
138
138
|
d === "mask" && typeof f == "string" && (r[d] = f.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
139
139
|
});
|
|
140
140
|
var i = e.defIds;
|
|
141
|
-
return !i || i.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(
|
|
142
|
-
var d =
|
|
141
|
+
return !i || i.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(o) {
|
|
142
|
+
var d = o[0], f = o[1];
|
|
143
143
|
typeof f == "string" && (r[d] = f.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
|
|
144
144
|
})), r;
|
|
145
145
|
}
|
|
@@ -210,7 +210,7 @@ function ye(t) {
|
|
|
210
210
|
}
|
|
211
211
|
const je = B((t, e) => {
|
|
212
212
|
var R;
|
|
213
|
-
const { comment: n, onSave: r, id: i, onCancel:
|
|
213
|
+
const { comment: n, onSave: r, id: i, onCancel: o, autoFocus: d, unitId: f, type: h } = t, w = N(ne), O = N(fe), [P, T] = A(!1), b = N(vt), c = te(null), v = h === ce.UNIVER_SHEET ? Ze : f, [E, y] = A(() => {
|
|
214
214
|
var u, m, p;
|
|
215
215
|
return ve.transform.getPlainText((p = (m = (u = c.current) == null ? void 0 : u.getDocumentData().body) == null ? void 0 : m.dataStream) != null ? p : "");
|
|
216
216
|
});
|
|
@@ -218,8 +218,8 @@ const je = B((t, e) => {
|
|
|
218
218
|
var m, p, S, g;
|
|
219
219
|
y(ve.transform.getPlainText((S = (p = (m = c.current) == null ? void 0 : m.getDocumentData().body) == null ? void 0 : p.dataStream) != null ? S : ""));
|
|
220
220
|
const u = (g = c.current) == null ? void 0 : g.selectionChange$.subscribe(() => {
|
|
221
|
-
var
|
|
222
|
-
y(ve.transform.getPlainText((W = (_ = (
|
|
221
|
+
var l, _, W;
|
|
222
|
+
y(ve.transform.getPlainText((W = (_ = (l = c.current) == null ? void 0 : l.getDocumentData().body) == null ? void 0 : _.dataStream) != null ? W : ""));
|
|
223
223
|
});
|
|
224
224
|
return () => u == null ? void 0 : u.unsubscribe();
|
|
225
225
|
}, [(R = c.current) == null ? void 0 : R.selectionChange$]);
|
|
@@ -284,7 +284,7 @@ const je = B((t, e) => {
|
|
|
284
284
|
style: { marginRight: 12 },
|
|
285
285
|
onClick: () => {
|
|
286
286
|
var u;
|
|
287
|
-
|
|
287
|
+
o == null || o(), T(!1), (u = c.current) == null || u.replaceText("", !0), w.executeCommand(K.id);
|
|
288
288
|
},
|
|
289
289
|
children: O.t("threadCommentUI.editor.cancel")
|
|
290
290
|
}
|
|
@@ -303,21 +303,21 @@ const je = B((t, e) => {
|
|
|
303
303
|
}), Rt = (t) => {
|
|
304
304
|
const { dataStream: e, customRanges: n } = t, r = e.endsWith(`\r
|
|
305
305
|
`) ? e.length - 2 : e.length, i = [];
|
|
306
|
-
let
|
|
306
|
+
let o = 0;
|
|
307
307
|
return n == null || n.forEach((d) => {
|
|
308
|
-
|
|
308
|
+
o < d.startIndex && i.push({
|
|
309
309
|
type: "text",
|
|
310
|
-
content: e.slice(
|
|
310
|
+
content: e.slice(o, d.startIndex)
|
|
311
311
|
}), i.push({
|
|
312
312
|
type: "mention",
|
|
313
313
|
content: {
|
|
314
314
|
label: e.slice(d.startIndex, d.endIndex + 1),
|
|
315
315
|
id: d.rangeId
|
|
316
316
|
}
|
|
317
|
-
}),
|
|
317
|
+
}), o = d.endIndex + 1;
|
|
318
318
|
}), i.push({
|
|
319
319
|
type: "text",
|
|
320
|
-
content: e.slice(
|
|
320
|
+
content: e.slice(o, r)
|
|
321
321
|
}), i;
|
|
322
322
|
}, jt = (t) => {
|
|
323
323
|
const { paragraphs: e = [] } = t;
|
|
@@ -337,12 +337,12 @@ const je = B((t, e) => {
|
|
|
337
337
|
case "mention": {
|
|
338
338
|
const i = e.length;
|
|
339
339
|
e += r.content.label;
|
|
340
|
-
const
|
|
340
|
+
const o = e.length - 1;
|
|
341
341
|
n.push({
|
|
342
342
|
rangeId: r.content.id,
|
|
343
343
|
rangeType: qe.MENTION,
|
|
344
344
|
startIndex: i,
|
|
345
|
-
endIndex:
|
|
345
|
+
endIndex: o,
|
|
346
346
|
properties: {},
|
|
347
347
|
wholeEntity: !0
|
|
348
348
|
});
|
|
@@ -367,7 +367,7 @@ const je = B((t, e) => {
|
|
|
367
367
|
customRanges: n
|
|
368
368
|
};
|
|
369
369
|
}, He = "__mock__", Lt = (t) => {
|
|
370
|
-
const { item: e, unitId: n, subUnitId: r, editing: i, onEditingChange:
|
|
370
|
+
const { item: e, unitId: n, subUnitId: r, editing: i, onEditingChange: o, onReply: d, resolved: f, isRoot: h, onClose: w, onDeleteComment: O, type: P } = t, T = N(ne), b = N(fe), c = N(he), v = c.getUser(e.personId), E = G(c.currentUser$), y = (E == null ? void 0 : E.userID) === e.personId, V = e.id === He, [I, R] = A(!1), u = ot(lt), m = u == null ? void 0 : u.avatarFallback, p = () => {
|
|
371
371
|
(O == null ? void 0 : O(e)) !== !1 && (T.executeCommand(
|
|
372
372
|
h ? we.id : it.id,
|
|
373
373
|
{
|
|
@@ -409,20 +409,22 @@ const je = B((t, e) => {
|
|
|
409
409
|
y && !V && !f ? /* @__PURE__ */ a(
|
|
410
410
|
ut,
|
|
411
411
|
{
|
|
412
|
-
overlay: /* @__PURE__ */ a("div", { className: "univer-rounded-lg
|
|
412
|
+
overlay: /* @__PURE__ */ a("div", { className: "univer-rounded-lg", children: /* @__PURE__ */ x(
|
|
413
413
|
"ul",
|
|
414
414
|
{
|
|
415
415
|
className: `
|
|
416
|
-
univer-m-0 univer-
|
|
417
|
-
univer-text-sm
|
|
418
|
-
[&_a]:univer-
|
|
416
|
+
univer-m-0 univer-box-border univer-grid univer-list-none
|
|
417
|
+
univer-p-1.5 univer-text-[13px] univer-text-sm
|
|
418
|
+
[&_a]:univer-block [&_a]:univer-cursor-pointer
|
|
419
|
+
[&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5
|
|
420
|
+
[&_a]:univer-transition-colors
|
|
419
421
|
`,
|
|
420
422
|
children: [
|
|
421
423
|
/* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
|
|
422
424
|
"a",
|
|
423
425
|
{
|
|
424
426
|
className: "hover:univer-bg-gray-200",
|
|
425
|
-
onClick: () =>
|
|
427
|
+
onClick: () => o == null ? void 0 : o(!0),
|
|
426
428
|
children: b.t("threadCommentUI.item.edit")
|
|
427
429
|
}
|
|
428
430
|
) }),
|
|
@@ -442,7 +444,7 @@ const je = B((t, e) => {
|
|
|
442
444
|
{
|
|
443
445
|
className: `
|
|
444
446
|
univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
|
|
445
|
-
univer-items-center univer-justify-center univer-rounded-
|
|
447
|
+
univer-items-center univer-justify-center univer-rounded-sm
|
|
446
448
|
univer-text-base
|
|
447
449
|
hover:univer-bg-gray-50
|
|
448
450
|
`,
|
|
@@ -453,19 +455,19 @@ const je = B((t, e) => {
|
|
|
453
455
|
) : null
|
|
454
456
|
] })
|
|
455
457
|
] }) : null,
|
|
456
|
-
/* @__PURE__ */ a("div", { className: "univer-mb-1 univer-text-xs univer-
|
|
458
|
+
/* @__PURE__ */ a("div", { className: "univer-mb-1 univer-text-xs/normal univer-text-gray-600", children: e.dT }),
|
|
457
459
|
i ? /* @__PURE__ */ a(
|
|
458
460
|
je,
|
|
459
461
|
{
|
|
460
462
|
type: P,
|
|
461
463
|
id: e.id,
|
|
462
464
|
comment: e,
|
|
463
|
-
onCancel: () =>
|
|
465
|
+
onCancel: () => o == null ? void 0 : o(!1),
|
|
464
466
|
autoFocus: !0,
|
|
465
467
|
unitId: n,
|
|
466
468
|
subUnitId: r,
|
|
467
469
|
onSave: ({ text: S, attachments: g }) => {
|
|
468
|
-
|
|
470
|
+
o == null || o(!1), T.executeCommand(
|
|
469
471
|
rt.id,
|
|
470
472
|
{
|
|
471
473
|
unitId: n,
|
|
@@ -479,15 +481,15 @@ const je = B((t, e) => {
|
|
|
479
481
|
);
|
|
480
482
|
}
|
|
481
483
|
}
|
|
482
|
-
) : /* @__PURE__ */ a("div", { className: "univer-text-[13px] univer-
|
|
483
|
-
switch (
|
|
484
|
+
) : /* @__PURE__ */ a("div", { className: "univer-text-[13px]/normal univer-text-gray-900", children: jt(e.text).map((S, g) => /* @__PURE__ */ a("div", { className: "univer-break-words", children: S.map((l, _) => {
|
|
485
|
+
switch (l.type) {
|
|
484
486
|
case "mention":
|
|
485
487
|
return /* @__PURE__ */ x("a", { className: "univer-text-primary-600", children: [
|
|
486
|
-
|
|
488
|
+
l.content.label,
|
|
487
489
|
" "
|
|
488
490
|
] }, _);
|
|
489
491
|
default:
|
|
490
|
-
return
|
|
492
|
+
return l.content;
|
|
491
493
|
}
|
|
492
494
|
}) }, g)) })
|
|
493
495
|
] });
|
|
@@ -498,7 +500,7 @@ const je = B((t, e) => {
|
|
|
498
500
|
unitId: n,
|
|
499
501
|
subUnitId: r,
|
|
500
502
|
refStr: i,
|
|
501
|
-
showEdit:
|
|
503
|
+
showEdit: o = !0,
|
|
502
504
|
onClick: d,
|
|
503
505
|
showHighlight: f,
|
|
504
506
|
onClose: h,
|
|
@@ -515,8 +517,8 @@ const je = B((t, e) => {
|
|
|
515
517
|
full: I
|
|
516
518
|
} = t, R = N(Ne), [u, m] = A(!1), [p, S] = A(""), g = ee(() => R.commentUpdate$.pipe(st(16)), [R]);
|
|
517
519
|
G(g);
|
|
518
|
-
const
|
|
519
|
-
...
|
|
520
|
+
const l = e ? R.getCommentWithChildren(n, r, e) : null, _ = N(ne), W = N(he), k = l == null ? void 0 : l.root.resolved, D = G(W.currentUser$), H = te(null), J = [
|
|
521
|
+
...l ? [l.root] : (
|
|
520
522
|
// mock empty comment
|
|
521
523
|
[{
|
|
522
524
|
id: He,
|
|
@@ -532,7 +534,7 @@ const je = B((t, e) => {
|
|
|
532
534
|
threadId: ""
|
|
533
535
|
}]
|
|
534
536
|
),
|
|
535
|
-
...(X =
|
|
537
|
+
...(X = l == null ? void 0 : l.children) != null ? X : []
|
|
536
538
|
], j = te(null), re = (C) => {
|
|
537
539
|
C.stopPropagation(), k ? _.executeCommand(K.id, {
|
|
538
540
|
unitId: n,
|
|
@@ -545,7 +547,7 @@ const je = B((t, e) => {
|
|
|
545
547
|
resolved: !k
|
|
546
548
|
}), E == null || E(!k);
|
|
547
549
|
}, Q = (C) => {
|
|
548
|
-
C.stopPropagation(), _.executeCommand(K.id), !(
|
|
550
|
+
C.stopPropagation(), _.executeCommand(K.id), !(l != null && l.root && (v == null ? void 0 : v(l.root)) === !1) && (_.executeCommand(
|
|
549
551
|
we.id,
|
|
550
552
|
{
|
|
551
553
|
unitId: n,
|
|
@@ -555,7 +557,7 @@ const je = B((t, e) => {
|
|
|
555
557
|
), h == null || h());
|
|
556
558
|
};
|
|
557
559
|
de(() => b == null ? void 0 : b(), []);
|
|
558
|
-
const ie = w((s =
|
|
560
|
+
const ie = w((s = l == null ? void 0 : l.root.subUnitId) != null ? s : r), oe = o && !p && !k, le = `${i || (l == null ? void 0 : l.root.ref) || ""}${ie ? " · " : ""}${ie}`;
|
|
559
561
|
return /* @__PURE__ */ x(
|
|
560
562
|
"div",
|
|
561
563
|
{
|
|
@@ -606,17 +608,17 @@ const je = B((t, e) => {
|
|
|
606
608
|
`
|
|
607
609
|
}
|
|
608
610
|
),
|
|
609
|
-
/* @__PURE__ */ a(dt, { showIfEllipsis: !0, title:
|
|
611
|
+
/* @__PURE__ */ a(dt, { showIfEllipsis: !0, title: le, children: /* @__PURE__ */ a(
|
|
610
612
|
"div",
|
|
611
613
|
{
|
|
612
614
|
className: `
|
|
613
615
|
univer-flex-1 univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap
|
|
614
616
|
`,
|
|
615
|
-
children:
|
|
617
|
+
children: le
|
|
616
618
|
}
|
|
617
619
|
) })
|
|
618
620
|
] }),
|
|
619
|
-
|
|
621
|
+
l ? /* @__PURE__ */ x("div", { className: "univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row", children: [
|
|
620
622
|
/* @__PURE__ */ a(
|
|
621
623
|
"div",
|
|
622
624
|
{
|
|
@@ -634,7 +636,7 @@ const je = B((t, e) => {
|
|
|
634
636
|
children: k ? /* @__PURE__ */ a(Me, {}) : /* @__PURE__ */ a(Re, {})
|
|
635
637
|
}
|
|
636
638
|
),
|
|
637
|
-
(D == null ? void 0 : D.userID) ===
|
|
639
|
+
(D == null ? void 0 : D.userID) === l.root.personId ? /* @__PURE__ */ a(
|
|
638
640
|
"div",
|
|
639
641
|
{
|
|
640
642
|
className: `
|
|
@@ -664,9 +666,9 @@ const je = B((t, e) => {
|
|
|
664
666
|
unitId: n,
|
|
665
667
|
subUnitId: r,
|
|
666
668
|
item: C,
|
|
667
|
-
isRoot: C.id === (
|
|
669
|
+
isRoot: C.id === (l == null ? void 0 : l.root.id),
|
|
668
670
|
editing: p === C.id,
|
|
669
|
-
resolved:
|
|
671
|
+
resolved: l == null ? void 0 : l.root.resolved,
|
|
670
672
|
type: y,
|
|
671
673
|
onEditingChange: ($) => {
|
|
672
674
|
S($ ? C.id : "");
|
|
@@ -697,7 +699,7 @@ const je = B((t, e) => {
|
|
|
697
699
|
)
|
|
698
700
|
}
|
|
699
701
|
),
|
|
700
|
-
|
|
702
|
+
oe ? /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
|
|
701
703
|
je,
|
|
702
704
|
{
|
|
703
705
|
ref: H,
|
|
@@ -712,10 +714,10 @@ const je = B((t, e) => {
|
|
|
712
714
|
id: Qe(),
|
|
713
715
|
ref: i,
|
|
714
716
|
personId: D == null ? void 0 : D.userID,
|
|
715
|
-
parentId:
|
|
717
|
+
parentId: l == null ? void 0 : l.root.id,
|
|
716
718
|
unitId: n,
|
|
717
719
|
subUnitId: r,
|
|
718
|
-
threadId:
|
|
720
|
+
threadId: l == null ? void 0 : l.root.threadId
|
|
719
721
|
};
|
|
720
722
|
(c == null ? void 0 : c(L)) !== !1 && (await _.executeCommand(
|
|
721
723
|
tt.id,
|
|
@@ -726,9 +728,9 @@ const je = B((t, e) => {
|
|
|
726
728
|
}
|
|
727
729
|
), j.current && (j.current.scrollTop = j.current.scrollHeight));
|
|
728
730
|
},
|
|
729
|
-
autoFocus: P || !
|
|
731
|
+
autoFocus: P || !l,
|
|
730
732
|
onCancel: () => {
|
|
731
|
-
|
|
733
|
+
l || h == null || h();
|
|
732
734
|
}
|
|
733
735
|
},
|
|
734
736
|
`${P}`
|
|
@@ -742,7 +744,7 @@ const je = B((t, e) => {
|
|
|
742
744
|
subUnitId$: n,
|
|
743
745
|
type: r,
|
|
744
746
|
onAdd: i,
|
|
745
|
-
getSubUnitName:
|
|
747
|
+
getSubUnitName: o,
|
|
746
748
|
onResolve: d,
|
|
747
749
|
sortComments: f,
|
|
748
750
|
onItemLeave: h,
|
|
@@ -752,7 +754,7 @@ const je = B((t, e) => {
|
|
|
752
754
|
onAddComment: T,
|
|
753
755
|
onDeleteComment: b,
|
|
754
756
|
showComments: c
|
|
755
|
-
} = t, [v, E] = A("all"), [y, V] = A("all"), I = N(fe), R = N(he), u = N(Ne), [m, p] = A(() => u.getUnit(e)), S = N(q), g = G(S.activeCommentId$),
|
|
757
|
+
} = t, [v, E] = A("all"), [y, V] = A("all"), I = N(fe), R = N(he), u = N(Ne), [m, p] = A(() => u.getUnit(e)), S = N(q), g = G(S.activeCommentId$), l = G(u.commentUpdate$), _ = N(ne), W = G(n), k = te(!0), D = "panel", H = G(R.currentUser$), J = ee(() => {
|
|
756
758
|
var L;
|
|
757
759
|
const s = v === "all" ? m : (L = m.filter((U) => U.subUnitId === W)) != null ? L : [], C = f != null ? f : (U) => U, $ = s.map((U) => {
|
|
758
760
|
var F;
|
|
@@ -768,14 +770,14 @@ const je = B((t, e) => {
|
|
|
768
770
|
}, [c, v, m, f, W]), j = ee(() => [
|
|
769
771
|
...J.filter((s) => !s.resolved),
|
|
770
772
|
...J.filter((s) => s.resolved)
|
|
771
|
-
], [J]), re = ee(() => y === "resolved" ? j.filter((s) => s.resolved) : y === "unsolved" ? j.filter((s) => !s.resolved) : y === "concern_me" && H != null && H.userID ? j.filter((s) => s == null ? void 0 : s.users.has(H.userID)) : j, [j, H == null ? void 0 : H.userID, y]), Q = P ? [P, ...re] : re, ie = Q.filter((s) => !s.resolved),
|
|
773
|
+
], [J]), re = ee(() => y === "resolved" ? j.filter((s) => s.resolved) : y === "unsolved" ? j.filter((s) => !s.resolved) : y === "concern_me" && H != null && H.userID ? j.filter((s) => s == null ? void 0 : s.users.has(H.userID)) : j, [j, H == null ? void 0 : H.userID, y]), Q = P ? [P, ...re] : re, ie = Q.filter((s) => !s.resolved), oe = Q.filter((s) => s.resolved), le = y !== "all" || v !== "all", ae = () => {
|
|
772
774
|
V("all"), E("all");
|
|
773
775
|
};
|
|
774
776
|
de(() => {
|
|
775
777
|
e && p(
|
|
776
778
|
u.getUnit(e)
|
|
777
779
|
);
|
|
778
|
-
}, [e, u,
|
|
780
|
+
}, [e, u, l]), de(() => {
|
|
779
781
|
var U;
|
|
780
782
|
if (!g)
|
|
781
783
|
return;
|
|
@@ -791,7 +793,7 @@ const je = B((t, e) => {
|
|
|
791
793
|
{
|
|
792
794
|
full: !0,
|
|
793
795
|
prefix: D,
|
|
794
|
-
getSubUnitName:
|
|
796
|
+
getSubUnitName: o,
|
|
795
797
|
id: s.id,
|
|
796
798
|
unitId: s.unitId,
|
|
797
799
|
subUnitId: s.subUnitId,
|
|
@@ -874,7 +876,7 @@ const je = B((t, e) => {
|
|
|
874
876
|
`,
|
|
875
877
|
children: [
|
|
876
878
|
I.t("threadCommentUI.panel.empty"),
|
|
877
|
-
|
|
879
|
+
le ? /* @__PURE__ */ a("div", { className: "univer-mt-2 univer-flex univer-flex-row", children: /* @__PURE__ */ a(se, { onClick: ae, children: I.t("threadCommentUI.panel.reset") }) }) : O ? null : /* @__PURE__ */ a("div", { className: "univer-mt-2 univer-flex univer-flex-row", children: /* @__PURE__ */ x(se, { onClick: i, children: [
|
|
878
880
|
/* @__PURE__ */ a(ke, { className: "univer-mr-1.5" }),
|
|
879
881
|
I.t("threadCommentUI.panel.add")
|
|
880
882
|
] }) })
|
|
@@ -882,8 +884,8 @@ const je = B((t, e) => {
|
|
|
882
884
|
}
|
|
883
885
|
) : /* @__PURE__ */ x("div", { className: "univer-mt-3 univer-flex univer-flex-col univer-gap-3", children: [
|
|
884
886
|
ie.map(X),
|
|
885
|
-
|
|
886
|
-
|
|
887
|
+
oe.length > 0 && /* @__PURE__ */ a("div", { className: "univer-text-xs", children: I.t("threadCommentUI.panel.solved") }),
|
|
888
|
+
oe.map(X)
|
|
887
889
|
] })
|
|
888
890
|
] });
|
|
889
891
|
};
|
package/lib/umd/index.js
CHANGED
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
univer-cursor-pointer univer-items-center univer-justify-center
|
|
9
9
|
univer-rounded-sm univer-text-base
|
|
10
10
|
hover:univer-bg-gray-50
|
|
11
|
-
`,onClick:()=>v(p),children:s.jsx(pe,{})}):null,N&&!q&&!C?s.jsx(B.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg
|
|
12
|
-
univer-m-0 univer-
|
|
13
|
-
univer-text-sm
|
|
14
|
-
[&_a]:univer-
|
|
11
|
+
`,onClick:()=>v(p),children:s.jsx(pe,{})}):null,N&&!q&&!C?s.jsx(B.Dropdown,{overlay:s.jsx("div",{className:"univer-rounded-lg",children:s.jsxs("ul",{className:`
|
|
12
|
+
univer-m-0 univer-box-border univer-grid univer-list-none
|
|
13
|
+
univer-p-1.5 univer-text-[13px] univer-text-sm
|
|
14
|
+
[&_a]:univer-block [&_a]:univer-cursor-pointer
|
|
15
|
+
[&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5
|
|
16
|
+
[&_a]:univer-transition-colors
|
|
15
17
|
`,children:[s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:()=>a==null?void 0:a(!0),children:T.t("threadCommentUI.item.edit")})}),s.jsx("li",{children:s.jsx("a",{className:"hover:univer-bg-gray-200",onClick:b,children:T.t("threadCommentUI.item.delete")})})]})}),children:s.jsx("div",{className:`
|
|
16
18
|
univer-ml-1 univer-inline-flex univer-h-6 univer-w-6 univer-cursor-pointer
|
|
17
|
-
univer-items-center univer-justify-center univer-rounded-
|
|
19
|
+
univer-items-center univer-justify-center univer-rounded-sm
|
|
18
20
|
univer-text-base
|
|
19
21
|
hover:univer-bg-gray-50
|
|
20
|
-
`,children:s.jsx(he,{})})}):null]})]}):null,s.jsx("div",{className:"univer-mb-1 univer-text-xs univer-
|
|
22
|
+
`,children:s.jsx(he,{})})}):null]})]}):null,s.jsx("div",{className:"univer-mb-1 univer-text-xs/normal univer-text-gray-600",children:e.dT}),i?s.jsx(be,{type:F,id:e.id,comment:e,onCancel:()=>a==null?void 0:a(!1),autoFocus:!0,unitId:n,subUnitId:r,onSave:({text:U,attachments:x})=>{a==null||a(!1),j.executeCommand(_.UpdateCommentCommand.id,{unitId:n,subUnitId:r,payload:{commentId:e.id,text:U,attachments:x}})}}):s.jsx("div",{className:"univer-text-[13px]/normal univer-text-gray-900",children:We(e.text).map((U,x)=>s.jsx("div",{className:"univer-break-words",children:U.map((o,w)=>{switch(o.type){case"mention":return s.jsxs("a",{className:"univer-text-primary-600",children:[o.content.label," "]},w);default:return o.content}})},x))})]})},ye=t=>{var ie,Q,u;const{id:e,unitId:n,subUnitId:r,refStr:i,showEdit:a=!0,onClick:v,showHighlight:C,onClose:I,getSubUnitName:O,prefix:M,autoFocus:F,onMouseEnter:j,onMouseLeave:T,onAddComment:h,onDeleteComment:p,onResolve:k,type:N,style:q,full:S}=t,L=f.useDependency(_.ThreadCommentModel),[m,g]=d.useState(!1),[b,U]=d.useState(""),x=d.useMemo(()=>L.commentUpdate$.pipe(X.debounceTime(16)),[L]);f.useObservable(x);const o=e?L.getCommentWithChildren(n,r,e):null,w=f.useDependency(l.ICommandService),G=f.useDependency(l.UserManagerService),P=o==null?void 0:o.root.resolved,$=f.useObservable(G.currentUser$),A=d.useRef(null),R=[...o?[o.root]:[{id:xe,text:{dataStream:`
|
|
21
23
|
\r`},personId:(ie=$==null?void 0:$.userID)!=null?ie:"",ref:i!=null?i:"",dT:"",unitId:n,subUnitId:r,threadId:""}],...(Q=o==null?void 0:o.children)!=null?Q:[]],V=d.useRef(null),ee=y=>{y.stopPropagation(),P?w.executeCommand(z.id,{unitId:n,subUnitId:r,commentId:e}):w.executeCommand(z.id),w.executeCommand(_.ResolveCommentCommand.id,{unitId:n,subUnitId:r,commentId:e,resolved:!P}),k==null||k(!P)},J=y=>{y.stopPropagation(),w.executeCommand(z.id),!(o!=null&&o.root&&(p==null?void 0:p(o.root))===!1)&&(w.executeCommand(_.DeleteCommentTreeCommand.id,{unitId:n,subUnitId:r,commentId:e}),I==null||I())};d.useEffect(()=>T==null?void 0:T(),[]);const ne=O((u=o==null?void 0:o.root.subUnitId)!=null?u:r),te=a&&!b&&!P,re=`${i||(o==null?void 0:o.root.ref)||""}${ne?" · ":""}${ne}`;return s.jsxs("div",{className:B.clsx(`
|
|
22
24
|
univer-relative univer-box-border univer-rounded-lg univer-border univer-border-solid
|
|
23
25
|
univer-border-gray-200 univer-bg-white univer-p-4
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/thread-comment-ui",
|
|
3
|
-
"version": "0.7.0-
|
|
3
|
+
"version": "0.7.0-nightly.202504301607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer common thread comment UI plugin",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"rxjs": ">=7.0.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@univerjs/icons": "^0.3.
|
|
56
|
-
"@univerjs/core": "0.7.0-
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/ui": "0.7.0-
|
|
60
|
-
"@univerjs/thread-comment": "0.7.0-
|
|
55
|
+
"@univerjs/icons": "^0.3.24",
|
|
56
|
+
"@univerjs/core": "0.7.0-nightly.202504301607",
|
|
57
|
+
"@univerjs/docs-ui": "0.7.0-nightly.202504301607",
|
|
58
|
+
"@univerjs/design": "0.7.0-nightly.202504301607",
|
|
59
|
+
"@univerjs/ui": "0.7.0-nightly.202504301607",
|
|
60
|
+
"@univerjs/thread-comment": "0.7.0-nightly.202504301607"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"less": "^4.3.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"rxjs": "^7.8.1",
|
|
67
67
|
"tailwindcss": "^3.4.17",
|
|
68
68
|
"typescript": "^5.8.3",
|
|
69
|
-
"vite": "^6.3.
|
|
69
|
+
"vite": "^6.3.4",
|
|
70
70
|
"vitest": "^3.1.2",
|
|
71
71
|
"@univerjs-infra/shared": "0.7.0-beta.0"
|
|
72
72
|
},
|