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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,330 +1,40 @@
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, UniverInstanceType, IUniverInstanceService, CommandType, createIdentifier, DependentOn, Injector, Plugin, mergeOverrideWithDependencies, ICommandService, IConfigService, CustomRangeType, useDependency, LocaleService, UserManagerService, generateRandomId } from "@univerjs/core";
6
- import { UniverThreadCommentPlugin, ThreadCommentModel, AddCommentCommand, UpdateCommentCommand, ResolveCommentCommand, DeleteCommentTreeCommand, DeleteCommentCommand } from "@univerjs/thread-comment";
7
- import { ISidebarService, useObservable } from "@univerjs/ui";
8
- import { BehaviorSubject, filter, debounceTime } from "rxjs";
9
- import { Mentions, Mention, Button, Tooltip, Dropdown, Menu, MenuItem, Select } from "@univerjs/design";
10
- import React, { forwardRef, useRef, createElement, useState, useImperativeHandle, useMemo, useEffect } from "react";
11
- import { DocSelectionManagerService } from "@univerjs/docs";
12
- import { DocSelectionRenderService } from "@univerjs/docs-ui";
13
- import { IRenderManagerService } from "@univerjs/engine-render";
14
- import { IThreadCommentMentionDataService as IThreadCommentMentionDataService$1 } from "@univerjs/thread-comment-ui";
15
- var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
16
- function getDefaultExportFromCjs(x) {
17
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
18
- }
19
- __name(getDefaultExportFromCjs, "getDefaultExportFromCjs");
20
- var dayjs_min = { exports: {} };
21
- (function(module, exports) {
22
- (function(t, e) {
23
- module.exports = e();
24
- })(commonjsGlobal, function() {
25
- var t = 1e3, e = 6e4, n = 36e5, r2 = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: /* @__PURE__ */ __name(function(t2) {
26
- var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
27
- return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
28
- }, "ordinal") }, m = /* @__PURE__ */ __name(function(t2, e2, n2) {
29
- var r3 = String(t2);
30
- return !r3 || r3.length >= e2 ? t2 : "" + Array(e2 + 1 - r3.length).join(n2) + t2;
31
- }, "m"), v = { s: m, z: /* @__PURE__ */ __name(function(t2) {
32
- var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r3 = Math.floor(n2 / 60), i2 = n2 % 60;
33
- return (e2 <= 0 ? "+" : "-") + m(r3, 2, "0") + ":" + m(i2, 2, "0");
34
- }, "z"), m: /* @__PURE__ */ __name(function t2(e2, n2) {
35
- if (e2.date() < n2.date()) return -t2(n2, e2);
36
- var r3 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r3, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r3 + (s2 ? -1 : 1), c);
37
- return +(-(r3 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
38
- }, "t"), a: /* @__PURE__ */ __name(function(t2) {
39
- return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
40
- }, "a"), p: /* @__PURE__ */ __name(function(t2) {
41
- return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r2, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
42
- }, "p"), u: /* @__PURE__ */ __name(function(t2) {
43
- return t2 === void 0;
44
- }, "u") }, g = "en", D = {};
45
- D[g] = M;
46
- var p = "$isDayjsObject", S = /* @__PURE__ */ __name(function(t2) {
47
- return t2 instanceof _ || !(!t2 || !t2[p]);
48
- }, "S"), w = /* @__PURE__ */ __name(function t2(e2, n2, r3) {
49
- var i2;
50
- if (!e2) return g;
51
- if (typeof e2 == "string") {
52
- var s2 = e2.toLowerCase();
53
- D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
54
- var u2 = e2.split("-");
55
- if (!i2 && u2.length > 1) return t2(u2[0]);
56
- } else {
57
- var a2 = e2.name;
58
- D[a2] = e2, i2 = a2;
59
- }
60
- return !r3 && i2 && (g = i2), i2 || !r3 && g;
61
- }, "t"), O = /* @__PURE__ */ __name(function(t2, e2) {
62
- if (S(t2)) return t2.clone();
63
- var n2 = typeof e2 == "object" ? e2 : {};
64
- return n2.date = t2, n2.args = arguments, new _(n2);
65
- }, "O"), b = v;
66
- b.l = w, b.i = S, b.w = function(t2, e2) {
67
- return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
68
- };
69
- var _ = function() {
70
- function M2(t2) {
71
- this.$L = w(t2.locale, null, !0), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = !0;
72
- }
73
- __name(M2, "M");
74
- var m2 = M2.prototype;
75
- return m2.parse = function(t2) {
76
- this.$d = function(t3) {
77
- var e2 = t3.date, n2 = t3.utc;
78
- if (e2 === null) return /* @__PURE__ */ new Date(NaN);
79
- if (b.u(e2)) return /* @__PURE__ */ new Date();
80
- if (e2 instanceof Date) return new Date(e2);
81
- if (typeof e2 == "string" && !/Z$/i.test(e2)) {
82
- var r3 = e2.match($);
83
- if (r3) {
84
- var i2 = r3[2] - 1 || 0, s2 = (r3[7] || "0").substring(0, 3);
85
- return n2 ? new Date(Date.UTC(r3[1], i2, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s2)) : new Date(r3[1], i2, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s2);
86
- }
87
- }
88
- return new Date(e2);
89
- }(t2), this.init();
90
- }, m2.init = function() {
91
- var t2 = this.$d;
92
- this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
93
- }, m2.$utils = function() {
94
- return b;
95
- }, m2.isValid = function() {
96
- return this.$d.toString() !== l;
97
- }, m2.isSame = function(t2, e2) {
98
- var n2 = O(t2);
99
- return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
100
- }, m2.isAfter = function(t2, e2) {
101
- return O(t2) < this.startOf(e2);
102
- }, m2.isBefore = function(t2, e2) {
103
- return this.endOf(e2) < O(t2);
104
- }, m2.$g = function(t2, e2, n2) {
105
- return b.u(t2) ? this[e2] : this.set(n2, t2);
106
- }, m2.unix = function() {
107
- return Math.floor(this.valueOf() / 1e3);
108
- }, m2.valueOf = function() {
109
- return this.$d.getTime();
110
- }, m2.startOf = function(t2, e2) {
111
- var n2 = this, r3 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = /* @__PURE__ */ __name(function(t3, e3) {
112
- var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
113
- return r3 ? i2 : i2.endOf(a);
114
- }, "l"), $2 = /* @__PURE__ */ __name(function(t3, e3) {
115
- return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r3 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
116
- }, "$"), y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
117
- switch (f2) {
118
- case h:
119
- return r3 ? l2(1, 0) : l2(31, 11);
120
- case c:
121
- return r3 ? l2(1, M3) : l2(0, M3 + 1);
122
- case o:
123
- var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
124
- return l2(r3 ? m3 - D2 : m3 + (6 - D2), M3);
125
- case a:
126
- case d:
127
- return $2(v2 + "Hours", 0);
128
- case u:
129
- return $2(v2 + "Minutes", 1);
130
- case s:
131
- return $2(v2 + "Seconds", 2);
132
- case i:
133
- return $2(v2 + "Milliseconds", 3);
134
- default:
135
- return this.clone();
136
- }
137
- }, m2.endOf = function(t2) {
138
- return this.startOf(t2, !1);
139
- }, m2.$set = function(t2, e2) {
140
- var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r2] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
141
- if (o2 === c || o2 === h) {
142
- var y2 = this.clone().set(d, 1);
143
- y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
144
- } else l2 && this.$d[l2]($2);
145
- return this.init(), this;
146
- }, m2.set = function(t2, e2) {
147
- return this.clone().$set(t2, e2);
148
- }, m2.get = function(t2) {
149
- return this[b.p(t2)]();
150
- }, m2.add = function(r3, f2) {
151
- var d2, l2 = this;
152
- r3 = Number(r3);
153
- var $2 = b.p(f2), y2 = /* @__PURE__ */ __name(function(t2) {
154
- var e2 = O(l2);
155
- return b.w(e2.date(e2.date() + Math.round(t2 * r3)), l2);
156
- }, "y");
157
- if ($2 === c) return this.set(c, this.$M + r3);
158
- if ($2 === h) return this.set(h, this.$y + r3);
159
- if ($2 === a) return y2(1);
160
- if ($2 === o) return y2(7);
161
- var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r3 * M3;
162
- return b.w(m3, this);
163
- }, m2.subtract = function(t2, e2) {
164
- return this.add(-1 * t2, e2);
165
- }, m2.format = function(t2) {
166
- var e2 = this, n2 = this.$locale();
167
- if (!this.isValid()) return n2.invalidDate || l;
168
- var r3 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = /* @__PURE__ */ __name(function(t3, n3, i3, s3) {
169
- return t3 && (t3[n3] || t3(e2, r3)) || i3[n3].slice(0, s3);
170
- }, "h"), d2 = /* @__PURE__ */ __name(function(t3) {
171
- return b.s(s2 % 12 || 12, t3, "0");
172
- }, "d"), $2 = f2 || function(t3, e3, n3) {
173
- var r4 = t3 < 12 ? "AM" : "PM";
174
- return n3 ? r4.toLowerCase() : r4;
175
- };
176
- return r3.replace(y, function(t3, r4) {
177
- return r4 || function(t4) {
178
- switch (t4) {
179
- case "YY":
180
- return String(e2.$y).slice(-2);
181
- case "YYYY":
182
- return b.s(e2.$y, 4, "0");
183
- case "M":
184
- return a2 + 1;
185
- case "MM":
186
- return b.s(a2 + 1, 2, "0");
187
- case "MMM":
188
- return h2(n2.monthsShort, a2, c2, 3);
189
- case "MMMM":
190
- return h2(c2, a2);
191
- case "D":
192
- return e2.$D;
193
- case "DD":
194
- return b.s(e2.$D, 2, "0");
195
- case "d":
196
- return String(e2.$W);
197
- case "dd":
198
- return h2(n2.weekdaysMin, e2.$W, o2, 2);
199
- case "ddd":
200
- return h2(n2.weekdaysShort, e2.$W, o2, 3);
201
- case "dddd":
202
- return o2[e2.$W];
203
- case "H":
204
- return String(s2);
205
- case "HH":
206
- return b.s(s2, 2, "0");
207
- case "h":
208
- return d2(1);
209
- case "hh":
210
- return d2(2);
211
- case "a":
212
- return $2(s2, u2, !0);
213
- case "A":
214
- return $2(s2, u2, !1);
215
- case "m":
216
- return String(u2);
217
- case "mm":
218
- return b.s(u2, 2, "0");
219
- case "s":
220
- return String(e2.$s);
221
- case "ss":
222
- return b.s(e2.$s, 2, "0");
223
- case "SSS":
224
- return b.s(e2.$ms, 3, "0");
225
- case "Z":
226
- return i2;
227
- }
228
- return null;
229
- }(t3) || i2.replace(":", "");
230
- });
231
- }, m2.utcOffset = function() {
232
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
233
- }, m2.diff = function(r3, d2, l2) {
234
- var $2, y2 = this, M3 = b.p(d2), m3 = O(r3), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = /* @__PURE__ */ __name(function() {
235
- return b.m(y2, m3);
236
- }, "D");
237
- switch (M3) {
238
- case h:
239
- $2 = D2() / 12;
240
- break;
241
- case c:
242
- $2 = D2();
243
- break;
244
- case f:
245
- $2 = D2() / 3;
246
- break;
247
- case o:
248
- $2 = (g2 - v2) / 6048e5;
249
- break;
250
- case a:
251
- $2 = (g2 - v2) / 864e5;
252
- break;
253
- case u:
254
- $2 = g2 / n;
255
- break;
256
- case s:
257
- $2 = g2 / e;
258
- break;
259
- case i:
260
- $2 = g2 / t;
261
- break;
262
- default:
263
- $2 = g2;
264
- }
265
- return l2 ? $2 : b.a($2);
266
- }, m2.daysInMonth = function() {
267
- return this.endOf(c).$D;
268
- }, m2.$locale = function() {
269
- return D[this.$L];
270
- }, m2.locale = function(t2, e2) {
271
- if (!t2) return this.$L;
272
- var n2 = this.clone(), r3 = w(t2, e2, !0);
273
- return r3 && (n2.$L = r3), n2;
274
- }, m2.clone = function() {
275
- return b.w(this.$d, this);
276
- }, m2.toDate = function() {
277
- return new Date(this.valueOf());
278
- }, m2.toJSON = function() {
279
- return this.isValid() ? this.toISOString() : null;
280
- }, m2.toISOString = function() {
281
- return this.$d.toISOString();
282
- }, m2.toString = function() {
283
- return this.$d.toUTCString();
284
- }, M2;
285
- }(), k = _.prototype;
286
- return O.prototype = k, [["$ms", r2], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
287
- k[t2[1]] = function(e2) {
288
- return this.$g(e2, t2[0], t2[1]);
289
- };
290
- }), O.extend = function(t2, e2) {
291
- return t2.$i || (t2(e2, _, O), t2.$i = !0), O;
292
- }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
293
- return O(1e3 * t2);
294
- }, O.en = D[g], O.Ls = D, O.p = {}, O;
295
- });
296
- })(dayjs_min);
297
- var dayjs_minExports = dayjs_min.exports;
298
- const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
299
- function getDT() {
300
- return dayjs().format("YYYY/MM/DD HH:mm");
301
- }
302
- __name(getDT, "getDT");
303
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
304
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
305
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
306
- return kind && result && __defProp$1(target, key, result), result;
307
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a;
308
- let ThreadCommentPanelService = (_a = class extends Disposable {
309
- constructor(_sidebarService, _univerInstanceService) {
1
+ var We = Object.defineProperty;
2
+ var ze = (t, e, r) => e in t ? We(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var w = (t, e, r) => ze(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { Inject as Se, Disposable as Ze, UniverInstanceType as he, IUniverInstanceService as Ge, CommandType as ye, createIdentifier as qe, DependentOn as Ke, Injector as Ye, Plugin as Je, mergeOverrideWithDependencies as Qe, ICommandService as re, IConfigService as Xe, CustomRangeType as et, useDependency as x, LocaleService as fe, UserManagerService as ge, generateRandomId as tt } from "@univerjs/core";
5
+ import { UniverThreadCommentPlugin as nt, ThreadCommentModel as _e, getDT as rt, AddCommentCommand as ot, UpdateCommentCommand as it, ResolveCommentCommand as st, DeleteCommentTreeCommand as je, DeleteCommentCommand as at } from "@univerjs/thread-comment";
6
+ import { ISidebarService as Ne, useObservable as F } from "@univerjs/ui";
7
+ import { BehaviorSubject as pe, filter as lt, debounceTime as dt } from "rxjs";
8
+ import mt, { forwardRef as A, useRef as ne, createElement as z, useState as k, useImperativeHandle as ct, useMemo as le, useEffect as Ce } from "react";
9
+ import { Mentions as ht, Mention as ut, Button as de, Tooltip as vt, Dropdown as Ct, Menu as ft, MenuItem as Ie, Select as xe } from "@univerjs/design";
10
+ import { DocSelectionManagerService as gt } from "@univerjs/docs";
11
+ import { DocSelectionRenderService as pt } from "@univerjs/docs-ui";
12
+ import { IRenderManagerService as It } from "@univerjs/engine-render";
13
+ var xt = Object.defineProperty, bt = Object.getOwnPropertyDescriptor, St = (t, e, r, n) => {
14
+ for (var o = n > 1 ? void 0 : n ? bt(e, r) : e, a = t.length - 1, d; a >= 0; a--)
15
+ (d = t[a]) && (o = (n ? d(e, r, o) : d(o)) || o);
16
+ return n && o && xt(e, r, o), o;
17
+ }, be = (t, e) => (r, n) => e(r, n, t);
18
+ let q = class extends Ze {
19
+ constructor(e, r) {
310
20
  super();
311
- __publicField(this, "_panelVisible", !1);
312
- __publicField(this, "_panelVisible$", new BehaviorSubject(!1));
313
- __publicField(this, "_activeCommentId");
314
- __publicField(this, "_activeCommentId$", new BehaviorSubject(void 0));
315
- __publicField(this, "panelVisible$", this._panelVisible$.asObservable());
316
- __publicField(this, "activeCommentId$", this._activeCommentId$.asObservable());
317
- this._sidebarService = _sidebarService, this._univerInstanceService = _univerInstanceService, this._init(), this.disposeWithMe(() => {
21
+ w(this, "_panelVisible", !1);
22
+ w(this, "_panelVisible$", new pe(!1));
23
+ w(this, "_activeCommentId");
24
+ w(this, "_activeCommentId$", new pe(void 0));
25
+ w(this, "panelVisible$", this._panelVisible$.asObservable());
26
+ w(this, "activeCommentId$", this._activeCommentId$.asObservable());
27
+ this._sidebarService = e, this._univerInstanceService = r, this._init(), this.disposeWithMe(() => {
318
28
  this._activeCommentId$.complete(), this._panelVisible$.complete();
319
29
  });
320
30
  }
321
31
  _init() {
322
32
  this.disposeWithMe(
323
- this._sidebarService.sidebarOptions$.subscribe((opt) => {
324
- opt.visible || this.setPanelVisible(!1);
33
+ this._sidebarService.sidebarOptions$.subscribe((e) => {
34
+ e.visible || this.setPanelVisible(!1);
325
35
  })
326
36
  ), this.disposeWithMe(
327
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
37
+ this._univerInstanceService.getCurrentTypeOfUnit$(he.UNIVER_SHEET).pipe(lt((e) => !e)).subscribe(() => {
328
38
  this._sidebarService.close();
329
39
  })
330
40
  );
@@ -335,733 +45,800 @@ let ThreadCommentPanelService = (_a = class extends Disposable {
335
45
  get activeCommentId() {
336
46
  return this._activeCommentId;
337
47
  }
338
- setPanelVisible(visible) {
339
- this._panelVisible = visible, this._panelVisible$.next(visible);
48
+ setPanelVisible(e) {
49
+ this._panelVisible = e, this._panelVisible$.next(e);
340
50
  }
341
- setActiveComment(commentInfo) {
342
- this._activeCommentId = commentInfo, this._activeCommentId$.next(commentInfo);
51
+ setActiveComment(e) {
52
+ this._activeCommentId = e, this._activeCommentId$.next(e);
343
53
  }
344
- }, __name(_a, "ThreadCommentPanelService"), _a);
345
- ThreadCommentPanelService = __decorateClass$1([
346
- __decorateParam$1(0, Inject(ISidebarService)),
347
- __decorateParam$1(1, IUniverInstanceService)
348
- ], ThreadCommentPanelService);
349
- const THREAD_COMMENT_PANEL = "thread-comment-panel", PLUGIN_NAME = "UNIVER_THREAD_COMMENT_UI_PLUGIN", ToggleSheetCommentPanelOperation = {
54
+ };
55
+ q = St([
56
+ be(0, Se(Ne)),
57
+ be(1, Ge)
58
+ ], q);
59
+ const yt = "thread-comment-panel", _t = "UNIVER_THREAD_COMMENT_UI_PLUGIN", jt = {
350
60
  id: "thread-comment-ui.operation.toggle-panel",
351
- type: CommandType.OPERATION,
352
- handler(accessor) {
353
- const sidebarService = accessor.get(ISidebarService), panelService = accessor.get(ThreadCommentPanelService);
354
- return panelService.panelVisible ? (sidebarService.close(), panelService.setPanelVisible(!1)) : (sidebarService.open({
61
+ type: ye.OPERATION,
62
+ handler(t) {
63
+ const e = t.get(Ne), r = t.get(q);
64
+ return r.panelVisible ? (e.close(), r.setPanelVisible(!1)) : (e.open({
355
65
  header: { title: "threadCommentUI.panel.title" },
356
- children: { label: THREAD_COMMENT_PANEL },
66
+ children: { label: yt },
357
67
  width: 330
358
- }), panelService.setPanelVisible(!0)), !0;
68
+ }), r.setPanelVisible(!0)), !0;
359
69
  }
360
- }, SetActiveCommentOperation = {
70
+ }, W = {
361
71
  id: "thread-comment-ui.operation.set-active-comment",
362
- type: CommandType.OPERATION,
363
- handler(accessor, params) {
364
- return accessor.get(ThreadCommentPanelService).setActiveComment(params), !0;
72
+ type: ye.OPERATION,
73
+ handler(t, e) {
74
+ return t.get(q).setActiveComment(e), !0;
365
75
  }
366
- }, PLUGIN_CONFIG_KEY = "thread-comment-ui.config", defaultPluginConfig = {}, _ThreadCommentMentionDataService = class _ThreadCommentMentionDataService {
76
+ }, Nt = "thread-comment-ui.config", Tt = {};
77
+ class Ut {
367
78
  constructor() {
368
- __publicField(this, "dataSource");
369
- __publicField(this, "renderSuggestion");
370
- __publicField(this, "trigger", "@");
79
+ w(this, "dataSource");
80
+ w(this, "renderSuggestion");
81
+ w(this, "trigger", "@");
371
82
  }
372
- async getMentions(search, unitId, subUnitId) {
373
- return this.dataSource ? this.dataSource.getMentions(search, unitId, subUnitId) : [];
83
+ async getMentions(e, r, n) {
84
+ return this.dataSource ? this.dataSource.getMentions(e, r, n) : [];
374
85
  }
375
- };
376
- __name(_ThreadCommentMentionDataService, "ThreadCommentMentionDataService");
377
- let ThreadCommentMentionDataService = _ThreadCommentMentionDataService;
378
- const IThreadCommentMentionDataService = createIdentifier("thread-comment.mention-data.service");
379
- 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) => {
380
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
381
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
382
- return kind && result && __defProp2(target, key, result), result;
383
- }, "__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"), _a2;
384
- let UniverThreadCommentUIPlugin = (_a2 = class extends Plugin {
385
- constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
386
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
387
- const { menu, ...rest } = this._config;
388
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
86
+ }
87
+ const Te = qe("thread-comment.mention-data.service");
88
+ var Ue = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, Mt = (t, e, r) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Ot = (t, e, r, n) => {
89
+ for (var o = n > 1 ? void 0 : n ? Et(e, r) : e, a = t.length - 1, d; a >= 0; a--)
90
+ (d = t[a]) && (o = (n ? d(e, r, o) : d(o)) || o);
91
+ return n && o && Ue(e, r, o), o;
92
+ }, ve = (t, e) => (r, n) => e(r, n, t), Ee = (t, e, r) => Mt(t, typeof e != "symbol" ? e + "" : e, r);
93
+ let me = class extends Je {
94
+ constructor(t = Tt, e, r, n) {
95
+ super(), this._config = t, this._injector = e, this._commandService = r, this._configService = n;
96
+ const { menu: o, ...a } = this._config;
97
+ o && this._configService.setConfig("menu", o, { merge: !0 }), this._configService.setConfig(Nt, a);
389
98
  }
390
99
  onStarting() {
391
- var _a3;
392
- mergeOverrideWithDependencies([
393
- [ThreadCommentPanelService],
394
- [IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }]
395
- ], (_a3 = this._config) == null ? void 0 : _a3.overrides).forEach((dep) => {
396
- this._injector.add(dep);
397
- }), [ToggleSheetCommentPanelOperation, SetActiveCommentOperation].forEach((command) => {
398
- this._commandService.registerCommand(command);
100
+ var t;
101
+ Qe([
102
+ [q],
103
+ [Te, { useClass: Ut }]
104
+ ], (t = this._config) == null ? void 0 : t.overrides).forEach((e) => {
105
+ this._injector.add(e);
106
+ }), [jt, W].forEach((e) => {
107
+ this._commandService.registerCommand(e);
399
108
  });
400
109
  }
401
- }, __name(_a2, "UniverThreadCommentUIPlugin"), _a2);
402
- __publicField2(UniverThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
403
- __publicField2(UniverThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_UNKNOWN);
404
- UniverThreadCommentUIPlugin = __decorateClass([
405
- DependentOn(UniverThreadCommentPlugin),
406
- __decorateParam(1, Inject(Injector)),
407
- __decorateParam(2, ICommandService),
408
- __decorateParam(3, IConfigService)
409
- ], UniverThreadCommentUIPlugin);
410
- var __assign = function() {
411
- return __assign = Object.assign || function(t) {
412
- for (var s, i = 1, n = arguments.length; i < n; i++) {
413
- s = arguments[i];
414
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
110
+ };
111
+ Ee(me, "pluginName", _t);
112
+ Ee(me, "type", he.UNIVER_UNKNOWN);
113
+ me = Ot([
114
+ Ke(nt),
115
+ ve(1, Se(Ye)),
116
+ ve(2, re),
117
+ ve(3, Xe)
118
+ ], me);
119
+ var Me = { exports: {} }, ue = {};
120
+ /**
121
+ * @license React
122
+ * react-jsx-runtime.production.min.js
123
+ *
124
+ * Copyright (c) Facebook, Inc. and its affiliates.
125
+ *
126
+ * This source code is licensed under the MIT license found in the
127
+ * LICENSE file in the root directory of this source tree.
128
+ */
129
+ var Pt = mt, $t = Symbol.for("react.element"), wt = Symbol.for("react.fragment"), Rt = Object.prototype.hasOwnProperty, Ht = Pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Dt = { key: !0, ref: !0, __self: !0, __source: !0 };
130
+ function Oe(t, e, r) {
131
+ var n, o = {}, a = null, d = null;
132
+ r !== void 0 && (a = "" + r), e.key !== void 0 && (a = "" + e.key), e.ref !== void 0 && (d = e.ref);
133
+ for (n in e) Rt.call(e, n) && !Dt.hasOwnProperty(n) && (o[n] = e[n]);
134
+ if (t && t.defaultProps) for (n in e = t.defaultProps, e) o[n] === void 0 && (o[n] = e[n]);
135
+ return { $$typeof: $t, type: t, key: a, ref: d, props: o, _owner: Ht.current };
136
+ }
137
+ ue.Fragment = wt;
138
+ ue.jsx = Oe;
139
+ ue.jsxs = Oe;
140
+ Me.exports = ue;
141
+ var i = Me.exports, M = function() {
142
+ return M = Object.assign || function(t) {
143
+ for (var e, r = 1, n = arguments.length; r < n; r++) {
144
+ e = arguments[r];
145
+ for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
415
146
  }
416
147
  return t;
417
- }, __assign.apply(this, arguments);
418
- }, __rest = function(s, e) {
419
- var t = {};
420
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
421
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
422
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
423
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
424
- return t;
425
- }, IconBase = forwardRef(function(props, ref) {
426
- 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()));
427
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
148
+ }, M.apply(this, arguments);
149
+ }, kt = function(t, e) {
150
+ var r = {};
151
+ for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]);
152
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
153
+ for (var o = 0, n = Object.getOwnPropertySymbols(t); o < n.length; o++)
154
+ e.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[o]) && (r[n[o]] = t[n[o]]);
155
+ return r;
156
+ }, Z = A(function(t, e) {
157
+ var r = t.icon, n = t.id, o = t.className, a = t.extend, d = kt(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(n, " ").concat(o || "").trim(), v = ne("_".concat(Vt()));
158
+ return Pe(r, "".concat(n), { defIds: r.defIds, idSuffix: v.current }, M({ ref: e, className: c }, d), a);
428
159
  });
429
- function render(node, id, runtimeProps, rootProps, extend) {
430
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
431
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
160
+ function Pe(t, e, r, n, o) {
161
+ return z(t.tag, M(M({ key: e }, At(t, r, o)), n), (Lt(t, r).children || []).map(function(a, d) {
162
+ return Pe(a, "".concat(e, "-").concat(t.tag, "-").concat(d), r, void 0, o);
432
163
  }));
433
164
  }
434
- __name(render, "render");
435
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
436
- var attrs = __assign({}, node.attrs);
437
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
438
- var defIds = runtimeProps.defIds;
439
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a3) {
440
- var key = _a3[0], value = _a3[1];
441
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
442
- })), attrs;
165
+ function At(t, e, r) {
166
+ var n = M({}, t.attrs);
167
+ r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1);
168
+ var o = e.defIds;
169
+ return !o || o.length === 0 || (t.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(a) {
170
+ var d = a[0], c = a[1];
171
+ typeof c == "string" && (n[d] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
172
+ })), n;
443
173
  }
444
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
445
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
446
- var _a3, defIds = runtimeProps.defIds;
447
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a3 = node.children) === null || _a3 === void 0) && _a3.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
448
- 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;
449
- }) }) : node;
174
+ function Lt(t, e) {
175
+ var r, n = e.defIds;
176
+ return !n || n.length === 0 ? t : t.tag === "defs" && (!((r = t.children) === null || r === void 0) && r.length) ? M(M({}, t), { children: t.children.map(function(o) {
177
+ return typeof o.attrs.id == "string" && n && n.indexOf(o.attrs.id) > -1 ? M(M({}, o), { attrs: M(M({}, o.attrs), { id: o.attrs.id + e.idSuffix }) }) : o;
178
+ }) }) : t;
450
179
  }
451
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
452
- function generateShortUuid() {
180
+ function Vt() {
453
181
  return Math.random().toString(36).substring(2, 8);
454
182
  }
455
- __name(generateShortUuid, "generateShortUuid");
456
- IconBase.displayName = "UniverIcon";
457
- var element$5 = { 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" } }] }, DeleteSingle = forwardRef(function(props, ref) {
458
- return createElement(IconBase, Object.assign({}, props, {
183
+ Z.displayName = "UniverIcon";
184
+ var Bt = { 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" } }] }, $e = A(function(t, e) {
185
+ return z(Z, Object.assign({}, t, {
459
186
  id: "delete-single",
460
- ref,
461
- icon: element$5
187
+ ref: e,
188
+ icon: Bt
462
189
  }));
463
190
  });
464
- DeleteSingle.displayName = "DeleteSingle";
465
- var element$4 = { 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" } }] }, IncreaseSingle = forwardRef(function(props, ref) {
466
- return createElement(IconBase, Object.assign({}, props, {
191
+ $e.displayName = "DeleteSingle";
192
+ var Ft = { 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" } }] }, we = A(function(t, e) {
193
+ return z(Z, Object.assign({}, t, {
467
194
  id: "increase-single",
468
- ref,
469
- icon: element$4
195
+ ref: e,
196
+ icon: Ft
470
197
  }));
471
198
  });
472
- IncreaseSingle.displayName = "IncreaseSingle";
473
- var element$3 = { 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" } }] }, MoreHorizontalSingle = forwardRef(function(props, ref) {
474
- return createElement(IconBase, Object.assign({}, props, {
199
+ we.displayName = "IncreaseSingle";
200
+ var Wt = { 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" } }] }, Re = A(function(t, e) {
201
+ return z(Z, Object.assign({}, t, {
475
202
  id: "more-horizontal-single",
476
- ref,
477
- icon: element$3
203
+ ref: e,
204
+ icon: Wt
478
205
  }));
479
206
  });
480
- MoreHorizontalSingle.displayName = "MoreHorizontalSingle";
481
- var element$2 = { 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 } }] }, ReplyToCommentSingle = forwardRef(function(props, ref) {
482
- return createElement(IconBase, Object.assign({}, props, {
207
+ Re.displayName = "MoreHorizontalSingle";
208
+ var zt = { 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 } }] }, He = A(function(t, e) {
209
+ return z(Z, Object.assign({}, t, {
483
210
  id: "reply-to-comment-single",
484
- ref,
485
- icon: element$2
211
+ ref: e,
212
+ icon: zt
486
213
  }));
487
214
  });
488
- ReplyToCommentSingle.displayName = "ReplyToCommentSingle";
489
- var element$1 = { 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" } }] }, ResolvedSingle = forwardRef(function(props, ref) {
490
- return createElement(IconBase, Object.assign({}, props, {
215
+ He.displayName = "ReplyToCommentSingle";
216
+ var Zt = { 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" } }] }, De = A(function(t, e) {
217
+ return z(Z, Object.assign({}, t, {
491
218
  id: "resolved-single",
492
- ref,
493
- icon: element$1
219
+ ref: e,
220
+ icon: Zt
494
221
  }));
495
222
  });
496
- ResolvedSingle.displayName = "ResolvedSingle";
497
- var element = { 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 } }] }, SolveSingle = forwardRef(function(props, ref) {
498
- return createElement(IconBase, Object.assign({}, props, {
223
+ De.displayName = "ResolvedSingle";
224
+ var Gt = { 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 } }] }, ke = A(function(t, e) {
225
+ return z(Z, Object.assign({}, t, {
499
226
  id: "solve-single",
500
- ref,
501
- icon: element
227
+ ref: e,
228
+ icon: Gt
502
229
  }));
503
230
  });
504
- SolveSingle.displayName = "SolveSingle";
505
- function r(e) {
506
- var t, f, n = "";
507
- if (typeof e == "string" || typeof e == "number") n += e;
508
- else if (typeof e == "object") if (Array.isArray(e)) {
509
- var o = e.length;
510
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
511
- } else for (f in e) e[f] && (n && (n += " "), n += f);
231
+ ke.displayName = "SolveSingle";
232
+ function Ae(t) {
233
+ var e, r, n = "";
234
+ if (typeof t == "string" || typeof t == "number") n += t;
235
+ else if (typeof t == "object") if (Array.isArray(t)) {
236
+ var o = t.length;
237
+ for (e = 0; e < o; e++) t[e] && (r = Ae(t[e])) && (n && (n += " "), n += r);
238
+ } else for (r in t) t[r] && (n && (n += " "), n += r);
512
239
  return n;
513
240
  }
514
- __name(r, "r");
515
- function clsx() {
516
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
241
+ function qt() {
242
+ for (var t, e, r = 0, n = "", o = arguments.length; r < o; r++) (t = arguments[r]) && (e = Ae(t)) && (n && (n += " "), n += e);
517
243
  return n;
518
244
  }
519
- __name(clsx, "clsx");
520
- const threadCommentEditorButtons = "univer-thread-comment-editor-buttons", threadCommentEditorSuggestion = "univer-thread-comment-editor-suggestion", threadCommentEditorSuggestionActive = "univer-thread-comment-editor-suggestionActive", threadCommentEditorSuggestionIcon = "univer-thread-comment-editor-suggestion-icon", styles$2 = {
521
- threadCommentEditorButtons,
522
- threadCommentEditorSuggestion,
523
- threadCommentEditorSuggestionActive,
524
- threadCommentEditorSuggestionIcon
525
- }, parseMentions = /* @__PURE__ */ __name((text) => {
526
- const regex = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
527
- let match, lastIndex = 0;
528
- const result = [];
529
- for (; (match = regex.exec(text)) !== null; )
530
- match.index > lastIndex && result.push({
245
+ const Kt = "univer-thread-comment-editor-buttons", Yt = "univer-thread-comment-editor-suggestion", Jt = "univer-thread-comment-editor-suggestionActive", Qt = "univer-thread-comment-editor-suggestion-icon", ce = {
246
+ threadCommentEditorButtons: Kt,
247
+ threadCommentEditorSuggestion: Yt,
248
+ threadCommentEditorSuggestionActive: Jt,
249
+ threadCommentEditorSuggestionIcon: Qt
250
+ }, Xt = (t) => {
251
+ const e = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
252
+ let r, n = 0;
253
+ const o = [];
254
+ for (; (r = e.exec(t)) !== null; )
255
+ r.index > n && o.push({
531
256
  type: "text",
532
- content: text.substring(lastIndex, match.index)
533
- }), match[1] && match[2] ? result.push({
257
+ content: t.substring(n, r.index)
258
+ }), r[1] && r[2] ? o.push({
534
259
  type: "mention",
535
260
  content: {
536
- label: match[1],
537
- id: match[2]
261
+ label: r[1],
262
+ id: r[2]
538
263
  }
539
- }) : match[3] && result.push({
264
+ }) : r[3] && o.push({
540
265
  type: "text",
541
- content: match[3]
542
- }), lastIndex = regex.lastIndex;
543
- return lastIndex < text.length && result.push({
266
+ content: r[3]
267
+ }), n = e.lastIndex;
268
+ return n < t.length && o.push({
544
269
  type: "text",
545
- content: text.substring(lastIndex)
546
- }), result;
547
- }, "parseMentions"), transformTextNode2Text = /* @__PURE__ */ __name((nodes) => nodes.map((item) => {
548
- switch (item.type) {
270
+ content: t.substring(n)
271
+ }), o;
272
+ }, en = (t) => t.map((e) => {
273
+ switch (e.type) {
549
274
  case "mention":
550
- return `@[${item.content.label}](${item.content.id})`;
275
+ return `@[${e.content.label}](${e.content.id})`;
551
276
  default:
552
- return item.content;
277
+ return e.content;
553
278
  }
554
- }).join(""), "transformTextNode2Text"), transformDocument2TextNodes = /* @__PURE__ */ __name((doc) => {
555
- const { dataStream, customRanges } = doc, end = dataStream.length - 2, textNodes = [];
556
- let lastIndex = 0;
557
- return customRanges == null || customRanges.forEach((range) => {
558
- lastIndex < range.startIndex && textNodes.push({
279
+ }).join(""), Le = (t) => {
280
+ const { dataStream: e, customRanges: r } = t, n = e.length - 2, o = [];
281
+ let a = 0;
282
+ return r == null || r.forEach((d) => {
283
+ a < d.startIndex && o.push({
559
284
  type: "text",
560
- content: dataStream.slice(lastIndex, range.startIndex)
561
- }), textNodes.push({
285
+ content: e.slice(a, d.startIndex)
286
+ }), o.push({
562
287
  type: "mention",
563
288
  content: {
564
- label: dataStream.slice(range.startIndex, range.endIndex).slice(1, -1),
565
- id: range.rangeId
289
+ label: e.slice(d.startIndex, d.endIndex).slice(1, -1),
290
+ id: d.rangeId
566
291
  }
567
- }), lastIndex = range.endIndex;
568
- }), textNodes.push({
292
+ }), a = d.endIndex;
293
+ }), o.push({
569
294
  type: "text",
570
- content: dataStream.slice(lastIndex, end)
571
- }), textNodes;
572
- }, "transformDocument2TextNodes"), transformTextNodes2Document = /* @__PURE__ */ __name((nodes) => {
573
- let str = "";
574
- const customRanges = [];
575
- return nodes.forEach((node) => {
576
- switch (node.type) {
295
+ content: e.slice(a, n)
296
+ }), o;
297
+ }, Ve = (t) => {
298
+ let e = "";
299
+ const r = [];
300
+ return t.forEach((n) => {
301
+ switch (n.type) {
577
302
  case "text":
578
- str += node.content;
303
+ e += n.content;
579
304
  break;
580
305
  case "mention": {
581
- const start = str.length;
582
- str += `${node.content.label}`;
583
- const end = str.length;
584
- customRanges.push({
585
- rangeId: node.content.id,
586
- rangeType: CustomRangeType.MENTION,
587
- startIndex: start,
588
- endIndex: end
306
+ const o = e.length;
307
+ e += `${n.content.label}`;
308
+ const a = e.length;
309
+ r.push({
310
+ rangeId: n.content.id,
311
+ rangeType: et.MENTION,
312
+ startIndex: o,
313
+ endIndex: a,
314
+ properties: {}
589
315
  });
590
316
  break;
591
317
  }
592
318
  }
593
- }), str += `
319
+ }), e += `
594
320
  \r`, {
595
321
  textRuns: [],
596
322
  paragraphs: [
597
323
  {
598
- startIndex: str.length - 2,
324
+ startIndex: e.length - 2,
599
325
  paragraphStyle: {}
600
326
  }
601
327
  ],
602
328
  sectionBreaks: [
603
329
  {
604
- startIndex: str.length - 1
330
+ startIndex: e.length - 1
605
331
  }
606
332
  ],
607
- dataStream: str,
608
- customRanges
333
+ dataStream: e,
334
+ customRanges: r
609
335
  };
610
- }, "transformTextNodes2Document"), transformMention = /* @__PURE__ */ __name((mention) => ({
611
- display: mention.label,
612
- id: `${mention.id}`,
613
- raw: mention
614
- }), "transformMention"), defaultRenderSuggestion = /* @__PURE__ */ __name((mention, search, highlightedDisplay, index, focused) => {
615
- var _a3, _b;
616
- const icon = (_a3 = mention.raw) == null ? void 0 : _a3.icon;
617
- return /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorSuggestion }, icon ? /* @__PURE__ */ React.createElement("img", { className: styles$2.threadCommentEditorSuggestionIcon, src: icon }) : null, /* @__PURE__ */ React.createElement("div", null, (_b = mention.display) != null ? _b : mention.id));
618
- }, "defaultRenderSuggestion"), ThreadCommentEditor = forwardRef((props, ref) => {
619
- var _a3, _b;
620
- const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService$1), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localComment, setLocalComment] = useState({ ...comment }), [editing, setEditing] = useState(!1), inputRef = useRef(null), docSelectionManagerService = useDependency(DocSelectionManagerService), docSelectionRenderService = (_a3 = useDependency(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_DOC)) == null ? void 0 : _a3.with(DocSelectionRenderService);
621
- useImperativeHandle(ref, () => ({
622
- reply(text) {
623
- var _a4;
624
- setLocalComment({
625
- ...comment,
626
- text,
336
+ }, tn = (t) => ({
337
+ display: t.label,
338
+ id: `${t.id}`,
339
+ raw: t
340
+ }), nn = (t, e, r, n, o) => {
341
+ var d, c;
342
+ const a = (d = t.raw) == null ? void 0 : d.icon;
343
+ return /* @__PURE__ */ i.jsxs("div", { className: ce.threadCommentEditorSuggestion, children: [
344
+ a ? /* @__PURE__ */ i.jsx("img", { className: ce.threadCommentEditorSuggestionIcon, src: a }) : null,
345
+ /* @__PURE__ */ i.jsx("div", { children: (c = t.display) != null ? c : t.id })
346
+ ] });
347
+ }, Be = A((t, e) => {
348
+ var p, U;
349
+ const { comment: r, onSave: n, id: o, onCancel: a, autoFocus: d, unitId: c, subUnitId: v } = t, S = x(Te), O = x(re), N = x(fe), [f, u] = k({ ...r }), [C, g] = k(!1), T = ne(null), b = x(gt), m = (p = x(It).getCurrentTypeOfRenderer(he.UNIVER_DOC)) == null ? void 0 : p.with(pt);
350
+ ct(e, () => ({
351
+ reply(s) {
352
+ var I;
353
+ u({
354
+ ...r,
355
+ text: s,
627
356
  attachments: []
628
- }), (_a4 = inputRef.current) == null || _a4.inputElement.focus();
357
+ }), (I = T.current) == null || I.inputElement.focus();
629
358
  }
630
359
  }));
631
- const handleSave = /* @__PURE__ */ __name(() => {
632
- var _a4;
633
- localComment.text && (onSave == null || onSave({
634
- ...localComment,
635
- text: localComment.text
636
- }), setEditing(!1), setLocalComment({ text: void 0 }), (_a4 = inputRef.current) == null || _a4.inputElement.blur());
637
- }, "handleSave");
638
- return /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditor, onClick: /* @__PURE__ */ __name((e) => e.preventDefault(), "onClick") }, /* @__PURE__ */ React.createElement(
639
- Mentions,
640
- {
641
- ref: inputRef,
642
- autoFocus,
643
- style: { width: "100%" },
644
- placeholder: localeService.t("threadCommentUI.editor.placeholder"),
645
- value: localComment != null && localComment.text ? transformTextNode2Text(transformDocument2TextNodes(localComment.text)) : "",
646
- onChange: /* @__PURE__ */ __name((e) => {
647
- e.target.value || setLocalComment({ ...comment, text: void 0 }), setLocalComment == null || setLocalComment({ ...comment, text: transformTextNodes2Document(parseMentions(e.target.value)) });
648
- }, "onChange"),
649
- onFocus: /* @__PURE__ */ __name(() => {
650
- const activeRange = docSelectionManagerService.getActiveTextRange();
651
- activeRange && activeRange.collapsed && (docSelectionRenderService == null || docSelectionRenderService.removeAllRanges()), docSelectionRenderService == null || docSelectionRenderService.blur(), setEditing(!0);
652
- }, "onFocus")
653
- },
654
- /* @__PURE__ */ React.createElement(
655
- Mention,
360
+ const D = () => {
361
+ var s;
362
+ f.text && (n == null || n({
363
+ ...f,
364
+ text: f.text
365
+ }), g(!1), u({ text: void 0 }), (s = T.current) == null || s.inputElement.blur());
366
+ };
367
+ return /* @__PURE__ */ i.jsxs("div", { className: ce.threadCommentEditor, onClick: (s) => s.preventDefault(), children: [
368
+ /* @__PURE__ */ i.jsx(
369
+ ht,
656
370
  {
657
- key: mentionDataService.trigger,
658
- trigger: mentionDataService.trigger,
659
- data: /* @__PURE__ */ __name((query, callback) => mentionDataService.getMentions(query, unitId, subUnitId).then((res) => res.map(transformMention)).then(callback), "data"),
660
- displayTransform: /* @__PURE__ */ __name((id2, label) => `@${label} `, "displayTransform"),
661
- renderSuggestion: (_b = mentionDataService.renderSuggestion) != null ? _b : defaultRenderSuggestion
371
+ ref: T,
372
+ autoFocus: d,
373
+ style: { width: "100%" },
374
+ placeholder: N.t("threadCommentUI.editor.placeholder"),
375
+ value: f != null && f.text ? en(Le(f.text)) : "",
376
+ onChange: (s) => {
377
+ s.target.value || u({ ...r, text: void 0 }), u == null || u({ ...r, text: Ve(Xt(s.target.value)) });
378
+ },
379
+ onFocus: () => {
380
+ const s = b.getActiveTextRange();
381
+ s && s.collapsed && (m == null || m.removeAllRanges()), m == null || m.blur(), g(!0);
382
+ },
383
+ children: /* @__PURE__ */ i.jsx(
384
+ ut,
385
+ {
386
+ trigger: S.trigger,
387
+ data: (s, I) => S.getMentions(s, c, v).then((y) => y.map(tn)).then(I),
388
+ displayTransform: (s, I) => `@${I} `,
389
+ renderSuggestion: (U = S.renderSuggestion) != null ? U : nn
390
+ },
391
+ S.trigger
392
+ )
662
393
  }
663
- )
664
- ), editing ? /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorButtons }, /* @__PURE__ */ React.createElement(
665
- Button,
666
- {
667
- style: { marginRight: 12 },
668
- onClick: /* @__PURE__ */ __name(() => {
669
- onCancel == null || onCancel(), setEditing(!1), setLocalComment({ text: void 0 }), commandService.executeCommand(SetActiveCommentOperation.id);
670
- }, "onClick")
671
- },
672
- localeService.t("threadCommentUI.editor.cancel")
673
- ), /* @__PURE__ */ React.createElement(
674
- Button,
675
- {
676
- type: "primary",
677
- disabled: !localComment.text,
678
- onClick: handleSave
679
- },
680
- localeService.t(id ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
681
- )) : null);
682
- }), threadComment$1 = "univer-thread-comment", threadCommentActive = "univer-thread-comment-active", threadCommentContent = "univer-thread-comment-content", threadCommentHighlight = "univer-thread-comment-highlight", threadCommentIconContainer = "univer-thread-comment-icon-container", threadCommentIcon = "univer-thread-comment-icon", threadCommentTitle = "univer-thread-comment-title", threadCommentTitlePosition = "univer-thread-comment-title-position", threadCommentTitleHighlight = "univer-thread-comment-title-highlight", threadCommentTitlePositionText = "univer-thread-comment-title-position-text", threadCommentUsername = "univer-thread-comment-username", threadCommentItem = "univer-thread-comment-item", threadCommentItemHead = "univer-thread-comment-item-head", threadCommentItemTitle = "univer-thread-comment-item-title", threadCommentItemTitlePosition = "univer-thread-comment-item-title-position", threadCommentItemTitleHighlight = "univer-thread-comment-item-title-highlight", threadCommentItemTime = "univer-thread-comment-item-time", threadCommentItemContent = "univer-thread-comment-item-content", threadCommentItemAt = "univer-thread-comment-item-at", styles$1 = {
683
- threadComment: threadComment$1,
684
- threadCommentActive,
685
- threadCommentContent,
686
- threadCommentHighlight,
687
- threadCommentIconContainer,
688
- threadCommentIcon,
689
- threadCommentTitle,
690
- threadCommentTitlePosition,
691
- threadCommentTitleHighlight,
692
- threadCommentTitlePositionText,
693
- threadCommentUsername,
694
- threadCommentItem,
695
- threadCommentItemHead,
696
- threadCommentItemTitle,
697
- threadCommentItemTitlePosition,
698
- threadCommentItemTitleHighlight,
699
- threadCommentItemTime,
700
- threadCommentItemContent,
701
- threadCommentItemAt
702
- }, MOCK_ID = "__mock__", ThreadCommentItem = /* @__PURE__ */ __name((props) => {
703
- const { item, unitId, subUnitId, editing, onEditingChange, onReply, resolved, isRoot, onClose, onDeleteComment } = props, commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), userManagerService = useDependency(UserManagerService), user = userManagerService.getUser(item.personId), currentUser = useObservable(userManagerService.currentUser$), isCommentBySelf = (currentUser == null ? void 0 : currentUser.userID) === item.personId, isMock = item.id === MOCK_ID, [showReply, setShowReply] = useState(!1), handleDeleteItem = /* @__PURE__ */ __name(() => {
704
- (onDeleteComment == null ? void 0 : onDeleteComment(item)) !== !1 && (commandService.executeCommand(
705
- isRoot ? DeleteCommentTreeCommand.id : DeleteCommentCommand.id,
394
+ ),
395
+ C ? /* @__PURE__ */ i.jsxs("div", { className: ce.threadCommentEditorButtons, children: [
396
+ /* @__PURE__ */ i.jsx(
397
+ de,
398
+ {
399
+ style: { marginRight: 12 },
400
+ onClick: () => {
401
+ a == null || a(), g(!1), u({ text: void 0 }), O.executeCommand(W.id);
402
+ },
403
+ children: N.t("threadCommentUI.editor.cancel")
404
+ }
405
+ ),
406
+ /* @__PURE__ */ i.jsx(
407
+ de,
408
+ {
409
+ type: "primary",
410
+ disabled: !f.text,
411
+ onClick: D,
412
+ children: N.t(o ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
413
+ }
414
+ )
415
+ ] }) : null
416
+ ] });
417
+ }), rn = "univer-thread-comment", on = "univer-thread-comment-active", sn = "univer-thread-comment-content", an = "univer-thread-comment-highlight", ln = "univer-thread-comment-icon-container", dn = "univer-thread-comment-icon", mn = "univer-thread-comment-title", cn = "univer-thread-comment-title-position", hn = "univer-thread-comment-title-highlight", un = "univer-thread-comment-title-position-text", vn = "univer-thread-comment-username", Cn = "univer-thread-comment-item", fn = "univer-thread-comment-item-head", gn = "univer-thread-comment-item-title", pn = "univer-thread-comment-item-title-position", In = "univer-thread-comment-item-title-highlight", xn = "univer-thread-comment-item-time", bn = "univer-thread-comment-item-content", Sn = "univer-thread-comment-item-at", h = {
418
+ threadComment: rn,
419
+ threadCommentActive: on,
420
+ threadCommentContent: sn,
421
+ threadCommentHighlight: an,
422
+ threadCommentIconContainer: ln,
423
+ threadCommentIcon: dn,
424
+ threadCommentTitle: mn,
425
+ threadCommentTitlePosition: cn,
426
+ threadCommentTitleHighlight: hn,
427
+ threadCommentTitlePositionText: un,
428
+ threadCommentUsername: vn,
429
+ threadCommentItem: Cn,
430
+ threadCommentItemHead: fn,
431
+ threadCommentItemTitle: gn,
432
+ threadCommentItemTitlePosition: pn,
433
+ threadCommentItemTitleHighlight: In,
434
+ threadCommentItemTime: xn,
435
+ threadCommentItemContent: bn,
436
+ threadCommentItemAt: Sn
437
+ }, Fe = "__mock__", yn = (t) => {
438
+ const { item: e, unitId: r, subUnitId: n, editing: o, onEditingChange: a, onReply: d, resolved: c, isRoot: v, onClose: S, onDeleteComment: O } = t, N = x(re), f = x(fe), u = x(ge), C = u.getUser(e.personId), g = F(u.currentUser$), T = (g == null ? void 0 : g.userID) === e.personId, b = e.id === Fe, [L, m] = k(!1), D = () => {
439
+ (O == null ? void 0 : O(e)) !== !1 && (N.executeCommand(
440
+ v ? je.id : at.id,
706
441
  {
707
- unitId,
708
- subUnitId,
709
- commentId: item.id
442
+ unitId: r,
443
+ subUnitId: n,
444
+ commentId: e.id
710
445
  }
711
- ), isRoot && (onClose == null || onClose()));
712
- }, "handleDeleteItem");
713
- return /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItem, onMouseLeave: /* @__PURE__ */ __name(() => setShowReply(!1), "onMouseLeave"), onMouseEnter: /* @__PURE__ */ __name(() => setShowReply(!0), "onMouseEnter") }, /* @__PURE__ */ React.createElement("img", { className: styles$1.threadCommentItemHead, src: user == null ? void 0 : user.avatar }), /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemTitle }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentUsername }, (user == null ? void 0 : user.name) || " "), /* @__PURE__ */ React.createElement("div", null, isMock || resolved ? null : showReply ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon, onClick: /* @__PURE__ */ __name(() => onReply(user), "onClick") }, /* @__PURE__ */ React.createElement(ReplyToCommentSingle, null)) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ React.createElement(
714
- Dropdown,
715
- {
716
- overlay: /* @__PURE__ */ React.createElement(Menu, null, /* @__PURE__ */ React.createElement(MenuItem, { key: "edit", onClick: /* @__PURE__ */ __name(() => onEditingChange == null ? void 0 : onEditingChange(!0), "onClick") }, localeService.t("threadCommentUI.item.edit")), /* @__PURE__ */ React.createElement(MenuItem, { key: "delete", onClick: handleDeleteItem }, localeService.t("threadCommentUI.item.delete")))
717
- },
718
- /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon }, /* @__PURE__ */ React.createElement(MoreHorizontalSingle, null))
719
- ) : null)), /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemTime }, item.dT), editing ? /* @__PURE__ */ React.createElement(
720
- ThreadCommentEditor,
721
- {
722
- id: item.id,
723
- comment: item,
724
- onCancel: /* @__PURE__ */ __name(() => onEditingChange == null ? void 0 : onEditingChange(!1), "onCancel"),
725
- autoFocus: !0,
726
- unitId,
727
- subUnitId,
728
- onSave: /* @__PURE__ */ __name(({ text, attachments }) => {
729
- onEditingChange == null || onEditingChange(!1), commandService.executeCommand(
730
- UpdateCommentCommand.id,
446
+ ), v && (S == null || S()));
447
+ };
448
+ return /* @__PURE__ */ i.jsxs("div", { className: h.threadCommentItem, onMouseLeave: () => m(!1), onMouseEnter: () => m(!0), children: [
449
+ /* @__PURE__ */ i.jsx("img", { className: h.threadCommentItemHead, src: C == null ? void 0 : C.avatar }),
450
+ /* @__PURE__ */ i.jsxs("div", { className: h.threadCommentItemTitle, children: [
451
+ /* @__PURE__ */ i.jsx("div", { className: h.threadCommentUsername, children: (C == null ? void 0 : C.name) || " " }),
452
+ /* @__PURE__ */ i.jsxs("div", { children: [
453
+ b || c ? null : L ? /* @__PURE__ */ i.jsx("div", { className: h.threadCommentIcon, onClick: () => d(C), children: /* @__PURE__ */ i.jsx(He, {}) }) : null,
454
+ T && !b && !c ? /* @__PURE__ */ i.jsx(
455
+ Ct,
731
456
  {
732
- unitId,
733
- subUnitId,
734
- payload: {
735
- commentId: item.id,
736
- text,
737
- attachments
738
- }
457
+ overlay: /* @__PURE__ */ i.jsxs(ft, { children: [
458
+ /* @__PURE__ */ i.jsx(Ie, { onClick: () => a == null ? void 0 : a(!0), children: f.t("threadCommentUI.item.edit") }, "edit"),
459
+ /* @__PURE__ */ i.jsx(Ie, { onClick: D, children: f.t("threadCommentUI.item.delete") }, "delete")
460
+ ] }),
461
+ children: /* @__PURE__ */ i.jsx("div", { className: h.threadCommentIcon, children: /* @__PURE__ */ i.jsx(Re, {}) })
739
462
  }
740
- );
741
- }, "onSave")
742
- }
743
- ) : /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemContent }, transformDocument2TextNodes(item.text).map((item2, i) => {
744
- switch (item2.type) {
745
- case "mention":
746
- return /* @__PURE__ */ React.createElement("a", { className: styles$1.threadCommentItemAt, key: i }, "@", item2.content.label, " ");
747
- default:
748
- return item2.content;
749
- }
750
- })));
751
- }, "ThreadCommentItem"), ThreadCommentTree = /* @__PURE__ */ __name((props) => {
752
- var _a3, _b, _c;
463
+ ) : null
464
+ ] })
465
+ ] }),
466
+ /* @__PURE__ */ i.jsx("div", { className: h.threadCommentItemTime, children: e.dT }),
467
+ o ? /* @__PURE__ */ i.jsx(
468
+ Be,
469
+ {
470
+ id: e.id,
471
+ comment: e,
472
+ onCancel: () => a == null ? void 0 : a(!1),
473
+ autoFocus: !0,
474
+ unitId: r,
475
+ subUnitId: n,
476
+ onSave: ({ text: p, attachments: U }) => {
477
+ a == null || a(!1), N.executeCommand(
478
+ it.id,
479
+ {
480
+ unitId: r,
481
+ subUnitId: n,
482
+ payload: {
483
+ commentId: e.id,
484
+ text: p,
485
+ attachments: U
486
+ }
487
+ }
488
+ );
489
+ }
490
+ }
491
+ ) : /* @__PURE__ */ i.jsx("div", { className: h.threadCommentItemContent, children: Le(e.text).map((p, U) => {
492
+ switch (p.type) {
493
+ case "mention":
494
+ return /* @__PURE__ */ i.jsxs("a", { className: h.threadCommentItemAt, children: [
495
+ "@",
496
+ p.content.label,
497
+ " "
498
+ ] }, U);
499
+ default:
500
+ return p.content;
501
+ }
502
+ }) })
503
+ ] });
504
+ }, _n = (t) => {
505
+ var ie, Q, X;
753
506
  const {
754
- id,
755
- unitId,
756
- subUnitId,
757
- refStr,
758
- showEdit = !0,
759
- onClick,
760
- showHighlight,
761
- onClose,
762
- getSubUnitName,
763
- prefix,
764
- autoFocus,
765
- onMouseEnter,
766
- onMouseLeave,
767
- onAddComment,
768
- onDeleteComment,
769
- onResolve
770
- } = props, threadCommentModel = useDependency(ThreadCommentModel), [isHover, setIsHover] = useState(!1), [editingId, setEditingId] = useState(""), updte$ = useMemo(() => threadCommentModel.commentUpdate$.pipe(debounceTime(16)), [threadCommentModel]);
771
- useObservable(updte$);
772
- const comments = id ? threadCommentModel.getCommentWithChildren(unitId, subUnitId, id) : null, commandService = useDependency(ICommandService), userManagerService = useDependency(UserManagerService), resolved = comments == null ? void 0 : comments.root.resolved, currentUser = useObservable(userManagerService.currentUser$), editorRef = useRef(null), renderComments = [
773
- ...comments ? [comments.root] : (
507
+ id: e,
508
+ unitId: r,
509
+ subUnitId: n,
510
+ refStr: o,
511
+ showEdit: a = !0,
512
+ onClick: d,
513
+ showHighlight: c,
514
+ onClose: v,
515
+ getSubUnitName: S,
516
+ prefix: O,
517
+ autoFocus: N,
518
+ onMouseEnter: f,
519
+ onMouseLeave: u,
520
+ onAddComment: C,
521
+ onDeleteComment: g,
522
+ onResolve: T
523
+ } = t, b = x(_e), [L, m] = k(!1), [D, p] = k(""), U = le(() => b.commentUpdate$.pipe(dt(16)), [b]);
524
+ F(U);
525
+ const s = e ? b.getCommentWithChildren(r, n, e) : null, I = x(re), y = x(ge), P = s == null ? void 0 : s.root.resolved, E = F(y.currentUser$), K = ne(null), Y = [
526
+ ...s ? [s.root] : (
774
527
  // mock empty comment
775
528
  [{
776
- id: MOCK_ID,
529
+ id: Fe,
777
530
  text: {
778
531
  dataStream: `
779
532
  \r`
780
533
  },
781
- personId: (_a3 = currentUser == null ? void 0 : currentUser.userID) != null ? _a3 : "",
782
- ref: refStr != null ? refStr : "",
534
+ personId: (ie = E == null ? void 0 : E.userID) != null ? ie : "",
535
+ ref: o != null ? o : "",
783
536
  dT: "",
784
- unitId,
785
- subUnitId,
537
+ unitId: r,
538
+ subUnitId: n,
786
539
  threadId: ""
787
540
  }]
788
541
  ),
789
- ...(_b = comments == null ? void 0 : comments.children) != null ? _b : []
790
- ], scroller = useRef(null), handleResolve = /* @__PURE__ */ __name((e) => {
791
- e.stopPropagation(), resolved ? commandService.executeCommand(SetActiveCommentOperation.id, {
792
- unitId,
793
- subUnitId,
794
- commentId: id
795
- }) : commandService.executeCommand(SetActiveCommentOperation.id), commandService.executeCommand(ResolveCommentCommand.id, {
796
- unitId,
797
- subUnitId,
798
- commentId: id,
799
- resolved: !resolved
800
- }), onResolve == null || onResolve(!resolved);
801
- }, "handleResolve"), handleDeleteRoot = /* @__PURE__ */ __name((e) => {
802
- e.stopPropagation(), commandService.executeCommand(SetActiveCommentOperation.id), !(comments != null && comments.root && (onDeleteComment == null ? void 0 : onDeleteComment(comments.root)) === !1) && (commandService.executeCommand(
803
- DeleteCommentTreeCommand.id,
542
+ ...(Q = s == null ? void 0 : s.children) != null ? Q : []
543
+ ], V = ne(null), R = (_) => {
544
+ _.stopPropagation(), P ? I.executeCommand(W.id, {
545
+ unitId: r,
546
+ subUnitId: n,
547
+ commentId: e
548
+ }) : I.executeCommand(W.id), I.executeCommand(st.id, {
549
+ unitId: r,
550
+ subUnitId: n,
551
+ commentId: e,
552
+ resolved: !P
553
+ }), T == null || T(!P);
554
+ }, J = (_) => {
555
+ _.stopPropagation(), I.executeCommand(W.id), !(s != null && s.root && (g == null ? void 0 : g(s.root)) === !1) && (I.executeCommand(
556
+ je.id,
804
557
  {
805
- unitId,
806
- subUnitId,
807
- commentId: id
558
+ unitId: r,
559
+ subUnitId: n,
560
+ commentId: e
808
561
  }
809
- ), onClose == null || onClose());
810
- }, "handleDeleteRoot");
811
- useEffect(() => onMouseLeave == null ? void 0 : onMouseLeave(), []);
812
- const subUnitName = getSubUnitName((_c = comments == null ? void 0 : comments.root.subUnitId) != null ? _c : subUnitId), editorVisible = showEdit && !editingId && !resolved, title = `${refStr || (comments == null ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
813
- return /* @__PURE__ */ React.createElement(
562
+ ), v == null || v());
563
+ };
564
+ Ce(() => u == null ? void 0 : u(), []);
565
+ const H = S((X = s == null ? void 0 : s.root.subUnitId) != null ? X : n), oe = a && !D && !P, G = `${o || (s == null ? void 0 : s.root.ref) || ""}${H ? " · " : ""}${H}`;
566
+ return /* @__PURE__ */ i.jsxs(
814
567
  "div",
815
568
  {
816
- className: clsx(styles$1.threadComment, {
817
- [styles$1.threadCommentActive]: !resolved && (showHighlight || isHover || prefix === "cell")
569
+ className: qt(h.threadComment, {
570
+ [h.threadCommentActive]: !P && (c || L || O === "cell")
818
571
  }),
819
- onClick,
820
- id: `${prefix}-${unitId}-${subUnitId}-${id}`,
821
- onMouseEnter: /* @__PURE__ */ __name(() => {
822
- onMouseEnter == null || onMouseEnter(), setIsHover(!0);
823
- }, "onMouseEnter"),
824
- onMouseLeave: /* @__PURE__ */ __name(() => {
825
- onMouseLeave == null || onMouseLeave(), setIsHover(!1);
826
- }, "onMouseLeave")
827
- },
828
- !resolved && showHighlight ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentHighlight }) : null,
829
- /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitle }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitlePosition }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitleHighlight }), /* @__PURE__ */ React.createElement(Tooltip, { showIfEllipsis: !0, title }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitlePositionText }, title))), comments ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIconContainer }, /* @__PURE__ */ React.createElement(
830
- "div",
831
- {
832
- onClick: handleResolve,
833
- className: styles$1.threadCommentIcon,
834
- style: { color: resolved ? "rgb(var(--green-500))" : "" }
572
+ onClick: d,
573
+ id: `${O}-${r}-${n}-${e}`,
574
+ onMouseEnter: () => {
575
+ f == null || f(), m(!0);
835
576
  },
836
- resolved ? /* @__PURE__ */ React.createElement(ResolvedSingle, null) : /* @__PURE__ */ React.createElement(SolveSingle, null)
837
- ), (currentUser == null ? void 0 : currentUser.userID) === comments.root.personId ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon, onClick: handleDeleteRoot }, /* @__PURE__ */ React.createElement(DeleteSingle, null)) : null) : null),
838
- /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentContent, ref: scroller }, renderComments.map(
839
- (item) => /* @__PURE__ */ React.createElement(
840
- ThreadCommentItem,
841
- {
842
- onClose,
843
- unitId,
844
- subUnitId,
845
- item,
846
- key: item.id,
847
- isRoot: item.id === (comments == null ? void 0 : comments.root.id),
848
- editing: editingId === item.id,
849
- resolved: comments == null ? void 0 : comments.root.resolved,
850
- onEditingChange: /* @__PURE__ */ __name((editing) => {
851
- setEditingId(editing ? item.id : "");
852
- }, "onEditingChange"),
853
- onReply: /* @__PURE__ */ __name((user) => {
854
- user && requestAnimationFrame(() => {
855
- var _a4;
856
- (_a4 = editorRef.current) == null || _a4.reply(transformTextNodes2Document([{
857
- type: "mention",
858
- content: {
859
- id: user.userID,
860
- label: user.name
861
- }
862
- }]));
863
- });
864
- }, "onReply"),
865
- onAddComment,
866
- onDeleteComment
867
- }
868
- )
869
- )),
870
- editorVisible ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
871
- ThreadCommentEditor,
872
- {
873
- key: `${autoFocus}`,
874
- ref: editorRef,
875
- unitId,
876
- subUnitId,
877
- onSave: /* @__PURE__ */ __name(async ({ text, attachments }) => {
878
- const comment = {
879
- text,
880
- attachments,
881
- dT: getDT(),
882
- id: generateRandomId(),
883
- ref: refStr,
884
- personId: currentUser == null ? void 0 : currentUser.userID,
885
- parentId: comments == null ? void 0 : comments.root.id,
886
- unitId,
887
- subUnitId,
888
- threadId: comments == null ? void 0 : comments.root.threadId
889
- };
890
- (onAddComment == null ? void 0 : onAddComment(comment)) !== !1 && (await commandService.executeCommand(
891
- AddCommentCommand.id,
577
+ onMouseLeave: () => {
578
+ u == null || u(), m(!1);
579
+ },
580
+ children: [
581
+ !P && c ? /* @__PURE__ */ i.jsx("div", { className: h.threadCommentHighlight }) : null,
582
+ /* @__PURE__ */ i.jsxs("div", { className: h.threadCommentTitle, children: [
583
+ /* @__PURE__ */ i.jsxs("div", { className: h.threadCommentTitlePosition, children: [
584
+ /* @__PURE__ */ i.jsx("div", { className: h.threadCommentTitleHighlight }),
585
+ /* @__PURE__ */ i.jsx(vt, { showIfEllipsis: !0, title: G, children: /* @__PURE__ */ i.jsx("div", { className: h.threadCommentTitlePositionText, children: G }) })
586
+ ] }),
587
+ s ? /* @__PURE__ */ i.jsxs("div", { className: h.threadCommentIconContainer, children: [
588
+ /* @__PURE__ */ i.jsx(
589
+ "div",
590
+ {
591
+ onClick: R,
592
+ className: h.threadCommentIcon,
593
+ style: { color: P ? "rgb(var(--green-500))" : "" },
594
+ children: P ? /* @__PURE__ */ i.jsx(De, {}) : /* @__PURE__ */ i.jsx(ke, {})
595
+ }
596
+ ),
597
+ (E == null ? void 0 : E.userID) === s.root.personId ? /* @__PURE__ */ i.jsx("div", { className: h.threadCommentIcon, onClick: J, children: /* @__PURE__ */ i.jsx($e, {}) }) : null
598
+ ] }) : null
599
+ ] }),
600
+ /* @__PURE__ */ i.jsx("div", { className: h.threadCommentContent, ref: V, children: Y.map(
601
+ (_) => /* @__PURE__ */ i.jsx(
602
+ yn,
892
603
  {
893
- unitId,
894
- subUnitId,
895
- comment
604
+ onClose: v,
605
+ unitId: r,
606
+ subUnitId: n,
607
+ item: _,
608
+ isRoot: _.id === (s == null ? void 0 : s.root.id),
609
+ editing: D === _.id,
610
+ resolved: s == null ? void 0 : s.root.resolved,
611
+ onEditingChange: ($) => {
612
+ p($ ? _.id : "");
613
+ },
614
+ onReply: ($) => {
615
+ $ && requestAnimationFrame(() => {
616
+ var l;
617
+ (l = K.current) == null || l.reply(Ve([{
618
+ type: "mention",
619
+ content: {
620
+ id: $.userID,
621
+ label: $.name
622
+ }
623
+ }]));
624
+ });
625
+ },
626
+ onAddComment: C,
627
+ onDeleteComment: g
628
+ },
629
+ _.id
630
+ )
631
+ ) }),
632
+ oe ? /* @__PURE__ */ i.jsx("div", { children: /* @__PURE__ */ i.jsx(
633
+ Be,
634
+ {
635
+ ref: K,
636
+ unitId: r,
637
+ subUnitId: n,
638
+ onSave: async ({ text: _, attachments: $ }) => {
639
+ const l = {
640
+ text: _,
641
+ attachments: $,
642
+ dT: rt(),
643
+ id: tt(),
644
+ ref: o,
645
+ personId: E == null ? void 0 : E.userID,
646
+ parentId: s == null ? void 0 : s.root.id,
647
+ unitId: r,
648
+ subUnitId: n,
649
+ threadId: s == null ? void 0 : s.root.threadId
650
+ };
651
+ (C == null ? void 0 : C(l)) !== !1 && (await I.executeCommand(
652
+ ot.id,
653
+ {
654
+ unitId: r,
655
+ subUnitId: n,
656
+ comment: l
657
+ }
658
+ ), V.current && (V.current.scrollTop = V.current.scrollHeight));
659
+ },
660
+ autoFocus: N || !s,
661
+ onCancel: () => {
662
+ s || v == null || v();
896
663
  }
897
- ), scroller.current && (scroller.current.scrollTop = scroller.current.scrollHeight));
898
- }, "onSave"),
899
- autoFocus: autoFocus || !comments,
900
- onCancel: /* @__PURE__ */ __name(() => {
901
- comments || onClose == null || onClose();
902
- }, "onCancel")
903
- }
904
- )) : null
664
+ },
665
+ `${N}`
666
+ ) }) : null
667
+ ]
668
+ }
905
669
  );
906
- }, "ThreadCommentTree"), threadCommentPanel = "univer-thread-comment-panel", threadComment = "univer-thread-comment", threadCommentPanelForms = "univer-thread-comment-panel-forms", select = "univer-select", threadCommentPanelEmpty = "univer-thread-comment-panel-empty", threadCommentPanelAdd = "univer-thread-comment-panel-add", threadCommentPanelSolved = "univer-thread-comment-panel-solved", styles = {
907
- threadCommentPanel,
908
- threadComment,
909
- threadCommentPanelForms,
910
- select,
911
- threadCommentPanelEmpty,
912
- threadCommentPanelAdd,
913
- threadCommentPanelSolved
914
- }, ThreadCommentPanel = /* @__PURE__ */ __name((props) => {
670
+ }, jn = "univer-thread-comment-panel", Nn = "univer-thread-comment", Tn = "univer-thread-comment-panel-forms", Un = "univer-select", En = "univer-thread-comment-panel-empty", Mn = "univer-thread-comment-panel-add", On = "univer-thread-comment-panel-solved", te = {
671
+ threadCommentPanel: jn,
672
+ threadComment: Nn,
673
+ threadCommentPanelForms: Tn,
674
+ select: Un,
675
+ threadCommentPanelEmpty: En,
676
+ threadCommentPanelAdd: Mn,
677
+ threadCommentPanelSolved: On
678
+ }, Bn = (t) => {
915
679
  const {
916
- unitId,
917
- subUnitId$,
918
- type,
919
- onAdd,
920
- getSubUnitName,
921
- onResolve,
922
- sortComments,
923
- onItemLeave,
924
- onItemEnter,
925
- disableAdd,
926
- tempComment,
927
- onAddComment,
928
- onDeleteComment,
929
- showComments
930
- } = props, [unit, setUnit] = useState("all"), [status, setStatus] = useState("all"), localeService = useDependency(LocaleService), userService = useDependency(UserManagerService), threadCommentModel = useDependency(ThreadCommentModel), [unitComments, setUnitComments] = useState(() => threadCommentModel.getUnit(unitId)), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), update = useObservable(threadCommentModel.commentUpdate$), commandService = useDependency(ICommandService), subUnitId = useObservable(subUnitId$), shouldScroll = useRef(!0), prefix = "panel", currentUser = useObservable(userService.currentUser$), comments = useMemo(() => {
931
- var _a3;
932
- const allComments = unit === "all" ? unitComments : (_a3 = unitComments.filter((i) => i.subUnitId === subUnitId)) != null ? _a3 : [], sort = sortComments != null ? sortComments : (a) => a, res = allComments.map((i) => {
933
- var _a4;
934
- return { ...i.root, children: (_a4 = i.children) != null ? _a4 : [], users: i.relativeUsers };
680
+ unitId: e,
681
+ subUnitId$: r,
682
+ type: n,
683
+ onAdd: o,
684
+ getSubUnitName: a,
685
+ onResolve: d,
686
+ sortComments: c,
687
+ onItemLeave: v,
688
+ onItemEnter: S,
689
+ disableAdd: O,
690
+ tempComment: N,
691
+ onAddComment: f,
692
+ onDeleteComment: u,
693
+ showComments: C
694
+ } = t, [g, T] = k("all"), [b, L] = k("all"), m = x(fe), D = x(ge), p = x(_e), [U, s] = k(() => p.getUnit(e)), I = x(q), y = F(I.activeCommentId$), P = F(p.commentUpdate$), E = x(re), K = F(r), Y = ne(!0), V = "panel", R = F(D.currentUser$), J = le(() => {
695
+ var ae;
696
+ const l = g === "all" ? U : (ae = U.filter((j) => j.subUnitId === K)) != null ? ae : [], ee = c != null ? c : (j) => j, se = l.map((j) => {
697
+ var B;
698
+ return { ...j.root, children: (B = j.children) != null ? B : [], users: j.relativeUsers };
935
699
  });
936
- if (showComments) {
937
- const map = /* @__PURE__ */ new Map();
938
- return res.forEach((comment) => {
939
- map.set(comment.id, comment);
940
- }), [...showComments, ""].map((id) => map.get(id)).filter(Boolean);
700
+ if (C) {
701
+ const j = /* @__PURE__ */ new Map();
702
+ return se.forEach((B) => {
703
+ j.set(B.id, B);
704
+ }), [...C, ""].map((B) => j.get(B)).filter(Boolean);
941
705
  } else
942
- return sort(res);
943
- }, [showComments, unit, unitComments, sortComments, subUnitId]), commentsSorted = useMemo(() => [
944
- ...comments.filter((comment) => !comment.resolved),
945
- ...comments.filter((comment) => comment.resolved)
946
- ], [comments]), statuedComments = useMemo(() => status === "resolved" ? commentsSorted.filter((comment) => comment.resolved) : status === "unsolved" ? commentsSorted.filter((comment) => !comment.resolved) : status === "concern_me" && currentUser != null && currentUser.userID ? commentsSorted.filter((comment) => comment == null ? void 0 : comment.users.has(currentUser.userID)) : commentsSorted, [commentsSorted, currentUser == null ? void 0 : currentUser.userID, status]), renderComments = tempComment ? [tempComment, ...statuedComments] : statuedComments, unSolvedComments = renderComments.filter((comment) => !comment.resolved), solvedComments = renderComments.filter((comment) => comment.resolved), isFiltering = status !== "all" || unit !== "all", onReset = /* @__PURE__ */ __name(() => {
947
- setStatus("all"), setUnit("all");
948
- }, "onReset");
949
- useEffect(() => {
950
- unitId && setUnitComments(
951
- threadCommentModel.getUnit(unitId)
706
+ return ee(se);
707
+ }, [C, g, U, c, K]), H = le(() => [
708
+ ...J.filter((l) => !l.resolved),
709
+ ...J.filter((l) => l.resolved)
710
+ ], [J]), oe = le(() => b === "resolved" ? H.filter((l) => l.resolved) : b === "unsolved" ? H.filter((l) => !l.resolved) : b === "concern_me" && R != null && R.userID ? H.filter((l) => l == null ? void 0 : l.users.has(R.userID)) : H, [H, R == null ? void 0 : R.userID, b]), G = N ? [N, ...oe] : oe, ie = G.filter((l) => !l.resolved), Q = G.filter((l) => l.resolved), X = b !== "all" || g !== "all", _ = () => {
711
+ L("all"), T("all");
712
+ };
713
+ Ce(() => {
714
+ e && s(
715
+ p.getUnit(e)
952
716
  );
953
- }, [unitId, threadCommentModel, update]), useEffect(() => {
954
- var _a3;
955
- if (!activeCommentId)
717
+ }, [e, p, P]), Ce(() => {
718
+ var j;
719
+ if (!y)
956
720
  return;
957
- if (!shouldScroll.current) {
958
- shouldScroll.current = !0;
721
+ if (!Y.current) {
722
+ Y.current = !0;
959
723
  return;
960
724
  }
961
- const { unitId: unitId2, subUnitId: subUnitId2, commentId } = activeCommentId, id = `${prefix}-${unitId2}-${subUnitId2}-${commentId}`;
962
- (_a3 = document.getElementById(id)) == null || _a3.scrollIntoView({ block: "center" });
963
- }, [activeCommentId]);
964
- const renderComment = /* @__PURE__ */ __name((comment) => /* @__PURE__ */ React.createElement(
965
- ThreadCommentTree,
725
+ const { unitId: l, subUnitId: ee, commentId: se } = y, ae = `${V}-${l}-${ee}-${se}`;
726
+ (j = document.getElementById(ae)) == null || j.scrollIntoView({ block: "center" });
727
+ }, [y]);
728
+ const $ = (l) => /* @__PURE__ */ i.jsx(
729
+ _n,
966
730
  {
967
- prefix,
968
- getSubUnitName,
969
- key: comment.id,
970
- id: comment.id,
971
- unitId: comment.unitId,
972
- subUnitId: comment.subUnitId,
973
- refStr: comment.ref,
974
- type,
975
- showEdit: (activeCommentId == null ? void 0 : activeCommentId.commentId) === comment.id,
976
- showHighlight: (activeCommentId == null ? void 0 : activeCommentId.commentId) === comment.id,
977
- onClick: /* @__PURE__ */ __name(() => {
978
- shouldScroll.current = !1, comment.resolved ? commandService.executeCommand(SetActiveCommentOperation.id) : commandService.executeCommand(
979
- SetActiveCommentOperation.id,
731
+ prefix: V,
732
+ getSubUnitName: a,
733
+ id: l.id,
734
+ unitId: l.unitId,
735
+ subUnitId: l.subUnitId,
736
+ refStr: l.ref,
737
+ type: n,
738
+ showEdit: (y == null ? void 0 : y.commentId) === l.id,
739
+ showHighlight: (y == null ? void 0 : y.commentId) === l.id,
740
+ onClick: () => {
741
+ Y.current = !1, l.resolved ? E.executeCommand(W.id) : E.executeCommand(
742
+ W.id,
980
743
  {
981
- unitId: comment.unitId,
982
- subUnitId: comment.subUnitId,
983
- commentId: comment.id,
744
+ unitId: l.unitId,
745
+ subUnitId: l.subUnitId,
746
+ commentId: l.id,
984
747
  temp: !1
985
748
  }
986
749
  );
987
- }, "onClick"),
988
- onMouseEnter: /* @__PURE__ */ __name(() => onItemEnter == null ? void 0 : onItemEnter(comment), "onMouseEnter"),
989
- onMouseLeave: /* @__PURE__ */ __name(() => onItemLeave == null ? void 0 : onItemLeave(comment), "onMouseLeave"),
990
- onAddComment,
991
- onDeleteComment,
992
- onResolve: /* @__PURE__ */ __name((resolved) => onResolve == null ? void 0 : onResolve(comment.id, resolved), "onResolve")
993
- }
994
- ), "renderComment");
995
- return /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanel }, /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelForms }, type === UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ React.createElement(
996
- Select,
997
- {
998
- borderless: !0,
999
- value: unit,
1000
- onChange: /* @__PURE__ */ __name((e) => setUnit(e), "onChange"),
1001
- options: [
1002
- {
1003
- value: "current",
1004
- label: localeService.t("threadCommentUI.filter.sheet.current")
1005
- },
750
+ },
751
+ onMouseEnter: () => S == null ? void 0 : S(l),
752
+ onMouseLeave: () => v == null ? void 0 : v(l),
753
+ onAddComment: f,
754
+ onDeleteComment: u,
755
+ onResolve: (ee) => d == null ? void 0 : d(l.id, ee)
756
+ },
757
+ l.id
758
+ );
759
+ return /* @__PURE__ */ i.jsxs("div", { className: te.threadCommentPanel, children: [
760
+ /* @__PURE__ */ i.jsxs("div", { className: te.threadCommentPanelForms, children: [
761
+ n === he.UNIVER_SHEET ? /* @__PURE__ */ i.jsx(
762
+ xe,
1006
763
  {
1007
- value: "all",
1008
- label: localeService.t("threadCommentUI.filter.sheet.all")
764
+ borderless: !0,
765
+ value: g,
766
+ onChange: (l) => T(l),
767
+ options: [
768
+ {
769
+ value: "current",
770
+ label: m.t("threadCommentUI.filter.sheet.current")
771
+ },
772
+ {
773
+ value: "all",
774
+ label: m.t("threadCommentUI.filter.sheet.all")
775
+ }
776
+ ]
1009
777
  }
1010
- ]
1011
- }
1012
- ) : null, /* @__PURE__ */ React.createElement(
1013
- Select,
1014
- {
1015
- borderless: !0,
1016
- value: status,
1017
- onChange: /* @__PURE__ */ __name((e) => setStatus(e), "onChange"),
1018
- options: [
778
+ ) : null,
779
+ /* @__PURE__ */ i.jsx(
780
+ xe,
1019
781
  {
1020
- value: "all",
1021
- label: localeService.t("threadCommentUI.filter.status.all")
1022
- },
1023
- {
1024
- value: "resolved",
1025
- label: localeService.t("threadCommentUI.filter.status.resolved")
1026
- },
782
+ borderless: !0,
783
+ value: b,
784
+ onChange: (l) => L(l),
785
+ options: [
786
+ {
787
+ value: "all",
788
+ label: m.t("threadCommentUI.filter.status.all")
789
+ },
790
+ {
791
+ value: "resolved",
792
+ label: m.t("threadCommentUI.filter.status.resolved")
793
+ },
794
+ {
795
+ value: "unsolved",
796
+ label: m.t("threadCommentUI.filter.status.unsolved")
797
+ },
798
+ {
799
+ value: "concern_me",
800
+ label: m.t("threadCommentUI.filter.status.concernMe")
801
+ }
802
+ ]
803
+ }
804
+ )
805
+ ] }),
806
+ ie.map($),
807
+ Q.length ? /* @__PURE__ */ i.jsx("div", { className: te.threadCommentPanelSolved, children: "已解决" }) : null,
808
+ Q.map($),
809
+ G.length ? null : /* @__PURE__ */ i.jsxs("div", { className: te.threadCommentPanelEmpty, children: [
810
+ X ? m.t("threadCommentUI.panel.filterEmpty") : m.t("threadCommentUI.panel.empty"),
811
+ X ? /* @__PURE__ */ i.jsx(
812
+ de,
1027
813
  {
1028
- value: "unsolved",
1029
- label: localeService.t("threadCommentUI.filter.status.unsolved")
1030
- },
814
+ onClick: _,
815
+ type: "link",
816
+ children: m.t("threadCommentUI.panel.reset")
817
+ }
818
+ ) : /* @__PURE__ */ i.jsxs(
819
+ de,
1031
820
  {
1032
- value: "concern_me",
1033
- label: localeService.t("threadCommentUI.filter.status.concernMe")
821
+ id: "thread-comment-add",
822
+ className: te.threadCommentPanelAdd,
823
+ type: "primary",
824
+ onClick: o,
825
+ disabled: O,
826
+ children: [
827
+ /* @__PURE__ */ i.jsx(we, {}),
828
+ m.t("threadCommentUI.panel.addComment")
829
+ ]
1034
830
  }
1035
- ]
1036
- }
1037
- )), unSolvedComments.map(renderComment), solvedComments.length ? /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelSolved }, "已解决") : null, solvedComments.map(renderComment), renderComments.length ? null : /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelEmpty }, isFiltering ? localeService.t("threadCommentUI.panel.filterEmpty") : localeService.t("threadCommentUI.panel.empty"), isFiltering ? /* @__PURE__ */ React.createElement(
1038
- Button,
1039
- {
1040
- onClick: onReset,
1041
- type: "link"
1042
- },
1043
- localeService.t("threadCommentUI.panel.reset")
1044
- ) : /* @__PURE__ */ React.createElement(
1045
- Button,
1046
- {
1047
- id: "thread-comment-add",
1048
- className: styles.threadCommentPanelAdd,
1049
- type: "primary",
1050
- onClick: onAdd,
1051
- disabled: disableAdd
1052
- },
1053
- /* @__PURE__ */ React.createElement(IncreaseSingle, null),
1054
- localeService.t("threadCommentUI.panel.addComment")
1055
- )));
1056
- }, "ThreadCommentPanel");
831
+ )
832
+ ] })
833
+ ] });
834
+ };
1057
835
  export {
1058
- IThreadCommentMentionDataService,
1059
- SetActiveCommentOperation,
1060
- THREAD_COMMENT_PANEL,
1061
- ThreadCommentPanel,
1062
- ThreadCommentPanelService,
1063
- ThreadCommentTree,
1064
- ToggleSheetCommentPanelOperation,
1065
- UniverThreadCommentUIPlugin,
1066
- getDT
836
+ Te as IThreadCommentMentionDataService,
837
+ W as SetActiveCommentOperation,
838
+ yt as THREAD_COMMENT_PANEL,
839
+ Bn as ThreadCommentPanel,
840
+ q as ThreadCommentPanelService,
841
+ _n as ThreadCommentTree,
842
+ jt as ToggleSheetCommentPanelOperation,
843
+ me as UniverThreadCommentUIPlugin
1067
844
  };