@univerjs/sheets-note 0.15.4 → 0.15.5

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,181 +1,260 @@
1
- var W = Object.defineProperty;
2
- var L = (i, r, e) => r in i ? W(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
- var l = (i, r, e) => L(i, typeof r != "symbol" ? r + "" : r, e);
4
- import { Disposable as x, ObjectMatrix as H, CommandType as p, IUniverInstanceService as P, ICommandService as N, IResourceManagerService as J, Inject as g, UniverInstanceType as v, sequenceExecuteAsync as G, DependentOn as z, IConfigService as F, Injector as q, Plugin as K, merge as Y, touchDependencies as O } from "@univerjs/core";
5
- import { getSheetCommandTarget as T, SheetsSelectionsService as y, SheetInterceptorService as B, RemoveSheetCommand as Q, CopySheetCommand as X, RefRangeService as Z, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as k, UniverSheetsPlugin as ee } from "@univerjs/sheets";
6
- import { Subject as te, filter as U, map as E } from "rxjs";
7
- class u extends x {
1
+ var z = Object.defineProperty;
2
+ var F = (i, r, e) => r in i ? z(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
+ var _ = (i, r, e) => F(i, typeof r != "symbol" ? r + "" : r, e);
4
+ import { Disposable as U, generateRandomId as J, CommandType as m, IUniverInstanceService as E, ICommandService as w, IUndoRedoService as T, IResourceManagerService as q, Inject as f, UniverInstanceType as I, sequenceExecuteAsync as K, DependentOn as Y, IConfigService as Q, Injector as X, Plugin as Z, merge as k, touchDependencies as A } from "@univerjs/core";
5
+ import { getSheetCommandTarget as D, SheetsSelectionsService as x, SheetInterceptorService as ee, RemoveSheetCommand as te, CopySheetCommand as se, RefRangeService as oe, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as ne, UniverSheetsPlugin as re } from "@univerjs/sheets";
6
+ import { Subject as ie, filter as W, map as B } from "rxjs";
7
+ class g extends U {
8
8
  constructor() {
9
9
  super(...arguments);
10
- l(this, "_noteMatrix", /* @__PURE__ */ new Map());
11
- l(this, "_change$", new te());
12
- l(this, "change$", this._change$.asObservable());
13
- }
14
- _ensureNoteMatrix(e, s) {
15
- let t = this._noteMatrix.get(e);
16
- t || (t = /* @__PURE__ */ new Map(), this._noteMatrix.set(e, t));
17
- let n = t.get(s);
18
- return n || (n = new H(), t.set(s, n)), n;
19
- }
20
- getSheetShowNotes$(e, s) {
10
+ _(this, "_notesMap", /* @__PURE__ */ new Map());
11
+ _(this, "_change$", new ie());
12
+ _(this, "change$", this._change$.asObservable());
13
+ }
14
+ _ensureNotesMap(e, t) {
15
+ let s = this._notesMap.get(e);
16
+ s || (s = /* @__PURE__ */ new Map(), this._notesMap.set(e, s));
17
+ let o = s.get(t);
18
+ return o || (o = /* @__PURE__ */ new Map(), s.set(t, o)), o;
19
+ }
20
+ _getNoteByPosition(e, t, s, o) {
21
+ const n = this._ensureNotesMap(e, t);
22
+ for (const [a, c] of n)
23
+ if (c.row === s && c.col === o)
24
+ return c;
25
+ }
26
+ _getNoteById(e, t, s) {
27
+ return this._ensureNotesMap(e, t).get(s);
28
+ }
29
+ _getNoteByParams(e, t, s) {
30
+ const { noteId: o, row: n, col: a } = s;
31
+ return o ? this._getNoteById(e, t, o) : n !== void 0 && a !== void 0 ? this._getNoteByPosition(e, t, n, a) : null;
32
+ }
33
+ getSheetShowNotes$(e, t) {
21
34
  return this._change$.pipe(
22
- U(({ unitId: t, sheetId: n }) => t === e && n === s),
23
- E(() => {
24
- const t = this._ensureNoteMatrix(e, s), n = [];
25
- return t.forValue((o, a, c) => {
26
- c.show && n.push({ loc: { row: o, col: a, unitId: e, subUnitId: s }, note: c });
27
- }), n;
35
+ W(({ unitId: s, subUnitId: o }) => s === e && o === t),
36
+ B(() => {
37
+ const s = this._ensureNotesMap(e, t), o = [];
38
+ for (const [n, a] of s)
39
+ a.show && o.push({ loc: { row: a.row, col: a.col, unitId: e, subUnitId: t }, note: a });
40
+ return o;
28
41
  })
29
42
  );
30
43
  }
31
- getCellNoteChange$(e, s, t, n) {
44
+ getCellNoteChange$(e, t, s, o) {
32
45
  return this._change$.pipe(
33
- U(({ unitId: o, sheetId: a, row: c, col: h }) => o === e && a === s && c === t && h === n),
34
- E(({ note: o }) => o)
46
+ W(({ unitId: n, subUnitId: a, oldNote: c }) => n !== e || a !== t || !c ? !1 : c.row === s && c.col === o),
47
+ B((n) => n)
35
48
  );
36
49
  }
37
- updateNote(e, s, t, n, o, a) {
38
- const c = this._ensureNoteMatrix(e, s), h = c.getValue(t, n);
39
- c.setValue(t, n, o), this._change$.next({ unitId: e, sheetId: s, row: t, col: n, type: "update", note: o, oldNote: h, silent: a });
40
- }
41
- removeNote(e, s, t, n, o) {
42
- const a = this._ensureNoteMatrix(e, s), c = a.getValue(t, n);
43
- a.realDeleteValue(t, n), this._change$.next({ unitId: e, sheetId: s, row: t, col: n, type: "update", note: null, oldNote: c, silent: o });
44
- }
45
- toggleNotePopup(e, s, t, n, o) {
46
- const a = this._ensureNoteMatrix(e, s), c = a.getValue(t, n);
47
- if (c) {
48
- c.show = !c.show;
49
- const h = { ...c, show: c.show };
50
- a.setValue(t, n, h), this._change$.next({
51
- unitId: e,
52
- sheetId: s,
53
- row: t,
54
- col: n,
55
- type: "update",
56
- note: h,
57
- oldNote: c,
58
- silent: o
59
- });
60
- }
50
+ updateNote(e, t, s, o, n, a) {
51
+ const c = this._getNoteByParams(e, t, { noteId: n == null ? void 0 : n.id, row: s, col: o }), d = this._ensureNotesMap(e, t), h = {
52
+ ...n,
53
+ id: (c == null ? void 0 : c.id) || n.id || J(6),
54
+ row: s,
55
+ col: o
56
+ };
57
+ d.set(h.id, h), this._change$.next({ unitId: e, subUnitId: t, oldNote: c, type: "update", newNote: h, silent: a });
58
+ }
59
+ removeNote(e, t, s) {
60
+ const { noteId: o, row: n, col: a, silent: c } = s, d = this._getNoteByParams(e, t, { noteId: o, row: n, col: a });
61
+ if (!d)
62
+ return;
63
+ this._ensureNotesMap(e, t).delete(d.id), this._change$.next({ unitId: e, subUnitId: t, oldNote: d, type: "update", newNote: null, silent: c });
64
+ }
65
+ toggleNotePopup(e, t, s) {
66
+ const { noteId: o, row: n, col: a, silent: c } = s, d = this._getNoteByParams(e, t, { noteId: o, row: n, col: a });
67
+ if (!d)
68
+ return;
69
+ const h = this._ensureNotesMap(e, t), u = { ...d, show: !d.show };
70
+ h.set(u.id, u), this._change$.next({ unitId: e, subUnitId: t, oldNote: d, type: "update", newNote: u, silent: c });
71
+ }
72
+ updateNotePosition(e, t, s) {
73
+ const { noteId: o, row: n, col: a, newRow: c, newCol: d, silent: h } = s, u = this._getNoteByParams(e, t, { noteId: o, row: n, col: a });
74
+ if (!u)
75
+ return;
76
+ const l = this._ensureNotesMap(e, t), p = { ...u, row: c, col: d };
77
+ l.set(p.id, p), this._change$.next({ unitId: e, subUnitId: t, oldNote: u, type: "ref", newNote: p, silent: h });
78
+ }
79
+ getNote(e, t, s) {
80
+ return this._getNoteByParams(e, t, s);
61
81
  }
62
- updateNotePosition(e, s, t, n, o, a, c) {
63
- const h = this._ensureNoteMatrix(e, s), d = h.getValue(t, n);
64
- d && (h.realDeleteValue(t, n), h.setValue(o, a, d), this._change$.next({
65
- unitId: e,
66
- sheetId: s,
67
- row: t,
68
- col: n,
69
- type: "ref",
70
- newPosition: { row: o, col: a },
71
- note: d,
72
- silent: c
73
- }));
74
- }
75
- getNote(e, s, t, n) {
76
- return this._ensureNoteMatrix(e, s).getValue(t, n);
82
+ getNotes() {
83
+ return this._notesMap;
77
84
  }
78
85
  getUnitNotes(e) {
79
- return this._noteMatrix.get(e);
80
- }
81
- getSheetNotes(e, s) {
82
- const t = this._noteMatrix.get(e);
83
- if (t)
84
- return t.get(s);
86
+ return this._notesMap.get(e);
85
87
  }
86
- getNotes() {
87
- return this._noteMatrix;
88
+ getSheetNotes(e, t) {
89
+ const s = this._notesMap.get(e);
90
+ if (s)
91
+ return s.get(t);
88
92
  }
89
93
  deleteUnitNotes(e) {
90
- this._noteMatrix.delete(e);
94
+ this._notesMap.delete(e);
91
95
  }
92
96
  }
93
- const _ = {
97
+ const N = {
94
98
  id: "sheet.mutation.update-note",
95
- type: p.MUTATION,
99
+ type: m.MUTATION,
96
100
  handler: (i, r) => {
97
- const { unitId: e, sheetId: s, row: t, col: n, note: o, silent: a } = r;
98
- return i.get(u).updateNote(e, s, t, n, o, a), !0;
101
+ const { unitId: e, sheetId: t, row: s, col: o, note: n, silent: a } = r;
102
+ return i.get(g).updateNote(e, t, s, o, n, a), !0;
99
103
  }
100
- }, m = {
104
+ }, M = {
101
105
  id: "sheet.mutation.remove-note",
102
- type: p.MUTATION,
106
+ type: m.MUTATION,
103
107
  handler: (i, r) => {
104
- const { unitId: e, sheetId: s, row: t, col: n, silent: o } = r;
105
- return i.get(u).removeNote(e, s, t, n, o), !0;
108
+ const { unitId: e, sheetId: t, noteId: s, row: o, col: n, silent: a } = r;
109
+ return i.get(g).removeNote(e, t, { noteId: s, row: o, col: n, silent: a }), !0;
106
110
  }
107
- }, D = {
111
+ }, b = {
108
112
  id: "sheet.mutation.toggle-note-popup",
109
- type: p.MUTATION,
113
+ type: m.MUTATION,
110
114
  handler: (i, r) => {
111
- const { unitId: e, sheetId: s, row: t, col: n, silent: o } = r;
112
- return i.get(u).toggleNotePopup(e, s, t, n, o), !0;
115
+ const { unitId: e, sheetId: t, noteId: s, row: o, col: n, silent: a } = r;
116
+ return i.get(g).toggleNotePopup(e, t, { noteId: s, row: o, col: n, silent: a }), !0;
113
117
  }
114
- }, R = {
118
+ }, $ = {
115
119
  id: "sheet.mutation.update-note-position",
116
- type: p.MUTATION,
120
+ type: m.MUTATION,
117
121
  handler: (i, r) => {
118
- const { unitId: e, sheetId: s, row: t, col: n, newPosition: o, silent: a } = r;
119
- return i.get(u).updateNotePosition(e, s, t, n, o.row, o.col, a), !0;
122
+ const { unitId: e, sheetId: t, noteId: s, row: o, col: n, newPosition: a, silent: c } = r;
123
+ return i.get(g).updateNotePosition(e, t, { noteId: s, row: o, col: n, newRow: a.row, newCol: a.col, silent: c }), !0;
120
124
  }
121
- }, se = {
125
+ }, ae = {
122
126
  id: "sheet.command.delete-note",
123
- type: p.COMMAND,
124
- handler: (i, r) => {
125
- const e = i.get(P), s = T(e);
126
- if (!s) return !1;
127
- const n = i.get(y).getCurrentLastSelection();
128
- if (!(n != null && n.primary)) return !1;
129
- const { actualColumn: o, actualRow: a } = n.primary;
130
- return i.get(N).executeCommand(m.id, {
131
- unitId: s.unitId,
132
- sheetId: s.subUnitId,
133
- row: a,
134
- col: o
135
- });
127
+ type: m.COMMAND,
128
+ handler: (i) => {
129
+ const r = D(i.get(E));
130
+ if (!r) return !1;
131
+ const t = i.get(x).getCurrentLastSelection();
132
+ if (!(t != null && t.primary)) return !1;
133
+ const s = i.get(g), { unitId: o, subUnitId: n } = r, { actualColumn: a, actualRow: c } = t.primary, d = s.getNote(o, n, { row: c, col: a });
134
+ if (!d) return !1;
135
+ const h = i.get(w), u = i.get(T), l = {
136
+ id: M.id,
137
+ params: {
138
+ unitId: o,
139
+ sheetId: n,
140
+ noteId: d.id
141
+ }
142
+ }, p = {
143
+ id: N.id,
144
+ params: {
145
+ unitId: o,
146
+ sheetId: n,
147
+ row: c,
148
+ col: a,
149
+ note: { ...d }
150
+ }
151
+ };
152
+ return h.syncExecuteCommand(l.id, l.params) ? (u.pushUndoRedo({
153
+ unitID: o,
154
+ redoMutations: [l],
155
+ undoMutations: [p]
156
+ }), !0) : !1;
136
157
  }
137
- }, ne = {
158
+ }, ce = {
138
159
  id: "sheet.command.toggle-note-popup",
139
- type: p.COMMAND,
140
- handler: (i, r) => {
141
- const e = i.get(P), s = T(e);
142
- if (!s) return !1;
143
- const n = i.get(y).getCurrentLastSelection();
144
- if (!(n != null && n.primary)) return !1;
145
- const { actualColumn: o, actualRow: a } = n.primary;
146
- return i.get(N).executeCommand(D.id, {
147
- unitId: s.unitId,
148
- sheetId: s.subUnitId,
149
- row: a,
150
- col: o
151
- });
160
+ type: m.COMMAND,
161
+ handler: (i) => {
162
+ const r = D(i.get(E));
163
+ if (!r) return !1;
164
+ const t = i.get(x).getCurrentLastSelection();
165
+ if (!(t != null && t.primary)) return !1;
166
+ const s = i.get(g), { unitId: o, subUnitId: n } = r, { actualColumn: a, actualRow: c } = t.primary, d = s.getNote(o, n, { row: c, col: a });
167
+ if (!d) return !1;
168
+ const h = i.get(w), u = i.get(T), l = {
169
+ id: b.id,
170
+ params: {
171
+ unitId: o,
172
+ sheetId: n,
173
+ noteId: d.id
174
+ }
175
+ }, p = {
176
+ id: b.id,
177
+ params: {
178
+ unitId: o,
179
+ sheetId: n,
180
+ noteId: d.id
181
+ }
182
+ };
183
+ return h.syncExecuteCommand(l.id, l.params) ? (u.pushUndoRedo({
184
+ unitID: o,
185
+ redoMutations: [l],
186
+ undoMutations: [p]
187
+ }), !0) : !1;
152
188
  }
153
- }, re = {
189
+ }, de = {
154
190
  id: "sheet.command.update-note",
155
- type: p.COMMAND,
156
- handler: (i, r) => i.get(N).syncExecuteCommand(_.id, r)
157
- }, V = "SHEET_NOTE_PLUGIN";
158
- var oe = Object.getOwnPropertyDescriptor, ie = (i, r, e, s) => {
159
- for (var t = s > 1 ? void 0 : s ? oe(r, e) : r, n = i.length - 1, o; n >= 0; n--)
160
- (o = i[n]) && (t = o(t) || t);
161
- return t;
162
- }, f = (i, r) => (e, s) => r(e, s, i);
163
- let M = class extends x {
164
- constructor(i, r, e, s) {
165
- super(), this._resourceManagerService = i, this._univerInstanceService = r, this._sheetInterceptorService = e, this._sheetsNoteModel = s, this._initSnapshot(), this._initSheetChange();
191
+ type: m.COMMAND,
192
+ handler: (i, r) => {
193
+ const e = D(i.get(E), r);
194
+ if (!e) return !1;
195
+ const t = i.get(w), s = i.get(T), o = i.get(g), { unitId: n, subUnitId: a } = e, { row: c, col: d, note: h } = r, u = o.getNote(n, a, { noteId: h.id, row: c, col: d }), l = {
196
+ id: N.id,
197
+ params: {
198
+ unitId: n,
199
+ sheetId: a,
200
+ row: c,
201
+ col: d,
202
+ note: h
203
+ }
204
+ }, p = [];
205
+ if (u) {
206
+ const O = {
207
+ id: N.id,
208
+ params: {
209
+ unitId: n,
210
+ sheetId: a,
211
+ row: c,
212
+ col: d,
213
+ note: { ...u }
214
+ }
215
+ };
216
+ p.push(O);
217
+ } else {
218
+ const O = {
219
+ id: M.id,
220
+ params: {
221
+ unitId: n,
222
+ sheetId: a,
223
+ row: c,
224
+ col: d
225
+ }
226
+ };
227
+ p.push(O);
228
+ }
229
+ return t.syncExecuteCommand(l.id, l.params) ? (s.pushUndoRedo({
230
+ unitID: n,
231
+ redoMutations: [l],
232
+ undoMutations: p
233
+ }), !0) : !1;
234
+ }
235
+ }, G = "SHEET_NOTE_PLUGIN";
236
+ var he = Object.getOwnPropertyDescriptor, ue = (i, r, e, t) => {
237
+ for (var s = t > 1 ? void 0 : t ? he(r, e) : r, o = i.length - 1, n; o >= 0; o--)
238
+ (n = i[o]) && (s = n(s) || s);
239
+ return s;
240
+ }, S = (i, r) => (e, t) => r(e, t, i);
241
+ let C = class extends U {
242
+ constructor(i, r, e, t) {
243
+ super(), this._resourceManagerService = i, this._univerInstanceService = r, this._sheetInterceptorService = e, this._sheetsNoteModel = t, this._initSnapshot(), this._initSheetChange();
166
244
  }
167
245
  _initSnapshot() {
168
246
  const i = (e) => {
169
- const s = this._sheetsNoteModel.getUnitNotes(e);
170
- if (!s)
247
+ const t = this._sheetsNoteModel.getUnitNotes(e);
248
+ if (!t)
171
249
  return "";
172
- const t = {};
173
- return s.forEach((n, o) => {
250
+ const s = {};
251
+ return t.forEach((o, n) => {
174
252
  const a = {};
175
- n.forValue((c, h, d) => {
176
- a[c] || (a[c] = {}), a[c][h] = d;
177
- }), Object.keys(a).length > 0 && (t[o] = a);
178
- }), JSON.stringify(t);
253
+ o.forEach((c) => {
254
+ const { row: d, col: h } = c;
255
+ a[d] || (a[d] = {}), a[d][h] = c;
256
+ }), Object.keys(a).length > 0 && (s[n] = a);
257
+ }), JSON.stringify(s);
179
258
  }, r = (e) => {
180
259
  if (!e)
181
260
  return {};
@@ -187,23 +266,23 @@ let M = class extends x {
187
266
  };
188
267
  this.disposeWithMe(
189
268
  this._resourceManagerService.registerPluginResource({
190
- pluginName: V,
191
- businesses: [v.UNIVER_SHEET],
269
+ pluginName: G,
270
+ businesses: [I.UNIVER_SHEET],
192
271
  toJson: (e) => i(e),
193
272
  parseJson: (e) => r(e),
194
273
  onUnLoad: (e) => {
195
274
  this._sheetsNoteModel.deleteUnitNotes(e);
196
275
  },
197
- onLoad: (e, s) => {
198
- Object.entries(s).forEach(([t, n]) => {
199
- Object.entries(n).forEach(([o, a]) => {
200
- Object.entries(a).forEach(([c, h]) => {
276
+ onLoad: (e, t) => {
277
+ Object.entries(t).forEach(([s, o]) => {
278
+ Object.entries(o).forEach(([n, a]) => {
279
+ Object.entries(a).forEach(([c, d]) => {
201
280
  this._sheetsNoteModel.updateNote(
202
281
  e,
203
- t,
204
- Number(o),
282
+ s,
283
+ Number(n),
205
284
  Number(c),
206
- h
285
+ d
207
286
  );
208
287
  });
209
288
  });
@@ -219,59 +298,62 @@ let M = class extends x {
219
298
  // eslint-disable-next-line max-lines-per-function
220
299
  getMutations: (i) => {
221
300
  var r;
222
- if (i.id === Q.id) {
223
- const e = i.params, s = e.unitId || this._univerInstanceService.getCurrentUnitOfType(v.UNIVER_SHEET).getUnitId(), t = e.subUnitId || ((r = this._univerInstanceService.getCurrentUnitOfType(v.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : r.getSheetId());
224
- if (!s || !t)
301
+ if (i.id === te.id) {
302
+ const e = i.params, t = e.unitId || this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getUnitId(), s = e.subUnitId || ((r = this._univerInstanceService.getCurrentUnitOfType(I.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : r.getSheetId());
303
+ if (!t || !s)
225
304
  return { redos: [], undos: [] };
226
- const n = this._sheetsNoteModel.getSheetNotes(s, t);
227
- if (!n)
305
+ const o = this._sheetsNoteModel.getSheetNotes(t, s);
306
+ if (!o)
228
307
  return { redos: [], undos: [] };
229
- const o = [], a = [];
230
- return n.forValue((c, h, d) => {
231
- o.push({
232
- id: m.id,
308
+ const n = [], a = [];
309
+ return o.forEach((c) => {
310
+ n.push({
311
+ id: M.id,
233
312
  params: {
234
- unitId: s,
235
- sheetId: t,
236
- row: c,
237
- col: h
313
+ unitId: t,
314
+ sheetId: s,
315
+ noteId: c.id,
316
+ row: c.row,
317
+ col: c.col
238
318
  }
239
319
  }), a.push({
240
- id: _.id,
320
+ id: N.id,
241
321
  params: {
242
- unitId: s,
243
- sheetId: t,
244
- row: c,
245
- col: h,
246
- note: d
322
+ unitId: t,
323
+ sheetId: s,
324
+ row: c.row,
325
+ col: c.col,
326
+ note: c
247
327
  }
248
328
  });
249
- }), { redos: o, undos: a };
250
- } else if (i.id === X.id) {
251
- const e = i.params, { unitId: s, subUnitId: t, targetSubUnitId: n } = e;
252
- if (!s || !t || !n)
329
+ }), { redos: n, undos: a };
330
+ } else if (i.id === se.id) {
331
+ const e = i.params, { unitId: t, subUnitId: s, targetSubUnitId: o } = e;
332
+ if (!t || !s || !o)
253
333
  return { redos: [], undos: [] };
254
- const o = this._sheetsNoteModel.getSheetNotes(s, t);
255
- if (!o)
334
+ const n = this._sheetsNoteModel.getSheetNotes(t, s);
335
+ if (!n)
256
336
  return { redos: [], undos: [] };
257
337
  const a = [], c = [];
258
- return o.forValue((h, d, A) => {
338
+ return n.forEach((d) => {
339
+ const h = { ...d, id: J(6) };
259
340
  a.push({
260
- id: _.id,
341
+ id: N.id,
261
342
  params: {
262
- unitId: s,
263
- sheetId: n,
264
- row: h,
265
- col: d,
266
- note: A
343
+ unitId: t,
344
+ sheetId: o,
345
+ row: h.row,
346
+ col: h.col,
347
+ note: h
267
348
  }
268
349
  }), c.push({
269
- id: m.id,
350
+ id: M.id,
270
351
  params: {
271
- unitId: s,
272
- sheetId: n,
273
- row: h,
274
- col: d
352
+ unitId: t,
353
+ sheetId: o,
354
+ noteId: h.id,
355
+ row: h.row,
356
+ col: h.col
275
357
  }
276
358
  });
277
359
  }), { redos: a, undos: c };
@@ -282,140 +364,139 @@ let M = class extends x {
282
364
  );
283
365
  }
284
366
  };
285
- M = ie([
286
- f(0, J),
287
- f(1, P),
288
- f(2, g(B)),
289
- f(3, g(u))
290
- ], M);
291
- const ae = "sheets-note.config", b = {};
292
- var ce = Object.getOwnPropertyDescriptor, he = (i, r, e, s) => {
293
- for (var t = s > 1 ? void 0 : s ? ce(r, e) : r, n = i.length - 1, o; n >= 0; n--)
294
- (o = i[n]) && (t = o(t) || t);
295
- return t;
296
- }, S = (i, r) => (e, s) => r(e, s, i);
297
- let I = class extends x {
298
- constructor(r, e, s, t) {
367
+ C = ue([
368
+ S(0, q),
369
+ S(1, E),
370
+ S(2, f(ee)),
371
+ S(3, f(g))
372
+ ], C);
373
+ const le = "sheets-note.config", L = {};
374
+ var pe = Object.getOwnPropertyDescriptor, ge = (i, r, e, t) => {
375
+ for (var s = t > 1 ? void 0 : t ? pe(r, e) : r, o = i.length - 1, n; o >= 0; o--)
376
+ (n = i[o]) && (s = n(s) || s);
377
+ return s;
378
+ }, v = (i, r) => (e, t) => r(e, t, i);
379
+ let R = class extends U {
380
+ constructor(r, e, t, s) {
299
381
  super();
300
- l(this, "_disposableMap", /* @__PURE__ */ new Map());
301
- l(this, "_watcherMap", /* @__PURE__ */ new Map());
302
- l(this, "_handleRangeChange", (r, e, s, t, n, o, a) => o ? {
382
+ _(this, "_disposableMap", /* @__PURE__ */ new Map());
383
+ _(this, "_watcherMap", /* @__PURE__ */ new Map());
384
+ _(this, "_handleRangeChange", (r, e, t, s, o, n, a) => n ? {
303
385
  redos: [{
304
- id: R.id,
386
+ id: $.id,
305
387
  params: {
306
388
  unitId: r,
307
389
  sheetId: e,
308
- row: t,
309
- col: n,
390
+ noteId: t.id,
310
391
  newPosition: {
311
- row: o.startRow,
312
- col: o.startColumn
392
+ row: n.startRow,
393
+ col: n.startColumn
313
394
  },
314
395
  silent: a
315
396
  }
316
397
  }],
317
398
  undos: [{
318
- id: R.id,
399
+ id: $.id,
319
400
  params: {
320
401
  unitId: r,
321
402
  sheetId: e,
322
- row: o.startRow,
323
- col: o.startColumn,
403
+ noteId: t.id,
324
404
  newPosition: {
325
- row: t,
326
- col: n
405
+ row: s,
406
+ col: o
327
407
  },
328
- note: s,
408
+ note: t,
329
409
  silent: a
330
410
  }
331
411
  }]
332
412
  } : {
333
413
  redos: [{
334
- id: m.id,
414
+ id: M.id,
335
415
  params: {
336
416
  unitId: r,
337
417
  sheetId: e,
338
- row: t,
339
- col: n
418
+ noteId: t.id
340
419
  }
341
420
  }],
342
421
  undos: [{
343
- id: _.id,
422
+ id: N.id,
344
423
  params: {
345
424
  unitId: r,
346
425
  sheetId: e,
347
- row: t,
348
- col: n,
349
- note: s
426
+ row: s,
427
+ col: o,
428
+ note: t
350
429
  }
351
430
  }]
352
431
  });
353
- this._refRangeService = r, this._sheetsNoteModel = e, this._selectionManagerService = s, this._commandService = t, this._initData(), this._initRefRange();
432
+ this._refRangeService = r, this._sheetsNoteModel = e, this._selectionManagerService = t, this._commandService = s, this._initData(), this._initRefRange();
354
433
  }
355
- _getIdWithUnitId(r, e, s, t) {
356
- return `${r}-${e}-${s}-${t}`;
434
+ _getIdWithUnitId(r, e, t, s) {
435
+ return `${r}-${e}-${t}-${s}`;
357
436
  }
358
- _register(r, e, s, t, n) {
359
- const o = {
360
- startColumn: n,
361
- endColumn: n,
362
- startRow: t,
363
- endRow: t
437
+ _register(r, e, t, s, o) {
438
+ const n = {
439
+ startColumn: o,
440
+ endColumn: o,
441
+ startRow: s,
442
+ endRow: s
364
443
  };
365
444
  this._disposableMap.set(
366
- this._getIdWithUnitId(r, e, t, n),
367
- this._refRangeService.registerRefRange(o, (a) => {
368
- const c = k(o, a, { selectionManagerService: this._selectionManagerService }), h = Array.isArray(c) ? c[0] : c;
369
- return h && h.startColumn === o.startColumn && h.startRow === o.startRow ? {
445
+ this._getIdWithUnitId(r, e, s, o),
446
+ this._refRangeService.registerRefRange(n, (a) => {
447
+ const c = ne(n, a, { selectionManagerService: this._selectionManagerService }), d = Array.isArray(c) ? c[0] : c;
448
+ return d && d.startColumn === n.startColumn && d.startRow === n.startRow ? {
370
449
  undos: [],
371
450
  redos: []
372
- } : this._handleRangeChange(r, e, s, t, n, h, !1);
451
+ } : this._handleRangeChange(r, e, t, s, o, d, !1);
373
452
  }, r, e)
374
453
  );
375
454
  }
376
- _watch(r, e, s, t, n) {
377
- const o = {
378
- startColumn: n,
379
- endColumn: n,
380
- startRow: t,
381
- endRow: t
455
+ _watch(r, e, t, s, o) {
456
+ const n = {
457
+ startColumn: o,
458
+ endColumn: o,
459
+ startRow: s,
460
+ endRow: s
382
461
  };
383
462
  this._watcherMap.set(
384
- this._getIdWithUnitId(r, e, t, n),
385
- this._refRangeService.watchRange(r, e, o, (a, c) => {
386
- const { redos: h } = this._handleRangeChange(r, e, s, a.startRow, a.startColumn, c, !0);
387
- G(h, this._commandService, { onlyLocal: !0 });
463
+ this._getIdWithUnitId(r, e, s, o),
464
+ this._refRangeService.watchRange(r, e, n, (a, c) => {
465
+ const { redos: d } = this._handleRangeChange(r, e, t, a.startRow, a.startColumn, c, !0);
466
+ K(d, this._commandService, { onlyLocal: !0 });
388
467
  }, !0)
389
468
  );
390
469
  }
391
- _unwatch(r, e, s, t) {
392
- var o;
393
- const n = this._getIdWithUnitId(r, e, s, t);
394
- (o = this._watcherMap.get(n)) == null || o.dispose(), this._watcherMap.delete(n);
470
+ _unwatch(r, e, t, s) {
471
+ var n;
472
+ const o = this._getIdWithUnitId(r, e, t, s);
473
+ (n = this._watcherMap.get(o)) == null || n.dispose(), this._watcherMap.delete(o);
395
474
  }
396
- _unregister(r, e, s, t) {
397
- var o;
398
- const n = this._getIdWithUnitId(r, e, s, t);
399
- (o = this._disposableMap.get(n)) == null || o.dispose(), this._disposableMap.delete(n);
475
+ _unregister(r, e, t, s) {
476
+ var n;
477
+ const o = this._getIdWithUnitId(r, e, t, s);
478
+ (n = this._disposableMap.get(o)) == null || n.dispose(), this._disposableMap.delete(o);
400
479
  }
401
480
  _initData() {
402
481
  const r = this._sheetsNoteModel.getNotes();
403
- for (const [e, s] of r)
404
- for (const [t, n] of s)
405
- n.forValue((o, a, c) => (c && (this._register(e, t, c, o, a), this._watch(e, t, c, o, a)), !0));
482
+ for (const [e, t] of r)
483
+ for (const [s, o] of t)
484
+ o.forEach((n) => {
485
+ this._register(e, s, n, n.row, n.col), this._watch(e, s, n, n.row, n.col);
486
+ });
406
487
  }
407
488
  _initRefRange() {
408
489
  this.disposeWithMe(
409
490
  this._sheetsNoteModel.change$.subscribe((r) => {
410
491
  switch (r.type) {
411
492
  case "update": {
412
- const { unitId: e, sheetId: s, row: t, col: n, note: o } = r, a = this._getIdWithUnitId(e, s, t, n);
413
- o ? this._disposableMap.has(a) || (this._register(e, s, o, t, n), this._watch(e, s, o, t, n)) : (this._unregister(e, s, t, n), this._unwatch(e, s, t, n));
493
+ const { unitId: e, subUnitId: t, oldNote: s, newNote: o } = r, n = o ? o.row : s.row, a = o ? o.col : s.col, c = this._getIdWithUnitId(e, t, n, a);
494
+ o ? this._disposableMap.has(c) || (this._register(e, t, o, n, a), this._watch(e, t, o, n, a)) : (this._unregister(e, t, n, a), this._unwatch(e, t, n, a));
414
495
  break;
415
496
  }
416
497
  case "ref": {
417
- const { unitId: e, sheetId: s, row: t, col: n, newPosition: o, note: a, silent: c } = r;
418
- this._unregister(e, s, t, n), c || (this._unwatch(e, s, t, n), this._watch(e, s, a, o.row, o.col)), this._register(e, s, a, o.row, o.col);
498
+ const { unitId: e, subUnitId: t, oldNote: s, newNote: o, silent: n } = r, { row: a, col: c } = s, { row: d, col: h } = o;
499
+ this._unregister(e, t, a, c), n || (this._unwatch(e, t, a, c), this._watch(e, t, o, d, h)), this._register(e, t, o, d, h);
419
500
  break;
420
501
  }
421
502
  }
@@ -423,30 +504,30 @@ let I = class extends x {
423
504
  );
424
505
  }
425
506
  };
426
- I = he([
427
- S(0, g(Z)),
428
- S(1, g(u)),
429
- S(2, g(y)),
430
- S(3, N)
431
- ], I);
432
- var de = Object.getOwnPropertyDescriptor, ue = (i, r, e, s) => {
433
- for (var t = s > 1 ? void 0 : s ? de(r, e) : r, n = i.length - 1, o; n >= 0; n--)
434
- (o = i[n]) && (t = o(t) || t);
435
- return t;
436
- }, le = (i, r) => (e, s) => r(e, s, i);
437
- let C = class extends x {
507
+ R = ge([
508
+ v(0, f(oe)),
509
+ v(1, f(g)),
510
+ v(2, f(x)),
511
+ v(3, w)
512
+ ], R);
513
+ var _e = Object.getOwnPropertyDescriptor, Ne = (i, r, e, t) => {
514
+ for (var s = t > 1 ? void 0 : t ? _e(r, e) : r, o = i.length - 1, n; o >= 0; o--)
515
+ (n = i[o]) && (s = n(s) || s);
516
+ return s;
517
+ }, me = (i, r) => (e, t) => r(e, t, i);
518
+ let y = class extends U {
438
519
  constructor(i) {
439
520
  super(), this._commandService = i, this._initialize();
440
521
  }
441
522
  _initialize() {
442
523
  [
443
- R,
444
- D,
445
- _,
446
- m,
447
- se,
448
- ne,
449
- re
524
+ $,
525
+ b,
526
+ N,
527
+ M,
528
+ ae,
529
+ ce,
530
+ de
450
531
  ].forEach((i) => {
451
532
  this.disposeWithMe(
452
533
  this._commandService.registerCommand(i)
@@ -454,60 +535,60 @@ let C = class extends x {
454
535
  });
455
536
  }
456
537
  };
457
- C = ue([
458
- le(0, N)
459
- ], C);
460
- var pe = Object.defineProperty, ge = Object.getOwnPropertyDescriptor, _e = (i, r, e) => r in i ? pe(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e, me = (i, r, e, s) => {
461
- for (var t = s > 1 ? void 0 : s ? ge(r, e) : r, n = i.length - 1, o; n >= 0; n--)
462
- (o = i[n]) && (t = o(t) || t);
463
- return t;
464
- }, $ = (i, r) => (e, s) => r(e, s, i), j = (i, r, e) => _e(i, typeof r != "symbol" ? r + "" : r, e);
465
- let w = class extends K {
466
- constructor(i = b, r, e) {
538
+ y = Ne([
539
+ me(0, w)
540
+ ], y);
541
+ var fe = Object.defineProperty, Me = Object.getOwnPropertyDescriptor, we = (i, r, e) => r in i ? fe(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e, Se = (i, r, e, t) => {
542
+ for (var s = t > 1 ? void 0 : t ? Me(r, e) : r, o = i.length - 1, n; o >= 0; o--)
543
+ (n = i[o]) && (s = n(s) || s);
544
+ return s;
545
+ }, H = (i, r) => (e, t) => r(e, t, i), V = (i, r, e) => we(i, typeof r != "symbol" ? r + "" : r, e);
546
+ let P = class extends Z {
547
+ constructor(i = L, r, e) {
467
548
  super(), this._config = i, this._configService = r, this._injector = e;
468
- const { ...s } = Y(
549
+ const { ...t } = k(
469
550
  {},
470
- b,
551
+ L,
471
552
  this._config
472
553
  );
473
- this._configService.setConfig(ae, s);
554
+ this._configService.setConfig(le, t);
474
555
  }
475
556
  onStarting() {
476
557
  [
477
- [u],
558
+ [g],
559
+ [y],
478
560
  [C],
479
- [M],
480
- [I]
561
+ [R]
481
562
  ].forEach((i) => {
482
563
  this._injector.add(i);
483
- }), O(this._injector, [
484
- [u],
485
- [C],
486
- [M]
564
+ }), A(this._injector, [
565
+ [g],
566
+ [y],
567
+ [C]
487
568
  ]);
488
569
  }
489
570
  onReady() {
490
- O(this._injector, [
491
- [I]
571
+ A(this._injector, [
572
+ [R]
492
573
  ]);
493
574
  }
494
575
  };
495
- j(w, "pluginName", V);
496
- j(w, "type", v.UNIVER_SHEET);
497
- w = me([
498
- z(ee),
499
- $(1, F),
500
- $(2, g(q))
501
- ], w);
576
+ V(P, "pluginName", G);
577
+ V(P, "type", I.UNIVER_SHEET);
578
+ P = Se([
579
+ Y(re),
580
+ H(1, Q),
581
+ H(2, f(X))
582
+ ], P);
502
583
  export {
503
- m as RemoveNoteMutation,
504
- se as SheetDeleteNoteCommand,
505
- ne as SheetToggleNotePopupCommand,
506
- re as SheetUpdateNoteCommand,
507
- u as SheetsNoteModel,
508
- M as SheetsNoteResourceController,
509
- D as ToggleNotePopupMutation,
510
- w as UniverSheetsNotePlugin,
511
- _ as UpdateNoteMutation,
512
- R as UpdateNotePositionMutation
584
+ M as RemoveNoteMutation,
585
+ ae as SheetDeleteNoteCommand,
586
+ ce as SheetToggleNotePopupCommand,
587
+ de as SheetUpdateNoteCommand,
588
+ g as SheetsNoteModel,
589
+ C as SheetsNoteResourceController,
590
+ b as ToggleNotePopupMutation,
591
+ P as UniverSheetsNotePlugin,
592
+ N as UpdateNoteMutation,
593
+ $ as UpdateNotePositionMutation
513
594
  };