@univerjs/thread-comment-ui 0.5.5-nightly.202501220324 → 0.5.5

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