@univerjs/sheets-note 0.20.1 → 0.21.0
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 +309 -1
- package/lib/cjs/index.js +900 -1
- package/lib/es/facade.js +305 -1
- package/lib/es/index.js +880 -1
- package/lib/facade.js +305 -1
- package/lib/index.js +880 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,309 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
3
|
+
let _univerjs_sheets_note = require("@univerjs/sheets-note");
|
|
4
|
+
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
5
|
+
let _univerjs_core = require("@univerjs/core");
|
|
6
|
+
let _univerjs_sheets = require("@univerjs/sheets");
|
|
7
|
+
|
|
8
|
+
//#region src/facade/f-event.ts
|
|
9
|
+
/**
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
var FSheetsNoteEventNameMixin = class extends _univerjs_core_facade.FEventName {
|
|
13
|
+
get SheetNoteAdd() {
|
|
14
|
+
return "SheetNoteAdd";
|
|
15
|
+
}
|
|
16
|
+
get SheetNoteDelete() {
|
|
17
|
+
return "SheetNoteDelete";
|
|
18
|
+
}
|
|
19
|
+
get SheetNoteUpdate() {
|
|
20
|
+
return "SheetNoteUpdate";
|
|
21
|
+
}
|
|
22
|
+
get SheetNoteShow() {
|
|
23
|
+
return "SheetNoteShow";
|
|
24
|
+
}
|
|
25
|
+
get SheetNoteHide() {
|
|
26
|
+
return "SheetNoteHide";
|
|
27
|
+
}
|
|
28
|
+
get BeforeSheetNoteAdd() {
|
|
29
|
+
return "BeforeSheetNoteAdd";
|
|
30
|
+
}
|
|
31
|
+
get BeforeSheetNoteDelete() {
|
|
32
|
+
return "BeforeSheetNoteDelete";
|
|
33
|
+
}
|
|
34
|
+
get BeforeSheetNoteUpdate() {
|
|
35
|
+
return "BeforeSheetNoteUpdate";
|
|
36
|
+
}
|
|
37
|
+
get BeforeSheetNoteShow() {
|
|
38
|
+
return "BeforeSheetNoteShow";
|
|
39
|
+
}
|
|
40
|
+
get BeforeSheetNoteHide() {
|
|
41
|
+
return "BeforeSheetNoteHide";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
_univerjs_core_facade.FEventName.extend(FSheetsNoteEventNameMixin);
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/facade/f-range.ts
|
|
48
|
+
var FRangeSheetsNoteMixin = class extends _univerjs_sheets_facade.FRange {
|
|
49
|
+
createOrUpdateNote(note) {
|
|
50
|
+
this._commandService.syncExecuteCommand(_univerjs_sheets_note.UpdateNoteMutation.id, {
|
|
51
|
+
unitId: this.getUnitId(),
|
|
52
|
+
sheetId: this.getSheetId(),
|
|
53
|
+
row: this.getRow(),
|
|
54
|
+
col: this.getColumn(),
|
|
55
|
+
note
|
|
56
|
+
});
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
deleteNote() {
|
|
60
|
+
this._commandService.syncExecuteCommand(_univerjs_sheets_note.RemoveNoteMutation.id, {
|
|
61
|
+
unitId: this.getUnitId(),
|
|
62
|
+
sheetId: this.getSheetId(),
|
|
63
|
+
row: this.getRow(),
|
|
64
|
+
col: this.getColumn()
|
|
65
|
+
});
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
getNote() {
|
|
69
|
+
return this._injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(this.getUnitId(), this.getSheetId(), {
|
|
70
|
+
row: this.getRow(),
|
|
71
|
+
col: this.getColumn()
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
_univerjs_sheets_facade.FRange.extend(FRangeSheetsNoteMixin);
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/facade/f-univer.ts
|
|
79
|
+
var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
80
|
+
_initialize(injector) {
|
|
81
|
+
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
82
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd, () => {
|
|
83
|
+
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
84
|
+
if (change.type === "update" && !change.oldNote && change.newNote) {
|
|
85
|
+
const { unitId, subUnitId, newNote } = change;
|
|
86
|
+
const target = this.getSheetTarget(unitId, subUnitId);
|
|
87
|
+
if (!target) return;
|
|
88
|
+
const { workbook, worksheet } = target;
|
|
89
|
+
const eventParams = {
|
|
90
|
+
workbook,
|
|
91
|
+
worksheet,
|
|
92
|
+
row: newNote.row,
|
|
93
|
+
col: newNote.col,
|
|
94
|
+
note: newNote
|
|
95
|
+
};
|
|
96
|
+
this.fireEvent(this.Event.SheetNoteAdd, eventParams);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}));
|
|
100
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete, () => {
|
|
101
|
+
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
102
|
+
if (change.type === "update" && change.oldNote && !change.newNote) {
|
|
103
|
+
const { unitId, subUnitId, oldNote } = change;
|
|
104
|
+
const target = this.getSheetTarget(unitId, subUnitId);
|
|
105
|
+
if (!target) return;
|
|
106
|
+
const { workbook, worksheet } = target;
|
|
107
|
+
const eventParams = {
|
|
108
|
+
workbook,
|
|
109
|
+
worksheet,
|
|
110
|
+
row: oldNote.row,
|
|
111
|
+
col: oldNote.col,
|
|
112
|
+
oldNote
|
|
113
|
+
};
|
|
114
|
+
this.fireEvent(this.Event.SheetNoteDelete, eventParams);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}));
|
|
118
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate, () => {
|
|
119
|
+
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
120
|
+
if (change.type === "update" && change.oldNote && change.newNote) {
|
|
121
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
122
|
+
const target = this.getSheetTarget(unitId, subUnitId);
|
|
123
|
+
if (!target) return;
|
|
124
|
+
const { workbook, worksheet } = target;
|
|
125
|
+
const eventParams = {
|
|
126
|
+
workbook,
|
|
127
|
+
worksheet,
|
|
128
|
+
row: newNote.row,
|
|
129
|
+
col: newNote.col,
|
|
130
|
+
note: newNote,
|
|
131
|
+
oldNote
|
|
132
|
+
};
|
|
133
|
+
this.fireEvent(this.Event.SheetNoteUpdate, eventParams);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}));
|
|
137
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow, () => {
|
|
138
|
+
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
139
|
+
if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
|
|
140
|
+
const { unitId, subUnitId, newNote } = change;
|
|
141
|
+
const target = this.getSheetTarget(unitId, subUnitId);
|
|
142
|
+
if (!target) return;
|
|
143
|
+
const { workbook, worksheet } = target;
|
|
144
|
+
const eventParams = {
|
|
145
|
+
workbook,
|
|
146
|
+
worksheet,
|
|
147
|
+
row: newNote.row,
|
|
148
|
+
col: newNote.col
|
|
149
|
+
};
|
|
150
|
+
this.fireEvent(this.Event.SheetNoteShow, eventParams);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}));
|
|
154
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide, () => {
|
|
155
|
+
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
156
|
+
if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
|
|
157
|
+
const { unitId, subUnitId, newNote } = change;
|
|
158
|
+
const target = this.getSheetTarget(unitId, subUnitId);
|
|
159
|
+
if (!target) return;
|
|
160
|
+
const { workbook, worksheet } = target;
|
|
161
|
+
const eventParams = {
|
|
162
|
+
workbook,
|
|
163
|
+
worksheet,
|
|
164
|
+
row: newNote.row,
|
|
165
|
+
col: newNote.col
|
|
166
|
+
};
|
|
167
|
+
this.fireEvent(this.Event.SheetNoteHide, eventParams);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}));
|
|
171
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
|
|
172
|
+
if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
|
|
173
|
+
const { unitId, sheetId, row, col, note } = command.params;
|
|
174
|
+
const target = this.getSheetTarget(unitId, sheetId);
|
|
175
|
+
if (!target) return;
|
|
176
|
+
if (injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
|
|
177
|
+
noteId: note.id,
|
|
178
|
+
row,
|
|
179
|
+
col
|
|
180
|
+
})) return;
|
|
181
|
+
const { workbook, worksheet } = target;
|
|
182
|
+
const eventParams = {
|
|
183
|
+
workbook,
|
|
184
|
+
worksheet,
|
|
185
|
+
row,
|
|
186
|
+
col,
|
|
187
|
+
note
|
|
188
|
+
};
|
|
189
|
+
if (this.fireEvent(this.Event.BeforeSheetNoteAdd, eventParams)) throw new _univerjs_core.CanceledError();
|
|
190
|
+
}
|
|
191
|
+
})));
|
|
192
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
|
|
193
|
+
if (command.id === _univerjs_sheets_note.SheetDeleteNoteCommand.id) {
|
|
194
|
+
const { unitId, sheetId, row, col } = command.params;
|
|
195
|
+
const target = this.getSheetTarget(unitId, sheetId);
|
|
196
|
+
if (!target) return;
|
|
197
|
+
if (row === void 0 || col === void 0) return;
|
|
198
|
+
const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
|
|
199
|
+
row,
|
|
200
|
+
col
|
|
201
|
+
});
|
|
202
|
+
if (!oldNote) return;
|
|
203
|
+
const { workbook, worksheet } = target;
|
|
204
|
+
const eventParams = {
|
|
205
|
+
workbook,
|
|
206
|
+
worksheet,
|
|
207
|
+
row,
|
|
208
|
+
col,
|
|
209
|
+
oldNote
|
|
210
|
+
};
|
|
211
|
+
if (this.fireEvent(this.Event.BeforeSheetNoteDelete, eventParams)) throw new _univerjs_core.CanceledError();
|
|
212
|
+
}
|
|
213
|
+
})));
|
|
214
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
|
|
215
|
+
if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
|
|
216
|
+
const { unitId, sheetId, row, col, note } = command.params;
|
|
217
|
+
const target = this.getSheetTarget(unitId, sheetId);
|
|
218
|
+
if (!target) return;
|
|
219
|
+
const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
|
|
220
|
+
row,
|
|
221
|
+
col
|
|
222
|
+
});
|
|
223
|
+
if (!oldNote) return;
|
|
224
|
+
const { workbook, worksheet } = target;
|
|
225
|
+
const eventParams = {
|
|
226
|
+
workbook,
|
|
227
|
+
worksheet,
|
|
228
|
+
row,
|
|
229
|
+
col,
|
|
230
|
+
note,
|
|
231
|
+
oldNote
|
|
232
|
+
};
|
|
233
|
+
if (this.fireEvent(this.Event.BeforeSheetNoteUpdate, eventParams)) throw new _univerjs_core.CanceledError();
|
|
234
|
+
}
|
|
235
|
+
})));
|
|
236
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
|
|
237
|
+
if (command.id === _univerjs_sheets_note.SheetToggleNotePopupCommand.id) {
|
|
238
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(injector.get(_univerjs_core.IUniverInstanceService));
|
|
239
|
+
if (!target) return;
|
|
240
|
+
const { unitId, subUnitId } = target;
|
|
241
|
+
const workbook = this.getUniverSheet(unitId);
|
|
242
|
+
if (!workbook) return;
|
|
243
|
+
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
244
|
+
if (!worksheet) return;
|
|
245
|
+
const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
246
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
247
|
+
const sheetsNoteModel = injector.get(_univerjs_sheets_note.SheetsNoteModel);
|
|
248
|
+
const { actualColumn, actualRow } = selection.primary;
|
|
249
|
+
const note = sheetsNoteModel.getNote(unitId, subUnitId, {
|
|
250
|
+
row: actualRow,
|
|
251
|
+
col: actualColumn
|
|
252
|
+
});
|
|
253
|
+
if (!note || note.show) return;
|
|
254
|
+
const eventParams = {
|
|
255
|
+
workbook,
|
|
256
|
+
worksheet,
|
|
257
|
+
row: actualRow,
|
|
258
|
+
col: actualColumn
|
|
259
|
+
};
|
|
260
|
+
if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new _univerjs_core.CanceledError();
|
|
261
|
+
}
|
|
262
|
+
})));
|
|
263
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
|
|
264
|
+
if (command.id === _univerjs_sheets_note.SheetToggleNotePopupCommand.id) {
|
|
265
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(injector.get(_univerjs_core.IUniverInstanceService));
|
|
266
|
+
if (!target) return;
|
|
267
|
+
const { unitId, subUnitId } = target;
|
|
268
|
+
const workbook = this.getUniverSheet(unitId);
|
|
269
|
+
if (!workbook) return;
|
|
270
|
+
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
271
|
+
if (!worksheet) return;
|
|
272
|
+
const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
273
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
274
|
+
const sheetsNoteModel = injector.get(_univerjs_sheets_note.SheetsNoteModel);
|
|
275
|
+
const { actualColumn, actualRow } = selection.primary;
|
|
276
|
+
const note = sheetsNoteModel.getNote(unitId, subUnitId, {
|
|
277
|
+
row: actualRow,
|
|
278
|
+
col: actualColumn
|
|
279
|
+
});
|
|
280
|
+
if (!note || !note.show) return;
|
|
281
|
+
const eventParams = {
|
|
282
|
+
workbook,
|
|
283
|
+
worksheet,
|
|
284
|
+
row: actualRow,
|
|
285
|
+
col: actualColumn
|
|
286
|
+
};
|
|
287
|
+
if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new _univerjs_core.CanceledError();
|
|
288
|
+
}
|
|
289
|
+
})));
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
_univerjs_core_facade.FUniver.extend(FUniverSheetsNoteMixin);
|
|
293
|
+
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/facade/f-worksheet.ts
|
|
296
|
+
var FWorksheetNoteMixin = class extends _univerjs_sheets_facade.FWorksheet {
|
|
297
|
+
getNotes() {
|
|
298
|
+
const notes = this._injector.get(_univerjs_sheets_note.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(), this.getSheetId());
|
|
299
|
+
if (!notes) return [];
|
|
300
|
+
return Array.from(notes.values()).map((note) => ({ ...note }));
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
_univerjs_sheets_facade.FWorksheet.extend(FWorksheetNoteMixin);
|
|
304
|
+
|
|
305
|
+
//#endregion
|
|
306
|
+
exports.FRangeSheetsNoteMixin = FRangeSheetsNoteMixin;
|
|
307
|
+
exports.FSheetsNoteEventNameMixin = FSheetsNoteEventNameMixin;
|
|
308
|
+
exports.FUniverSheetsNoteMixin = FUniverSheetsNoteMixin;
|
|
309
|
+
exports.FWorksheetNoteMixin = FWorksheetNoteMixin;
|