@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/cjs/index.js +4 -11
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +604 -636
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/types/views/thread-comment-editor/index.d.ts +2 -1
- package/lib/types/views/thread-comment-editor/util.d.ts +1 -8
- package/lib/types/views/thread-comment-panel/index.d.ts +1 -2
- package/lib/types/views/thread-comment-tree/index.d.ts +2 -2
- package/lib/umd/index.js +4 -11
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +8 -10
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
var
|
|
14
|
-
for (var
|
|
15
|
-
(
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
constructor(
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this._sidebarService =
|
|
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((
|
|
34
|
-
|
|
33
|
+
this._sidebarService.sidebarOptions$.subscribe((opt) => {
|
|
34
|
+
opt.visible || this.setPanelVisible(!1);
|
|
35
35
|
})
|
|
36
36
|
), this.disposeWithMe(
|
|
37
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
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(
|
|
49
|
-
this._panelVisible =
|
|
48
|
+
setPanelVisible(visible) {
|
|
49
|
+
this._panelVisible = visible, this._panelVisible$.next(visible);
|
|
50
50
|
}
|
|
51
|
-
setActiveComment(
|
|
52
|
-
this._activeCommentId =
|
|
51
|
+
setActiveComment(commentInfo) {
|
|
52
|
+
this._activeCommentId = commentInfo, this._activeCommentId$.next(commentInfo);
|
|
53
53
|
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
],
|
|
59
|
-
const
|
|
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:
|
|
62
|
-
handler(
|
|
63
|
-
const
|
|
64
|
-
return
|
|
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:
|
|
66
|
+
children: { label: THREAD_COMMENT_PANEL },
|
|
67
67
|
width: 330
|
|
68
|
-
}),
|
|
68
|
+
}), panelService.setPanelVisible(!0)), !0;
|
|
69
69
|
}
|
|
70
|
-
},
|
|
70
|
+
}, SetActiveCommentOperation = {
|
|
71
71
|
id: "thread-comment-ui.operation.set-active-comment",
|
|
72
|
-
type:
|
|
73
|
-
handler(
|
|
74
|
-
return
|
|
72
|
+
type: CommandType.OPERATION,
|
|
73
|
+
handler(accessor, params) {
|
|
74
|
+
return accessor.get(ThreadCommentPanelService).setActiveComment(params), !0;
|
|
75
75
|
}
|
|
76
|
-
},
|
|
77
|
-
var
|
|
78
|
-
for (var
|
|
79
|
-
(
|
|
80
|
-
return
|
|
81
|
-
},
|
|
82
|
-
let
|
|
83
|
-
constructor(
|
|
84
|
-
super(), this._config =
|
|
85
|
-
const { menu
|
|
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
|
-
|
|
87
|
+
defaultPluginConfig,
|
|
88
88
|
this._config
|
|
89
89
|
);
|
|
90
|
-
|
|
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
|
|
94
|
-
|
|
95
|
-
[
|
|
96
|
-
], (
|
|
97
|
-
this._injector.add(
|
|
98
|
-
}), [
|
|
99
|
-
this._commandService.registerCommand(
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
],
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
},
|
|
147
|
-
},
|
|
148
|
-
var
|
|
149
|
-
for (var
|
|
150
|
-
if (
|
|
151
|
-
for (var i = 0,
|
|
152
|
-
e.indexOf(
|
|
153
|
-
return
|
|
154
|
-
},
|
|
155
|
-
var
|
|
156
|
-
return
|
|
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
|
|
159
|
-
return
|
|
160
|
-
return
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
152
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
153
|
+
function generateShortUuid() {
|
|
179
154
|
return Math.random().toString(36).substring(2, 8);
|
|
180
155
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
|
186
|
-
icon:
|
|
161
|
+
ref,
|
|
162
|
+
icon: element$5
|
|
187
163
|
}));
|
|
188
164
|
});
|
|
189
|
-
|
|
190
|
-
var
|
|
191
|
-
return
|
|
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
|
|
194
|
-
icon:
|
|
169
|
+
ref,
|
|
170
|
+
icon: element$4
|
|
195
171
|
}));
|
|
196
172
|
});
|
|
197
|
-
|
|
198
|
-
var
|
|
199
|
-
return
|
|
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
|
|
202
|
-
icon:
|
|
177
|
+
ref,
|
|
178
|
+
icon: element$3
|
|
203
179
|
}));
|
|
204
180
|
});
|
|
205
|
-
|
|
206
|
-
var
|
|
207
|
-
return
|
|
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
|
|
210
|
-
icon:
|
|
185
|
+
ref,
|
|
186
|
+
icon: element$2
|
|
211
187
|
}));
|
|
212
188
|
});
|
|
213
|
-
|
|
214
|
-
var
|
|
215
|
-
return
|
|
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
|
|
218
|
-
icon:
|
|
193
|
+
ref,
|
|
194
|
+
icon: element$1
|
|
219
195
|
}));
|
|
220
196
|
});
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
return
|
|
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
|
|
226
|
-
icon:
|
|
201
|
+
ref,
|
|
202
|
+
icon: element
|
|
227
203
|
}));
|
|
228
204
|
});
|
|
229
|
-
|
|
230
|
-
function
|
|
231
|
-
var
|
|
232
|
-
if (typeof
|
|
233
|
-
else if (typeof
|
|
234
|
-
var
|
|
235
|
-
for (
|
|
236
|
-
} else for (
|
|
237
|
-
return
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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:
|
|
284
|
-
}),
|
|
326
|
+
content: dataStream.slice(lastIndex, range.startIndex)
|
|
327
|
+
}), textNodes.push({
|
|
285
328
|
type: "mention",
|
|
286
329
|
content: {
|
|
287
|
-
label:
|
|
288
|
-
id:
|
|
330
|
+
label: dataStream.slice(range.startIndex, range.endIndex + 1),
|
|
331
|
+
id: range.rangeId
|
|
289
332
|
}
|
|
290
|
-
}),
|
|
291
|
-
}),
|
|
333
|
+
}), lastIndex = range.endIndex + 1;
|
|
334
|
+
}), textNodes.push({
|
|
292
335
|
type: "text",
|
|
293
|
-
content:
|
|
294
|
-
}),
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return
|
|
299
|
-
|
|
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
|
-
|
|
351
|
+
str += node.content;
|
|
302
352
|
break;
|
|
303
353
|
case "mention": {
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
rangeId:
|
|
309
|
-
rangeType:
|
|
310
|
-
startIndex:
|
|
311
|
-
endIndex:
|
|
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
|
-
}),
|
|
367
|
+
}), str += `
|
|
318
368
|
\r`, {
|
|
319
369
|
textRuns: [],
|
|
320
370
|
paragraphs: [
|
|
321
371
|
{
|
|
322
|
-
startIndex:
|
|
372
|
+
startIndex: str.length - 2,
|
|
323
373
|
paragraphStyle: {}
|
|
324
374
|
}
|
|
325
375
|
],
|
|
326
376
|
sectionBreaks: [
|
|
327
377
|
{
|
|
328
|
-
startIndex:
|
|
378
|
+
startIndex: str.length - 1
|
|
329
379
|
}
|
|
330
380
|
],
|
|
331
|
-
dataStream:
|
|
332
|
-
customRanges
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
|
445
|
-
subUnitId
|
|
446
|
-
commentId:
|
|
409
|
+
unitId,
|
|
410
|
+
subUnitId,
|
|
411
|
+
commentId: item.id
|
|
447
412
|
}
|
|
448
|
-
),
|
|
449
|
-
};
|
|
450
|
-
return /* @__PURE__ */
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
/* @__PURE__ */
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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__ */
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */
|
|
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__ */
|
|
428
|
+
children: /* @__PURE__ */ jsx("div", { className: styles$1.threadCommentIcon, children: /* @__PURE__ */ jsx(MoreHorizontalSingle, {}) })
|
|
464
429
|
}
|
|
465
430
|
) : null
|
|
466
431
|
] })
|
|
467
432
|
] }),
|
|
468
|
-
/* @__PURE__ */
|
|
469
|
-
|
|
470
|
-
|
|
433
|
+
/* @__PURE__ */ jsx("div", { className: styles$1.threadCommentItemTime, children: item.dT }),
|
|
434
|
+
editing ? /* @__PURE__ */ jsx(
|
|
435
|
+
ThreadCommentEditor,
|
|
471
436
|
{
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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
|
|
477
|
-
subUnitId
|
|
478
|
-
onSave: ({ text
|
|
479
|
-
|
|
480
|
-
|
|
442
|
+
unitId,
|
|
443
|
+
subUnitId,
|
|
444
|
+
onSave: /* @__PURE__ */ __name(({ text, attachments }) => {
|
|
445
|
+
onEditingChange == null || onEditingChange(!1), commandService.executeCommand(
|
|
446
|
+
UpdateCommentCommand.id,
|
|
481
447
|
{
|
|
482
|
-
unitId
|
|
483
|
-
subUnitId
|
|
448
|
+
unitId,
|
|
449
|
+
subUnitId,
|
|
484
450
|
payload: {
|
|
485
|
-
commentId:
|
|
486
|
-
text
|
|
487
|
-
attachments
|
|
451
|
+
commentId: item.id,
|
|
452
|
+
text,
|
|
453
|
+
attachments
|
|
488
454
|
}
|
|
489
455
|
}
|
|
490
456
|
);
|
|
491
|
-
}
|
|
457
|
+
}, "onSave")
|
|
492
458
|
}
|
|
493
|
-
) : /* @__PURE__ */
|
|
494
|
-
switch (
|
|
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__ */
|
|
497
|
-
|
|
498
|
-
c.content.label,
|
|
462
|
+
return /* @__PURE__ */ jsxs("a", { className: styles$1.threadCommentItemAt, children: [
|
|
463
|
+
item2.content.label,
|
|
499
464
|
" "
|
|
500
|
-
] },
|
|
465
|
+
] }, i2);
|
|
501
466
|
default:
|
|
502
|
-
return
|
|
467
|
+
return item2.content;
|
|
503
468
|
}
|
|
504
|
-
}) })
|
|
469
|
+
}) }, i)) })
|
|
505
470
|
] });
|
|
506
|
-
},
|
|
507
|
-
var
|
|
471
|
+
}, "ThreadCommentItem"), ThreadCommentTree = /* @__PURE__ */ __name((props) => {
|
|
472
|
+
var _a3, _b, _c;
|
|
508
473
|
const {
|
|
509
|
-
id
|
|
510
|
-
unitId
|
|
511
|
-
subUnitId
|
|
512
|
-
refStr
|
|
513
|
-
showEdit
|
|
514
|
-
onClick
|
|
515
|
-
showHighlight
|
|
516
|
-
onClose
|
|
517
|
-
getSubUnitName
|
|
518
|
-
prefix
|
|
519
|
-
autoFocus
|
|
520
|
-
onMouseEnter
|
|
521
|
-
onMouseLeave
|
|
522
|
-
onAddComment
|
|
523
|
-
onDeleteComment
|
|
524
|
-
onResolve
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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:
|
|
497
|
+
id: MOCK_ID,
|
|
532
498
|
text: {
|
|
533
499
|
dataStream: `
|
|
534
500
|
\r`
|
|
535
501
|
},
|
|
536
|
-
personId: (
|
|
537
|
-
ref:
|
|
502
|
+
personId: (_a3 = currentUser == null ? void 0 : currentUser.userID) != null ? _a3 : "",
|
|
503
|
+
ref: refStr != null ? refStr : "",
|
|
538
504
|
dT: "",
|
|
539
|
-
unitId
|
|
540
|
-
subUnitId
|
|
505
|
+
unitId,
|
|
506
|
+
subUnitId,
|
|
541
507
|
threadId: ""
|
|
542
508
|
}]
|
|
543
509
|
),
|
|
544
|
-
...(
|
|
545
|
-
],
|
|
546
|
-
|
|
547
|
-
unitId
|
|
548
|
-
subUnitId
|
|
549
|
-
commentId:
|
|
550
|
-
}) :
|
|
551
|
-
unitId
|
|
552
|
-
subUnitId
|
|
553
|
-
commentId:
|
|
554
|
-
resolved: !
|
|
555
|
-
}),
|
|
556
|
-
},
|
|
557
|
-
|
|
558
|
-
|
|
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
|
|
561
|
-
subUnitId
|
|
562
|
-
commentId:
|
|
526
|
+
unitId,
|
|
527
|
+
subUnitId,
|
|
528
|
+
commentId: id
|
|
563
529
|
}
|
|
564
|
-
),
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
return /* @__PURE__ */
|
|
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:
|
|
572
|
-
[
|
|
537
|
+
className: clsx(styles$1.threadComment, {
|
|
538
|
+
[styles$1.threadCommentActive]: !resolved && (showHighlight || isHover || prefix === "cell")
|
|
573
539
|
}),
|
|
574
|
-
onClick
|
|
575
|
-
id: `${
|
|
576
|
-
onMouseEnter: () => {
|
|
577
|
-
|
|
578
|
-
},
|
|
579
|
-
onMouseLeave: () => {
|
|
580
|
-
|
|
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
|
-
!
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
590
|
-
/* @__PURE__ */
|
|
555
|
+
comments ? /* @__PURE__ */ jsxs("div", { className: styles$1.threadCommentIconContainer, children: [
|
|
556
|
+
/* @__PURE__ */ jsx(
|
|
591
557
|
"div",
|
|
592
558
|
{
|
|
593
|
-
onClick:
|
|
594
|
-
className:
|
|
595
|
-
style: { color:
|
|
596
|
-
children:
|
|
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
|
-
(
|
|
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__ */
|
|
603
|
-
(
|
|
604
|
-
|
|
568
|
+
/* @__PURE__ */ jsx("div", { className: styles$1.threadCommentContent, ref: scroller, children: renderComments.map(
|
|
569
|
+
(item) => /* @__PURE__ */ jsx(
|
|
570
|
+
ThreadCommentItem,
|
|
605
571
|
{
|
|
606
|
-
onClose
|
|
607
|
-
unitId
|
|
608
|
-
subUnitId
|
|
609
|
-
item
|
|
610
|
-
isRoot:
|
|
611
|
-
editing:
|
|
612
|
-
resolved:
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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:
|
|
623
|
-
label:
|
|
589
|
+
id: user.userID,
|
|
590
|
+
label: user.name
|
|
624
591
|
}
|
|
625
592
|
}]));
|
|
626
593
|
});
|
|
627
|
-
},
|
|
628
|
-
onAddComment
|
|
629
|
-
onDeleteComment
|
|
594
|
+
}, "onReply"),
|
|
595
|
+
onAddComment,
|
|
596
|
+
onDeleteComment
|
|
630
597
|
},
|
|
631
|
-
|
|
598
|
+
item.id
|
|
632
599
|
)
|
|
633
600
|
) }),
|
|
634
|
-
|
|
635
|
-
|
|
601
|
+
editorVisible ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
602
|
+
ThreadCommentEditor,
|
|
636
603
|
{
|
|
637
|
-
ref:
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
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
|
-
(
|
|
654
|
-
|
|
621
|
+
(onAddComment == null ? void 0 : onAddComment(comment)) !== !1 && (await commandService.executeCommand(
|
|
622
|
+
AddCommentCommand.id,
|
|
655
623
|
{
|
|
656
|
-
unitId
|
|
657
|
-
subUnitId
|
|
658
|
-
comment
|
|
624
|
+
unitId,
|
|
625
|
+
subUnitId,
|
|
626
|
+
comment
|
|
659
627
|
}
|
|
660
|
-
),
|
|
661
|
-
},
|
|
662
|
-
autoFocus:
|
|
663
|
-
onCancel: () => {
|
|
664
|
-
|
|
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
|
-
`${
|
|
635
|
+
`${autoFocus}`
|
|
668
636
|
) }) : null
|
|
669
637
|
]
|
|
670
638
|
}
|
|
671
639
|
);
|
|
672
|
-
},
|
|
673
|
-
threadCommentPanel
|
|
674
|
-
threadComment
|
|
675
|
-
threadCommentPanelForms
|
|
676
|
-
select
|
|
677
|
-
threadCommentPanelEmpty
|
|
678
|
-
threadCommentPanelAdd
|
|
679
|
-
threadCommentPanelSolved
|
|
680
|
-
},
|
|
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
|
|
683
|
-
subUnitId
|
|
684
|
-
type
|
|
685
|
-
onAdd
|
|
686
|
-
getSubUnitName
|
|
687
|
-
onResolve
|
|
688
|
-
sortComments
|
|
689
|
-
onItemLeave
|
|
690
|
-
onItemEnter
|
|
691
|
-
disableAdd
|
|
692
|
-
tempComment
|
|
693
|
-
onAddComment
|
|
694
|
-
onDeleteComment
|
|
695
|
-
showComments
|
|
696
|
-
} =
|
|
697
|
-
var
|
|
698
|
-
const
|
|
699
|
-
var
|
|
700
|
-
return { ...
|
|
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 (
|
|
703
|
-
const
|
|
704
|
-
return
|
|
705
|
-
|
|
706
|
-
}), [...
|
|
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
|
|
709
|
-
}, [
|
|
710
|
-
...
|
|
711
|
-
...
|
|
712
|
-
], [
|
|
713
|
-
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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
|
-
}, [
|
|
720
|
-
var
|
|
721
|
-
if (!
|
|
687
|
+
}, [unitId, threadCommentModel, update]), useEffect(() => {
|
|
688
|
+
var _a3;
|
|
689
|
+
if (!activeCommentId)
|
|
722
690
|
return;
|
|
723
|
-
if (!
|
|
724
|
-
|
|
691
|
+
if (!shouldScroll.current) {
|
|
692
|
+
shouldScroll.current = !0;
|
|
725
693
|
return;
|
|
726
694
|
}
|
|
727
|
-
const { unitId:
|
|
728
|
-
(
|
|
729
|
-
}, [
|
|
730
|
-
const
|
|
731
|
-
|
|
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
|
|
734
|
-
getSubUnitName
|
|
735
|
-
id:
|
|
736
|
-
unitId:
|
|
737
|
-
subUnitId:
|
|
738
|
-
refStr:
|
|
739
|
-
type
|
|
740
|
-
showEdit: (
|
|
741
|
-
showHighlight: (
|
|
742
|
-
onClick: () => {
|
|
743
|
-
|
|
744
|
-
|
|
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:
|
|
747
|
-
subUnitId:
|
|
748
|
-
commentId:
|
|
714
|
+
unitId: comment.unitId,
|
|
715
|
+
subUnitId: comment.subUnitId,
|
|
716
|
+
commentId: comment.id,
|
|
749
717
|
temp: !1
|
|
750
718
|
}
|
|
751
719
|
);
|
|
752
|
-
},
|
|
753
|
-
onMouseEnter: () =>
|
|
754
|
-
onMouseLeave: () =>
|
|
755
|
-
onAddComment
|
|
756
|
-
onDeleteComment
|
|
757
|
-
onResolve: (
|
|
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
|
-
|
|
760
|
-
);
|
|
761
|
-
return /* @__PURE__ */
|
|
762
|
-
/* @__PURE__ */
|
|
763
|
-
|
|
764
|
-
|
|
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:
|
|
768
|
-
onChange: (
|
|
735
|
+
value: unit,
|
|
736
|
+
onChange: /* @__PURE__ */ __name((e) => setUnit(e), "onChange"),
|
|
769
737
|
options: [
|
|
770
738
|
{
|
|
771
739
|
value: "current",
|
|
772
|
-
label:
|
|
740
|
+
label: localeService.t("threadCommentUI.filter.sheet.current")
|
|
773
741
|
},
|
|
774
742
|
{
|
|
775
743
|
value: "all",
|
|
776
|
-
label:
|
|
744
|
+
label: localeService.t("threadCommentUI.filter.sheet.all")
|
|
777
745
|
}
|
|
778
746
|
]
|
|
779
747
|
}
|
|
780
748
|
) : null,
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
|
|
749
|
+
/* @__PURE__ */ jsx(
|
|
750
|
+
Select,
|
|
783
751
|
{
|
|
784
752
|
borderless: !0,
|
|
785
|
-
value:
|
|
786
|
-
onChange: (
|
|
753
|
+
value: status,
|
|
754
|
+
onChange: /* @__PURE__ */ __name((e) => setStatus(e), "onChange"),
|
|
787
755
|
options: [
|
|
788
756
|
{
|
|
789
757
|
value: "all",
|
|
790
|
-
label:
|
|
758
|
+
label: localeService.t("threadCommentUI.filter.status.all")
|
|
791
759
|
},
|
|
792
760
|
{
|
|
793
761
|
value: "resolved",
|
|
794
|
-
label:
|
|
762
|
+
label: localeService.t("threadCommentUI.filter.status.resolved")
|
|
795
763
|
},
|
|
796
764
|
{
|
|
797
765
|
value: "unsolved",
|
|
798
|
-
label:
|
|
766
|
+
label: localeService.t("threadCommentUI.filter.status.unsolved")
|
|
799
767
|
},
|
|
800
768
|
{
|
|
801
769
|
value: "concern_me",
|
|
802
|
-
label:
|
|
770
|
+
label: localeService.t("threadCommentUI.filter.status.concernMe")
|
|
803
771
|
}
|
|
804
772
|
]
|
|
805
773
|
}
|
|
806
774
|
)
|
|
807
775
|
] }),
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
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:
|
|
784
|
+
onClick: onReset,
|
|
817
785
|
type: "link",
|
|
818
|
-
children:
|
|
786
|
+
children: localeService.t("threadCommentUI.panel.reset")
|
|
819
787
|
}
|
|
820
|
-
) : /* @__PURE__ */
|
|
821
|
-
|
|
788
|
+
) : /* @__PURE__ */ jsxs(
|
|
789
|
+
Button,
|
|
822
790
|
{
|
|
823
791
|
id: "thread-comment-add",
|
|
824
|
-
className:
|
|
792
|
+
className: styles.threadCommentPanelAdd,
|
|
825
793
|
type: "primary",
|
|
826
|
-
onClick:
|
|
827
|
-
disabled:
|
|
794
|
+
onClick: onAdd,
|
|
795
|
+
disabled: disableAdd,
|
|
828
796
|
children: [
|
|
829
|
-
/* @__PURE__ */
|
|
830
|
-
|
|
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
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
806
|
+
SetActiveCommentOperation,
|
|
807
|
+
THREAD_COMMENT_PANEL,
|
|
808
|
+
ThreadCommentPanel,
|
|
809
|
+
ThreadCommentPanelService,
|
|
810
|
+
ThreadCommentTree,
|
|
811
|
+
ToggleSheetCommentPanelOperation,
|
|
812
|
+
UniverThreadCommentUIPlugin
|
|
845
813
|
};
|