@univerjs/sheets-thread-comment-ui 0.5.5-nightly.202501210734 → 0.5.5-nightly.202501210925
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/es/index.js +583 -575
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/package.json +10 -10
package/lib/es/index.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { Inject, Disposable, DisposableCollection, CommandType, IUniverInstanceService, InterceptorEffectEnum, UniverInstanceType, Range, ICommandService, RANGE_TYPE, Rectangle, useDependency, Tools, DependentOn, Injector, Plugin, merge, IConfigService } from "@univerjs/core";
|
|
6
|
+
import { SheetsSelectionsService, getSheetCommandTarget, SheetInterceptorService, INTERCEPTOR_POINT, SheetPermissionCheckController, WorkbookCommentPermission, WorksheetViewPermission, RangeProtectionPermissionViewPoint, SetWorksheetActiveOperation, RemoveSheetCommand } from "@univerjs/sheets";
|
|
7
|
+
import { SheetsThreadCommentModel, UniverSheetsThreadCommentPlugin } from "@univerjs/sheets-thread-comment";
|
|
8
|
+
import { ThreadCommentPanelService, SetActiveCommentOperation, ThreadCommentTree, ThreadCommentPanel, ToggleSheetCommentPanelOperation, THREAD_COMMENT_PANEL, UniverThreadCommentUIPlugin } from "@univerjs/thread-comment-ui";
|
|
9
|
+
import { UniverThreadCommentUIPlugin as UniverThreadCommentUIPlugin2 } from "@univerjs/thread-comment-ui";
|
|
10
|
+
import { SheetCanvasPopManagerService, ISheetClipboardService, COPY_TYPE, HoverManagerService, IMarkSelectionService, IEditorBridgeService, SheetSkeletonManagerService, ScrollToRangeOperation, whenSheetEditorFocused, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
11
|
+
import { IZenZoneService, useObservable, KeyCode, MetaKeys, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService, IShortcutService } from "@univerjs/ui";
|
|
12
|
+
import { BehaviorSubject, debounceTime, map } from "rxjs";
|
|
13
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
14
|
+
import { singleReferenceToGrid, serializeRange } from "@univerjs/engine-formula";
|
|
15
|
+
import { IThreadCommentDataSourceService, DeleteCommentMutation, AddCommentMutation, ThreadCommentModel } from "@univerjs/thread-comment";
|
|
16
|
+
import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, IThreadCommentDataSourceService as IThreadCommentDataSourceService2, ResolveCommentCommand, UpdateCommentCommand } from "@univerjs/thread-comment";
|
|
17
|
+
import require$$0, { forwardRef, useRef, createElement, useMemo, useCallback, useEffect } from "react";
|
|
18
|
+
const SHEETS_THREAD_COMMENT_MODAL = "univer.sheet.thread-comment-modal", COMMENT_SINGLE_ICON = "comment-single", SHEETS_THREAD_COMMENT = "SHEET_THREAD_COMMENT";
|
|
19
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
20
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
21
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
22
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
23
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a;
|
|
24
|
+
let SheetsThreadCommentPopupService = (_a = class extends Disposable {
|
|
25
|
+
constructor(_canvasPopupManagerService, _zenZoneService) {
|
|
25
26
|
super();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this._canvasPopupManagerService =
|
|
27
|
+
__publicField(this, "_lastPopup", null);
|
|
28
|
+
__publicField(this, "_activePopup");
|
|
29
|
+
__publicField(this, "_activePopup$", new BehaviorSubject(null));
|
|
30
|
+
__publicField(this, "activePopup$", this._activePopup$.asObservable());
|
|
31
|
+
this._canvasPopupManagerService = _canvasPopupManagerService, this._zenZoneService = _zenZoneService, this._initZenVisible(), this.disposeWithMe(() => {
|
|
31
32
|
this._activePopup$.complete();
|
|
32
33
|
});
|
|
33
34
|
}
|
|
@@ -35,28 +36,28 @@ let O = class extends $ {
|
|
|
35
36
|
return this._activePopup;
|
|
36
37
|
}
|
|
37
38
|
_initZenVisible() {
|
|
38
|
-
this.disposeWithMe(this._zenZoneService.visible$.subscribe((
|
|
39
|
-
|
|
39
|
+
this.disposeWithMe(this._zenZoneService.visible$.subscribe((visible) => {
|
|
40
|
+
visible && this.hidePopup();
|
|
40
41
|
}));
|
|
41
42
|
}
|
|
42
|
-
showPopup(
|
|
43
|
-
var
|
|
44
|
-
const { row
|
|
45
|
-
if (this._activePopup &&
|
|
46
|
-
this._activePopup =
|
|
43
|
+
showPopup(location, onHide) {
|
|
44
|
+
var _a9;
|
|
45
|
+
const { row, col, unitId, subUnitId } = location;
|
|
46
|
+
if (this._activePopup && row === this._activePopup.row && col === this._activePopup.col && unitId === this._activePopup.unitId && subUnitId === ((_a9 = this.activePopup) == null ? void 0 : _a9.subUnitId)) {
|
|
47
|
+
this._activePopup = location, this._activePopup$.next(location);
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
if (this._lastPopup && this._lastPopup.dispose(), this._zenZoneService.visible)
|
|
50
51
|
return;
|
|
51
|
-
this._activePopup =
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
this._activePopup = location, this._activePopup$.next(location);
|
|
53
|
+
const popupDisposable = this._canvasPopupManagerService.attachPopupToCell(
|
|
54
|
+
row,
|
|
55
|
+
col,
|
|
55
56
|
{
|
|
56
|
-
componentKey:
|
|
57
|
-
onClickOutside: () => {
|
|
57
|
+
componentKey: SHEETS_THREAD_COMMENT_MODAL,
|
|
58
|
+
onClickOutside: /* @__PURE__ */ __name(() => {
|
|
58
59
|
this.hidePopup();
|
|
59
|
-
},
|
|
60
|
+
}, "onClickOutside"),
|
|
60
61
|
direction: "horizontal",
|
|
61
62
|
excludeOutside: [
|
|
62
63
|
...Array.from(document.querySelectorAll(".univer-thread-comment")),
|
|
@@ -64,14 +65,14 @@ let O = class extends $ {
|
|
|
64
65
|
].filter(Boolean)
|
|
65
66
|
}
|
|
66
67
|
);
|
|
67
|
-
if (!
|
|
68
|
+
if (!popupDisposable)
|
|
68
69
|
throw new Error("[SheetsThreadCommentPopupService]: cannot show popup!");
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
dispose: () => {
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}), this._lastPopup =
|
|
70
|
+
const disposableCollection = new DisposableCollection();
|
|
71
|
+
disposableCollection.add(popupDisposable), disposableCollection.add({
|
|
72
|
+
dispose: /* @__PURE__ */ __name(() => {
|
|
73
|
+
onHide == null || onHide();
|
|
74
|
+
}, "dispose")
|
|
75
|
+
}), this._lastPopup = disposableCollection;
|
|
75
76
|
}
|
|
76
77
|
hidePopup() {
|
|
77
78
|
this._activePopup && (this._lastPopup && this._lastPopup.dispose(), this._lastPopup = null, this._activePopup = null, this._activePopup$.next(null));
|
|
@@ -82,188 +83,189 @@ let O = class extends $ {
|
|
|
82
83
|
temp: !1
|
|
83
84
|
}, this._activePopup$.next(this._activePopup));
|
|
84
85
|
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
],
|
|
90
|
-
const
|
|
91
|
-
type:
|
|
86
|
+
}, __name(_a, "SheetsThreadCommentPopupService"), _a);
|
|
87
|
+
SheetsThreadCommentPopupService = __decorateClass$7([
|
|
88
|
+
__decorateParam$7(0, Inject(SheetCanvasPopManagerService)),
|
|
89
|
+
__decorateParam$7(1, IZenZoneService)
|
|
90
|
+
], SheetsThreadCommentPopupService);
|
|
91
|
+
const ShowAddSheetCommentModalOperation = {
|
|
92
|
+
type: CommandType.OPERATION,
|
|
92
93
|
id: "sheets.operation.show-comment-modal",
|
|
93
|
-
handler(
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
94
|
+
handler(accessor) {
|
|
95
|
+
var _a9;
|
|
96
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), sheetsThreadCommentPopupService = accessor.get(SheetsThreadCommentPopupService), threadCommentPanelService = accessor.get(ThreadCommentPanelService), activeCell = (_a9 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a9.primary, model = accessor.get(SheetsThreadCommentModel);
|
|
97
|
+
if (!activeCell)
|
|
97
98
|
return !1;
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
99
|
+
const result = getSheetCommandTarget(univerInstanceService);
|
|
100
|
+
if (!result)
|
|
100
101
|
return !1;
|
|
101
|
-
const { workbook
|
|
102
|
-
workbook
|
|
103
|
-
worksheet
|
|
104
|
-
unitId
|
|
105
|
-
subUnitId
|
|
106
|
-
row:
|
|
107
|
-
col:
|
|
102
|
+
const { workbook, worksheet, unitId, subUnitId } = result, location = {
|
|
103
|
+
workbook,
|
|
104
|
+
worksheet,
|
|
105
|
+
unitId,
|
|
106
|
+
subUnitId,
|
|
107
|
+
row: activeCell.startRow,
|
|
108
|
+
col: activeCell.startColumn
|
|
108
109
|
};
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
unitId
|
|
113
|
-
subUnitId
|
|
114
|
-
commentId:
|
|
110
|
+
sheetsThreadCommentPopupService.showPopup(location);
|
|
111
|
+
const rootId = model.getByLocation(unitId, subUnitId, activeCell.startRow, activeCell.startColumn);
|
|
112
|
+
return rootId && threadCommentPanelService.setActiveComment({
|
|
113
|
+
unitId,
|
|
114
|
+
subUnitId,
|
|
115
|
+
commentId: rootId,
|
|
115
116
|
trigger: "context-menu"
|
|
116
117
|
}), !0;
|
|
117
118
|
}
|
|
118
|
-
},
|
|
119
|
-
var
|
|
120
|
-
for (var
|
|
121
|
-
(
|
|
122
|
-
return
|
|
123
|
-
},
|
|
124
|
-
let
|
|
125
|
-
constructor(
|
|
126
|
-
super(), this._sheetInterceptorService =
|
|
119
|
+
}, SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY = "sheets-thread-comment.config", defaultPluginConfig = {};
|
|
120
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
121
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
122
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
123
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
124
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a2;
|
|
125
|
+
let SheetsThreadCommentRenderController = (_a2 = class extends Disposable {
|
|
126
|
+
constructor(_sheetInterceptorService, _sheetsThreadCommentModel, _univerInstanceService, _renderManagerService) {
|
|
127
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._univerInstanceService = _univerInstanceService, this._renderManagerService = _renderManagerService, this._initViewModelIntercept(), this._initSkeletonChange();
|
|
127
128
|
}
|
|
128
129
|
_initViewModelIntercept() {
|
|
129
130
|
this.disposeWithMe(
|
|
130
131
|
this._sheetInterceptorService.intercept(
|
|
131
|
-
|
|
132
|
+
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
132
133
|
{
|
|
133
|
-
effect:
|
|
134
|
-
handler: (
|
|
135
|
-
const { row
|
|
136
|
-
return this._sheetsThreadCommentModel.showCommentMarker(
|
|
137
|
-
...
|
|
134
|
+
effect: InterceptorEffectEnum.Style,
|
|
135
|
+
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
136
|
+
const { row, col, unitId, subUnitId } = pos;
|
|
137
|
+
return this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col) ? next({
|
|
138
|
+
...cell,
|
|
138
139
|
markers: {
|
|
139
|
-
...
|
|
140
|
+
...cell == null ? void 0 : cell.markers,
|
|
140
141
|
tr: {
|
|
141
142
|
color: "#FFBD37",
|
|
142
143
|
size: 6
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
|
-
}) :
|
|
146
|
-
},
|
|
146
|
+
}) : next(cell);
|
|
147
|
+
}, "handler"),
|
|
147
148
|
priority: 100
|
|
148
149
|
}
|
|
149
150
|
)
|
|
150
151
|
);
|
|
151
152
|
}
|
|
152
153
|
_initSkeletonChange() {
|
|
153
|
-
const
|
|
154
|
-
var
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
157
|
-
const
|
|
158
|
-
(
|
|
159
|
-
};
|
|
160
|
-
this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(
|
|
161
|
-
|
|
154
|
+
const markSkeletonDirty = /* @__PURE__ */ __name(() => {
|
|
155
|
+
var _a9;
|
|
156
|
+
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
157
|
+
if (!workbook) return;
|
|
158
|
+
const unitId = workbook.getUnitId(), currentRender = this._renderManagerService.getRenderById(unitId);
|
|
159
|
+
(_a9 = currentRender == null ? void 0 : currentRender.mainComponent) == null || _a9.makeForceDirty();
|
|
160
|
+
}, "markSkeletonDirty");
|
|
161
|
+
this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.pipe(debounceTime(16)).subscribe(() => {
|
|
162
|
+
markSkeletonDirty();
|
|
162
163
|
}));
|
|
163
164
|
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
],
|
|
171
|
-
var
|
|
172
|
-
for (var
|
|
173
|
-
(
|
|
174
|
-
return
|
|
175
|
-
},
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
startColumn:
|
|
179
|
-
startRow:
|
|
180
|
-
endColumn:
|
|
181
|
-
endRow:
|
|
165
|
+
}, __name(_a2, "SheetsThreadCommentRenderController"), _a2);
|
|
166
|
+
SheetsThreadCommentRenderController = __decorateClass$6([
|
|
167
|
+
__decorateParam$6(0, Inject(SheetInterceptorService)),
|
|
168
|
+
__decorateParam$6(1, Inject(SheetsThreadCommentModel)),
|
|
169
|
+
__decorateParam$6(2, IUniverInstanceService),
|
|
170
|
+
__decorateParam$6(3, IRenderManagerService)
|
|
171
|
+
], SheetsThreadCommentRenderController);
|
|
172
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
173
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
174
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
175
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
176
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
|
|
177
|
+
const transformRef = /* @__PURE__ */ __name((ref, source, target) => {
|
|
178
|
+
const refObj = singleReferenceToGrid(ref), offsetRow = target.row - source.row, offsetCol = target.column - source.column, targetRange = {
|
|
179
|
+
startColumn: refObj.column + offsetCol,
|
|
180
|
+
startRow: refObj.row + offsetRow,
|
|
181
|
+
endColumn: refObj.column + offsetCol,
|
|
182
|
+
endRow: refObj.row + offsetRow
|
|
182
183
|
};
|
|
183
|
-
return
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
return serializeRange(targetRange);
|
|
185
|
+
}, "transformRef");
|
|
186
|
+
var _a3;
|
|
187
|
+
let SheetsThreadCommentCopyPasteController = (_a3 = class extends Disposable {
|
|
188
|
+
constructor(_sheetClipboardService, _sheetsThreadCommentModel, _threadCommentDataSourceService) {
|
|
187
189
|
super();
|
|
188
|
-
|
|
189
|
-
this._sheetClipboardService =
|
|
190
|
+
__publicField(this, "_copyInfo");
|
|
191
|
+
this._sheetClipboardService = _sheetClipboardService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initClipboardHook();
|
|
190
192
|
}
|
|
191
193
|
// eslint-disable-next-line max-lines-per-function
|
|
192
194
|
_initClipboardHook() {
|
|
193
195
|
this.disposeWithMe(
|
|
194
196
|
this._sheetClipboardService.addClipboardHook({
|
|
195
|
-
id:
|
|
196
|
-
onBeforeCopy: (
|
|
197
|
+
id: SHEETS_THREAD_COMMENT,
|
|
198
|
+
onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => {
|
|
197
199
|
this._copyInfo = {
|
|
198
|
-
unitId
|
|
199
|
-
subUnitId
|
|
200
|
-
range
|
|
200
|
+
unitId,
|
|
201
|
+
subUnitId,
|
|
202
|
+
range
|
|
201
203
|
};
|
|
202
|
-
},
|
|
204
|
+
}, "onBeforeCopy"),
|
|
203
205
|
// eslint-disable-next-line max-lines-per-function
|
|
204
|
-
onPasteCells: (
|
|
205
|
-
const { unitId:
|
|
206
|
-
row:
|
|
207
|
-
column:
|
|
206
|
+
onPasteCells: /* @__PURE__ */ __name((_pasteFrom, pasteTo, _data, payload) => {
|
|
207
|
+
const { unitId: targetUnitId, subUnitId: targetSubUnitId, range } = pasteTo, targetPos = {
|
|
208
|
+
row: range.rows[0],
|
|
209
|
+
column: range.cols[0]
|
|
208
210
|
};
|
|
209
|
-
if (
|
|
210
|
-
const { range:
|
|
211
|
-
row:
|
|
212
|
-
column:
|
|
211
|
+
if (payload.copyType === COPY_TYPE.CUT && this._copyInfo) {
|
|
212
|
+
const { range: range2, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._copyInfo, sourcePos = {
|
|
213
|
+
row: range2.startRow,
|
|
214
|
+
column: range2.startColumn
|
|
213
215
|
};
|
|
214
|
-
if (!(
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
this._threadCommentDataSourceService.syncUpdateMutationToColla ?
|
|
219
|
-
|
|
220
|
-
}) :
|
|
221
|
-
|
|
216
|
+
if (!(targetUnitId === sourceUnitId && targetSubUnitId === sourceSubUnitId)) {
|
|
217
|
+
const roots = [];
|
|
218
|
+
Range.foreach(range2, (row, col) => {
|
|
219
|
+
const comments = this._sheetsThreadCommentModel.getAllByLocation(sourceUnitId, sourceSubUnitId, row, col);
|
|
220
|
+
this._threadCommentDataSourceService.syncUpdateMutationToColla ? comments.forEach((comment) => {
|
|
221
|
+
roots.push(comment);
|
|
222
|
+
}) : comments.forEach(({ children, ...comment }) => {
|
|
223
|
+
comment.parentId || roots.push(comment);
|
|
222
224
|
});
|
|
223
225
|
});
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
id:
|
|
226
|
+
const sourceRedos = [], sourceUndos = [], targetRedos = [], targetUndos = [], handleCommentItem = /* @__PURE__ */ __name((item) => {
|
|
227
|
+
sourceRedos.unshift({
|
|
228
|
+
id: DeleteCommentMutation.id,
|
|
227
229
|
params: {
|
|
228
|
-
unitId:
|
|
229
|
-
subUnitId:
|
|
230
|
-
commentId:
|
|
230
|
+
unitId: sourceUnitId,
|
|
231
|
+
subUnitId: sourceSubUnitId,
|
|
232
|
+
commentId: item.id
|
|
231
233
|
}
|
|
232
|
-
}),
|
|
233
|
-
id:
|
|
234
|
+
}), targetRedos.push({
|
|
235
|
+
id: AddCommentMutation.id,
|
|
234
236
|
params: {
|
|
235
|
-
unitId:
|
|
236
|
-
subUnitId:
|
|
237
|
+
unitId: targetUnitId,
|
|
238
|
+
subUnitId: targetSubUnitId,
|
|
237
239
|
comment: {
|
|
238
|
-
...
|
|
239
|
-
ref:
|
|
240
|
-
unitId:
|
|
241
|
-
subUnitId:
|
|
240
|
+
...item,
|
|
241
|
+
ref: transformRef(item.ref, sourcePos, targetPos),
|
|
242
|
+
unitId: targetUnitId,
|
|
243
|
+
subUnitId: targetSubUnitId
|
|
242
244
|
},
|
|
243
245
|
sync: !0
|
|
244
246
|
}
|
|
245
|
-
}),
|
|
246
|
-
id:
|
|
247
|
+
}), sourceUndos.push({
|
|
248
|
+
id: AddCommentMutation.id,
|
|
247
249
|
params: {
|
|
248
|
-
unitId:
|
|
249
|
-
subUnitId:
|
|
250
|
-
comment:
|
|
250
|
+
unitId: sourceUnitId,
|
|
251
|
+
subUnitId: sourceSubUnitId,
|
|
252
|
+
comment: item,
|
|
251
253
|
sync: !0
|
|
252
254
|
}
|
|
253
|
-
}),
|
|
254
|
-
id:
|
|
255
|
+
}), targetUndos.unshift({
|
|
256
|
+
id: DeleteCommentMutation.id,
|
|
255
257
|
params: {
|
|
256
|
-
unitId:
|
|
257
|
-
subUnitId:
|
|
258
|
-
commentId:
|
|
258
|
+
unitId: targetUnitId,
|
|
259
|
+
subUnitId: targetSubUnitId,
|
|
260
|
+
commentId: item.id
|
|
259
261
|
}
|
|
260
262
|
});
|
|
261
|
-
};
|
|
262
|
-
return
|
|
263
|
-
|
|
263
|
+
}, "handleCommentItem");
|
|
264
|
+
return roots.forEach((root) => {
|
|
265
|
+
handleCommentItem(root);
|
|
264
266
|
}), {
|
|
265
|
-
redos: [...
|
|
266
|
-
undos: [...
|
|
267
|
+
redos: [...sourceRedos, ...targetRedos],
|
|
268
|
+
undos: [...targetUndos, ...sourceUndos]
|
|
267
269
|
};
|
|
268
270
|
}
|
|
269
271
|
}
|
|
@@ -271,188 +273,188 @@ let Z = class extends $ {
|
|
|
271
273
|
redos: [],
|
|
272
274
|
undos: []
|
|
273
275
|
};
|
|
274
|
-
}
|
|
276
|
+
}, "onPasteCells")
|
|
275
277
|
})
|
|
276
278
|
);
|
|
277
279
|
}
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
],
|
|
284
|
-
var
|
|
285
|
-
for (var
|
|
286
|
-
(
|
|
287
|
-
return
|
|
288
|
-
},
|
|
289
|
-
let
|
|
290
|
-
constructor(
|
|
291
|
-
super(), this._hoverManagerService =
|
|
280
|
+
}, __name(_a3, "SheetsThreadCommentCopyPasteController"), _a3);
|
|
281
|
+
SheetsThreadCommentCopyPasteController = __decorateClass$5([
|
|
282
|
+
__decorateParam$5(0, Inject(ISheetClipboardService)),
|
|
283
|
+
__decorateParam$5(1, Inject(SheetsThreadCommentModel)),
|
|
284
|
+
__decorateParam$5(2, IThreadCommentDataSourceService)
|
|
285
|
+
], SheetsThreadCommentCopyPasteController);
|
|
286
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
287
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
288
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
289
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
290
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a4;
|
|
291
|
+
let SheetsThreadCommentHoverController = (_a4 = class extends Disposable {
|
|
292
|
+
constructor(_hoverManagerService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _sheetPermissionCheckController) {
|
|
293
|
+
super(), this._hoverManagerService = _hoverManagerService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._sheetPermissionCheckController = _sheetPermissionCheckController, this._initHoverEvent();
|
|
292
294
|
}
|
|
293
295
|
_initHoverEvent() {
|
|
294
296
|
this.disposeWithMe(
|
|
295
|
-
this._hoverManagerService.currentCell$.pipe(
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
298
|
-
const { location
|
|
299
|
-
if (
|
|
297
|
+
this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cell) => {
|
|
298
|
+
const currentPopup = this._sheetsThreadCommentPopupService.activePopup;
|
|
299
|
+
if (cell && (currentPopup && currentPopup.temp || !currentPopup)) {
|
|
300
|
+
const { location } = cell, { unitId, subUnitId, row, col } = location, commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
|
|
301
|
+
if (commentId) {
|
|
300
302
|
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
301
|
-
workbookTypes: [
|
|
302
|
-
worksheetTypes: [
|
|
303
|
-
rangeTypes: [
|
|
304
|
-
}, [{ startRow:
|
|
303
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
304
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
305
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
306
|
+
}, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
|
|
305
307
|
return;
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
unitId
|
|
309
|
-
subUnitId
|
|
310
|
-
row
|
|
311
|
-
col
|
|
312
|
-
commentId
|
|
308
|
+
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
309
|
+
comment && !comment.resolved && this._sheetsThreadCommentPopupService.showPopup({
|
|
310
|
+
unitId,
|
|
311
|
+
subUnitId,
|
|
312
|
+
row,
|
|
313
|
+
col,
|
|
314
|
+
commentId,
|
|
313
315
|
temp: !0
|
|
314
316
|
});
|
|
315
317
|
} else
|
|
316
|
-
|
|
318
|
+
currentPopup && this._sheetsThreadCommentPopupService.hidePopup();
|
|
317
319
|
}
|
|
318
320
|
})
|
|
319
321
|
);
|
|
320
322
|
}
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
],
|
|
328
|
-
var
|
|
329
|
-
for (var
|
|
330
|
-
(
|
|
331
|
-
return
|
|
332
|
-
},
|
|
333
|
-
let
|
|
334
|
-
constructor(
|
|
323
|
+
}, __name(_a4, "SheetsThreadCommentHoverController"), _a4);
|
|
324
|
+
SheetsThreadCommentHoverController = __decorateClass$4([
|
|
325
|
+
__decorateParam$4(0, Inject(HoverManagerService)),
|
|
326
|
+
__decorateParam$4(1, Inject(SheetsThreadCommentPopupService)),
|
|
327
|
+
__decorateParam$4(2, Inject(SheetsThreadCommentModel)),
|
|
328
|
+
__decorateParam$4(3, Inject(SheetPermissionCheckController))
|
|
329
|
+
], SheetsThreadCommentHoverController);
|
|
330
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
331
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
332
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
333
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
334
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a5;
|
|
335
|
+
let SheetsThreadCommentPopupController = (_a5 = class extends Disposable {
|
|
336
|
+
constructor(_commandService, _sheetsThreadCommentPopupService, _sheetsThreadCommentModel, _threadCommentPanelService, _univerInstanceService, _sheetPermissionCheckController, _markSelectionService, _sheetSelectionService, _editorBridgeService, _renderManagerService) {
|
|
335
337
|
super();
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
this._commandService =
|
|
339
|
-
}
|
|
340
|
-
_handleSelectionChange(
|
|
341
|
-
var
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
338
|
+
__publicField(this, "_isSwitchToCommenting", !1);
|
|
339
|
+
__publicField(this, "_selectionShapeInfo", null);
|
|
340
|
+
this._commandService = _commandService, this._sheetsThreadCommentPopupService = _sheetsThreadCommentPopupService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentPanelService = _threadCommentPanelService, this._univerInstanceService = _univerInstanceService, this._sheetPermissionCheckController = _sheetPermissionCheckController, this._markSelectionService = _markSelectionService, this._sheetSelectionService = _sheetSelectionService, this._editorBridgeService = _editorBridgeService, this._renderManagerService = _renderManagerService, this._initCommandListener(), this._initPanelListener(), this._initMarkSelection(), this._initSelectionUpdateListener(), this._initEditorBridge();
|
|
341
|
+
}
|
|
342
|
+
_handleSelectionChange(selections, unitId, subUnitId) {
|
|
343
|
+
var _a9, _b, _c;
|
|
344
|
+
const range = (_a9 = selections[0]) == null ? void 0 : _a9.range, render2 = this._renderManagerService.getRenderById(unitId), skeleton = (_b = render2 == null ? void 0 : render2.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b.skeleton;
|
|
345
|
+
if (!skeleton || !range)
|
|
344
346
|
return;
|
|
345
|
-
const
|
|
346
|
-
if ((((
|
|
347
|
-
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(
|
|
347
|
+
const actualCell = skeleton.getCellWithCoordByIndex(range.startRow, range.startColumn);
|
|
348
|
+
if ((((_c = range.rangeType) != null ? _c : RANGE_TYPE.NORMAL) !== RANGE_TYPE.NORMAL || range.endColumn - range.startColumn > 0 || range.endRow - range.startRow > 0) && !((actualCell.isMerged || actualCell.isMergedMainCell) && Rectangle.equals(actualCell.mergeInfo, range))) {
|
|
349
|
+
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
|
|
348
350
|
return;
|
|
349
351
|
}
|
|
350
|
-
const
|
|
351
|
-
if (!this._sheetsThreadCommentModel.showCommentMarker(
|
|
352
|
-
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(
|
|
352
|
+
const row = actualCell.actualRow, col = actualCell.actualColumn;
|
|
353
|
+
if (!this._sheetsThreadCommentModel.showCommentMarker(unitId, subUnitId, row, col)) {
|
|
354
|
+
this._threadCommentPanelService.activeCommentId && this._commandService.executeCommand(SetActiveCommentOperation.id);
|
|
353
355
|
return;
|
|
354
356
|
}
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
unitId
|
|
358
|
-
subUnitId
|
|
359
|
-
commentId
|
|
357
|
+
const commentId = this._sheetsThreadCommentModel.getByLocation(unitId, subUnitId, row, col);
|
|
358
|
+
commentId && this._commandService.executeCommand(SetActiveCommentOperation.id, {
|
|
359
|
+
unitId,
|
|
360
|
+
subUnitId,
|
|
361
|
+
commentId
|
|
360
362
|
});
|
|
361
363
|
}
|
|
362
364
|
_initSelectionUpdateListener() {
|
|
363
365
|
this.disposeWithMe(
|
|
364
|
-
this._sheetSelectionService.selectionMoveEnd$.subscribe((
|
|
366
|
+
this._sheetSelectionService.selectionMoveEnd$.subscribe((selections) => {
|
|
365
367
|
if (this._isSwitchToCommenting)
|
|
366
368
|
return;
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
+
const current = this._sheetSelectionService.currentSelectionParam;
|
|
370
|
+
current && this._handleSelectionChange(selections, current.unitId, current.sheetId);
|
|
369
371
|
})
|
|
370
372
|
);
|
|
371
373
|
}
|
|
372
374
|
_initEditorBridge() {
|
|
373
375
|
this.disposeWithMe(
|
|
374
|
-
this._editorBridgeService.visible$.subscribe((
|
|
375
|
-
|
|
376
|
+
this._editorBridgeService.visible$.subscribe((visible) => {
|
|
377
|
+
visible.visible && this._sheetsThreadCommentPopupService.hidePopup();
|
|
376
378
|
})
|
|
377
379
|
);
|
|
378
380
|
}
|
|
379
381
|
_initCommandListener() {
|
|
380
|
-
this._commandService.onCommandExecuted((
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
382
|
+
this._commandService.onCommandExecuted((commandInfo) => {
|
|
383
|
+
if (commandInfo.id === DeleteCommentMutation.id) {
|
|
384
|
+
const params = commandInfo.params, active = this._sheetsThreadCommentPopupService.activePopup;
|
|
385
|
+
if (!active)
|
|
384
386
|
return;
|
|
385
|
-
const { unitId
|
|
386
|
-
|
|
387
|
+
const { unitId, subUnitId, commentId } = active;
|
|
388
|
+
params.unitId === unitId && params.subUnitId === subUnitId && params.commentId === commentId && this._sheetsThreadCommentPopupService.hidePopup();
|
|
387
389
|
}
|
|
388
390
|
});
|
|
389
391
|
}
|
|
390
392
|
_initPanelListener() {
|
|
391
|
-
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (
|
|
392
|
-
var
|
|
393
|
-
if (
|
|
394
|
-
const { unitId
|
|
395
|
-
if (!
|
|
393
|
+
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.subscribe(async (commentInfo) => {
|
|
394
|
+
var _a9;
|
|
395
|
+
if (commentInfo) {
|
|
396
|
+
const { unitId, subUnitId, commentId, trigger } = commentInfo, comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
397
|
+
if (!comment || comment.resolved)
|
|
396
398
|
return;
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
399
|
+
const currentUnit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
400
|
+
if (!currentUnit || currentUnit.getUnitId() !== unitId)
|
|
399
401
|
return;
|
|
400
|
-
this._isSwitchToCommenting = !0, ((
|
|
401
|
-
unitId
|
|
402
|
-
subUnitId
|
|
402
|
+
this._isSwitchToCommenting = !0, ((_a9 = currentUnit.getActiveSheet()) == null ? void 0 : _a9.getSheetId()) !== subUnitId && await this._commandService.executeCommand(SetWorksheetActiveOperation.id, {
|
|
403
|
+
unitId,
|
|
404
|
+
subUnitId
|
|
403
405
|
}), this._isSwitchToCommenting = !1;
|
|
404
|
-
const
|
|
406
|
+
const location = singleReferenceToGrid(comment.ref), { row, column: col } = location;
|
|
405
407
|
if (!this._sheetPermissionCheckController.permissionCheckWithRanges({
|
|
406
|
-
workbookTypes: [
|
|
407
|
-
worksheetTypes: [
|
|
408
|
-
rangeTypes: [
|
|
409
|
-
}, [{ startRow:
|
|
408
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
409
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
410
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
411
|
+
}, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]))
|
|
410
412
|
return;
|
|
411
|
-
const
|
|
412
|
-
if (await this._commandService.executeCommand(
|
|
413
|
+
const GAP = 1;
|
|
414
|
+
if (await this._commandService.executeCommand(ScrollToRangeOperation.id, {
|
|
413
415
|
range: {
|
|
414
|
-
startRow: Math.max(
|
|
415
|
-
endRow:
|
|
416
|
-
startColumn: Math.max(
|
|
417
|
-
endColumn:
|
|
416
|
+
startRow: Math.max(location.row - GAP, 0),
|
|
417
|
+
endRow: location.row + GAP,
|
|
418
|
+
startColumn: Math.max(location.column - GAP, 0),
|
|
419
|
+
endColumn: location.column + GAP
|
|
418
420
|
}
|
|
419
421
|
}), this._editorBridgeService.isVisible().visible)
|
|
420
422
|
return;
|
|
421
423
|
this._sheetsThreadCommentPopupService.showPopup({
|
|
422
|
-
unitId
|
|
423
|
-
subUnitId
|
|
424
|
-
row:
|
|
425
|
-
col:
|
|
426
|
-
commentId:
|
|
427
|
-
trigger
|
|
424
|
+
unitId,
|
|
425
|
+
subUnitId,
|
|
426
|
+
row: location.row,
|
|
427
|
+
col: location.column,
|
|
428
|
+
commentId: comment.id,
|
|
429
|
+
trigger
|
|
428
430
|
});
|
|
429
431
|
} else
|
|
430
432
|
this._sheetsThreadCommentPopupService.hidePopup();
|
|
431
433
|
}));
|
|
432
434
|
}
|
|
433
435
|
_initMarkSelection() {
|
|
434
|
-
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(
|
|
435
|
-
var
|
|
436
|
-
if (!
|
|
436
|
+
this.disposeWithMe(this._threadCommentPanelService.activeCommentId$.pipe(debounceTime(100)).subscribe((activeComment) => {
|
|
437
|
+
var _a9, _b;
|
|
438
|
+
if (!activeComment) {
|
|
437
439
|
this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
|
|
438
440
|
return;
|
|
439
441
|
}
|
|
440
|
-
const { unitId
|
|
442
|
+
const { unitId, subUnitId, commentId } = activeComment;
|
|
441
443
|
this._selectionShapeInfo && (this._markSelectionService.removeShape(this._selectionShapeInfo.shapeId), this._selectionShapeInfo = null);
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
444
|
+
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
445
|
+
if (!comment)
|
|
444
446
|
return;
|
|
445
|
-
const
|
|
446
|
-
if (Number.isNaN(
|
|
447
|
+
const location = singleReferenceToGrid(comment.ref), { row, column } = location;
|
|
448
|
+
if (Number.isNaN(row) || Number.isNaN(column))
|
|
447
449
|
return null;
|
|
448
|
-
const
|
|
449
|
-
startColumn:
|
|
450
|
-
endColumn:
|
|
451
|
-
startRow:
|
|
452
|
-
endRow:
|
|
453
|
-
},
|
|
450
|
+
const worksheet = (_a9 = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a9.getSheetBySheetId(subUnitId), mergeInfo = (_b = worksheet == null ? void 0 : worksheet.getMergedCell(row, column)) != null ? _b : {
|
|
451
|
+
startColumn: column,
|
|
452
|
+
endColumn: column,
|
|
453
|
+
startRow: row,
|
|
454
|
+
endRow: row
|
|
455
|
+
}, shapeId = this._markSelectionService.addShape(
|
|
454
456
|
{
|
|
455
|
-
range:
|
|
457
|
+
range: mergeInfo,
|
|
456
458
|
style: {
|
|
457
459
|
// hasAutoFill: false,
|
|
458
460
|
fill: "rgb(255, 189, 55, 0.35)",
|
|
@@ -465,131 +467,135 @@ let q = class extends $ {
|
|
|
465
467
|
[],
|
|
466
468
|
-1
|
|
467
469
|
);
|
|
468
|
-
|
|
469
|
-
...
|
|
470
|
-
shapeId
|
|
470
|
+
shapeId && (this._selectionShapeInfo = {
|
|
471
|
+
...activeComment,
|
|
472
|
+
shapeId
|
|
471
473
|
});
|
|
472
474
|
}));
|
|
473
475
|
}
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
],
|
|
487
|
-
var
|
|
488
|
-
for (var
|
|
489
|
-
(
|
|
490
|
-
return
|
|
491
|
-
},
|
|
492
|
-
let
|
|
493
|
-
constructor(
|
|
494
|
-
super(), this._sheetInterceptorService =
|
|
476
|
+
}, __name(_a5, "SheetsThreadCommentPopupController"), _a5);
|
|
477
|
+
SheetsThreadCommentPopupController = __decorateClass$3([
|
|
478
|
+
__decorateParam$3(0, ICommandService),
|
|
479
|
+
__decorateParam$3(1, Inject(SheetsThreadCommentPopupService)),
|
|
480
|
+
__decorateParam$3(2, Inject(SheetsThreadCommentModel)),
|
|
481
|
+
__decorateParam$3(3, Inject(ThreadCommentPanelService)),
|
|
482
|
+
__decorateParam$3(4, IUniverInstanceService),
|
|
483
|
+
__decorateParam$3(5, Inject(SheetPermissionCheckController)),
|
|
484
|
+
__decorateParam$3(6, IMarkSelectionService),
|
|
485
|
+
__decorateParam$3(7, Inject(SheetsSelectionsService)),
|
|
486
|
+
__decorateParam$3(8, IEditorBridgeService),
|
|
487
|
+
__decorateParam$3(9, IRenderManagerService)
|
|
488
|
+
], SheetsThreadCommentPopupController);
|
|
489
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
490
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
491
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
492
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
493
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a6;
|
|
494
|
+
let ThreadCommentRemoveSheetsController = (_a6 = class extends Disposable {
|
|
495
|
+
constructor(_sheetInterceptorService, _univerInstanceService, _threadCommentModel, _threadCommentDataSourceService) {
|
|
496
|
+
super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._threadCommentModel = _threadCommentModel, this._threadCommentDataSourceService = _threadCommentDataSourceService, this._initSheetChange();
|
|
495
497
|
}
|
|
496
498
|
_initSheetChange() {
|
|
497
499
|
this.disposeWithMe(
|
|
498
500
|
this._sheetInterceptorService.interceptCommand({
|
|
499
|
-
getMutations: (
|
|
500
|
-
var
|
|
501
|
-
if (
|
|
502
|
-
const
|
|
503
|
-
if (!
|
|
501
|
+
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
502
|
+
var _a9;
|
|
503
|
+
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
504
|
+
const params = commandInfo.params, workbook = params.unitId ? this._univerInstanceService.getUnit(params.unitId) : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
505
|
+
if (!workbook)
|
|
504
506
|
return { redos: [], undos: [] };
|
|
505
|
-
const
|
|
506
|
-
if (!
|
|
507
|
+
const unitId = workbook.getUnitId(), subUnitId = params.subUnitId || ((_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId());
|
|
508
|
+
if (!subUnitId)
|
|
507
509
|
return { redos: [], undos: [] };
|
|
508
|
-
const
|
|
509
|
-
id:
|
|
510
|
+
const commentMap = this._threadCommentModel.ensureMap(unitId, subUnitId), comments = Array.from(commentMap.values()).filter((comment) => !comment.parentId), ids = comments.map((comment) => comment.id), shouldSync = this._threadCommentDataSourceService.syncUpdateMutationToColla, redos = ids.map((id) => ({
|
|
511
|
+
id: DeleteCommentMutation.id,
|
|
510
512
|
params: {
|
|
511
|
-
unitId
|
|
512
|
-
subUnitId
|
|
513
|
-
commentId:
|
|
513
|
+
unitId,
|
|
514
|
+
subUnitId,
|
|
515
|
+
commentId: id
|
|
514
516
|
}
|
|
515
|
-
})),
|
|
516
|
-
id:
|
|
517
|
+
})), undos = comments.map(({ children, ...comment }) => ({
|
|
518
|
+
id: AddCommentMutation.id,
|
|
517
519
|
params: {
|
|
518
|
-
unitId
|
|
519
|
-
subUnitId
|
|
520
|
+
unitId,
|
|
521
|
+
subUnitId,
|
|
520
522
|
comment: {
|
|
521
|
-
...
|
|
522
|
-
children:
|
|
523
|
+
...comment,
|
|
524
|
+
children: shouldSync ? children : void 0
|
|
523
525
|
},
|
|
524
|
-
sync: !
|
|
526
|
+
sync: !shouldSync
|
|
525
527
|
}
|
|
526
528
|
}));
|
|
527
|
-
return { redos
|
|
529
|
+
return { redos, undos };
|
|
528
530
|
}
|
|
529
531
|
return { redos: [], undos: [] };
|
|
530
|
-
}
|
|
532
|
+
}, "getMutations")
|
|
531
533
|
})
|
|
532
534
|
);
|
|
533
535
|
}
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
],
|
|
541
|
-
var
|
|
542
|
-
return
|
|
543
|
-
for (var
|
|
544
|
-
|
|
545
|
-
for (var
|
|
536
|
+
}, __name(_a6, "ThreadCommentRemoveSheetsController"), _a6);
|
|
537
|
+
ThreadCommentRemoveSheetsController = __decorateClass$2([
|
|
538
|
+
__decorateParam$2(0, Inject(SheetInterceptorService)),
|
|
539
|
+
__decorateParam$2(1, IUniverInstanceService),
|
|
540
|
+
__decorateParam$2(2, Inject(ThreadCommentModel)),
|
|
541
|
+
__decorateParam$2(3, IThreadCommentDataSourceService)
|
|
542
|
+
], ThreadCommentRemoveSheetsController);
|
|
543
|
+
var __assign = function() {
|
|
544
|
+
return __assign = Object.assign || function(t) {
|
|
545
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
546
|
+
s = arguments[i];
|
|
547
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
546
548
|
}
|
|
547
|
-
return
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
var
|
|
551
|
-
for (var
|
|
552
|
-
if (
|
|
553
|
-
for (var
|
|
554
|
-
e.indexOf(
|
|
555
|
-
return
|
|
556
|
-
},
|
|
557
|
-
var
|
|
558
|
-
return
|
|
549
|
+
return t;
|
|
550
|
+
}, __assign.apply(this, arguments);
|
|
551
|
+
}, __rest = function(s, e) {
|
|
552
|
+
var t = {};
|
|
553
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
554
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
555
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
556
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
557
|
+
return t;
|
|
558
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
559
|
+
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()));
|
|
560
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
559
561
|
});
|
|
560
|
-
function
|
|
561
|
-
return
|
|
562
|
-
return
|
|
562
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
563
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
564
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
563
565
|
}));
|
|
564
566
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
567
|
+
__name(render, "render");
|
|
568
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
569
|
+
var attrs = __assign({}, node.attrs);
|
|
570
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
571
|
+
var defIds = runtimeProps.defIds;
|
|
572
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a9) {
|
|
573
|
+
var key = _a9[0], value = _a9[1];
|
|
574
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
575
|
+
})), attrs;
|
|
573
576
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
577
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
578
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
579
|
+
var _a9, defIds = runtimeProps.defIds;
|
|
580
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a9 = node.children) === null || _a9 === void 0) && _a9.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
581
|
+
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;
|
|
582
|
+
}) }) : node;
|
|
579
583
|
}
|
|
580
|
-
|
|
584
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
585
|
+
function generateShortUuid() {
|
|
581
586
|
return Math.random().toString(36).substring(2, 8);
|
|
582
587
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
588
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
589
|
+
IconBase.displayName = "UniverIcon";
|
|
590
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521C5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345ZM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521C8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345ZM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521C11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.83725 6.78345C6.22188 6.78345 6.53368 7.10742 6.53368 7.50706V8.41159C6.53368 8.81123 6.22188 9.13521 5.83725 9.13521 5.45263 9.13521 5.14082 8.81123 5.14082 8.41159V7.50706C5.14082 7.10742 5.45263 6.78345 5.83725 6.78345zM8.73904 6.78345C9.12366 6.78345 9.43546 7.10742 9.43546 7.50706V8.41159C9.43546 8.81123 9.12366 9.13521 8.73904 9.13521 8.35441 9.13521 8.04261 8.81123 8.04261 8.41159V7.50706C8.04261 7.10742 8.35441 6.78345 8.73904 6.78345zM11.6408 6.78345C12.0254 6.78345 12.3372 7.10742 12.3372 7.50706V8.41159C12.3372 8.81123 12.0254 9.13521 11.6408 9.13521 11.2562 9.13521 10.9444 8.81123 10.9444 8.41159V7.50706C10.9444 7.10742 11.2562 6.78345 11.6408 6.78345z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.84351 3.41861C1.84351 3.01861 2.15531 2.69434 2.53993 2.69434H14.9381C15.3228 2.69434 15.6346 3.01861 15.6346 3.41861V12.4611C15.6346 12.8612 15.3228 13.1854 14.9381 13.1854H8.82117L6.06643 14.6179C5.85054 14.7301 5.59416 14.7181 5.38884 14.5862C5.18352 14.4542 5.05855 14.2211 5.05855 13.9701V13.1854H2.53993C2.15531 13.1854 1.84351 12.8612 1.84351 12.4611L1.84351 3.41861ZM6.45141 12.7982L8.34531 12.0135C8.44201 11.9632 8.54864 11.9371 8.65676 11.9371H14.2417C14.3522 11.9371 14.4417 11.8475 14.4417 11.7371V4.14271C14.4417 4.03225 14.3522 3.94271 14.2417 3.94271H3.23636C3.12591 3.94271 3.03636 4.03225 3.03636 4.14271L3.03636 11.7371C3.03636 11.8475 3.12591 11.9371 3.23636 11.9371L5.75498 11.9371C6.1396 11.9371 6.45141 12.0611 6.45141 12.4611V12.7982Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CommentSingle = forwardRef(function(props, ref) {
|
|
591
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
586
592
|
id: "comment-single",
|
|
587
|
-
ref
|
|
588
|
-
icon:
|
|
593
|
+
ref,
|
|
594
|
+
icon: element
|
|
589
595
|
}));
|
|
590
596
|
});
|
|
591
|
-
|
|
592
|
-
var
|
|
597
|
+
CommentSingle.displayName = "CommentSingle";
|
|
598
|
+
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
593
599
|
/**
|
|
594
600
|
* @license React
|
|
595
601
|
* react-jsx-runtime.production.min.js
|
|
@@ -599,80 +605,82 @@ var re = { exports: {} }, j = {};
|
|
|
599
605
|
* This source code is licensed under the MIT license found in the
|
|
600
606
|
* LICENSE file in the root directory of this source tree.
|
|
601
607
|
*/
|
|
602
|
-
var
|
|
603
|
-
function
|
|
604
|
-
if (
|
|
605
|
-
|
|
606
|
-
var
|
|
607
|
-
function
|
|
608
|
-
var
|
|
609
|
-
|
|
610
|
-
for (
|
|
611
|
-
if (c && c.defaultProps) for (
|
|
612
|
-
return { $$typeof:
|
|
613
|
-
}
|
|
614
|
-
return
|
|
608
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
609
|
+
function requireReactJsxRuntime_production_min() {
|
|
610
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
611
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
612
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
613
|
+
function q(c, a, g) {
|
|
614
|
+
var b, d = {}, e = null, h = null;
|
|
615
|
+
g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
|
|
616
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
617
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
|
|
618
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
619
|
+
}
|
|
620
|
+
return __name(q, "q"), reactJsxRuntime_production_min.Fragment = l, reactJsxRuntime_production_min.jsx = q, reactJsxRuntime_production_min.jsxs = q, reactJsxRuntime_production_min;
|
|
615
621
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
622
|
+
__name(requireReactJsxRuntime_production_min, "requireReactJsxRuntime_production_min");
|
|
623
|
+
var hasRequiredJsxRuntime;
|
|
624
|
+
function requireJsxRuntime() {
|
|
625
|
+
return hasRequiredJsxRuntime || (hasRequiredJsxRuntime = 1, jsxRuntime.exports = requireReactJsxRuntime_production_min()), jsxRuntime.exports;
|
|
619
626
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
627
|
+
__name(requireJsxRuntime, "requireJsxRuntime");
|
|
628
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
629
|
+
const SheetsThreadCommentCell = /* @__PURE__ */ __name(() => {
|
|
630
|
+
const univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), activePopup = useObservable(sheetsThreadCommentPopupService.activePopup$), sheetThreadCommentModel = useDependency(SheetsThreadCommentModel);
|
|
631
|
+
if (useObservable(sheetThreadCommentModel.commentUpdate$), !activePopup)
|
|
624
632
|
return null;
|
|
625
|
-
const { row
|
|
626
|
-
|
|
627
|
-
},
|
|
628
|
-
var
|
|
629
|
-
return (
|
|
630
|
-
};
|
|
631
|
-
return /* @__PURE__ */
|
|
632
|
-
|
|
633
|
+
const { row, col, unitId, subUnitId, trigger } = activePopup, rootId = sheetThreadCommentModel.getByLocation(unitId, subUnitId, row, col), ref = `${Tools.chatAtABC(col)}${row + 1}`, onClose = /* @__PURE__ */ __name(() => {
|
|
634
|
+
sheetsThreadCommentPopupService.hidePopup();
|
|
635
|
+
}, "onClose"), getSubUnitName = /* @__PURE__ */ __name((id) => {
|
|
636
|
+
var _a9, _b, _c;
|
|
637
|
+
return (_c = (_b = (_a9 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a9.getSheetBySheetId(id)) == null ? void 0 : _b.getName()) != null ? _c : "";
|
|
638
|
+
}, "getSubUnitName");
|
|
639
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
640
|
+
ThreadCommentTree,
|
|
633
641
|
{
|
|
634
|
-
onClick: () => {
|
|
635
|
-
|
|
636
|
-
},
|
|
642
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
643
|
+
sheetsThreadCommentPopupService.persistPopup();
|
|
644
|
+
}, "onClick"),
|
|
637
645
|
prefix: "cell",
|
|
638
|
-
id:
|
|
639
|
-
unitId
|
|
640
|
-
subUnitId
|
|
641
|
-
type:
|
|
642
|
-
refStr:
|
|
643
|
-
onClose
|
|
644
|
-
getSubUnitName
|
|
645
|
-
autoFocus:
|
|
646
|
+
id: rootId,
|
|
647
|
+
unitId,
|
|
648
|
+
subUnitId,
|
|
649
|
+
type: UniverInstanceType.UNIVER_SHEET,
|
|
650
|
+
refStr: ref,
|
|
651
|
+
onClose,
|
|
652
|
+
getSubUnitName,
|
|
653
|
+
autoFocus: trigger === "context-menu"
|
|
646
654
|
}
|
|
647
655
|
);
|
|
648
|
-
},
|
|
649
|
-
var
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
656
|
+
}, "SheetsThreadCommentCell"), SheetsThreadCommentPanel = /* @__PURE__ */ __name(() => {
|
|
657
|
+
var _a9;
|
|
658
|
+
const markSelectionService = useDependency(IMarkSelectionService), univerInstanceService = useDependency(IUniverInstanceService), sheetsThreadCommentPopupService = useDependency(SheetsThreadCommentPopupService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), commandService = useDependency(ICommandService), subUnitId$ = useMemo(() => workbook.activeSheet$.pipe(map((i) => i == null ? void 0 : i.getSheetId())), [workbook.activeSheet$]), subUnitId = useObservable(subUnitId$, (_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId()), hoverShapeId = useRef(), panelService = useDependency(ThreadCommentPanelService), activeCommentId = useObservable(panelService.activeCommentId$), panelVisible = useObservable(panelService.panelVisible$, panelService.panelVisible), sortComments = useCallback((comments) => {
|
|
659
|
+
const worksheets = workbook.getSheets(), sheetIndex = {};
|
|
660
|
+
worksheets.forEach((sheet, i) => {
|
|
661
|
+
sheetIndex[sheet.getSheetId()] = i;
|
|
654
662
|
});
|
|
655
|
-
const
|
|
656
|
-
var
|
|
657
|
-
const
|
|
658
|
-
return { ...
|
|
659
|
-
}).sort((
|
|
663
|
+
const sort = /* @__PURE__ */ __name((comments2) => comments2.map((comment) => {
|
|
664
|
+
var _a10;
|
|
665
|
+
const ref = singleReferenceToGrid(comment.ref), p = [(_a10 = sheetIndex[comment.subUnitId]) != null ? _a10 : 0, ref.row, ref.column];
|
|
666
|
+
return { ...comment, p };
|
|
667
|
+
}).sort((pre, aft) => pre.p[0] === aft.p[0] ? pre.p[1] === aft.p[1] ? pre.p[2] - aft.p[2] : pre.p[1] - aft.p[1] : pre.p[0] - aft.p[0]), "sort");
|
|
660
668
|
return [
|
|
661
|
-
...
|
|
662
|
-
...
|
|
669
|
+
...sort(comments.filter((comment) => !comment.resolved)),
|
|
670
|
+
...sort(comments.filter((comment) => comment.resolved))
|
|
663
671
|
];
|
|
664
|
-
}, [
|
|
665
|
-
var
|
|
666
|
-
if (
|
|
667
|
-
const { row
|
|
668
|
-
startColumn:
|
|
669
|
-
endColumn:
|
|
670
|
-
startRow:
|
|
671
|
-
endRow:
|
|
672
|
+
}, [workbook]), showShape = useCallback((comment) => {
|
|
673
|
+
var _a10;
|
|
674
|
+
if (comment.unitId === unitId && comment.subUnitId === subUnitId && !comment.resolved) {
|
|
675
|
+
const { row, column } = singleReferenceToGrid(comment.ref), worksheet = workbook.getSheetBySheetId(comment.subUnitId), mergeInfo = (_a10 = worksheet == null ? void 0 : worksheet.getMergedCell(row, column)) != null ? _a10 : {
|
|
676
|
+
startColumn: column,
|
|
677
|
+
endColumn: column,
|
|
678
|
+
startRow: row,
|
|
679
|
+
endRow: row
|
|
672
680
|
};
|
|
673
|
-
if (!Number.isNaN(
|
|
674
|
-
return
|
|
675
|
-
range:
|
|
681
|
+
if (!Number.isNaN(row) && !Number.isNaN(column))
|
|
682
|
+
return markSelectionService.addShape({
|
|
683
|
+
range: mergeInfo,
|
|
676
684
|
style: {
|
|
677
685
|
// hasAutoFill: false,
|
|
678
686
|
fill: "rgb(255, 189, 55, 0.35)",
|
|
@@ -683,162 +691,162 @@ const sn = () => {
|
|
|
683
691
|
primary: null
|
|
684
692
|
});
|
|
685
693
|
}
|
|
686
|
-
}, [
|
|
687
|
-
var
|
|
688
|
-
return (
|
|
689
|
-
},
|
|
690
|
-
|
|
691
|
-
},
|
|
692
|
-
|
|
693
|
-
},
|
|
694
|
-
|
|
695
|
-
},
|
|
696
|
-
|
|
697
|
-
};
|
|
698
|
-
return
|
|
699
|
-
!
|
|
700
|
-
}, [
|
|
701
|
-
|
|
694
|
+
}, [markSelectionService, subUnitId, unitId]), getSubUnitName = /* @__PURE__ */ __name((id) => {
|
|
695
|
+
var _a10, _b;
|
|
696
|
+
return (_b = (_a10 = workbook.getSheetBySheetId(id)) == null ? void 0 : _a10.getName()) != null ? _b : "";
|
|
697
|
+
}, "getSubUnitName"), handleAdd = /* @__PURE__ */ __name(() => {
|
|
698
|
+
commandService.executeCommand(ShowAddSheetCommentModalOperation.id);
|
|
699
|
+
}, "handleAdd"), handleHover = /* @__PURE__ */ __name((comment) => {
|
|
700
|
+
activeCommentId && activeCommentId.unitId === comment.unitId && activeCommentId.subUnitId === comment.subUnitId && activeCommentId.commentId === comment.id || (hoverShapeId.current && (markSelectionService.removeShape(hoverShapeId.current), hoverShapeId.current = null), hoverShapeId.current = showShape(comment));
|
|
701
|
+
}, "handleHover"), handleLeave = /* @__PURE__ */ __name(() => {
|
|
702
|
+
hoverShapeId.current && (markSelectionService.removeShape(hoverShapeId.current), hoverShapeId.current = null);
|
|
703
|
+
}, "handleLeave"), handleResolve = /* @__PURE__ */ __name((id, resolved) => {
|
|
704
|
+
resolved && sheetsThreadCommentPopupService.hidePopup();
|
|
705
|
+
}, "handleResolve");
|
|
706
|
+
return useEffect(() => {
|
|
707
|
+
!panelVisible && hoverShapeId.current && markSelectionService.removeShape(hoverShapeId.current);
|
|
708
|
+
}, [markSelectionService, panelVisible]), /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
709
|
+
ThreadCommentPanel,
|
|
702
710
|
{
|
|
703
|
-
unitId
|
|
704
|
-
subUnitId
|
|
705
|
-
type:
|
|
706
|
-
onAdd:
|
|
707
|
-
getSubUnitName
|
|
708
|
-
onResolve:
|
|
709
|
-
sortComments
|
|
710
|
-
onItemEnter:
|
|
711
|
-
onItemLeave:
|
|
712
|
-
onDeleteComment: () => (
|
|
711
|
+
unitId,
|
|
712
|
+
subUnitId$,
|
|
713
|
+
type: UniverInstanceType.UNIVER_SHEET,
|
|
714
|
+
onAdd: handleAdd,
|
|
715
|
+
getSubUnitName,
|
|
716
|
+
onResolve: handleResolve,
|
|
717
|
+
sortComments,
|
|
718
|
+
onItemEnter: handleHover,
|
|
719
|
+
onItemLeave: handleLeave,
|
|
720
|
+
onDeleteComment: /* @__PURE__ */ __name(() => (handleLeave(), !0), "onDeleteComment")
|
|
713
721
|
}
|
|
714
722
|
);
|
|
715
|
-
},
|
|
716
|
-
id:
|
|
717
|
-
type:
|
|
718
|
-
icon:
|
|
723
|
+
}, "SheetsThreadCommentPanel"), threadCommentMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
724
|
+
id: ShowAddSheetCommentModalOperation.id,
|
|
725
|
+
type: MenuItemType.BUTTON,
|
|
726
|
+
icon: COMMENT_SINGLE_ICON,
|
|
719
727
|
title: "sheetThreadComment.menu.addComment",
|
|
720
|
-
hidden$:
|
|
721
|
-
disabled$:
|
|
722
|
-
workbookTypes: [
|
|
723
|
-
worksheetTypes: [
|
|
724
|
-
rangeTypes: [
|
|
728
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
729
|
+
disabled$: getCurrentRangeDisable$(accessor, {
|
|
730
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
731
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
732
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
725
733
|
})
|
|
726
|
-
}),
|
|
727
|
-
id:
|
|
728
|
-
type:
|
|
729
|
-
icon:
|
|
734
|
+
}), "threadCommentMenuFactory"), threadPanelMenuFactory = /* @__PURE__ */ __name((accessor) => ({
|
|
735
|
+
id: ToggleSheetCommentPanelOperation.id,
|
|
736
|
+
type: MenuItemType.BUTTON,
|
|
737
|
+
icon: COMMENT_SINGLE_ICON,
|
|
730
738
|
tooltip: "sheetThreadComment.menu.commentManagement",
|
|
731
|
-
disabled$:
|
|
732
|
-
workbookTypes: [
|
|
733
|
-
worksheetTypes: [
|
|
734
|
-
rangeTypes: [
|
|
739
|
+
disabled$: getCurrentRangeDisable$(accessor, {
|
|
740
|
+
workbookTypes: [WorkbookCommentPermission],
|
|
741
|
+
worksheetTypes: [WorksheetViewPermission],
|
|
742
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
735
743
|
}),
|
|
736
|
-
hidden$:
|
|
737
|
-
}),
|
|
738
|
-
id:
|
|
739
|
-
binding:
|
|
740
|
-
preconditions:
|
|
741
|
-
},
|
|
742
|
-
[
|
|
743
|
-
[
|
|
744
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
|
|
745
|
+
}), "threadPanelMenuFactory"), AddCommentShortcut = {
|
|
746
|
+
id: ShowAddSheetCommentModalOperation.id,
|
|
747
|
+
binding: KeyCode.M | MetaKeys.CTRL_COMMAND | MetaKeys.ALT,
|
|
748
|
+
preconditions: whenSheetEditorFocused
|
|
749
|
+
}, menuSchema = {
|
|
750
|
+
[RibbonStartGroup.OTHERS]: {
|
|
751
|
+
[ToggleSheetCommentPanelOperation.id]: {
|
|
744
752
|
order: 1,
|
|
745
|
-
menuItemFactory:
|
|
753
|
+
menuItemFactory: threadPanelMenuFactory
|
|
746
754
|
}
|
|
747
755
|
},
|
|
748
|
-
[
|
|
749
|
-
[
|
|
750
|
-
[
|
|
756
|
+
[ContextMenuPosition.MAIN_AREA]: {
|
|
757
|
+
[ContextMenuGroup.OTHERS]: {
|
|
758
|
+
[ShowAddSheetCommentModalOperation.id]: {
|
|
751
759
|
order: 0,
|
|
752
|
-
menuItemFactory:
|
|
760
|
+
menuItemFactory: threadCommentMenuFactory
|
|
753
761
|
}
|
|
754
762
|
}
|
|
755
763
|
}
|
|
756
764
|
};
|
|
757
|
-
var
|
|
758
|
-
for (var
|
|
759
|
-
(
|
|
760
|
-
return
|
|
761
|
-
},
|
|
762
|
-
let
|
|
763
|
-
constructor(
|
|
764
|
-
super(), this._menuManagerService =
|
|
765
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
766
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
767
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
768
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
769
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a7;
|
|
770
|
+
let SheetsThreadCommentController = (_a7 = class extends Disposable {
|
|
771
|
+
constructor(_menuManagerService, _componentManager, _shortcutService) {
|
|
772
|
+
super(), this._menuManagerService = _menuManagerService, this._componentManager = _componentManager, this._shortcutService = _shortcutService, this._initMenu(), this._initShortcut(), this._initComponent();
|
|
765
773
|
}
|
|
766
774
|
_initShortcut() {
|
|
767
|
-
this._shortcutService.registerShortcut(
|
|
775
|
+
this._shortcutService.registerShortcut(AddCommentShortcut);
|
|
768
776
|
}
|
|
769
777
|
_initMenu() {
|
|
770
|
-
this._menuManagerService.mergeMenu(
|
|
778
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
771
779
|
}
|
|
772
780
|
_initComponent() {
|
|
773
781
|
[
|
|
774
|
-
[
|
|
775
|
-
[
|
|
776
|
-
[
|
|
777
|
-
].forEach(([
|
|
778
|
-
this._componentManager.register(
|
|
782
|
+
[SHEETS_THREAD_COMMENT_MODAL, SheetsThreadCommentCell],
|
|
783
|
+
[THREAD_COMMENT_PANEL, SheetsThreadCommentPanel],
|
|
784
|
+
[COMMENT_SINGLE_ICON, CommentSingle]
|
|
785
|
+
].forEach(([key, comp]) => {
|
|
786
|
+
this._componentManager.register(key, comp);
|
|
779
787
|
});
|
|
780
788
|
}
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
],
|
|
787
|
-
var
|
|
788
|
-
for (var
|
|
789
|
-
(
|
|
790
|
-
return
|
|
791
|
-
},
|
|
792
|
-
let
|
|
793
|
-
constructor(
|
|
794
|
-
super(), this._config =
|
|
795
|
-
const { menu
|
|
789
|
+
}, __name(_a7, "SheetsThreadCommentController"), _a7);
|
|
790
|
+
SheetsThreadCommentController = __decorateClass$1([
|
|
791
|
+
__decorateParam$1(0, IMenuManagerService),
|
|
792
|
+
__decorateParam$1(1, Inject(ComponentManager)),
|
|
793
|
+
__decorateParam$1(2, IShortcutService)
|
|
794
|
+
], SheetsThreadCommentController);
|
|
795
|
+
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) => {
|
|
796
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
797
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
798
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
799
|
+
}, "__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"), _a8;
|
|
800
|
+
let UniverSheetsThreadCommentUIPlugin = (_a8 = class extends Plugin {
|
|
801
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
802
|
+
super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
|
|
803
|
+
const { menu, ...rest } = merge(
|
|
796
804
|
{},
|
|
797
|
-
|
|
805
|
+
defaultPluginConfig,
|
|
798
806
|
this._config
|
|
799
807
|
);
|
|
800
|
-
|
|
808
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(SHEETS_THREAD_COMMENT_UI_PLUGIN_CONFIG_KEY, rest);
|
|
801
809
|
}
|
|
802
810
|
onStarting() {
|
|
803
811
|
[
|
|
804
|
-
[
|
|
805
|
-
[
|
|
806
|
-
[
|
|
807
|
-
[
|
|
808
|
-
[
|
|
809
|
-
[
|
|
810
|
-
[
|
|
811
|
-
].forEach((
|
|
812
|
-
this._injector.add(
|
|
813
|
-
}), [
|
|
814
|
-
this._commandService.registerCommand(
|
|
815
|
-
}), this._injector.get(
|
|
812
|
+
[SheetsThreadCommentController],
|
|
813
|
+
[SheetsThreadCommentRenderController],
|
|
814
|
+
[SheetsThreadCommentCopyPasteController],
|
|
815
|
+
[SheetsThreadCommentHoverController],
|
|
816
|
+
[ThreadCommentRemoveSheetsController],
|
|
817
|
+
[SheetsThreadCommentPopupController],
|
|
818
|
+
[SheetsThreadCommentPopupService]
|
|
819
|
+
].forEach((dep) => {
|
|
820
|
+
this._injector.add(dep);
|
|
821
|
+
}), [ShowAddSheetCommentModalOperation].forEach((command) => {
|
|
822
|
+
this._commandService.registerCommand(command);
|
|
823
|
+
}), this._injector.get(SheetsThreadCommentController);
|
|
816
824
|
}
|
|
817
825
|
onReady() {
|
|
818
|
-
this._injector.get(
|
|
826
|
+
this._injector.get(SheetsThreadCommentRenderController), this._injector.get(ThreadCommentRemoveSheetsController);
|
|
819
827
|
}
|
|
820
828
|
onRendered() {
|
|
821
|
-
this._injector.get(
|
|
822
|
-
}
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
],
|
|
829
|
+
this._injector.get(SheetsThreadCommentCopyPasteController), this._injector.get(SheetsThreadCommentHoverController), this._injector.get(SheetsThreadCommentPopupController);
|
|
830
|
+
}
|
|
831
|
+
}, __name(_a8, "UniverSheetsThreadCommentUIPlugin"), _a8);
|
|
832
|
+
__publicField2(UniverSheetsThreadCommentUIPlugin, "pluginName", SHEETS_THREAD_COMMENT);
|
|
833
|
+
__publicField2(UniverSheetsThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
834
|
+
UniverSheetsThreadCommentUIPlugin = __decorateClass([
|
|
835
|
+
DependentOn(UniverThreadCommentUIPlugin, UniverSheetsThreadCommentPlugin),
|
|
836
|
+
__decorateParam(1, Inject(Injector)),
|
|
837
|
+
__decorateParam(2, Inject(ICommandService)),
|
|
838
|
+
__decorateParam(3, IConfigService)
|
|
839
|
+
], UniverSheetsThreadCommentUIPlugin);
|
|
832
840
|
export {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
841
|
+
AddCommentCommand,
|
|
842
|
+
DeleteCommentCommand,
|
|
843
|
+
DeleteCommentTreeCommand,
|
|
844
|
+
IThreadCommentDataSourceService2 as IThreadCommentDataSourceService,
|
|
845
|
+
ResolveCommentCommand,
|
|
846
|
+
SHEETS_THREAD_COMMENT,
|
|
847
|
+
SheetsThreadCommentPopupService,
|
|
848
|
+
ShowAddSheetCommentModalOperation,
|
|
849
|
+
UniverSheetsThreadCommentUIPlugin,
|
|
850
|
+
UniverThreadCommentUIPlugin2 as UniverThreadCommentUIPlugin,
|
|
851
|
+
UpdateCommentCommand
|
|
844
852
|
};
|