@univerjs/thread-comment-ui 0.5.4 → 0.5.5-experimental.20250122-3362a4a

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