@univerjs/thread-comment-ui 0.2.4 → 0.2.6

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,47 +1,47 @@
1
- var We = Object.defineProperty;
2
- var Fe = (t, e, n) => e in t ? We(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var w = (t, e, n) => Fe(t, typeof e != "symbol" ? e + "" : e, n);
4
- import ze from "dayjs";
5
- import { UniverThreadCommentPlugin as Ze, ThreadCommentModel as xe, AddCommentCommand as Ye, UpdateCommentCommand as Ge, ResolveCommentCommand as Ke, DeleteCommentTreeCommand as _e, DeleteCommentCommand as qe } from "@univerjs/thread-comment";
6
- import { Disposable as Te, UniverInstanceType as Ce, IUniverInstanceService as Je, CommandType as Ne, OnLifecycle as Qe, LifecycleStages as Xe, LocaleService as de, Plugin as et, mergeOverrideWithDependencies as tt, DependentOn as nt, ICommandService as X, CustomRangeType as rt, UserManagerService as fe, Tools as ot } from "@univerjs/core";
7
- import { Inject as ge, createIdentifier as at, Injector as it } from "@wendellhu/redi";
8
- import { ISidebarService as Me, useObservable as j } from "@univerjs/ui";
9
- import { BehaviorSubject as Ie, filter as lt } from "rxjs";
10
- import a, { forwardRef as A, useRef as ce, createElement as B, useState as k, useImperativeHandle as st, useEffect as ve, useMemo as he } from "react";
11
- import { useDependency as b } from "@wendellhu/redi/react-bindings";
12
- import { Mentions as mt, Mention as dt, Button as le, Dropdown as ct, Menu as ut, MenuItem as Se, Select as be } from "@univerjs/design";
13
- import ht from "clsx";
14
- import { ITextSelectionRenderManager as vt } from "@univerjs/engine-render";
15
- import { TextSelectionManagerService as Ct } from "@univerjs/docs";
16
- function ft() {
17
- return ze().format("YYYY/MM/DD HH:mm");
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 dayjs from "dayjs";
6
+ import { UniverThreadCommentPlugin, ThreadCommentModel, AddCommentCommand, UpdateCommentCommand, ResolveCommentCommand, DeleteCommentTreeCommand, DeleteCommentCommand } from "@univerjs/thread-comment";
7
+ import { Disposable, UniverInstanceType, Inject, IUniverInstanceService, CommandType, createIdentifier, Plugin, mergeOverrideWithDependencies, DependentOn, Injector, ICommandService, CustomRangeType, useDependency, LocaleService, UserManagerService, Tools } from "@univerjs/core";
8
+ import { ISidebarService, useObservable } from "@univerjs/ui";
9
+ import { BehaviorSubject, filter } from "rxjs";
10
+ import React, { forwardRef, useRef, createElement, useState, useImperativeHandle, useEffect, useMemo } from "react";
11
+ import { Mentions, Mention, Button, Dropdown, Menu, MenuItem, Select } from "@univerjs/design";
12
+ import cs from "clsx";
13
+ import { ITextSelectionRenderManager } from "@univerjs/engine-render";
14
+ import { TextSelectionManagerService } from "@univerjs/docs";
15
+ function getDT() {
16
+ return dayjs().format("YYYY/MM/DD HH:mm");
18
17
  }
19
- const gt = "thread-comment-panel", pt = "THREAD_COMMENT_UI_PLUGIN";
20
- var It = Object.defineProperty, St = Object.getOwnPropertyDescriptor, bt = (t, e, n, r) => {
21
- for (var o = r > 1 ? void 0 : r ? St(e, n) : e, i = t.length - 1, m; i >= 0; i--)
22
- (m = t[i]) && (o = (r ? m(e, n, o) : m(o)) || o);
23
- return r && o && It(e, n, o), o;
24
- }, Ee = (t, e) => (n, r) => e(n, r, t);
25
- let z = class extends Te {
26
- constructor(e, n) {
18
+ __name(getDT, "getDT");
19
+ const THREAD_COMMENT_PANEL = "thread-comment-panel", PLUGIN_NAME = "THREAD_COMMENT_UI_PLUGIN";
20
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
21
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
22
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
23
+ return kind && result && __defProp$1(target, key, result), result;
24
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a;
25
+ let ThreadCommentPanelService = (_a = class extends Disposable {
26
+ constructor(_sidebarService, _univerInstanceService) {
27
27
  super();
28
- w(this, "_panelVisible", !1);
29
- w(this, "_panelVisible$", new Ie(!1));
30
- w(this, "_activeCommentId");
31
- w(this, "_activeCommentId$", new Ie(void 0));
32
- w(this, "panelVisible$", this._panelVisible$.asObservable());
33
- w(this, "activeCommentId$", this._activeCommentId$.asObservable());
34
- this._sidebarService = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
28
+ __publicField(this, "_panelVisible", !1);
29
+ __publicField(this, "_panelVisible$", new BehaviorSubject(!1));
30
+ __publicField(this, "_activeCommentId");
31
+ __publicField(this, "_activeCommentId$", new BehaviorSubject(void 0));
32
+ __publicField(this, "panelVisible$", this._panelVisible$.asObservable());
33
+ __publicField(this, "activeCommentId$", this._activeCommentId$.asObservable());
34
+ this._sidebarService = _sidebarService, this._univerInstanceService = _univerInstanceService, this._init(), this.disposeWithMe(() => {
35
35
  this._activeCommentId$.complete(), this._panelVisible$.complete();
36
36
  });
37
37
  }
38
38
  _init() {
39
39
  this.disposeWithMe(
40
- this._sidebarService.sidebarOptions$.subscribe((e) => {
41
- e.visible || this.setPanelVisible(!1);
40
+ this._sidebarService.sidebarOptions$.subscribe((opt) => {
41
+ opt.visible || this.setPanelVisible(!1);
42
42
  })
43
43
  ), this.disposeWithMe(
44
- this._univerInstanceService.getCurrentTypeOfUnit$(Ce.UNIVER_SHEET).pipe(lt((e) => !e)).subscribe(() => {
44
+ this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
45
45
  this._sidebarService.close();
46
46
  })
47
47
  );
@@ -52,719 +52,709 @@ let z = class extends Te {
52
52
  get activeCommentId() {
53
53
  return this._activeCommentId;
54
54
  }
55
- setPanelVisible(e) {
56
- this._panelVisible = e, this._panelVisible$.next(e);
55
+ setPanelVisible(visible) {
56
+ this._panelVisible = visible, this._panelVisible$.next(visible);
57
57
  }
58
- setActiveComment(e) {
59
- this._activeCommentId = e, this._activeCommentId$.next(e);
58
+ setActiveComment(commentInfo) {
59
+ this._activeCommentId = commentInfo, this._activeCommentId$.next(commentInfo);
60
60
  }
61
- };
62
- z = bt([
63
- Ee(0, ge(Me)),
64
- Ee(1, Je)
65
- ], z);
66
- const Et = {
61
+ }, __name(_a, "ThreadCommentPanelService"), _a);
62
+ ThreadCommentPanelService = __decorateClass$1([
63
+ __decorateParam$1(0, Inject(ISidebarService)),
64
+ __decorateParam$1(1, IUniverInstanceService)
65
+ ], ThreadCommentPanelService);
66
+ const ToggleSheetCommentPanelOperation = {
67
67
  id: "thread-comment-ui.operation.toggle-panel",
68
- type: Ne.OPERATION,
69
- handler(t) {
70
- const e = t.get(Me), n = t.get(z);
71
- return n.panelVisible ? (e.close(), n.setPanelVisible(!1)) : (e.open({
68
+ type: CommandType.OPERATION,
69
+ handler(accessor) {
70
+ const sidebarService = accessor.get(ISidebarService), panelService = accessor.get(ThreadCommentPanelService);
71
+ return panelService.panelVisible ? (sidebarService.close(), panelService.setPanelVisible(!1)) : (sidebarService.open({
72
72
  header: { title: "threadCommentUI.panel.title" },
73
- children: { label: gt },
73
+ children: { label: THREAD_COMMENT_PANEL },
74
74
  width: 320
75
- }), n.setPanelVisible(!0)), !0;
75
+ }), panelService.setPanelVisible(!0)), !0;
76
76
  }
77
- }, V = {
77
+ }, SetActiveCommentOperation = {
78
78
  id: "thread-comment-ui.operation.set-active-comment",
79
- type: Ne.OPERATION,
80
- handler(t, e) {
81
- return t.get(z).setActiveComment(e), !0;
82
- }
83
- };
84
- var yt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, _t = (t, e, n, r) => {
85
- for (var o = r > 1 ? void 0 : r ? xt(e, n) : e, i = t.length - 1, m; i >= 0; i--)
86
- (m = t[i]) && (o = (r ? m(e, n, o) : m(o)) || o);
87
- return r && o && yt(e, n, o), o;
88
- }, Tt = (t, e) => (n, r) => e(n, r, t);
89
- let ie = class extends Te {
90
- constructor(t) {
91
- super(), this._localeService = t;
79
+ type: CommandType.OPERATION,
80
+ handler(accessor, params) {
81
+ return accessor.get(ThreadCommentPanelService).setActiveComment(params), !0;
92
82
  }
93
- };
94
- ie = _t([
95
- Qe(Xe.Starting, ie),
96
- Tt(0, ge(de))
97
- ], ie);
98
- class Nt {
83
+ }, _ThreadCommentMentionDataService = class _ThreadCommentMentionDataService {
99
84
  constructor() {
100
- w(this, "dataSource");
101
- w(this, "renderSuggestion");
102
- w(this, "trigger", "@");
85
+ __publicField(this, "dataSource");
86
+ __publicField(this, "renderSuggestion");
87
+ __publicField(this, "trigger", "@");
103
88
  }
104
- async getMentions(e, n, r) {
105
- return this.dataSource ? this.dataSource.getMentions(e, n, r) : [];
89
+ async getMentions(search, unitId, subUnitId) {
90
+ return this.dataSource ? this.dataSource.getMentions(search, unitId, subUnitId) : [];
106
91
  }
107
- }
108
- const Pe = at("thread-comment.mention-data.service");
109
- var Ue = Object.defineProperty, Mt = Object.getOwnPropertyDescriptor, Pt = (t, e, n) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Ut = (t, e, n, r) => {
110
- for (var o = r > 1 ? void 0 : r ? Mt(e, n) : e, i = t.length - 1, m; i >= 0; i--)
111
- (m = t[i]) && (o = (r ? m(e, n, o) : m(o)) || o);
112
- return r && o && Ue(e, n, o), o;
113
- }, ye = (t, e) => (n, r) => e(n, r, t), $e = (t, e, n) => Pt(t, typeof e != "symbol" ? e + "" : e, n);
114
- let se = class extends et {
115
- constructor(t, e, n) {
116
- super(), this._config = t, this._injector = e, this._commandService = n;
92
+ };
93
+ __name(_ThreadCommentMentionDataService, "ThreadCommentMentionDataService");
94
+ let ThreadCommentMentionDataService = _ThreadCommentMentionDataService;
95
+ const IThreadCommentMentionDataService = createIdentifier("thread-comment.mention-data.service");
96
+ 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) => {
97
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
98
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
99
+ return kind && result && __defProp2(target, key, result), result;
100
+ }, "__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;
101
+ let UniverThreadCommentUIPlugin = (_a2 = class extends Plugin {
102
+ constructor(_config, _injector, _commandService) {
103
+ super(), this._config = _config, this._injector = _injector, this._commandService = _commandService;
117
104
  }
118
- onStarting(t) {
119
- var e;
120
- tt([
121
- [ie],
122
- [z],
123
- [Pe, { useClass: Nt }]
124
- ], (e = this._config) == null ? void 0 : e.overrides).forEach((n) => {
125
- t.add(n);
126
- }), [Et, V].forEach((n) => {
127
- this._commandService.registerCommand(n);
105
+ onStarting() {
106
+ var _a3;
107
+ mergeOverrideWithDependencies([
108
+ [ThreadCommentPanelService],
109
+ [IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }]
110
+ ], (_a3 = this._config) == null ? void 0 : _a3.overrides).forEach((dep) => {
111
+ this._injector.add(dep);
112
+ }), [ToggleSheetCommentPanelOperation, SetActiveCommentOperation].forEach((command) => {
113
+ this._commandService.registerCommand(command);
128
114
  });
129
115
  }
130
- };
131
- $e(se, "pluginName", pt);
132
- $e(se, "type", Ce.UNIVER_UNKNOWN);
133
- se = Ut([
134
- nt(Ze),
135
- ye(1, ge(it)),
136
- ye(2, X)
137
- ], se);
138
- var T = function() {
139
- return T = Object.assign || function(t) {
140
- for (var e, n = 1, r = arguments.length; n < r; n++) {
141
- e = arguments[n];
142
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
116
+ }, __name(_a2, "UniverThreadCommentUIPlugin"), _a2);
117
+ __publicField2(UniverThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
118
+ __publicField2(UniverThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_UNKNOWN);
119
+ UniverThreadCommentUIPlugin = __decorateClass([
120
+ DependentOn(UniverThreadCommentPlugin),
121
+ __decorateParam(1, Inject(Injector)),
122
+ __decorateParam(2, ICommandService)
123
+ ], UniverThreadCommentUIPlugin);
124
+ var __assign = function() {
125
+ return __assign = Object.assign || function(t) {
126
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
127
+ s = arguments[i];
128
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
143
129
  }
144
130
  return t;
145
- }, T.apply(this, arguments);
146
- }, $t = function(t, e) {
147
- var n = {};
148
- for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
149
- if (t != null && typeof Object.getOwnPropertySymbols == "function")
150
- for (var o = 0, r = Object.getOwnPropertySymbols(t); o < r.length; o++)
151
- e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[o]) && (n[r[o]] = t[r[o]]);
152
- return n;
153
- }, W = A(function(t, e) {
154
- var n = t.icon, r = t.id, o = t.className, i = t.extend, m = $t(t, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(r, " ").concat(o || "").trim(), f = ce("_".concat(Ht()));
155
- return Oe(n, "".concat(r), { defIds: n.defIds, idSuffix: f.current }, T({ ref: e, className: c }, m), i);
131
+ }, __assign.apply(this, arguments);
132
+ }, __rest = function(s, e) {
133
+ var t = {};
134
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
135
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
136
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
137
+ e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
138
+ return t;
139
+ }, IconBase = forwardRef(function(props, ref) {
140
+ 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()));
141
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
156
142
  });
157
- function Oe(t, e, n, r, o) {
158
- return B(t.tag, T(T({ key: e }, Ot(t, n, o)), r), (wt(t, n).children || []).map(function(i, m) {
159
- return Oe(i, "".concat(e, "-").concat(t.tag, "-").concat(m), n, void 0, o);
143
+ function render(node, id, runtimeProps, rootProps, extend) {
144
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
145
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
160
146
  }));
161
147
  }
162
- function Ot(t, e, n) {
163
- var r = T({}, t.attrs);
164
- n != null && n.colorChannel1 && r.fill === "colorChannel1" && (r.fill = n.colorChannel1);
165
- var o = e.defIds;
166
- return !o || o.length === 0 || (t.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
167
- var m = i[0], c = i[1];
168
- typeof c == "string" && (r[m] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
169
- })), r;
148
+ __name(render, "render");
149
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
150
+ var attrs = __assign({}, node.attrs);
151
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
152
+ var defIds = runtimeProps.defIds;
153
+ 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) {
154
+ var key = _a3[0], value = _a3[1];
155
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
156
+ })), attrs;
170
157
  }
171
- function wt(t, e) {
172
- var n, r = e.defIds;
173
- return !r || r.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? T(T({}, t), { children: t.children.map(function(o) {
174
- return typeof o.attrs.id == "string" && r && r.indexOf(o.attrs.id) > -1 ? T(T({}, o), { attrs: T(T({}, o.attrs), { id: o.attrs.id + e.idSuffix }) }) : o;
175
- }) }) : t;
158
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
159
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
160
+ var _a3, defIds = runtimeProps.defIds;
161
+ 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) {
162
+ 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;
163
+ }) }) : node;
176
164
  }
177
- function Ht() {
165
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
166
+ function generateShortUuid() {
178
167
  return Math.random().toString(36).substring(2, 8);
179
168
  }
180
- W.displayName = "UniverIcon";
181
- var Rt = { 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" } }] }, we = A(function(t, e) {
182
- return B(W, Object.assign({}, t, {
169
+ __name(generateShortUuid, "generateShortUuid");
170
+ IconBase.displayName = "UniverIcon";
171
+ 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) {
172
+ return createElement(IconBase, Object.assign({}, props, {
183
173
  id: "delete-single",
184
- ref: e,
185
- icon: Rt
174
+ ref,
175
+ icon: element$5
186
176
  }));
187
177
  });
188
- we.displayName = "DeleteSingle";
189
- var Dt = { 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" } }] }, He = A(function(t, e) {
190
- return B(W, Object.assign({}, t, {
178
+ DeleteSingle.displayName = "DeleteSingle";
179
+ 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) {
180
+ return createElement(IconBase, Object.assign({}, props, {
191
181
  id: "increase-single",
192
- ref: e,
193
- icon: Dt
182
+ ref,
183
+ icon: element$4
194
184
  }));
195
185
  });
196
- He.displayName = "IncreaseSingle";
197
- var kt = { 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) {
198
- return B(W, Object.assign({}, t, {
186
+ IncreaseSingle.displayName = "IncreaseSingle";
187
+ 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) {
188
+ return createElement(IconBase, Object.assign({}, props, {
199
189
  id: "more-horizontal-single",
200
- ref: e,
201
- icon: kt
190
+ ref,
191
+ icon: element$3
202
192
  }));
203
193
  });
204
- Re.displayName = "MoreHorizontalSingle";
205
- var At = { 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 } }] }, De = A(function(t, e) {
206
- return B(W, Object.assign({}, t, {
194
+ MoreHorizontalSingle.displayName = "MoreHorizontalSingle";
195
+ 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) {
196
+ return createElement(IconBase, Object.assign({}, props, {
207
197
  id: "reply-to-comment-single",
208
- ref: e,
209
- icon: At
198
+ ref,
199
+ icon: element$2
210
200
  }));
211
201
  });
212
- De.displayName = "ReplyToCommentSingle";
213
- var Lt = { 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" } }] }, ke = A(function(t, e) {
214
- return B(W, Object.assign({}, t, {
202
+ ReplyToCommentSingle.displayName = "ReplyToCommentSingle";
203
+ 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) {
204
+ return createElement(IconBase, Object.assign({}, props, {
215
205
  id: "resolved-single",
216
- ref: e,
217
- icon: Lt
206
+ ref,
207
+ icon: element$1
218
208
  }));
219
209
  });
220
- ke.displayName = "ResolvedSingle";
221
- var jt = { 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 } }] }, Ae = A(function(t, e) {
222
- return B(W, Object.assign({}, t, {
210
+ ResolvedSingle.displayName = "ResolvedSingle";
211
+ 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) {
212
+ return createElement(IconBase, Object.assign({}, props, {
223
213
  id: "solve-single",
224
- ref: e,
225
- icon: jt
214
+ ref,
215
+ icon: element
226
216
  }));
227
217
  });
228
- Ae.displayName = "SolveSingle";
229
- const Vt = "univer-thread-comment-editor-buttons", Bt = "univer-thread-comment-editor-suggestion", Wt = "univer-thread-comment-editor-suggestionActive", Ft = "univer-thread-comment-editor-suggestion-icon", me = {
230
- threadCommentEditorButtons: Vt,
231
- threadCommentEditorSuggestion: Bt,
232
- threadCommentEditorSuggestionActive: Wt,
233
- threadCommentEditorSuggestionIcon: Ft
234
- }, zt = (t) => {
235
- const e = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
236
- let n, r = 0;
237
- const o = [];
238
- for (; (n = e.exec(t)) !== null; )
239
- n.index > r && o.push({
218
+ SolveSingle.displayName = "SolveSingle";
219
+ 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 = {
220
+ threadCommentEditorButtons,
221
+ threadCommentEditorSuggestion,
222
+ threadCommentEditorSuggestionActive,
223
+ threadCommentEditorSuggestionIcon
224
+ }, parseMentions = /* @__PURE__ */ __name((text) => {
225
+ const regex = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
226
+ let match, lastIndex = 0;
227
+ const result = [];
228
+ for (; (match = regex.exec(text)) !== null; )
229
+ match.index > lastIndex && result.push({
240
230
  type: "text",
241
- content: t.substring(r, n.index)
242
- }), n[1] && n[2] ? o.push({
231
+ content: text.substring(lastIndex, match.index)
232
+ }), match[1] && match[2] ? result.push({
243
233
  type: "mention",
244
234
  content: {
245
- label: n[1],
246
- id: n[2]
235
+ label: match[1],
236
+ id: match[2]
247
237
  }
248
- }) : n[3] && o.push({
238
+ }) : match[3] && result.push({
249
239
  type: "text",
250
- content: n[3]
251
- }), r = e.lastIndex;
252
- return r < t.length && o.push({
240
+ content: match[3]
241
+ }), lastIndex = regex.lastIndex;
242
+ return lastIndex < text.length && result.push({
253
243
  type: "text",
254
- content: t.substring(r)
255
- }), o;
256
- }, Zt = (t) => t.map((e) => {
257
- switch (e.type) {
244
+ content: text.substring(lastIndex)
245
+ }), result;
246
+ }, "parseMentions"), transformTextNode2Text = /* @__PURE__ */ __name((nodes) => nodes.map((item) => {
247
+ switch (item.type) {
258
248
  case "mention":
259
- return `@[${e.content.label}](${e.content.id})`;
249
+ return `@[${item.content.label}](${item.content.id})`;
260
250
  default:
261
- return e.content;
251
+ return item.content;
262
252
  }
263
- }).join(""), Le = (t) => {
264
- const { dataStream: e, customRanges: n } = t, r = e.length - 2, o = [];
265
- let i = 0;
266
- return n == null || n.forEach((m) => {
267
- i < m.startIndex && o.push({
253
+ }).join(""), "transformTextNode2Text"), transformDocument2TextNodes = /* @__PURE__ */ __name((doc) => {
254
+ const { dataStream, customRanges } = doc, end = dataStream.length - 2, textNodes = [];
255
+ let lastIndex = 0;
256
+ return customRanges == null || customRanges.forEach((range) => {
257
+ lastIndex < range.startIndex && textNodes.push({
268
258
  type: "text",
269
- content: e.slice(i, m.startIndex)
270
- }), o.push({
259
+ content: dataStream.slice(lastIndex, range.startIndex)
260
+ }), textNodes.push({
271
261
  type: "mention",
272
262
  content: {
273
- label: e.slice(m.startIndex, m.endIndex).slice(1, -1),
274
- id: m.rangeId
263
+ label: dataStream.slice(range.startIndex, range.endIndex).slice(1, -1),
264
+ id: range.rangeId
275
265
  }
276
- }), i = m.endIndex;
277
- }), o.push({
266
+ }), lastIndex = range.endIndex;
267
+ }), textNodes.push({
278
268
  type: "text",
279
- content: e.slice(i, r)
280
- }), o;
281
- }, je = (t) => {
282
- let e = "";
283
- const n = [];
284
- return t.forEach((r) => {
285
- switch (r.type) {
269
+ content: dataStream.slice(lastIndex, end)
270
+ }), textNodes;
271
+ }, "transformDocument2TextNodes"), transformTextNodes2Document = /* @__PURE__ */ __name((nodes) => {
272
+ let str = "";
273
+ const customRanges = [];
274
+ return nodes.forEach((node) => {
275
+ switch (node.type) {
286
276
  case "text":
287
- e += r.content;
277
+ str += node.content;
288
278
  break;
289
279
  case "mention": {
290
- const o = e.length;
291
- e += `${r.content.label}`;
292
- const i = e.length;
293
- n.push({
294
- rangeId: r.content.id,
295
- rangeType: rt.MENTION,
296
- startIndex: o,
297
- endIndex: i
280
+ const start = str.length;
281
+ str += `${node.content.label}`;
282
+ const end = str.length;
283
+ customRanges.push({
284
+ rangeId: node.content.id,
285
+ rangeType: CustomRangeType.MENTION,
286
+ startIndex: start,
287
+ endIndex: end
298
288
  });
299
289
  break;
300
290
  }
301
291
  }
302
- }), e += `
292
+ }), str += `
303
293
  \r`, {
304
294
  textRuns: [],
305
295
  paragraphs: [
306
296
  {
307
- startIndex: e.length - 2,
297
+ startIndex: str.length - 2,
308
298
  paragraphStyle: {}
309
299
  }
310
300
  ],
311
301
  sectionBreaks: [
312
302
  {
313
- startIndex: e.length - 1
303
+ startIndex: str.length - 1
314
304
  }
315
305
  ],
316
- dataStream: e,
317
- customRanges: n
306
+ dataStream: str,
307
+ customRanges
318
308
  };
319
- }, Yt = (t) => ({
320
- display: t.label,
321
- id: `${t.id}`,
322
- raw: t
323
- }), Gt = (t, e, n, r, o) => {
324
- var m, c;
325
- const i = (m = t.raw) == null ? void 0 : m.icon;
326
- return /* @__PURE__ */ a.createElement("div", { className: me.threadCommentEditorSuggestion }, i ? /* @__PURE__ */ a.createElement("img", { className: me.threadCommentEditorSuggestionIcon, src: i }) : null, /* @__PURE__ */ a.createElement("div", null, (c = t.display) != null ? c : t.id));
327
- }, Ve = A((t, e) => {
328
- var v;
329
- const { comment: n, onSave: r, id: o, onCancel: i, autoFocus: m, unitId: c, subUnitId: f } = t, y = b(Pe), P = b(X), _ = b(de), [I, h] = k({ ...n }), [g, S] = k(!1), N = ce(null), E = b(vt), H = b(Ct);
330
- return st(e, () => ({
331
- reply(C) {
332
- var d;
333
- h({
334
- ...n,
335
- text: C,
309
+ }, "transformTextNodes2Document"), transformMention = /* @__PURE__ */ __name((mention) => ({
310
+ display: mention.label,
311
+ id: `${mention.id}`,
312
+ raw: mention
313
+ }), "transformMention"), defaultRenderSuggestion = /* @__PURE__ */ __name((mention, search, highlightedDisplay, index, focused) => {
314
+ var _a3, _b;
315
+ const icon = (_a3 = mention.raw) == null ? void 0 : _a3.icon;
316
+ 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));
317
+ }, "defaultRenderSuggestion"), ThreadCommentEditor = forwardRef((props, ref) => {
318
+ var _a3;
319
+ const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localComment, setLocalComment] = useState({ ...comment }), [editing, setEditing] = useState(!1), inputRef = useRef(null), textSelectionRenderManager = useDependency(ITextSelectionRenderManager), textSelectionManagerService = useDependency(TextSelectionManagerService);
320
+ return useImperativeHandle(ref, () => ({
321
+ reply(text) {
322
+ var _a4;
323
+ setLocalComment({
324
+ ...comment,
325
+ text,
336
326
  attachments: []
337
- }), (d = N.current) == null || d.inputElement.focus();
327
+ }), (_a4 = inputRef.current) == null || _a4.inputElement.focus();
338
328
  }
339
- })), /* @__PURE__ */ a.createElement("div", { className: me.threadCommentEditor, onClick: (C) => C.preventDefault() }, /* @__PURE__ */ a.createElement(
340
- mt,
329
+ })), /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditor, onClick: /* @__PURE__ */ __name((e) => e.preventDefault(), "onClick") }, /* @__PURE__ */ React.createElement(
330
+ Mentions,
341
331
  {
342
- ref: N,
343
- autoFocus: m,
332
+ ref: inputRef,
333
+ autoFocus,
344
334
  style: { width: "100%" },
345
- placeholder: _.t("threadCommentUI.editor.placeholder"),
346
- value: I != null && I.text ? Zt(Le(I.text)) : "",
347
- onChange: (C) => {
348
- C.target.value || h({ ...n, text: void 0 }), h == null || h({ ...n, text: je(zt(C.target.value)) });
349
- },
350
- onFocus: () => {
351
- const C = H.getActiveRange();
352
- C && C.collapsed && E.removeAllTextRanges(), E.blur(), S(!0);
353
- }
335
+ placeholder: localeService.t("threadCommentUI.editor.placeholder"),
336
+ value: localComment != null && localComment.text ? transformTextNode2Text(transformDocument2TextNodes(localComment.text)) : "",
337
+ onChange: /* @__PURE__ */ __name((e) => {
338
+ e.target.value || setLocalComment({ ...comment, text: void 0 }), setLocalComment == null || setLocalComment({ ...comment, text: transformTextNodes2Document(parseMentions(e.target.value)) });
339
+ }, "onChange"),
340
+ onFocus: /* @__PURE__ */ __name(() => {
341
+ const activeRange = textSelectionManagerService.getActiveRange();
342
+ activeRange && activeRange.collapsed && textSelectionRenderManager.removeAllTextRanges(), textSelectionRenderManager.blur(), setEditing(!0);
343
+ }, "onFocus")
354
344
  },
355
- /* @__PURE__ */ a.createElement(
356
- dt,
345
+ /* @__PURE__ */ React.createElement(
346
+ Mention,
357
347
  {
358
- key: y.trigger,
359
- trigger: y.trigger,
360
- data: (C, d) => y.getMentions(C, c, f).then((l) => l.map(Yt)).then(d),
361
- displayTransform: (C, d) => `@${d} `,
362
- renderSuggestion: (v = y.renderSuggestion) != null ? v : Gt
348
+ key: mentionDataService.trigger,
349
+ trigger: mentionDataService.trigger,
350
+ data: /* @__PURE__ */ __name((query, callback) => mentionDataService.getMentions(query, unitId, subUnitId).then((res) => res.map(transformMention)).then(callback), "data"),
351
+ displayTransform: /* @__PURE__ */ __name((id2, label) => `@${label} `, "displayTransform"),
352
+ renderSuggestion: (_a3 = mentionDataService.renderSuggestion) != null ? _a3 : defaultRenderSuggestion
363
353
  }
364
354
  )
365
- ), g ? /* @__PURE__ */ a.createElement("div", { className: me.threadCommentEditorButtons }, /* @__PURE__ */ a.createElement(
366
- le,
355
+ ), editing ? /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorButtons }, /* @__PURE__ */ React.createElement(
356
+ Button,
367
357
  {
368
358
  style: { marginRight: 12 },
369
- onClick: () => {
370
- i == null || i(), S(!1), h({ text: void 0 }), P.executeCommand(V.id);
371
- }
359
+ onClick: /* @__PURE__ */ __name(() => {
360
+ onCancel == null || onCancel(), setEditing(!1), setLocalComment({ text: void 0 }), commandService.executeCommand(SetActiveCommentOperation.id);
361
+ }, "onClick")
372
362
  },
373
- _.t("threadCommentUI.editor.cancel")
374
- ), /* @__PURE__ */ a.createElement(
375
- le,
363
+ localeService.t("threadCommentUI.editor.cancel")
364
+ ), /* @__PURE__ */ React.createElement(
365
+ Button,
376
366
  {
377
367
  type: "primary",
378
- disabled: !I.text,
379
- onClick: () => {
380
- I.text && (r == null || r({
381
- ...I,
382
- text: I.text
383
- }), S(!1), h({ text: void 0 }));
384
- }
368
+ disabled: !localComment.text,
369
+ onClick: /* @__PURE__ */ __name(() => {
370
+ localComment.text && (onSave == null || onSave({
371
+ ...localComment,
372
+ text: localComment.text
373
+ }), setEditing(!1), setLocalComment({ text: void 0 }));
374
+ }, "onClick")
385
375
  },
386
- _.t(o ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
376
+ localeService.t(id ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
387
377
  )) : null);
388
- }), Kt = "univer-thread-comment", qt = "univer-thread-comment-active", Jt = "univer-thread-comment-content", Qt = "univer-thread-comment-highlight", Xt = "univer-thread-comment-icon-container", en = "univer-thread-comment-icon", tn = "univer-thread-comment-title", nn = "univer-thread-comment-title-position", rn = "univer-thread-comment-title-highlight", on = "univer-thread-comment-title-position-text", an = "univer-thread-comment-username", ln = "univer-thread-comment-item", sn = "univer-thread-comment-item-head", mn = "univer-thread-comment-item-title", dn = "univer-thread-comment-item-title-position", cn = "univer-thread-comment-item-title-highlight", un = "univer-thread-comment-item-time", hn = "univer-thread-comment-item-content", vn = "univer-thread-comment-item-at", u = {
389
- threadComment: Kt,
390
- threadCommentActive: qt,
391
- threadCommentContent: Jt,
392
- threadCommentHighlight: Qt,
393
- threadCommentIconContainer: Xt,
394
- threadCommentIcon: en,
395
- threadCommentTitle: tn,
396
- threadCommentTitlePosition: nn,
397
- threadCommentTitleHighlight: rn,
398
- threadCommentTitlePositionText: on,
399
- threadCommentUsername: an,
400
- threadCommentItem: ln,
401
- threadCommentItemHead: sn,
402
- threadCommentItemTitle: mn,
403
- threadCommentItemTitlePosition: dn,
404
- threadCommentItemTitleHighlight: cn,
405
- threadCommentItemTime: un,
406
- threadCommentItemContent: hn,
407
- threadCommentItemAt: vn
408
- }, Be = "__mock__", Cn = (t) => {
409
- const { item: e, unitId: n, subUnitId: r, editing: o, onEditingChange: i, onReply: m, resolved: c, isRoot: f, onClose: y, onDeleteComment: P } = t, _ = b(X), I = b(de), h = b(fe), g = h.getUser(e.personId), S = j(h.currentUser$), N = (S == null ? void 0 : S.userID) === e.personId, E = e.id === Be, [H, v] = k(!1), C = () => {
410
- (P == null ? void 0 : P(e)) !== !1 && (_.executeCommand(
411
- f ? _e.id : qe.id,
378
+ }), 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 = {
379
+ threadComment: threadComment$1,
380
+ threadCommentActive,
381
+ threadCommentContent,
382
+ threadCommentHighlight,
383
+ threadCommentIconContainer,
384
+ threadCommentIcon,
385
+ threadCommentTitle,
386
+ threadCommentTitlePosition,
387
+ threadCommentTitleHighlight,
388
+ threadCommentTitlePositionText,
389
+ threadCommentUsername,
390
+ threadCommentItem,
391
+ threadCommentItemHead,
392
+ threadCommentItemTitle,
393
+ threadCommentItemTitlePosition,
394
+ threadCommentItemTitleHighlight,
395
+ threadCommentItemTime,
396
+ threadCommentItemContent,
397
+ threadCommentItemAt
398
+ }, MOCK_ID = "__mock__", ThreadCommentItem = /* @__PURE__ */ __name((props) => {
399
+ 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(() => {
400
+ (onDeleteComment == null ? void 0 : onDeleteComment(item)) !== !1 && (commandService.executeCommand(
401
+ isRoot ? DeleteCommentTreeCommand.id : DeleteCommentCommand.id,
412
402
  {
413
- unitId: n,
414
- subUnitId: r,
415
- commentId: e.id
403
+ unitId,
404
+ subUnitId,
405
+ commentId: item.id
416
406
  }
417
- ), f && (y == null || y()));
418
- };
419
- return /* @__PURE__ */ a.createElement("div", { className: u.threadCommentItem, onMouseLeave: () => v(!1), onMouseEnter: () => v(!0) }, /* @__PURE__ */ a.createElement("img", { className: u.threadCommentItemHead, src: g == null ? void 0 : g.avatar }), /* @__PURE__ */ a.createElement("div", { className: u.threadCommentItemTitle }, /* @__PURE__ */ a.createElement("div", { className: u.threadCommentUsername }, (g == null ? void 0 : g.name) || " "), /* @__PURE__ */ a.createElement("div", null, E || c ? null : H ? /* @__PURE__ */ a.createElement("div", { className: u.threadCommentIcon, onClick: () => m(g) }, /* @__PURE__ */ a.createElement(De, null)) : null, N && !E && !c ? /* @__PURE__ */ a.createElement(
420
- ct,
407
+ ), isRoot && (onClose == null || onClose()));
408
+ }, "handleDeleteItem");
409
+ 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(
410
+ Dropdown,
421
411
  {
422
- overlay: /* @__PURE__ */ a.createElement(ut, null, /* @__PURE__ */ a.createElement(Se, { key: "edit", onClick: () => i == null ? void 0 : i(!0) }, I.t("threadCommentUI.item.edit")), /* @__PURE__ */ a.createElement(Se, { key: "delete", onClick: C }, I.t("threadCommentUI.item.delete")))
412
+ 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")))
423
413
  },
424
- /* @__PURE__ */ a.createElement("div", { className: u.threadCommentIcon }, /* @__PURE__ */ a.createElement(Re, null))
425
- ) : null)), /* @__PURE__ */ a.createElement("div", { className: u.threadCommentItemTime }, e.dT), o ? /* @__PURE__ */ a.createElement(
426
- Ve,
414
+ /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon }, /* @__PURE__ */ React.createElement(MoreHorizontalSingle, null))
415
+ ) : null)), /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemTime }, item.dT), editing ? /* @__PURE__ */ React.createElement(
416
+ ThreadCommentEditor,
427
417
  {
428
- id: e.id,
429
- comment: e,
430
- onCancel: () => i == null ? void 0 : i(!1),
418
+ id: item.id,
419
+ comment: item,
420
+ onCancel: /* @__PURE__ */ __name(() => onEditingChange == null ? void 0 : onEditingChange(!1), "onCancel"),
431
421
  autoFocus: !0,
432
- unitId: n,
433
- subUnitId: r,
434
- onSave: ({ text: d, attachments: l }) => {
435
- i == null || i(!1), _.executeCommand(
436
- Ge.id,
422
+ unitId,
423
+ subUnitId,
424
+ onSave: /* @__PURE__ */ __name(({ text, attachments }) => {
425
+ onEditingChange == null || onEditingChange(!1), commandService.executeCommand(
426
+ UpdateCommentCommand.id,
437
427
  {
438
- unitId: n,
439
- subUnitId: r,
428
+ unitId,
429
+ subUnitId,
440
430
  payload: {
441
- commentId: e.id,
442
- text: d,
443
- attachments: l
431
+ commentId: item.id,
432
+ text,
433
+ attachments
444
434
  }
445
435
  }
446
436
  );
447
- }
437
+ }, "onSave")
448
438
  }
449
- ) : /* @__PURE__ */ a.createElement("div", { className: u.threadCommentItemContent }, Le(e.text).map((d, l) => {
450
- switch (d.type) {
439
+ ) : /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemContent }, transformDocument2TextNodes(item.text).map((item2, i) => {
440
+ switch (item2.type) {
451
441
  case "mention":
452
- return /* @__PURE__ */ a.createElement("a", { className: u.threadCommentItemAt, key: l }, "@", d.content.label, " ");
442
+ return /* @__PURE__ */ React.createElement("a", { className: styles$1.threadCommentItemAt, key: i }, "@", item2.content.label, " ");
453
443
  default:
454
- return d.content;
444
+ return item2.content;
455
445
  }
456
446
  })));
457
- }, fn = (t) => {
458
- var K, F, ne;
447
+ }, "ThreadCommentItem"), ThreadCommentTree = /* @__PURE__ */ __name((props) => {
448
+ var _a3, _b, _c;
459
449
  const {
460
- id: e,
461
- unitId: n,
462
- subUnitId: r,
463
- refStr: o,
464
- showEdit: i = !0,
465
- onClick: m,
466
- showHighlight: c,
467
- onClose: f,
468
- getSubUnitName: y,
469
- prefix: P,
470
- autoFocus: _,
471
- onMouseEnter: I,
472
- onMouseLeave: h,
473
- onAddComment: g,
474
- onDeleteComment: S,
475
- onResolve: N
476
- } = t, E = b(xe), [H, v] = k(!1), [C, d] = k("");
477
- j(E.commentMap$);
478
- const l = e ? E.getCommentWithChildren(n, r, e) : null, R = b(X), ue = b(fe), p = l == null ? void 0 : l.root.resolved, M = j(ue.currentUser$), Z = ce(null), ee = [
479
- ...l ? [l.root] : (
450
+ id,
451
+ unitId,
452
+ subUnitId,
453
+ refStr,
454
+ showEdit = !0,
455
+ onClick,
456
+ showHighlight,
457
+ onClose,
458
+ getSubUnitName,
459
+ prefix,
460
+ autoFocus,
461
+ onMouseEnter,
462
+ onMouseLeave,
463
+ onAddComment,
464
+ onDeleteComment,
465
+ onResolve
466
+ } = props, threadCommentModel = useDependency(ThreadCommentModel), [isHover, setIsHover] = useState(!1), [editingId, setEditingId] = useState("");
467
+ useObservable(threadCommentModel.commentMap$);
468
+ 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 = [
469
+ ...comments ? [comments.root] : (
480
470
  // mock empty comment
481
471
  [{
482
- id: Be,
472
+ id: MOCK_ID,
483
473
  text: {
484
474
  dataStream: `
485
475
  \r`
486
476
  },
487
- personId: (K = M == null ? void 0 : M.userID) != null ? K : "",
488
- ref: o != null ? o : "",
477
+ personId: (_a3 = currentUser == null ? void 0 : currentUser.userID) != null ? _a3 : "",
478
+ ref: refStr != null ? refStr : "",
489
479
  dT: "",
490
- unitId: n,
491
- subUnitId: r,
480
+ unitId,
481
+ subUnitId,
492
482
  threadId: ""
493
483
  }]
494
484
  ),
495
- ...(F = l == null ? void 0 : l.children) != null ? F : []
496
- ], Y = (x) => {
497
- x.stopPropagation(), p ? R.executeCommand(V.id, {
498
- unitId: n,
499
- subUnitId: r,
500
- commentId: e
501
- }) : R.executeCommand(V.id), R.executeCommand(Ke.id, {
502
- unitId: n,
503
- subUnitId: r,
504
- commentId: e,
505
- resolved: !p
506
- }), N == null || N(!p);
507
- }, te = (x) => {
508
- x.stopPropagation(), R.executeCommand(V.id), !(l != null && l.root && (S == null ? void 0 : S(l.root)) === !1) && (R.executeCommand(
509
- _e.id,
485
+ ...(_b = comments == null ? void 0 : comments.children) != null ? _b : []
486
+ ], handleResolve = /* @__PURE__ */ __name((e) => {
487
+ e.stopPropagation(), resolved ? commandService.executeCommand(SetActiveCommentOperation.id, {
488
+ unitId,
489
+ subUnitId,
490
+ commentId: id
491
+ }) : commandService.executeCommand(SetActiveCommentOperation.id), commandService.executeCommand(ResolveCommentCommand.id, {
492
+ unitId,
493
+ subUnitId,
494
+ commentId: id,
495
+ resolved: !resolved
496
+ }), onResolve == null || onResolve(!resolved);
497
+ }, "handleResolve"), handleDeleteRoot = /* @__PURE__ */ __name((e) => {
498
+ e.stopPropagation(), commandService.executeCommand(SetActiveCommentOperation.id), !(comments != null && comments.root && (onDeleteComment == null ? void 0 : onDeleteComment(comments.root)) === !1) && (commandService.executeCommand(
499
+ DeleteCommentTreeCommand.id,
510
500
  {
511
- unitId: n,
512
- subUnitId: r,
513
- commentId: e
501
+ unitId,
502
+ subUnitId,
503
+ commentId: id
514
504
  }
515
- ), f == null || f());
516
- };
517
- ve(() => h == null ? void 0 : h(), []);
518
- const U = y((ne = l == null ? void 0 : l.root.subUnitId) != null ? ne : r), G = i && !C && !p, D = `${o || (l == null ? void 0 : l.root.ref) || ""}${U ? " · " : ""}${U}`;
519
- return /* @__PURE__ */ a.createElement(
505
+ ), onClose == null || onClose());
506
+ }, "handleDeleteRoot");
507
+ useEffect(() => onMouseLeave == null ? void 0 : onMouseLeave(), []);
508
+ 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}`;
509
+ return /* @__PURE__ */ React.createElement(
520
510
  "div",
521
511
  {
522
- className: ht(u.threadComment, {
523
- [u.threadCommentActive]: !p && (c || H || P === "cell")
512
+ className: cs(styles$1.threadComment, {
513
+ [styles$1.threadCommentActive]: !resolved && (showHighlight || isHover || prefix === "cell")
524
514
  }),
525
- onClick: m,
526
- id: `${P}-${n}-${r}-${e}`,
527
- onMouseEnter: () => {
528
- I == null || I(), v(!0);
529
- },
530
- onMouseLeave: () => {
531
- h == null || h(), v(!1);
532
- }
515
+ onClick,
516
+ id: `${prefix}-${unitId}-${subUnitId}-${id}`,
517
+ onMouseEnter: /* @__PURE__ */ __name(() => {
518
+ onMouseEnter == null || onMouseEnter(), setIsHover(!0);
519
+ }, "onMouseEnter"),
520
+ onMouseLeave: /* @__PURE__ */ __name(() => {
521
+ onMouseLeave == null || onMouseLeave(), setIsHover(!1);
522
+ }, "onMouseLeave")
533
523
  },
534
- !p && c ? /* @__PURE__ */ a.createElement("div", { className: u.threadCommentHighlight }) : null,
535
- /* @__PURE__ */ a.createElement("div", { className: u.threadCommentTitle }, /* @__PURE__ */ a.createElement("div", { className: u.threadCommentTitlePosition }, /* @__PURE__ */ a.createElement("div", { className: u.threadCommentTitleHighlight }), /* @__PURE__ */ a.createElement("div", { className: u.threadCommentTitlePositionText }, D)), l ? /* @__PURE__ */ a.createElement("div", { className: u.threadCommentIconContainer }, /* @__PURE__ */ a.createElement(
524
+ !resolved && showHighlight ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentHighlight }) : null,
525
+ /* @__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("div", { className: styles$1.threadCommentTitlePositionText }, title)), comments ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIconContainer }, /* @__PURE__ */ React.createElement(
536
526
  "div",
537
527
  {
538
- onClick: Y,
539
- className: u.threadCommentIcon,
540
- style: { color: p ? "rgb(var(--green-500))" : "" }
528
+ onClick: handleResolve,
529
+ className: styles$1.threadCommentIcon,
530
+ style: { color: resolved ? "rgb(var(--green-500))" : "" }
541
531
  },
542
- p ? /* @__PURE__ */ a.createElement(ke, null) : /* @__PURE__ */ a.createElement(Ae, null)
543
- ), (M == null ? void 0 : M.userID) === l.root.personId ? /* @__PURE__ */ a.createElement("div", { className: u.threadCommentIcon, onClick: te }, /* @__PURE__ */ a.createElement(we, null)) : null) : null),
544
- /* @__PURE__ */ a.createElement("div", { className: u.threadCommentContent }, ee.map(
545
- (x) => /* @__PURE__ */ a.createElement(
546
- Cn,
532
+ resolved ? /* @__PURE__ */ React.createElement(ResolvedSingle, null) : /* @__PURE__ */ React.createElement(SolveSingle, null)
533
+ ), (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),
534
+ /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentContent }, renderComments.map(
535
+ (item) => /* @__PURE__ */ React.createElement(
536
+ ThreadCommentItem,
547
537
  {
548
- onClose: f,
549
- unitId: n,
550
- subUnitId: r,
551
- item: x,
552
- key: x.id,
553
- isRoot: x.id === (l == null ? void 0 : l.root.id),
554
- editing: C === x.id,
555
- resolved: l == null ? void 0 : l.root.resolved,
556
- onEditingChange: ($) => {
557
- d($ ? x.id : "");
558
- },
559
- onReply: ($) => {
560
- $ && requestAnimationFrame(() => {
561
- var L;
562
- (L = Z.current) == null || L.reply(je([{
538
+ onClose,
539
+ unitId,
540
+ subUnitId,
541
+ item,
542
+ key: item.id,
543
+ isRoot: item.id === (comments == null ? void 0 : comments.root.id),
544
+ editing: editingId === item.id,
545
+ resolved: comments == null ? void 0 : comments.root.resolved,
546
+ onEditingChange: /* @__PURE__ */ __name((editing) => {
547
+ setEditingId(editing ? item.id : "");
548
+ }, "onEditingChange"),
549
+ onReply: /* @__PURE__ */ __name((user) => {
550
+ user && requestAnimationFrame(() => {
551
+ var _a4;
552
+ (_a4 = editorRef.current) == null || _a4.reply(transformTextNodes2Document([{
563
553
  type: "mention",
564
554
  content: {
565
- id: $.userID,
566
- label: $.name
555
+ id: user.userID,
556
+ label: user.name
567
557
  }
568
558
  }]));
569
559
  });
570
- },
571
- onAddComment: g,
572
- onDeleteComment: S
560
+ }, "onReply"),
561
+ onAddComment,
562
+ onDeleteComment
573
563
  }
574
564
  )
575
565
  )),
576
- G ? /* @__PURE__ */ a.createElement("div", null, /* @__PURE__ */ a.createElement(
577
- Ve,
566
+ editorVisible ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
567
+ ThreadCommentEditor,
578
568
  {
579
- key: `${_}`,
580
- ref: Z,
581
- unitId: n,
582
- subUnitId: r,
583
- onSave: ({ text: x, attachments: $ }) => {
584
- const L = {
585
- text: x,
586
- attachments: $,
587
- dT: ft(),
588
- id: ot.generateRandomId(),
589
- ref: o,
590
- personId: M == null ? void 0 : M.userID,
591
- parentId: l == null ? void 0 : l.root.id,
592
- unitId: n,
593
- subUnitId: r,
594
- threadId: l == null ? void 0 : l.root.threadId
569
+ key: `${autoFocus}`,
570
+ ref: editorRef,
571
+ unitId,
572
+ subUnitId,
573
+ onSave: /* @__PURE__ */ __name(({ text, attachments }) => {
574
+ const comment = {
575
+ text,
576
+ attachments,
577
+ dT: getDT(),
578
+ id: Tools.generateRandomId(),
579
+ ref: refStr,
580
+ personId: currentUser == null ? void 0 : currentUser.userID,
581
+ parentId: comments == null ? void 0 : comments.root.id,
582
+ unitId,
583
+ subUnitId,
584
+ threadId: comments == null ? void 0 : comments.root.threadId
595
585
  };
596
- (g == null ? void 0 : g(L)) !== !1 && R.executeCommand(
597
- Ye.id,
586
+ (onAddComment == null ? void 0 : onAddComment(comment)) !== !1 && commandService.executeCommand(
587
+ AddCommentCommand.id,
598
588
  {
599
- unitId: n,
600
- subUnitId: r,
601
- comment: L
589
+ unitId,
590
+ subUnitId,
591
+ comment
602
592
  }
603
593
  );
604
- },
605
- autoFocus: _ || !l,
606
- onCancel: () => {
607
- l || f == null || f();
608
- }
594
+ }, "onSave"),
595
+ autoFocus: autoFocus || !comments,
596
+ onCancel: /* @__PURE__ */ __name(() => {
597
+ comments || onClose == null || onClose();
598
+ }, "onCancel")
609
599
  }
610
600
  )) : null
611
601
  );
612
- }, gn = "univer-thread-comment-panel", pn = "univer-thread-comment", In = "univer-thread-comment-panel-forms", Sn = "univer-select", bn = "univer-thread-comment-panel-empty", En = "univer-thread-comment-panel-add", yn = "univer-thread-comment-panel-solved", Q = {
613
- threadCommentPanel: gn,
614
- threadComment: pn,
615
- threadCommentPanelForms: In,
616
- select: Sn,
617
- threadCommentPanelEmpty: bn,
618
- threadCommentPanelAdd: En,
619
- threadCommentPanelSolved: yn
620
- }, kn = (t) => {
602
+ }, "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 = {
603
+ threadCommentPanel,
604
+ threadComment,
605
+ threadCommentPanelForms,
606
+ select,
607
+ threadCommentPanelEmpty,
608
+ threadCommentPanelAdd,
609
+ threadCommentPanelSolved
610
+ }, ThreadCommentPanel = /* @__PURE__ */ __name((props) => {
621
611
  const {
622
- unitId: e,
623
- subUnitId$: n,
624
- type: r,
625
- onAdd: o,
626
- getSubUnitName: i,
627
- onResolve: m,
628
- sortComments: c,
629
- onItemLeave: f,
630
- onItemEnter: y,
631
- disableAdd: P,
632
- tempComment: _,
633
- onAddComment: I,
634
- onDeleteComment: h,
635
- showComments: g
636
- } = t, [S, N] = k("all"), [E, H] = k("all"), v = b(de), C = b(fe), d = b(xe), [l, R] = k(() => d.getUnit(e)), ue = b(z), p = j(ue.activeCommentId$), M = j(d.commentUpdate$), Z = b(X), ee = j(n), Y = ce(!0), te = "panel", U = j(C.currentUser$), G = he(() => {
637
- var oe, J;
638
- const s = (S === "all" ? l.map((O) => O[1]).flat() : (J = (oe = l.find((O) => O[0] === ee)) == null ? void 0 : oe[1]) != null ? J : []).filter((O) => !O.parentId), q = c != null ? c : (O) => O, re = s;
639
- if (g) {
640
- const O = /* @__PURE__ */ new Map();
641
- return re.forEach((ae) => {
642
- O.set(ae.id, ae);
643
- }), [...g, ""].map((ae) => O.get(ae)).filter(Boolean);
612
+ unitId,
613
+ subUnitId$,
614
+ type,
615
+ onAdd,
616
+ getSubUnitName,
617
+ onResolve,
618
+ sortComments,
619
+ onItemLeave,
620
+ onItemEnter,
621
+ disableAdd,
622
+ tempComment,
623
+ onAddComment,
624
+ onDeleteComment,
625
+ showComments
626
+ } = 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(() => {
627
+ var _a3, _b;
628
+ const allComments = (unit === "all" ? unitComments.map((i) => i[1]).flat() : (_b = (_a3 = unitComments.find((i) => i[0] === subUnitId)) == null ? void 0 : _a3[1]) != null ? _b : []).filter((i) => !i.parentId), sort = sortComments != null ? sortComments : (a) => a, res = allComments;
629
+ if (showComments) {
630
+ const map = /* @__PURE__ */ new Map();
631
+ return res.forEach((comment) => {
632
+ map.set(comment.id, comment);
633
+ }), [...showComments, ""].map((id) => map.get(id)).filter(Boolean);
644
634
  } else
645
- return q(re);
646
- }, [g, S, l, c, ee]), D = he(() => [
647
- ...G.filter((s) => !s.resolved),
648
- ...G.filter((s) => s.resolved)
649
- ], [G]), K = he(() => E === "resolved" ? D.filter((s) => s.resolved) : E === "unsolved" ? D.filter((s) => !s.resolved) : E === "concern_me" && U != null && U.userID ? D.map((s) => d.getCommentWithChildren(s.unitId, s.subUnitId, s.id)).map((s) => s != null && s.relativeUsers.has(U.userID) ? s.root : null).filter(Boolean) : D, [D, U == null ? void 0 : U.userID, E, d]), F = _ ? [_, ...K] : K, ne = F.filter((s) => !s.resolved), x = F.filter((s) => s.resolved), $ = E !== "all" || S !== "all", L = () => {
650
- H("all"), N("all");
651
- };
652
- ve(() => {
653
- e && R(
654
- d.getUnit(e)
635
+ return sort(res);
636
+ }, [showComments, unit, unitComments, sortComments, subUnitId]), commentsSorted = useMemo(() => [
637
+ ...comments.filter((comment) => !comment.resolved),
638
+ ...comments.filter((comment) => comment.resolved)
639
+ ], [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.map((comment) => threadCommentModel.getCommentWithChildren(comment.unitId, comment.subUnitId, comment.id)).map((comment) => comment != null && comment.relativeUsers.has(currentUser.userID) ? comment.root : null).filter(Boolean) : commentsSorted, [commentsSorted, currentUser == null ? void 0 : currentUser.userID, status, threadCommentModel]), 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(() => {
640
+ setStatus("all"), setUnit("all");
641
+ }, "onReset");
642
+ useEffect(() => {
643
+ unitId && setUnitComments(
644
+ threadCommentModel.getUnit(unitId)
655
645
  );
656
- }, [e, d, M]), ve(() => {
657
- var J;
658
- if (!p)
646
+ }, [unitId, threadCommentModel, update]), useEffect(() => {
647
+ var _a3;
648
+ if (!activeCommentId)
659
649
  return;
660
- if (!Y.current) {
661
- Y.current = !0;
650
+ if (!shouldScroll.current) {
651
+ shouldScroll.current = !0;
662
652
  return;
663
653
  }
664
- const { unitId: s, subUnitId: q, commentId: re } = p, oe = `${te}-${s}-${q}-${re}`;
665
- (J = document.getElementById(oe)) == null || J.scrollIntoView({ block: "center" });
666
- }, [p]);
667
- const pe = (s) => /* @__PURE__ */ a.createElement(
668
- fn,
654
+ const { unitId: unitId2, subUnitId: subUnitId2, commentId } = activeCommentId, id = `${prefix}-${unitId2}-${subUnitId2}-${commentId}`;
655
+ (_a3 = document.getElementById(id)) == null || _a3.scrollIntoView({ block: "center" });
656
+ }, [activeCommentId]);
657
+ const renderComment = /* @__PURE__ */ __name((comment) => /* @__PURE__ */ React.createElement(
658
+ ThreadCommentTree,
669
659
  {
670
- prefix: te,
671
- getSubUnitName: i,
672
- key: s.id,
673
- id: s.id,
674
- unitId: s.unitId,
675
- subUnitId: s.subUnitId,
676
- refStr: s.ref,
677
- type: r,
678
- showEdit: (p == null ? void 0 : p.commentId) === s.id,
679
- showHighlight: (p == null ? void 0 : p.commentId) === s.id,
680
- onClick: () => {
681
- Y.current = !1, s.resolved ? Z.executeCommand(V.id) : Z.executeCommand(
682
- V.id,
660
+ prefix,
661
+ getSubUnitName,
662
+ key: comment.id,
663
+ id: comment.id,
664
+ unitId: comment.unitId,
665
+ subUnitId: comment.subUnitId,
666
+ refStr: comment.ref,
667
+ type,
668
+ showEdit: (activeCommentId == null ? void 0 : activeCommentId.commentId) === comment.id,
669
+ showHighlight: (activeCommentId == null ? void 0 : activeCommentId.commentId) === comment.id,
670
+ onClick: /* @__PURE__ */ __name(() => {
671
+ shouldScroll.current = !1, comment.resolved ? commandService.executeCommand(SetActiveCommentOperation.id) : commandService.executeCommand(
672
+ SetActiveCommentOperation.id,
683
673
  {
684
- unitId: s.unitId,
685
- subUnitId: s.subUnitId,
686
- commentId: s.id,
674
+ unitId: comment.unitId,
675
+ subUnitId: comment.subUnitId,
676
+ commentId: comment.id,
687
677
  temp: !1
688
678
  }
689
679
  );
690
- },
691
- onMouseEnter: () => y == null ? void 0 : y(s),
692
- onMouseLeave: () => f == null ? void 0 : f(s),
693
- onAddComment: I,
694
- onDeleteComment: h,
695
- onResolve: (q) => m == null ? void 0 : m(s.id, q)
680
+ }, "onClick"),
681
+ onMouseEnter: /* @__PURE__ */ __name(() => onItemEnter == null ? void 0 : onItemEnter(comment), "onMouseEnter"),
682
+ onMouseLeave: /* @__PURE__ */ __name(() => onItemLeave == null ? void 0 : onItemLeave(comment), "onMouseLeave"),
683
+ onAddComment,
684
+ onDeleteComment,
685
+ onResolve: /* @__PURE__ */ __name((resolved) => onResolve == null ? void 0 : onResolve(comment.id, resolved), "onResolve")
696
686
  }
697
- );
698
- return /* @__PURE__ */ a.createElement("div", { className: Q.threadCommentPanel }, /* @__PURE__ */ a.createElement("div", { className: Q.threadCommentPanelForms }, r === Ce.UNIVER_SHEET ? /* @__PURE__ */ a.createElement(
699
- be,
687
+ ), "renderComment");
688
+ return /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanel }, /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelForms }, type === UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ React.createElement(
689
+ Select,
700
690
  {
701
691
  borderless: !0,
702
- value: S,
703
- onChange: (s) => N(s),
692
+ value: unit,
693
+ onChange: /* @__PURE__ */ __name((e) => setUnit(e), "onChange"),
704
694
  options: [
705
695
  {
706
696
  value: "current",
707
- label: v.t("threadCommentUI.filter.sheet.current")
697
+ label: localeService.t("threadCommentUI.filter.sheet.current")
708
698
  },
709
699
  {
710
700
  value: "all",
711
- label: v.t("threadCommentUI.filter.sheet.all")
701
+ label: localeService.t("threadCommentUI.filter.sheet.all")
712
702
  }
713
703
  ]
714
704
  }
715
- ) : null, /* @__PURE__ */ a.createElement(
716
- be,
705
+ ) : null, /* @__PURE__ */ React.createElement(
706
+ Select,
717
707
  {
718
708
  borderless: !0,
719
- value: E,
720
- onChange: (s) => H(s),
709
+ value: status,
710
+ onChange: /* @__PURE__ */ __name((e) => setStatus(e), "onChange"),
721
711
  options: [
722
712
  {
723
713
  value: "all",
724
- label: v.t("threadCommentUI.filter.status.all")
714
+ label: localeService.t("threadCommentUI.filter.status.all")
725
715
  },
726
716
  {
727
717
  value: "resolved",
728
- label: v.t("threadCommentUI.filter.status.resolved")
718
+ label: localeService.t("threadCommentUI.filter.status.resolved")
729
719
  },
730
720
  {
731
721
  value: "unsolved",
732
- label: v.t("threadCommentUI.filter.status.unsolved")
722
+ label: localeService.t("threadCommentUI.filter.status.unsolved")
733
723
  },
734
724
  {
735
725
  value: "concern_me",
736
- label: v.t("threadCommentUI.filter.status.concernMe")
726
+ label: localeService.t("threadCommentUI.filter.status.concernMe")
737
727
  }
738
728
  ]
739
729
  }
740
- )), ne.map(pe), x.length ? /* @__PURE__ */ a.createElement("div", { className: Q.threadCommentPanelSolved }, "已解决") : null, x.map(pe), F.length ? null : /* @__PURE__ */ a.createElement("div", { className: Q.threadCommentPanelEmpty }, $ ? v.t("threadCommentUI.panel.filterEmpty") : v.t("threadCommentUI.panel.empty"), $ ? /* @__PURE__ */ a.createElement(
741
- le,
730
+ )), 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(
731
+ Button,
742
732
  {
743
- onClick: L,
733
+ onClick: onReset,
744
734
  type: "link"
745
735
  },
746
- v.t("threadCommentUI.panel.reset")
747
- ) : /* @__PURE__ */ a.createElement(
748
- le,
736
+ localeService.t("threadCommentUI.panel.reset")
737
+ ) : /* @__PURE__ */ React.createElement(
738
+ Button,
749
739
  {
750
740
  id: "thread-comment-add",
751
- className: Q.threadCommentPanelAdd,
741
+ className: styles.threadCommentPanelAdd,
752
742
  type: "primary",
753
- onClick: o,
754
- disabled: P
743
+ onClick: onAdd,
744
+ disabled: disableAdd
755
745
  },
756
- /* @__PURE__ */ a.createElement(He, null),
757
- v.t("threadCommentUI.panel.addComment")
746
+ /* @__PURE__ */ React.createElement(IncreaseSingle, null),
747
+ localeService.t("threadCommentUI.panel.addComment")
758
748
  )));
759
- };
749
+ }, "ThreadCommentPanel");
760
750
  export {
761
- Pe as IThreadCommentMentionDataService,
762
- V as SetActiveCommentOperation,
763
- gt as THREAD_COMMENT_PANEL,
764
- kn as ThreadCommentPanel,
765
- z as ThreadCommentPanelService,
766
- fn as ThreadCommentTree,
767
- Et as ToggleSheetCommentPanelOperation,
768
- se as UniverThreadCommentUIPlugin,
769
- ft as getDT
751
+ IThreadCommentMentionDataService,
752
+ SetActiveCommentOperation,
753
+ THREAD_COMMENT_PANEL,
754
+ ThreadCommentPanel,
755
+ ThreadCommentPanelService,
756
+ ThreadCommentTree,
757
+ ToggleSheetCommentPanelOperation,
758
+ UniverThreadCommentUIPlugin,
759
+ getDT
770
760
  };