@univerjs/thread-comment-ui 0.2.5 → 0.2.7

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