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