@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/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +134 -136
- package/lib/es/index.js +398 -317
- package/lib/facade.js +134 -136
- package/lib/index.js +398 -317
- package/lib/types/commands/mutations/note.mutation.d.ts +9 -6
- package/lib/types/facade/f-worksheet.d.ts +3 -7
- package/lib/types/models/sheets-note.model.d.ts +44 -23
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/facade.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { FEventName as
|
|
2
|
-
import { UpdateNoteMutation as
|
|
3
|
-
import { FRange as
|
|
4
|
-
import { ICommandService as
|
|
5
|
-
|
|
1
|
+
import { FEventName as B, FUniver as I } from "@univerjs/core/facade";
|
|
2
|
+
import { UpdateNoteMutation as C, RemoveNoteMutation as H, SheetsNoteModel as c, SheetUpdateNoteCommand as f, SheetDeleteNoteCommand as x, SheetToggleNotePopupCommand as m } from "@univerjs/sheets-note";
|
|
3
|
+
import { FRange as k, FWorksheet as b } from "@univerjs/sheets/facade";
|
|
4
|
+
import { ICommandService as M, CanceledError as g, IUniverInstanceService as v } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as E, SheetsSelectionsService as p } from "@univerjs/sheets";
|
|
6
|
+
class y {
|
|
6
7
|
get SheetNoteAdd() {
|
|
7
8
|
return "SheetNoteAdd";
|
|
8
9
|
}
|
|
@@ -34,23 +35,23 @@ class x {
|
|
|
34
35
|
return "BeforeSheetNoteHide";
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
class
|
|
39
|
-
createOrUpdateNote(
|
|
38
|
+
B.extend(y);
|
|
39
|
+
class W extends k {
|
|
40
|
+
createOrUpdateNote(n) {
|
|
40
41
|
return this._commandService.syncExecuteCommand(
|
|
41
|
-
|
|
42
|
+
C.id,
|
|
42
43
|
{
|
|
43
44
|
unitId: this.getUnitId(),
|
|
44
45
|
sheetId: this.getSheetId(),
|
|
45
46
|
row: this.getRow(),
|
|
46
47
|
col: this.getColumn(),
|
|
47
|
-
note:
|
|
48
|
+
note: n
|
|
48
49
|
}
|
|
49
50
|
), this;
|
|
50
51
|
}
|
|
51
52
|
deleteNote() {
|
|
52
53
|
return this._commandService.syncExecuteCommand(
|
|
53
|
-
|
|
54
|
+
H.id,
|
|
54
55
|
{
|
|
55
56
|
unitId: this.getUnitId(),
|
|
56
57
|
sheetId: this.getSheetId(),
|
|
@@ -60,29 +61,29 @@ class U extends E {
|
|
|
60
61
|
), this;
|
|
61
62
|
}
|
|
62
63
|
getNote() {
|
|
63
|
-
return this._injector.get(
|
|
64
|
+
return this._injector.get(c).getNote(this.getUnitId(), this.getSheetId(), { row: this.getRow(), col: this.getColumn() });
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
class
|
|
67
|
+
k.extend(W);
|
|
68
|
+
class T extends I {
|
|
68
69
|
// eslint-disable-next-line max-lines-per-function
|
|
69
|
-
_initialize(
|
|
70
|
-
const a =
|
|
70
|
+
_initialize(n) {
|
|
71
|
+
const a = n.get(M);
|
|
71
72
|
this.disposeWithMe(
|
|
72
73
|
this.registerEventHandler(
|
|
73
74
|
this.Event.SheetNoteAdd,
|
|
74
|
-
() =>
|
|
75
|
-
if (e.type === "update" && !e.oldNote && e.
|
|
76
|
-
const { unitId:
|
|
77
|
-
if (!
|
|
75
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
76
|
+
if (e.type === "update" && !e.oldNote && e.newNote) {
|
|
77
|
+
const { unitId: s, subUnitId: r, newNote: t } = e, o = this.getSheetTarget(s, r);
|
|
78
|
+
if (!o)
|
|
78
79
|
return;
|
|
79
|
-
const { workbook: d, worksheet:
|
|
80
|
+
const { workbook: d, worksheet: i } = o;
|
|
80
81
|
this.fireEvent(this.Event.SheetNoteAdd, {
|
|
81
82
|
workbook: d,
|
|
82
|
-
worksheet:
|
|
83
|
-
row:
|
|
84
|
-
col:
|
|
85
|
-
note:
|
|
83
|
+
worksheet: i,
|
|
84
|
+
row: t.row,
|
|
85
|
+
col: t.col,
|
|
86
|
+
note: t
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
89
|
})
|
|
@@ -90,18 +91,18 @@ class C extends m {
|
|
|
90
91
|
), this.disposeWithMe(
|
|
91
92
|
this.registerEventHandler(
|
|
92
93
|
this.Event.SheetNoteDelete,
|
|
93
|
-
() =>
|
|
94
|
-
if (e.type === "update" && e.oldNote && !e.
|
|
95
|
-
const { unitId:
|
|
96
|
-
if (!
|
|
94
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
95
|
+
if (e.type === "update" && e.oldNote && !e.newNote) {
|
|
96
|
+
const { unitId: s, subUnitId: r, oldNote: t } = e, o = this.getSheetTarget(s, r);
|
|
97
|
+
if (!o)
|
|
97
98
|
return;
|
|
98
|
-
const { workbook: d, worksheet:
|
|
99
|
+
const { workbook: d, worksheet: i } = o;
|
|
99
100
|
this.fireEvent(this.Event.SheetNoteDelete, {
|
|
100
101
|
workbook: d,
|
|
101
|
-
worksheet:
|
|
102
|
-
row:
|
|
103
|
-
col:
|
|
104
|
-
oldNote:
|
|
102
|
+
worksheet: i,
|
|
103
|
+
row: t.row,
|
|
104
|
+
col: t.col,
|
|
105
|
+
oldNote: t
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
})
|
|
@@ -109,19 +110,19 @@ class C extends m {
|
|
|
109
110
|
), this.disposeWithMe(
|
|
110
111
|
this.registerEventHandler(
|
|
111
112
|
this.Event.SheetNoteUpdate,
|
|
112
|
-
() =>
|
|
113
|
-
if (e.type === "update" && e.oldNote && e.
|
|
114
|
-
const { unitId:
|
|
113
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
114
|
+
if (e.type === "update" && e.oldNote && e.newNote) {
|
|
115
|
+
const { unitId: s, subUnitId: r, oldNote: t, newNote: o } = e, d = this.getSheetTarget(s, r);
|
|
115
116
|
if (!d)
|
|
116
117
|
return;
|
|
117
|
-
const { workbook:
|
|
118
|
+
const { workbook: i, worksheet: l } = d;
|
|
118
119
|
this.fireEvent(this.Event.SheetNoteUpdate, {
|
|
119
|
-
workbook:
|
|
120
|
-
worksheet:
|
|
121
|
-
row:
|
|
122
|
-
col:
|
|
123
|
-
note:
|
|
124
|
-
oldNote:
|
|
120
|
+
workbook: i,
|
|
121
|
+
worksheet: l,
|
|
122
|
+
row: o.row,
|
|
123
|
+
col: o.col,
|
|
124
|
+
note: o,
|
|
125
|
+
oldNote: t
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
})
|
|
@@ -129,17 +130,17 @@ class C extends m {
|
|
|
129
130
|
), this.disposeWithMe(
|
|
130
131
|
this.registerEventHandler(
|
|
131
132
|
this.Event.SheetNoteShow,
|
|
132
|
-
() =>
|
|
133
|
-
if (e.type === "update" && e.oldNote && e.
|
|
134
|
-
const { unitId:
|
|
135
|
-
if (!
|
|
133
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
134
|
+
if (e.type === "update" && e.oldNote && e.newNote && !e.oldNote.show && e.newNote.show) {
|
|
135
|
+
const { unitId: s, subUnitId: r, newNote: t } = e, o = this.getSheetTarget(s, r);
|
|
136
|
+
if (!o)
|
|
136
137
|
return;
|
|
137
|
-
const { workbook:
|
|
138
|
+
const { workbook: d, worksheet: i } = o;
|
|
138
139
|
this.fireEvent(this.Event.SheetNoteShow, {
|
|
139
|
-
workbook:
|
|
140
|
-
worksheet:
|
|
141
|
-
row:
|
|
142
|
-
col:
|
|
140
|
+
workbook: d,
|
|
141
|
+
worksheet: i,
|
|
142
|
+
row: t.row,
|
|
143
|
+
col: t.col
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
})
|
|
@@ -147,17 +148,17 @@ class C extends m {
|
|
|
147
148
|
), this.disposeWithMe(
|
|
148
149
|
this.registerEventHandler(
|
|
149
150
|
this.Event.SheetNoteHide,
|
|
150
|
-
() =>
|
|
151
|
-
if (e.type === "update" && e.oldNote && e.
|
|
152
|
-
const { unitId:
|
|
153
|
-
if (!
|
|
151
|
+
() => n.get(c).change$.subscribe((e) => {
|
|
152
|
+
if (e.type === "update" && e.oldNote && e.newNote && e.oldNote.show && !e.newNote.show) {
|
|
153
|
+
const { unitId: s, subUnitId: r, newNote: t } = e, o = this.getSheetTarget(s, r);
|
|
154
|
+
if (!o)
|
|
154
155
|
return;
|
|
155
|
-
const { workbook:
|
|
156
|
+
const { workbook: d, worksheet: i } = o;
|
|
156
157
|
this.fireEvent(this.Event.SheetNoteHide, {
|
|
157
|
-
workbook:
|
|
158
|
-
worksheet:
|
|
159
|
-
row:
|
|
160
|
-
col:
|
|
158
|
+
workbook: d,
|
|
159
|
+
worksheet: i,
|
|
160
|
+
row: t.row,
|
|
161
|
+
col: t.col
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
164
|
})
|
|
@@ -167,20 +168,17 @@ class C extends m {
|
|
|
167
168
|
this.Event.BeforeSheetNoteAdd,
|
|
168
169
|
() => a.beforeCommandExecuted((h) => {
|
|
169
170
|
if (h.id === f.id) {
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
if (!d)
|
|
174
|
-
return;
|
|
175
|
-
const { workbook: l, worksheet: S } = d;
|
|
171
|
+
const { unitId: e, sheetId: s, row: r, col: t, note: o } = h.params, d = this.getSheetTarget(e, s);
|
|
172
|
+
if (!d || n.get(c).getNote(e, s, { noteId: o.id, row: r, col: t })) return;
|
|
173
|
+
const { workbook: S, worksheet: u } = d;
|
|
176
174
|
if (this.fireEvent(this.Event.BeforeSheetNoteAdd, {
|
|
177
|
-
workbook:
|
|
178
|
-
worksheet:
|
|
175
|
+
workbook: S,
|
|
176
|
+
worksheet: u,
|
|
179
177
|
row: r,
|
|
180
|
-
col:
|
|
181
|
-
note:
|
|
178
|
+
col: t,
|
|
179
|
+
note: o
|
|
182
180
|
}))
|
|
183
|
-
throw new
|
|
181
|
+
throw new g();
|
|
184
182
|
}
|
|
185
183
|
})
|
|
186
184
|
)
|
|
@@ -188,21 +186,20 @@ class C extends m {
|
|
|
188
186
|
this.registerEventHandler(
|
|
189
187
|
this.Event.BeforeSheetNoteDelete,
|
|
190
188
|
() => a.beforeCommandExecuted((h) => {
|
|
191
|
-
if (h.id ===
|
|
192
|
-
const
|
|
193
|
-
if (!
|
|
194
|
-
const
|
|
195
|
-
if (!
|
|
196
|
-
|
|
197
|
-
const { workbook: d, worksheet: l } = n;
|
|
189
|
+
if (h.id === x.id) {
|
|
190
|
+
const { unitId: e, sheetId: s, row: r, col: t } = h.params, o = this.getSheetTarget(e, s);
|
|
191
|
+
if (!o || r === void 0 || t === void 0) return;
|
|
192
|
+
const i = n.get(c).getNote(e, s, { row: r, col: t });
|
|
193
|
+
if (!i) return;
|
|
194
|
+
const { workbook: l, worksheet: S } = o;
|
|
198
195
|
if (this.fireEvent(this.Event.BeforeSheetNoteDelete, {
|
|
199
|
-
workbook:
|
|
200
|
-
worksheet:
|
|
196
|
+
workbook: l,
|
|
197
|
+
worksheet: S,
|
|
201
198
|
row: r,
|
|
202
|
-
col:
|
|
203
|
-
oldNote:
|
|
199
|
+
col: t,
|
|
200
|
+
oldNote: i
|
|
204
201
|
}))
|
|
205
|
-
throw new
|
|
202
|
+
throw new g();
|
|
206
203
|
}
|
|
207
204
|
})
|
|
208
205
|
)
|
|
@@ -211,21 +208,20 @@ class C extends m {
|
|
|
211
208
|
this.Event.BeforeSheetNoteUpdate,
|
|
212
209
|
() => a.beforeCommandExecuted((h) => {
|
|
213
210
|
if (h.id === f.id) {
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
216
|
-
const
|
|
217
|
-
if (!
|
|
218
|
-
|
|
219
|
-
const { workbook: l, worksheet: S } = d;
|
|
211
|
+
const { unitId: e, sheetId: s, row: r, col: t, note: o } = h.params, d = this.getSheetTarget(e, s);
|
|
212
|
+
if (!d) return;
|
|
213
|
+
const l = n.get(c).getNote(e, s, { row: r, col: t });
|
|
214
|
+
if (!l) return;
|
|
215
|
+
const { workbook: S, worksheet: u } = d;
|
|
220
216
|
if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, {
|
|
221
|
-
workbook:
|
|
222
|
-
worksheet:
|
|
217
|
+
workbook: S,
|
|
218
|
+
worksheet: u,
|
|
223
219
|
row: r,
|
|
224
|
-
col:
|
|
225
|
-
note:
|
|
226
|
-
oldNote:
|
|
220
|
+
col: t,
|
|
221
|
+
note: o,
|
|
222
|
+
oldNote: l
|
|
227
223
|
}))
|
|
228
|
-
throw new
|
|
224
|
+
throw new g();
|
|
229
225
|
}
|
|
230
226
|
})
|
|
231
227
|
)
|
|
@@ -233,20 +229,24 @@ class C extends m {
|
|
|
233
229
|
this.registerEventHandler(
|
|
234
230
|
this.Event.BeforeSheetNoteShow,
|
|
235
231
|
() => a.beforeCommandExecuted((h) => {
|
|
236
|
-
if (h.id ===
|
|
237
|
-
const e =
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
if (!
|
|
241
|
-
|
|
242
|
-
|
|
232
|
+
if (h.id === m.id) {
|
|
233
|
+
const e = E(n.get(v));
|
|
234
|
+
if (!e) return;
|
|
235
|
+
const { unitId: s, subUnitId: r } = e, t = this.getUniverSheet(s);
|
|
236
|
+
if (!t) return;
|
|
237
|
+
const o = t.getSheetBySheetId(r);
|
|
238
|
+
if (!o) return;
|
|
239
|
+
const i = n.get(p).getCurrentLastSelection();
|
|
240
|
+
if (!(i != null && i.primary)) return;
|
|
241
|
+
const l = n.get(c), { actualColumn: S, actualRow: u } = i.primary, N = l.getNote(s, r, { row: u, col: S });
|
|
242
|
+
if (!N || N.show) return;
|
|
243
243
|
if (this.fireEvent(this.Event.BeforeSheetNoteShow, {
|
|
244
|
-
workbook:
|
|
245
|
-
worksheet:
|
|
246
|
-
row:
|
|
247
|
-
col:
|
|
244
|
+
workbook: t,
|
|
245
|
+
worksheet: o,
|
|
246
|
+
row: u,
|
|
247
|
+
col: S
|
|
248
248
|
}))
|
|
249
|
-
throw new
|
|
249
|
+
throw new g();
|
|
250
250
|
}
|
|
251
251
|
})
|
|
252
252
|
)
|
|
@@ -254,43 +254,41 @@ class C extends m {
|
|
|
254
254
|
this.registerEventHandler(
|
|
255
255
|
this.Event.BeforeSheetNoteHide,
|
|
256
256
|
() => a.beforeCommandExecuted((h) => {
|
|
257
|
-
if (h.id ===
|
|
258
|
-
const e =
|
|
259
|
-
if (!
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
262
|
-
|
|
263
|
-
|
|
257
|
+
if (h.id === m.id) {
|
|
258
|
+
const e = E(n.get(v));
|
|
259
|
+
if (!e) return;
|
|
260
|
+
const { unitId: s, subUnitId: r } = e, t = this.getUniverSheet(s);
|
|
261
|
+
if (!t) return;
|
|
262
|
+
const o = t.getSheetBySheetId(r);
|
|
263
|
+
if (!o) return;
|
|
264
|
+
const i = n.get(p).getCurrentLastSelection();
|
|
265
|
+
if (!(i != null && i.primary)) return;
|
|
266
|
+
const l = n.get(c), { actualColumn: S, actualRow: u } = i.primary, N = l.getNote(s, r, { row: u, col: S });
|
|
267
|
+
if (!N || !N.show) return;
|
|
264
268
|
if (this.fireEvent(this.Event.BeforeSheetNoteHide, {
|
|
265
|
-
workbook:
|
|
266
|
-
worksheet:
|
|
267
|
-
row:
|
|
268
|
-
col:
|
|
269
|
+
workbook: t,
|
|
270
|
+
worksheet: o,
|
|
271
|
+
row: u,
|
|
272
|
+
col: S
|
|
269
273
|
}))
|
|
270
|
-
throw new
|
|
274
|
+
throw new g();
|
|
271
275
|
}
|
|
272
276
|
})
|
|
273
277
|
)
|
|
274
278
|
);
|
|
275
279
|
}
|
|
276
280
|
}
|
|
277
|
-
|
|
278
|
-
class
|
|
281
|
+
I.extend(T);
|
|
282
|
+
class A extends b {
|
|
279
283
|
getNotes() {
|
|
280
|
-
const a = this._injector.get(
|
|
281
|
-
return a
|
|
282
|
-
h.push({
|
|
283
|
-
...o,
|
|
284
|
-
row: e,
|
|
285
|
-
col: t
|
|
286
|
-
});
|
|
287
|
-
}), h;
|
|
284
|
+
const a = this._injector.get(c).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId());
|
|
285
|
+
return a ? Array.from(a.values()).map((h) => ({ ...h })) : [];
|
|
288
286
|
}
|
|
289
287
|
}
|
|
290
|
-
|
|
288
|
+
b.extend(A);
|
|
291
289
|
export {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
y as FSheetNoteEvent,
|
|
291
|
+
W as FSheetsNoteRangeMixin,
|
|
292
|
+
A as FSheetsNoteWorksheet,
|
|
293
|
+
T as FUniverSheetNoteMixin
|
|
296
294
|
};
|