@univerjs/thread-comment-ui 0.1.12

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.
@@ -0,0 +1,751 @@
1
+ var Ue = Object.defineProperty;
2
+ var Oe = (t, e, n) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var _ = (t, e, n) => (Oe(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { UniverThreadCommentPlugin as Pe, ThreadCommentModel as ce, AddCommentCommand as He, UpdateCommentCommand as we, ResolveCommentCommand as De, DeleteCommentTreeCommand as ue, DeleteCommentCommand as Re } from "@univerjs/thread-comment";
5
+ import { Disposable as he, UniverInstanceType as ve, IUniverInstanceService as ke, CommandType as Ce, OnLifecycle as Le, LifecycleStages as je, LocaleService as J, mergeOverrideWithDependencies as Ae, ICommandService as Q, CustomRangeType as Ve, UserManagerService as ee, Tools as Be } from "@univerjs/core";
6
+ import { Inject as te, createIdentifier as ze, Injector as We } from "@wendellhu/redi";
7
+ import { ISidebarService as fe, useObservable as j } from "@univerjs/ui";
8
+ import { BehaviorSubject as re, filter as Fe } from "rxjs";
9
+ import a, { forwardRef as H, useRef as X, createElement as k, useState as P, useImperativeHandle as Ze, useMemo as oe, useEffect as ae } from "react";
10
+ import { useDependency as S } from "@wendellhu/redi/react-bindings";
11
+ import { Mentions as Ye, Mention as Ke, Button as G, Dropdown as Ge, Menu as qe, MenuItem as ie, Select as le } from "@univerjs/design";
12
+ import Je from "dayjs";
13
+ import Qe from "clsx";
14
+ const Xe = "thread-comment-panel", et = "thread-comment-ui-plugin";
15
+ var tt = Object.defineProperty, nt = Object.getOwnPropertyDescriptor, rt = (t, e, n, r) => {
16
+ for (var o = r > 1 ? void 0 : r ? nt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
17
+ (s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
18
+ return r && o && tt(e, n, o), o;
19
+ }, se = (t, e) => (n, r) => e(n, r, t);
20
+ let A = class extends he {
21
+ constructor(e, n) {
22
+ super();
23
+ _(this, "_panelVisible", !1);
24
+ _(this, "_panelVisible$", new re(!1));
25
+ _(this, "_activeCommentId");
26
+ _(this, "_activeCommentId$", new re(void 0));
27
+ _(this, "panelVisible$", this._panelVisible$.asObservable());
28
+ _(this, "activeCommentId$", this._activeCommentId$.asObservable());
29
+ this._sidebarService = e, this._univerInstanceService = n, this._init();
30
+ }
31
+ _init() {
32
+ this.disposeWithMe(
33
+ this._sidebarService.sidebarOptions$.subscribe((e) => {
34
+ e.visible || this.setPanelVisible(!1);
35
+ })
36
+ ), this.disposeWithMe(
37
+ this._univerInstanceService.getCurrentTypeOfUnit$(ve.UNIVER_SHEET).pipe(Fe((e) => !e)).subscribe(() => {
38
+ this._sidebarService.close();
39
+ })
40
+ );
41
+ }
42
+ get panelVisible() {
43
+ return this._panelVisible;
44
+ }
45
+ get activeCommentId() {
46
+ return this._activeCommentId;
47
+ }
48
+ setPanelVisible(e) {
49
+ this._panelVisible = e, this._panelVisible$.next(e);
50
+ }
51
+ setActiveComment(e) {
52
+ this._activeCommentId = e, this._activeCommentId$.next(e);
53
+ }
54
+ };
55
+ A = rt([
56
+ se(0, te(fe)),
57
+ se(1, ke)
58
+ ], A);
59
+ const ot = {
60
+ id: "thread-comment-ui.operation.toggle-panel",
61
+ type: Ce.OPERATION,
62
+ handler(t) {
63
+ const e = t.get(fe), n = t.get(A);
64
+ return n.panelVisible ? (e.close(), n.setPanelVisible(!1)) : (e.open({
65
+ header: { title: "threadCommentUI.panel.title" },
66
+ children: { label: Xe },
67
+ width: 320
68
+ }), n.setPanelVisible(!0)), !0;
69
+ }
70
+ }, ge = {
71
+ id: "thread-comment-ui.operation.set-active-comment",
72
+ type: Ce.OPERATION,
73
+ handler(t, e) {
74
+ return t.get(A).setActiveComment(e), !0;
75
+ }
76
+ }, at = {
77
+ threadCommentUI: {
78
+ panel: {
79
+ title: "评论管理",
80
+ empty: "暂无评论",
81
+ filterEmpty: "没有匹配的结果",
82
+ reset: "重置",
83
+ addComment: "新建评论"
84
+ },
85
+ editor: {
86
+ placeholder: "回复",
87
+ reply: "回复",
88
+ cancel: "取消",
89
+ save: "保存"
90
+ },
91
+ item: {
92
+ edit: "编辑",
93
+ delete: "删除"
94
+ },
95
+ filter: {
96
+ sheet: {
97
+ all: "所有表格",
98
+ current: "当前表格"
99
+ },
100
+ status: {
101
+ all: "所有评论",
102
+ resolved: "已解决",
103
+ unsolved: "未解决",
104
+ concernMe: "与我有关"
105
+ }
106
+ }
107
+ }
108
+ };
109
+ var it = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, st = (t, e, n, r) => {
110
+ for (var o = r > 1 ? void 0 : r ? lt(e, n) : e, i = t.length - 1, s; i >= 0; i--)
111
+ (s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
112
+ return r && o && it(e, n, o), o;
113
+ }, mt = (t, e) => (n, r) => e(n, r, t);
114
+ let K = class extends he {
115
+ constructor(t) {
116
+ super(), this._localeService = t, this._initLocales();
117
+ }
118
+ _initLocales() {
119
+ this._localeService.load({ zhCN: at });
120
+ }
121
+ };
122
+ K = st([
123
+ Le(je.Starting, K),
124
+ mt(0, te(J))
125
+ ], K);
126
+ class dt {
127
+ constructor() {
128
+ _(this, "trigger", "@");
129
+ }
130
+ async getMentions(e) {
131
+ return [];
132
+ }
133
+ }
134
+ const pe = ze("thread-comment.mention-data.service");
135
+ var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, ht = (t, e, n, r) => {
136
+ for (var o = r > 1 ? void 0 : r ? ut(e, n) : e, i = t.length - 1, s; i >= 0; i--)
137
+ (s = t[i]) && (o = (r ? s(e, n, o) : s(o)) || o);
138
+ return r && o && ct(e, n, o), o;
139
+ }, me = (t, e) => (n, r) => e(n, r, t), Y;
140
+ let de = (Y = class extends Pe {
141
+ constructor(e, n, r) {
142
+ super(
143
+ e,
144
+ n,
145
+ r
146
+ );
147
+ _(this, "_config1");
148
+ this._injector = n, this._commandService = r, this._config1 = e;
149
+ }
150
+ onStarting(e) {
151
+ super.onStarting(e), Ae([
152
+ [K],
153
+ [A],
154
+ [pe, { useClass: dt }]
155
+ ], this._config1.overrides).forEach((n) => {
156
+ e.add(n);
157
+ }), [ot, ge].forEach((n) => {
158
+ this._commandService.registerCommand(n);
159
+ });
160
+ }
161
+ }, _(Y, "pluginName", et), _(Y, "type", ve.UNIVER_UNKNOWN), Y);
162
+ de = ht([
163
+ me(1, te(We)),
164
+ me(2, Q)
165
+ ], de);
166
+ var x = function() {
167
+ return x = Object.assign || function(t) {
168
+ for (var e, n = 1, r = arguments.length; n < r; n++) {
169
+ e = arguments[n];
170
+ for (var o in e)
171
+ Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
172
+ }
173
+ return t;
174
+ }, x.apply(this, arguments);
175
+ }, vt = function(t, e) {
176
+ var n = {};
177
+ for (var r in t)
178
+ Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
179
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
180
+ for (var o = 0, r = Object.getOwnPropertySymbols(t); o < r.length; o++)
181
+ e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[o]) && (n[r[o]] = t[r[o]]);
182
+ return n;
183
+ }, L = H(function(t, e) {
184
+ var n = t.icon, r = t.id, o = t.className, i = t.extend, s = vt(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(), d = X("_".concat(gt()));
185
+ return Ie(n, "".concat(r), { defIds: n.defIds, idSuffix: d.current }, x({ ref: e, className: c }, s), i);
186
+ });
187
+ function Ie(t, e, n, r, o) {
188
+ return k(t.tag, x(x({ key: e }, Ct(t, n, o)), r), (ft(t, n).children || []).map(function(i, s) {
189
+ return Ie(i, "".concat(e, "-").concat(t.tag, "-").concat(s), n, void 0, o);
190
+ }));
191
+ }
192
+ function Ct(t, e, n) {
193
+ var r = x({}, t.attrs);
194
+ n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
195
+ var o = e.defIds;
196
+ return !o || o.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
197
+ var s = i[0], c = i[1];
198
+ typeof c == "string" && (r[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
199
+ })), r;
200
+ }
201
+ function ft(t, e) {
202
+ var n, r = e.defIds;
203
+ return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? x(x({}, t), { children: t.children.map(function(o) {
204
+ return typeof o.attrs.id == "string" && r && r.indexOf(o.attrs.id) > -1 ? x(x({}, o), { attrs: x(x({}, o.attrs), { id: o.attrs.id + e.idSuffix }) }) : o;
205
+ }) }) : t;
206
+ }
207
+ function gt() {
208
+ return Math.random().toString(36).substring(2, 8);
209
+ }
210
+ L.displayName = "UniverIcon";
211
+ var pt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ye = H(function(t, e) {
212
+ return k(L, Object.assign({}, t, {
213
+ id: "delete-single",
214
+ ref: e,
215
+ icon: pt
216
+ }));
217
+ });
218
+ ye.displayName = "DeleteSingle";
219
+ const It = ye;
220
+ var yt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, Se = H(function(t, e) {
221
+ return k(L, Object.assign({}, t, {
222
+ id: "increase-single",
223
+ ref: e,
224
+ icon: yt
225
+ }));
226
+ });
227
+ Se.displayName = "IncreaseSingle";
228
+ const St = Se;
229
+ var bt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z" } }] }, be = H(function(t, e) {
230
+ return k(L, Object.assign({}, t, {
231
+ id: "more-horizontal-single",
232
+ ref: e,
233
+ icon: bt
234
+ }));
235
+ });
236
+ be.displayName = "MoreHorizontalSingle";
237
+ const Et = be;
238
+ var xt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { stroke: "currentColor", d: "M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252", strokeLinecap: "round", strokeWidth: 1.2 } }] }, Ee = H(function(t, e) {
239
+ return k(L, Object.assign({}, t, {
240
+ id: "reply-to-comment-single",
241
+ ref: e,
242
+ icon: xt
243
+ }));
244
+ });
245
+ Ee.displayName = "ReplyToCommentSingle";
246
+ const _t = Ee;
247
+ var Nt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, xe = H(function(t, e) {
248
+ return k(L, Object.assign({}, t, {
249
+ id: "resolved-single",
250
+ ref: e,
251
+ icon: Nt
252
+ }));
253
+ });
254
+ xe.displayName = "ResolvedSingle";
255
+ const Tt = xe;
256
+ var Mt = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "circle", attrs: { cx: 8.73, cy: 8.4, r: 6.4, stroke: "currentColor", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }] }, _e = H(function(t, e) {
257
+ return k(L, Object.assign({}, t, {
258
+ id: "solve-single",
259
+ ref: e,
260
+ icon: Mt
261
+ }));
262
+ });
263
+ _e.displayName = "SolveSingle";
264
+ const $t = _e, Ut = "univer-thread-comment-editor-buttons", Ot = "univer-thread-comment-editor-suggestion", Pt = "univer-thread-comment-editor-suggestionActive", Ht = "univer-thread-comment-editor-suggestion-icon", q = {
265
+ threadCommentEditorButtons: Ut,
266
+ threadCommentEditorSuggestion: Ot,
267
+ threadCommentEditorSuggestionActive: Pt,
268
+ threadCommentEditorSuggestionIcon: Ht
269
+ }, wt = (t) => {
270
+ const e = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
271
+ let n, r = 0;
272
+ const o = [];
273
+ for (; (n = e.exec(t)) !== null; )
274
+ n.index > r && o.push({
275
+ type: "text",
276
+ content: t.substring(r, n.index)
277
+ }), n[1] && n[2] ? o.push({
278
+ type: "mention",
279
+ content: {
280
+ label: n[1],
281
+ id: n[2]
282
+ }
283
+ }) : n[3] && o.push({
284
+ type: "text",
285
+ content: n[3]
286
+ }), r = e.lastIndex;
287
+ return r < t.length && o.push({
288
+ type: "text",
289
+ content: t.substring(r)
290
+ }), o;
291
+ }, Dt = (t) => t.map((e) => {
292
+ switch (e.type) {
293
+ case "mention":
294
+ return `@[${e.content.label}](${e.content.id})`;
295
+ default:
296
+ return e.content;
297
+ }
298
+ }).join(""), Ne = (t) => {
299
+ const { dataStream: e, customRanges: n } = t, r = e.length - 2, o = [];
300
+ let i = 0;
301
+ return n == null || n.forEach((s) => {
302
+ i < s.startIndex && o.push({
303
+ type: "text",
304
+ content: e.slice(i, s.startIndex)
305
+ }), o.push({
306
+ type: "mention",
307
+ content: {
308
+ label: e.slice(s.startIndex, s.endIndex).slice(1, -1),
309
+ id: s.rangeId
310
+ }
311
+ }), i = s.endIndex;
312
+ }), o.push({
313
+ type: "text",
314
+ content: e.slice(i, r)
315
+ }), o;
316
+ }, Te = (t) => {
317
+ let e = "";
318
+ const n = [];
319
+ return t.forEach((r) => {
320
+ switch (r.type) {
321
+ case "text":
322
+ e += r.content;
323
+ break;
324
+ case "mention": {
325
+ const o = e.length;
326
+ e += `${r.content.label}`;
327
+ const i = e.length;
328
+ n.push({
329
+ rangeId: r.content.id,
330
+ rangeType: Ve.MENTION,
331
+ startIndex: o,
332
+ endIndex: i
333
+ });
334
+ break;
335
+ }
336
+ }
337
+ }), e += `
338
+ \r`, {
339
+ textRuns: [],
340
+ paragraphs: [
341
+ {
342
+ startIndex: e.length - 2,
343
+ paragraphStyle: {}
344
+ }
345
+ ],
346
+ sectionBreaks: [
347
+ {
348
+ startIndex: e.length - 1
349
+ }
350
+ ],
351
+ dataStream: e,
352
+ customRanges: n
353
+ };
354
+ }, Rt = (t) => ({
355
+ display: t.label,
356
+ id: `${t.id}`,
357
+ raw: t
358
+ }), kt = (t, e, n, r, o) => {
359
+ var s, c;
360
+ const i = (s = t.raw) == null ? void 0 : s.icon;
361
+ return /* @__PURE__ */ a.createElement("div", { className: q.threadCommentEditorSuggestion }, i ? /* @__PURE__ */ a.createElement("img", { className: q.threadCommentEditorSuggestionIcon, src: i }) : null, /* @__PURE__ */ a.createElement("div", null, (c = t.display) != null ? c : t.id));
362
+ }, Me = H((t, e) => {
363
+ var u;
364
+ const { comment: n, onSave: r, id: o, onCancel: i, autoFocus: s } = t, c = S(pe), d = S(J), [f, g] = P({ ...n }), [N, p] = P(!1), I = X(null);
365
+ return Ze(e, () => ({
366
+ reply(y) {
367
+ var h;
368
+ g({
369
+ ...n,
370
+ text: y,
371
+ attachments: []
372
+ }), (h = I.current) == null || h.inputElement.focus();
373
+ }
374
+ })), /* @__PURE__ */ a.createElement("div", { className: q.threadCommentEditor, onClick: (y) => y.preventDefault() }, /* @__PURE__ */ a.createElement(
375
+ Ye,
376
+ {
377
+ ref: I,
378
+ autoFocus: s,
379
+ style: { width: "100%" },
380
+ placeholder: d.t("threadCommentUI.editor.placeholder"),
381
+ value: f != null && f.text ? Dt(Ne(f.text)) : "",
382
+ onChange: (y) => {
383
+ y.target.value || g({ ...n, text: void 0 }), g == null || g({ ...n, text: Te(wt(y.target.value)) });
384
+ },
385
+ onFocus: () => {
386
+ p(!0);
387
+ }
388
+ },
389
+ /* @__PURE__ */ a.createElement(
390
+ Ke,
391
+ {
392
+ key: c.trigger,
393
+ trigger: c.trigger,
394
+ data: (y, h) => c.getMentions(y).then((T) => T.map(Rt)).then(h),
395
+ displayTransform: (y, h) => `@${h} `,
396
+ renderSuggestion: (u = c.renderSuggestion) != null ? u : kt
397
+ }
398
+ )
399
+ ), N ? /* @__PURE__ */ a.createElement("div", { className: q.threadCommentEditorButtons }, /* @__PURE__ */ a.createElement(
400
+ G,
401
+ {
402
+ style: { marginRight: 12 },
403
+ onClick: () => {
404
+ i == null || i(), p(!1), g({ text: void 0 });
405
+ }
406
+ },
407
+ d.t("threadCommentUI.editor.cancel")
408
+ ), /* @__PURE__ */ a.createElement(
409
+ G,
410
+ {
411
+ type: "primary",
412
+ disabled: !f.text,
413
+ onClick: () => {
414
+ f.text && (r == null || r({
415
+ ...f,
416
+ text: f.text
417
+ }), p(!1), g({ text: void 0 }));
418
+ }
419
+ },
420
+ d.t(o ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
421
+ )) : null);
422
+ }), Lt = "univer-thread-comment", jt = "univer-thread-comment-active", At = "univer-thread-comment-content", Vt = "univer-thread-comment-highlight", Bt = "univer-thread-comment-icon-container", zt = "univer-thread-comment-icon", Wt = "univer-thread-comment-title", Ft = "univer-thread-comment-title-position", Zt = "univer-thread-comment-title-highlight", Yt = "univer-thread-comment-username", Kt = "univer-thread-comment-item", Gt = "univer-thread-comment-item-head", qt = "univer-thread-comment-item-title", Jt = "univer-thread-comment-item-title-position", Qt = "univer-thread-comment-item-title-highlight", Xt = "univer-thread-comment-item-time", en = "univer-thread-comment-item-content", tn = "univer-thread-comment-item-at", C = {
423
+ threadComment: Lt,
424
+ threadCommentActive: jt,
425
+ threadCommentContent: At,
426
+ threadCommentHighlight: Vt,
427
+ threadCommentIconContainer: Bt,
428
+ threadCommentIcon: zt,
429
+ threadCommentTitle: Wt,
430
+ threadCommentTitlePosition: Ft,
431
+ threadCommentTitleHighlight: Zt,
432
+ threadCommentUsername: Yt,
433
+ threadCommentItem: Kt,
434
+ threadCommentItemHead: Gt,
435
+ threadCommentItemTitle: qt,
436
+ threadCommentItemTitlePosition: Jt,
437
+ threadCommentItemTitleHighlight: Qt,
438
+ threadCommentItemTime: Xt,
439
+ threadCommentItemContent: en,
440
+ threadCommentItemAt: tn
441
+ }, $e = "__mock__", nn = (t) => {
442
+ const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: i, onReply: s, resolved: c, isRoot: d, onClose: f } = t, g = S(Q), N = S(J), p = S(ee), I = p.getUser(e.personId), u = j(p.currentUser$), y = (u == null ? void 0 : u.userID) === e.personId, h = e.id === $e, [T, w] = P(!1), m = () => {
443
+ g.executeCommand(
444
+ d ? ue.id : Re.id,
445
+ {
446
+ unitId: n,
447
+ subUnitId: r,
448
+ commentId: e.id
449
+ }
450
+ ), d && (f == null || f());
451
+ };
452
+ return /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItem, onMouseLeave: () => w(!1), onMouseEnter: () => w(!0) }, /* @__PURE__ */ a.createElement("img", { className: C.threadCommentItemHead, src: I == null ? void 0 : I.avatar }), /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItemTitle }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentUsername }, (I == null ? void 0 : I.name) || " "), /* @__PURE__ */ a.createElement("div", null, h || c ? null : T ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon, onClick: () => s(I) }, /* @__PURE__ */ a.createElement(_t, null)) : null, y && !h && !c ? /* @__PURE__ */ a.createElement(
453
+ Ge,
454
+ {
455
+ overlay: /* @__PURE__ */ a.createElement(qe, null, /* @__PURE__ */ a.createElement(ie, { key: "edit", onClick: () => i == null ? void 0 : i(!0) }, N.t("threadCommentUI.item.edit")), /* @__PURE__ */ a.createElement(ie, { key: "delete", onClick: m }, N.t("threadCommentUI.item.delete")))
456
+ },
457
+ /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon }, /* @__PURE__ */ a.createElement(Et, null))
458
+ ) : null)), /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItemTime }, e.dT), o ? /* @__PURE__ */ a.createElement(
459
+ Me,
460
+ {
461
+ id: e.id,
462
+ comment: e,
463
+ onCancel: () => i == null ? void 0 : i(!1),
464
+ autoFocus: !0,
465
+ onSave: ({ text: v, attachments: D }) => {
466
+ i == null || i(!1), g.executeCommand(
467
+ we.id,
468
+ {
469
+ unitId: n,
470
+ subUnitId: r,
471
+ payload: {
472
+ commentId: e.id,
473
+ text: v,
474
+ attachments: D
475
+ }
476
+ }
477
+ );
478
+ }
479
+ }
480
+ ) : /* @__PURE__ */ a.createElement("div", { className: C.threadCommentItemContent }, Ne(e.text).map((v, D) => {
481
+ switch (v.type) {
482
+ case "mention":
483
+ return /* @__PURE__ */ a.createElement("a", { className: C.threadCommentItemAt, key: D }, "@", v.content.label, " ");
484
+ default:
485
+ return v.content;
486
+ }
487
+ })));
488
+ }, rn = (t) => {
489
+ var R, B, F;
490
+ const {
491
+ id: e,
492
+ unitId: n,
493
+ subUnitId: r,
494
+ refStr: o,
495
+ showEdit: i = !0,
496
+ onClick: s,
497
+ showHighlight: c,
498
+ onClose: d,
499
+ getSubUnitName: f,
500
+ prefix: g,
501
+ autoFocus: N,
502
+ onMouseEnter: p,
503
+ onMouseLeave: I
504
+ } = t, u = S(ce), [y, h] = P(!1), [T, w] = P("");
505
+ j(u.commentMap$);
506
+ const m = e ? u.getCommentWithChildren(n, r, e) : null, v = S(Q), D = S(ee), U = m == null ? void 0 : m.root.resolved, b = j(D.currentUser$), M = X(null), V = [
507
+ ...m ? [m.root] : (
508
+ // mock empty comment
509
+ [{
510
+ id: $e,
511
+ text: {
512
+ dataStream: `
513
+ \r`
514
+ },
515
+ personId: (R = b == null ? void 0 : b.userID) != null ? R : "",
516
+ ref: o != null ? o : "",
517
+ dT: "",
518
+ unitId: n,
519
+ subUnitId: r
520
+ }]
521
+ ),
522
+ ...(B = m == null ? void 0 : m.children) != null ? B : []
523
+ ], W = () => {
524
+ v.executeCommand(De.id, {
525
+ unitId: n,
526
+ subUnitId: r,
527
+ commentId: e,
528
+ resolved: !U
529
+ }), d == null || d();
530
+ }, O = () => {
531
+ v.executeCommand(
532
+ ue.id,
533
+ {
534
+ unitId: n,
535
+ subUnitId: r,
536
+ commentId: e
537
+ }
538
+ ), d == null || d();
539
+ };
540
+ return /* @__PURE__ */ a.createElement(
541
+ "div",
542
+ {
543
+ className: Qe(C.threadComment, {
544
+ [C.threadCommentActive]: !U && (c || y || g === "cell")
545
+ }),
546
+ onClick: s,
547
+ id: `${g}-${n}-${r}-${e}`,
548
+ onMouseEnter: () => {
549
+ p == null || p(), h(!0);
550
+ },
551
+ onMouseLeave: () => {
552
+ I == null || I(), h(!1);
553
+ }
554
+ },
555
+ !U && c ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentHighlight }) : null,
556
+ /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitle }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitlePosition }, /* @__PURE__ */ a.createElement("div", { className: C.threadCommentTitleHighlight }), o || (m == null ? void 0 : m.root.ref), " · ", f((F = m == null ? void 0 : m.root.subUnitId) != null ? F : r)), m ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIconContainer }, /* @__PURE__ */ a.createElement(
557
+ "div",
558
+ {
559
+ onClick: W,
560
+ className: C.threadCommentIcon,
561
+ style: { color: U ? "rgb(var(--green-500))" : "" }
562
+ },
563
+ U ? /* @__PURE__ */ a.createElement(Tt, null) : /* @__PURE__ */ a.createElement($t, null)
564
+ ), (b == null ? void 0 : b.userID) === m.root.personId ? /* @__PURE__ */ a.createElement("div", { className: C.threadCommentIcon, onClick: O }, /* @__PURE__ */ a.createElement(It, null)) : null) : null),
565
+ /* @__PURE__ */ a.createElement("div", { className: C.threadCommentContent }, V.map(
566
+ (l) => /* @__PURE__ */ a.createElement(
567
+ nn,
568
+ {
569
+ onClose: d,
570
+ unitId: n,
571
+ subUnitId: r,
572
+ item: l,
573
+ key: l.id,
574
+ isRoot: l.id === (m == null ? void 0 : m.root.id),
575
+ editing: T === l.id,
576
+ resolved: m == null ? void 0 : m.root.resolved,
577
+ onEditingChange: (E) => {
578
+ w(E ? l.id : "");
579
+ },
580
+ onReply: (E) => {
581
+ var $;
582
+ E && (($ = M.current) == null || $.reply(Te([{
583
+ type: "mention",
584
+ content: {
585
+ id: E.userID,
586
+ label: E.name
587
+ }
588
+ }])));
589
+ }
590
+ }
591
+ )
592
+ )),
593
+ i && !T && !U ? /* @__PURE__ */ a.createElement("div", null, /* @__PURE__ */ a.createElement(
594
+ Me,
595
+ {
596
+ key: `${N}`,
597
+ ref: M,
598
+ onSave: ({ text: l, attachments: E }) => {
599
+ v.executeCommand(
600
+ He.id,
601
+ {
602
+ unitId: n,
603
+ subUnitId: r,
604
+ comment: {
605
+ text: l,
606
+ attachments: E,
607
+ dT: Je().format("YYYY/MM/DD HH:mm"),
608
+ id: Be.generateRandomId(),
609
+ ref: o,
610
+ personId: b == null ? void 0 : b.userID,
611
+ parentId: m == null ? void 0 : m.root.id,
612
+ unitId: n,
613
+ subUnitId: r
614
+ }
615
+ }
616
+ );
617
+ },
618
+ autoFocus: N || !m,
619
+ onCancel: () => {
620
+ m || d == null || d();
621
+ }
622
+ }
623
+ )) : null
624
+ );
625
+ }, on = "univer-thread-comment-panel", an = "univer-thread-comment", ln = "univer-thread-comment-panel-forms", sn = "univer-select", mn = "univer-thread-comment-panel-empty", dn = "univer-thread-comment-panel-add", Z = {
626
+ threadCommentPanel: on,
627
+ threadComment: an,
628
+ threadCommentPanelForms: ln,
629
+ select: sn,
630
+ threadCommentPanelEmpty: mn,
631
+ threadCommentPanelAdd: dn
632
+ }, bn = (t) => {
633
+ const { unitId: e, subUnitId$: n, type: r, onAdd: o, getSubUnitName: i, onResolve: s, sortComments: c, onItemLeave: d, onItemEnter: f } = t, [g, N] = P("all"), [p, I] = P("all"), u = S(J), y = S(ee), h = S(ce), [T, w] = P(() => h.getUnit(e)), m = S(A), v = j(m.activeCommentId$), D = j(h.commentUpdate$), U = S(Q), b = j(n), M = y.getCurrentUser(), V = X(!0), W = "panel", O = oe(() => {
634
+ var l, E;
635
+ if (g === "all") {
636
+ const $ = T.map((z) => z[1]).flat().filter((z) => !z.parentId);
637
+ return c ? c($) : $;
638
+ } else
639
+ return (E = (l = T.find(($) => $[0] === b)) == null ? void 0 : l[1]) != null ? E : [];
640
+ }, [g, T, b, c]), R = oe(() => p === "resolved" ? O.filter((l) => l.resolved) : p === "unsolved" ? O.filter((l) => !l.resolved) : p === "concern_me" && M != null && M.userID ? O.map((l) => h.getCommentWithChildren(l.unitId, l.subUnitId, l.id)).map((l) => l != null && l.relativeUsers.has(M.userID) ? l.root : null).filter(Boolean) : O, [O, M == null ? void 0 : M.userID, p, h]), B = p !== "all" || g !== "all", F = () => {
641
+ I("all"), N("all");
642
+ };
643
+ return ae(() => {
644
+ e && w(
645
+ h.getUnit(e)
646
+ );
647
+ }, [e, h, D]), ae(() => {
648
+ var ne;
649
+ if (!v)
650
+ return;
651
+ if (!V.current) {
652
+ V.current = !0;
653
+ return;
654
+ }
655
+ const { unitId: l, subUnitId: E, commentId: $ } = v, z = `${W}-${l}-${E}-${$}`;
656
+ (ne = document.getElementById(z)) == null || ne.scrollIntoView({ block: "center" });
657
+ }, [v]), /* @__PURE__ */ a.createElement("div", { className: Z.threadCommentPanel }, /* @__PURE__ */ a.createElement("div", { className: Z.threadCommentPanelForms }, /* @__PURE__ */ a.createElement(
658
+ le,
659
+ {
660
+ borderless: !0,
661
+ value: g,
662
+ onChange: (l) => N(l),
663
+ options: [
664
+ {
665
+ value: "current",
666
+ label: u.t("threadCommentUI.filter.sheet.current")
667
+ },
668
+ {
669
+ value: "all",
670
+ label: u.t("threadCommentUI.filter.sheet.all")
671
+ }
672
+ ]
673
+ }
674
+ ), /* @__PURE__ */ a.createElement(
675
+ le,
676
+ {
677
+ borderless: !0,
678
+ value: p,
679
+ onChange: (l) => I(l),
680
+ options: [
681
+ {
682
+ value: "all",
683
+ label: u.t("threadCommentUI.filter.status.all")
684
+ },
685
+ {
686
+ value: "resolved",
687
+ label: u.t("threadCommentUI.filter.status.resolved")
688
+ },
689
+ {
690
+ value: "unsolved",
691
+ label: u.t("threadCommentUI.filter.status.unsolved")
692
+ },
693
+ {
694
+ value: "concern_me",
695
+ label: u.t("threadCommentUI.filter.status.concernMe")
696
+ }
697
+ ]
698
+ }
699
+ )), R == null ? void 0 : R.map((l) => /* @__PURE__ */ a.createElement(
700
+ rn,
701
+ {
702
+ prefix: W,
703
+ getSubUnitName: i,
704
+ key: l.id,
705
+ id: l.id,
706
+ unitId: l.unitId,
707
+ subUnitId: l.subUnitId,
708
+ type: r,
709
+ showEdit: (v == null ? void 0 : v.commentId) === l.id,
710
+ showHighlight: (v == null ? void 0 : v.commentId) === l.id,
711
+ onClick: () => {
712
+ V.current = !1, U.executeCommand(ge.id, {
713
+ unitId: l.unitId,
714
+ subUnitId: l.subUnitId,
715
+ commentId: l.id,
716
+ temp: !0
717
+ });
718
+ },
719
+ onClose: () => s == null ? void 0 : s(l.id),
720
+ onMouseEnter: () => f == null ? void 0 : f(l),
721
+ onMouseLeave: () => d == null ? void 0 : d(l)
722
+ }
723
+ )), R.length ? null : /* @__PURE__ */ a.createElement("div", { className: Z.threadCommentPanelEmpty }, B ? u.t("threadCommentUI.panel.filterEmpty") : u.t("threadCommentUI.panel.empty"), B ? /* @__PURE__ */ a.createElement(
724
+ G,
725
+ {
726
+ onClick: F,
727
+ type: "link"
728
+ },
729
+ u.t("threadCommentUI.panel.reset")
730
+ ) : /* @__PURE__ */ a.createElement(
731
+ G,
732
+ {
733
+ id: "thread-comment-add",
734
+ className: Z.threadCommentPanelAdd,
735
+ type: "primary",
736
+ onClick: o
737
+ },
738
+ /* @__PURE__ */ a.createElement(St, null),
739
+ u.t("threadCommentUI.panel.addComment")
740
+ )));
741
+ };
742
+ export {
743
+ pe as IThreadCommentMentionDataService,
744
+ ge as SetActiveCommentOperation,
745
+ Xe as THREAD_COMMENT_PANEL,
746
+ bn as ThreadCommentPanel,
747
+ A as ThreadCommentPanelService,
748
+ rn as ThreadCommentTree,
749
+ ot as ToggleSheetCommentPanelOperation,
750
+ de as UniverThreadCommentUIPlugin
751
+ };