@univerjs/thread-comment 0.1.17 → 0.2.1
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 +411 -387
- package/lib/types/commands/commands/comment.command.d.ts +3 -10
- package/lib/types/commands/mutations/comment.mutation.d.ts +1 -0
- package/lib/types/index.d.ts +4 -4
- package/lib/types/models/thread-comment.model.d.ts +18 -8
- package/lib/types/services/tc-datasource.service.d.ts +62 -13
- package/lib/types/types/interfaces/i-thread-comment.d.ts +9 -5
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
package/lib/es/index.js
CHANGED
|
@@ -1,500 +1,524 @@
|
|
|
1
|
-
var
|
|
2
|
-
var P = (
|
|
3
|
-
var
|
|
4
|
-
import { Subject as
|
|
5
|
-
import { CustomRangeType as L,
|
|
6
|
-
import { createIdentifier as
|
|
7
|
-
class
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var P = (n, t, e) => t in n ? x(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var h = (n, t, e) => P(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { Subject as A, BehaviorSubject as b, map as j } from "rxjs";
|
|
5
|
+
import { Disposable as E, CustomRangeType as L, ICommandService as f, OnLifecycle as V, LifecycleStages as W, IResourceManagerService as J, CommandType as p, Plugin as H, UniverInstanceType as B, mergeOverrideWithDependencies as G } from "@univerjs/core";
|
|
6
|
+
import { createIdentifier as K, Inject as g, Injector as Z } from "@wendellhu/redi";
|
|
7
|
+
class q extends E {
|
|
8
8
|
constructor() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
super();
|
|
10
|
+
h(this, "_dataSource", null);
|
|
11
|
+
h(this, "syncUpdateMutationToColla", !0);
|
|
12
|
+
}
|
|
13
|
+
set dataSource(e) {
|
|
14
|
+
this._dataSource = e;
|
|
15
|
+
}
|
|
16
|
+
get dataSource() {
|
|
17
|
+
return this._dataSource;
|
|
18
|
+
}
|
|
19
|
+
async getThreadComment(e, r, o) {
|
|
20
|
+
return this._dataSource ? (await this._dataSource.listComments(e, r, [o]))[0] : null;
|
|
21
|
+
}
|
|
22
|
+
async addComment(e) {
|
|
23
|
+
return this._dataSource ? this._dataSource.addComment(e) : e;
|
|
24
|
+
}
|
|
25
|
+
async updateComment(e) {
|
|
26
|
+
return this._dataSource ? this._dataSource.updateComment(e) : !0;
|
|
27
|
+
}
|
|
28
|
+
async resolveComment(e) {
|
|
29
|
+
return this._dataSource ? this._dataSource.resolveComment(e) : !0;
|
|
30
|
+
}
|
|
31
|
+
async deleteComment(e, r, o, a) {
|
|
32
|
+
return this._dataSource ? this._dataSource.deleteComment(e, r, o, a) : !0;
|
|
33
|
+
}
|
|
34
|
+
async listThreadComments(e, r, o) {
|
|
35
|
+
return this.dataSource ? this.dataSource.listComments(e, r, o) : [];
|
|
36
|
+
}
|
|
37
|
+
saveToSnapshot(e, r) {
|
|
38
|
+
if (this._dataSource) {
|
|
39
|
+
const o = {};
|
|
40
|
+
return Object.keys(e).forEach((a) => {
|
|
41
|
+
const m = e[a];
|
|
42
|
+
o[a] = m.map(this.dataSource.saveCommentToSnapshot);
|
|
43
|
+
}), o;
|
|
44
|
+
}
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const C = K("univer.thread-comment.data-source-service");
|
|
49
|
+
var z = Object.defineProperty, F = Object.getOwnPropertyDescriptor, Q = (n, t, e, r) => {
|
|
50
|
+
for (var o = r > 1 ? void 0 : r ? F(t, e) : t, a = n.length - 1, m; a >= 0; a--)
|
|
51
|
+
(m = n[a]) && (o = (r ? m(t, e, o) : m(o)) || o);
|
|
52
|
+
return r && o && z(t, e, o), o;
|
|
53
|
+
}, N = (n, t) => (e, r) => t(e, r, n);
|
|
54
|
+
let u = class {
|
|
55
|
+
constructor(n, t) {
|
|
56
|
+
h(this, "_commentsMap", {});
|
|
57
|
+
h(this, "_commentsTreeMap", /* @__PURE__ */ new Map());
|
|
58
|
+
h(this, "_threadMap", /* @__PURE__ */ new Map());
|
|
59
|
+
h(this, "_commentUpdate$", new A());
|
|
60
|
+
h(this, "_commentsMap$", new b({}));
|
|
61
|
+
h(this, "commentUpdate$", this._commentUpdate$.asObservable());
|
|
62
|
+
h(this, "commentMap$", this._commentsMap$.asObservable());
|
|
63
|
+
this._dataSourceService = n, this._commandService = t;
|
|
64
|
+
}
|
|
65
|
+
_ensureCommentMap(n, t) {
|
|
66
|
+
let e = this._commentsMap[n];
|
|
67
|
+
e || (e = {}, this._commentsMap[n] = e);
|
|
68
|
+
let r = e[t];
|
|
69
|
+
return r || (r = {}, e[t] = r), r;
|
|
70
|
+
}
|
|
71
|
+
_ensureCommentChildrenMap(n, t) {
|
|
72
|
+
let e = this._commentsTreeMap.get(n);
|
|
73
|
+
e || (e = /* @__PURE__ */ new Map(), this._commentsTreeMap.set(n, e));
|
|
74
|
+
let r = e.get(t);
|
|
75
|
+
return r || (r = /* @__PURE__ */ new Map(), e.set(t, r)), r;
|
|
76
|
+
}
|
|
77
|
+
_ensureThreadMap(n) {
|
|
78
|
+
let t = this._threadMap.get(n);
|
|
79
|
+
return t || (t = /* @__PURE__ */ new Map(), this._threadMap.set(n, t)), t;
|
|
29
80
|
}
|
|
30
81
|
_refreshCommentsMap$() {
|
|
31
82
|
this._commentsMap$.next({
|
|
32
83
|
...this._commentsMap
|
|
33
84
|
});
|
|
34
85
|
}
|
|
35
|
-
|
|
36
|
-
const e =
|
|
37
|
-
this._commentsTreeMap.forEach((n, t) => {
|
|
38
|
-
e[t] = {};
|
|
39
|
-
const o = e[t];
|
|
40
|
-
n.forEach((s, m) => {
|
|
41
|
-
o[m] = {};
|
|
42
|
-
const a = o[m];
|
|
43
|
-
s.forEach((d, c) => {
|
|
44
|
-
a[c] = d;
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}), this._commentsTreeMap$.next(e);
|
|
48
|
-
}
|
|
49
|
-
ensureMap(e, n) {
|
|
50
|
-
const t = this._ensureCommentMap(e, n), o = this._ensureCommentChildrenMap(e, n);
|
|
86
|
+
ensureMap(n, t) {
|
|
87
|
+
const e = this._ensureCommentMap(n, t), r = this._ensureCommentChildrenMap(n, t);
|
|
51
88
|
return {
|
|
52
|
-
commentMap:
|
|
53
|
-
commentChildrenMap:
|
|
89
|
+
commentMap: e,
|
|
90
|
+
commentChildrenMap: r
|
|
54
91
|
};
|
|
55
92
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
_replaceComment(n, t, e) {
|
|
94
|
+
var m;
|
|
95
|
+
const { commentMap: r, commentChildrenMap: o } = this.ensureMap(n, t), a = r[e.id];
|
|
96
|
+
if (a) {
|
|
97
|
+
const s = {
|
|
98
|
+
...e,
|
|
99
|
+
ref: a.ref
|
|
100
|
+
};
|
|
101
|
+
r[e.id] = s, (m = e.children) == null || m.forEach((c) => {
|
|
102
|
+
r[c.id] = {
|
|
103
|
+
...c,
|
|
104
|
+
ref: ""
|
|
105
|
+
};
|
|
106
|
+
}), o.set(e.id, s), this._commentUpdate$.next({
|
|
107
|
+
unitId: n,
|
|
108
|
+
subUnitId: t,
|
|
109
|
+
type: "syncUpdate",
|
|
110
|
+
payload: s
|
|
111
|
+
}), !!e.resolved != !!a.resolved && this._commentUpdate$.next({
|
|
112
|
+
unitId: n,
|
|
113
|
+
subUnitId: t,
|
|
114
|
+
type: "resolve",
|
|
115
|
+
payload: {
|
|
116
|
+
commentId: e.id,
|
|
117
|
+
resolved: !!e.resolved
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async syncThreadComments(n, t, e) {
|
|
123
|
+
const r = await this._dataSourceService.listThreadComments(n, t, e);
|
|
124
|
+
if (!r.length)
|
|
125
|
+
return;
|
|
126
|
+
const o = new Set(e);
|
|
127
|
+
r.forEach((a) => {
|
|
128
|
+
this._replaceComment(n, t, a), o.delete(a.threadId);
|
|
129
|
+
}), o.forEach((a) => {
|
|
130
|
+
const m = this.getThread(n, a);
|
|
131
|
+
m && this.deleteComment(m.unitId, m.subUnitId, m.id);
|
|
132
|
+
}), this._refreshCommentsMap$();
|
|
133
|
+
}
|
|
134
|
+
addComment(n, t, e, r) {
|
|
135
|
+
var d, l;
|
|
136
|
+
const { commentMap: o, commentChildrenMap: a } = this.ensureMap(n, t), m = e, s = (i) => {
|
|
137
|
+
o[i.id] = i, this._commentUpdate$.next({
|
|
138
|
+
unitId: n,
|
|
139
|
+
subUnitId: t,
|
|
140
|
+
type: "add",
|
|
141
|
+
payload: i,
|
|
142
|
+
isRoot: !i.parentId
|
|
143
|
+
});
|
|
144
|
+
}, c = m.parentId;
|
|
145
|
+
if (c) {
|
|
146
|
+
const i = o[c];
|
|
147
|
+
i.children = [
|
|
148
|
+
...(d = i.children) != null ? d : [],
|
|
149
|
+
m
|
|
150
|
+
], s(m);
|
|
67
151
|
} else
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
unitId: e,
|
|
80
|
-
subUnitId: n,
|
|
152
|
+
a.set(m.id, m), this._ensureThreadMap(n).set(m.threadId, m), s(m), (l = m.children) == null || l.forEach((M) => s({
|
|
153
|
+
...M,
|
|
154
|
+
ref: ""
|
|
155
|
+
}));
|
|
156
|
+
return this._refreshCommentsMap$(), r && this.syncThreadComments(n, t, [m.threadId]), !0;
|
|
157
|
+
}
|
|
158
|
+
updateComment(n, t, e, r) {
|
|
159
|
+
const { commentMap: o } = this.ensureMap(n, t), a = o[e.commentId];
|
|
160
|
+
return a ? (a.updated = !0, a.text = e.text, a.attachments = e.attachments, a.updateT = e.updateT, this._commentUpdate$.next({
|
|
161
|
+
unitId: n,
|
|
162
|
+
subUnitId: t,
|
|
81
163
|
type: "update",
|
|
82
|
-
payload:
|
|
83
|
-
silent:
|
|
84
|
-
}), this._refreshCommentsMap$(),
|
|
85
|
-
}
|
|
86
|
-
updateCommentRef(
|
|
87
|
-
const { commentMap:
|
|
88
|
-
return
|
|
89
|
-
unitId:
|
|
90
|
-
subUnitId:
|
|
164
|
+
payload: e,
|
|
165
|
+
silent: r
|
|
166
|
+
}), this._refreshCommentsMap$(), !0) : !1;
|
|
167
|
+
}
|
|
168
|
+
updateCommentRef(n, t, e, r) {
|
|
169
|
+
const { commentMap: o } = this.ensureMap(n, t), a = o[e.commentId];
|
|
170
|
+
return a ? (a.ref = e.ref, this._commentUpdate$.next({
|
|
171
|
+
unitId: n,
|
|
172
|
+
subUnitId: t,
|
|
91
173
|
type: "updateRef",
|
|
92
|
-
payload:
|
|
93
|
-
silent:
|
|
94
|
-
}), this._refreshCommentsMap$(),
|
|
95
|
-
}
|
|
96
|
-
resolveComment(
|
|
97
|
-
const { commentMap:
|
|
98
|
-
return
|
|
99
|
-
unitId:
|
|
100
|
-
subUnitId:
|
|
174
|
+
payload: e,
|
|
175
|
+
silent: r
|
|
176
|
+
}), this._refreshCommentsMap$(), !0) : !1;
|
|
177
|
+
}
|
|
178
|
+
resolveComment(n, t, e, r) {
|
|
179
|
+
const { commentMap: o } = this.ensureMap(n, t), a = o[e];
|
|
180
|
+
return a ? (a.resolved = r, this._commentUpdate$.next({
|
|
181
|
+
unitId: n,
|
|
182
|
+
subUnitId: t,
|
|
101
183
|
type: "resolve",
|
|
102
184
|
payload: {
|
|
103
|
-
commentId:
|
|
104
|
-
resolved:
|
|
185
|
+
commentId: e,
|
|
186
|
+
resolved: r
|
|
105
187
|
}
|
|
106
|
-
}), this._refreshCommentsMap$(),
|
|
188
|
+
}), this._refreshCommentsMap$(), !0) : !1;
|
|
107
189
|
}
|
|
108
|
-
getComment(
|
|
109
|
-
const { commentMap:
|
|
110
|
-
return
|
|
190
|
+
getComment(n, t, e) {
|
|
191
|
+
const { commentMap: r } = this.ensureMap(n, t);
|
|
192
|
+
return r[e];
|
|
111
193
|
}
|
|
112
|
-
getComment$(
|
|
113
|
-
return this._commentsMap$.pipe(
|
|
194
|
+
getComment$(n, t, e) {
|
|
195
|
+
return this._commentsMap$.pipe(j((r) => r[n][t][e]));
|
|
114
196
|
}
|
|
115
|
-
getCommentWithChildren(
|
|
116
|
-
var
|
|
117
|
-
const { commentMap:
|
|
118
|
-
if (!
|
|
197
|
+
getCommentWithChildren(n, t, e) {
|
|
198
|
+
var c, d;
|
|
199
|
+
const { commentMap: r, commentChildrenMap: o } = this.ensureMap(n, t), a = r[e];
|
|
200
|
+
if (!a)
|
|
119
201
|
return;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
202
|
+
const m = /* @__PURE__ */ new Set(), s = o.get(e);
|
|
203
|
+
if (s)
|
|
204
|
+
return [s, ...(c = s.children) != null ? c : []].forEach((l) => {
|
|
205
|
+
var i;
|
|
206
|
+
m.add(l.personId), (i = l.text.customRanges) == null || i.forEach((M) => {
|
|
207
|
+
M.rangeType === L.MENTION && m.add(M.rangeId);
|
|
208
|
+
});
|
|
209
|
+
}), {
|
|
210
|
+
root: a,
|
|
211
|
+
children: (d = s.children) != null ? d : [],
|
|
212
|
+
relativeUsers: m
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
deleteComment(n, t, e) {
|
|
216
|
+
var m;
|
|
217
|
+
const { commentMap: r, commentChildrenMap: o } = this.ensureMap(n, t), a = r[e];
|
|
218
|
+
if (!a)
|
|
219
|
+
return !0;
|
|
220
|
+
if (a.parentId) {
|
|
221
|
+
const s = o.get(a.parentId);
|
|
222
|
+
if (s && s.children) {
|
|
223
|
+
const c = s.children.findIndex((d) => d.id = e);
|
|
224
|
+
s.children.splice(c, 1);
|
|
141
225
|
}
|
|
142
|
-
delete
|
|
143
|
-
} else
|
|
144
|
-
delete
|
|
226
|
+
delete r[e];
|
|
227
|
+
} else {
|
|
228
|
+
delete r[e];
|
|
229
|
+
const s = o.get(e);
|
|
230
|
+
o.delete(e), this._ensureThreadMap(n).delete(a.threadId), (m = s == null ? void 0 : s.children) == null || m.forEach((d) => {
|
|
231
|
+
delete r[d.id], this._commentUpdate$.next({
|
|
232
|
+
unitId: n,
|
|
233
|
+
subUnitId: t,
|
|
234
|
+
type: "delete",
|
|
235
|
+
payload: {
|
|
236
|
+
commentId: d.id,
|
|
237
|
+
isRoot: !1,
|
|
238
|
+
comment: d
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
}
|
|
145
243
|
return this._commentUpdate$.next({
|
|
146
|
-
unitId:
|
|
147
|
-
subUnitId:
|
|
244
|
+
unitId: n,
|
|
245
|
+
subUnitId: t,
|
|
148
246
|
type: "delete",
|
|
149
247
|
payload: {
|
|
150
|
-
commentId:
|
|
151
|
-
isRoot: !
|
|
152
|
-
comment:
|
|
248
|
+
commentId: e,
|
|
249
|
+
isRoot: !a.parentId,
|
|
250
|
+
comment: a
|
|
153
251
|
}
|
|
154
|
-
}), this._refreshCommentsMap$(),
|
|
252
|
+
}), this._refreshCommentsMap$(), !0;
|
|
155
253
|
}
|
|
156
|
-
getUnit(
|
|
157
|
-
const
|
|
158
|
-
return
|
|
254
|
+
getUnit(n) {
|
|
255
|
+
const t = this._commentsMap[n];
|
|
256
|
+
return t ? Array.from(Object.entries(t)).map(([e, r]) => [e, Array.from(Object.values(r))]) : [];
|
|
159
257
|
}
|
|
160
|
-
deleteUnit(
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
Object.values(
|
|
164
|
-
this.deleteComment(
|
|
258
|
+
deleteUnit(n) {
|
|
259
|
+
const t = this._commentsMap[n];
|
|
260
|
+
t && Object.entries(t).forEach(([e, r]) => {
|
|
261
|
+
Object.values(r).forEach((o) => {
|
|
262
|
+
this.deleteComment(n, e, o.id);
|
|
165
263
|
});
|
|
166
264
|
});
|
|
167
265
|
}
|
|
168
|
-
getRootCommentIds(
|
|
169
|
-
const
|
|
170
|
-
return Array.from(
|
|
171
|
-
}
|
|
172
|
-
getRootCommentIds$(e, n) {
|
|
173
|
-
return this._commentsTreeMap$.pipe(R(
|
|
174
|
-
(t) => {
|
|
175
|
-
var o;
|
|
176
|
-
return Object.keys((o = t[e]) == null ? void 0 : o[n]);
|
|
177
|
-
}
|
|
178
|
-
));
|
|
266
|
+
getRootCommentIds(n, t) {
|
|
267
|
+
const e = this._ensureCommentChildrenMap(n, t);
|
|
268
|
+
return Array.from(e.keys());
|
|
179
269
|
}
|
|
180
270
|
getAll() {
|
|
181
271
|
return this._commentsMap;
|
|
182
272
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const x = "THREAD_COMMENT_PLUGIN";
|
|
186
|
-
class z {
|
|
187
|
-
async addComment(e) {
|
|
188
|
-
return e;
|
|
273
|
+
getThread(n, t) {
|
|
274
|
+
return this._ensureThreadMap(n).get(t);
|
|
189
275
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
const f = Z("univer.thread-comment.data-source-service");
|
|
207
|
-
var Q = Object.defineProperty, X = Object.getOwnPropertyDescriptor, Y = (r, e, n, t) => {
|
|
208
|
-
for (var o = t > 1 ? void 0 : t ? X(e, n) : e, s = r.length - 1, m; s >= 0; s--)
|
|
209
|
-
(m = r[s]) && (o = (t ? m(e, n, o) : m(o)) || o);
|
|
210
|
-
return t && o && Q(e, n, o), o;
|
|
211
|
-
}, N = (r, e) => (n, t) => e(n, t, r);
|
|
212
|
-
let U = class extends V {
|
|
213
|
-
constructor(r, e, n) {
|
|
214
|
-
super(), this._resourceManagerService = r, this._threadCommentModel = e, this._threadCommentDataSourceService = n, this._initSnapshot();
|
|
276
|
+
};
|
|
277
|
+
u = Q([
|
|
278
|
+
N(0, g(C)),
|
|
279
|
+
N(1, f)
|
|
280
|
+
], u);
|
|
281
|
+
var y = /* @__PURE__ */ ((n) => (n[n.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", n[n.UNIVER_DOC = 1] = "UNIVER_DOC", n[n.UNIVER_SHEET = 2] = "UNIVER_SHEET", n[n.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", n[n.UNRECOGNIZED = -1] = "UNRECOGNIZED", n))(y || {});
|
|
282
|
+
const $ = "THREAD_COMMENT_PLUGIN";
|
|
283
|
+
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, k = (n, t, e, r) => {
|
|
284
|
+
for (var o = r > 1 ? void 0 : r ? Y(t, e) : t, a = n.length - 1, m; a >= 0; a--)
|
|
285
|
+
(m = n[a]) && (o = (r ? m(t, e, o) : m(o)) || o);
|
|
286
|
+
return r && o && X(t, e, o), o;
|
|
287
|
+
}, S = (n, t) => (e, r) => t(e, r, n);
|
|
288
|
+
let v = class extends E {
|
|
289
|
+
constructor(n, t, e) {
|
|
290
|
+
super(), this._resourceManagerService = n, this._threadCommentModel = t, this._threadCommentDataSourceService = e, this._initSnapshot();
|
|
215
291
|
}
|
|
216
292
|
_initSnapshot() {
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
return
|
|
220
|
-
o[
|
|
221
|
-
}), JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o))) : "";
|
|
222
|
-
},
|
|
223
|
-
if (!
|
|
293
|
+
const n = (e) => {
|
|
294
|
+
const r = this._threadCommentModel.getUnit(e), o = {};
|
|
295
|
+
return r ? (r.forEach(([a, m]) => {
|
|
296
|
+
o[a] = m;
|
|
297
|
+
}), JSON.stringify(this._threadCommentDataSourceService.saveToSnapshot(o, e))) : "";
|
|
298
|
+
}, t = (e) => {
|
|
299
|
+
if (!e)
|
|
224
300
|
return {};
|
|
225
301
|
try {
|
|
226
|
-
return JSON.parse(
|
|
302
|
+
return JSON.parse(e);
|
|
227
303
|
} catch {
|
|
228
304
|
return {};
|
|
229
305
|
}
|
|
230
306
|
};
|
|
231
307
|
this.disposeWithMe(
|
|
232
308
|
this._resourceManagerService.registerPluginResource({
|
|
233
|
-
pluginName: `SHEET_${
|
|
234
|
-
businesses: [
|
|
235
|
-
toJson: (
|
|
236
|
-
parseJson: (
|
|
237
|
-
onUnLoad: (
|
|
238
|
-
this._threadCommentModel.deleteUnit(
|
|
309
|
+
pluginName: `SHEET_${$}`,
|
|
310
|
+
businesses: [y.UNIVER_SHEET, y.UNIVER_DOC],
|
|
311
|
+
toJson: (e) => n(e),
|
|
312
|
+
parseJson: (e) => t(e),
|
|
313
|
+
onUnLoad: (e) => {
|
|
314
|
+
this._threadCommentModel.deleteUnit(e);
|
|
239
315
|
},
|
|
240
|
-
onLoad: async (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
this._threadCommentModel.addComment(
|
|
245
|
-
});
|
|
316
|
+
onLoad: async (e, r) => {
|
|
317
|
+
Object.keys(r).forEach((o) => {
|
|
318
|
+
const a = r[o];
|
|
319
|
+
a.forEach((m) => {
|
|
320
|
+
this._threadCommentModel.addComment(e, o, m);
|
|
321
|
+
}), this._threadCommentModel.syncThreadComments(e, o, a.map((m) => m.threadId));
|
|
246
322
|
});
|
|
247
323
|
}
|
|
248
324
|
})
|
|
249
325
|
);
|
|
250
326
|
}
|
|
251
327
|
};
|
|
252
|
-
|
|
253
|
-
W
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
],
|
|
258
|
-
const
|
|
328
|
+
v = k([
|
|
329
|
+
V(W.Starting, v),
|
|
330
|
+
S(0, J),
|
|
331
|
+
S(1, g(u)),
|
|
332
|
+
S(2, C)
|
|
333
|
+
], v);
|
|
334
|
+
const R = {
|
|
259
335
|
id: "thread-comment.mutation.add-comment",
|
|
260
|
-
type:
|
|
261
|
-
handler(
|
|
262
|
-
if (!
|
|
336
|
+
type: p.MUTATION,
|
|
337
|
+
handler(n, t, e) {
|
|
338
|
+
if (!t)
|
|
263
339
|
return !1;
|
|
264
|
-
const
|
|
265
|
-
return
|
|
340
|
+
const r = n.get(u), { unitId: o, subUnitId: a, comment: m, sync: s } = t, c = s || (e == null ? void 0 : e.fromChangeset) && !m.parentId;
|
|
341
|
+
return r.addComment(o, a, m, c);
|
|
266
342
|
}
|
|
267
|
-
},
|
|
343
|
+
}, D = {
|
|
268
344
|
id: "thread-comment.mutation.update-comment",
|
|
269
|
-
type:
|
|
270
|
-
handler(
|
|
271
|
-
if (!
|
|
345
|
+
type: p.MUTATION,
|
|
346
|
+
handler(n, t) {
|
|
347
|
+
if (!t)
|
|
272
348
|
return !1;
|
|
273
|
-
const
|
|
274
|
-
return
|
|
349
|
+
const e = n.get(u), { unitId: r, subUnitId: o, payload: a, silent: m } = t;
|
|
350
|
+
return e.updateComment(r, o, a, m);
|
|
275
351
|
}
|
|
276
|
-
},
|
|
352
|
+
}, ee = {
|
|
277
353
|
id: "thread-comment.mutation.update-comment-ref",
|
|
278
|
-
type:
|
|
279
|
-
handler(
|
|
280
|
-
if (!
|
|
354
|
+
type: p.MUTATION,
|
|
355
|
+
handler(n, t) {
|
|
356
|
+
if (!t)
|
|
281
357
|
return !1;
|
|
282
|
-
const
|
|
283
|
-
return
|
|
358
|
+
const e = n.get(u), { unitId: r, subUnitId: o, payload: a, silent: m } = t;
|
|
359
|
+
return e.updateCommentRef(r, o, a, m);
|
|
284
360
|
}
|
|
285
361
|
}, w = {
|
|
286
362
|
id: "thread-comment.mutation.resolve-comment",
|
|
287
|
-
type:
|
|
288
|
-
handler(
|
|
289
|
-
if (!
|
|
363
|
+
type: p.MUTATION,
|
|
364
|
+
handler(n, t) {
|
|
365
|
+
if (!t)
|
|
290
366
|
return !1;
|
|
291
|
-
const
|
|
292
|
-
return
|
|
367
|
+
const e = n.get(u), { unitId: r, subUnitId: o, resolved: a, commentId: m } = t;
|
|
368
|
+
return e.resolveComment(r, o, m, a);
|
|
293
369
|
}
|
|
294
|
-
},
|
|
370
|
+
}, T = {
|
|
295
371
|
id: "thread-comment.mutation.delete-comment",
|
|
296
|
-
type:
|
|
297
|
-
handler(
|
|
298
|
-
if (!
|
|
372
|
+
type: p.MUTATION,
|
|
373
|
+
handler(n, t) {
|
|
374
|
+
if (!t)
|
|
299
375
|
return !1;
|
|
300
|
-
const
|
|
301
|
-
return
|
|
376
|
+
const e = n.get(u), { unitId: r, subUnitId: o, commentId: a } = t;
|
|
377
|
+
return e.deleteComment(r, o, a);
|
|
302
378
|
}
|
|
303
|
-
},
|
|
379
|
+
}, te = {
|
|
304
380
|
id: "thread-comment.command.add-comment",
|
|
305
|
-
type:
|
|
306
|
-
async handler(
|
|
307
|
-
if (!
|
|
381
|
+
type: p.COMMAND,
|
|
382
|
+
async handler(n, t) {
|
|
383
|
+
if (!t)
|
|
308
384
|
return !1;
|
|
309
|
-
const
|
|
310
|
-
id:
|
|
311
|
-
params: e
|
|
312
|
-
}, u = {
|
|
313
|
-
id: y.id,
|
|
385
|
+
const e = n.get(f), r = n.get(C), { comment: o } = t, a = await r.addComment(o), m = r.syncUpdateMutationToColla, s = !o.parentId, c = {
|
|
386
|
+
id: R.id,
|
|
314
387
|
params: {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
commentId: d.id
|
|
388
|
+
...t,
|
|
389
|
+
comment: a
|
|
318
390
|
}
|
|
319
391
|
};
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
unitID: s
|
|
324
|
-
}), n.executeCommand(c.id, c.params), !0;
|
|
392
|
+
return s ? await e.executeCommand(c.id, c.params) : e.executeCommand(c.id, c.params, {
|
|
393
|
+
onlyLocal: !m
|
|
394
|
+
});
|
|
325
395
|
}
|
|
326
|
-
},
|
|
396
|
+
}, ne = {
|
|
327
397
|
id: "thread-comment.command.update-comment",
|
|
328
|
-
type:
|
|
329
|
-
async handler(
|
|
330
|
-
if (!
|
|
398
|
+
type: p.COMMAND,
|
|
399
|
+
async handler(n, t) {
|
|
400
|
+
if (!t)
|
|
331
401
|
return !1;
|
|
332
|
-
const { unitId:
|
|
333
|
-
|
|
334
|
-
|
|
402
|
+
const { unitId: e, subUnitId: r, payload: o } = t, a = n.get(f), m = n.get(u), s = n.get(C), c = s.syncUpdateMutationToColla, d = m.getComment(
|
|
403
|
+
e,
|
|
404
|
+
r,
|
|
335
405
|
o.commentId
|
|
336
406
|
);
|
|
337
|
-
if (!
|
|
338
|
-
|
|
407
|
+
if (!d)
|
|
408
|
+
return !1;
|
|
409
|
+
const { children: l, ...i } = d;
|
|
410
|
+
if (!await s.updateComment({
|
|
411
|
+
...i,
|
|
339
412
|
...o
|
|
340
413
|
}))
|
|
341
414
|
return !1;
|
|
342
|
-
const
|
|
343
|
-
id:
|
|
344
|
-
params:
|
|
345
|
-
}, C = {
|
|
346
|
-
id: g.id,
|
|
347
|
-
params: {
|
|
348
|
-
unitId: n,
|
|
349
|
-
subUnitId: t,
|
|
350
|
-
payload: {
|
|
351
|
-
commentId: o.commentId,
|
|
352
|
-
text: c.text,
|
|
353
|
-
attachments: c.attachments,
|
|
354
|
-
updateT: c.updateT,
|
|
355
|
-
updated: c.updated
|
|
356
|
-
}
|
|
357
|
-
}
|
|
415
|
+
const U = {
|
|
416
|
+
id: D.id,
|
|
417
|
+
params: t
|
|
358
418
|
};
|
|
359
|
-
return
|
|
360
|
-
undoMutations: [C],
|
|
361
|
-
redoMutations: [i],
|
|
362
|
-
unitID: n
|
|
363
|
-
}), s.executeCommand(i.id, i.params), !0;
|
|
419
|
+
return a.executeCommand(U.id, U.params, { onlyLocal: !c }), !0;
|
|
364
420
|
}
|
|
365
|
-
}
|
|
366
|
-
l.COMMAND;
|
|
367
|
-
const ne = {
|
|
421
|
+
}, re = {
|
|
368
422
|
id: "thread-comment.command.resolve-comment",
|
|
369
|
-
type:
|
|
370
|
-
async handler(
|
|
371
|
-
if (!
|
|
423
|
+
type: p.COMMAND,
|
|
424
|
+
async handler(n, t) {
|
|
425
|
+
if (!t)
|
|
372
426
|
return !1;
|
|
373
|
-
const { unitId:
|
|
374
|
-
return !
|
|
375
|
-
...
|
|
427
|
+
const { unitId: e, subUnitId: r, resolved: o, commentId: a } = t, m = n.get(C), c = n.get(u).getComment(e, r, a), d = m.syncUpdateMutationToColla;
|
|
428
|
+
return !c || !await m.resolveComment({
|
|
429
|
+
...c,
|
|
376
430
|
resolved: o
|
|
377
|
-
}) ? !1 :
|
|
431
|
+
}) ? !1 : n.get(f).executeCommand(
|
|
378
432
|
w.id,
|
|
379
|
-
|
|
380
|
-
|
|
433
|
+
t,
|
|
434
|
+
{ onlyLocal: !d }
|
|
435
|
+
);
|
|
381
436
|
}
|
|
382
437
|
}, oe = {
|
|
383
438
|
id: "thread-comment.command.delete-comment",
|
|
384
|
-
type:
|
|
385
|
-
async handler(
|
|
386
|
-
if (!
|
|
439
|
+
type: p.COMMAND,
|
|
440
|
+
async handler(n, t) {
|
|
441
|
+
if (!t)
|
|
387
442
|
return !1;
|
|
388
|
-
const
|
|
389
|
-
if (!
|
|
443
|
+
const e = n.get(u), r = n.get(C), o = n.get(f), { unitId: a, subUnitId: m, commentId: s } = t, c = r.syncUpdateMutationToColla, d = e.getComment(a, m, s);
|
|
444
|
+
if (!d || !await r.deleteComment(a, m, d.threadId, s))
|
|
390
445
|
return !1;
|
|
391
|
-
const
|
|
392
|
-
id: y.id,
|
|
393
|
-
params: e
|
|
394
|
-
}, i = {
|
|
446
|
+
const l = {
|
|
395
447
|
id: T.id,
|
|
396
|
-
params:
|
|
397
|
-
unitId: m,
|
|
398
|
-
subUnitId: a,
|
|
399
|
-
comment: c
|
|
400
|
-
}
|
|
448
|
+
params: t
|
|
401
449
|
};
|
|
402
|
-
return
|
|
403
|
-
undoMutations: [i],
|
|
404
|
-
redoMutations: [u],
|
|
405
|
-
unitID: m
|
|
406
|
-
}), o.executeCommand(u.id, u.params);
|
|
450
|
+
return o.executeCommand(l.id, l.params, { onlyLocal: !c });
|
|
407
451
|
}
|
|
408
|
-
},
|
|
452
|
+
}, ae = {
|
|
409
453
|
id: "thread-comment.command.delete-comment-tree",
|
|
410
|
-
type:
|
|
411
|
-
async handler(
|
|
412
|
-
if (!
|
|
413
|
-
return !1;
|
|
414
|
-
const n = r.get(h), t = r.get(M), o = r.get(f), s = r.get(S), { unitId: m, subUnitId: a, commentId: d } = e, c = n.getCommentWithChildren(m, a, d);
|
|
415
|
-
if (!c)
|
|
454
|
+
type: p.COMMAND,
|
|
455
|
+
async handler(n, t) {
|
|
456
|
+
if (!t)
|
|
416
457
|
return !1;
|
|
417
|
-
const u =
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
unitId: m,
|
|
424
|
-
subUnitId: a,
|
|
425
|
-
commentId: v.id
|
|
426
|
-
}
|
|
427
|
-
})), C = u.map((v) => ({
|
|
428
|
-
id: T.id,
|
|
429
|
-
params: {
|
|
430
|
-
unitId: m,
|
|
431
|
-
subUnitId: a,
|
|
432
|
-
comment: v
|
|
433
|
-
}
|
|
434
|
-
})), _ = G(i, t);
|
|
435
|
-
return _.result && s.pushUndoRedo({
|
|
436
|
-
undoMutations: C,
|
|
437
|
-
redoMutations: i,
|
|
438
|
-
unitID: m
|
|
439
|
-
}), _.result;
|
|
458
|
+
const e = n.get(u), r = n.get(f), o = n.get(C), { unitId: a, subUnitId: m, commentId: s } = t, c = e.getCommentWithChildren(a, m, s);
|
|
459
|
+
return !c || !await o.deleteComment(a, m, c.root.threadId, s) ? !1 : await r.executeCommand(T.id, {
|
|
460
|
+
unitId: a,
|
|
461
|
+
subUnitId: m,
|
|
462
|
+
commentId: c.root.id
|
|
463
|
+
});
|
|
440
464
|
}
|
|
441
465
|
};
|
|
442
|
-
var me = Object.defineProperty, se = Object.getOwnPropertyDescriptor,
|
|
443
|
-
for (var o =
|
|
444
|
-
(m =
|
|
445
|
-
return
|
|
446
|
-
},
|
|
447
|
-
let
|
|
448
|
-
constructor(
|
|
466
|
+
var me = Object.defineProperty, se = Object.getOwnPropertyDescriptor, ce = (n, t, e, r) => {
|
|
467
|
+
for (var o = r > 1 ? void 0 : r ? se(t, e) : t, a = n.length - 1, m; a >= 0; a--)
|
|
468
|
+
(m = n[a]) && (o = (r ? m(t, e, o) : m(o)) || o);
|
|
469
|
+
return r && o && me(t, e, o), o;
|
|
470
|
+
}, O = (n, t) => (e, r) => t(e, r, n), _;
|
|
471
|
+
let I = (_ = class extends H {
|
|
472
|
+
constructor(t, e, r) {
|
|
449
473
|
super();
|
|
450
|
-
|
|
451
|
-
this._injector =
|
|
452
|
-
}
|
|
453
|
-
onStarting(
|
|
454
|
-
var
|
|
455
|
-
|
|
456
|
-
[
|
|
457
|
-
[
|
|
458
|
-
[
|
|
459
|
-
], (
|
|
460
|
-
(
|
|
461
|
-
|
|
474
|
+
h(this, "_config");
|
|
475
|
+
this._injector = e, this._commandService = r, this._config = t;
|
|
476
|
+
}
|
|
477
|
+
onStarting(t) {
|
|
478
|
+
var e;
|
|
479
|
+
G([
|
|
480
|
+
[C, { useClass: q }],
|
|
481
|
+
[u],
|
|
482
|
+
[v]
|
|
483
|
+
], (e = this._config) == null ? void 0 : e.overrides).forEach(
|
|
484
|
+
(r) => {
|
|
485
|
+
t.add(r);
|
|
462
486
|
}
|
|
463
487
|
), [
|
|
464
|
-
ee,
|
|
465
488
|
te,
|
|
466
|
-
oe,
|
|
467
489
|
ne,
|
|
490
|
+
oe,
|
|
468
491
|
re,
|
|
492
|
+
ae,
|
|
493
|
+
R,
|
|
494
|
+
D,
|
|
495
|
+
ee,
|
|
469
496
|
T,
|
|
470
|
-
g,
|
|
471
|
-
k,
|
|
472
|
-
y,
|
|
473
497
|
w
|
|
474
|
-
].forEach((
|
|
475
|
-
this._commandService.registerCommand(
|
|
498
|
+
].forEach((r) => {
|
|
499
|
+
this._commandService.registerCommand(r);
|
|
476
500
|
});
|
|
477
501
|
}
|
|
478
|
-
},
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
],
|
|
502
|
+
}, h(_, "pluginName", $), h(_, "type", B.UNIVER_UNKNOWN), _);
|
|
503
|
+
I = ce([
|
|
504
|
+
O(1, g(Z)),
|
|
505
|
+
O(2, f)
|
|
506
|
+
], I);
|
|
483
507
|
export {
|
|
484
|
-
|
|
485
|
-
|
|
508
|
+
te as AddCommentCommand,
|
|
509
|
+
R as AddCommentMutation,
|
|
486
510
|
oe as DeleteCommentCommand,
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
511
|
+
T as DeleteCommentMutation,
|
|
512
|
+
ae as DeleteCommentTreeCommand,
|
|
513
|
+
C as IThreadCommentDataSourceService,
|
|
514
|
+
re as ResolveCommentCommand,
|
|
491
515
|
w as ResolveCommentMutation,
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
516
|
+
$ as TC_PLUGIN_NAME,
|
|
517
|
+
q as ThreadCommentDataSourceService,
|
|
518
|
+
u as ThreadCommentModel,
|
|
519
|
+
v as ThreadCommentResourceController,
|
|
520
|
+
I as UniverThreadCommentPlugin,
|
|
521
|
+
ne as UpdateCommentCommand,
|
|
522
|
+
D as UpdateCommentMutation,
|
|
523
|
+
ee as UpdateCommentRefMutation
|
|
500
524
|
};
|