@univerjs/sheets-note 0.7.0-beta.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.
@@ -0,0 +1,438 @@
1
+ var j = Object.defineProperty;
2
+ var A = (i, r, e) => r in i ? j(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
+ var d = (i, r, e) => A(i, typeof r != "symbol" ? r + "" : r, e);
4
+ import { Disposable as S, ObjectMatrix as W, CommandType as l, Inject as _, ICommandService as g, sequenceExecuteAsync as L, IResourceManagerService as J, IUniverInstanceService as x, UniverInstanceType as U, DependentOn as H, IConfigService as z, Injector as G, Plugin as q, touchDependencies as y } from "@univerjs/core";
5
+ import { RefRangeService as F, SheetsSelectionsService as R, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests as B, getSheetCommandTarget as D, UniverSheetsPlugin as K } from "@univerjs/sheets";
6
+ import { Subject as Q, filter as O, map as $ } from "rxjs";
7
+ class u extends S {
8
+ constructor() {
9
+ super(...arguments);
10
+ d(this, "_noteMatrix", /* @__PURE__ */ new Map());
11
+ d(this, "_change$", new Q());
12
+ d(this, "change$", this._change$.asObservable());
13
+ }
14
+ _ensureNoteMatrix(e, n) {
15
+ let t = this._noteMatrix.get(e);
16
+ t || (t = /* @__PURE__ */ new Map(), this._noteMatrix.set(e, t));
17
+ let s = t.get(n);
18
+ return s || (s = new W(), t.set(n, s)), s;
19
+ }
20
+ getSheetShowNotes$(e, n) {
21
+ return this._change$.pipe(
22
+ O(({ unitId: t, sheetId: s }) => t === e && s === n),
23
+ $(() => {
24
+ const t = this._ensureNoteMatrix(e, n), s = [];
25
+ return t.forValue((o, a, c) => {
26
+ c.show && s.push({ loc: { row: o, col: a, unitId: e, subUnitId: n }, note: c });
27
+ }), s;
28
+ })
29
+ );
30
+ }
31
+ getCellNoteChange$(e, n, t, s) {
32
+ return this._change$.pipe(
33
+ O(({ unitId: o, sheetId: a, row: c, col: h }) => o === e && a === n && c === t && h === s),
34
+ $(({ note: o }) => o)
35
+ );
36
+ }
37
+ updateNote(e, n, t, s, o, a) {
38
+ const c = this._ensureNoteMatrix(e, n), h = c.getValue(t, s);
39
+ c.setValue(t, s, o), this._change$.next({ unitId: e, sheetId: n, row: t, col: s, type: "update", note: o, oldNote: h, silent: a });
40
+ }
41
+ removeNote(e, n, t, s, o) {
42
+ const a = this._ensureNoteMatrix(e, n), c = a.getValue(t, s);
43
+ a.realDeleteValue(t, s), this._change$.next({ unitId: e, sheetId: n, row: t, col: s, type: "update", note: null, oldNote: c, silent: o });
44
+ }
45
+ toggleNotePopup(e, n, t, s, o) {
46
+ const a = this._ensureNoteMatrix(e, n), c = a.getValue(t, s);
47
+ if (c) {
48
+ c.show = !c.show;
49
+ const h = { ...c, show: c.show };
50
+ a.setValue(t, s, h), this._change$.next({
51
+ unitId: e,
52
+ sheetId: n,
53
+ row: t,
54
+ col: s,
55
+ type: "update",
56
+ note: h,
57
+ oldNote: c,
58
+ silent: o
59
+ });
60
+ }
61
+ }
62
+ updateNotePosition(e, n, t, s, o, a, c) {
63
+ const h = this._ensureNoteMatrix(e, n), p = h.getValue(t, s);
64
+ p && (h.realDeleteValue(t, s), h.setValue(o, a, p), this._change$.next({
65
+ unitId: e,
66
+ sheetId: n,
67
+ row: t,
68
+ col: s,
69
+ type: "ref",
70
+ newPosition: { row: o, col: a },
71
+ note: p,
72
+ silent: c
73
+ }));
74
+ }
75
+ getNote(e, n, t, s) {
76
+ return this._ensureNoteMatrix(e, n).getValue(t, s);
77
+ }
78
+ getUnitNotes(e) {
79
+ return this._noteMatrix.get(e);
80
+ }
81
+ getSheetNotes(e, n) {
82
+ const t = this._noteMatrix.get(e);
83
+ if (t)
84
+ return t.get(n);
85
+ }
86
+ getNotes() {
87
+ return this._noteMatrix;
88
+ }
89
+ deleteUnitNotes(e) {
90
+ this._noteMatrix.delete(e);
91
+ }
92
+ }
93
+ const I = {
94
+ id: "sheet.mutation.update-note",
95
+ type: l.MUTATION,
96
+ handler: (i, r) => {
97
+ const { unitId: e, sheetId: n, row: t, col: s, note: o, silent: a } = r;
98
+ return i.get(u).updateNote(e, n, t, s, o, a), !0;
99
+ }
100
+ }, P = {
101
+ id: "sheet.mutation.remove-note",
102
+ type: l.MUTATION,
103
+ handler: (i, r) => {
104
+ const { unitId: e, sheetId: n, row: t, col: s, silent: o } = r;
105
+ return i.get(u).removeNote(e, n, t, s, o), !0;
106
+ }
107
+ }, E = {
108
+ id: "sheet.mutation.toggle-note-popup",
109
+ type: l.MUTATION,
110
+ handler: (i, r) => {
111
+ const { unitId: e, sheetId: n, row: t, col: s, silent: o } = r;
112
+ return i.get(u).toggleNotePopup(e, n, t, s, o), !0;
113
+ }
114
+ }, C = {
115
+ id: "sheet.mutation.update-note-position",
116
+ type: l.MUTATION,
117
+ handler: (i, r) => {
118
+ const { unitId: e, sheetId: n, row: t, col: s, newPosition: o, silent: a } = r;
119
+ return i.get(u).updateNotePosition(e, n, t, s, o.row, o.col, a), !0;
120
+ }
121
+ };
122
+ var X = Object.getOwnPropertyDescriptor, Y = (i, r, e, n) => {
123
+ for (var t = n > 1 ? void 0 : n ? X(r, e) : r, s = i.length - 1, o; s >= 0; s--)
124
+ (o = i[s]) && (t = o(t) || t);
125
+ return t;
126
+ }, m = (i, r) => (e, n) => r(e, n, i);
127
+ let N = class extends S {
128
+ constructor(r, e, n, t) {
129
+ super();
130
+ d(this, "_disposableMap", /* @__PURE__ */ new Map());
131
+ d(this, "_watcherMap", /* @__PURE__ */ new Map());
132
+ d(this, "_handleRangeChange", (r, e, n, t, s, o, a) => o ? {
133
+ redos: [{
134
+ id: C.id,
135
+ params: {
136
+ unitId: r,
137
+ sheetId: e,
138
+ row: t,
139
+ col: s,
140
+ newPosition: {
141
+ row: o.startRow,
142
+ col: o.startColumn
143
+ },
144
+ silent: a
145
+ }
146
+ }],
147
+ undos: [{
148
+ id: C.id,
149
+ params: {
150
+ unitId: r,
151
+ sheetId: e,
152
+ row: o.startRow,
153
+ col: o.startColumn,
154
+ newPosition: {
155
+ row: t,
156
+ col: s
157
+ },
158
+ note: n,
159
+ silent: a
160
+ }
161
+ }]
162
+ } : {
163
+ redos: [{
164
+ id: P.id,
165
+ params: {
166
+ unitId: r,
167
+ sheetId: e,
168
+ row: t,
169
+ col: s
170
+ }
171
+ }],
172
+ undos: [{
173
+ id: I.id,
174
+ params: {
175
+ unitId: r,
176
+ sheetId: e,
177
+ row: t,
178
+ col: s,
179
+ note: n
180
+ }
181
+ }]
182
+ });
183
+ this._refRangeService = r, this._sheetsNoteModel = e, this._selectionManagerService = n, this._commandService = t, this._initData(), this._initRefRange();
184
+ }
185
+ _getIdWithUnitId(r, e, n, t) {
186
+ return `${r}-${e}-${n}-${t}`;
187
+ }
188
+ _register(r, e, n, t, s) {
189
+ const o = {
190
+ startColumn: s,
191
+ endColumn: s,
192
+ startRow: t,
193
+ endRow: t
194
+ };
195
+ this._disposableMap.set(
196
+ this._getIdWithUnitId(r, e, t, s),
197
+ this._refRangeService.registerRefRange(o, (a) => {
198
+ const c = B(o, a, { selectionManagerService: this._selectionManagerService }), h = Array.isArray(c) ? c[0] : c;
199
+ return h && h.startColumn === o.startColumn && h.startRow === o.startRow ? {
200
+ undos: [],
201
+ redos: []
202
+ } : this._handleRangeChange(r, e, n, t, s, h, !1);
203
+ }, r, e)
204
+ );
205
+ }
206
+ _watch(r, e, n, t, s) {
207
+ const o = {
208
+ startColumn: s,
209
+ endColumn: s,
210
+ startRow: t,
211
+ endRow: t
212
+ };
213
+ this._watcherMap.set(
214
+ this._getIdWithUnitId(r, e, t, s),
215
+ this._refRangeService.watchRange(r, e, o, (a, c) => {
216
+ const { redos: h } = this._handleRangeChange(r, e, n, a.startRow, a.startColumn, c, !0);
217
+ L(h, this._commandService, { onlyLocal: !0 });
218
+ }, !0)
219
+ );
220
+ }
221
+ _unwatch(r, e, n, t) {
222
+ var o;
223
+ const s = this._getIdWithUnitId(r, e, n, t);
224
+ (o = this._watcherMap.get(s)) == null || o.dispose(), this._watcherMap.delete(s);
225
+ }
226
+ _unregister(r, e, n, t) {
227
+ var o;
228
+ const s = this._getIdWithUnitId(r, e, n, t);
229
+ (o = this._disposableMap.get(s)) == null || o.dispose(), this._disposableMap.delete(s);
230
+ }
231
+ _initData() {
232
+ const r = this._sheetsNoteModel.getNotes();
233
+ for (const [e, n] of r)
234
+ for (const [t, s] of n)
235
+ s.forValue((o, a, c) => (c && (this._register(e, t, c, o, a), this._watch(e, t, c, o, a)), !0));
236
+ }
237
+ _initRefRange() {
238
+ this.disposeWithMe(
239
+ this._sheetsNoteModel.change$.subscribe((r) => {
240
+ switch (r.type) {
241
+ case "update": {
242
+ const { unitId: e, sheetId: n, row: t, col: s, note: o } = r, a = this._getIdWithUnitId(e, n, t, s);
243
+ o ? this._disposableMap.has(a) || (this._register(e, n, o, t, s), this._watch(e, n, o, t, s)) : (this._unregister(e, n, t, s), this._unwatch(e, n, t, s));
244
+ break;
245
+ }
246
+ case "ref": {
247
+ const { unitId: e, sheetId: n, row: t, col: s, newPosition: o, note: a, silent: c } = r;
248
+ this._unregister(e, n, t, s), c || (this._unwatch(e, n, t, s), this._watch(e, n, a, o.row, o.col)), this._register(e, n, a, o.row, o.col);
249
+ break;
250
+ }
251
+ }
252
+ })
253
+ );
254
+ }
255
+ };
256
+ N = Y([
257
+ m(0, _(F)),
258
+ m(1, _(u)),
259
+ m(2, _(R)),
260
+ m(3, g)
261
+ ], N);
262
+ var Z = Object.getOwnPropertyDescriptor, k = (i, r, e, n) => {
263
+ for (var t = n > 1 ? void 0 : n ? Z(r, e) : r, s = i.length - 1, o; s >= 0; s--)
264
+ (o = i[s]) && (t = o(t) || t);
265
+ return t;
266
+ }, w = (i, r) => (e, n) => r(e, n, i);
267
+ let M = class extends S {
268
+ constructor(i, r, e) {
269
+ super(), this._resourceManagerService = i, this._univerInstanceService = r, this._sheetsNoteModel = e, this._initSnapshot();
270
+ }
271
+ _initSnapshot() {
272
+ const i = (e) => {
273
+ const n = this._sheetsNoteModel.getUnitNotes(e);
274
+ if (!n)
275
+ return "";
276
+ const t = {};
277
+ return n.forEach((s, o) => {
278
+ const a = {};
279
+ s.forValue((c, h, p) => {
280
+ a[c] || (a[c] = {}), a[c][h] = p;
281
+ }), Object.keys(a).length > 0 && (t[o] = a);
282
+ }), JSON.stringify(t);
283
+ }, r = (e) => {
284
+ if (!e)
285
+ return {};
286
+ try {
287
+ return JSON.parse(e);
288
+ } catch {
289
+ return {};
290
+ }
291
+ };
292
+ this.disposeWithMe(
293
+ this._resourceManagerService.registerPluginResource({
294
+ pluginName: V,
295
+ businesses: [U.UNIVER_SHEET],
296
+ toJson: (e) => i(e),
297
+ parseJson: (e) => r(e),
298
+ onUnLoad: (e) => {
299
+ this._sheetsNoteModel.deleteUnitNotes(e);
300
+ },
301
+ onLoad: (e, n) => {
302
+ Object.entries(n).forEach(([t, s]) => {
303
+ Object.entries(s).forEach(([o, a]) => {
304
+ Object.entries(a).forEach(([c, h]) => {
305
+ this._sheetsNoteModel.updateNote(
306
+ e,
307
+ t,
308
+ Number(o),
309
+ Number(c),
310
+ h
311
+ );
312
+ });
313
+ });
314
+ });
315
+ }
316
+ })
317
+ );
318
+ }
319
+ };
320
+ M = k([
321
+ w(0, J),
322
+ w(1, x),
323
+ w(2, _(u))
324
+ ], M);
325
+ const ee = {
326
+ id: "sheet.command.delete-note",
327
+ type: l.COMMAND,
328
+ handler: (i, r) => {
329
+ const e = i.get(x), n = D(e);
330
+ if (!n) return !1;
331
+ const s = i.get(R).getCurrentLastSelection();
332
+ if (!(s != null && s.primary)) return !1;
333
+ const { actualColumn: o, actualRow: a } = s.primary;
334
+ return i.get(g).executeCommand(P.id, {
335
+ unitId: n.unitId,
336
+ sheetId: n.subUnitId,
337
+ row: a,
338
+ col: o
339
+ });
340
+ }
341
+ }, te = {
342
+ id: "sheet.command.toggle-note-popup",
343
+ type: l.COMMAND,
344
+ handler: (i, r) => {
345
+ const e = i.get(x), n = D(e);
346
+ if (!n) return !1;
347
+ const s = i.get(R).getCurrentLastSelection();
348
+ if (!(s != null && s.primary)) return !1;
349
+ const { actualColumn: o, actualRow: a } = s.primary;
350
+ return i.get(g).executeCommand(E.id, {
351
+ unitId: n.unitId,
352
+ sheetId: n.subUnitId,
353
+ row: a,
354
+ col: o
355
+ });
356
+ }
357
+ }, se = {
358
+ id: "sheet.command.update-note",
359
+ type: l.COMMAND,
360
+ handler: (i, r) => i.get(g).syncExecuteCommand(I.id, r)
361
+ };
362
+ var ne = Object.getOwnPropertyDescriptor, re = (i, r, e, n) => {
363
+ for (var t = n > 1 ? void 0 : n ? ne(r, e) : r, s = i.length - 1, o; s >= 0; s--)
364
+ (o = i[s]) && (t = o(t) || t);
365
+ return t;
366
+ }, oe = (i, r) => (e, n) => r(e, n, i);
367
+ let f = class extends S {
368
+ constructor(i) {
369
+ super(), this._commandService = i, this._initialize();
370
+ }
371
+ _initialize() {
372
+ [
373
+ C,
374
+ E,
375
+ I,
376
+ P,
377
+ ee,
378
+ te,
379
+ se
380
+ ].forEach((i) => {
381
+ this.disposeWithMe(
382
+ this._commandService.registerCommand(i)
383
+ );
384
+ });
385
+ }
386
+ };
387
+ f = re([
388
+ oe(0, g)
389
+ ], f);
390
+ var ie = Object.defineProperty, ae = Object.getOwnPropertyDescriptor, ce = (i, r, e) => r in i ? ie(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e, he = (i, r, e, n) => {
391
+ for (var t = n > 1 ? void 0 : n ? ae(r, e) : r, s = i.length - 1, o; s >= 0; s--)
392
+ (o = i[s]) && (t = o(t) || t);
393
+ return t;
394
+ }, b = (i, r) => (e, n) => r(e, n, i), T = (i, r, e) => ce(i, typeof r != "symbol" ? r + "" : r, e);
395
+ const V = "SHEET_NOTE_PLUGIN";
396
+ let v = class extends q {
397
+ constructor(i, r) {
398
+ super(), this._configService = i, this._injector = r;
399
+ }
400
+ onStarting() {
401
+ [
402
+ [u],
403
+ [f],
404
+ [M],
405
+ [N]
406
+ ].forEach((i) => {
407
+ this._injector.add(i);
408
+ }), y(this._injector, [
409
+ [u],
410
+ [f],
411
+ [M]
412
+ ]);
413
+ }
414
+ onReady() {
415
+ y(this._injector, [
416
+ [N]
417
+ ]);
418
+ }
419
+ };
420
+ T(v, "pluginName", V);
421
+ T(v, "type", U.UNIVER_SHEET);
422
+ v = he([
423
+ H(K),
424
+ b(0, z),
425
+ b(1, _(G))
426
+ ], v);
427
+ export {
428
+ P as RemoveNoteMutation,
429
+ ee as SheetDeleteNoteCommand,
430
+ te as SheetToggleNotePopupCommand,
431
+ se as SheetUpdateNoteCommand,
432
+ u as SheetsNoteModel,
433
+ M as SheetsNoteResourceController,
434
+ E as ToggleNotePopupMutation,
435
+ v as UniverSheetsNotePlugin,
436
+ I as UpdateNoteMutation,
437
+ C as UpdateNotePositionMutation
438
+ };
package/lib/facade.js ADDED
@@ -0,0 +1,274 @@
1
+ import { FEventName as I, FUniver as v } from "@univerjs/core/facade";
2
+ import { UpdateNoteMutation as b, SheetsNoteModel as S, RemoveNoteMutation as B, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as H, SheetToggleNotePopupCommand as w } from "@univerjs/sheets-note";
3
+ import { FRange as E, FWorksheet as k } from "@univerjs/sheets/facade";
4
+ import { ICommandService as u, CanceledError as N } from "@univerjs/core";
5
+ class U {
6
+ get SheetNoteAdd() {
7
+ return "SheetNoteAdd";
8
+ }
9
+ get SheetNoteDelete() {
10
+ return "SheetNoteDelete";
11
+ }
12
+ get SheetNoteUpdate() {
13
+ return "SheetNoteUpdate";
14
+ }
15
+ get SheetNoteShow() {
16
+ return "SheetNoteShow";
17
+ }
18
+ get SheetNoteHide() {
19
+ return "SheetNoteHide";
20
+ }
21
+ get BeforeSheetNoteAdd() {
22
+ return "BeforeSheetNoteAdd";
23
+ }
24
+ get BeforeSheetNoteDelete() {
25
+ return "BeforeSheetNoteDelete";
26
+ }
27
+ get BeforeSheetNoteUpdate() {
28
+ return "BeforeSheetNoteUpdate";
29
+ }
30
+ get BeforeSheetNoteShow() {
31
+ return "BeforeSheetNoteShow";
32
+ }
33
+ get BeforeSheetNoteHide() {
34
+ return "BeforeSheetNoteHide";
35
+ }
36
+ }
37
+ I.extend(U);
38
+ class x extends E {
39
+ createOrUpdateNote(d) {
40
+ return this._commandService.syncExecuteCommand(
41
+ b.id,
42
+ {
43
+ unitId: this.getUnitId(),
44
+ sheetId: this.getSheetId(),
45
+ row: this.getRow(),
46
+ col: this.getColumn(),
47
+ note: d
48
+ }
49
+ ), this;
50
+ }
51
+ deleteNote() {
52
+ return this._injector.get(S), this._commandService.syncExecuteCommand(
53
+ B.id,
54
+ {
55
+ unitId: this.getUnitId(),
56
+ sheetId: this.getSheetId(),
57
+ row: this.getRow(),
58
+ col: this.getColumn()
59
+ }
60
+ ), this;
61
+ }
62
+ getNote() {
63
+ return this._injector.get(S).getNote(this.getUnitId(), this.getSheetId(), this.getRow(), this.getColumn());
64
+ }
65
+ }
66
+ E.extend(x);
67
+ class C extends v {
68
+ _initialize(d) {
69
+ this.registerEventHandler(
70
+ this.Event.SheetNoteAdd,
71
+ () => d.get(S).change$.subscribe((e) => {
72
+ if (e.type === "update" && !e.oldNote && e.note) {
73
+ const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
74
+ if (!n)
75
+ return;
76
+ const { workbook: c, worksheet: l } = n;
77
+ this.fireEvent(this.Event.SheetNoteAdd, {
78
+ workbook: c,
79
+ worksheet: l,
80
+ row: o,
81
+ col: s,
82
+ note: r
83
+ });
84
+ }
85
+ })
86
+ ), this.registerEventHandler(
87
+ this.Event.SheetNoteDelete,
88
+ () => d.get(S).change$.subscribe((e) => {
89
+ if (e.type === "update" && e.oldNote && !e.note) {
90
+ const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
91
+ if (!n)
92
+ return;
93
+ const { workbook: c, worksheet: l } = n;
94
+ this.fireEvent(this.Event.SheetNoteDelete, {
95
+ workbook: c,
96
+ worksheet: l,
97
+ row: o,
98
+ col: s,
99
+ oldNote: i
100
+ });
101
+ }
102
+ })
103
+ ), this.registerEventHandler(
104
+ this.Event.SheetNoteUpdate,
105
+ () => d.get(S).change$.subscribe((e) => {
106
+ if (e.type === "update" && e.oldNote && e.note) {
107
+ const { unitId: h, sheetId: t, row: o, col: s, note: r, oldNote: i } = e, n = this.getSheetTarget(h, t);
108
+ if (!n)
109
+ return;
110
+ const { workbook: c, worksheet: l } = n;
111
+ this.fireEvent(this.Event.SheetNoteUpdate, {
112
+ workbook: c,
113
+ worksheet: l,
114
+ row: o,
115
+ col: s,
116
+ note: r,
117
+ oldNote: i
118
+ });
119
+ }
120
+ })
121
+ ), this.registerEventHandler(
122
+ this.Event.SheetNoteShow,
123
+ () => d.get(S).change$.subscribe((e) => {
124
+ if (e.type === "update" && e.oldNote && e.note && !e.oldNote.show && e.note.show) {
125
+ const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
126
+ if (!r)
127
+ return;
128
+ const { workbook: i, worksheet: n } = r;
129
+ this.fireEvent(this.Event.SheetNoteShow, {
130
+ workbook: i,
131
+ worksheet: n,
132
+ row: o,
133
+ col: s
134
+ });
135
+ }
136
+ })
137
+ ), this.registerEventHandler(
138
+ this.Event.SheetNoteHide,
139
+ () => d.get(S).change$.subscribe((e) => {
140
+ if (e.type === "update" && e.oldNote && e.note && e.oldNote.show && !e.note.show) {
141
+ const { unitId: h, sheetId: t, row: o, col: s } = e, r = this.getSheetTarget(h, t);
142
+ if (!r)
143
+ return;
144
+ const { workbook: i, worksheet: n } = r;
145
+ this.fireEvent(this.Event.SheetNoteHide, {
146
+ workbook: i,
147
+ worksheet: n,
148
+ row: o,
149
+ col: s
150
+ });
151
+ }
152
+ })
153
+ ), this.registerEventHandler(
154
+ this.Event.BeforeSheetNoteAdd,
155
+ () => d.get(u).beforeCommandExecuted((e) => {
156
+ if (e.id === f.id) {
157
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params;
158
+ if (h.getNote(t, o, s, r)) return;
159
+ const c = this.getSheetTarget(t, o);
160
+ if (!c)
161
+ return;
162
+ const { workbook: l, worksheet: g } = c;
163
+ if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
164
+ workbook: l,
165
+ worksheet: g,
166
+ row: s,
167
+ col: r,
168
+ note: i
169
+ }))
170
+ throw new N();
171
+ }
172
+ })
173
+ ), this.registerEventHandler(
174
+ this.Event.BeforeSheetNoteDelete,
175
+ () => d.get(u).beforeCommandExecuted((e) => {
176
+ if (e.id === H.id) {
177
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
178
+ if (!i) return;
179
+ const n = this.getSheetTarget(t, o);
180
+ if (!n)
181
+ return;
182
+ const { workbook: c, worksheet: l } = n;
183
+ if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
184
+ workbook: c,
185
+ worksheet: l,
186
+ row: s,
187
+ col: r,
188
+ oldNote: i
189
+ }))
190
+ throw new N();
191
+ }
192
+ })
193
+ ), this.registerEventHandler(
194
+ this.Event.BeforeSheetNoteUpdate,
195
+ () => d.get(u).beforeCommandExecuted((e) => {
196
+ if (e.id === f.id) {
197
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r, note: i } = e.params, n = h.getNote(t, o, s, r);
198
+ if (!n) return;
199
+ const c = this.getSheetTarget(t, o);
200
+ if (!c)
201
+ return;
202
+ const { workbook: l, worksheet: g } = c;
203
+ if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
204
+ workbook: l,
205
+ worksheet: g,
206
+ row: s,
207
+ col: r,
208
+ note: i,
209
+ oldNote: n
210
+ }))
211
+ throw new N();
212
+ }
213
+ })
214
+ ), this.registerEventHandler(
215
+ this.Event.BeforeSheetNoteShow,
216
+ () => d.get(u).beforeCommandExecuted((e) => {
217
+ if (e.id === w.id) {
218
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
219
+ if (i != null && i.show) return;
220
+ const n = this.getSheetTarget(t, o);
221
+ if (!n)
222
+ return;
223
+ const { workbook: c, worksheet: l } = n;
224
+ if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
225
+ workbook: c,
226
+ worksheet: l,
227
+ row: s,
228
+ col: r
229
+ }))
230
+ throw new N();
231
+ }
232
+ })
233
+ ), this.registerEventHandler(
234
+ this.Event.BeforeSheetNoteHide,
235
+ () => d.get(u).beforeCommandExecuted((e) => {
236
+ if (e.id === w.id) {
237
+ const h = d.get(S), { unitId: t, sheetId: o, row: s, col: r } = e.params, i = h.getNote(t, o, s, r);
238
+ if (!(i != null && i.show)) return;
239
+ const n = this.getSheetTarget(t, o);
240
+ if (!n)
241
+ return;
242
+ const { workbook: c, worksheet: l } = n;
243
+ if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
244
+ workbook: c,
245
+ worksheet: l,
246
+ row: s,
247
+ col: r
248
+ }))
249
+ throw new N();
250
+ }
251
+ })
252
+ );
253
+ }
254
+ }
255
+ v.extend(C);
256
+ class T extends k {
257
+ getNotes() {
258
+ const a = this._injector.get(S).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId()), e = [];
259
+ return a == null || a.forValue((h, t, o) => {
260
+ e.push({
261
+ ...o,
262
+ row: h,
263
+ col: t
264
+ });
265
+ }), e;
266
+ }
267
+ }
268
+ k.extend(T);
269
+ export {
270
+ U as FSheetNoteEvent,
271
+ x as FSheetsNoteRange,
272
+ T as FSheetsNoteWorksheet,
273
+ C as FUniverSheetNoteMixin
274
+ };