@univerjs/sheets-thread-comment 0.5.4 → 0.5.5-experimental.20250123-34738ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +268 -234
- package/lib/es/index.js +239 -238
- package/lib/types/facade/f-event.d.ts +9 -0
- package/lib/types/facade/f-range.d.ts +59 -4
- package/lib/types/facade/f-thread-comment.d.ts +61 -50
- package/lib/types/facade/f-univer.d.ts +10 -1
- package/lib/types/facade/f-workbook.d.ts +24 -0
- package/lib/types/facade/f-worksheet.d.ts +6 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,367 +1,368 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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, ObjectMatrix, UniverInstanceType, IUniverInstanceService, sequenceExecuteAsync, toDisposable, ICommandService, DependentOn, Injector, Plugin } from "@univerjs/core";
|
|
6
|
+
import { singleReferenceToGrid, serializeRange } from "@univerjs/engine-formula";
|
|
7
|
+
import { RefRangeService, SheetsSelectionsService, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
|
|
8
|
+
import { ThreadCommentModel, DeleteCommentMutation, AddCommentMutation, UpdateCommentRefMutation, UniverThreadCommentPlugin } from "@univerjs/thread-comment";
|
|
9
|
+
import { Subject } from "rxjs";
|
|
10
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
11
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
13
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
14
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
|
|
15
|
+
let SheetsThreadCommentModel = (_a = class extends Disposable {
|
|
16
|
+
constructor(_threadCommentModel, _univerInstanceService) {
|
|
16
17
|
super();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this._threadCommentModel =
|
|
18
|
+
__publicField(this, "_matrixMap", /* @__PURE__ */ new Map());
|
|
19
|
+
__publicField(this, "_locationMap", /* @__PURE__ */ new Map());
|
|
20
|
+
__publicField(this, "_commentUpdate$", new Subject());
|
|
21
|
+
__publicField(this, "commentUpdate$", this._commentUpdate$.asObservable());
|
|
22
|
+
this._threadCommentModel = _threadCommentModel, this._univerInstanceService = _univerInstanceService, this._init(), this.disposeWithMe(() => {
|
|
22
23
|
this._commentUpdate$.complete();
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
_init() {
|
|
26
27
|
this._initData(), this._initUpdateTransform();
|
|
27
28
|
}
|
|
28
|
-
_ensureCommentMatrix(
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
return
|
|
29
|
+
_ensureCommentMatrix(unitId, subUnitId) {
|
|
30
|
+
let unitMap = this._matrixMap.get(unitId);
|
|
31
|
+
unitMap || (unitMap = /* @__PURE__ */ new Map(), this._matrixMap.set(unitId, unitMap));
|
|
32
|
+
let subUnitMap = unitMap.get(subUnitId);
|
|
33
|
+
return subUnitMap || (subUnitMap = new ObjectMatrix(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
|
|
33
34
|
}
|
|
34
|
-
_ensureCommentLocationMap(
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
let
|
|
38
|
-
return
|
|
35
|
+
_ensureCommentLocationMap(unitId, subUnitId) {
|
|
36
|
+
let unitMap = this._locationMap.get(unitId);
|
|
37
|
+
unitMap || (unitMap = /* @__PURE__ */ new Map(), this._locationMap.set(unitId, unitMap));
|
|
38
|
+
let subUnitMap = unitMap.get(subUnitId);
|
|
39
|
+
return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
|
|
39
40
|
}
|
|
40
|
-
_addCommentToMatrix(
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
_addCommentToMatrix(matrix, row, column, commentId) {
|
|
42
|
+
var _a4;
|
|
43
|
+
const current = (_a4 = matrix.getValue(row, column)) != null ? _a4 : /* @__PURE__ */ new Set();
|
|
44
|
+
current.add(commentId), matrix.setValue(row, column, current);
|
|
44
45
|
}
|
|
45
|
-
_deleteCommentFromMatrix(
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
|
|
46
|
+
_deleteCommentFromMatrix(matrix, row, column, commentId) {
|
|
47
|
+
if (row >= 0 && column >= 0) {
|
|
48
|
+
const current = matrix.getValue(row, column);
|
|
49
|
+
current && current.has(commentId) && (current.delete(commentId), current.size === 0 && matrix.realDeleteValue(row, column));
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
_ensure(
|
|
52
|
-
const
|
|
53
|
-
return { matrix
|
|
52
|
+
_ensure(unitId, subUnitId) {
|
|
53
|
+
const matrix = this._ensureCommentMatrix(unitId, subUnitId), locationMap = this._ensureCommentLocationMap(unitId, subUnitId);
|
|
54
|
+
return { matrix, locationMap };
|
|
54
55
|
}
|
|
55
56
|
_initData() {
|
|
56
|
-
const
|
|
57
|
-
for (const
|
|
58
|
-
for (const
|
|
59
|
-
const { unitId
|
|
60
|
-
this._addComment(
|
|
57
|
+
const datas = this._threadCommentModel.getAll();
|
|
58
|
+
for (const data of datas)
|
|
59
|
+
for (const thread of data.threads) {
|
|
60
|
+
const { unitId, subUnitId, root } = thread;
|
|
61
|
+
this._addComment(unitId, subUnitId, root);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
_addComment(
|
|
64
|
-
const
|
|
65
|
-
!
|
|
66
|
-
unitId
|
|
67
|
-
subUnitId
|
|
68
|
-
payload:
|
|
64
|
+
_addComment(unitId, subUnitId, comment) {
|
|
65
|
+
const location = singleReferenceToGrid(comment.ref), parentId = comment.parentId, { row, column } = location, commentId = comment.id, { matrix, locationMap } = this._ensure(unitId, subUnitId);
|
|
66
|
+
!parentId && row >= 0 && column >= 0 && (this._addCommentToMatrix(matrix, row, column, commentId), locationMap.set(commentId, { row, column })), parentId || this._commentUpdate$.next({
|
|
67
|
+
unitId,
|
|
68
|
+
subUnitId,
|
|
69
|
+
payload: comment,
|
|
69
70
|
type: "add",
|
|
70
|
-
isRoot: !
|
|
71
|
-
...
|
|
71
|
+
isRoot: !parentId,
|
|
72
|
+
...location
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
// eslint-disable-next-line max-lines-per-function
|
|
75
76
|
_initUpdateTransform() {
|
|
76
|
-
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((
|
|
77
|
-
const { unitId
|
|
77
|
+
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
|
|
78
|
+
const { unitId, subUnitId } = update;
|
|
78
79
|
try {
|
|
79
|
-
if (this._univerInstanceService.getUnitType(
|
|
80
|
+
if (this._univerInstanceService.getUnitType(unitId) !== UniverInstanceType.UNIVER_SHEET)
|
|
80
81
|
return;
|
|
81
82
|
} catch {
|
|
82
83
|
}
|
|
83
|
-
const { matrix
|
|
84
|
-
switch (
|
|
84
|
+
const { matrix, locationMap } = this._ensure(unitId, subUnitId);
|
|
85
|
+
switch (update.type) {
|
|
85
86
|
case "add": {
|
|
86
|
-
this._addComment(
|
|
87
|
+
this._addComment(update.unitId, update.subUnitId, update.payload);
|
|
87
88
|
break;
|
|
88
89
|
}
|
|
89
90
|
case "delete": {
|
|
90
|
-
const { isRoot
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
this._deleteCommentFromMatrix(
|
|
94
|
-
...
|
|
95
|
-
...
|
|
91
|
+
const { isRoot, comment } = update.payload;
|
|
92
|
+
if (isRoot) {
|
|
93
|
+
const location = singleReferenceToGrid(comment.ref), { row, column } = location;
|
|
94
|
+
this._deleteCommentFromMatrix(matrix, row, column, comment.id), this._commentUpdate$.next({
|
|
95
|
+
...update,
|
|
96
|
+
...location
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
break;
|
|
99
100
|
}
|
|
100
101
|
case "update": {
|
|
101
|
-
const { commentId
|
|
102
|
-
if (!
|
|
102
|
+
const { commentId } = update.payload, comment = this._threadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
103
|
+
if (!comment)
|
|
103
104
|
return;
|
|
104
|
-
const
|
|
105
|
+
const location = singleReferenceToGrid(comment.ref);
|
|
105
106
|
this._commentUpdate$.next({
|
|
106
|
-
...
|
|
107
|
-
...
|
|
107
|
+
...update,
|
|
108
|
+
...location
|
|
108
109
|
});
|
|
109
110
|
break;
|
|
110
111
|
}
|
|
111
112
|
case "updateRef": {
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
113
|
+
const location = singleReferenceToGrid(update.payload.ref), { commentId } = update.payload, currentLoc = locationMap.get(commentId);
|
|
114
|
+
if (!currentLoc)
|
|
114
115
|
return;
|
|
115
|
-
const { row
|
|
116
|
-
this._deleteCommentFromMatrix(
|
|
117
|
-
...
|
|
118
|
-
...
|
|
116
|
+
const { row, column } = currentLoc;
|
|
117
|
+
this._deleteCommentFromMatrix(matrix, row, column, commentId), locationMap.delete(commentId), location.row >= 0 && location.column >= 0 && (this._addCommentToMatrix(matrix, location.row, location.column, commentId), locationMap.set(commentId, { row: location.row, column: location.column })), this._commentUpdate$.next({
|
|
118
|
+
...update,
|
|
119
|
+
...location
|
|
119
120
|
});
|
|
120
121
|
break;
|
|
121
122
|
}
|
|
122
123
|
case "resolve": {
|
|
123
|
-
const { unitId:
|
|
124
|
-
|
|
125
|
-
...
|
|
126
|
-
...
|
|
124
|
+
const { unitId: unitId2, subUnitId: subUnitId2, payload } = update, { locationMap: locationMap2 } = this._ensure(unitId2, subUnitId2), location = locationMap2.get(payload.commentId);
|
|
125
|
+
location && this._commentUpdate$.next({
|
|
126
|
+
...update,
|
|
127
|
+
...location
|
|
127
128
|
});
|
|
128
129
|
break;
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
}));
|
|
132
133
|
}
|
|
133
|
-
getByLocation(
|
|
134
|
-
var
|
|
135
|
-
return (
|
|
134
|
+
getByLocation(unitId, subUnitId, row, column) {
|
|
135
|
+
var _a4;
|
|
136
|
+
return (_a4 = this.getAllByLocation(unitId, subUnitId, row, column).filter((comment) => !comment.resolved)[0]) == null ? void 0 : _a4.id;
|
|
136
137
|
}
|
|
137
|
-
getAllByLocation(
|
|
138
|
-
const
|
|
139
|
-
return
|
|
138
|
+
getAllByLocation(unitId, subUnitId, row, column) {
|
|
139
|
+
const current = this._ensureCommentMatrix(unitId, subUnitId).getValue(row, column);
|
|
140
|
+
return current ? Array.from(current).map((id) => this.getComment(unitId, subUnitId, id)).filter(Boolean) : [];
|
|
140
141
|
}
|
|
141
|
-
getComment(
|
|
142
|
-
return this._threadCommentModel.getComment(
|
|
142
|
+
getComment(unitId, subUnitId, commentId) {
|
|
143
|
+
return this._threadCommentModel.getComment(unitId, subUnitId, commentId);
|
|
143
144
|
}
|
|
144
|
-
getCommentWithChildren(
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
145
|
+
getCommentWithChildren(unitId, subUnitId, row, column) {
|
|
146
|
+
const commentId = this.getByLocation(unitId, subUnitId, row, column);
|
|
147
|
+
if (!commentId)
|
|
147
148
|
return;
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
return this._threadCommentModel.getThread(
|
|
149
|
+
const comment = this.getComment(unitId, subUnitId, commentId);
|
|
150
|
+
if (comment)
|
|
151
|
+
return this._threadCommentModel.getThread(unitId, subUnitId, comment.threadId);
|
|
151
152
|
}
|
|
152
|
-
showCommentMarker(
|
|
153
|
-
const
|
|
154
|
-
if (!
|
|
153
|
+
showCommentMarker(unitId, subUnitId, row, column) {
|
|
154
|
+
const commentId = this.getByLocation(unitId, subUnitId, row, column);
|
|
155
|
+
if (!commentId)
|
|
155
156
|
return !1;
|
|
156
|
-
const
|
|
157
|
-
return !!(
|
|
157
|
+
const comment = this.getComment(unitId, subUnitId, commentId);
|
|
158
|
+
return !!(comment && !comment.resolved);
|
|
158
159
|
}
|
|
159
|
-
getSubUnitAll(
|
|
160
|
-
return this._threadCommentModel.getUnit(
|
|
160
|
+
getSubUnitAll(unitId, subUnitId) {
|
|
161
|
+
return this._threadCommentModel.getUnit(unitId).filter((i) => i.subUnitId === subUnitId).map((i) => i.root);
|
|
161
162
|
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
],
|
|
167
|
-
var
|
|
168
|
-
for (var
|
|
169
|
-
(
|
|
170
|
-
return
|
|
171
|
-
},
|
|
172
|
-
let
|
|
173
|
-
constructor(
|
|
163
|
+
}, __name(_a, "SheetsThreadCommentModel"), _a);
|
|
164
|
+
SheetsThreadCommentModel = __decorateClass$2([
|
|
165
|
+
__decorateParam$2(0, Inject(ThreadCommentModel)),
|
|
166
|
+
__decorateParam$2(1, IUniverInstanceService)
|
|
167
|
+
], SheetsThreadCommentModel);
|
|
168
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
169
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
170
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
171
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
172
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
|
|
173
|
+
let SheetsThreadCommentRefRangeController = (_a2 = class extends Disposable {
|
|
174
|
+
constructor(_refRangeService, _sheetsThreadCommentModel, _threadCommentModel, _selectionManagerService, _commandService) {
|
|
174
175
|
super();
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
startColumn:
|
|
180
|
-
endColumn:
|
|
181
|
-
startRow:
|
|
182
|
-
endRow:
|
|
176
|
+
__publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
177
|
+
__publicField(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
178
|
+
__publicField(this, "_handleRangeChange", /* @__PURE__ */ __name((unitId, subUnitId, comment, resultRange, silent) => {
|
|
179
|
+
const commentId = comment.id, oldRange = {
|
|
180
|
+
startColumn: comment.column,
|
|
181
|
+
endColumn: comment.column,
|
|
182
|
+
startRow: comment.row,
|
|
183
|
+
endRow: comment.row
|
|
183
184
|
};
|
|
184
|
-
return
|
|
185
|
+
return resultRange ? {
|
|
185
186
|
redos: [{
|
|
186
|
-
id:
|
|
187
|
+
id: UpdateCommentRefMutation.id,
|
|
187
188
|
params: {
|
|
188
|
-
unitId
|
|
189
|
-
subUnitId
|
|
189
|
+
unitId,
|
|
190
|
+
subUnitId,
|
|
190
191
|
payload: {
|
|
191
|
-
ref:
|
|
192
|
-
commentId
|
|
192
|
+
ref: serializeRange(resultRange),
|
|
193
|
+
commentId
|
|
193
194
|
},
|
|
194
|
-
silent
|
|
195
|
+
silent
|
|
195
196
|
}
|
|
196
197
|
}],
|
|
197
198
|
undos: [{
|
|
198
|
-
id:
|
|
199
|
+
id: UpdateCommentRefMutation.id,
|
|
199
200
|
params: {
|
|
200
|
-
unitId
|
|
201
|
-
subUnitId
|
|
201
|
+
unitId,
|
|
202
|
+
subUnitId,
|
|
202
203
|
payload: {
|
|
203
|
-
ref:
|
|
204
|
-
commentId
|
|
204
|
+
ref: serializeRange(oldRange),
|
|
205
|
+
commentId
|
|
205
206
|
},
|
|
206
|
-
silent
|
|
207
|
+
silent
|
|
207
208
|
}
|
|
208
209
|
}]
|
|
209
210
|
} : {
|
|
210
211
|
redos: [{
|
|
211
|
-
id:
|
|
212
|
+
id: DeleteCommentMutation.id,
|
|
212
213
|
params: {
|
|
213
|
-
unitId
|
|
214
|
-
subUnitId
|
|
215
|
-
commentId
|
|
214
|
+
unitId,
|
|
215
|
+
subUnitId,
|
|
216
|
+
commentId
|
|
216
217
|
}
|
|
217
218
|
}],
|
|
218
219
|
undos: [{
|
|
219
|
-
id:
|
|
220
|
+
id: AddCommentMutation.id,
|
|
220
221
|
params: {
|
|
221
|
-
unitId
|
|
222
|
-
subUnitId
|
|
223
|
-
comment
|
|
222
|
+
unitId,
|
|
223
|
+
subUnitId,
|
|
224
|
+
comment,
|
|
224
225
|
sync: !0
|
|
225
226
|
}
|
|
226
227
|
}]
|
|
227
228
|
};
|
|
228
|
-
});
|
|
229
|
-
this._refRangeService =
|
|
229
|
+
}, "_handleRangeChange"));
|
|
230
|
+
this._refRangeService = _refRangeService, this._sheetsThreadCommentModel = _sheetsThreadCommentModel, this._threadCommentModel = _threadCommentModel, this._selectionManagerService = _selectionManagerService, this._commandService = _commandService, this._initData(), this._initRefRange();
|
|
230
231
|
}
|
|
231
|
-
_getIdWithUnitId(
|
|
232
|
-
return `${
|
|
232
|
+
_getIdWithUnitId(unitId, subUnitId, id) {
|
|
233
|
+
return `${unitId}-${subUnitId}-${id}`;
|
|
233
234
|
}
|
|
234
|
-
_register(
|
|
235
|
-
const
|
|
236
|
-
startColumn:
|
|
237
|
-
endColumn:
|
|
238
|
-
startRow:
|
|
239
|
-
endRow:
|
|
235
|
+
_register(unitId, subUnitId, comment) {
|
|
236
|
+
const commentId = comment.id, oldRange = {
|
|
237
|
+
startColumn: comment.column,
|
|
238
|
+
endColumn: comment.column,
|
|
239
|
+
startRow: comment.row,
|
|
240
|
+
endRow: comment.row
|
|
240
241
|
};
|
|
241
242
|
this._disposableMap.set(
|
|
242
|
-
this._getIdWithUnitId(
|
|
243
|
-
this._refRangeService.registerRefRange(
|
|
244
|
-
const
|
|
245
|
-
return
|
|
243
|
+
this._getIdWithUnitId(unitId, subUnitId, commentId),
|
|
244
|
+
this._refRangeService.registerRefRange(oldRange, (commandInfo) => {
|
|
245
|
+
const resultRanges = handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests(oldRange, commandInfo, { selectionManagerService: this._selectionManagerService }), resultRange = Array.isArray(resultRanges) ? resultRanges[0] : resultRanges;
|
|
246
|
+
return resultRange && resultRange.startColumn === oldRange.startColumn && resultRange.startRow === oldRange.startRow ? {
|
|
246
247
|
undos: [],
|
|
247
248
|
redos: []
|
|
248
|
-
} : this._handleRangeChange(
|
|
249
|
-
},
|
|
249
|
+
} : this._handleRangeChange(unitId, subUnitId, comment, resultRange, !1);
|
|
250
|
+
}, unitId, subUnitId)
|
|
250
251
|
);
|
|
251
252
|
}
|
|
252
|
-
_watch(
|
|
253
|
-
const
|
|
254
|
-
startColumn:
|
|
255
|
-
endColumn:
|
|
256
|
-
startRow:
|
|
257
|
-
endRow:
|
|
253
|
+
_watch(unitId, subUnitId, comment) {
|
|
254
|
+
const commentId = comment.id, oldRange = {
|
|
255
|
+
startColumn: comment.column,
|
|
256
|
+
endColumn: comment.column,
|
|
257
|
+
startRow: comment.row,
|
|
258
|
+
endRow: comment.row
|
|
258
259
|
};
|
|
259
260
|
this._watcherMap.set(
|
|
260
|
-
this._getIdWithUnitId(
|
|
261
|
-
this._refRangeService.watchRange(
|
|
262
|
-
const { redos
|
|
263
|
-
|
|
261
|
+
this._getIdWithUnitId(unitId, subUnitId, commentId),
|
|
262
|
+
this._refRangeService.watchRange(unitId, subUnitId, oldRange, (before, after) => {
|
|
263
|
+
const { redos } = this._handleRangeChange(unitId, subUnitId, comment, after, !0);
|
|
264
|
+
sequenceExecuteAsync(redos, this._commandService, { onlyLocal: !0 });
|
|
264
265
|
}, !0)
|
|
265
266
|
);
|
|
266
267
|
}
|
|
267
|
-
_unwatch(
|
|
268
|
-
var
|
|
269
|
-
const
|
|
270
|
-
(
|
|
268
|
+
_unwatch(unitId, subUnitId, commentId) {
|
|
269
|
+
var _a4;
|
|
270
|
+
const id = this._getIdWithUnitId(unitId, subUnitId, commentId);
|
|
271
|
+
(_a4 = this._watcherMap.get(id)) == null || _a4.dispose(), this._watcherMap.delete(id);
|
|
271
272
|
}
|
|
272
|
-
_unregister(
|
|
273
|
-
var
|
|
274
|
-
const
|
|
275
|
-
(
|
|
273
|
+
_unregister(unitId, subUnitId, commentId) {
|
|
274
|
+
var _a4;
|
|
275
|
+
const id = this._getIdWithUnitId(unitId, subUnitId, commentId);
|
|
276
|
+
(_a4 = this._disposableMap.get(id)) == null || _a4.dispose(), this._disposableMap.delete(id);
|
|
276
277
|
}
|
|
277
278
|
_initData() {
|
|
278
|
-
const
|
|
279
|
-
for (const
|
|
280
|
-
for (const
|
|
281
|
-
const { unitId
|
|
282
|
-
...
|
|
283
|
-
...
|
|
279
|
+
const datas = this._threadCommentModel.getAll();
|
|
280
|
+
for (const data of datas)
|
|
281
|
+
for (const thread of data.threads) {
|
|
282
|
+
const { unitId, subUnitId, root } = thread, pos = singleReferenceToGrid(root.ref), sheetComment = {
|
|
283
|
+
...root,
|
|
284
|
+
...pos
|
|
284
285
|
};
|
|
285
|
-
this._register(
|
|
286
|
+
this._register(unitId, subUnitId, sheetComment), this._watch(unitId, subUnitId, sheetComment);
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
_initRefRange() {
|
|
289
290
|
this.disposeWithMe(
|
|
290
|
-
this._sheetsThreadCommentModel.commentUpdate$.subscribe((
|
|
291
|
-
const { unitId
|
|
292
|
-
switch (
|
|
291
|
+
this._sheetsThreadCommentModel.commentUpdate$.subscribe((option) => {
|
|
292
|
+
const { unitId, subUnitId } = option;
|
|
293
|
+
switch (option.type) {
|
|
293
294
|
case "add": {
|
|
294
|
-
if (
|
|
295
|
+
if (option.payload.parentId)
|
|
295
296
|
return;
|
|
296
|
-
const
|
|
297
|
-
...
|
|
298
|
-
row:
|
|
299
|
-
column:
|
|
297
|
+
const comment = {
|
|
298
|
+
...option.payload,
|
|
299
|
+
row: option.row,
|
|
300
|
+
column: option.column
|
|
300
301
|
};
|
|
301
|
-
this._register(
|
|
302
|
+
this._register(option.unitId, option.subUnitId, comment), this._watch(option.unitId, option.subUnitId, comment);
|
|
302
303
|
break;
|
|
303
304
|
}
|
|
304
305
|
case "delete": {
|
|
305
|
-
this._unregister(
|
|
306
|
+
this._unregister(unitId, subUnitId, option.payload.commentId), this._unwatch(unitId, subUnitId, option.payload.commentId);
|
|
306
307
|
break;
|
|
307
308
|
}
|
|
308
309
|
case "updateRef": {
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
310
|
+
const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, option.payload.commentId);
|
|
311
|
+
if (!comment)
|
|
311
312
|
return;
|
|
312
|
-
this._unregister(
|
|
313
|
-
const
|
|
314
|
-
...
|
|
315
|
-
row:
|
|
316
|
-
column:
|
|
313
|
+
this._unregister(unitId, subUnitId, option.payload.commentId);
|
|
314
|
+
const sheetComment = {
|
|
315
|
+
...comment,
|
|
316
|
+
row: option.row,
|
|
317
|
+
column: option.column
|
|
317
318
|
};
|
|
318
|
-
|
|
319
|
+
option.silent || (this._unwatch(unitId, subUnitId, option.payload.commentId), this._watch(unitId, subUnitId, sheetComment)), this._register(option.unitId, option.subUnitId, sheetComment);
|
|
319
320
|
break;
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
})
|
|
323
|
-
), this.disposeWithMe(
|
|
324
|
-
this._disposableMap.forEach((
|
|
325
|
-
|
|
324
|
+
), this.disposeWithMe(toDisposable(() => {
|
|
325
|
+
this._disposableMap.forEach((item) => {
|
|
326
|
+
item.dispose();
|
|
326
327
|
}), this._disposableMap.clear();
|
|
327
328
|
}));
|
|
328
329
|
}
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
],
|
|
337
|
-
const
|
|
338
|
-
var
|
|
339
|
-
for (var
|
|
340
|
-
(
|
|
341
|
-
return
|
|
342
|
-
},
|
|
343
|
-
let
|
|
344
|
-
constructor(
|
|
345
|
-
super(), this._injector =
|
|
330
|
+
}, __name(_a2, "SheetsThreadCommentRefRangeController"), _a2);
|
|
331
|
+
SheetsThreadCommentRefRangeController = __decorateClass$1([
|
|
332
|
+
__decorateParam$1(0, Inject(RefRangeService)),
|
|
333
|
+
__decorateParam$1(1, Inject(SheetsThreadCommentModel)),
|
|
334
|
+
__decorateParam$1(2, Inject(ThreadCommentModel)),
|
|
335
|
+
__decorateParam$1(3, Inject(SheetsSelectionsService)),
|
|
336
|
+
__decorateParam$1(4, ICommandService)
|
|
337
|
+
], SheetsThreadCommentRefRangeController);
|
|
338
|
+
const SHEET_THREAD_COMMENT_BASE = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
339
|
+
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) => {
|
|
340
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
341
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
342
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
343
|
+
}, "__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"), _a3;
|
|
344
|
+
let UniverSheetsThreadCommentPlugin = (_a3 = class extends Plugin {
|
|
345
|
+
constructor(config, _injector, _commandService) {
|
|
346
|
+
super(), this._injector = _injector, this._commandService = _commandService;
|
|
346
347
|
}
|
|
347
348
|
onStarting() {
|
|
348
349
|
[
|
|
349
|
-
[
|
|
350
|
-
[
|
|
351
|
-
].forEach((
|
|
352
|
-
this._injector.add(
|
|
353
|
-
}), this._injector.get(
|
|
350
|
+
[SheetsThreadCommentModel],
|
|
351
|
+
[SheetsThreadCommentRefRangeController]
|
|
352
|
+
].forEach((dep) => {
|
|
353
|
+
this._injector.add(dep);
|
|
354
|
+
}), this._injector.get(SheetsThreadCommentRefRangeController);
|
|
354
355
|
}
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
],
|
|
356
|
+
}, __name(_a3, "UniverSheetsThreadCommentPlugin"), _a3);
|
|
357
|
+
__publicField2(UniverSheetsThreadCommentPlugin, "pluginName", SHEET_THREAD_COMMENT_BASE);
|
|
358
|
+
__publicField2(UniverSheetsThreadCommentPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
359
|
+
UniverSheetsThreadCommentPlugin = __decorateClass([
|
|
360
|
+
DependentOn(UniverThreadCommentPlugin),
|
|
361
|
+
__decorateParam(1, Inject(Injector)),
|
|
362
|
+
__decorateParam(2, Inject(ICommandService))
|
|
363
|
+
], UniverSheetsThreadCommentPlugin);
|
|
363
364
|
export {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
365
|
+
SheetsThreadCommentModel,
|
|
366
|
+
SheetsThreadCommentRefRangeController,
|
|
367
|
+
UniverSheetsThreadCommentPlugin
|
|
367
368
|
};
|