@univerjs/thread-comment-ui 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +3 -3
- package/lib/es/index.js +549 -559
- package/lib/types/plugin.d.ts +2 -3
- package/lib/types/services/thread-comment-mention-data.service.d.ts +1 -1
- package/lib/types/views/thread-comment-panel/index.d.ts +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +19 -21
- package/lib/types/controllers/thread-comment-ui.controller.d.ts +0 -6
package/lib/es/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { Inject
|
|
8
|
-
import { ISidebarService
|
|
9
|
-
import { BehaviorSubject
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return ze().format("YYYY/MM/DD HH:mm");
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import { UniverThreadCommentPlugin, ThreadCommentModel, AddCommentCommand, UpdateCommentCommand, ResolveCommentCommand, DeleteCommentTreeCommand, DeleteCommentCommand } from "@univerjs/thread-comment";
|
|
7
|
+
import { Disposable, UniverInstanceType, Inject, IUniverInstanceService, CommandType, createIdentifier, Plugin, mergeOverrideWithDependencies, DependentOn, Injector, ICommandService, CustomRangeType, useDependency, LocaleService, UserManagerService, Tools } from "@univerjs/core";
|
|
8
|
+
import { ISidebarService, useObservable } from "@univerjs/ui";
|
|
9
|
+
import { BehaviorSubject, filter } from "rxjs";
|
|
10
|
+
import React, { forwardRef, useRef, createElement, useState, useImperativeHandle, useEffect, useMemo } from "react";
|
|
11
|
+
import { Mentions, Mention, Button, Dropdown, Menu, MenuItem, Select } from "@univerjs/design";
|
|
12
|
+
import cs from "clsx";
|
|
13
|
+
import { ITextSelectionRenderManager } from "@univerjs/engine-render";
|
|
14
|
+
import { TextSelectionManagerService } from "@univerjs/docs";
|
|
15
|
+
function getDT() {
|
|
16
|
+
return dayjs().format("YYYY/MM/DD HH:mm");
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
__name(getDT, "getDT");
|
|
19
|
+
const THREAD_COMMENT_PANEL = "thread-comment-panel", PLUGIN_NAME = "THREAD_COMMENT_UI_PLUGIN";
|
|
20
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
21
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
23
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
24
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a;
|
|
25
|
+
let ThreadCommentPanelService = (_a = class extends Disposable {
|
|
26
|
+
constructor(_sidebarService, _univerInstanceService) {
|
|
27
27
|
super();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this._sidebarService =
|
|
28
|
+
__publicField(this, "_panelVisible", !1);
|
|
29
|
+
__publicField(this, "_panelVisible$", new BehaviorSubject(!1));
|
|
30
|
+
__publicField(this, "_activeCommentId");
|
|
31
|
+
__publicField(this, "_activeCommentId$", new BehaviorSubject(void 0));
|
|
32
|
+
__publicField(this, "panelVisible$", this._panelVisible$.asObservable());
|
|
33
|
+
__publicField(this, "activeCommentId$", this._activeCommentId$.asObservable());
|
|
34
|
+
this._sidebarService = _sidebarService, this._univerInstanceService = _univerInstanceService, this._init(), this.disposeWithMe(() => {
|
|
35
35
|
this._activeCommentId$.complete(), this._panelVisible$.complete();
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
_init() {
|
|
39
39
|
this.disposeWithMe(
|
|
40
|
-
this._sidebarService.sidebarOptions$.subscribe((
|
|
41
|
-
|
|
40
|
+
this._sidebarService.sidebarOptions$.subscribe((opt) => {
|
|
41
|
+
opt.visible || this.setPanelVisible(!1);
|
|
42
42
|
})
|
|
43
43
|
), this.disposeWithMe(
|
|
44
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
44
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
|
|
45
45
|
this._sidebarService.close();
|
|
46
46
|
})
|
|
47
47
|
);
|
|
@@ -52,719 +52,709 @@ let z = class extends Te {
|
|
|
52
52
|
get activeCommentId() {
|
|
53
53
|
return this._activeCommentId;
|
|
54
54
|
}
|
|
55
|
-
setPanelVisible(
|
|
56
|
-
this._panelVisible =
|
|
55
|
+
setPanelVisible(visible) {
|
|
56
|
+
this._panelVisible = visible, this._panelVisible$.next(visible);
|
|
57
57
|
}
|
|
58
|
-
setActiveComment(
|
|
59
|
-
this._activeCommentId =
|
|
58
|
+
setActiveComment(commentInfo) {
|
|
59
|
+
this._activeCommentId = commentInfo, this._activeCommentId$.next(commentInfo);
|
|
60
60
|
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
],
|
|
66
|
-
const
|
|
61
|
+
}, __name(_a, "ThreadCommentPanelService"), _a);
|
|
62
|
+
ThreadCommentPanelService = __decorateClass$1([
|
|
63
|
+
__decorateParam$1(0, Inject(ISidebarService)),
|
|
64
|
+
__decorateParam$1(1, IUniverInstanceService)
|
|
65
|
+
], ThreadCommentPanelService);
|
|
66
|
+
const ToggleSheetCommentPanelOperation = {
|
|
67
67
|
id: "thread-comment-ui.operation.toggle-panel",
|
|
68
|
-
type:
|
|
69
|
-
handler(
|
|
70
|
-
const
|
|
71
|
-
return
|
|
68
|
+
type: CommandType.OPERATION,
|
|
69
|
+
handler(accessor) {
|
|
70
|
+
const sidebarService = accessor.get(ISidebarService), panelService = accessor.get(ThreadCommentPanelService);
|
|
71
|
+
return panelService.panelVisible ? (sidebarService.close(), panelService.setPanelVisible(!1)) : (sidebarService.open({
|
|
72
72
|
header: { title: "threadCommentUI.panel.title" },
|
|
73
|
-
children: { label:
|
|
73
|
+
children: { label: THREAD_COMMENT_PANEL },
|
|
74
74
|
width: 320
|
|
75
|
-
}),
|
|
75
|
+
}), panelService.setPanelVisible(!0)), !0;
|
|
76
76
|
}
|
|
77
|
-
},
|
|
77
|
+
}, SetActiveCommentOperation = {
|
|
78
78
|
id: "thread-comment-ui.operation.set-active-comment",
|
|
79
|
-
type:
|
|
80
|
-
handler(
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
var yt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, _t = (t, e, n, r) => {
|
|
85
|
-
for (var o = r > 1 ? void 0 : r ? xt(e, n) : e, i = t.length - 1, m; i >= 0; i--)
|
|
86
|
-
(m = t[i]) && (o = (r ? m(e, n, o) : m(o)) || o);
|
|
87
|
-
return r && o && yt(e, n, o), o;
|
|
88
|
-
}, Tt = (t, e) => (n, r) => e(n, r, t);
|
|
89
|
-
let ie = class extends Te {
|
|
90
|
-
constructor(t) {
|
|
91
|
-
super(), this._localeService = t;
|
|
79
|
+
type: CommandType.OPERATION,
|
|
80
|
+
handler(accessor, params) {
|
|
81
|
+
return accessor.get(ThreadCommentPanelService).setActiveComment(params), !0;
|
|
92
82
|
}
|
|
93
|
-
}
|
|
94
|
-
ie = _t([
|
|
95
|
-
Qe(Xe.Starting, ie),
|
|
96
|
-
Tt(0, ge(de))
|
|
97
|
-
], ie);
|
|
98
|
-
class Nt {
|
|
83
|
+
}, _ThreadCommentMentionDataService = class _ThreadCommentMentionDataService {
|
|
99
84
|
constructor() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
85
|
+
__publicField(this, "dataSource");
|
|
86
|
+
__publicField(this, "renderSuggestion");
|
|
87
|
+
__publicField(this, "trigger", "@");
|
|
103
88
|
}
|
|
104
|
-
async getMentions(
|
|
105
|
-
return this.dataSource ? this.dataSource.getMentions(
|
|
89
|
+
async getMentions(search, unitId, subUnitId) {
|
|
90
|
+
return this.dataSource ? this.dataSource.getMentions(search, unitId, subUnitId) : [];
|
|
106
91
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
92
|
+
};
|
|
93
|
+
__name(_ThreadCommentMentionDataService, "ThreadCommentMentionDataService");
|
|
94
|
+
let ThreadCommentMentionDataService = _ThreadCommentMentionDataService;
|
|
95
|
+
const IThreadCommentMentionDataService = createIdentifier("thread-comment.mention-data.service");
|
|
96
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
97
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
98
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
99
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
100
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a2;
|
|
101
|
+
let UniverThreadCommentUIPlugin = (_a2 = class extends Plugin {
|
|
102
|
+
constructor(_config, _injector, _commandService) {
|
|
103
|
+
super(), this._config = _config, this._injector = _injector, this._commandService = _commandService;
|
|
117
104
|
}
|
|
118
|
-
onStarting(
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
[
|
|
122
|
-
[
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this._commandService.registerCommand(n);
|
|
105
|
+
onStarting() {
|
|
106
|
+
var _a3;
|
|
107
|
+
mergeOverrideWithDependencies([
|
|
108
|
+
[ThreadCommentPanelService],
|
|
109
|
+
[IThreadCommentMentionDataService, { useClass: ThreadCommentMentionDataService }]
|
|
110
|
+
], (_a3 = this._config) == null ? void 0 : _a3.overrides).forEach((dep) => {
|
|
111
|
+
this._injector.add(dep);
|
|
112
|
+
}), [ToggleSheetCommentPanelOperation, SetActiveCommentOperation].forEach((command) => {
|
|
113
|
+
this._commandService.registerCommand(command);
|
|
128
114
|
});
|
|
129
115
|
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
],
|
|
138
|
-
var
|
|
139
|
-
return
|
|
140
|
-
for (var
|
|
141
|
-
|
|
142
|
-
for (var
|
|
116
|
+
}, __name(_a2, "UniverThreadCommentUIPlugin"), _a2);
|
|
117
|
+
__publicField2(UniverThreadCommentUIPlugin, "pluginName", PLUGIN_NAME);
|
|
118
|
+
__publicField2(UniverThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_UNKNOWN);
|
|
119
|
+
UniverThreadCommentUIPlugin = __decorateClass([
|
|
120
|
+
DependentOn(UniverThreadCommentPlugin),
|
|
121
|
+
__decorateParam(1, Inject(Injector)),
|
|
122
|
+
__decorateParam(2, ICommandService)
|
|
123
|
+
], UniverThreadCommentUIPlugin);
|
|
124
|
+
var __assign = function() {
|
|
125
|
+
return __assign = Object.assign || function(t) {
|
|
126
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
127
|
+
s = arguments[i];
|
|
128
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
143
129
|
}
|
|
144
130
|
return t;
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
var
|
|
148
|
-
for (var
|
|
149
|
-
if (
|
|
150
|
-
for (var
|
|
151
|
-
e.indexOf(
|
|
152
|
-
return
|
|
153
|
-
},
|
|
154
|
-
var
|
|
155
|
-
return
|
|
131
|
+
}, __assign.apply(this, arguments);
|
|
132
|
+
}, __rest = function(s, e) {
|
|
133
|
+
var t = {};
|
|
134
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
135
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
136
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
137
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
138
|
+
return t;
|
|
139
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
140
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
141
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
156
142
|
});
|
|
157
|
-
function
|
|
158
|
-
return
|
|
159
|
-
return
|
|
143
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
144
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
145
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
160
146
|
}));
|
|
161
147
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
148
|
+
__name(render, "render");
|
|
149
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
150
|
+
var attrs = __assign({}, node.attrs);
|
|
151
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
152
|
+
var defIds = runtimeProps.defIds;
|
|
153
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a3) {
|
|
154
|
+
var key = _a3[0], value = _a3[1];
|
|
155
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
156
|
+
})), attrs;
|
|
170
157
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
159
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
160
|
+
var _a3, defIds = runtimeProps.defIds;
|
|
161
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a3 = node.children) === null || _a3 === void 0) && _a3.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
162
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
163
|
+
}) }) : node;
|
|
176
164
|
}
|
|
177
|
-
|
|
165
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
166
|
+
function generateShortUuid() {
|
|
178
167
|
return Math.random().toString(36).substring(2, 8);
|
|
179
168
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
170
|
+
IconBase.displayName = "UniverIcon";
|
|
171
|
+
var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, DeleteSingle = forwardRef(function(props, ref) {
|
|
172
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
183
173
|
id: "delete-single",
|
|
184
|
-
ref
|
|
185
|
-
icon:
|
|
174
|
+
ref,
|
|
175
|
+
icon: element$5
|
|
186
176
|
}));
|
|
187
177
|
});
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
return
|
|
178
|
+
DeleteSingle.displayName = "DeleteSingle";
|
|
179
|
+
var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, IncreaseSingle = forwardRef(function(props, ref) {
|
|
180
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
191
181
|
id: "increase-single",
|
|
192
|
-
ref
|
|
193
|
-
icon:
|
|
182
|
+
ref,
|
|
183
|
+
icon: element$4
|
|
194
184
|
}));
|
|
195
185
|
});
|
|
196
|
-
|
|
197
|
-
var
|
|
198
|
-
return
|
|
186
|
+
IncreaseSingle.displayName = "IncreaseSingle";
|
|
187
|
+
var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3 9C3.55228 9 4 8.55228 4 8 4 7.44772 3.55228 7 3 7 2.44772 7 2 7.44772 2 8 2 8.55228 2.44772 9 3 9zM8 9C8.55228 9 9 8.55228 9 8 9 7.44772 8.55228 7 8 7 7.44772 7 7 7.44772 7 8 7 8.55228 7.44772 9 8 9zM13 9C13.5523 9 14 8.55228 14 8 14 7.44772 13.5523 7 13 7 12.4477 7 12 7.44772 12 8 12 8.55228 12.4477 9 13 9z" } }] }, MoreHorizontalSingle = forwardRef(function(props, ref) {
|
|
188
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
199
189
|
id: "more-horizontal-single",
|
|
200
|
-
ref
|
|
201
|
-
icon:
|
|
190
|
+
ref,
|
|
191
|
+
icon: element$3
|
|
202
192
|
}));
|
|
203
193
|
});
|
|
204
|
-
|
|
205
|
-
var
|
|
206
|
-
return
|
|
194
|
+
MoreHorizontalSingle.displayName = "MoreHorizontalSingle";
|
|
195
|
+
var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { stroke: "currentColor", d: "M7.48389 10.3267V12.1905C7.48389 12.7428 7.9316 13.1905 8.48389 13.1905H11.2216L12.2955 14.2644L13.3695 13.1905H14.1593C14.7116 13.1905 15.1593 12.7428 15.1593 12.1905V8.46289C15.1593 7.91061 14.7116 7.46289 14.1593 7.46289H12.2955", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M0.840332 3.73535C0.840332 2.63078 1.73576 1.73535 2.84033 1.73535H10.2955C11.4001 1.73535 12.2955 2.63078 12.2955 3.73535V8.32676C12.2955 9.43132 11.4001 10.3268 10.2955 10.3268H5.6014L4.1695 11.7587L3.05978 10.3268H2.84033C1.73576 10.3268 0.840332 9.43133 0.840332 8.32676V3.73535Z", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.41016 6.1311H6.76813M8.91626 6.1311H9.27424M3.90454 6.1311H4.26252", strokeLinecap: "round", strokeWidth: 1.2 } }] }, ReplyToCommentSingle = forwardRef(function(props, ref) {
|
|
196
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
207
197
|
id: "reply-to-comment-single",
|
|
208
|
-
ref
|
|
209
|
-
icon:
|
|
198
|
+
ref,
|
|
199
|
+
icon: element$2
|
|
210
200
|
}));
|
|
211
201
|
});
|
|
212
|
-
|
|
213
|
-
var
|
|
214
|
-
return
|
|
202
|
+
ReplyToCommentSingle.displayName = "ReplyToCommentSingle";
|
|
203
|
+
var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6106 15.4036C12.4766 15.4036 15.6106 12.2696 15.6106 8.40356C15.6106 4.53757 12.4766 1.40356 8.6106 1.40356C4.7446 1.40356 1.6106 4.53757 1.6106 8.40356C1.6106 12.2696 4.7446 15.4036 8.6106 15.4036ZM12.3351 6.82773C12.5694 6.59342 12.5694 6.21352 12.3351 5.9792C12.1007 5.74489 11.7208 5.74489 11.4865 5.9792L7.91079 9.55494L6.33506 7.9792C6.10074 7.74489 5.72084 7.74489 5.48653 7.9792C5.25221 8.21352 5.25221 8.59342 5.48653 8.82773L7.48653 10.8277C7.72084 11.062 8.10074 11.062 8.33506 10.8277L12.3351 6.82773Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ResolvedSingle = forwardRef(function(props, ref) {
|
|
204
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
215
205
|
id: "resolved-single",
|
|
216
|
-
ref
|
|
217
|
-
icon:
|
|
206
|
+
ref,
|
|
207
|
+
icon: element$1
|
|
218
208
|
}));
|
|
219
209
|
});
|
|
220
|
-
|
|
221
|
-
var
|
|
222
|
-
return
|
|
210
|
+
ResolvedSingle.displayName = "ResolvedSingle";
|
|
211
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "circle", attrs: { cx: 8.73, cy: 8.4, r: 6.4, stroke: "currentColor", strokeWidth: 1.2 } }, { tag: "path", attrs: { stroke: "currentColor", d: "M6.02637 8.40356L8.02637 10.4036L12.0264 6.40356", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.2 } }] }, SolveSingle = forwardRef(function(props, ref) {
|
|
212
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
223
213
|
id: "solve-single",
|
|
224
|
-
ref
|
|
225
|
-
icon:
|
|
214
|
+
ref,
|
|
215
|
+
icon: element
|
|
226
216
|
}));
|
|
227
217
|
});
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
threadCommentEditorButtons
|
|
231
|
-
threadCommentEditorSuggestion
|
|
232
|
-
threadCommentEditorSuggestionActive
|
|
233
|
-
threadCommentEditorSuggestionIcon
|
|
234
|
-
},
|
|
235
|
-
const
|
|
236
|
-
let
|
|
237
|
-
const
|
|
238
|
-
for (; (
|
|
239
|
-
|
|
218
|
+
SolveSingle.displayName = "SolveSingle";
|
|
219
|
+
const threadCommentEditorButtons = "univer-thread-comment-editor-buttons", threadCommentEditorSuggestion = "univer-thread-comment-editor-suggestion", threadCommentEditorSuggestionActive = "univer-thread-comment-editor-suggestionActive", threadCommentEditorSuggestionIcon = "univer-thread-comment-editor-suggestion-icon", styles$2 = {
|
|
220
|
+
threadCommentEditorButtons,
|
|
221
|
+
threadCommentEditorSuggestion,
|
|
222
|
+
threadCommentEditorSuggestionActive,
|
|
223
|
+
threadCommentEditorSuggestionIcon
|
|
224
|
+
}, parseMentions = /* @__PURE__ */ __name((text) => {
|
|
225
|
+
const regex = /@\[(.*?)\]\((.*?)\)|(\w+)/g;
|
|
226
|
+
let match, lastIndex = 0;
|
|
227
|
+
const result = [];
|
|
228
|
+
for (; (match = regex.exec(text)) !== null; )
|
|
229
|
+
match.index > lastIndex && result.push({
|
|
240
230
|
type: "text",
|
|
241
|
-
content:
|
|
242
|
-
}),
|
|
231
|
+
content: text.substring(lastIndex, match.index)
|
|
232
|
+
}), match[1] && match[2] ? result.push({
|
|
243
233
|
type: "mention",
|
|
244
234
|
content: {
|
|
245
|
-
label:
|
|
246
|
-
id:
|
|
235
|
+
label: match[1],
|
|
236
|
+
id: match[2]
|
|
247
237
|
}
|
|
248
|
-
}) :
|
|
238
|
+
}) : match[3] && result.push({
|
|
249
239
|
type: "text",
|
|
250
|
-
content:
|
|
251
|
-
}),
|
|
252
|
-
return
|
|
240
|
+
content: match[3]
|
|
241
|
+
}), lastIndex = regex.lastIndex;
|
|
242
|
+
return lastIndex < text.length && result.push({
|
|
253
243
|
type: "text",
|
|
254
|
-
content:
|
|
255
|
-
}),
|
|
256
|
-
},
|
|
257
|
-
switch (
|
|
244
|
+
content: text.substring(lastIndex)
|
|
245
|
+
}), result;
|
|
246
|
+
}, "parseMentions"), transformTextNode2Text = /* @__PURE__ */ __name((nodes) => nodes.map((item) => {
|
|
247
|
+
switch (item.type) {
|
|
258
248
|
case "mention":
|
|
259
|
-
return `@[${
|
|
249
|
+
return `@[${item.content.label}](${item.content.id})`;
|
|
260
250
|
default:
|
|
261
|
-
return
|
|
251
|
+
return item.content;
|
|
262
252
|
}
|
|
263
|
-
}).join(""),
|
|
264
|
-
const { dataStream
|
|
265
|
-
let
|
|
266
|
-
return
|
|
267
|
-
|
|
253
|
+
}).join(""), "transformTextNode2Text"), transformDocument2TextNodes = /* @__PURE__ */ __name((doc) => {
|
|
254
|
+
const { dataStream, customRanges } = doc, end = dataStream.length - 2, textNodes = [];
|
|
255
|
+
let lastIndex = 0;
|
|
256
|
+
return customRanges == null || customRanges.forEach((range) => {
|
|
257
|
+
lastIndex < range.startIndex && textNodes.push({
|
|
268
258
|
type: "text",
|
|
269
|
-
content:
|
|
270
|
-
}),
|
|
259
|
+
content: dataStream.slice(lastIndex, range.startIndex)
|
|
260
|
+
}), textNodes.push({
|
|
271
261
|
type: "mention",
|
|
272
262
|
content: {
|
|
273
|
-
label:
|
|
274
|
-
id:
|
|
263
|
+
label: dataStream.slice(range.startIndex, range.endIndex).slice(1, -1),
|
|
264
|
+
id: range.rangeId
|
|
275
265
|
}
|
|
276
|
-
}),
|
|
277
|
-
}),
|
|
266
|
+
}), lastIndex = range.endIndex;
|
|
267
|
+
}), textNodes.push({
|
|
278
268
|
type: "text",
|
|
279
|
-
content:
|
|
280
|
-
}),
|
|
281
|
-
},
|
|
282
|
-
let
|
|
283
|
-
const
|
|
284
|
-
return
|
|
285
|
-
switch (
|
|
269
|
+
content: dataStream.slice(lastIndex, end)
|
|
270
|
+
}), textNodes;
|
|
271
|
+
}, "transformDocument2TextNodes"), transformTextNodes2Document = /* @__PURE__ */ __name((nodes) => {
|
|
272
|
+
let str = "";
|
|
273
|
+
const customRanges = [];
|
|
274
|
+
return nodes.forEach((node) => {
|
|
275
|
+
switch (node.type) {
|
|
286
276
|
case "text":
|
|
287
|
-
|
|
277
|
+
str += node.content;
|
|
288
278
|
break;
|
|
289
279
|
case "mention": {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
rangeId:
|
|
295
|
-
rangeType:
|
|
296
|
-
startIndex:
|
|
297
|
-
endIndex:
|
|
280
|
+
const start = str.length;
|
|
281
|
+
str += `${node.content.label}`;
|
|
282
|
+
const end = str.length;
|
|
283
|
+
customRanges.push({
|
|
284
|
+
rangeId: node.content.id,
|
|
285
|
+
rangeType: CustomRangeType.MENTION,
|
|
286
|
+
startIndex: start,
|
|
287
|
+
endIndex: end
|
|
298
288
|
});
|
|
299
289
|
break;
|
|
300
290
|
}
|
|
301
291
|
}
|
|
302
|
-
}),
|
|
292
|
+
}), str += `
|
|
303
293
|
\r`, {
|
|
304
294
|
textRuns: [],
|
|
305
295
|
paragraphs: [
|
|
306
296
|
{
|
|
307
|
-
startIndex:
|
|
297
|
+
startIndex: str.length - 2,
|
|
308
298
|
paragraphStyle: {}
|
|
309
299
|
}
|
|
310
300
|
],
|
|
311
301
|
sectionBreaks: [
|
|
312
302
|
{
|
|
313
|
-
startIndex:
|
|
303
|
+
startIndex: str.length - 1
|
|
314
304
|
}
|
|
315
305
|
],
|
|
316
|
-
dataStream:
|
|
317
|
-
customRanges
|
|
306
|
+
dataStream: str,
|
|
307
|
+
customRanges
|
|
318
308
|
};
|
|
319
|
-
},
|
|
320
|
-
display:
|
|
321
|
-
id: `${
|
|
322
|
-
raw:
|
|
323
|
-
}),
|
|
324
|
-
var
|
|
325
|
-
const
|
|
326
|
-
return /* @__PURE__ */
|
|
327
|
-
},
|
|
328
|
-
var
|
|
329
|
-
const { comment
|
|
330
|
-
return
|
|
331
|
-
reply(
|
|
332
|
-
var
|
|
333
|
-
|
|
334
|
-
...
|
|
335
|
-
text
|
|
309
|
+
}, "transformTextNodes2Document"), transformMention = /* @__PURE__ */ __name((mention) => ({
|
|
310
|
+
display: mention.label,
|
|
311
|
+
id: `${mention.id}`,
|
|
312
|
+
raw: mention
|
|
313
|
+
}), "transformMention"), defaultRenderSuggestion = /* @__PURE__ */ __name((mention, search, highlightedDisplay, index, focused) => {
|
|
314
|
+
var _a3, _b;
|
|
315
|
+
const icon = (_a3 = mention.raw) == null ? void 0 : _a3.icon;
|
|
316
|
+
return /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorSuggestion }, icon ? /* @__PURE__ */ React.createElement("img", { className: styles$2.threadCommentEditorSuggestionIcon, src: icon }) : null, /* @__PURE__ */ React.createElement("div", null, (_b = mention.display) != null ? _b : mention.id));
|
|
317
|
+
}, "defaultRenderSuggestion"), ThreadCommentEditor = forwardRef((props, ref) => {
|
|
318
|
+
var _a3;
|
|
319
|
+
const { comment, onSave, id, onCancel, autoFocus, unitId, subUnitId } = props, mentionDataService = useDependency(IThreadCommentMentionDataService), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localComment, setLocalComment] = useState({ ...comment }), [editing, setEditing] = useState(!1), inputRef = useRef(null), textSelectionRenderManager = useDependency(ITextSelectionRenderManager), textSelectionManagerService = useDependency(TextSelectionManagerService);
|
|
320
|
+
return useImperativeHandle(ref, () => ({
|
|
321
|
+
reply(text) {
|
|
322
|
+
var _a4;
|
|
323
|
+
setLocalComment({
|
|
324
|
+
...comment,
|
|
325
|
+
text,
|
|
336
326
|
attachments: []
|
|
337
|
-
}), (
|
|
327
|
+
}), (_a4 = inputRef.current) == null || _a4.inputElement.focus();
|
|
338
328
|
}
|
|
339
|
-
})), /* @__PURE__ */
|
|
340
|
-
|
|
329
|
+
})), /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditor, onClick: /* @__PURE__ */ __name((e) => e.preventDefault(), "onClick") }, /* @__PURE__ */ React.createElement(
|
|
330
|
+
Mentions,
|
|
341
331
|
{
|
|
342
|
-
ref:
|
|
343
|
-
autoFocus
|
|
332
|
+
ref: inputRef,
|
|
333
|
+
autoFocus,
|
|
344
334
|
style: { width: "100%" },
|
|
345
|
-
placeholder:
|
|
346
|
-
value:
|
|
347
|
-
onChange: (
|
|
348
|
-
|
|
349
|
-
},
|
|
350
|
-
onFocus: () => {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
}
|
|
335
|
+
placeholder: localeService.t("threadCommentUI.editor.placeholder"),
|
|
336
|
+
value: localComment != null && localComment.text ? transformTextNode2Text(transformDocument2TextNodes(localComment.text)) : "",
|
|
337
|
+
onChange: /* @__PURE__ */ __name((e) => {
|
|
338
|
+
e.target.value || setLocalComment({ ...comment, text: void 0 }), setLocalComment == null || setLocalComment({ ...comment, text: transformTextNodes2Document(parseMentions(e.target.value)) });
|
|
339
|
+
}, "onChange"),
|
|
340
|
+
onFocus: /* @__PURE__ */ __name(() => {
|
|
341
|
+
const activeRange = textSelectionManagerService.getActiveRange();
|
|
342
|
+
activeRange && activeRange.collapsed && textSelectionRenderManager.removeAllTextRanges(), textSelectionRenderManager.blur(), setEditing(!0);
|
|
343
|
+
}, "onFocus")
|
|
354
344
|
},
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
|
|
345
|
+
/* @__PURE__ */ React.createElement(
|
|
346
|
+
Mention,
|
|
357
347
|
{
|
|
358
|
-
key:
|
|
359
|
-
trigger:
|
|
360
|
-
data: (
|
|
361
|
-
displayTransform: (
|
|
362
|
-
renderSuggestion: (
|
|
348
|
+
key: mentionDataService.trigger,
|
|
349
|
+
trigger: mentionDataService.trigger,
|
|
350
|
+
data: /* @__PURE__ */ __name((query, callback) => mentionDataService.getMentions(query, unitId, subUnitId).then((res) => res.map(transformMention)).then(callback), "data"),
|
|
351
|
+
displayTransform: /* @__PURE__ */ __name((id2, label) => `@${label} `, "displayTransform"),
|
|
352
|
+
renderSuggestion: (_a3 = mentionDataService.renderSuggestion) != null ? _a3 : defaultRenderSuggestion
|
|
363
353
|
}
|
|
364
354
|
)
|
|
365
|
-
),
|
|
366
|
-
|
|
355
|
+
), editing ? /* @__PURE__ */ React.createElement("div", { className: styles$2.threadCommentEditorButtons }, /* @__PURE__ */ React.createElement(
|
|
356
|
+
Button,
|
|
367
357
|
{
|
|
368
358
|
style: { marginRight: 12 },
|
|
369
|
-
onClick: () => {
|
|
370
|
-
|
|
371
|
-
}
|
|
359
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
360
|
+
onCancel == null || onCancel(), setEditing(!1), setLocalComment({ text: void 0 }), commandService.executeCommand(SetActiveCommentOperation.id);
|
|
361
|
+
}, "onClick")
|
|
372
362
|
},
|
|
373
|
-
|
|
374
|
-
), /* @__PURE__ */
|
|
375
|
-
|
|
363
|
+
localeService.t("threadCommentUI.editor.cancel")
|
|
364
|
+
), /* @__PURE__ */ React.createElement(
|
|
365
|
+
Button,
|
|
376
366
|
{
|
|
377
367
|
type: "primary",
|
|
378
|
-
disabled: !
|
|
379
|
-
onClick: () => {
|
|
380
|
-
|
|
381
|
-
...
|
|
382
|
-
text:
|
|
383
|
-
}),
|
|
384
|
-
}
|
|
368
|
+
disabled: !localComment.text,
|
|
369
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
370
|
+
localComment.text && (onSave == null || onSave({
|
|
371
|
+
...localComment,
|
|
372
|
+
text: localComment.text
|
|
373
|
+
}), setEditing(!1), setLocalComment({ text: void 0 }));
|
|
374
|
+
}, "onClick")
|
|
385
375
|
},
|
|
386
|
-
|
|
376
|
+
localeService.t(id ? "threadCommentUI.editor.save" : "threadCommentUI.editor.reply")
|
|
387
377
|
)) : null);
|
|
388
|
-
}),
|
|
389
|
-
threadComment:
|
|
390
|
-
threadCommentActive
|
|
391
|
-
threadCommentContent
|
|
392
|
-
threadCommentHighlight
|
|
393
|
-
threadCommentIconContainer
|
|
394
|
-
threadCommentIcon
|
|
395
|
-
threadCommentTitle
|
|
396
|
-
threadCommentTitlePosition
|
|
397
|
-
threadCommentTitleHighlight
|
|
398
|
-
threadCommentTitlePositionText
|
|
399
|
-
threadCommentUsername
|
|
400
|
-
threadCommentItem
|
|
401
|
-
threadCommentItemHead
|
|
402
|
-
threadCommentItemTitle
|
|
403
|
-
threadCommentItemTitlePosition
|
|
404
|
-
threadCommentItemTitleHighlight
|
|
405
|
-
threadCommentItemTime
|
|
406
|
-
threadCommentItemContent
|
|
407
|
-
threadCommentItemAt
|
|
408
|
-
},
|
|
409
|
-
const { item
|
|
410
|
-
(
|
|
411
|
-
|
|
378
|
+
}), threadComment$1 = "univer-thread-comment", threadCommentActive = "univer-thread-comment-active", threadCommentContent = "univer-thread-comment-content", threadCommentHighlight = "univer-thread-comment-highlight", threadCommentIconContainer = "univer-thread-comment-icon-container", threadCommentIcon = "univer-thread-comment-icon", threadCommentTitle = "univer-thread-comment-title", threadCommentTitlePosition = "univer-thread-comment-title-position", threadCommentTitleHighlight = "univer-thread-comment-title-highlight", threadCommentTitlePositionText = "univer-thread-comment-title-position-text", threadCommentUsername = "univer-thread-comment-username", threadCommentItem = "univer-thread-comment-item", threadCommentItemHead = "univer-thread-comment-item-head", threadCommentItemTitle = "univer-thread-comment-item-title", threadCommentItemTitlePosition = "univer-thread-comment-item-title-position", threadCommentItemTitleHighlight = "univer-thread-comment-item-title-highlight", threadCommentItemTime = "univer-thread-comment-item-time", threadCommentItemContent = "univer-thread-comment-item-content", threadCommentItemAt = "univer-thread-comment-item-at", styles$1 = {
|
|
379
|
+
threadComment: threadComment$1,
|
|
380
|
+
threadCommentActive,
|
|
381
|
+
threadCommentContent,
|
|
382
|
+
threadCommentHighlight,
|
|
383
|
+
threadCommentIconContainer,
|
|
384
|
+
threadCommentIcon,
|
|
385
|
+
threadCommentTitle,
|
|
386
|
+
threadCommentTitlePosition,
|
|
387
|
+
threadCommentTitleHighlight,
|
|
388
|
+
threadCommentTitlePositionText,
|
|
389
|
+
threadCommentUsername,
|
|
390
|
+
threadCommentItem,
|
|
391
|
+
threadCommentItemHead,
|
|
392
|
+
threadCommentItemTitle,
|
|
393
|
+
threadCommentItemTitlePosition,
|
|
394
|
+
threadCommentItemTitleHighlight,
|
|
395
|
+
threadCommentItemTime,
|
|
396
|
+
threadCommentItemContent,
|
|
397
|
+
threadCommentItemAt
|
|
398
|
+
}, MOCK_ID = "__mock__", ThreadCommentItem = /* @__PURE__ */ __name((props) => {
|
|
399
|
+
const { item, unitId, subUnitId, editing, onEditingChange, onReply, resolved, isRoot, onClose, onDeleteComment } = props, commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), userManagerService = useDependency(UserManagerService), user = userManagerService.getUser(item.personId), currentUser = useObservable(userManagerService.currentUser$), isCommentBySelf = (currentUser == null ? void 0 : currentUser.userID) === item.personId, isMock = item.id === MOCK_ID, [showReply, setShowReply] = useState(!1), handleDeleteItem = /* @__PURE__ */ __name(() => {
|
|
400
|
+
(onDeleteComment == null ? void 0 : onDeleteComment(item)) !== !1 && (commandService.executeCommand(
|
|
401
|
+
isRoot ? DeleteCommentTreeCommand.id : DeleteCommentCommand.id,
|
|
412
402
|
{
|
|
413
|
-
unitId
|
|
414
|
-
subUnitId
|
|
415
|
-
commentId:
|
|
403
|
+
unitId,
|
|
404
|
+
subUnitId,
|
|
405
|
+
commentId: item.id
|
|
416
406
|
}
|
|
417
|
-
),
|
|
418
|
-
};
|
|
419
|
-
return /* @__PURE__ */
|
|
420
|
-
|
|
407
|
+
), isRoot && (onClose == null || onClose()));
|
|
408
|
+
}, "handleDeleteItem");
|
|
409
|
+
return /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItem, onMouseLeave: /* @__PURE__ */ __name(() => setShowReply(!1), "onMouseLeave"), onMouseEnter: /* @__PURE__ */ __name(() => setShowReply(!0), "onMouseEnter") }, /* @__PURE__ */ React.createElement("img", { className: styles$1.threadCommentItemHead, src: user == null ? void 0 : user.avatar }), /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemTitle }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentUsername }, (user == null ? void 0 : user.name) || " "), /* @__PURE__ */ React.createElement("div", null, isMock || resolved ? null : showReply ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon, onClick: /* @__PURE__ */ __name(() => onReply(user), "onClick") }, /* @__PURE__ */ React.createElement(ReplyToCommentSingle, null)) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ React.createElement(
|
|
410
|
+
Dropdown,
|
|
421
411
|
{
|
|
422
|
-
overlay: /* @__PURE__ */
|
|
412
|
+
overlay: /* @__PURE__ */ React.createElement(Menu, null, /* @__PURE__ */ React.createElement(MenuItem, { key: "edit", onClick: /* @__PURE__ */ __name(() => onEditingChange == null ? void 0 : onEditingChange(!0), "onClick") }, localeService.t("threadCommentUI.item.edit")), /* @__PURE__ */ React.createElement(MenuItem, { key: "delete", onClick: handleDeleteItem }, localeService.t("threadCommentUI.item.delete")))
|
|
423
413
|
},
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
) : null)), /* @__PURE__ */
|
|
426
|
-
|
|
414
|
+
/* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon }, /* @__PURE__ */ React.createElement(MoreHorizontalSingle, null))
|
|
415
|
+
) : null)), /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemTime }, item.dT), editing ? /* @__PURE__ */ React.createElement(
|
|
416
|
+
ThreadCommentEditor,
|
|
427
417
|
{
|
|
428
|
-
id:
|
|
429
|
-
comment:
|
|
430
|
-
onCancel: () =>
|
|
418
|
+
id: item.id,
|
|
419
|
+
comment: item,
|
|
420
|
+
onCancel: /* @__PURE__ */ __name(() => onEditingChange == null ? void 0 : onEditingChange(!1), "onCancel"),
|
|
431
421
|
autoFocus: !0,
|
|
432
|
-
unitId
|
|
433
|
-
subUnitId
|
|
434
|
-
onSave: ({ text
|
|
435
|
-
|
|
436
|
-
|
|
422
|
+
unitId,
|
|
423
|
+
subUnitId,
|
|
424
|
+
onSave: /* @__PURE__ */ __name(({ text, attachments }) => {
|
|
425
|
+
onEditingChange == null || onEditingChange(!1), commandService.executeCommand(
|
|
426
|
+
UpdateCommentCommand.id,
|
|
437
427
|
{
|
|
438
|
-
unitId
|
|
439
|
-
subUnitId
|
|
428
|
+
unitId,
|
|
429
|
+
subUnitId,
|
|
440
430
|
payload: {
|
|
441
|
-
commentId:
|
|
442
|
-
text
|
|
443
|
-
attachments
|
|
431
|
+
commentId: item.id,
|
|
432
|
+
text,
|
|
433
|
+
attachments
|
|
444
434
|
}
|
|
445
435
|
}
|
|
446
436
|
);
|
|
447
|
-
}
|
|
437
|
+
}, "onSave")
|
|
448
438
|
}
|
|
449
|
-
) : /* @__PURE__ */
|
|
450
|
-
switch (
|
|
439
|
+
) : /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentItemContent }, transformDocument2TextNodes(item.text).map((item2, i) => {
|
|
440
|
+
switch (item2.type) {
|
|
451
441
|
case "mention":
|
|
452
|
-
return /* @__PURE__ */
|
|
442
|
+
return /* @__PURE__ */ React.createElement("a", { className: styles$1.threadCommentItemAt, key: i }, "@", item2.content.label, " ");
|
|
453
443
|
default:
|
|
454
|
-
return
|
|
444
|
+
return item2.content;
|
|
455
445
|
}
|
|
456
446
|
})));
|
|
457
|
-
},
|
|
458
|
-
var
|
|
447
|
+
}, "ThreadCommentItem"), ThreadCommentTree = /* @__PURE__ */ __name((props) => {
|
|
448
|
+
var _a3, _b, _c;
|
|
459
449
|
const {
|
|
460
|
-
id
|
|
461
|
-
unitId
|
|
462
|
-
subUnitId
|
|
463
|
-
refStr
|
|
464
|
-
showEdit
|
|
465
|
-
onClick
|
|
466
|
-
showHighlight
|
|
467
|
-
onClose
|
|
468
|
-
getSubUnitName
|
|
469
|
-
prefix
|
|
470
|
-
autoFocus
|
|
471
|
-
onMouseEnter
|
|
472
|
-
onMouseLeave
|
|
473
|
-
onAddComment
|
|
474
|
-
onDeleteComment
|
|
475
|
-
onResolve
|
|
476
|
-
} =
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
...
|
|
450
|
+
id,
|
|
451
|
+
unitId,
|
|
452
|
+
subUnitId,
|
|
453
|
+
refStr,
|
|
454
|
+
showEdit = !0,
|
|
455
|
+
onClick,
|
|
456
|
+
showHighlight,
|
|
457
|
+
onClose,
|
|
458
|
+
getSubUnitName,
|
|
459
|
+
prefix,
|
|
460
|
+
autoFocus,
|
|
461
|
+
onMouseEnter,
|
|
462
|
+
onMouseLeave,
|
|
463
|
+
onAddComment,
|
|
464
|
+
onDeleteComment,
|
|
465
|
+
onResolve
|
|
466
|
+
} = props, threadCommentModel = useDependency(ThreadCommentModel), [isHover, setIsHover] = useState(!1), [editingId, setEditingId] = useState("");
|
|
467
|
+
useObservable(threadCommentModel.commentMap$);
|
|
468
|
+
const comments = id ? threadCommentModel.getCommentWithChildren(unitId, subUnitId, id) : null, commandService = useDependency(ICommandService), userManagerService = useDependency(UserManagerService), resolved = comments == null ? void 0 : comments.root.resolved, currentUser = useObservable(userManagerService.currentUser$), editorRef = useRef(null), renderComments = [
|
|
469
|
+
...comments ? [comments.root] : (
|
|
480
470
|
// mock empty comment
|
|
481
471
|
[{
|
|
482
|
-
id:
|
|
472
|
+
id: MOCK_ID,
|
|
483
473
|
text: {
|
|
484
474
|
dataStream: `
|
|
485
475
|
\r`
|
|
486
476
|
},
|
|
487
|
-
personId: (
|
|
488
|
-
ref:
|
|
477
|
+
personId: (_a3 = currentUser == null ? void 0 : currentUser.userID) != null ? _a3 : "",
|
|
478
|
+
ref: refStr != null ? refStr : "",
|
|
489
479
|
dT: "",
|
|
490
|
-
unitId
|
|
491
|
-
subUnitId
|
|
480
|
+
unitId,
|
|
481
|
+
subUnitId,
|
|
492
482
|
threadId: ""
|
|
493
483
|
}]
|
|
494
484
|
),
|
|
495
|
-
...(
|
|
496
|
-
],
|
|
497
|
-
|
|
498
|
-
unitId
|
|
499
|
-
subUnitId
|
|
500
|
-
commentId:
|
|
501
|
-
}) :
|
|
502
|
-
unitId
|
|
503
|
-
subUnitId
|
|
504
|
-
commentId:
|
|
505
|
-
resolved: !
|
|
506
|
-
}),
|
|
507
|
-
},
|
|
508
|
-
|
|
509
|
-
|
|
485
|
+
...(_b = comments == null ? void 0 : comments.children) != null ? _b : []
|
|
486
|
+
], handleResolve = /* @__PURE__ */ __name((e) => {
|
|
487
|
+
e.stopPropagation(), resolved ? commandService.executeCommand(SetActiveCommentOperation.id, {
|
|
488
|
+
unitId,
|
|
489
|
+
subUnitId,
|
|
490
|
+
commentId: id
|
|
491
|
+
}) : commandService.executeCommand(SetActiveCommentOperation.id), commandService.executeCommand(ResolveCommentCommand.id, {
|
|
492
|
+
unitId,
|
|
493
|
+
subUnitId,
|
|
494
|
+
commentId: id,
|
|
495
|
+
resolved: !resolved
|
|
496
|
+
}), onResolve == null || onResolve(!resolved);
|
|
497
|
+
}, "handleResolve"), handleDeleteRoot = /* @__PURE__ */ __name((e) => {
|
|
498
|
+
e.stopPropagation(), commandService.executeCommand(SetActiveCommentOperation.id), !(comments != null && comments.root && (onDeleteComment == null ? void 0 : onDeleteComment(comments.root)) === !1) && (commandService.executeCommand(
|
|
499
|
+
DeleteCommentTreeCommand.id,
|
|
510
500
|
{
|
|
511
|
-
unitId
|
|
512
|
-
subUnitId
|
|
513
|
-
commentId:
|
|
501
|
+
unitId,
|
|
502
|
+
subUnitId,
|
|
503
|
+
commentId: id
|
|
514
504
|
}
|
|
515
|
-
),
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
return /* @__PURE__ */
|
|
505
|
+
), onClose == null || onClose());
|
|
506
|
+
}, "handleDeleteRoot");
|
|
507
|
+
useEffect(() => onMouseLeave == null ? void 0 : onMouseLeave(), []);
|
|
508
|
+
const subUnitName = getSubUnitName((_c = comments == null ? void 0 : comments.root.subUnitId) != null ? _c : subUnitId), editorVisible = showEdit && !editingId && !resolved, title = `${refStr || (comments == null ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
|
|
509
|
+
return /* @__PURE__ */ React.createElement(
|
|
520
510
|
"div",
|
|
521
511
|
{
|
|
522
|
-
className:
|
|
523
|
-
[
|
|
512
|
+
className: cs(styles$1.threadComment, {
|
|
513
|
+
[styles$1.threadCommentActive]: !resolved && (showHighlight || isHover || prefix === "cell")
|
|
524
514
|
}),
|
|
525
|
-
onClick
|
|
526
|
-
id: `${
|
|
527
|
-
onMouseEnter: () => {
|
|
528
|
-
|
|
529
|
-
},
|
|
530
|
-
onMouseLeave: () => {
|
|
531
|
-
|
|
532
|
-
}
|
|
515
|
+
onClick,
|
|
516
|
+
id: `${prefix}-${unitId}-${subUnitId}-${id}`,
|
|
517
|
+
onMouseEnter: /* @__PURE__ */ __name(() => {
|
|
518
|
+
onMouseEnter == null || onMouseEnter(), setIsHover(!0);
|
|
519
|
+
}, "onMouseEnter"),
|
|
520
|
+
onMouseLeave: /* @__PURE__ */ __name(() => {
|
|
521
|
+
onMouseLeave == null || onMouseLeave(), setIsHover(!1);
|
|
522
|
+
}, "onMouseLeave")
|
|
533
523
|
},
|
|
534
|
-
!
|
|
535
|
-
/* @__PURE__ */
|
|
524
|
+
!resolved && showHighlight ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentHighlight }) : null,
|
|
525
|
+
/* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitle }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitlePosition }, /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitleHighlight }), /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentTitlePositionText }, title)), comments ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIconContainer }, /* @__PURE__ */ React.createElement(
|
|
536
526
|
"div",
|
|
537
527
|
{
|
|
538
|
-
onClick:
|
|
539
|
-
className:
|
|
540
|
-
style: { color:
|
|
528
|
+
onClick: handleResolve,
|
|
529
|
+
className: styles$1.threadCommentIcon,
|
|
530
|
+
style: { color: resolved ? "rgb(var(--green-500))" : "" }
|
|
541
531
|
},
|
|
542
|
-
|
|
543
|
-
), (
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
-
(
|
|
546
|
-
|
|
532
|
+
resolved ? /* @__PURE__ */ React.createElement(ResolvedSingle, null) : /* @__PURE__ */ React.createElement(SolveSingle, null)
|
|
533
|
+
), (currentUser == null ? void 0 : currentUser.userID) === comments.root.personId ? /* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentIcon, onClick: handleDeleteRoot }, /* @__PURE__ */ React.createElement(DeleteSingle, null)) : null) : null),
|
|
534
|
+
/* @__PURE__ */ React.createElement("div", { className: styles$1.threadCommentContent }, renderComments.map(
|
|
535
|
+
(item) => /* @__PURE__ */ React.createElement(
|
|
536
|
+
ThreadCommentItem,
|
|
547
537
|
{
|
|
548
|
-
onClose
|
|
549
|
-
unitId
|
|
550
|
-
subUnitId
|
|
551
|
-
item
|
|
552
|
-
key:
|
|
553
|
-
isRoot:
|
|
554
|
-
editing:
|
|
555
|
-
resolved:
|
|
556
|
-
onEditingChange: (
|
|
557
|
-
|
|
558
|
-
},
|
|
559
|
-
onReply: (
|
|
560
|
-
|
|
561
|
-
var
|
|
562
|
-
(
|
|
538
|
+
onClose,
|
|
539
|
+
unitId,
|
|
540
|
+
subUnitId,
|
|
541
|
+
item,
|
|
542
|
+
key: item.id,
|
|
543
|
+
isRoot: item.id === (comments == null ? void 0 : comments.root.id),
|
|
544
|
+
editing: editingId === item.id,
|
|
545
|
+
resolved: comments == null ? void 0 : comments.root.resolved,
|
|
546
|
+
onEditingChange: /* @__PURE__ */ __name((editing) => {
|
|
547
|
+
setEditingId(editing ? item.id : "");
|
|
548
|
+
}, "onEditingChange"),
|
|
549
|
+
onReply: /* @__PURE__ */ __name((user) => {
|
|
550
|
+
user && requestAnimationFrame(() => {
|
|
551
|
+
var _a4;
|
|
552
|
+
(_a4 = editorRef.current) == null || _a4.reply(transformTextNodes2Document([{
|
|
563
553
|
type: "mention",
|
|
564
554
|
content: {
|
|
565
|
-
id:
|
|
566
|
-
label:
|
|
555
|
+
id: user.userID,
|
|
556
|
+
label: user.name
|
|
567
557
|
}
|
|
568
558
|
}]));
|
|
569
559
|
});
|
|
570
|
-
},
|
|
571
|
-
onAddComment
|
|
572
|
-
onDeleteComment
|
|
560
|
+
}, "onReply"),
|
|
561
|
+
onAddComment,
|
|
562
|
+
onDeleteComment
|
|
573
563
|
}
|
|
574
564
|
)
|
|
575
565
|
)),
|
|
576
|
-
|
|
577
|
-
|
|
566
|
+
editorVisible ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
567
|
+
ThreadCommentEditor,
|
|
578
568
|
{
|
|
579
|
-
key: `${
|
|
580
|
-
ref:
|
|
581
|
-
unitId
|
|
582
|
-
subUnitId
|
|
583
|
-
onSave: ({ text
|
|
584
|
-
const
|
|
585
|
-
text
|
|
586
|
-
attachments
|
|
587
|
-
dT:
|
|
588
|
-
id:
|
|
589
|
-
ref:
|
|
590
|
-
personId:
|
|
591
|
-
parentId:
|
|
592
|
-
unitId
|
|
593
|
-
subUnitId
|
|
594
|
-
threadId:
|
|
569
|
+
key: `${autoFocus}`,
|
|
570
|
+
ref: editorRef,
|
|
571
|
+
unitId,
|
|
572
|
+
subUnitId,
|
|
573
|
+
onSave: /* @__PURE__ */ __name(({ text, attachments }) => {
|
|
574
|
+
const comment = {
|
|
575
|
+
text,
|
|
576
|
+
attachments,
|
|
577
|
+
dT: getDT(),
|
|
578
|
+
id: Tools.generateRandomId(),
|
|
579
|
+
ref: refStr,
|
|
580
|
+
personId: currentUser == null ? void 0 : currentUser.userID,
|
|
581
|
+
parentId: comments == null ? void 0 : comments.root.id,
|
|
582
|
+
unitId,
|
|
583
|
+
subUnitId,
|
|
584
|
+
threadId: comments == null ? void 0 : comments.root.threadId
|
|
595
585
|
};
|
|
596
|
-
(
|
|
597
|
-
|
|
586
|
+
(onAddComment == null ? void 0 : onAddComment(comment)) !== !1 && commandService.executeCommand(
|
|
587
|
+
AddCommentCommand.id,
|
|
598
588
|
{
|
|
599
|
-
unitId
|
|
600
|
-
subUnitId
|
|
601
|
-
comment
|
|
589
|
+
unitId,
|
|
590
|
+
subUnitId,
|
|
591
|
+
comment
|
|
602
592
|
}
|
|
603
593
|
);
|
|
604
|
-
},
|
|
605
|
-
autoFocus:
|
|
606
|
-
onCancel: () => {
|
|
607
|
-
|
|
608
|
-
}
|
|
594
|
+
}, "onSave"),
|
|
595
|
+
autoFocus: autoFocus || !comments,
|
|
596
|
+
onCancel: /* @__PURE__ */ __name(() => {
|
|
597
|
+
comments || onClose == null || onClose();
|
|
598
|
+
}, "onCancel")
|
|
609
599
|
}
|
|
610
600
|
)) : null
|
|
611
601
|
);
|
|
612
|
-
},
|
|
613
|
-
threadCommentPanel
|
|
614
|
-
threadComment
|
|
615
|
-
threadCommentPanelForms
|
|
616
|
-
select
|
|
617
|
-
threadCommentPanelEmpty
|
|
618
|
-
threadCommentPanelAdd
|
|
619
|
-
threadCommentPanelSolved
|
|
620
|
-
},
|
|
602
|
+
}, "ThreadCommentTree"), threadCommentPanel = "univer-thread-comment-panel", threadComment = "univer-thread-comment", threadCommentPanelForms = "univer-thread-comment-panel-forms", select = "univer-select", threadCommentPanelEmpty = "univer-thread-comment-panel-empty", threadCommentPanelAdd = "univer-thread-comment-panel-add", threadCommentPanelSolved = "univer-thread-comment-panel-solved", styles = {
|
|
603
|
+
threadCommentPanel,
|
|
604
|
+
threadComment,
|
|
605
|
+
threadCommentPanelForms,
|
|
606
|
+
select,
|
|
607
|
+
threadCommentPanelEmpty,
|
|
608
|
+
threadCommentPanelAdd,
|
|
609
|
+
threadCommentPanelSolved
|
|
610
|
+
}, ThreadCommentPanel = /* @__PURE__ */ __name((props) => {
|
|
621
611
|
const {
|
|
622
|
-
unitId
|
|
623
|
-
subUnitId
|
|
624
|
-
type
|
|
625
|
-
onAdd
|
|
626
|
-
getSubUnitName
|
|
627
|
-
onResolve
|
|
628
|
-
sortComments
|
|
629
|
-
onItemLeave
|
|
630
|
-
onItemEnter
|
|
631
|
-
disableAdd
|
|
632
|
-
tempComment
|
|
633
|
-
onAddComment
|
|
634
|
-
onDeleteComment
|
|
635
|
-
showComments
|
|
636
|
-
} =
|
|
637
|
-
var
|
|
638
|
-
const
|
|
639
|
-
if (
|
|
640
|
-
const
|
|
641
|
-
return
|
|
642
|
-
|
|
643
|
-
}), [...
|
|
612
|
+
unitId,
|
|
613
|
+
subUnitId$,
|
|
614
|
+
type,
|
|
615
|
+
onAdd,
|
|
616
|
+
getSubUnitName,
|
|
617
|
+
onResolve,
|
|
618
|
+
sortComments,
|
|
619
|
+
onItemLeave,
|
|
620
|
+
onItemEnter,
|
|
621
|
+
disableAdd,
|
|
622
|
+
tempComment,
|
|
623
|
+
onAddComment,
|
|
624
|
+
onDeleteComment,
|
|
625
|
+
showComments
|
|
626
|
+
} = props, [unit, setUnit] = useState("all"), [status, setStatus] = useState("all"), localeService = useDependency(LocaleService), userService = useDependency(UserManagerService), threadCommentModel = useDependency(ThreadCommentModel), [unitComments, setUnitComments] = useState(() => threadCommentModel.getUnit(unitId)), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), update = useObservable(threadCommentModel.commentUpdate$), commandService = useDependency(ICommandService), subUnitId = useObservable(subUnitId$), shouldScroll = useRef(!0), prefix = "panel", currentUser = useObservable(userService.currentUser$), comments = useMemo(() => {
|
|
627
|
+
var _a3, _b;
|
|
628
|
+
const allComments = (unit === "all" ? unitComments.map((i) => i[1]).flat() : (_b = (_a3 = unitComments.find((i) => i[0] === subUnitId)) == null ? void 0 : _a3[1]) != null ? _b : []).filter((i) => !i.parentId), sort = sortComments != null ? sortComments : (a) => a, res = allComments;
|
|
629
|
+
if (showComments) {
|
|
630
|
+
const map = /* @__PURE__ */ new Map();
|
|
631
|
+
return res.forEach((comment) => {
|
|
632
|
+
map.set(comment.id, comment);
|
|
633
|
+
}), [...showComments, ""].map((id) => map.get(id)).filter(Boolean);
|
|
644
634
|
} else
|
|
645
|
-
return
|
|
646
|
-
}, [
|
|
647
|
-
...
|
|
648
|
-
...
|
|
649
|
-
], [
|
|
650
|
-
|
|
651
|
-
};
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
635
|
+
return sort(res);
|
|
636
|
+
}, [showComments, unit, unitComments, sortComments, subUnitId]), commentsSorted = useMemo(() => [
|
|
637
|
+
...comments.filter((comment) => !comment.resolved),
|
|
638
|
+
...comments.filter((comment) => comment.resolved)
|
|
639
|
+
], [comments]), statuedComments = useMemo(() => status === "resolved" ? commentsSorted.filter((comment) => comment.resolved) : status === "unsolved" ? commentsSorted.filter((comment) => !comment.resolved) : status === "concern_me" && currentUser != null && currentUser.userID ? commentsSorted.map((comment) => threadCommentModel.getCommentWithChildren(comment.unitId, comment.subUnitId, comment.id)).map((comment) => comment != null && comment.relativeUsers.has(currentUser.userID) ? comment.root : null).filter(Boolean) : commentsSorted, [commentsSorted, currentUser == null ? void 0 : currentUser.userID, status, threadCommentModel]), renderComments = tempComment ? [tempComment, ...statuedComments] : statuedComments, unSolvedComments = renderComments.filter((comment) => !comment.resolved), solvedComments = renderComments.filter((comment) => comment.resolved), isFiltering = status !== "all" || unit !== "all", onReset = /* @__PURE__ */ __name(() => {
|
|
640
|
+
setStatus("all"), setUnit("all");
|
|
641
|
+
}, "onReset");
|
|
642
|
+
useEffect(() => {
|
|
643
|
+
unitId && setUnitComments(
|
|
644
|
+
threadCommentModel.getUnit(unitId)
|
|
655
645
|
);
|
|
656
|
-
}, [
|
|
657
|
-
var
|
|
658
|
-
if (!
|
|
646
|
+
}, [unitId, threadCommentModel, update]), useEffect(() => {
|
|
647
|
+
var _a3;
|
|
648
|
+
if (!activeCommentId)
|
|
659
649
|
return;
|
|
660
|
-
if (!
|
|
661
|
-
|
|
650
|
+
if (!shouldScroll.current) {
|
|
651
|
+
shouldScroll.current = !0;
|
|
662
652
|
return;
|
|
663
653
|
}
|
|
664
|
-
const { unitId:
|
|
665
|
-
(
|
|
666
|
-
}, [
|
|
667
|
-
const
|
|
668
|
-
|
|
654
|
+
const { unitId: unitId2, subUnitId: subUnitId2, commentId } = activeCommentId, id = `${prefix}-${unitId2}-${subUnitId2}-${commentId}`;
|
|
655
|
+
(_a3 = document.getElementById(id)) == null || _a3.scrollIntoView({ block: "center" });
|
|
656
|
+
}, [activeCommentId]);
|
|
657
|
+
const renderComment = /* @__PURE__ */ __name((comment) => /* @__PURE__ */ React.createElement(
|
|
658
|
+
ThreadCommentTree,
|
|
669
659
|
{
|
|
670
|
-
prefix
|
|
671
|
-
getSubUnitName
|
|
672
|
-
key:
|
|
673
|
-
id:
|
|
674
|
-
unitId:
|
|
675
|
-
subUnitId:
|
|
676
|
-
refStr:
|
|
677
|
-
type
|
|
678
|
-
showEdit: (
|
|
679
|
-
showHighlight: (
|
|
680
|
-
onClick: () => {
|
|
681
|
-
|
|
682
|
-
|
|
660
|
+
prefix,
|
|
661
|
+
getSubUnitName,
|
|
662
|
+
key: comment.id,
|
|
663
|
+
id: comment.id,
|
|
664
|
+
unitId: comment.unitId,
|
|
665
|
+
subUnitId: comment.subUnitId,
|
|
666
|
+
refStr: comment.ref,
|
|
667
|
+
type,
|
|
668
|
+
showEdit: (activeCommentId == null ? void 0 : activeCommentId.commentId) === comment.id,
|
|
669
|
+
showHighlight: (activeCommentId == null ? void 0 : activeCommentId.commentId) === comment.id,
|
|
670
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
671
|
+
shouldScroll.current = !1, comment.resolved ? commandService.executeCommand(SetActiveCommentOperation.id) : commandService.executeCommand(
|
|
672
|
+
SetActiveCommentOperation.id,
|
|
683
673
|
{
|
|
684
|
-
unitId:
|
|
685
|
-
subUnitId:
|
|
686
|
-
commentId:
|
|
674
|
+
unitId: comment.unitId,
|
|
675
|
+
subUnitId: comment.subUnitId,
|
|
676
|
+
commentId: comment.id,
|
|
687
677
|
temp: !1
|
|
688
678
|
}
|
|
689
679
|
);
|
|
690
|
-
},
|
|
691
|
-
onMouseEnter: () =>
|
|
692
|
-
onMouseLeave: () =>
|
|
693
|
-
onAddComment
|
|
694
|
-
onDeleteComment
|
|
695
|
-
onResolve: (
|
|
680
|
+
}, "onClick"),
|
|
681
|
+
onMouseEnter: /* @__PURE__ */ __name(() => onItemEnter == null ? void 0 : onItemEnter(comment), "onMouseEnter"),
|
|
682
|
+
onMouseLeave: /* @__PURE__ */ __name(() => onItemLeave == null ? void 0 : onItemLeave(comment), "onMouseLeave"),
|
|
683
|
+
onAddComment,
|
|
684
|
+
onDeleteComment,
|
|
685
|
+
onResolve: /* @__PURE__ */ __name((resolved) => onResolve == null ? void 0 : onResolve(comment.id, resolved), "onResolve")
|
|
696
686
|
}
|
|
697
|
-
);
|
|
698
|
-
return /* @__PURE__ */
|
|
699
|
-
|
|
687
|
+
), "renderComment");
|
|
688
|
+
return /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanel }, /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelForms }, type === UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ React.createElement(
|
|
689
|
+
Select,
|
|
700
690
|
{
|
|
701
691
|
borderless: !0,
|
|
702
|
-
value:
|
|
703
|
-
onChange: (
|
|
692
|
+
value: unit,
|
|
693
|
+
onChange: /* @__PURE__ */ __name((e) => setUnit(e), "onChange"),
|
|
704
694
|
options: [
|
|
705
695
|
{
|
|
706
696
|
value: "current",
|
|
707
|
-
label:
|
|
697
|
+
label: localeService.t("threadCommentUI.filter.sheet.current")
|
|
708
698
|
},
|
|
709
699
|
{
|
|
710
700
|
value: "all",
|
|
711
|
-
label:
|
|
701
|
+
label: localeService.t("threadCommentUI.filter.sheet.all")
|
|
712
702
|
}
|
|
713
703
|
]
|
|
714
704
|
}
|
|
715
|
-
) : null, /* @__PURE__ */
|
|
716
|
-
|
|
705
|
+
) : null, /* @__PURE__ */ React.createElement(
|
|
706
|
+
Select,
|
|
717
707
|
{
|
|
718
708
|
borderless: !0,
|
|
719
|
-
value:
|
|
720
|
-
onChange: (
|
|
709
|
+
value: status,
|
|
710
|
+
onChange: /* @__PURE__ */ __name((e) => setStatus(e), "onChange"),
|
|
721
711
|
options: [
|
|
722
712
|
{
|
|
723
713
|
value: "all",
|
|
724
|
-
label:
|
|
714
|
+
label: localeService.t("threadCommentUI.filter.status.all")
|
|
725
715
|
},
|
|
726
716
|
{
|
|
727
717
|
value: "resolved",
|
|
728
|
-
label:
|
|
718
|
+
label: localeService.t("threadCommentUI.filter.status.resolved")
|
|
729
719
|
},
|
|
730
720
|
{
|
|
731
721
|
value: "unsolved",
|
|
732
|
-
label:
|
|
722
|
+
label: localeService.t("threadCommentUI.filter.status.unsolved")
|
|
733
723
|
},
|
|
734
724
|
{
|
|
735
725
|
value: "concern_me",
|
|
736
|
-
label:
|
|
726
|
+
label: localeService.t("threadCommentUI.filter.status.concernMe")
|
|
737
727
|
}
|
|
738
728
|
]
|
|
739
729
|
}
|
|
740
|
-
)),
|
|
741
|
-
|
|
730
|
+
)), unSolvedComments.map(renderComment), solvedComments.length ? /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelSolved }, "已解决") : null, solvedComments.map(renderComment), renderComments.length ? null : /* @__PURE__ */ React.createElement("div", { className: styles.threadCommentPanelEmpty }, isFiltering ? localeService.t("threadCommentUI.panel.filterEmpty") : localeService.t("threadCommentUI.panel.empty"), isFiltering ? /* @__PURE__ */ React.createElement(
|
|
731
|
+
Button,
|
|
742
732
|
{
|
|
743
|
-
onClick:
|
|
733
|
+
onClick: onReset,
|
|
744
734
|
type: "link"
|
|
745
735
|
},
|
|
746
|
-
|
|
747
|
-
) : /* @__PURE__ */
|
|
748
|
-
|
|
736
|
+
localeService.t("threadCommentUI.panel.reset")
|
|
737
|
+
) : /* @__PURE__ */ React.createElement(
|
|
738
|
+
Button,
|
|
749
739
|
{
|
|
750
740
|
id: "thread-comment-add",
|
|
751
|
-
className:
|
|
741
|
+
className: styles.threadCommentPanelAdd,
|
|
752
742
|
type: "primary",
|
|
753
|
-
onClick:
|
|
754
|
-
disabled:
|
|
743
|
+
onClick: onAdd,
|
|
744
|
+
disabled: disableAdd
|
|
755
745
|
},
|
|
756
|
-
/* @__PURE__ */
|
|
757
|
-
|
|
746
|
+
/* @__PURE__ */ React.createElement(IncreaseSingle, null),
|
|
747
|
+
localeService.t("threadCommentUI.panel.addComment")
|
|
758
748
|
)));
|
|
759
|
-
};
|
|
749
|
+
}, "ThreadCommentPanel");
|
|
760
750
|
export {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
751
|
+
IThreadCommentMentionDataService,
|
|
752
|
+
SetActiveCommentOperation,
|
|
753
|
+
THREAD_COMMENT_PANEL,
|
|
754
|
+
ThreadCommentPanel,
|
|
755
|
+
ThreadCommentPanelService,
|
|
756
|
+
ThreadCommentTree,
|
|
757
|
+
ToggleSheetCommentPanelOperation,
|
|
758
|
+
UniverThreadCommentUIPlugin,
|
|
759
|
+
getDT
|
|
770
760
|
};
|