@univerjs/sheets-thread-comment 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -932
- package/lib/es/index.js +1 -463
- package/lib/facade.js +1 -932
- package/lib/index.js +1 -463
- package/lib/types/controllers/sheets-thread-comment-ref-range.controller.d.ts +15 -0
- package/lib/types/controllers/sheets-thread-comment-resource.controller.d.ts +15 -0
- package/lib/types/facade/f-event.d.ts +20 -4
- package/lib/types/facade/f-range.d.ts +16 -1
- package/lib/types/facade/f-thread-comment.d.ts +18 -2
- package/lib/types/facade/f-univer.d.ts +18 -3
- package/lib/types/facade/f-workbook.d.ts +18 -2
- package/lib/types/facade/f-worksheet.d.ts +17 -2
- package/lib/types/models/sheets-thread-comment.model.d.ts +19 -3
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/types/interfaces/i-sheet-thread-comment.d.ts +16 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +10 -9
package/lib/es/index.js
CHANGED
|
@@ -1,463 +1 @@
|
|
|
1
|
-
var W = Object.defineProperty;
|
|
2
|
-
var j = (a, e, n) => e in a ? W(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3
|
-
var _ = (a, e, n) => j(a, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { Inject as h, IUniverInstanceService as O, Disposable as R, ObjectMatrix as N, UniverInstanceType as C, ICommandService as P, sequenceExecuteAsync as L, toDisposable as V, generateRandomId as T, DependentOn as B, Injector as H, Plugin as k, touchDependencies as F } from "@univerjs/core";
|
|
5
|
-
import { singleReferenceToGrid as g, serializeRange as E } from "@univerjs/engine-formula";
|
|
6
|
-
import { RefRangeService as z, SheetsSelectionsService as G, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as q, SheetInterceptorService as J, RemoveSheetCommand as K, CopySheetCommand as Q } from "@univerjs/sheets";
|
|
7
|
-
import { ThreadCommentModel as U, AddCommentMutation as I, DeleteCommentMutation as y, UpdateCommentRefMutation as x, IThreadCommentDataSourceService as X, UniverThreadCommentPlugin as Y } from "@univerjs/thread-comment";
|
|
8
|
-
import { Subject as Z } from "rxjs";
|
|
9
|
-
var ee = Object.getOwnPropertyDescriptor, te = (a, e, n, t) => {
|
|
10
|
-
for (var r = t > 1 ? void 0 : t ? ee(e, n) : e, s = a.length - 1, o; s >= 0; s--)
|
|
11
|
-
(o = a[s]) && (r = o(r) || r);
|
|
12
|
-
return r;
|
|
13
|
-
}, D = (a, e) => (n, t) => e(n, t, a);
|
|
14
|
-
let M = class extends R {
|
|
15
|
-
constructor(e, n) {
|
|
16
|
-
super();
|
|
17
|
-
_(this, "_matrixMap", /* @__PURE__ */ new Map());
|
|
18
|
-
_(this, "_locationMap", /* @__PURE__ */ new Map());
|
|
19
|
-
_(this, "_commentUpdate$", new Z());
|
|
20
|
-
_(this, "commentUpdate$", this._commentUpdate$.asObservable());
|
|
21
|
-
this._threadCommentModel = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
|
|
22
|
-
this._commentUpdate$.complete();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
_init() {
|
|
26
|
-
this._initData(), this._initUpdateTransform();
|
|
27
|
-
}
|
|
28
|
-
_ensureCommentMatrix(e, n) {
|
|
29
|
-
let t = this._matrixMap.get(e);
|
|
30
|
-
t || (t = /* @__PURE__ */ new Map(), this._matrixMap.set(e, t));
|
|
31
|
-
let r = t.get(n);
|
|
32
|
-
return r || (r = new N(), t.set(n, r)), r;
|
|
33
|
-
}
|
|
34
|
-
_ensureCommentLocationMap(e, n) {
|
|
35
|
-
let t = this._locationMap.get(e);
|
|
36
|
-
t || (t = /* @__PURE__ */ new Map(), this._locationMap.set(e, t));
|
|
37
|
-
let r = t.get(n);
|
|
38
|
-
return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
|
|
39
|
-
}
|
|
40
|
-
_addCommentToMatrix(e, n, t, r) {
|
|
41
|
-
var o;
|
|
42
|
-
const s = (o = e.getValue(n, t)) != null ? o : /* @__PURE__ */ new Set();
|
|
43
|
-
s.add(r), e.setValue(n, t, s);
|
|
44
|
-
}
|
|
45
|
-
_deleteCommentFromMatrix(e, n, t, r) {
|
|
46
|
-
if (n >= 0 && t >= 0) {
|
|
47
|
-
const s = e.getValue(n, t);
|
|
48
|
-
s && s.has(r) && (s.delete(r), s.size === 0 && e.realDeleteValue(n, t));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
_ensure(e, n) {
|
|
52
|
-
const t = this._ensureCommentMatrix(e, n), r = this._ensureCommentLocationMap(e, n);
|
|
53
|
-
return { matrix: t, locationMap: r };
|
|
54
|
-
}
|
|
55
|
-
_initData() {
|
|
56
|
-
const e = this._threadCommentModel.getAll();
|
|
57
|
-
for (const n of e)
|
|
58
|
-
for (const t of n.threads) {
|
|
59
|
-
const { unitId: r, subUnitId: s, root: o } = t;
|
|
60
|
-
this._addComment(r, s, o);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
_addComment(e, n, t) {
|
|
64
|
-
const r = g(t.ref), s = t.parentId, { row: o, column: i } = r, c = t.id, { matrix: m, locationMap: d } = this._ensure(e, n);
|
|
65
|
-
!s && o >= 0 && i >= 0 && (this._addCommentToMatrix(m, o, i, c), d.set(c, { row: o, column: i })), s || this._commentUpdate$.next({
|
|
66
|
-
unitId: e,
|
|
67
|
-
subUnitId: n,
|
|
68
|
-
payload: t,
|
|
69
|
-
type: "add",
|
|
70
|
-
isRoot: !s,
|
|
71
|
-
...r
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// eslint-disable-next-line max-lines-per-function
|
|
75
|
-
_initUpdateTransform() {
|
|
76
|
-
this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((e) => {
|
|
77
|
-
const { unitId: n, subUnitId: t } = e;
|
|
78
|
-
try {
|
|
79
|
-
if (this._univerInstanceService.getUnitType(n) !== C.UNIVER_SHEET)
|
|
80
|
-
return;
|
|
81
|
-
} catch {
|
|
82
|
-
}
|
|
83
|
-
const { matrix: r, locationMap: s } = this._ensure(n, t);
|
|
84
|
-
switch (e.type) {
|
|
85
|
-
case "add": {
|
|
86
|
-
this._addComment(e.unitId, e.subUnitId, e.payload);
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case "delete": {
|
|
90
|
-
const { isRoot: o, comment: i } = e.payload;
|
|
91
|
-
if (o) {
|
|
92
|
-
const c = g(i.ref), { row: m, column: d } = c;
|
|
93
|
-
this._deleteCommentFromMatrix(r, m, d, i.id), this._commentUpdate$.next({
|
|
94
|
-
...e,
|
|
95
|
-
...c
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case "update": {
|
|
101
|
-
const { commentId: o } = e.payload, i = this._threadCommentModel.getComment(n, t, o);
|
|
102
|
-
if (!i)
|
|
103
|
-
return;
|
|
104
|
-
const c = g(i.ref);
|
|
105
|
-
this._commentUpdate$.next({
|
|
106
|
-
...e,
|
|
107
|
-
...c
|
|
108
|
-
});
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
case "updateRef": {
|
|
112
|
-
const o = g(e.payload.ref), { commentId: i } = e.payload, c = s.get(i);
|
|
113
|
-
if (!c)
|
|
114
|
-
return;
|
|
115
|
-
const { row: m, column: d } = c;
|
|
116
|
-
this._deleteCommentFromMatrix(r, m, d, i), s.delete(i), o.row >= 0 && o.column >= 0 && (this._addCommentToMatrix(r, o.row, o.column, i), s.set(i, { row: o.row, column: o.column })), this._commentUpdate$.next({
|
|
117
|
-
...e,
|
|
118
|
-
...o
|
|
119
|
-
});
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case "resolve": {
|
|
123
|
-
const { unitId: o, subUnitId: i, payload: c } = e, { locationMap: m } = this._ensure(o, i), d = m.get(c.commentId);
|
|
124
|
-
d && this._commentUpdate$.next({
|
|
125
|
-
...e,
|
|
126
|
-
...d
|
|
127
|
-
});
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
getByLocation(e, n, t, r) {
|
|
134
|
-
var i;
|
|
135
|
-
return (i = this.getAllByLocation(e, n, t, r).filter((c) => !c.resolved)[0]) == null ? void 0 : i.id;
|
|
136
|
-
}
|
|
137
|
-
getAllByLocation(e, n, t, r) {
|
|
138
|
-
const o = this._ensureCommentMatrix(e, n).getValue(t, r);
|
|
139
|
-
return o ? Array.from(o).map((i) => this.getComment(e, n, i)).filter(Boolean) : [];
|
|
140
|
-
}
|
|
141
|
-
getComment(e, n, t) {
|
|
142
|
-
return this._threadCommentModel.getComment(e, n, t);
|
|
143
|
-
}
|
|
144
|
-
getCommentWithChildren(e, n, t, r) {
|
|
145
|
-
const s = this.getByLocation(e, n, t, r);
|
|
146
|
-
if (!s)
|
|
147
|
-
return;
|
|
148
|
-
const o = this.getComment(e, n, s);
|
|
149
|
-
if (o)
|
|
150
|
-
return this._threadCommentModel.getThread(e, n, o.threadId);
|
|
151
|
-
}
|
|
152
|
-
showCommentMarker(e, n, t, r) {
|
|
153
|
-
const s = this.getByLocation(e, n, t, r);
|
|
154
|
-
if (!s)
|
|
155
|
-
return !1;
|
|
156
|
-
const o = this.getComment(e, n, s);
|
|
157
|
-
return !!(o && !o.resolved);
|
|
158
|
-
}
|
|
159
|
-
getSubUnitAll(e, n) {
|
|
160
|
-
return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId === n).map((t) => t.root);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
M = te([
|
|
164
|
-
D(0, h(U)),
|
|
165
|
-
D(1, O)
|
|
166
|
-
], M);
|
|
167
|
-
var ne = Object.getOwnPropertyDescriptor, re = (a, e, n, t) => {
|
|
168
|
-
for (var r = t > 1 ? void 0 : t ? ne(e, n) : e, s = a.length - 1, o; s >= 0; s--)
|
|
169
|
-
(o = a[s]) && (r = o(r) || r);
|
|
170
|
-
return r;
|
|
171
|
-
}, p = (a, e) => (n, t) => e(n, t, a);
|
|
172
|
-
let v = class extends R {
|
|
173
|
-
constructor(e, n, t, r, s) {
|
|
174
|
-
super();
|
|
175
|
-
_(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
176
|
-
_(this, "_watcherMap", /* @__PURE__ */ new Map());
|
|
177
|
-
_(this, "_handleRangeChange", (e, n, t, r, s) => {
|
|
178
|
-
const o = t.id, i = {
|
|
179
|
-
startColumn: t.column,
|
|
180
|
-
endColumn: t.column,
|
|
181
|
-
startRow: t.row,
|
|
182
|
-
endRow: t.row
|
|
183
|
-
};
|
|
184
|
-
return r ? {
|
|
185
|
-
redos: [{
|
|
186
|
-
id: x.id,
|
|
187
|
-
params: {
|
|
188
|
-
unitId: e,
|
|
189
|
-
subUnitId: n,
|
|
190
|
-
payload: {
|
|
191
|
-
ref: E(r),
|
|
192
|
-
commentId: o
|
|
193
|
-
},
|
|
194
|
-
silent: s
|
|
195
|
-
}
|
|
196
|
-
}],
|
|
197
|
-
undos: [{
|
|
198
|
-
id: x.id,
|
|
199
|
-
params: {
|
|
200
|
-
unitId: e,
|
|
201
|
-
subUnitId: n,
|
|
202
|
-
payload: {
|
|
203
|
-
ref: E(i),
|
|
204
|
-
commentId: o
|
|
205
|
-
},
|
|
206
|
-
silent: s
|
|
207
|
-
}
|
|
208
|
-
}]
|
|
209
|
-
} : {
|
|
210
|
-
redos: [{
|
|
211
|
-
id: y.id,
|
|
212
|
-
params: {
|
|
213
|
-
unitId: e,
|
|
214
|
-
subUnitId: n,
|
|
215
|
-
commentId: o
|
|
216
|
-
}
|
|
217
|
-
}],
|
|
218
|
-
undos: [{
|
|
219
|
-
id: I.id,
|
|
220
|
-
params: {
|
|
221
|
-
unitId: e,
|
|
222
|
-
subUnitId: n,
|
|
223
|
-
comment: t,
|
|
224
|
-
sync: !0
|
|
225
|
-
}
|
|
226
|
-
}]
|
|
227
|
-
};
|
|
228
|
-
});
|
|
229
|
-
this._refRangeService = e, this._sheetsThreadCommentModel = n, this._threadCommentModel = t, this._selectionManagerService = r, this._commandService = s, this._initData(), this._initRefRange();
|
|
230
|
-
}
|
|
231
|
-
_getIdWithUnitId(e, n, t) {
|
|
232
|
-
return `${e}-${n}-${t}`;
|
|
233
|
-
}
|
|
234
|
-
_register(e, n, t) {
|
|
235
|
-
const r = t.id, s = {
|
|
236
|
-
startColumn: t.column,
|
|
237
|
-
endColumn: t.column,
|
|
238
|
-
startRow: t.row,
|
|
239
|
-
endRow: t.row
|
|
240
|
-
};
|
|
241
|
-
this._disposableMap.set(
|
|
242
|
-
this._getIdWithUnitId(e, n, r),
|
|
243
|
-
this._refRangeService.registerRefRange(s, (o) => {
|
|
244
|
-
const i = q(s, o, { selectionManagerService: this._selectionManagerService }), c = Array.isArray(i) ? i[0] : i;
|
|
245
|
-
return c && c.startColumn === s.startColumn && c.startRow === s.startRow ? {
|
|
246
|
-
undos: [],
|
|
247
|
-
redos: []
|
|
248
|
-
} : this._handleRangeChange(e, n, t, c, !1);
|
|
249
|
-
}, e, n)
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
_watch(e, n, t) {
|
|
253
|
-
const r = t.id, s = {
|
|
254
|
-
startColumn: t.column,
|
|
255
|
-
endColumn: t.column,
|
|
256
|
-
startRow: t.row,
|
|
257
|
-
endRow: t.row
|
|
258
|
-
};
|
|
259
|
-
this._watcherMap.set(
|
|
260
|
-
this._getIdWithUnitId(e, n, r),
|
|
261
|
-
this._refRangeService.watchRange(e, n, s, (o, i) => {
|
|
262
|
-
const { redos: c } = this._handleRangeChange(e, n, t, i, !0);
|
|
263
|
-
L(c, this._commandService, { onlyLocal: !0 });
|
|
264
|
-
}, !0)
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
_unwatch(e, n, t) {
|
|
268
|
-
var s;
|
|
269
|
-
const r = this._getIdWithUnitId(e, n, t);
|
|
270
|
-
(s = this._watcherMap.get(r)) == null || s.dispose(), this._watcherMap.delete(r);
|
|
271
|
-
}
|
|
272
|
-
_unregister(e, n, t) {
|
|
273
|
-
var s;
|
|
274
|
-
const r = this._getIdWithUnitId(e, n, t);
|
|
275
|
-
(s = this._disposableMap.get(r)) == null || s.dispose(), this._disposableMap.delete(r);
|
|
276
|
-
}
|
|
277
|
-
_initData() {
|
|
278
|
-
const e = this._threadCommentModel.getAll();
|
|
279
|
-
for (const n of e)
|
|
280
|
-
for (const t of n.threads) {
|
|
281
|
-
const { unitId: r, subUnitId: s, root: o } = t, i = g(o.ref), c = {
|
|
282
|
-
...o,
|
|
283
|
-
...i
|
|
284
|
-
};
|
|
285
|
-
this._register(r, s, c), this._watch(r, s, c);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
_initRefRange() {
|
|
289
|
-
this.disposeWithMe(
|
|
290
|
-
this._sheetsThreadCommentModel.commentUpdate$.subscribe((e) => {
|
|
291
|
-
const { unitId: n, subUnitId: t } = e;
|
|
292
|
-
switch (e.type) {
|
|
293
|
-
case "add": {
|
|
294
|
-
if (e.payload.parentId)
|
|
295
|
-
return;
|
|
296
|
-
const r = {
|
|
297
|
-
...e.payload,
|
|
298
|
-
row: e.row,
|
|
299
|
-
column: e.column
|
|
300
|
-
};
|
|
301
|
-
this._register(e.unitId, e.subUnitId, r), this._watch(e.unitId, e.subUnitId, r);
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
case "delete": {
|
|
305
|
-
this._unregister(n, t, e.payload.commentId), this._unwatch(n, t, e.payload.commentId);
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
case "updateRef": {
|
|
309
|
-
const r = this._sheetsThreadCommentModel.getComment(n, t, e.payload.commentId);
|
|
310
|
-
if (!r)
|
|
311
|
-
return;
|
|
312
|
-
this._unregister(n, t, e.payload.commentId);
|
|
313
|
-
const s = {
|
|
314
|
-
...r,
|
|
315
|
-
row: e.row,
|
|
316
|
-
column: e.column
|
|
317
|
-
};
|
|
318
|
-
e.silent || (this._unwatch(n, t, e.payload.commentId), this._watch(n, t, s)), this._register(e.unitId, e.subUnitId, s);
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
), this.disposeWithMe(V(() => {
|
|
324
|
-
this._disposableMap.forEach((e) => {
|
|
325
|
-
e.dispose();
|
|
326
|
-
}), this._disposableMap.clear();
|
|
327
|
-
}));
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
v = re([
|
|
331
|
-
p(0, h(z)),
|
|
332
|
-
p(1, h(M)),
|
|
333
|
-
p(2, h(U)),
|
|
334
|
-
p(3, h(G)),
|
|
335
|
-
p(4, P)
|
|
336
|
-
], v);
|
|
337
|
-
const se = "@univerjs/sheets-thread-comment", oe = "0.17.0", A = {
|
|
338
|
-
name: se,
|
|
339
|
-
version: oe
|
|
340
|
-
}, ae = {};
|
|
341
|
-
var ie = Object.getOwnPropertyDescriptor, ce = (a, e, n, t) => {
|
|
342
|
-
for (var r = t > 1 ? void 0 : t ? ie(e, n) : e, s = a.length - 1, o; s >= 0; s--)
|
|
343
|
-
(o = a[s]) && (r = o(r) || r);
|
|
344
|
-
return r;
|
|
345
|
-
}, f = (a, e) => (n, t) => e(n, t, a);
|
|
346
|
-
let S = class extends R {
|
|
347
|
-
constructor(a, e, n, t) {
|
|
348
|
-
super(), this._univerInstanceService = a, this._sheetInterceptorService = e, this._threadCommentModel = n, this._threadCommentDataSourceService = t, this._initSheetChange();
|
|
349
|
-
}
|
|
350
|
-
// eslint-disable-next-line max-lines-per-function
|
|
351
|
-
_initSheetChange() {
|
|
352
|
-
this.disposeWithMe(
|
|
353
|
-
this._sheetInterceptorService.interceptCommand({
|
|
354
|
-
// eslint-disable-next-line max-lines-per-function
|
|
355
|
-
getMutations: (a) => {
|
|
356
|
-
var e;
|
|
357
|
-
if (a.id === K.id) {
|
|
358
|
-
const n = a.params, t = n.unitId || this._univerInstanceService.getCurrentUnitOfType(C.UNIVER_SHEET).getUnitId(), r = n.subUnitId || ((e = this._univerInstanceService.getCurrentUnitOfType(C.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : e.getSheetId());
|
|
359
|
-
if (!t || !r)
|
|
360
|
-
return { redos: [], undos: [] };
|
|
361
|
-
const s = this._threadCommentModel.ensureMap(t, r), o = Array.from(s.values()).filter((d) => !d.parentId), i = this._threadCommentDataSourceService.syncUpdateMutationToColla, c = [], m = [];
|
|
362
|
-
return o.forEach(({ children: d, ...l }) => {
|
|
363
|
-
c.push({
|
|
364
|
-
id: y.id,
|
|
365
|
-
params: {
|
|
366
|
-
unitId: t,
|
|
367
|
-
subUnitId: r,
|
|
368
|
-
commentId: l.id
|
|
369
|
-
}
|
|
370
|
-
}), m.push({
|
|
371
|
-
id: I.id,
|
|
372
|
-
params: {
|
|
373
|
-
unitId: t,
|
|
374
|
-
subUnitId: r,
|
|
375
|
-
comment: {
|
|
376
|
-
...l,
|
|
377
|
-
children: i ? d : void 0
|
|
378
|
-
},
|
|
379
|
-
sync: !i
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
}), { redos: c, undos: m };
|
|
383
|
-
} else if (a.id === Q.id) {
|
|
384
|
-
const n = a.params, { unitId: t, subUnitId: r, targetSubUnitId: s } = n;
|
|
385
|
-
if (!t || !r || !s)
|
|
386
|
-
return { redos: [], undos: [] };
|
|
387
|
-
const o = this._threadCommentModel.ensureMap(t, r), i = Array.from(o.values()).map((l) => ({
|
|
388
|
-
...l,
|
|
389
|
-
subUnitId: s,
|
|
390
|
-
id: T(),
|
|
391
|
-
threadId: T()
|
|
392
|
-
})).filter((l) => !l.parentId), c = this._threadCommentDataSourceService.syncUpdateMutationToColla, m = [], d = [];
|
|
393
|
-
return i.forEach(({ children: l, ...b }) => {
|
|
394
|
-
m.push({
|
|
395
|
-
id: I.id,
|
|
396
|
-
params: {
|
|
397
|
-
unitId: t,
|
|
398
|
-
subUnitId: s,
|
|
399
|
-
comment: {
|
|
400
|
-
...b,
|
|
401
|
-
children: c ? l : void 0
|
|
402
|
-
},
|
|
403
|
-
sync: !c
|
|
404
|
-
}
|
|
405
|
-
}), d.push({
|
|
406
|
-
id: y.id,
|
|
407
|
-
params: {
|
|
408
|
-
unitId: t,
|
|
409
|
-
subUnitId: s,
|
|
410
|
-
commentId: b.id
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
}), { redos: m, undos: d };
|
|
414
|
-
}
|
|
415
|
-
return { redos: [], undos: [] };
|
|
416
|
-
}
|
|
417
|
-
})
|
|
418
|
-
);
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
S = ce([
|
|
422
|
-
f(0, O),
|
|
423
|
-
f(1, h(J)),
|
|
424
|
-
f(2, h(U)),
|
|
425
|
-
f(3, X)
|
|
426
|
-
], S);
|
|
427
|
-
const de = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
|
|
428
|
-
var me = Object.defineProperty, he = Object.getOwnPropertyDescriptor, le = (a, e, n) => e in a ? me(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n, _e = (a, e, n, t) => {
|
|
429
|
-
for (var r = t > 1 ? void 0 : t ? he(e, n) : e, s = a.length - 1, o; s >= 0; s--)
|
|
430
|
-
(o = a[s]) && (r = o(r) || r);
|
|
431
|
-
return r;
|
|
432
|
-
}, $ = (a, e) => (n, t) => e(n, t, a), w = (a, e, n) => le(a, typeof e != "symbol" ? e + "" : e, n);
|
|
433
|
-
let u = class extends k {
|
|
434
|
-
constructor(a = ae, e, n) {
|
|
435
|
-
super(), this._config = a, this._injector = e, this._commandService = n;
|
|
436
|
-
}
|
|
437
|
-
onStarting() {
|
|
438
|
-
[
|
|
439
|
-
[M],
|
|
440
|
-
[v],
|
|
441
|
-
[S]
|
|
442
|
-
].forEach((a) => {
|
|
443
|
-
this._injector.add(a);
|
|
444
|
-
}), F(this._injector, [
|
|
445
|
-
[v],
|
|
446
|
-
[S]
|
|
447
|
-
]);
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
w(u, "pluginName", de);
|
|
451
|
-
w(u, "packageName", A.name);
|
|
452
|
-
w(u, "version", A.version);
|
|
453
|
-
w(u, "type", C.UNIVER_SHEET);
|
|
454
|
-
u = _e([
|
|
455
|
-
B(Y),
|
|
456
|
-
$(1, h(H)),
|
|
457
|
-
$(2, h(P))
|
|
458
|
-
], u);
|
|
459
|
-
export {
|
|
460
|
-
M as SheetsThreadCommentModel,
|
|
461
|
-
v as SheetsThreadCommentRefRangeController,
|
|
462
|
-
u as UniverSheetsThreadCommentPlugin
|
|
463
|
-
};
|
|
1
|
+
import{DependentOn as e,Disposable as t,ICommandService as n,IUniverInstanceService as r,Inject as i,Injector as a,ObjectMatrix as o,Plugin as s,UniverInstanceType as c,generateRandomId as l,sequenceExecuteAsync as u,toDisposable as d,touchDependencies as f}from"@univerjs/core";import{serializeRange as p,singleReferenceToGrid as m}from"@univerjs/engine-formula";import{CopySheetCommand as h,RefRangeService as g,RemoveSheetCommand as _,SheetInterceptorService as v,SheetsSelectionsService as y,handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as b}from"@univerjs/sheets";import{AddCommentMutation as x,DeleteCommentMutation as S,IThreadCommentDataSourceService as C,ThreadCommentModel as w,UniverThreadCommentPlugin as T,UpdateCommentRefMutation as E}from"@univerjs/thread-comment";import{Subject as D}from"rxjs";function O(e){"@babel/helpers - typeof";return O=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},O(e)}function k(e,t){if(O(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(O(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function A(e){var t=k(e,`string`);return O(t)==`symbol`?t:t+``}function j(e,t,n){return(t=A(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e,t){return function(n,r){t(n,r,e)}}function N(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let P=class extends t{constructor(e,t){super(),this._threadCommentModel=e,this._univerInstanceService=t,j(this,`_matrixMap`,new Map),j(this,`_locationMap`,new Map),j(this,`_commentUpdate$`,new D),j(this,`commentUpdate$`,this._commentUpdate$.asObservable()),this._init(),this.disposeWithMe(()=>{this._commentUpdate$.complete()})}_init(){this._initData(),this._initUpdateTransform()}_ensureCommentMatrix(e,t){let n=this._matrixMap.get(e);n||(n=new Map,this._matrixMap.set(e,n));let r=n.get(t);return r||(r=new o,n.set(t,r)),r}_ensureCommentLocationMap(e,t){let n=this._locationMap.get(e);n||(n=new Map,this._locationMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_addCommentToMatrix(e,t,n,r){var i;let a=(i=e.getValue(t,n))==null?new Set:i;a.add(r),e.setValue(t,n,a)}_deleteCommentFromMatrix(e,t,n,r){if(t>=0&&n>=0){let i=e.getValue(t,n);i&&i.has(r)&&(i.delete(r),i.size===0&&e.realDeleteValue(t,n))}}_ensure(e,t){return{matrix:this._ensureCommentMatrix(e,t),locationMap:this._ensureCommentLocationMap(e,t)}}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:n,root:r}=e;this._addComment(t,n,r)}}_addComment(e,t,n){let r=m(n.ref),i=n.parentId,{row:a,column:o}=r,s=n.id,{matrix:c,locationMap:l}=this._ensure(e,t);!i&&a>=0&&o>=0&&(this._addCommentToMatrix(c,a,o,s),l.set(s,{row:a,column:o})),i||this._commentUpdate$.next({unitId:e,subUnitId:t,payload:n,type:`add`,isRoot:!i,...r})}_initUpdateTransform(){this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n}=e;try{if(this._univerInstanceService.getUnitType(t)!==c.UNIVER_SHEET)return}catch{}let{matrix:r,locationMap:i}=this._ensure(t,n);switch(e.type){case`add`:this._addComment(e.unitId,e.subUnitId,e.payload);break;case`delete`:{let{isRoot:t,comment:n}=e.payload;if(t){let t=m(n.ref),{row:i,column:a}=t;this._deleteCommentFromMatrix(r,i,a,n.id),this._commentUpdate$.next({...e,...t})}break}case`update`:{let{commentId:r}=e.payload,i=this._threadCommentModel.getComment(t,n,r);if(!i)return;let a=m(i.ref);this._commentUpdate$.next({...e,...a});break}case`updateRef`:{let t=m(e.payload.ref),{commentId:n}=e.payload,a=i.get(n);if(!a)return;let{row:o,column:s}=a;this._deleteCommentFromMatrix(r,o,s,n),i.delete(n),t.row>=0&&t.column>=0&&(this._addCommentToMatrix(r,t.row,t.column,n),i.set(n,{row:t.row,column:t.column})),this._commentUpdate$.next({...e,...t});break}case`resolve`:{let{unitId:t,subUnitId:n,payload:r}=e,{locationMap:i}=this._ensure(t,n),a=i.get(r.commentId);a&&this._commentUpdate$.next({...e,...a});break}default:break}}))}getByLocation(e,t,n,r){var i;return(i=this.getAllByLocation(e,t,n,r).filter(e=>!e.resolved)[0])==null?void 0:i.id}getAllByLocation(e,t,n,r){let i=this._ensureCommentMatrix(e,t).getValue(n,r);return i?Array.from(i).map(n=>this.getComment(e,t,n)).filter(Boolean):[]}getComment(e,t,n){return this._threadCommentModel.getComment(e,t,n)}getCommentWithChildren(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return;let a=this.getComment(e,t,i);if(a)return this._threadCommentModel.getThread(e,t,a.threadId)}showCommentMarker(e,t,n,r){let i=this.getByLocation(e,t,n,r);if(!i)return!1;let a=this.getComment(e,t,i);return!!(a&&!a.resolved)}getSubUnitAll(e,t){return this._threadCommentModel.getUnit(e).filter(e=>e.subUnitId===t).map(e=>e.root)}};P=N([M(0,i(w)),M(1,r)],P);let F=class extends t{constructor(e,t,n,r,i){super(),this._refRangeService=e,this._sheetsThreadCommentModel=t,this._threadCommentModel=n,this._selectionManagerService=r,this._commandService=i,j(this,`_disposableMap`,new Map),j(this,`_watcherMap`,new Map),j(this,`_handleRangeChange`,(e,t,n,r,i)=>{let a=n.id,o={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};return r?{redos:[{id:E.id,params:{unitId:e,subUnitId:t,payload:{ref:p(r),commentId:a},silent:i}}],undos:[{id:E.id,params:{unitId:e,subUnitId:t,payload:{ref:p(o),commentId:a},silent:i}}]}:{redos:[{id:S.id,params:{unitId:e,subUnitId:t,commentId:a}}],undos:[{id:x.id,params:{unitId:e,subUnitId:t,comment:n,sync:!0}}]}}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}-${t}-${n}`}_register(e,t,n){let r=n.id,i={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._disposableMap.set(this._getIdWithUnitId(e,t,r),this._refRangeService.registerRefRange(i,r=>{let a=b(i,r,{selectionManagerService:this._selectionManagerService}),o=Array.isArray(a)?a[0]:a;return o&&o.startColumn===i.startColumn&&o.startRow===i.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,n,o,!1)},e,t))}_watch(e,t,n){let r=n.id,i={startColumn:n.column,endColumn:n.column,startRow:n.row,endRow:n.row};this._watcherMap.set(this._getIdWithUnitId(e,t,r),this._refRangeService.watchRange(e,t,i,(r,i)=>{let{redos:a}=this._handleRangeChange(e,t,n,i,!0);u(a,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._watcherMap.get(i))==null||r.dispose(),this._watcherMap.delete(i)}_unregister(e,t,n){var r;let i=this._getIdWithUnitId(e,t,n);(r=this._disposableMap.get(i))==null||r.dispose(),this._disposableMap.delete(i)}_initData(){let e=this._threadCommentModel.getAll();for(let t of e)for(let e of t.threads){let{unitId:t,subUnitId:n,root:r}=e,i=m(r.ref),a={...r,...i};this._register(t,n,a),this._watch(t,n,a)}}_initRefRange(){this.disposeWithMe(this._sheetsThreadCommentModel.commentUpdate$.subscribe(e=>{let{unitId:t,subUnitId:n}=e;switch(e.type){case`add`:{if(e.payload.parentId)return;let t={...e.payload,row:e.row,column:e.column};this._register(e.unitId,e.subUnitId,t),this._watch(e.unitId,e.subUnitId,t);break}case`delete`:this._unregister(t,n,e.payload.commentId),this._unwatch(t,n,e.payload.commentId);break;case`updateRef`:{let r=this._sheetsThreadCommentModel.getComment(t,n,e.payload.commentId);if(!r)return;this._unregister(t,n,e.payload.commentId);let i={...r,row:e.row,column:e.column};e.silent||(this._unwatch(t,n,e.payload.commentId),this._watch(t,n,i)),this._register(e.unitId,e.subUnitId,i);break}}})),this.disposeWithMe(d(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};F=N([M(0,i(g)),M(1,i(P)),M(2,i(w)),M(3,i(y)),M(4,n)],F);var I=`@univerjs/sheets-thread-comment`,L=`0.18.0`;const R={};let z=class extends t{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._sheetInterceptorService=t,this._threadCommentModel=n,this._threadCommentDataSourceService=r,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===_.id){var t;let n=e.params,r=n.unitId||this._univerInstanceService.getCurrentUnitOfType(c.UNIVER_SHEET).getUnitId(),i=n.subUnitId||((t=this._univerInstanceService.getCurrentUnitOfType(c.UNIVER_SHEET).getActiveSheet())==null?void 0:t.getSheetId());if(!r||!i)return{redos:[],undos:[]};let a=this._threadCommentModel.ensureMap(r,i),o=Array.from(a.values()).filter(e=>!e.parentId),s=this._threadCommentDataSourceService.syncUpdateMutationToColla,l=[],u=[];return o.forEach(({children:e,...t})=>{l.push({id:S.id,params:{unitId:r,subUnitId:i,commentId:t.id}}),u.push({id:x.id,params:{unitId:r,subUnitId:i,comment:{...t,children:s?e:void 0},sync:!s}})}),{redos:l,undos:u}}else if(e.id===h.id){let{unitId:t,subUnitId:n,targetSubUnitId:r}=e.params;if(!t||!n||!r)return{redos:[],undos:[]};let i=this._threadCommentModel.ensureMap(t,n),a=Array.from(i.values()).map(e=>({...e,subUnitId:r,id:l(),threadId:l()})).filter(e=>!e.parentId),o=this._threadCommentDataSourceService.syncUpdateMutationToColla,s=[],c=[];return a.forEach(({children:e,...n})=>{s.push({id:x.id,params:{unitId:t,subUnitId:r,comment:{...n,children:o?e:void 0},sync:!o}}),c.push({id:S.id,params:{unitId:t,subUnitId:r,commentId:n.id}})}),{redos:s,undos:c}}return{redos:[],undos:[]}}}))}};z=N([M(0,r),M(1,i(v)),M(2,i(w)),M(3,C)],z);let B=class extends s{constructor(e=R,t,n){super(),this._config=e,this._injector=t,this._commandService=n}onStarting(){[[P],[F],[z]].forEach(e=>{this._injector.add(e)}),f(this._injector,[[F],[z]])}};j(B,`pluginName`,`SHEET_THREAD_COMMENT_BASE_PLUGIN`),j(B,`packageName`,I),j(B,`version`,L),j(B,`type`,c.UNIVER_SHEET),B=N([e(T),M(1,i(a)),M(2,i(n))],B);export{P as SheetsThreadCommentModel,F as SheetsThreadCommentRefRangeController,B as UniverSheetsThreadCommentPlugin};
|