@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/es/index.js CHANGED
@@ -1,367 +1,368 @@
1
- var x = Object.defineProperty;
2
- var T = (i, e, n) => e in i ? x(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
- var h = (i, e, n) => T(i, typeof e != "symbol" ? e + "" : e, n);
4
- import { Inject as l, Disposable as R, ObjectMatrix as $, UniverInstanceType as y, IUniverInstanceService as E, sequenceExecuteAsync as P, toDisposable as D, ICommandService as b, DependentOn as O, Injector as A, Plugin as j } from "@univerjs/core";
5
- import { singleReferenceToGrid as u, serializeRange as M } from "@univerjs/engine-formula";
6
- import { RefRangeService as W, SheetsSelectionsService as L, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B } from "@univerjs/sheets";
7
- import { ThreadCommentModel as S, DeleteCommentMutation as N, AddCommentMutation as V, UpdateCommentRefMutation as C, UniverThreadCommentPlugin as H } from "@univerjs/thread-comment";
8
- import { Subject as F } from "rxjs";
9
- var z = Object.defineProperty, G = Object.getOwnPropertyDescriptor, q = (i, e, n, t) => {
10
- for (var r = t > 1 ? void 0 : t ? G(e, n) : e, s = i.length - 1, o; s >= 0; s--)
11
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
12
- return t && r && z(e, n, r), r;
13
- }, w = (i, e) => (n, t) => e(n, t, i);
14
- let p = class extends R {
15
- constructor(e, n) {
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
- h(this, "_matrixMap", /* @__PURE__ */ new Map());
18
- h(this, "_locationMap", /* @__PURE__ */ new Map());
19
- h(this, "_commentUpdate$", new F());
20
- h(this, "commentUpdate$", this._commentUpdate$.asObservable());
21
- this._threadCommentModel = e, this._univerInstanceService = n, this._init(), this.disposeWithMe(() => {
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(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 $(), t.set(n, r)), r;
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(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;
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(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);
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(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));
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(e, n) {
52
- const t = this._ensureCommentMatrix(e, n), r = this._ensureCommentLocationMap(e, n);
53
- return { matrix: t, locationMap: r };
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 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);
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(e, n, t) {
64
- const r = u(t.ref), s = t.parentId, { row: o, column: a } = r, c = t.id, { matrix: m, locationMap: d } = this._ensure(e, n);
65
- !s && o >= 0 && a >= 0 && (this._addCommentToMatrix(m, o, a, c), d.set(c, { row: o, column: a })), s || this._commentUpdate$.next({
66
- unitId: e,
67
- subUnitId: n,
68
- payload: t,
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: !s,
71
- ...r
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((e) => {
77
- const { unitId: n, subUnitId: t } = e;
77
+ this.disposeWithMe(this._threadCommentModel.commentUpdate$.subscribe((update) => {
78
+ const { unitId, subUnitId } = update;
78
79
  try {
79
- if (this._univerInstanceService.getUnitType(n) !== y.UNIVER_SHEET)
80
+ if (this._univerInstanceService.getUnitType(unitId) !== UniverInstanceType.UNIVER_SHEET)
80
81
  return;
81
82
  } catch {
82
83
  }
83
- const { matrix: r, locationMap: s } = this._ensure(n, t);
84
- switch (e.type) {
84
+ const { matrix, locationMap } = this._ensure(unitId, subUnitId);
85
+ switch (update.type) {
85
86
  case "add": {
86
- this._addComment(e.unitId, e.subUnitId, e.payload);
87
+ this._addComment(update.unitId, update.subUnitId, update.payload);
87
88
  break;
88
89
  }
89
90
  case "delete": {
90
- const { isRoot: o, comment: a } = e.payload;
91
- if (o) {
92
- const c = u(a.ref), { row: m, column: d } = c;
93
- this._deleteCommentFromMatrix(r, m, d, a.id), this._commentUpdate$.next({
94
- ...e,
95
- ...c
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: o } = e.payload, a = this._threadCommentModel.getComment(n, t, o);
102
- if (!a)
102
+ const { commentId } = update.payload, comment = this._threadCommentModel.getComment(unitId, subUnitId, commentId);
103
+ if (!comment)
103
104
  return;
104
- const c = u(a.ref);
105
+ const location = singleReferenceToGrid(comment.ref);
105
106
  this._commentUpdate$.next({
106
- ...e,
107
- ...c
107
+ ...update,
108
+ ...location
108
109
  });
109
110
  break;
110
111
  }
111
112
  case "updateRef": {
112
- const o = u(e.payload.ref), { commentId: a } = e.payload, c = s.get(a);
113
- if (!c)
113
+ const location = singleReferenceToGrid(update.payload.ref), { commentId } = update.payload, currentLoc = locationMap.get(commentId);
114
+ if (!currentLoc)
114
115
  return;
115
- const { row: m, column: d } = c;
116
- this._deleteCommentFromMatrix(r, m, d, a), s.delete(a), o.row >= 0 && o.column >= 0 && (this._addCommentToMatrix(r, o.row, o.column, a), s.set(a, { row: o.row, column: o.column })), this._commentUpdate$.next({
117
- ...e,
118
- ...o
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: o, subUnitId: a, payload: c } = e, { locationMap: m } = this._ensure(o, a), d = m.get(c.commentId);
124
- d && this._commentUpdate$.next({
125
- ...e,
126
- ...d
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(e, n, t, r) {
134
- var a;
135
- return (a = this.getAllByLocation(e, n, t, r).filter((c) => !c.resolved)[0]) == null ? void 0 : a.id;
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(e, n, t, r) {
138
- const o = this._ensureCommentMatrix(e, n).getValue(t, r);
139
- return o ? Array.from(o).map((a) => this.getComment(e, n, a)).filter(Boolean) : [];
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(e, n, t) {
142
- return this._threadCommentModel.getComment(e, n, t);
142
+ getComment(unitId, subUnitId, commentId) {
143
+ return this._threadCommentModel.getComment(unitId, subUnitId, commentId);
143
144
  }
144
- getCommentWithChildren(e, n, t, r) {
145
- const s = this.getByLocation(e, n, t, r);
146
- if (!s)
145
+ getCommentWithChildren(unitId, subUnitId, row, column) {
146
+ const commentId = this.getByLocation(unitId, subUnitId, row, column);
147
+ if (!commentId)
147
148
  return;
148
- const o = this.getComment(e, n, s);
149
- if (o)
150
- return this._threadCommentModel.getThread(e, n, o.threadId);
149
+ const comment = this.getComment(unitId, subUnitId, commentId);
150
+ if (comment)
151
+ return this._threadCommentModel.getThread(unitId, subUnitId, comment.threadId);
151
152
  }
152
- showCommentMarker(e, n, t, r) {
153
- const s = this.getByLocation(e, n, t, r);
154
- if (!s)
153
+ showCommentMarker(unitId, subUnitId, row, column) {
154
+ const commentId = this.getByLocation(unitId, subUnitId, row, column);
155
+ if (!commentId)
155
156
  return !1;
156
- const o = this.getComment(e, n, s);
157
- return !!(o && !o.resolved);
157
+ const comment = this.getComment(unitId, subUnitId, commentId);
158
+ return !!(comment && !comment.resolved);
158
159
  }
159
- getSubUnitAll(e, n) {
160
- return this._threadCommentModel.getUnit(e).filter((t) => t.subUnitId === n).map((t) => t.root);
160
+ getSubUnitAll(unitId, subUnitId) {
161
+ return this._threadCommentModel.getUnit(unitId).filter((i) => i.subUnitId === subUnitId).map((i) => i.root);
161
162
  }
162
- };
163
- p = q([
164
- w(0, l(S)),
165
- w(1, E)
166
- ], p);
167
- var J = Object.defineProperty, K = Object.getOwnPropertyDescriptor, Q = (i, e, n, t) => {
168
- for (var r = t > 1 ? void 0 : t ? K(e, n) : e, s = i.length - 1, o; s >= 0; s--)
169
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
170
- return t && r && J(e, n, r), r;
171
- }, _ = (i, e) => (n, t) => e(n, t, i);
172
- let f = class extends R {
173
- constructor(e, n, t, r, s) {
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
- h(this, "_disposableMap", /* @__PURE__ */ new Map());
176
- h(this, "_watcherMap", /* @__PURE__ */ new Map());
177
- h(this, "_handleRangeChange", (e, n, t, r, s) => {
178
- const o = t.id, a = {
179
- startColumn: t.column,
180
- endColumn: t.column,
181
- startRow: t.row,
182
- endRow: t.row
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 r ? {
185
+ return resultRange ? {
185
186
  redos: [{
186
- id: C.id,
187
+ id: UpdateCommentRefMutation.id,
187
188
  params: {
188
- unitId: e,
189
- subUnitId: n,
189
+ unitId,
190
+ subUnitId,
190
191
  payload: {
191
- ref: M(r),
192
- commentId: o
192
+ ref: serializeRange(resultRange),
193
+ commentId
193
194
  },
194
- silent: s
195
+ silent
195
196
  }
196
197
  }],
197
198
  undos: [{
198
- id: C.id,
199
+ id: UpdateCommentRefMutation.id,
199
200
  params: {
200
- unitId: e,
201
- subUnitId: n,
201
+ unitId,
202
+ subUnitId,
202
203
  payload: {
203
- ref: M(a),
204
- commentId: o
204
+ ref: serializeRange(oldRange),
205
+ commentId
205
206
  },
206
- silent: s
207
+ silent
207
208
  }
208
209
  }]
209
210
  } : {
210
211
  redos: [{
211
- id: N.id,
212
+ id: DeleteCommentMutation.id,
212
213
  params: {
213
- unitId: e,
214
- subUnitId: n,
215
- commentId: o
214
+ unitId,
215
+ subUnitId,
216
+ commentId
216
217
  }
217
218
  }],
218
219
  undos: [{
219
- id: V.id,
220
+ id: AddCommentMutation.id,
220
221
  params: {
221
- unitId: e,
222
- subUnitId: n,
223
- comment: t,
222
+ unitId,
223
+ subUnitId,
224
+ comment,
224
225
  sync: !0
225
226
  }
226
227
  }]
227
228
  };
228
- });
229
- this._refRangeService = e, this._sheetsThreadCommentModel = n, this._threadCommentModel = t, this._selectionManagerService = r, this._commandService = s, this._initData(), this._initRefRange();
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(e, n, t) {
232
- return `${e}-${n}-${t}`;
232
+ _getIdWithUnitId(unitId, subUnitId, id) {
233
+ return `${unitId}-${subUnitId}-${id}`;
233
234
  }
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
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(e, n, r),
243
- this._refRangeService.registerRefRange(s, (o) => {
244
- const a = B(s, o, { selectionManagerService: this._selectionManagerService }), c = Array.isArray(a) ? a[0] : a;
245
- return c && c.startColumn === s.startColumn && c.startRow === s.startRow ? {
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(e, n, t, c, !1);
249
- }, e, n)
249
+ } : this._handleRangeChange(unitId, subUnitId, comment, resultRange, !1);
250
+ }, unitId, subUnitId)
250
251
  );
251
252
  }
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
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(e, n, r),
261
- this._refRangeService.watchRange(e, n, s, (o, a) => {
262
- const { redos: c } = this._handleRangeChange(e, n, t, a, !0);
263
- P(c, this._commandService, { onlyLocal: !0 });
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(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);
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(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);
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 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, a = u(o.ref), c = {
282
- ...o,
283
- ...a
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(r, s, c), this._watch(r, s, c);
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((e) => {
291
- const { unitId: n, subUnitId: t } = e;
292
- switch (e.type) {
291
+ this._sheetsThreadCommentModel.commentUpdate$.subscribe((option) => {
292
+ const { unitId, subUnitId } = option;
293
+ switch (option.type) {
293
294
  case "add": {
294
- if (e.payload.parentId)
295
+ if (option.payload.parentId)
295
296
  return;
296
- const r = {
297
- ...e.payload,
298
- row: e.row,
299
- column: e.column
297
+ const comment = {
298
+ ...option.payload,
299
+ row: option.row,
300
+ column: option.column
300
301
  };
301
- this._register(e.unitId, e.subUnitId, r), this._watch(e.unitId, e.subUnitId, r);
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(n, t, e.payload.commentId), this._unwatch(n, t, e.payload.commentId);
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 r = this._sheetsThreadCommentModel.getComment(n, t, e.payload.commentId);
310
- if (!r)
310
+ const comment = this._sheetsThreadCommentModel.getComment(unitId, subUnitId, option.payload.commentId);
311
+ if (!comment)
311
312
  return;
312
- this._unregister(n, t, e.payload.commentId);
313
- const s = {
314
- ...r,
315
- row: e.row,
316
- column: e.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
- e.silent || (this._unwatch(n, t, e.payload.commentId), this._watch(n, t, s)), this._register(e.unitId, e.subUnitId, s);
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(D(() => {
324
- this._disposableMap.forEach((e) => {
325
- e.dispose();
324
+ ), this.disposeWithMe(toDisposable(() => {
325
+ this._disposableMap.forEach((item) => {
326
+ item.dispose();
326
327
  }), this._disposableMap.clear();
327
328
  }));
328
329
  }
329
- };
330
- f = Q([
331
- _(0, l(W)),
332
- _(1, l(p)),
333
- _(2, l(S)),
334
- _(3, l(L)),
335
- _(4, b)
336
- ], f);
337
- const X = "SHEET_THREAD_COMMENT_BASE_PLUGIN";
338
- var I = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, Z = (i, e, n) => e in i ? I(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, k = (i, e, n, t) => {
339
- for (var r = t > 1 ? void 0 : t ? Y(e, n) : e, s = i.length - 1, o; s >= 0; s--)
340
- (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
341
- return t && r && I(e, n, r), r;
342
- }, v = (i, e) => (n, t) => e(n, t, i), U = (i, e, n) => Z(i, typeof e != "symbol" ? e + "" : e, n);
343
- let g = class extends j {
344
- constructor(i, e, n) {
345
- super(), this._injector = e, this._commandService = n;
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
- [p],
350
- [f]
351
- ].forEach((i) => {
352
- this._injector.add(i);
353
- }), this._injector.get(f);
350
+ [SheetsThreadCommentModel],
351
+ [SheetsThreadCommentRefRangeController]
352
+ ].forEach((dep) => {
353
+ this._injector.add(dep);
354
+ }), this._injector.get(SheetsThreadCommentRefRangeController);
354
355
  }
355
- };
356
- U(g, "pluginName", X);
357
- U(g, "type", y.UNIVER_SHEET);
358
- g = k([
359
- O(H),
360
- v(1, l(A)),
361
- v(2, l(b))
362
- ], g);
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
- p as SheetsThreadCommentModel,
365
- f as SheetsThreadCommentRefRangeController,
366
- g as UniverSheetsThreadCommentPlugin
365
+ SheetsThreadCommentModel,
366
+ SheetsThreadCommentRefRangeController,
367
+ UniverSheetsThreadCommentPlugin
367
368
  };