@univerjs/thread-comment-ui 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.0
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/LICENSE +176 -0
- package/README.md +0 -1
- package/lib/cjs/index.js +582 -132
- package/lib/cjs/locale/ar-SA.js +2 -3
- package/lib/cjs/locale/ca-ES.js +2 -3
- package/lib/cjs/locale/de-DE.js +2 -3
- package/lib/cjs/locale/en-US.js +2 -3
- package/lib/cjs/locale/es-ES.js +2 -3
- package/lib/cjs/locale/fa-IR.js +2 -3
- package/lib/cjs/locale/fr-FR.js +2 -3
- package/lib/cjs/locale/id-ID.js +2 -3
- package/lib/cjs/locale/it-IT.js +2 -3
- package/lib/cjs/locale/ja-JP.js +2 -3
- package/lib/cjs/locale/ko-KR.js +2 -3
- package/lib/cjs/locale/pl-PL.js +2 -3
- package/lib/cjs/locale/pt-BR.js +2 -3
- package/lib/cjs/locale/ru-RU.js +2 -3
- package/lib/cjs/locale/sk-SK.js +2 -3
- package/lib/cjs/locale/vi-VN.js +2 -3
- package/lib/cjs/locale/zh-CN.js +2 -3
- package/lib/cjs/locale/zh-HK.js +2 -3
- package/lib/cjs/locale/zh-TW.js +2 -3
- package/lib/es/index.js +573 -138
- package/lib/es/locale/ar-SA.js +2 -3
- package/lib/es/locale/ca-ES.js +2 -3
- package/lib/es/locale/de-DE.js +2 -3
- package/lib/es/locale/en-US.js +2 -3
- package/lib/es/locale/es-ES.js +2 -3
- package/lib/es/locale/fa-IR.js +2 -3
- package/lib/es/locale/fr-FR.js +2 -3
- package/lib/es/locale/id-ID.js +2 -3
- package/lib/es/locale/it-IT.js +2 -3
- package/lib/es/locale/ja-JP.js +2 -3
- package/lib/es/locale/ko-KR.js +2 -3
- package/lib/es/locale/pl-PL.js +2 -3
- package/lib/es/locale/pt-BR.js +2 -3
- package/lib/es/locale/ru-RU.js +2 -3
- package/lib/es/locale/sk-SK.js +2 -3
- package/lib/es/locale/vi-VN.js +2 -3
- package/lib/es/locale/zh-CN.js +2 -3
- package/lib/es/locale/zh-HK.js +2 -3
- package/lib/es/locale/zh-TW.js +2 -3
- package/lib/index.css +54 -18
- package/lib/index.js +573 -138
- package/lib/locale/ar-SA.js +2 -3
- package/lib/locale/ca-ES.js +2 -3
- package/lib/locale/de-DE.js +2 -3
- package/lib/locale/en-US.js +2 -3
- package/lib/locale/es-ES.js +2 -3
- package/lib/locale/fa-IR.js +2 -3
- package/lib/locale/fr-FR.js +2 -3
- package/lib/locale/id-ID.js +2 -3
- package/lib/locale/it-IT.js +2 -3
- package/lib/locale/ja-JP.js +2 -3
- package/lib/locale/ko-KR.js +2 -3
- package/lib/locale/pl-PL.js +2 -3
- package/lib/locale/pt-BR.js +2 -3
- package/lib/locale/ru-RU.js +2 -3
- package/lib/locale/sk-SK.js +2 -3
- package/lib/locale/vi-VN.js +2 -3
- package/lib/locale/zh-CN.js +2 -3
- package/lib/locale/zh-HK.js +2 -3
- package/lib/locale/zh-TW.js +2 -3
- package/lib/types/index.d.ts +7 -0
- package/lib/types/locale/en-US.d.ts +1 -2
- package/lib/types/mobile-plugin.d.ts +29 -0
- package/lib/types/render-objects/thread-comment-canvas-overlay.d.ts +66 -0
- package/lib/types/services/thread-comment-draft.service.d.ts +39 -0
- package/lib/types/services/thread-comment-panel.service.d.ts +7 -3
- package/lib/types/views/ThreadCommentEditor.d.ts +3 -1
- package/lib/types/views/ThreadCommentPanel.d.ts +9 -0
- package/lib/types/views/ThreadCommentTree.d.ts +10 -2
- package/lib/types/views/mobile/MobileThreadCommentEditor.d.ts +17 -0
- package/lib/types/views/mobile/MobileThreadCommentPanel.d.ts +17 -0
- package/lib/types/views/mobile/MobileThreadCommentTree.d.ts +17 -0
- package/lib/types/views/thread-comment-panel/util.d.ts +8 -0
- package/lib/umd/index.js +4 -4
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.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/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.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-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ let _univerjs_ui = require("@univerjs/ui");
|
|
|
4
4
|
let rxjs = require("rxjs");
|
|
5
5
|
let _univerjs_docs_ui = require("@univerjs/docs-ui");
|
|
6
6
|
let _univerjs_thread_comment = require("@univerjs/thread-comment");
|
|
7
|
+
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
7
8
|
let _univerjs_design = require("@univerjs/design");
|
|
8
9
|
let _univerjs_icons = require("@univerjs/icons");
|
|
9
10
|
let react = require("react");
|
|
@@ -70,19 +71,22 @@ function __decorate(decorators, target, key, desc) {
|
|
|
70
71
|
//#endregion
|
|
71
72
|
//#region src/services/thread-comment-panel.service.ts
|
|
72
73
|
let ThreadCommentPanelService = class ThreadCommentPanelService extends _univerjs_core.Disposable {
|
|
73
|
-
constructor(_sidebarService
|
|
74
|
+
constructor(_sidebarService) {
|
|
74
75
|
super();
|
|
75
76
|
this._sidebarService = _sidebarService;
|
|
76
|
-
this._univerInstanceService = _univerInstanceService;
|
|
77
77
|
_defineProperty(this, "_panelVisible", false);
|
|
78
78
|
_defineProperty(this, "_panelVisible$", new rxjs.BehaviorSubject(false));
|
|
79
79
|
_defineProperty(this, "_activeCommentId", void 0);
|
|
80
80
|
_defineProperty(this, "_activeCommentId$", new rxjs.BehaviorSubject(void 0));
|
|
81
|
+
_defineProperty(this, "_hoveredCommentId", void 0);
|
|
82
|
+
_defineProperty(this, "_hoveredCommentId$", new rxjs.BehaviorSubject(void 0));
|
|
81
83
|
_defineProperty(this, "panelVisible$", this._panelVisible$.asObservable());
|
|
82
84
|
_defineProperty(this, "activeCommentId$", this._activeCommentId$.asObservable());
|
|
85
|
+
_defineProperty(this, "hoveredCommentId$", this._hoveredCommentId$.asObservable());
|
|
83
86
|
this._init();
|
|
84
87
|
this.disposeWithMe(() => {
|
|
85
88
|
this._activeCommentId$.complete();
|
|
89
|
+
this._hoveredCommentId$.complete();
|
|
86
90
|
this._panelVisible$.complete();
|
|
87
91
|
});
|
|
88
92
|
}
|
|
@@ -90,9 +94,6 @@ let ThreadCommentPanelService = class ThreadCommentPanelService extends _univerj
|
|
|
90
94
|
this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((opt) => {
|
|
91
95
|
if (!opt.visible) this.setPanelVisible(false);
|
|
92
96
|
}));
|
|
93
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.filter)((sheet) => !sheet)).subscribe(() => {
|
|
94
|
-
this._sidebarService.close();
|
|
95
|
-
}));
|
|
96
97
|
}
|
|
97
98
|
get panelVisible() {
|
|
98
99
|
return this._panelVisible;
|
|
@@ -100,16 +101,24 @@ let ThreadCommentPanelService = class ThreadCommentPanelService extends _univerj
|
|
|
100
101
|
get activeCommentId() {
|
|
101
102
|
return this._activeCommentId;
|
|
102
103
|
}
|
|
104
|
+
get hoveredCommentId() {
|
|
105
|
+
return this._hoveredCommentId;
|
|
106
|
+
}
|
|
103
107
|
setPanelVisible(visible) {
|
|
104
108
|
this._panelVisible = visible;
|
|
105
109
|
this._panelVisible$.next(visible);
|
|
110
|
+
if (!visible) this.setHoveredComment(void 0);
|
|
106
111
|
}
|
|
107
112
|
setActiveComment(commentInfo) {
|
|
108
113
|
this._activeCommentId = commentInfo;
|
|
109
114
|
this._activeCommentId$.next(commentInfo);
|
|
110
115
|
}
|
|
116
|
+
setHoveredComment(commentInfo) {
|
|
117
|
+
this._hoveredCommentId = commentInfo;
|
|
118
|
+
this._hoveredCommentId$.next(commentInfo);
|
|
119
|
+
}
|
|
111
120
|
};
|
|
112
|
-
ThreadCommentPanelService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))
|
|
121
|
+
ThreadCommentPanelService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))], ThreadCommentPanelService);
|
|
113
122
|
|
|
114
123
|
//#endregion
|
|
115
124
|
//#region src/commands/operations/comment.operations.ts
|
|
@@ -125,7 +134,7 @@ const SetActiveCommentOperation = {
|
|
|
125
134
|
//#endregion
|
|
126
135
|
//#region package.json
|
|
127
136
|
var name = "@univerjs/thread-comment-ui";
|
|
128
|
-
var version = "1.0.0-
|
|
137
|
+
var version = "1.0.0-rc.0";
|
|
129
138
|
|
|
130
139
|
//#endregion
|
|
131
140
|
//#region src/config/config.ts
|
|
@@ -133,6 +142,72 @@ const THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "thread-comment-ui.config";
|
|
|
133
142
|
const configSymbol = Symbol(THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY);
|
|
134
143
|
const defaultPluginConfig = {};
|
|
135
144
|
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/services/thread-comment-draft.service.ts
|
|
147
|
+
let ThreadCommentDraftService = class ThreadCommentDraftService extends _univerjs_core.Disposable {
|
|
148
|
+
constructor(instanceService, _userManagerService) {
|
|
149
|
+
super();
|
|
150
|
+
this._userManagerService = _userManagerService;
|
|
151
|
+
_defineProperty(this, "_placementType$", new rxjs.BehaviorSubject(null));
|
|
152
|
+
_defineProperty(this, "_draft$", new rxjs.BehaviorSubject(null));
|
|
153
|
+
_defineProperty(this, "_placementUnitId", void 0);
|
|
154
|
+
_defineProperty(this, "_ownerUserId", void 0);
|
|
155
|
+
_defineProperty(this, "placementType$", this._placementType$.asObservable());
|
|
156
|
+
_defineProperty(this, "draft$", this._draft$.asObservable());
|
|
157
|
+
this.disposeWithMe(instanceService.unitDisposed$.subscribe((unit) => {
|
|
158
|
+
var _this$draft;
|
|
159
|
+
if (((_this$draft = this.draft) === null || _this$draft === void 0 ? void 0 : _this$draft.unitId) === unit.getUnitId() || this._placementUnitId === unit.getUnitId()) this.cancel();
|
|
160
|
+
}));
|
|
161
|
+
this.disposeWithMe(instanceService.focused$.subscribe((unitId) => {
|
|
162
|
+
if (unitId && this._placementUnitId && unitId !== this._placementUnitId) this.cancel();
|
|
163
|
+
}));
|
|
164
|
+
this.disposeWithMe(this._userManagerService.currentUser$.subscribe((user) => {
|
|
165
|
+
if (this._ownerUserId && (user === null || user === void 0 ? void 0 : user.userID) !== this._ownerUserId) this.cancel();
|
|
166
|
+
}));
|
|
167
|
+
if (typeof window !== "undefined") {
|
|
168
|
+
const cancelPlacement = (event) => {
|
|
169
|
+
if (event.key === "Escape" && (this.placementType || this.draft)) this.cancel();
|
|
170
|
+
};
|
|
171
|
+
window.addEventListener("keydown", cancelPlacement);
|
|
172
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(() => window.removeEventListener("keydown", cancelPlacement)));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
get placementType() {
|
|
176
|
+
return this._placementType$.value;
|
|
177
|
+
}
|
|
178
|
+
get draft() {
|
|
179
|
+
return this._draft$.value;
|
|
180
|
+
}
|
|
181
|
+
startPlacement(type, unitId) {
|
|
182
|
+
if (this.placementType === type && this._placementUnitId === unitId) {
|
|
183
|
+
this.cancel();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this._ownerUserId = this._userManagerService.getCurrentUser().userID;
|
|
187
|
+
this._placementUnitId = unitId;
|
|
188
|
+
this._draft$.next(null);
|
|
189
|
+
this._placementType$.next(type);
|
|
190
|
+
}
|
|
191
|
+
place(draft) {
|
|
192
|
+
this._ownerUserId = this._userManagerService.getCurrentUser().userID;
|
|
193
|
+
this._placementUnitId = void 0;
|
|
194
|
+
this._placementType$.next(null);
|
|
195
|
+
this._draft$.next(draft);
|
|
196
|
+
}
|
|
197
|
+
cancel() {
|
|
198
|
+
this._ownerUserId = void 0;
|
|
199
|
+
this._placementUnitId = void 0;
|
|
200
|
+
this._placementType$.next(null);
|
|
201
|
+
this._draft$.next(null);
|
|
202
|
+
}
|
|
203
|
+
dispose() {
|
|
204
|
+
this._placementType$.complete();
|
|
205
|
+
this._draft$.complete();
|
|
206
|
+
super.dispose();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
ThreadCommentDraftService = __decorate([__decorateParam(0, _univerjs_core.IUniverInstanceService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.UserManagerService))], ThreadCommentDraftService);
|
|
210
|
+
|
|
136
211
|
//#endregion
|
|
137
212
|
//#region src/types/const.ts
|
|
138
213
|
/**
|
|
@@ -152,6 +227,38 @@ const defaultPluginConfig = {};
|
|
|
152
227
|
*/
|
|
153
228
|
const PLUGIN_NAME = "UNIVER_THREAD_COMMENT_UI_PLUGIN";
|
|
154
229
|
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/mobile-plugin.ts
|
|
232
|
+
let UniverThreadCommentMobileUIPlugin = class UniverThreadCommentMobileUIPlugin extends _univerjs_core.Plugin {
|
|
233
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
234
|
+
super();
|
|
235
|
+
this._config = _config;
|
|
236
|
+
this._injector = _injector;
|
|
237
|
+
this._commandService = _commandService;
|
|
238
|
+
this._configService = _configService;
|
|
239
|
+
const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
240
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
241
|
+
this._configService.setConfig(THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
242
|
+
}
|
|
243
|
+
onStarting() {
|
|
244
|
+
var _this$_config;
|
|
245
|
+
(0, _univerjs_core.mergeOverrideWithDependencies)([[ThreadCommentDraftService], [ThreadCommentPanelService]], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.overrides).forEach((dependency) => {
|
|
246
|
+
this._injector.add(dependency);
|
|
247
|
+
});
|
|
248
|
+
this._commandService.registerCommand(SetActiveCommentOperation);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
_defineProperty(UniverThreadCommentMobileUIPlugin, "pluginName", PLUGIN_NAME);
|
|
252
|
+
_defineProperty(UniverThreadCommentMobileUIPlugin, "packageName", name);
|
|
253
|
+
_defineProperty(UniverThreadCommentMobileUIPlugin, "version", version);
|
|
254
|
+
_defineProperty(UniverThreadCommentMobileUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_UNKNOWN);
|
|
255
|
+
UniverThreadCommentMobileUIPlugin = __decorate([
|
|
256
|
+
(0, _univerjs_core.DependentOn)(_univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_docs_ui.UniverDocsUIPlugin, _univerjs_ui.UniverMobileUIPlugin),
|
|
257
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
258
|
+
__decorateParam(2, _univerjs_core.ICommandService),
|
|
259
|
+
__decorateParam(3, _univerjs_core.IConfigService)
|
|
260
|
+
], UniverThreadCommentMobileUIPlugin);
|
|
261
|
+
|
|
155
262
|
//#endregion
|
|
156
263
|
//#region src/plugin.ts
|
|
157
264
|
let UniverThreadCommentUIPlugin = class UniverThreadCommentUIPlugin extends _univerjs_core.Plugin {
|
|
@@ -167,7 +274,7 @@ let UniverThreadCommentUIPlugin = class UniverThreadCommentUIPlugin extends _uni
|
|
|
167
274
|
}
|
|
168
275
|
onStarting() {
|
|
169
276
|
var _this$_config;
|
|
170
|
-
(0, _univerjs_core.mergeOverrideWithDependencies)([[ThreadCommentPanelService]], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.overrides).forEach((dep) => {
|
|
277
|
+
(0, _univerjs_core.mergeOverrideWithDependencies)([[ThreadCommentDraftService], [ThreadCommentPanelService]], (_this$_config = this._config) === null || _this$_config === void 0 ? void 0 : _this$_config.overrides).forEach((dep) => {
|
|
171
278
|
this._injector.add(dep);
|
|
172
279
|
});
|
|
173
280
|
[SetActiveCommentOperation].forEach((command) => {
|
|
@@ -186,8 +293,175 @@ UniverThreadCommentUIPlugin = __decorate([
|
|
|
186
293
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
187
294
|
], UniverThreadCommentUIPlugin);
|
|
188
295
|
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/render-objects/thread-comment-canvas-overlay.ts
|
|
298
|
+
const MARKER_SIZE = 24;
|
|
299
|
+
const MARKER_IDLE_OPACITY = .58;
|
|
300
|
+
const MARKER_PREVIEW_OPACITY = .42;
|
|
301
|
+
const UNDERLINE_WIDTH = 2;
|
|
302
|
+
const UNDERLINE_HIT_PADDING = 4;
|
|
303
|
+
const OUTLINE_PADDING = 2;
|
|
304
|
+
var ThreadCommentCanvasOverlay = class extends _univerjs_engine_render.BaseObject {
|
|
305
|
+
constructor(key, state) {
|
|
306
|
+
super(key);
|
|
307
|
+
_defineProperty(this, "_state", void 0);
|
|
308
|
+
_defineProperty(this, "_hoveredCommentId", null);
|
|
309
|
+
_defineProperty(this, "_hitCommentId", null);
|
|
310
|
+
this.evented = true;
|
|
311
|
+
this._state = state;
|
|
312
|
+
this.show();
|
|
313
|
+
}
|
|
314
|
+
get hitCommentId() {
|
|
315
|
+
return this._hitCommentId;
|
|
316
|
+
}
|
|
317
|
+
updateState(state) {
|
|
318
|
+
this._state = {
|
|
319
|
+
...this._state,
|
|
320
|
+
...state
|
|
321
|
+
};
|
|
322
|
+
if (this._hitCommentId && !this._containsComment(this._hitCommentId)) this._hitCommentId = null;
|
|
323
|
+
if (this._hoveredCommentId && !this._containsComment(this._hoveredCommentId)) this._hoveredCommentId = null;
|
|
324
|
+
if ("previewMarker" in state || "previewUnderline" in state) this.makeDirtyNoDebounce(true);
|
|
325
|
+
else this.makeDirty(true);
|
|
326
|
+
}
|
|
327
|
+
clearHover() {
|
|
328
|
+
if (this._hoveredCommentId) {
|
|
329
|
+
this._hoveredCommentId = null;
|
|
330
|
+
this.makeDirty(true);
|
|
331
|
+
}
|
|
332
|
+
this._hitCommentId = null;
|
|
333
|
+
}
|
|
334
|
+
isHit(coord) {
|
|
335
|
+
const zoomRatio = this._getZoomRatio();
|
|
336
|
+
const halfSize = MARKER_SIZE / zoomRatio / 2;
|
|
337
|
+
let marker;
|
|
338
|
+
for (let index = this._state.markers.length - 1; index >= 0; index -= 1) {
|
|
339
|
+
const item = this._state.markers[index];
|
|
340
|
+
if (!item) continue;
|
|
341
|
+
if (coord.x >= item.x - halfSize && coord.x <= item.x + halfSize && coord.y >= item.y - halfSize && coord.y <= item.y + halfSize) {
|
|
342
|
+
marker = item;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
let underline;
|
|
347
|
+
if (!marker) for (let index = this._state.underlines.length - 1; index >= 0; index -= 1) {
|
|
348
|
+
const item = this._state.underlines[index];
|
|
349
|
+
if (!item) continue;
|
|
350
|
+
if (coord.x >= item.left && coord.x <= item.left + item.width && Math.abs(coord.y - item.top) <= UNDERLINE_HIT_PADDING / zoomRatio) {
|
|
351
|
+
underline = item;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const commentId = (marker === null || marker === void 0 ? void 0 : marker.commentId) ?? (underline === null || underline === void 0 ? void 0 : underline.commentId) ?? null;
|
|
356
|
+
this._hitCommentId = commentId;
|
|
357
|
+
if (commentId !== this._hoveredCommentId) {
|
|
358
|
+
this._hoveredCommentId = commentId;
|
|
359
|
+
this.makeDirty(true);
|
|
360
|
+
}
|
|
361
|
+
return commentId !== null;
|
|
362
|
+
}
|
|
363
|
+
render(ctx, _bounds) {
|
|
364
|
+
var _this$_state$focusOut;
|
|
365
|
+
const zoomRatio = this._getZoomRatio();
|
|
366
|
+
this._state.underlines.forEach((underline) => this._renderUnderline(ctx, underline, zoomRatio, 1));
|
|
367
|
+
(_this$_state$focusOut = this._state.focusOutlines) === null || _this$_state$focusOut === void 0 || _this$_state$focusOut.forEach((outline) => this._renderOutline(ctx, outline, zoomRatio));
|
|
368
|
+
if (this._state.previewUnderline) this._renderUnderline(ctx, this._state.previewUnderline, zoomRatio, MARKER_PREVIEW_OPACITY);
|
|
369
|
+
this._state.markers.forEach((marker) => {
|
|
370
|
+
var _this$_state$focusedC;
|
|
371
|
+
return this._renderMarker(ctx, marker, zoomRatio, this._markerContainsComment(marker, this._hoveredCommentId) || ((_this$_state$focusedC = this._state.focusedCommentIds) === null || _this$_state$focusedC === void 0 ? void 0 : _this$_state$focusedC.some((commentId) => this._markerContainsComment(marker, commentId))) ? 1 : MARKER_IDLE_OPACITY);
|
|
372
|
+
});
|
|
373
|
+
if (this._state.previewMarker) this._renderMarker(ctx, this._state.previewMarker, zoomRatio, MARKER_PREVIEW_OPACITY);
|
|
374
|
+
this.makeDirty(false);
|
|
375
|
+
return this;
|
|
376
|
+
}
|
|
377
|
+
_getZoomRatio() {
|
|
378
|
+
return Number.isFinite(this._state.zoomRatio) && this._state.zoomRatio > 0 ? this._state.zoomRatio : 1;
|
|
379
|
+
}
|
|
380
|
+
_containsComment(commentId) {
|
|
381
|
+
return this._state.markers.some((marker) => this._markerContainsComment(marker, commentId)) || this._state.underlines.some((underline) => underline.commentId === commentId);
|
|
382
|
+
}
|
|
383
|
+
_markerContainsComment(marker, commentId) {
|
|
384
|
+
var _marker$commentIds;
|
|
385
|
+
return commentId != null && (marker.commentId === commentId || ((_marker$commentIds = marker.commentIds) === null || _marker$commentIds === void 0 ? void 0 : _marker$commentIds.includes(commentId)) === true);
|
|
386
|
+
}
|
|
387
|
+
_renderUnderline(ctx, underline, zoomRatio, opacity) {
|
|
388
|
+
ctx.save();
|
|
389
|
+
ctx.globalAlpha = opacity;
|
|
390
|
+
ctx.strokeStyle = this._state.accentColor;
|
|
391
|
+
ctx.lineWidth = UNDERLINE_WIDTH / zoomRatio;
|
|
392
|
+
ctx.beginPath();
|
|
393
|
+
ctx.moveTo(underline.left, underline.top);
|
|
394
|
+
ctx.lineTo(underline.left + underline.width, underline.top);
|
|
395
|
+
ctx.stroke();
|
|
396
|
+
ctx.restore();
|
|
397
|
+
}
|
|
398
|
+
_renderOutline(ctx, outline, zoomRatio) {
|
|
399
|
+
const padding = OUTLINE_PADDING / zoomRatio;
|
|
400
|
+
ctx.save();
|
|
401
|
+
ctx.strokeStyle = this._state.accentColor;
|
|
402
|
+
ctx.lineWidth = UNDERLINE_WIDTH / zoomRatio;
|
|
403
|
+
ctx.strokeRect(outline.left - padding, outline.top - padding, outline.width + padding * 2, outline.height + padding * 2);
|
|
404
|
+
ctx.restore();
|
|
405
|
+
}
|
|
406
|
+
_renderMarker(ctx, marker, zoomRatio, opacity) {
|
|
407
|
+
const size = MARKER_SIZE / zoomRatio;
|
|
408
|
+
const left = marker.x - size / 2;
|
|
409
|
+
const top = marker.y - size / 2;
|
|
410
|
+
const radius = 4 / zoomRatio;
|
|
411
|
+
const tail = 4 / zoomRatio;
|
|
412
|
+
ctx.save();
|
|
413
|
+
ctx.globalAlpha = opacity;
|
|
414
|
+
ctx.fillStyle = this._state.accentColor;
|
|
415
|
+
ctx.strokeStyle = this._state.outlineColor;
|
|
416
|
+
ctx.lineWidth = 1.5 / zoomRatio;
|
|
417
|
+
ctx.beginPath();
|
|
418
|
+
ctx.moveTo(left + radius, top);
|
|
419
|
+
ctx.lineTo(left + size - radius, top);
|
|
420
|
+
ctx.quadraticCurveTo(left + size, top, left + size, top + radius);
|
|
421
|
+
ctx.lineTo(left + size, top + size - tail - radius);
|
|
422
|
+
ctx.quadraticCurveTo(left + size, top + size - tail, left + size - radius, top + size - tail);
|
|
423
|
+
ctx.lineTo(left + size / 2 + tail, top + size - tail);
|
|
424
|
+
ctx.lineTo(left + size / 2, top + size);
|
|
425
|
+
ctx.lineTo(left + size / 2 - tail, top + size - tail);
|
|
426
|
+
ctx.lineTo(left + radius, top + size - tail);
|
|
427
|
+
ctx.quadraticCurveTo(left, top + size - tail, left, top + size - tail - radius);
|
|
428
|
+
ctx.lineTo(left, top + radius);
|
|
429
|
+
ctx.quadraticCurveTo(left, top, left + radius, top);
|
|
430
|
+
ctx.closePath();
|
|
431
|
+
ctx.fill();
|
|
432
|
+
ctx.stroke();
|
|
433
|
+
ctx.fillStyle = this._state.foregroundColor;
|
|
434
|
+
if ((marker.count ?? 1) > 1) {
|
|
435
|
+
ctx.font = `600 ${11 / zoomRatio}px ${_univerjs_engine_render.DEFAULT_FONTFACE_PLANE}`;
|
|
436
|
+
ctx.textAlign = "center";
|
|
437
|
+
ctx.textBaseline = "middle";
|
|
438
|
+
ctx.fillText(String(marker.count), marker.x, top + size * .42);
|
|
439
|
+
} else {
|
|
440
|
+
const dotRadius = 1.2 / zoomRatio;
|
|
441
|
+
const dotY = top + size * .43;
|
|
442
|
+
[
|
|
443
|
+
.32,
|
|
444
|
+
.5,
|
|
445
|
+
.68
|
|
446
|
+
].forEach((ratio) => {
|
|
447
|
+
ctx.beginPath();
|
|
448
|
+
ctx.arc(left + size * ratio, dotY, dotRadius, 0, Math.PI * 2);
|
|
449
|
+
ctx.fill();
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
ctx.restore();
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
189
456
|
//#endregion
|
|
190
457
|
//#region src/views/thread-comment-panel/util.ts
|
|
458
|
+
function isSameThreadCommentTarget(active, comment) {
|
|
459
|
+
return (active === null || active === void 0 ? void 0 : active.unitId) === comment.unitId && active.subUnitId === comment.subUnitId && active.commentId === comment.id;
|
|
460
|
+
}
|
|
461
|
+
function shouldClearThreadCommentTarget(active, currentUnitId, commentExists) {
|
|
462
|
+
if (!active) return false;
|
|
463
|
+
return active.unitId !== currentUnitId || !commentExists;
|
|
464
|
+
}
|
|
191
465
|
function getThreadCommentPanelItemKey(comment, index, section) {
|
|
192
466
|
if (comment.id) return comment.id;
|
|
193
467
|
return [
|
|
@@ -300,29 +574,60 @@ function getSnapshot(body) {
|
|
|
300
574
|
};
|
|
301
575
|
}
|
|
302
576
|
const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
303
|
-
const { comment, onSave, id, onCancel, autoFocus, unitId, type, editorId } = props;
|
|
577
|
+
const { comment, onSave, id, onCancel, autoFocus, unitId, type, editorId, ActionRowComponent = _univerjs_design.ActionRow } = props;
|
|
304
578
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
305
579
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
306
580
|
const [editing, setEditing] = (0, react.useState)(false);
|
|
581
|
+
const [submitting, setSubmitting] = (0, react.useState)(false);
|
|
582
|
+
const submittingRef = (0, react.useRef)(false);
|
|
583
|
+
const mountedRef = (0, react.useRef)(true);
|
|
307
584
|
const editorService = (0, _univerjs_ui.useDependency)(_univerjs_docs_ui.IEditorService);
|
|
308
|
-
const
|
|
585
|
+
const editorRef = (0, react.useRef)(null);
|
|
309
586
|
const rootEditorId = type === _univerjs_core.UniverInstanceType.UNIVER_DOC ? _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY : unitId;
|
|
310
587
|
const [canSubmit, setCanSubmit] = (0, react.useState)(() => {
|
|
311
588
|
var _comment$text;
|
|
312
589
|
return _univerjs_core.BuildTextUtils.transform.getPlainText((comment === null || comment === void 0 || (_comment$text = comment.text) === null || _comment$text === void 0 ? void 0 : _comment$text.dataStream) ?? "");
|
|
313
590
|
});
|
|
314
591
|
const keyboardEventConfig = (0, react.useMemo)(() => ({
|
|
315
|
-
keyCodes: [
|
|
592
|
+
keyCodes: [
|
|
593
|
+
{ keyCode: _univerjs_ui.KeyCode.ENTER },
|
|
594
|
+
{ keyCode: _univerjs_ui.KeyCode.BACKSPACE },
|
|
595
|
+
{ keyCode: _univerjs_ui.KeyCode.DELETE }
|
|
596
|
+
],
|
|
316
597
|
handler: (keyCode) => {
|
|
317
|
-
|
|
598
|
+
let commandId;
|
|
599
|
+
switch (keyCode) {
|
|
600
|
+
case _univerjs_ui.KeyCode.ENTER:
|
|
601
|
+
commandId = _univerjs_docs_ui.BreakLineCommand.id;
|
|
602
|
+
break;
|
|
603
|
+
case _univerjs_ui.KeyCode.BACKSPACE:
|
|
604
|
+
commandId = _univerjs_docs_ui.DeleteLeftCommand.id;
|
|
605
|
+
break;
|
|
606
|
+
case _univerjs_ui.KeyCode.DELETE:
|
|
607
|
+
commandId = _univerjs_docs_ui.DeleteRightCommand.id;
|
|
608
|
+
break;
|
|
609
|
+
default: return;
|
|
610
|
+
}
|
|
611
|
+
focusThreadCommentEditor(editorService, editorId, editorRef.current);
|
|
612
|
+
commandService.executeCommand(commandId).then(() => {
|
|
613
|
+
if (keyCode !== _univerjs_ui.KeyCode.ENTER && mountedRef.current) {
|
|
614
|
+
var _editorRef$current;
|
|
615
|
+
const dataStream = ((_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.getDocumentData().body) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.dataStream) ?? "";
|
|
616
|
+
setCanSubmit(_univerjs_core.BuildTextUtils.transform.getPlainText(dataStream));
|
|
617
|
+
}
|
|
618
|
+
});
|
|
318
619
|
}
|
|
319
|
-
}), [
|
|
620
|
+
}), [
|
|
621
|
+
commandService,
|
|
622
|
+
editorId,
|
|
623
|
+
editorService
|
|
624
|
+
]);
|
|
320
625
|
(0, react.useImperativeHandle)(ref, () => ({ reply(text) {
|
|
321
|
-
var
|
|
322
|
-
if (!
|
|
323
|
-
focusThreadCommentEditor(editorService, editorId,
|
|
626
|
+
var _editorRef$current2;
|
|
627
|
+
if (!editorRef.current) return;
|
|
628
|
+
focusThreadCommentEditor(editorService, editorId, editorRef.current);
|
|
324
629
|
const documentData = getSnapshot(text);
|
|
325
|
-
(
|
|
630
|
+
(_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 || _editorRef$current2.setDocumentData(documentData, [{
|
|
326
631
|
startOffset: documentData.body.dataStream.length - 2,
|
|
327
632
|
endOffset: documentData.body.dataStream.length - 2,
|
|
328
633
|
collapsed: true
|
|
@@ -330,29 +635,44 @@ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
330
635
|
setCanSubmit(_univerjs_core.BuildTextUtils.transform.getPlainText(documentData.body.dataStream));
|
|
331
636
|
setEditing(true);
|
|
332
637
|
} }));
|
|
333
|
-
const handleSave = () => {
|
|
334
|
-
const currentEditor =
|
|
335
|
-
if (currentEditor)
|
|
336
|
-
|
|
638
|
+
const handleSave = async () => {
|
|
639
|
+
const currentEditor = editorRef.current;
|
|
640
|
+
if (!currentEditor || submittingRef.current) return;
|
|
641
|
+
const newText = _univerjs_core.Tools.deepClone(currentEditor.getDocumentData().body);
|
|
642
|
+
submittingRef.current = true;
|
|
643
|
+
setSubmitting(true);
|
|
644
|
+
try {
|
|
645
|
+
if (await (onSave === null || onSave === void 0 ? void 0 : onSave({
|
|
646
|
+
...comment,
|
|
647
|
+
text: newText
|
|
648
|
+
})) === false) return;
|
|
649
|
+
if (!mountedRef.current) return;
|
|
337
650
|
currentEditor.blur();
|
|
338
651
|
currentEditor.replaceText("", false);
|
|
339
652
|
currentEditor.setSelectionRanges([], false);
|
|
340
653
|
setCanSubmit("");
|
|
341
654
|
setEditing(false);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
655
|
+
} catch {
|
|
656
|
+
return;
|
|
657
|
+
} finally {
|
|
658
|
+
submittingRef.current = false;
|
|
659
|
+
if (mountedRef.current) setSubmitting(false);
|
|
346
660
|
}
|
|
347
661
|
};
|
|
348
662
|
const handleEditorMouseDown = () => {
|
|
349
|
-
focusThreadCommentEditor(editorService, editorId,
|
|
663
|
+
focusThreadCommentEditor(editorService, editorId, editorRef.current);
|
|
350
664
|
setEditing(true);
|
|
351
665
|
};
|
|
666
|
+
(0, react.useEffect)(() => {
|
|
667
|
+
mountedRef.current = true;
|
|
668
|
+
return () => {
|
|
669
|
+
mountedRef.current = false;
|
|
670
|
+
};
|
|
671
|
+
}, []);
|
|
352
672
|
(0, react.useEffect)(() => {
|
|
353
673
|
if (!autoFocus) return;
|
|
354
674
|
const timer = setTimeout(() => {
|
|
355
|
-
focusThreadCommentEditor(editorService, editorId,
|
|
675
|
+
focusThreadCommentEditor(editorService, editorId, editorRef.current);
|
|
356
676
|
});
|
|
357
677
|
return () => clearTimeout(timer);
|
|
358
678
|
}, [
|
|
@@ -366,7 +686,7 @@ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
366
686
|
onMouseDown: handleEditorMouseDown,
|
|
367
687
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_docs_ui.RichTextEditor, {
|
|
368
688
|
className: "univer-w-full",
|
|
369
|
-
editorRef
|
|
689
|
+
editorRef,
|
|
370
690
|
editorId,
|
|
371
691
|
preserveHostFocus: true,
|
|
372
692
|
autoFocus,
|
|
@@ -386,12 +706,12 @@ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
386
706
|
}, 30);
|
|
387
707
|
}
|
|
388
708
|
})
|
|
389
|
-
}), editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
709
|
+
}), editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ActionRowComponent, {
|
|
390
710
|
className: "univer-mt-3 univer-flex univer-flex-row univer-justify-end univer-gap-2",
|
|
391
711
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
392
712
|
type: "button",
|
|
393
713
|
onClick: () => {
|
|
394
|
-
const currentEditor =
|
|
714
|
+
const currentEditor = editorRef.current;
|
|
395
715
|
currentEditor === null || currentEditor === void 0 || currentEditor.blur();
|
|
396
716
|
currentEditor === null || currentEditor === void 0 || currentEditor.replaceText("", false);
|
|
397
717
|
currentEditor === null || currentEditor === void 0 || currentEditor.setSelectionRanges([], false);
|
|
@@ -404,7 +724,7 @@ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
404
724
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
405
725
|
type: "button",
|
|
406
726
|
variant: "primary",
|
|
407
|
-
disabled: !canSubmit,
|
|
727
|
+
disabled: !canSubmit || submitting,
|
|
408
728
|
onClick: handleSave,
|
|
409
729
|
children: localeService.t(id ? "thread-comment-ui.editor.save" : "thread-comment-ui.editor.reply")
|
|
410
730
|
})]
|
|
@@ -434,7 +754,7 @@ function formatCommentDateTime(value, region) {
|
|
|
434
754
|
});
|
|
435
755
|
}
|
|
436
756
|
const ThreadCommentItem = (props) => {
|
|
437
|
-
const { item, unitId, subUnitId, editing, onEditingChange, onReply, resolved, isRoot, onClose, onDeleteComment, type, threadCommentEditorId } = props;
|
|
757
|
+
const { item, unitId, subUnitId, editing, onEditingChange, onReply, resolved, isRoot, onClose, onDeleteComment, onAfterDeleteComment, type, threadCommentEditorId, DropdownComponent, EditorComponent } = props;
|
|
438
758
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
439
759
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
440
760
|
const regionService = (0, _univerjs_ui.useDependency)(_univerjs_core.RegionService);
|
|
@@ -449,14 +769,20 @@ const ThreadCommentItem = (props) => {
|
|
|
449
769
|
const currentRegion = (0, _univerjs_ui.useObservable)(regionService.currentRegion$, regionService.getCurrentRegion());
|
|
450
770
|
const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
|
|
451
771
|
const dateText = isMock ? null : formatCommentDateTime(item.dT, currentRegion);
|
|
452
|
-
const handleDeleteItem = () => {
|
|
772
|
+
const handleDeleteItem = async () => {
|
|
453
773
|
if ((onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(item)) === false) return;
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
774
|
+
try {
|
|
775
|
+
if (await commandService.executeCommand(isRoot ? _univerjs_thread_comment.DeleteCommentTreeCommand.id : _univerjs_thread_comment.DeleteCommentCommand.id, {
|
|
776
|
+
unitId,
|
|
777
|
+
subUnitId,
|
|
778
|
+
commentId: item.id
|
|
779
|
+
})) {
|
|
780
|
+
try {
|
|
781
|
+
await (onAfterDeleteComment === null || onAfterDeleteComment === void 0 ? void 0 : onAfterDeleteComment(item));
|
|
782
|
+
} catch {}
|
|
783
|
+
if (isRoot) onClose === null || onClose === void 0 || onClose();
|
|
784
|
+
}
|
|
785
|
+
} catch {}
|
|
460
786
|
};
|
|
461
787
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
462
788
|
className: "univer-relative univer-mb-3 univer-pl-[30px] rtl:univer-pl-0 rtl:univer-pr-[30px]",
|
|
@@ -472,39 +798,47 @@ const ThreadCommentItem = (props) => {
|
|
|
472
798
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
473
799
|
className: "univer-text-sm univer-font-medium univer-leading-5",
|
|
474
800
|
children: (user === null || user === void 0 ? void 0 : user.name) || " "
|
|
475
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [isMock || resolved ? null : showReply && user ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
476
|
-
|
|
801
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [isMock || resolved ? null : showReply && user ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
802
|
+
type: "button",
|
|
803
|
+
"aria-label": localeService.t("thread-comment-ui.editor.reply"),
|
|
804
|
+
className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800",
|
|
477
805
|
onClick: () => onReply(user),
|
|
478
806
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ReplyToCommentIcon, {})
|
|
479
|
-
}) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
807
|
+
}) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownComponent, {
|
|
480
808
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
481
809
|
dir: direction,
|
|
482
810
|
className: "univer-rounded-lg",
|
|
483
811
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
|
|
484
|
-
className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm rtl:univer-text-right [&
|
|
485
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
812
|
+
className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm rtl:univer-text-right [&_button]:univer-block [&_button]:univer-w-full [&_button]:univer-cursor-pointer [&_button]:univer-rounded [&_button]:univer-border-0 [&_button]:univer-bg-transparent [&_button]:univer-px-2 [&_button]:univer-py-1.5 [&_button]:univer-text-left [&_button]:univer-transition-colors rtl:[&_button]:univer-text-right",
|
|
813
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
814
|
+
type: "button",
|
|
486
815
|
className: "hover:univer-bg-gray-200",
|
|
487
816
|
onClick: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(true),
|
|
488
817
|
children: localeService.t("thread-comment-ui.item.edit")
|
|
489
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
818
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
819
|
+
type: "button",
|
|
490
820
|
className: "hover:univer-bg-gray-200",
|
|
491
821
|
onClick: handleDeleteItem,
|
|
492
822
|
children: localeService.t("thread-comment-ui.item.delete")
|
|
493
823
|
}) })]
|
|
494
824
|
})
|
|
495
825
|
}),
|
|
496
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
497
|
-
|
|
826
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
827
|
+
type: "button",
|
|
828
|
+
"aria-label": localeService.t("thread-comment-ui.item.more"),
|
|
829
|
+
className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800",
|
|
498
830
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreHorizontalIcon, {})
|
|
499
831
|
})
|
|
500
832
|
}) : null] })]
|
|
501
833
|
}) : null,
|
|
502
834
|
dateText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("time", {
|
|
503
|
-
dir: "ltr",
|
|
504
835
|
className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200",
|
|
505
|
-
children:
|
|
836
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("bdo", {
|
|
837
|
+
dir: "ltr",
|
|
838
|
+
children: dateText
|
|
839
|
+
})
|
|
506
840
|
}),
|
|
507
|
-
editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
841
|
+
editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorComponent, {
|
|
508
842
|
type,
|
|
509
843
|
id: item.id,
|
|
510
844
|
comment: item,
|
|
@@ -513,9 +847,8 @@ const ThreadCommentItem = (props) => {
|
|
|
513
847
|
unitId,
|
|
514
848
|
subUnitId,
|
|
515
849
|
editorId: threadCommentEditorId,
|
|
516
|
-
onSave: ({ text, attachments }) => {
|
|
517
|
-
|
|
518
|
-
commandService.executeCommand(_univerjs_thread_comment.UpdateCommentCommand.id, {
|
|
850
|
+
onSave: async ({ text, attachments }) => {
|
|
851
|
+
const success = await commandService.executeCommand(_univerjs_thread_comment.UpdateCommentCommand.id, {
|
|
519
852
|
unitId,
|
|
520
853
|
subUnitId,
|
|
521
854
|
payload: {
|
|
@@ -524,27 +857,35 @@ const ThreadCommentItem = (props) => {
|
|
|
524
857
|
attachments
|
|
525
858
|
}
|
|
526
859
|
});
|
|
860
|
+
if (success) onEditingChange === null || onEditingChange === void 0 || onEditingChange(false);
|
|
861
|
+
return success;
|
|
527
862
|
}
|
|
528
863
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
529
|
-
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-
|
|
530
|
-
children: transformDocument2TextNodes(item.text).map((paragraph,
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
864
|
+
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
|
|
865
|
+
children: transformDocument2TextNodes(item.text).map((paragraph, paragraphIndex) => {
|
|
866
|
+
var _item$text$paragraphs;
|
|
867
|
+
let offset = 0;
|
|
868
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
869
|
+
className: "univer-break-words",
|
|
870
|
+
children: paragraph.map((node) => {
|
|
871
|
+
const key = offset;
|
|
872
|
+
offset += node.type === "mention" ? node.content.label.length : node.content.length;
|
|
873
|
+
switch (node.type) {
|
|
874
|
+
case "mention": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
875
|
+
className: "univer-text-primary-600",
|
|
876
|
+
children: [node.content.label, " "]
|
|
877
|
+
}, key);
|
|
878
|
+
default: return node.content;
|
|
879
|
+
}
|
|
880
|
+
})
|
|
881
|
+
}, (_item$text$paragraphs = item.text.paragraphs) === null || _item$text$paragraphs === void 0 || (_item$text$paragraphs = _item$text$paragraphs[paragraphIndex]) === null || _item$text$paragraphs === void 0 ? void 0 : _item$text$paragraphs.paragraphId);
|
|
882
|
+
})
|
|
542
883
|
})
|
|
543
884
|
]
|
|
544
885
|
});
|
|
545
886
|
};
|
|
546
887
|
const ThreadCommentTree = (props) => {
|
|
547
|
-
const { id, unitId, subUnitId, refStr, showEdit = true, onClick, showHighlight, onClose, getSubUnitName, location, autoFocus, onMouseEnter, onMouseLeave, onAddComment, onDeleteComment, onResolve, type, style, full } = props;
|
|
888
|
+
const { id, unitId, subUnitId, refStr, displayRef, showEdit = true, onClick, showHighlight, onClose, getSubUnitName, location, autoFocus, onMouseEnter, onMouseLeave, onAddComment, onDeleteComment, onAfterDeleteComment, onResolve, type, style, full, DropdownComponent = _univerjs_design.Dropdown, EditorComponent = ThreadCommentEditor } = props;
|
|
548
889
|
const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
|
|
549
890
|
const [isHover, setIsHover] = (0, react.useState)(false);
|
|
550
891
|
const [editingId, setEditingId] = (0, react.useState)("");
|
|
@@ -557,6 +898,7 @@ const ThreadCommentTree = (props) => {
|
|
|
557
898
|
updte$
|
|
558
899
|
]);
|
|
559
900
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
901
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
560
902
|
const userManagerService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
|
|
561
903
|
const resolved = comments === null || comments === void 0 ? void 0 : comments.root.resolved;
|
|
562
904
|
const currentUser = (0, _univerjs_ui.useObservable)(userManagerService.currentUser$);
|
|
@@ -572,40 +914,49 @@ const ThreadCommentTree = (props) => {
|
|
|
572
914
|
subUnitId,
|
|
573
915
|
threadId: ""
|
|
574
916
|
}], ...(comments === null || comments === void 0 ? void 0 : comments.children) ?? []];
|
|
575
|
-
const
|
|
576
|
-
const
|
|
917
|
+
const scrollerRef = (0, react.useRef)(null);
|
|
918
|
+
const handleMouseLeave = (0, _univerjs_ui.useEvent)(onMouseLeave);
|
|
919
|
+
const handleResolve = async (e) => {
|
|
577
920
|
e.stopPropagation();
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
921
|
+
try {
|
|
922
|
+
if (!await commandService.executeCommand(_univerjs_thread_comment.ResolveCommentCommand.id, {
|
|
923
|
+
unitId,
|
|
924
|
+
subUnitId,
|
|
925
|
+
commentId: id,
|
|
926
|
+
resolved: !resolved
|
|
927
|
+
})) return;
|
|
928
|
+
await commandService.executeCommand(SetActiveCommentOperation.id, resolved ? {
|
|
929
|
+
unitId,
|
|
930
|
+
subUnitId,
|
|
931
|
+
commentId: id
|
|
932
|
+
} : void 0);
|
|
933
|
+
onResolve === null || onResolve === void 0 || onResolve(!resolved);
|
|
934
|
+
} catch {}
|
|
591
935
|
};
|
|
592
|
-
const handleDeleteRoot = (e) => {
|
|
936
|
+
const handleDeleteRoot = async (e) => {
|
|
593
937
|
e.stopPropagation();
|
|
594
|
-
|
|
595
|
-
if (
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
938
|
+
const root = comments === null || comments === void 0 ? void 0 : comments.root;
|
|
939
|
+
if (!root || (onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(root)) === false) return;
|
|
940
|
+
try {
|
|
941
|
+
if (await commandService.executeCommand(_univerjs_thread_comment.DeleteCommentTreeCommand.id, {
|
|
942
|
+
unitId,
|
|
943
|
+
subUnitId,
|
|
944
|
+
commentId: id
|
|
945
|
+
})) {
|
|
946
|
+
try {
|
|
947
|
+
await (onAfterDeleteComment === null || onAfterDeleteComment === void 0 ? void 0 : onAfterDeleteComment(root));
|
|
948
|
+
} catch {}
|
|
949
|
+
await commandService.executeCommand(SetActiveCommentOperation.id);
|
|
950
|
+
onClose === null || onClose === void 0 || onClose();
|
|
951
|
+
}
|
|
952
|
+
} catch {}
|
|
602
953
|
};
|
|
603
954
|
(0, react.useEffect)(() => {
|
|
604
|
-
return
|
|
605
|
-
}, []);
|
|
955
|
+
return handleMouseLeave;
|
|
956
|
+
}, [handleMouseLeave]);
|
|
606
957
|
const subUnitName = getSubUnitName((comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) ?? subUnitId);
|
|
607
958
|
const editorVisible = showEdit && !editingId && !resolved;
|
|
608
|
-
const title = `${refStr
|
|
959
|
+
const title = `${displayRef ?? refStr ?? (comments === null || comments === void 0 ? void 0 : comments.root.ref) ?? ""}${subUnitName ? " · " : ""}${subUnitName}`;
|
|
609
960
|
const threadCommentEditorId = getThreadCommentEditorId({
|
|
610
961
|
location,
|
|
611
962
|
unitId,
|
|
@@ -615,7 +966,7 @@ const ThreadCommentTree = (props) => {
|
|
|
615
966
|
});
|
|
616
967
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
617
968
|
id: `${location}-${unitId}-${subUnitId}-${id}`,
|
|
618
|
-
className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-rounded-md univer-bg-
|
|
969
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-rounded-md univer-bg-gray-0 univer-p-4 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-0", _univerjs_design.borderClassName, {
|
|
619
970
|
"univer-w-[278px]": !full,
|
|
620
971
|
"univer-w-full": full,
|
|
621
972
|
"univer-shadow": !resolved && (showHighlight || isHover || location === "CELL")
|
|
@@ -646,19 +997,23 @@ const ThreadCommentTree = (props) => {
|
|
|
646
997
|
})]
|
|
647
998
|
}), !!comments && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
648
999
|
className: "univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",
|
|
649
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
650
|
-
|
|
1000
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1001
|
+
type: "button",
|
|
1002
|
+
"aria-label": localeService.t(resolved ? "thread-comment-ui.filter.status.unsolved" : "thread-comment-ui.filter.status.resolved"),
|
|
1003
|
+
className: (0, _univerjs_design.clsx)("univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800", { "univer-text-green-500": resolved }),
|
|
651
1004
|
onClick: handleResolve,
|
|
652
1005
|
children: resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SuccessIcon, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SuccessOutlineIcon, {})
|
|
653
|
-
}), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) === comments.root.personId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
654
|
-
|
|
1006
|
+
}), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) === comments.root.personId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1007
|
+
type: "button",
|
|
1008
|
+
"aria-label": localeService.t("thread-comment-ui.item.delete"),
|
|
1009
|
+
className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800",
|
|
655
1010
|
onClick: handleDeleteRoot,
|
|
656
1011
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
|
|
657
1012
|
}) : null]
|
|
658
1013
|
})]
|
|
659
1014
|
}),
|
|
660
1015
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
661
|
-
ref:
|
|
1016
|
+
ref: scrollerRef,
|
|
662
1017
|
className: (0, _univerjs_design.clsx)("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", _univerjs_design.scrollbarClassName, location === "PANEL" && "-univer-mx-4 univer-px-4"),
|
|
663
1018
|
children: renderComments.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentItem, {
|
|
664
1019
|
unitId,
|
|
@@ -669,6 +1024,8 @@ const ThreadCommentTree = (props) => {
|
|
|
669
1024
|
resolved: comments === null || comments === void 0 ? void 0 : comments.root.resolved,
|
|
670
1025
|
type,
|
|
671
1026
|
threadCommentEditorId,
|
|
1027
|
+
DropdownComponent,
|
|
1028
|
+
EditorComponent,
|
|
672
1029
|
onClose,
|
|
673
1030
|
onEditingChange: (editing) => {
|
|
674
1031
|
if (editing) setEditingId(item.id);
|
|
@@ -690,11 +1047,11 @@ const ThreadCommentTree = (props) => {
|
|
|
690
1047
|
}]));
|
|
691
1048
|
});
|
|
692
1049
|
},
|
|
693
|
-
|
|
694
|
-
|
|
1050
|
+
onDeleteComment,
|
|
1051
|
+
onAfterDeleteComment
|
|
695
1052
|
}, item.id))
|
|
696
1053
|
}),
|
|
697
|
-
editorVisible && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1054
|
+
editorVisible && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorComponent, {
|
|
698
1055
|
ref: editorRef,
|
|
699
1056
|
type,
|
|
700
1057
|
unitId,
|
|
@@ -713,13 +1070,18 @@ const ThreadCommentTree = (props) => {
|
|
|
713
1070
|
subUnitId,
|
|
714
1071
|
threadId: (comments === null || comments === void 0 ? void 0 : comments.root.threadId) ?? ""
|
|
715
1072
|
};
|
|
716
|
-
if ((onAddComment === null || onAddComment === void 0 ? void 0 : onAddComment(comment)) === false)
|
|
717
|
-
|
|
1073
|
+
if (await (onAddComment === null || onAddComment === void 0 ? void 0 : onAddComment(comment)) === false) {
|
|
1074
|
+
if (!comments) onClose === null || onClose === void 0 || onClose();
|
|
1075
|
+
return true;
|
|
1076
|
+
}
|
|
1077
|
+
const success = await commandService.executeCommand(_univerjs_thread_comment.AddCommentCommand.id, {
|
|
718
1078
|
unitId,
|
|
719
1079
|
subUnitId,
|
|
720
1080
|
comment
|
|
721
1081
|
});
|
|
722
|
-
if (
|
|
1082
|
+
if (success && scrollerRef.current) scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
|
|
1083
|
+
if (success && !comments) onClose === null || onClose === void 0 || onClose();
|
|
1084
|
+
return success;
|
|
723
1085
|
},
|
|
724
1086
|
autoFocus: autoFocus || !comments,
|
|
725
1087
|
onCancel: () => {
|
|
@@ -733,22 +1095,25 @@ const ThreadCommentTree = (props) => {
|
|
|
733
1095
|
//#endregion
|
|
734
1096
|
//#region src/views/ThreadCommentPanel.tsx
|
|
735
1097
|
const ThreadCommentPanel = (props) => {
|
|
736
|
-
const { unitId, subUnitId$, type, onAdd, getSubUnitName, onResolve, sortComments, onItemLeave, onItemEnter, disableAdd, tempComment, onAddComment, onDeleteComment, showComments } = props;
|
|
1098
|
+
const { unitId, subUnitId$, type, onAdd, getSubUnitName, onResolve, sortComments, onItemLeave, onItemEnter, disableAdd, tempComment, onAddComment, onDeleteComment, onAfterDeleteComment, showComments, formatRef, onTempCommentClose, autoFocusActiveComment = false, ActionRowComponent = _univerjs_design.ActionRow, SelectComponent = _univerjs_design.Select, ThreadCommentTreeComponent = ThreadCommentTree } = props;
|
|
737
1099
|
const [unit, setUnit] = (0, react.useState)("all");
|
|
738
1100
|
const [status, setStatus] = (0, react.useState)("all");
|
|
739
1101
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
740
1102
|
const userService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
|
|
741
1103
|
const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
|
|
742
|
-
const
|
|
743
|
-
const activeCommentId = (0, _univerjs_ui.useObservable)(
|
|
744
|
-
|
|
1104
|
+
const panelService = (0, _univerjs_ui.useDependency)(ThreadCommentPanelService);
|
|
1105
|
+
const activeCommentId = (0, _univerjs_ui.useObservable)(panelService.activeCommentId$);
|
|
1106
|
+
(0, _univerjs_ui.useObservable)(threadCommentModel.commentUpdate$);
|
|
1107
|
+
const unitComments = threadCommentModel.getUnit(unitId);
|
|
1108
|
+
const scopedTempComment = (tempComment === null || tempComment === void 0 ? void 0 : tempComment.unitId) === unitId ? tempComment : null;
|
|
1109
|
+
const shouldClearActiveTarget = shouldClearThreadCommentTarget(activeCommentId, unitId, activeCommentId ? Boolean(threadCommentModel.getComment(activeCommentId.unitId, activeCommentId.subUnitId, activeCommentId.commentId) || scopedTempComment && isSameThreadCommentTarget(activeCommentId, scopedTempComment)) : false);
|
|
745
1110
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
746
1111
|
const subUnitId = (0, _univerjs_ui.useObservable)(subUnitId$);
|
|
747
|
-
const
|
|
1112
|
+
const shouldScrollRef = (0, react.useRef)(true);
|
|
748
1113
|
const location = "PANEL";
|
|
749
1114
|
const currentUser = (0, _univerjs_ui.useObservable)(userService.currentUser$);
|
|
750
1115
|
const comments = (0, react.useMemo)(() => {
|
|
751
|
-
const allComments = unit === "all" ? unitComments : unitComments.filter((i) => i.subUnitId === subUnitId)
|
|
1116
|
+
const allComments = unit === "all" && type !== _univerjs_core.UniverInstanceType.UNIVER_SLIDE ? unitComments : unitComments.filter((i) => i.subUnitId === subUnitId);
|
|
752
1117
|
const sort = sortComments ?? ((a) => a);
|
|
753
1118
|
const res = allComments.map((i) => ({
|
|
754
1119
|
...i.root,
|
|
@@ -767,7 +1132,8 @@ const ThreadCommentPanel = (props) => {
|
|
|
767
1132
|
unit,
|
|
768
1133
|
unitComments,
|
|
769
1134
|
sortComments,
|
|
770
|
-
subUnitId
|
|
1135
|
+
subUnitId,
|
|
1136
|
+
type
|
|
771
1137
|
]);
|
|
772
1138
|
const commentsSorted = (0, react.useMemo)(() => [...comments.filter((comment) => !comment.resolved), ...comments.filter((comment) => comment.resolved)], [comments]);
|
|
773
1139
|
const statuedComments = (0, react.useMemo)(() => {
|
|
@@ -783,7 +1149,7 @@ const ThreadCommentPanel = (props) => {
|
|
|
783
1149
|
currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID,
|
|
784
1150
|
status
|
|
785
1151
|
]);
|
|
786
|
-
const renderComments =
|
|
1152
|
+
const renderComments = scopedTempComment ? [scopedTempComment, ...statuedComments] : statuedComments;
|
|
787
1153
|
const unSolvedComments = renderComments.filter((comment) => !comment.resolved);
|
|
788
1154
|
const solvedComments = renderComments.filter((comment) => comment.resolved);
|
|
789
1155
|
const isFiltering = status !== "all" || unit !== "all";
|
|
@@ -792,24 +1158,49 @@ const ThreadCommentPanel = (props) => {
|
|
|
792
1158
|
setUnit("all");
|
|
793
1159
|
};
|
|
794
1160
|
(0, react.useEffect)(() => {
|
|
795
|
-
if (
|
|
1161
|
+
if (shouldClearActiveTarget) panelService.setActiveComment(void 0);
|
|
1162
|
+
}, [panelService, shouldClearActiveTarget]);
|
|
1163
|
+
(0, react.useEffect)(() => {
|
|
1164
|
+
if (tempComment && (tempComment.unitId !== unitId || subUnitId && tempComment.subUnitId !== subUnitId)) onTempCommentClose === null || onTempCommentClose === void 0 || onTempCommentClose();
|
|
796
1165
|
}, [
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
1166
|
+
onTempCommentClose,
|
|
1167
|
+
subUnitId,
|
|
1168
|
+
tempComment,
|
|
1169
|
+
unitId
|
|
1170
|
+
]);
|
|
1171
|
+
(0, react.useEffect)(() => {
|
|
1172
|
+
if (!activeCommentId) return;
|
|
1173
|
+
const handlePointerDown = (event) => {
|
|
1174
|
+
const activeComment = panelService.activeCommentId;
|
|
1175
|
+
const target = event.target;
|
|
1176
|
+
if (event.button !== 0 || !activeComment || !(target instanceof Element)) return;
|
|
1177
|
+
const activeElement = document.getElementById(`${location}-${activeComment.unitId}-${activeComment.subUnitId}-${activeComment.commentId}`);
|
|
1178
|
+
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.contains(target)) || target.closest("button, input, textarea, select, a, [contenteditable=\"true\"], [role=\"menu\"], [role=\"menuitem\"], [role=\"option\"], [role=\"listbox\"], [role=\"combobox\"], [role=\"separator\"]")) return;
|
|
1179
|
+
commandService.executeCommand(SetActiveCommentOperation.id);
|
|
1180
|
+
if (scopedTempComment && isSameThreadCommentTarget(activeComment, scopedTempComment)) onTempCommentClose === null || onTempCommentClose === void 0 || onTempCommentClose();
|
|
1181
|
+
};
|
|
1182
|
+
document.addEventListener("pointerdown", handlePointerDown, true);
|
|
1183
|
+
return () => document.removeEventListener("pointerdown", handlePointerDown, true);
|
|
1184
|
+
}, [
|
|
1185
|
+
activeCommentId,
|
|
1186
|
+
commandService,
|
|
1187
|
+
location,
|
|
1188
|
+
onTempCommentClose,
|
|
1189
|
+
panelService,
|
|
1190
|
+
scopedTempComment
|
|
800
1191
|
]);
|
|
801
1192
|
(0, react.useEffect)(() => {
|
|
802
1193
|
var _document$getElementB;
|
|
803
1194
|
if (!activeCommentId) return;
|
|
804
|
-
if (!
|
|
805
|
-
|
|
1195
|
+
if (!shouldScrollRef.current) {
|
|
1196
|
+
shouldScrollRef.current = true;
|
|
806
1197
|
return;
|
|
807
1198
|
}
|
|
808
1199
|
const { unitId, subUnitId, commentId } = activeCommentId;
|
|
809
1200
|
const id = `${location}-${unitId}-${subUnitId}-${commentId}`;
|
|
810
1201
|
(_document$getElementB = document.getElementById(id)) === null || _document$getElementB === void 0 || _document$getElementB.scrollIntoView({ block: "center" });
|
|
811
|
-
}, [activeCommentId]);
|
|
812
|
-
const renderComment = (section) => (comment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1202
|
+
}, [activeCommentId, location]);
|
|
1203
|
+
const renderComment = (section) => (comment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentTreeComponent, {
|
|
813
1204
|
full: true,
|
|
814
1205
|
location,
|
|
815
1206
|
getSubUnitName,
|
|
@@ -817,11 +1208,13 @@ const ThreadCommentPanel = (props) => {
|
|
|
817
1208
|
unitId: comment.unitId,
|
|
818
1209
|
subUnitId: comment.subUnitId,
|
|
819
1210
|
refStr: comment.ref,
|
|
1211
|
+
displayRef: formatRef === null || formatRef === void 0 ? void 0 : formatRef(comment),
|
|
820
1212
|
type,
|
|
821
|
-
showEdit:
|
|
822
|
-
showHighlight: (activeCommentId
|
|
1213
|
+
showEdit: !comment.id || isSameThreadCommentTarget(activeCommentId, comment),
|
|
1214
|
+
showHighlight: isSameThreadCommentTarget(activeCommentId, comment),
|
|
1215
|
+
autoFocus: autoFocusActiveComment && isSameThreadCommentTarget(activeCommentId, comment),
|
|
823
1216
|
onClick: () => {
|
|
824
|
-
|
|
1217
|
+
shouldScrollRef.current = false;
|
|
825
1218
|
if (!comment.resolved) commandService.executeCommand(SetActiveCommentOperation.id, {
|
|
826
1219
|
unitId: comment.unitId,
|
|
827
1220
|
subUnitId: comment.subUnitId,
|
|
@@ -830,17 +1223,30 @@ const ThreadCommentPanel = (props) => {
|
|
|
830
1223
|
});
|
|
831
1224
|
else commandService.executeCommand(SetActiveCommentOperation.id);
|
|
832
1225
|
},
|
|
833
|
-
onMouseEnter: () =>
|
|
834
|
-
|
|
1226
|
+
onMouseEnter: () => {
|
|
1227
|
+
panelService.setHoveredComment({
|
|
1228
|
+
unitId: comment.unitId,
|
|
1229
|
+
subUnitId: comment.subUnitId,
|
|
1230
|
+
commentId: comment.id,
|
|
1231
|
+
trigger: "panel-hover"
|
|
1232
|
+
});
|
|
1233
|
+
onItemEnter === null || onItemEnter === void 0 || onItemEnter(comment);
|
|
1234
|
+
},
|
|
1235
|
+
onMouseLeave: () => {
|
|
1236
|
+
if (isSameThreadCommentTarget(panelService.hoveredCommentId, comment)) panelService.setHoveredComment(void 0);
|
|
1237
|
+
onItemLeave === null || onItemLeave === void 0 || onItemLeave(comment);
|
|
1238
|
+
},
|
|
835
1239
|
onAddComment,
|
|
836
1240
|
onDeleteComment,
|
|
837
|
-
|
|
1241
|
+
onAfterDeleteComment,
|
|
1242
|
+
onResolve: (resolved) => onResolve === null || onResolve === void 0 ? void 0 : onResolve(comment.id, resolved),
|
|
1243
|
+
onClose: !comment.id ? onTempCommentClose : void 0
|
|
838
1244
|
}, getThreadCommentPanelItemKey(comment, index, section));
|
|
839
1245
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
840
1246
|
className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
|
|
841
1247
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
842
1248
|
className: "univer-mt-3 univer-flex univer-flex-row univer-justify-between",
|
|
843
|
-
children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1249
|
+
children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectComponent, {
|
|
844
1250
|
borderless: true,
|
|
845
1251
|
value: unit,
|
|
846
1252
|
options: [{
|
|
@@ -851,7 +1257,7 @@ const ThreadCommentPanel = (props) => {
|
|
|
851
1257
|
label: localeService.t("thread-comment-ui.filter.sheet.all")
|
|
852
1258
|
}],
|
|
853
1259
|
onChange: setUnit
|
|
854
|
-
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1260
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectComponent, {
|
|
855
1261
|
borderless: true,
|
|
856
1262
|
value: status,
|
|
857
1263
|
options: [
|
|
@@ -876,13 +1282,13 @@ const ThreadCommentPanel = (props) => {
|
|
|
876
1282
|
})]
|
|
877
1283
|
}), renderComments.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
878
1284
|
className: "univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
879
|
-
children: [localeService.t("thread-comment-ui.panel.empty"), isFiltering ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1285
|
+
children: [localeService.t("thread-comment-ui.panel.empty"), isFiltering ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionRowComponent, {
|
|
880
1286
|
className: "univer-mt-2 univer-flex univer-flex-row",
|
|
881
1287
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
882
1288
|
onClick: onReset,
|
|
883
1289
|
children: localeService.t("thread-comment-ui.panel.reset")
|
|
884
1290
|
})
|
|
885
|
-
}) : !disableAdd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1291
|
+
}) : !disableAdd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionRowComponent, {
|
|
886
1292
|
className: "univer-mt-2 univer-flex univer-flex-row",
|
|
887
1293
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
888
1294
|
onClick: onAdd,
|
|
@@ -904,7 +1310,45 @@ const ThreadCommentPanel = (props) => {
|
|
|
904
1310
|
};
|
|
905
1311
|
|
|
906
1312
|
//#endregion
|
|
1313
|
+
//#region src/views/mobile/MobileThreadCommentEditor.tsx
|
|
1314
|
+
const MobileThreadCommentEditor = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
|
|
1315
|
+
...props,
|
|
1316
|
+
ref,
|
|
1317
|
+
ActionRowComponent: _univerjs_design.MobileActionRowGroup
|
|
1318
|
+
}));
|
|
1319
|
+
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region src/views/mobile/MobileThreadCommentTree.tsx
|
|
1322
|
+
function MobileThreadCommentTree(props) {
|
|
1323
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentTree, {
|
|
1324
|
+
...props,
|
|
1325
|
+
DropdownComponent: _univerjs_design.MobileDropdown,
|
|
1326
|
+
EditorComponent: MobileThreadCommentEditor
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region src/views/mobile/MobileThreadCommentPanel.tsx
|
|
1332
|
+
function MobileThreadCommentPanel(props) {
|
|
1333
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentPanel, {
|
|
1334
|
+
...props,
|
|
1335
|
+
ActionRowComponent: _univerjs_design.MobileActionRowGroup,
|
|
1336
|
+
SelectComponent: _univerjs_design.MobileSelect,
|
|
1337
|
+
ThreadCommentTreeComponent: MobileThreadCommentTree
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
//#endregion
|
|
1342
|
+
exports.MobileThreadCommentPanel = MobileThreadCommentPanel;
|
|
1343
|
+
exports.MobileThreadCommentTree = MobileThreadCommentTree;
|
|
907
1344
|
exports.SetActiveCommentOperation = SetActiveCommentOperation;
|
|
1345
|
+
exports.ThreadCommentCanvasOverlay = ThreadCommentCanvasOverlay;
|
|
1346
|
+
Object.defineProperty(exports, 'ThreadCommentDraftService', {
|
|
1347
|
+
enumerable: true,
|
|
1348
|
+
get: function () {
|
|
1349
|
+
return ThreadCommentDraftService;
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
908
1352
|
exports.ThreadCommentPanel = ThreadCommentPanel;
|
|
909
1353
|
Object.defineProperty(exports, 'ThreadCommentPanelService', {
|
|
910
1354
|
enumerable: true,
|
|
@@ -914,6 +1358,12 @@ Object.defineProperty(exports, 'ThreadCommentPanelService', {
|
|
|
914
1358
|
});
|
|
915
1359
|
exports.ThreadCommentTree = ThreadCommentTree;
|
|
916
1360
|
exports.ThreadCommentTreeLocation = ThreadCommentTreeLocation;
|
|
1361
|
+
Object.defineProperty(exports, 'UniverThreadCommentMobileUIPlugin', {
|
|
1362
|
+
enumerable: true,
|
|
1363
|
+
get: function () {
|
|
1364
|
+
return UniverThreadCommentMobileUIPlugin;
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
917
1367
|
Object.defineProperty(exports, 'UniverThreadCommentUIPlugin', {
|
|
918
1368
|
enumerable: true,
|
|
919
1369
|
get: function () {
|