@univerjs/sheets-note 0.25.1 → 1.0.0-alpha.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.
- package/lib/cjs/facade.js +52 -44
- package/lib/cjs/index.js +7 -7
- package/lib/es/facade.js +54 -46
- package/lib/es/index.js +7 -7
- package/lib/facade.js +54 -46
- package/lib/index.js +7 -7
- package/lib/types/facade/f-range.d.ts +10 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/cjs/facade.js
CHANGED
|
@@ -83,7 +83,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
83
83
|
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
84
84
|
if (change.type === "update" && !change.oldNote && change.newNote) {
|
|
85
85
|
const { unitId, subUnitId, newNote } = change;
|
|
86
|
-
const target = this.
|
|
86
|
+
const target = this.getSheetCommandTarget({
|
|
87
|
+
unitId,
|
|
88
|
+
subUnitId
|
|
89
|
+
});
|
|
87
90
|
if (!target) return;
|
|
88
91
|
const { workbook, worksheet } = target;
|
|
89
92
|
const eventParams = {
|
|
@@ -101,7 +104,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
101
104
|
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
102
105
|
if (change.type === "update" && change.oldNote && !change.newNote) {
|
|
103
106
|
const { unitId, subUnitId, oldNote } = change;
|
|
104
|
-
const target = this.
|
|
107
|
+
const target = this.getSheetCommandTarget({
|
|
108
|
+
unitId,
|
|
109
|
+
subUnitId
|
|
110
|
+
});
|
|
105
111
|
if (!target) return;
|
|
106
112
|
const { workbook, worksheet } = target;
|
|
107
113
|
const eventParams = {
|
|
@@ -119,7 +125,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
119
125
|
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
120
126
|
if (change.type === "update" && change.oldNote && change.newNote) {
|
|
121
127
|
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
122
|
-
const target = this.
|
|
128
|
+
const target = this.getSheetCommandTarget({
|
|
129
|
+
unitId,
|
|
130
|
+
subUnitId
|
|
131
|
+
});
|
|
123
132
|
if (!target) return;
|
|
124
133
|
const { workbook, worksheet } = target;
|
|
125
134
|
const eventParams = {
|
|
@@ -138,7 +147,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
138
147
|
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
139
148
|
if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
|
|
140
149
|
const { unitId, subUnitId, newNote } = change;
|
|
141
|
-
const target = this.
|
|
150
|
+
const target = this.getSheetCommandTarget({
|
|
151
|
+
unitId,
|
|
152
|
+
subUnitId
|
|
153
|
+
});
|
|
142
154
|
if (!target) return;
|
|
143
155
|
const { workbook, worksheet } = target;
|
|
144
156
|
const eventParams = {
|
|
@@ -155,7 +167,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
155
167
|
return injector.get(_univerjs_sheets_note.SheetsNoteModel).change$.subscribe((change) => {
|
|
156
168
|
if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
|
|
157
169
|
const { unitId, subUnitId, newNote } = change;
|
|
158
|
-
const target = this.
|
|
170
|
+
const target = this.getSheetCommandTarget({
|
|
171
|
+
unitId,
|
|
172
|
+
subUnitId
|
|
173
|
+
});
|
|
159
174
|
if (!target) return;
|
|
160
175
|
const { workbook, worksheet } = target;
|
|
161
176
|
const eventParams = {
|
|
@@ -170,15 +185,16 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
170
185
|
}));
|
|
171
186
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
|
|
172
187
|
if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
|
|
173
|
-
const
|
|
174
|
-
const target = this.
|
|
188
|
+
const params = command.params;
|
|
189
|
+
const target = this.getSheetCommandTarget(params);
|
|
175
190
|
if (!target) return;
|
|
176
|
-
|
|
191
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
192
|
+
const { row, col, note } = params;
|
|
193
|
+
if (injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
177
194
|
noteId: note.id,
|
|
178
195
|
row,
|
|
179
196
|
col
|
|
180
197
|
})) return;
|
|
181
|
-
const { workbook, worksheet } = target;
|
|
182
198
|
const eventParams = {
|
|
183
199
|
workbook,
|
|
184
200
|
worksheet,
|
|
@@ -191,16 +207,17 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
191
207
|
})));
|
|
192
208
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
|
|
193
209
|
if (command.id === _univerjs_sheets_note.SheetDeleteNoteCommand.id) {
|
|
194
|
-
const
|
|
195
|
-
const target = this.getSheetTarget(unitId, sheetId);
|
|
210
|
+
const target = this.getSheetCommandTarget();
|
|
196
211
|
if (!target) return;
|
|
197
|
-
|
|
198
|
-
|
|
212
|
+
const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
213
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
214
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
215
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
216
|
+
const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
199
217
|
row,
|
|
200
218
|
col
|
|
201
219
|
});
|
|
202
220
|
if (!oldNote) return;
|
|
203
|
-
const { workbook, worksheet } = target;
|
|
204
221
|
const eventParams = {
|
|
205
222
|
workbook,
|
|
206
223
|
worksheet,
|
|
@@ -213,15 +230,16 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
213
230
|
})));
|
|
214
231
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
|
|
215
232
|
if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
|
|
216
|
-
const
|
|
217
|
-
const target = this.
|
|
233
|
+
const params = command.params;
|
|
234
|
+
const target = this.getSheetCommandTarget(params);
|
|
218
235
|
if (!target) return;
|
|
219
|
-
const
|
|
236
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
237
|
+
const { row, col, note } = params;
|
|
238
|
+
const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
220
239
|
row,
|
|
221
240
|
col
|
|
222
241
|
});
|
|
223
242
|
if (!oldNote) return;
|
|
224
|
-
const { workbook, worksheet } = target;
|
|
225
243
|
const eventParams = {
|
|
226
244
|
workbook,
|
|
227
245
|
worksheet,
|
|
@@ -235,54 +253,44 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
235
253
|
})));
|
|
236
254
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
|
|
237
255
|
if (command.id === _univerjs_sheets_note.SheetToggleNotePopupCommand.id) {
|
|
238
|
-
const target =
|
|
256
|
+
const target = this.getSheetCommandTarget();
|
|
239
257
|
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
258
|
const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
246
259
|
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
247
|
-
const
|
|
248
|
-
const {
|
|
249
|
-
const note =
|
|
250
|
-
row
|
|
251
|
-
col
|
|
260
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
261
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
262
|
+
const note = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
263
|
+
row,
|
|
264
|
+
col
|
|
252
265
|
});
|
|
253
266
|
if (!note || note.show) return;
|
|
254
267
|
const eventParams = {
|
|
255
268
|
workbook,
|
|
256
269
|
worksheet,
|
|
257
|
-
row
|
|
258
|
-
col
|
|
270
|
+
row,
|
|
271
|
+
col
|
|
259
272
|
};
|
|
260
273
|
if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new _univerjs_core.CanceledError();
|
|
261
274
|
}
|
|
262
275
|
})));
|
|
263
276
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
|
|
264
277
|
if (command.id === _univerjs_sheets_note.SheetToggleNotePopupCommand.id) {
|
|
265
|
-
const target =
|
|
278
|
+
const target = this.getSheetCommandTarget();
|
|
266
279
|
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
280
|
const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
273
281
|
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
274
|
-
const
|
|
275
|
-
const {
|
|
276
|
-
const note =
|
|
277
|
-
row
|
|
278
|
-
col
|
|
282
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
283
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
284
|
+
const note = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
285
|
+
row,
|
|
286
|
+
col
|
|
279
287
|
});
|
|
280
288
|
if (!note || !note.show) return;
|
|
281
289
|
const eventParams = {
|
|
282
290
|
workbook,
|
|
283
291
|
worksheet,
|
|
284
|
-
row
|
|
285
|
-
col
|
|
292
|
+
row,
|
|
293
|
+
col
|
|
286
294
|
};
|
|
287
295
|
if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new _univerjs_core.CanceledError();
|
|
288
296
|
}
|
package/lib/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ let _univerjs_core = require("@univerjs/core");
|
|
|
3
3
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
4
4
|
let rxjs = require("rxjs");
|
|
5
5
|
|
|
6
|
-
//#region \0@oxc-project+runtime@0.
|
|
6
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
7
7
|
function _typeof(o) {
|
|
8
8
|
"@babel/helpers - typeof";
|
|
9
9
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,7 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
18
18
|
function toPrimitive(t, r) {
|
|
19
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
20
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region \0@oxc-project+runtime@0.
|
|
30
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
31
31
|
function toPropertyKey(t) {
|
|
32
32
|
var i = toPrimitive(t, "string");
|
|
33
33
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
38
38
|
function _defineProperty(e, r, t) {
|
|
39
39
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
40
|
value: t,
|
|
@@ -441,7 +441,7 @@ const SheetUpdateNoteCommand = {
|
|
|
441
441
|
const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
|
|
442
442
|
|
|
443
443
|
//#endregion
|
|
444
|
-
//#region \0@oxc-project+runtime@0.
|
|
444
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
445
445
|
function __decorateParam(paramIndex, decorator) {
|
|
446
446
|
return function(target, key) {
|
|
447
447
|
decorator(target, key, paramIndex);
|
|
@@ -449,7 +449,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
//#endregion
|
|
452
|
-
//#region \0@oxc-project+runtime@0.
|
|
452
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
453
453
|
function __decorate(decorators, target, key, desc) {
|
|
454
454
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
455
455
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -617,7 +617,7 @@ SheetsNoteResourceController = __decorate([
|
|
|
617
617
|
//#endregion
|
|
618
618
|
//#region package.json
|
|
619
619
|
var name = "@univerjs/sheets-note";
|
|
620
|
-
var version = "0.
|
|
620
|
+
var version = "1.0.0-alpha.1";
|
|
621
621
|
|
|
622
622
|
//#endregion
|
|
623
623
|
//#region src/config/config.ts
|
package/lib/es/facade.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
2
2
|
import { RemoveNoteMutation, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UpdateNoteMutation } from "@univerjs/sheets-note";
|
|
3
3
|
import { FRange, FWorksheet } from "@univerjs/sheets/facade";
|
|
4
|
-
import { CanceledError, ICommandService
|
|
5
|
-
import { SheetsSelectionsService
|
|
4
|
+
import { CanceledError, ICommandService } from "@univerjs/core";
|
|
5
|
+
import { SheetsSelectionsService } from "@univerjs/sheets";
|
|
6
6
|
|
|
7
7
|
//#region src/facade/f-event.ts
|
|
8
8
|
/**
|
|
@@ -82,7 +82,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
82
82
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
83
83
|
if (change.type === "update" && !change.oldNote && change.newNote) {
|
|
84
84
|
const { unitId, subUnitId, newNote } = change;
|
|
85
|
-
const target = this.
|
|
85
|
+
const target = this.getSheetCommandTarget({
|
|
86
|
+
unitId,
|
|
87
|
+
subUnitId
|
|
88
|
+
});
|
|
86
89
|
if (!target) return;
|
|
87
90
|
const { workbook, worksheet } = target;
|
|
88
91
|
const eventParams = {
|
|
@@ -100,7 +103,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
100
103
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
101
104
|
if (change.type === "update" && change.oldNote && !change.newNote) {
|
|
102
105
|
const { unitId, subUnitId, oldNote } = change;
|
|
103
|
-
const target = this.
|
|
106
|
+
const target = this.getSheetCommandTarget({
|
|
107
|
+
unitId,
|
|
108
|
+
subUnitId
|
|
109
|
+
});
|
|
104
110
|
if (!target) return;
|
|
105
111
|
const { workbook, worksheet } = target;
|
|
106
112
|
const eventParams = {
|
|
@@ -118,7 +124,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
118
124
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
119
125
|
if (change.type === "update" && change.oldNote && change.newNote) {
|
|
120
126
|
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
121
|
-
const target = this.
|
|
127
|
+
const target = this.getSheetCommandTarget({
|
|
128
|
+
unitId,
|
|
129
|
+
subUnitId
|
|
130
|
+
});
|
|
122
131
|
if (!target) return;
|
|
123
132
|
const { workbook, worksheet } = target;
|
|
124
133
|
const eventParams = {
|
|
@@ -137,7 +146,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
137
146
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
138
147
|
if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
|
|
139
148
|
const { unitId, subUnitId, newNote } = change;
|
|
140
|
-
const target = this.
|
|
149
|
+
const target = this.getSheetCommandTarget({
|
|
150
|
+
unitId,
|
|
151
|
+
subUnitId
|
|
152
|
+
});
|
|
141
153
|
if (!target) return;
|
|
142
154
|
const { workbook, worksheet } = target;
|
|
143
155
|
const eventParams = {
|
|
@@ -154,7 +166,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
154
166
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
155
167
|
if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
|
|
156
168
|
const { unitId, subUnitId, newNote } = change;
|
|
157
|
-
const target = this.
|
|
169
|
+
const target = this.getSheetCommandTarget({
|
|
170
|
+
unitId,
|
|
171
|
+
subUnitId
|
|
172
|
+
});
|
|
158
173
|
if (!target) return;
|
|
159
174
|
const { workbook, worksheet } = target;
|
|
160
175
|
const eventParams = {
|
|
@@ -169,15 +184,16 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
169
184
|
}));
|
|
170
185
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
|
|
171
186
|
if (command.id === SheetUpdateNoteCommand.id) {
|
|
172
|
-
const
|
|
173
|
-
const target = this.
|
|
187
|
+
const params = command.params;
|
|
188
|
+
const target = this.getSheetCommandTarget(params);
|
|
174
189
|
if (!target) return;
|
|
175
|
-
|
|
190
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
191
|
+
const { row, col, note } = params;
|
|
192
|
+
if (injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
176
193
|
noteId: note.id,
|
|
177
194
|
row,
|
|
178
195
|
col
|
|
179
196
|
})) return;
|
|
180
|
-
const { workbook, worksheet } = target;
|
|
181
197
|
const eventParams = {
|
|
182
198
|
workbook,
|
|
183
199
|
worksheet,
|
|
@@ -190,16 +206,17 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
190
206
|
})));
|
|
191
207
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
|
|
192
208
|
if (command.id === SheetDeleteNoteCommand.id) {
|
|
193
|
-
const
|
|
194
|
-
const target = this.getSheetTarget(unitId, sheetId);
|
|
209
|
+
const target = this.getSheetCommandTarget();
|
|
195
210
|
if (!target) return;
|
|
196
|
-
|
|
197
|
-
|
|
211
|
+
const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
212
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
213
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
214
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
215
|
+
const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
198
216
|
row,
|
|
199
217
|
col
|
|
200
218
|
});
|
|
201
219
|
if (!oldNote) return;
|
|
202
|
-
const { workbook, worksheet } = target;
|
|
203
220
|
const eventParams = {
|
|
204
221
|
workbook,
|
|
205
222
|
worksheet,
|
|
@@ -212,15 +229,16 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
212
229
|
})));
|
|
213
230
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
|
|
214
231
|
if (command.id === SheetUpdateNoteCommand.id) {
|
|
215
|
-
const
|
|
216
|
-
const target = this.
|
|
232
|
+
const params = command.params;
|
|
233
|
+
const target = this.getSheetCommandTarget(params);
|
|
217
234
|
if (!target) return;
|
|
218
|
-
const
|
|
235
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
236
|
+
const { row, col, note } = params;
|
|
237
|
+
const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
219
238
|
row,
|
|
220
239
|
col
|
|
221
240
|
});
|
|
222
241
|
if (!oldNote) return;
|
|
223
|
-
const { workbook, worksheet } = target;
|
|
224
242
|
const eventParams = {
|
|
225
243
|
workbook,
|
|
226
244
|
worksheet,
|
|
@@ -234,54 +252,44 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
234
252
|
})));
|
|
235
253
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
|
|
236
254
|
if (command.id === SheetToggleNotePopupCommand.id) {
|
|
237
|
-
const target = getSheetCommandTarget(
|
|
255
|
+
const target = this.getSheetCommandTarget();
|
|
238
256
|
if (!target) return;
|
|
239
|
-
const { unitId, subUnitId } = target;
|
|
240
|
-
const workbook = this.getUniverSheet(unitId);
|
|
241
|
-
if (!workbook) return;
|
|
242
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
243
|
-
if (!worksheet) return;
|
|
244
257
|
const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
245
258
|
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
246
|
-
const
|
|
247
|
-
const {
|
|
248
|
-
const note =
|
|
249
|
-
row
|
|
250
|
-
col
|
|
259
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
260
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
261
|
+
const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
262
|
+
row,
|
|
263
|
+
col
|
|
251
264
|
});
|
|
252
265
|
if (!note || note.show) return;
|
|
253
266
|
const eventParams = {
|
|
254
267
|
workbook,
|
|
255
268
|
worksheet,
|
|
256
|
-
row
|
|
257
|
-
col
|
|
269
|
+
row,
|
|
270
|
+
col
|
|
258
271
|
};
|
|
259
272
|
if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new CanceledError();
|
|
260
273
|
}
|
|
261
274
|
})));
|
|
262
275
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
|
|
263
276
|
if (command.id === SheetToggleNotePopupCommand.id) {
|
|
264
|
-
const target = getSheetCommandTarget(
|
|
277
|
+
const target = this.getSheetCommandTarget();
|
|
265
278
|
if (!target) return;
|
|
266
|
-
const { unitId, subUnitId } = target;
|
|
267
|
-
const workbook = this.getUniverSheet(unitId);
|
|
268
|
-
if (!workbook) return;
|
|
269
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
270
|
-
if (!worksheet) return;
|
|
271
279
|
const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
272
280
|
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
273
|
-
const
|
|
274
|
-
const {
|
|
275
|
-
const note =
|
|
276
|
-
row
|
|
277
|
-
col
|
|
281
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
282
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
283
|
+
const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
284
|
+
row,
|
|
285
|
+
col
|
|
278
286
|
});
|
|
279
287
|
if (!note || !note.show) return;
|
|
280
288
|
const eventParams = {
|
|
281
289
|
workbook,
|
|
282
290
|
worksheet,
|
|
283
|
-
row
|
|
284
|
-
col
|
|
291
|
+
row,
|
|
292
|
+
col
|
|
285
293
|
};
|
|
286
294
|
if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new CanceledError();
|
|
287
295
|
}
|
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CommandType, DependentOn, Disposable, ICommandService, IConfigService,
|
|
|
2
2
|
import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, getSheetCommandTarget, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
|
|
3
3
|
import { Subject, filter, map } from "rxjs";
|
|
4
4
|
|
|
5
|
-
//#region \0@oxc-project+runtime@0.
|
|
5
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
6
6
|
function _typeof(o) {
|
|
7
7
|
"@babel/helpers - typeof";
|
|
8
8
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -13,7 +13,7 @@ function _typeof(o) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region \0@oxc-project+runtime@0.
|
|
16
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
17
17
|
function toPrimitive(t, r) {
|
|
18
18
|
if ("object" != _typeof(t) || !t) return t;
|
|
19
19
|
var e = t[Symbol.toPrimitive];
|
|
@@ -26,14 +26,14 @@ function toPrimitive(t, r) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
|
-
//#region \0@oxc-project+runtime@0.
|
|
29
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
30
30
|
function toPropertyKey(t) {
|
|
31
31
|
var i = toPrimitive(t, "string");
|
|
32
32
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region \0@oxc-project+runtime@0.
|
|
36
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
37
37
|
function _defineProperty(e, r, t) {
|
|
38
38
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
39
39
|
value: t,
|
|
@@ -440,7 +440,7 @@ const SheetUpdateNoteCommand = {
|
|
|
440
440
|
const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
|
|
441
441
|
|
|
442
442
|
//#endregion
|
|
443
|
-
//#region \0@oxc-project+runtime@0.
|
|
443
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
444
444
|
function __decorateParam(paramIndex, decorator) {
|
|
445
445
|
return function(target, key) {
|
|
446
446
|
decorator(target, key, paramIndex);
|
|
@@ -448,7 +448,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
//#endregion
|
|
451
|
-
//#region \0@oxc-project+runtime@0.
|
|
451
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
452
452
|
function __decorate(decorators, target, key, desc) {
|
|
453
453
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
454
454
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -616,7 +616,7 @@ SheetsNoteResourceController = __decorate([
|
|
|
616
616
|
//#endregion
|
|
617
617
|
//#region package.json
|
|
618
618
|
var name = "@univerjs/sheets-note";
|
|
619
|
-
var version = "0.
|
|
619
|
+
var version = "1.0.0-alpha.1";
|
|
620
620
|
|
|
621
621
|
//#endregion
|
|
622
622
|
//#region src/config/config.ts
|
package/lib/facade.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
2
2
|
import { RemoveNoteMutation, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UpdateNoteMutation } from "@univerjs/sheets-note";
|
|
3
3
|
import { FRange, FWorksheet } from "@univerjs/sheets/facade";
|
|
4
|
-
import { CanceledError, ICommandService
|
|
5
|
-
import { SheetsSelectionsService
|
|
4
|
+
import { CanceledError, ICommandService } from "@univerjs/core";
|
|
5
|
+
import { SheetsSelectionsService } from "@univerjs/sheets";
|
|
6
6
|
|
|
7
7
|
//#region src/facade/f-event.ts
|
|
8
8
|
/**
|
|
@@ -82,7 +82,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
82
82
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
83
83
|
if (change.type === "update" && !change.oldNote && change.newNote) {
|
|
84
84
|
const { unitId, subUnitId, newNote } = change;
|
|
85
|
-
const target = this.
|
|
85
|
+
const target = this.getSheetCommandTarget({
|
|
86
|
+
unitId,
|
|
87
|
+
subUnitId
|
|
88
|
+
});
|
|
86
89
|
if (!target) return;
|
|
87
90
|
const { workbook, worksheet } = target;
|
|
88
91
|
const eventParams = {
|
|
@@ -100,7 +103,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
100
103
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
101
104
|
if (change.type === "update" && change.oldNote && !change.newNote) {
|
|
102
105
|
const { unitId, subUnitId, oldNote } = change;
|
|
103
|
-
const target = this.
|
|
106
|
+
const target = this.getSheetCommandTarget({
|
|
107
|
+
unitId,
|
|
108
|
+
subUnitId
|
|
109
|
+
});
|
|
104
110
|
if (!target) return;
|
|
105
111
|
const { workbook, worksheet } = target;
|
|
106
112
|
const eventParams = {
|
|
@@ -118,7 +124,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
118
124
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
119
125
|
if (change.type === "update" && change.oldNote && change.newNote) {
|
|
120
126
|
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
121
|
-
const target = this.
|
|
127
|
+
const target = this.getSheetCommandTarget({
|
|
128
|
+
unitId,
|
|
129
|
+
subUnitId
|
|
130
|
+
});
|
|
122
131
|
if (!target) return;
|
|
123
132
|
const { workbook, worksheet } = target;
|
|
124
133
|
const eventParams = {
|
|
@@ -137,7 +146,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
137
146
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
138
147
|
if (change.type === "update" && change.oldNote && change.newNote && !change.oldNote.show && change.newNote.show) {
|
|
139
148
|
const { unitId, subUnitId, newNote } = change;
|
|
140
|
-
const target = this.
|
|
149
|
+
const target = this.getSheetCommandTarget({
|
|
150
|
+
unitId,
|
|
151
|
+
subUnitId
|
|
152
|
+
});
|
|
141
153
|
if (!target) return;
|
|
142
154
|
const { workbook, worksheet } = target;
|
|
143
155
|
const eventParams = {
|
|
@@ -154,7 +166,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
154
166
|
return injector.get(SheetsNoteModel).change$.subscribe((change) => {
|
|
155
167
|
if (change.type === "update" && change.oldNote && change.newNote && change.oldNote.show && !change.newNote.show) {
|
|
156
168
|
const { unitId, subUnitId, newNote } = change;
|
|
157
|
-
const target = this.
|
|
169
|
+
const target = this.getSheetCommandTarget({
|
|
170
|
+
unitId,
|
|
171
|
+
subUnitId
|
|
172
|
+
});
|
|
158
173
|
if (!target) return;
|
|
159
174
|
const { workbook, worksheet } = target;
|
|
160
175
|
const eventParams = {
|
|
@@ -169,15 +184,16 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
169
184
|
}));
|
|
170
185
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
|
|
171
186
|
if (command.id === SheetUpdateNoteCommand.id) {
|
|
172
|
-
const
|
|
173
|
-
const target = this.
|
|
187
|
+
const params = command.params;
|
|
188
|
+
const target = this.getSheetCommandTarget(params);
|
|
174
189
|
if (!target) return;
|
|
175
|
-
|
|
190
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
191
|
+
const { row, col, note } = params;
|
|
192
|
+
if (injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
176
193
|
noteId: note.id,
|
|
177
194
|
row,
|
|
178
195
|
col
|
|
179
196
|
})) return;
|
|
180
|
-
const { workbook, worksheet } = target;
|
|
181
197
|
const eventParams = {
|
|
182
198
|
workbook,
|
|
183
199
|
worksheet,
|
|
@@ -190,16 +206,17 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
190
206
|
})));
|
|
191
207
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
|
|
192
208
|
if (command.id === SheetDeleteNoteCommand.id) {
|
|
193
|
-
const
|
|
194
|
-
const target = this.getSheetTarget(unitId, sheetId);
|
|
209
|
+
const target = this.getSheetCommandTarget();
|
|
195
210
|
if (!target) return;
|
|
196
|
-
|
|
197
|
-
|
|
211
|
+
const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
212
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
213
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
214
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
215
|
+
const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
198
216
|
row,
|
|
199
217
|
col
|
|
200
218
|
});
|
|
201
219
|
if (!oldNote) return;
|
|
202
|
-
const { workbook, worksheet } = target;
|
|
203
220
|
const eventParams = {
|
|
204
221
|
workbook,
|
|
205
222
|
worksheet,
|
|
@@ -212,15 +229,16 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
212
229
|
})));
|
|
213
230
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
|
|
214
231
|
if (command.id === SheetUpdateNoteCommand.id) {
|
|
215
|
-
const
|
|
216
|
-
const target = this.
|
|
232
|
+
const params = command.params;
|
|
233
|
+
const target = this.getSheetCommandTarget(params);
|
|
217
234
|
if (!target) return;
|
|
218
|
-
const
|
|
235
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
236
|
+
const { row, col, note } = params;
|
|
237
|
+
const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
219
238
|
row,
|
|
220
239
|
col
|
|
221
240
|
});
|
|
222
241
|
if (!oldNote) return;
|
|
223
|
-
const { workbook, worksheet } = target;
|
|
224
242
|
const eventParams = {
|
|
225
243
|
workbook,
|
|
226
244
|
worksheet,
|
|
@@ -234,54 +252,44 @@ var FUniverSheetsNoteMixin = class extends FUniver {
|
|
|
234
252
|
})));
|
|
235
253
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow, () => commandService.beforeCommandExecuted((command) => {
|
|
236
254
|
if (command.id === SheetToggleNotePopupCommand.id) {
|
|
237
|
-
const target = getSheetCommandTarget(
|
|
255
|
+
const target = this.getSheetCommandTarget();
|
|
238
256
|
if (!target) return;
|
|
239
|
-
const { unitId, subUnitId } = target;
|
|
240
|
-
const workbook = this.getUniverSheet(unitId);
|
|
241
|
-
if (!workbook) return;
|
|
242
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
243
|
-
if (!worksheet) return;
|
|
244
257
|
const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
245
258
|
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
246
|
-
const
|
|
247
|
-
const {
|
|
248
|
-
const note =
|
|
249
|
-
row
|
|
250
|
-
col
|
|
259
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
260
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
261
|
+
const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
262
|
+
row,
|
|
263
|
+
col
|
|
251
264
|
});
|
|
252
265
|
if (!note || note.show) return;
|
|
253
266
|
const eventParams = {
|
|
254
267
|
workbook,
|
|
255
268
|
worksheet,
|
|
256
|
-
row
|
|
257
|
-
col
|
|
269
|
+
row,
|
|
270
|
+
col
|
|
258
271
|
};
|
|
259
272
|
if (this.fireEvent(this.Event.BeforeSheetNoteShow, eventParams)) throw new CanceledError();
|
|
260
273
|
}
|
|
261
274
|
})));
|
|
262
275
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide, () => commandService.beforeCommandExecuted((command) => {
|
|
263
276
|
if (command.id === SheetToggleNotePopupCommand.id) {
|
|
264
|
-
const target = getSheetCommandTarget(
|
|
277
|
+
const target = this.getSheetCommandTarget();
|
|
265
278
|
if (!target) return;
|
|
266
|
-
const { unitId, subUnitId } = target;
|
|
267
|
-
const workbook = this.getUniverSheet(unitId);
|
|
268
|
-
if (!workbook) return;
|
|
269
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
270
|
-
if (!worksheet) return;
|
|
271
279
|
const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
272
280
|
if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
|
|
273
|
-
const
|
|
274
|
-
const {
|
|
275
|
-
const note =
|
|
276
|
-
row
|
|
277
|
-
col
|
|
281
|
+
const { workbook, worksheet, unitId, subUnitId } = target;
|
|
282
|
+
const { actualRow: row, actualColumn: col } = selection.primary;
|
|
283
|
+
const note = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
|
|
284
|
+
row,
|
|
285
|
+
col
|
|
278
286
|
});
|
|
279
287
|
if (!note || !note.show) return;
|
|
280
288
|
const eventParams = {
|
|
281
289
|
workbook,
|
|
282
290
|
worksheet,
|
|
283
|
-
row
|
|
284
|
-
col
|
|
291
|
+
row,
|
|
292
|
+
col
|
|
285
293
|
};
|
|
286
294
|
if (this.fireEvent(this.Event.BeforeSheetNoteHide, eventParams)) throw new CanceledError();
|
|
287
295
|
}
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CommandType, DependentOn, Disposable, ICommandService, IConfigService,
|
|
|
2
2
|
import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, getSheetCommandTarget, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
|
|
3
3
|
import { Subject, filter, map } from "rxjs";
|
|
4
4
|
|
|
5
|
-
//#region \0@oxc-project+runtime@0.
|
|
5
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
6
6
|
function _typeof(o) {
|
|
7
7
|
"@babel/helpers - typeof";
|
|
8
8
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -13,7 +13,7 @@ function _typeof(o) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
|
-
//#region \0@oxc-project+runtime@0.
|
|
16
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
17
17
|
function toPrimitive(t, r) {
|
|
18
18
|
if ("object" != _typeof(t) || !t) return t;
|
|
19
19
|
var e = t[Symbol.toPrimitive];
|
|
@@ -26,14 +26,14 @@ function toPrimitive(t, r) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
|
-
//#region \0@oxc-project+runtime@0.
|
|
29
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
30
30
|
function toPropertyKey(t) {
|
|
31
31
|
var i = toPrimitive(t, "string");
|
|
32
32
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region \0@oxc-project+runtime@0.
|
|
36
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
37
37
|
function _defineProperty(e, r, t) {
|
|
38
38
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
39
39
|
value: t,
|
|
@@ -440,7 +440,7 @@ const SheetUpdateNoteCommand = {
|
|
|
440
440
|
const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
|
|
441
441
|
|
|
442
442
|
//#endregion
|
|
443
|
-
//#region \0@oxc-project+runtime@0.
|
|
443
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
444
444
|
function __decorateParam(paramIndex, decorator) {
|
|
445
445
|
return function(target, key) {
|
|
446
446
|
decorator(target, key, paramIndex);
|
|
@@ -448,7 +448,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
//#endregion
|
|
451
|
-
//#region \0@oxc-project+runtime@0.
|
|
451
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
452
452
|
function __decorate(decorators, target, key, desc) {
|
|
453
453
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
454
454
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -616,7 +616,7 @@ SheetsNoteResourceController = __decorate([
|
|
|
616
616
|
//#endregion
|
|
617
617
|
//#region package.json
|
|
618
618
|
var name = "@univerjs/sheets-note";
|
|
619
|
-
var version = "0.
|
|
619
|
+
var version = "1.0.0-alpha.1";
|
|
620
620
|
|
|
621
621
|
//#endregion
|
|
622
622
|
//#region src/config/config.ts
|
|
@@ -16,6 +16,13 @@
|
|
|
16
16
|
import type { Nullable } from '@univerjs/core';
|
|
17
17
|
import type { ISheetNote } from '@univerjs/sheets-note';
|
|
18
18
|
import { FRange } from '@univerjs/sheets/facade';
|
|
19
|
+
export interface ICreateOrUpdateNoteOptions {
|
|
20
|
+
id?: string;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
note: string;
|
|
24
|
+
show?: boolean;
|
|
25
|
+
}
|
|
19
26
|
/**
|
|
20
27
|
* @ignore
|
|
21
28
|
*/
|
|
@@ -36,7 +43,7 @@ export interface IFRangeSheetsNoteMixin {
|
|
|
36
43
|
getNote(): Nullable<ISheetNote>;
|
|
37
44
|
/**
|
|
38
45
|
* Create or update the annotation of the top-left cell in the range
|
|
39
|
-
* @param {
|
|
46
|
+
* @param {ICreateOrUpdateNoteOptions} note The annotation to create or update
|
|
40
47
|
* @returns {FRange} This range for method chaining
|
|
41
48
|
* @example
|
|
42
49
|
* ```ts
|
|
@@ -52,7 +59,7 @@ export interface IFRangeSheetsNoteMixin {
|
|
|
52
59
|
* });
|
|
53
60
|
* ```
|
|
54
61
|
*/
|
|
55
|
-
createOrUpdateNote(note:
|
|
62
|
+
createOrUpdateNote(note: ICreateOrUpdateNoteOptions): FRange;
|
|
56
63
|
/**
|
|
57
64
|
* Delete the annotation of the top-left cell in the range
|
|
58
65
|
* @returns {FRange} This range for method chaining
|
|
@@ -74,7 +81,7 @@ export interface IFRangeSheetsNoteMixin {
|
|
|
74
81
|
deleteNote(): FRange;
|
|
75
82
|
}
|
|
76
83
|
export declare class FRangeSheetsNoteMixin extends FRange implements IFRangeSheetsNoteMixin {
|
|
77
|
-
createOrUpdateNote(note:
|
|
84
|
+
createOrUpdateNote(note: ICreateOrUpdateNoteOptions): FRange;
|
|
78
85
|
deleteNote(): FRange;
|
|
79
86
|
getNote(): Nullable<ISheetNote>;
|
|
80
87
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/sheets")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core/facade`,`@univerjs/sheets-note`,`@univerjs/sheets/facade`,`@univerjs/core`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteFacade={},e.UniverCoreFacade,e.UniverSheetsNote,e.UniverSheetsFacade,e.UniverCore,e.UniverSheets))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=class extends t.FEventName{get SheetNoteAdd(){return`SheetNoteAdd`}get SheetNoteDelete(){return`SheetNoteDelete`}get SheetNoteUpdate(){return`SheetNoteUpdate`}get SheetNoteShow(){return`SheetNoteShow`}get SheetNoteHide(){return`SheetNoteHide`}get BeforeSheetNoteAdd(){return`BeforeSheetNoteAdd`}get BeforeSheetNoteDelete(){return`BeforeSheetNoteDelete`}get BeforeSheetNoteUpdate(){return`BeforeSheetNoteUpdate`}get BeforeSheetNoteShow(){return`BeforeSheetNoteShow`}get BeforeSheetNoteHide(){return`BeforeSheetNoteHide`}};t.FEventName.extend(o);var s=class extends r.FRange{createOrUpdateNote(e){return this._commandService.syncExecuteCommand(n.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:e}),this}deleteNote(){return this._commandService.syncExecuteCommand(n.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(n.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),{row:this.getRow(),col:this.getColumn()})}};r.FRange.extend(s);var c=class extends t.FUniver{_initialize(e){let t=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&!e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core/facade"),require("@univerjs/sheets-note"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/sheets")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core/facade`,`@univerjs/sheets-note`,`@univerjs/sheets/facade`,`@univerjs/core`,`@univerjs/sheets`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteFacade={},e.UniverCoreFacade,e.UniverSheetsNote,e.UniverSheetsFacade,e.UniverCore,e.UniverSheets))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=class extends t.FEventName{get SheetNoteAdd(){return`SheetNoteAdd`}get SheetNoteDelete(){return`SheetNoteDelete`}get SheetNoteUpdate(){return`SheetNoteUpdate`}get SheetNoteShow(){return`SheetNoteShow`}get SheetNoteHide(){return`SheetNoteHide`}get BeforeSheetNoteAdd(){return`BeforeSheetNoteAdd`}get BeforeSheetNoteDelete(){return`BeforeSheetNoteDelete`}get BeforeSheetNoteUpdate(){return`BeforeSheetNoteUpdate`}get BeforeSheetNoteShow(){return`BeforeSheetNoteShow`}get BeforeSheetNoteHide(){return`BeforeSheetNoteHide`}};t.FEventName.extend(o);var s=class extends r.FRange{createOrUpdateNote(e){return this._commandService.syncExecuteCommand(n.UpdateNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn(),note:e}),this}deleteNote(){return this._commandService.syncExecuteCommand(n.RemoveNoteMutation.id,{unitId:this.getUnitId(),sheetId:this.getSheetId(),row:this.getRow(),col:this.getColumn()}),this}getNote(){return this._injector.get(n.SheetsNoteModel).getNote(this.getUnitId(),this.getSheetId(),{row:this.getRow(),col:this.getColumn()})}};r.FRange.extend(s);var c=class extends t.FUniver{_initialize(e){let t=e.get(i.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteAdd,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&!e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col,note:r};this.fireEvent(this.Event.SheetNoteAdd,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteDelete,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&!e.newNote){let{unitId:t,subUnitId:n,oldNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col,oldNote:r};this.fireEvent(this.Event.SheetNoteDelete,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteUpdate,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote){let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!a)return;let{workbook:o,worksheet:s}=a,c={workbook:o,worksheet:s,row:i.row,col:i.col,note:i,oldNote:r};this.fireEvent(this.Event.SheetNoteUpdate,c)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteShow,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote&&!e.oldNote.show&&e.newNote.show){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col};this.fireEvent(this.Event.SheetNoteShow,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.SheetNoteHide,()=>e.get(n.SheetsNoteModel).change$.subscribe(e=>{if(e.type===`update`&&e.oldNote&&e.newNote&&e.oldNote.show&&!e.newNote.show){let{unitId:t,subUnitId:n,newNote:r}=e,i=this.getSheetCommandTarget({unitId:t,subUnitId:n});if(!i)return;let{workbook:a,worksheet:o}=i,s={workbook:a,worksheet:o,row:r.row,col:r.col};this.fireEvent(this.Event.SheetNoteHide,s)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetUpdateNoteCommand.id){let r=t.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=a,{row:u,col:d,note:f}=r;if(e.get(n.SheetsNoteModel).getNote(c,l,{noteId:f.id,row:u,col:d}))return;let p={workbook:o,worksheet:s,row:u,col:d,note:f};if(this.fireEvent(this.Event.BeforeSheetNoteAdd,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetDeleteNoteCommand.id){let t=this.getSheetCommandTarget();if(!t)return;let r=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(r!=null&&r.primary))return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=t,{actualRow:u,actualColumn:d}=r.primary,f=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!f)return;let p={workbook:o,worksheet:s,row:u,col:d,oldNote:f};if(this.fireEvent(this.Event.BeforeSheetNoteDelete,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetUpdateNoteCommand.id){let r=t.params,a=this.getSheetCommandTarget(r);if(!a)return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=a,{row:u,col:d,note:f}=r,p=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!p)return;let m={workbook:o,worksheet:s,row:u,col:d,note:f,oldNote:p};if(this.fireEvent(this.Event.BeforeSheetNoteUpdate,m))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteShow,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetToggleNotePopupCommand.id){let t=this.getSheetCommandTarget();if(!t)return;let r=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(r!=null&&r.primary))return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=t,{actualRow:u,actualColumn:d}=r.primary,f=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!f||f.show)return;let p={workbook:o,worksheet:s,row:u,col:d};if(this.fireEvent(this.Event.BeforeSheetNoteShow,p))throw new i.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteHide,()=>t.beforeCommandExecuted(t=>{if(t.id===n.SheetToggleNotePopupCommand.id){let t=this.getSheetCommandTarget();if(!t)return;let r=e.get(a.SheetsSelectionsService).getCurrentLastSelection();if(!(r!=null&&r.primary))return;let{workbook:o,worksheet:s,unitId:c,subUnitId:l}=t,{actualRow:u,actualColumn:d}=r.primary,f=e.get(n.SheetsNoteModel).getNote(c,l,{row:u,col:d});if(!f||!f.show)return;let p={workbook:o,worksheet:s,row:u,col:d};if(this.fireEvent(this.Event.BeforeSheetNoteHide,p))throw new i.CanceledError}})))}};t.FUniver.extend(c);var l=class extends r.FWorksheet{getNotes(){let e=this._injector.get(n.SheetsNoteModel).getSheetNotes(this.getWorkbook().getUnitId(),this.getSheetId());return e?Array.from(e.values()).map(e=>({...e})):[]}};r.FWorksheet.extend(l),e.FRangeSheetsNoteMixin=s,e.FSheetsNoteEventNameMixin=o,e.FUniverSheetsNoteMixin=c,e.FWorksheetNoteMixin=l});
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNote={},e.UniverCore,e.UniverSheets,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=class extends t.Disposable{constructor(...e){super(...e),s(this,`_notesMap`,new Map),s(this,`_change$`,new r.Subject),s(this,`change$`,this._change$.asObservable())}_ensureNotesMap(e,t){let n=this._notesMap.get(e);n||(n=new Map,this._notesMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_getNoteByPosition(e,t,n,r){let i=this._ensureNotesMap(e,t);for(let[e,t]of i)if(t.row===n&&t.col===r)return t}_getNoteById(e,t,n){return this._ensureNotesMap(e,t).get(n)}_getNoteByParams(e,t,n){let{noteId:r,row:i,col:a}=n;return r?this._getNoteById(e,t,r):i!==void 0&&a!==void 0?this._getNoteByPosition(e,t,i,a):null}getSheetShowNotes$(e,t){return this._change$.pipe((0,r.filter)(({unitId:n,subUnitId:r})=>n===e&&r===t),(0,r.map)(()=>{let n=this._ensureNotesMap(e,t),r=[];for(let[i,a]of n)a.show&&r.push({loc:{row:a.row,col:a.col,unitId:e,subUnitId:t},note:a});return r}))}getCellNoteChange$(e,t,n,i){return this._change$.pipe((0,r.filter)(({unitId:r,subUnitId:a,oldNote:o})=>r!==e||a!==t||!o?!1:o.row===n&&o.col===i),(0,r.map)(e=>e))}updateNote(e,n,r,i,a,o){let s=this._getNoteByParams(e,n,{noteId:a==null?void 0:a.id,row:r,col:i}),c=this._ensureNotesMap(e,n),l={...a,id:(s==null?void 0:s.id)||a.id||(0,t.generateRandomId)(6),row:r,col:i};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:n,oldNote:s,type:`update`,newNote:l,silent:o})}removeNote(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});s&&(this._ensureNotesMap(e,t).delete(s.id),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:null,silent:o}))}toggleNotePopup(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!s)return;let c=this._ensureNotesMap(e,t),l={...s,show:!s.show};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:l,silent:o})}updateNotePosition(e,t,n){let{noteId:r,row:i,col:a,newRow:o,newCol:s,silent:c}=n,l=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!l)return;let u=this._ensureNotesMap(e,t),d={...l,row:o,col:s};u.set(d.id,d),this._change$.next({unitId:e,subUnitId:t,oldNote:l,type:`ref`,newNote:d,silent:c})}getNote(e,t,n){return this._getNoteByParams(e,t,n)}getNotes(){return this._notesMap}getUnitNotes(e){return this._notesMap.get(e)}getSheetNotes(e,t){let n=this._notesMap.get(e);if(n)return n.get(t)}deleteUnitNotes(e){this._notesMap.delete(e)}};let l={id:`sheet.mutation.update-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,row:i,col:a,note:o,silent:s}=t;return e.get(c).updateNote(n,r,i,a,o,s),!0}},u={id:`sheet.mutation.remove-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).removeNote(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},d={id:`sheet.mutation.toggle-note-popup`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).toggleNotePopup(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},f={id:`sheet.mutation.update-note-position`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,newPosition:s,silent:l}=t;return e.get(c).updateNotePosition(n,r,{noteId:i,row:a,col:o,newRow:s.row,newCol:s.col,silent:l}),!0}},p={id:`sheet.command.delete-note`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:d,actualRow:f}=i.primary,p=a.getNote(o,s,{row:f,col:d});if(!p)return!1;let m=e.get(t.ICommandService),h=e.get(t.IUndoRedoService),g={id:u.id,params:{unitId:o,sheetId:s,noteId:p.id}},_={id:l.id,params:{unitId:o,sheetId:s,row:f,col:d,note:{...p}}};return m.syncExecuteCommand(g.id,g.params)?(h.pushUndoRedo({unitID:o,redoMutations:[g],undoMutations:[_]}),!0):!1}},m={id:`sheet.command.toggle-note-popup`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:l,actualRow:u}=i.primary,f=a.getNote(o,s,{row:u,col:l});if(!f)return!1;let p=e.get(t.ICommandService),m=e.get(t.IUndoRedoService),h={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}},g={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}};return p.syncExecuteCommand(h.id,h.params)?(m.pushUndoRedo({unitID:o,redoMutations:[h],undoMutations:[g]}),!0):!1}},h={id:`sheet.command.update-note`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(c),{unitId:d,subUnitId:f}=i,{row:p,col:m,note:h}=r,g=s.getNote(d,f,{noteId:h.id,row:p,col:m}),_={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:h}},v=[];if(g){let e={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:{...g}}};v.push(e)}else{let e={id:u.id,params:{unitId:d,sheetId:f,row:p,col:m}};v.push(e)}return a.syncExecuteCommand(_.id,_.params)?(o.pushUndoRedo({unitID:d,redoMutations:[_],undoMutations:v}),!0):!1}},g=`SHEET_NOTE_PLUGIN`;function _(e,t){return function(n,r){t(n,r,e)}}function v(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let y=class extends t.Disposable{constructor(e,t,n,r){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._sheetsNoteModel=r,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){let e=e=>{let t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return``;let n={};return t.forEach((e,t)=>{let r={};e.forEach(e=>{let{row:t,col:n}=e;r[t]||(r[t]={}),r[t][n]=e}),Object.keys(r).length>0&&(n[t]=r)}),JSON.stringify(n)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:g,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([t,n])=>{Object.entries(n).forEach(([n,r])=>{Object.entries(r).forEach(([r,i])=>{this._sheetsNoteModel.updateNote(e,t,Number(n),Number(r),i)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===n.RemoveSheetCommand.id){var r;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetsNoteModel.getSheetNotes(i,a);if(!o)return{redos:[],undos:[]};let s=[],c=[];return o.forEach(e=>{s.push({id:u.id,params:{unitId:i,sheetId:a,noteId:e.id,row:e.row,col:e.col}}),c.push({id:l.id,params:{unitId:i,sheetId:a,row:e.row,col:e.col,note:e}})}),{redos:s,undos:c}}else if(e.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetsNoteModel.getSheetNotes(n,r);if(!a)return{redos:[],undos:[]};let o=[],s=[];return a.forEach(e=>{let r={...e,id:(0,t.generateRandomId)(6)};o.push({id:l.id,params:{unitId:n,sheetId:i,row:r.row,col:r.col,note:r}}),s.push({id:u.id,params:{unitId:n,sheetId:i,noteId:r.id,row:r.row,col:r.col}})}),{redos:o,undos:s}}return{redos:[],undos:[]}}}))}};y=v([_(0,t.IResourceManagerService),_(1,t.IUniverInstanceService),_(2,(0,t.Inject)(n.SheetInterceptorService)),_(3,(0,t.Inject)(c))],y);var b=`@univerjs/sheets-note`,x=`0.25.1`;let S={},C=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._sheetsNoteModel=t,this._selectionManagerService=n,this._commandService=r,s(this,`_disposableMap`,new Map),s(this,`_watcherMap`,new Map),s(this,`_handleRangeChange`,(e,t,n,r,i,a,o)=>a?{redos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:a.startRow,col:a.startColumn},silent:o}}],undos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:r,col:i},note:n,silent:o}}]}:{redos:[{id:u.id,params:{unitId:e,sheetId:t,noteId:n.id}}],undos:[{id:l.id,params:{unitId:e,sheetId:t,row:r,col:i,note:n}}]}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n,r){return`${e}-${t}-${n}-${r}`}_register(e,t,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._disposableMap.set(this._getIdWithUnitId(e,t,i,a),this._refRangeService.registerRefRange(o,s=>{let c=(0,n.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(o,s,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===o.startColumn&&l.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,r,i,a,l,!1)},e,t))}_watch(e,n,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._watcherMap.set(this._getIdWithUnitId(e,n,i,a),this._refRangeService.watchRange(e,n,o,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,i.startRow,i.startColumn,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._watcherMap.get(a))==null||i.dispose(),this._watcherMap.delete(a)}_unregister(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._disposableMap.get(a))==null||i.dispose(),this._disposableMap.delete(a)}_initData(){let e=this._sheetsNoteModel.getNotes();for(let[t,n]of e)for(let[e,r]of n)r.forEach(n=>{this._register(t,e,n,n.row,n.col),this._watch(t,e,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{switch(e.type){case`update`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=i?i.row:r.row,o=i?i.col:r.col,s=this._getIdWithUnitId(t,n,a,o);i?this._disposableMap.has(s)||(this._register(t,n,i,a,o),this._watch(t,n,i,a,o)):(this._unregister(t,n,a,o),this._unwatch(t,n,a,o));break}case`ref`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i,silent:a}=e,{row:o,col:s}=r,{row:c,col:l}=i;this._unregister(t,n,o,s),a||(this._unwatch(t,n,o,s),this._watch(t,n,i,c,l)),this._register(t,n,i,c,l);break}}}))}};C=v([_(0,(0,t.Inject)(n.RefRangeService)),_(1,(0,t.Inject)(c)),_(2,(0,t.Inject)(n.SheetsSelectionsService)),_(3,t.ICommandService)],C);let w=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._initialize()}_initialize(){[f,d,l,u,p,m,h].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}};w=v([_(0,t.ICommandService)],w);let T=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._configService=n,this._injector=r;let{...i}=(0,t.merge)({},S,this._config);this._configService.setConfig(`sheets-note.config`,i)}onStarting(){[[c],[w],[y],[C]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[c],[w],[y]])}onReady(){(0,t.touchDependencies)(this._injector,[[C]])}};s(T,`pluginName`,g),s(T,`packageName`,b),s(T,`version`,x),s(T,`type`,t.UniverInstanceType.UNIVER_SHEET),T=v([(0,t.DependentOn)(n.UniverSheetsPlugin),_(1,t.IConfigService),_(2,(0,t.Inject)(t.Injector))],T),e.RemoveNoteMutation=u,e.SheetDeleteNoteCommand=p,e.SheetToggleNotePopupCommand=m,e.SheetUpdateNoteCommand=h,e.SheetsNoteModel=c,Object.defineProperty(e,"SheetsNoteResourceController",{enumerable:!0,get:function(){return y}}),e.ToggleNotePopupMutation=d,Object.defineProperty(e,"UniverSheetsNotePlugin",{enumerable:!0,get:function(){return T}}),e.UpdateNoteMutation=l,e.UpdateNotePositionMutation=f});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNote={},e.UniverCore,e.UniverSheets,e.rxjs))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=class extends t.Disposable{constructor(...e){super(...e),s(this,`_notesMap`,new Map),s(this,`_change$`,new r.Subject),s(this,`change$`,this._change$.asObservable())}_ensureNotesMap(e,t){let n=this._notesMap.get(e);n||(n=new Map,this._notesMap.set(e,n));let r=n.get(t);return r||(r=new Map,n.set(t,r)),r}_getNoteByPosition(e,t,n,r){let i=this._ensureNotesMap(e,t);for(let[e,t]of i)if(t.row===n&&t.col===r)return t}_getNoteById(e,t,n){return this._ensureNotesMap(e,t).get(n)}_getNoteByParams(e,t,n){let{noteId:r,row:i,col:a}=n;return r?this._getNoteById(e,t,r):i!==void 0&&a!==void 0?this._getNoteByPosition(e,t,i,a):null}getSheetShowNotes$(e,t){return this._change$.pipe((0,r.filter)(({unitId:n,subUnitId:r})=>n===e&&r===t),(0,r.map)(()=>{let n=this._ensureNotesMap(e,t),r=[];for(let[i,a]of n)a.show&&r.push({loc:{row:a.row,col:a.col,unitId:e,subUnitId:t},note:a});return r}))}getCellNoteChange$(e,t,n,i){return this._change$.pipe((0,r.filter)(({unitId:r,subUnitId:a,oldNote:o})=>r!==e||a!==t||!o?!1:o.row===n&&o.col===i),(0,r.map)(e=>e))}updateNote(e,n,r,i,a,o){let s=this._getNoteByParams(e,n,{noteId:a==null?void 0:a.id,row:r,col:i}),c=this._ensureNotesMap(e,n),l={...a,id:(s==null?void 0:s.id)||a.id||(0,t.generateRandomId)(6),row:r,col:i};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:n,oldNote:s,type:`update`,newNote:l,silent:o})}removeNote(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});s&&(this._ensureNotesMap(e,t).delete(s.id),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:null,silent:o}))}toggleNotePopup(e,t,n){let{noteId:r,row:i,col:a,silent:o}=n,s=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!s)return;let c=this._ensureNotesMap(e,t),l={...s,show:!s.show};c.set(l.id,l),this._change$.next({unitId:e,subUnitId:t,oldNote:s,type:`update`,newNote:l,silent:o})}updateNotePosition(e,t,n){let{noteId:r,row:i,col:a,newRow:o,newCol:s,silent:c}=n,l=this._getNoteByParams(e,t,{noteId:r,row:i,col:a});if(!l)return;let u=this._ensureNotesMap(e,t),d={...l,row:o,col:s};u.set(d.id,d),this._change$.next({unitId:e,subUnitId:t,oldNote:l,type:`ref`,newNote:d,silent:c})}getNote(e,t,n){return this._getNoteByParams(e,t,n)}getNotes(){return this._notesMap}getUnitNotes(e){return this._notesMap.get(e)}getSheetNotes(e,t){let n=this._notesMap.get(e);if(n)return n.get(t)}deleteUnitNotes(e){this._notesMap.delete(e)}};let l={id:`sheet.mutation.update-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,row:i,col:a,note:o,silent:s}=t;return e.get(c).updateNote(n,r,i,a,o,s),!0}},u={id:`sheet.mutation.remove-note`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).removeNote(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},d={id:`sheet.mutation.toggle-note-popup`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,silent:s}=t;return e.get(c).toggleNotePopup(n,r,{noteId:i,row:a,col:o,silent:s}),!0}},f={id:`sheet.mutation.update-note-position`,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,sheetId:r,noteId:i,row:a,col:o,newPosition:s,silent:l}=t;return e.get(c).updateNotePosition(n,r,{noteId:i,row:a,col:o,newRow:s.row,newCol:s.col,silent:l}),!0}},p={id:`sheet.command.delete-note`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:d,actualRow:f}=i.primary,p=a.getNote(o,s,{row:f,col:d});if(!p)return!1;let m=e.get(t.ICommandService),h=e.get(t.IUndoRedoService),g={id:u.id,params:{unitId:o,sheetId:s,noteId:p.id}},_={id:l.id,params:{unitId:o,sheetId:s,row:f,col:d,note:{...p}}};return m.syncExecuteCommand(g.id,g.params)?(h.pushUndoRedo({unitID:o,redoMutations:[g],undoMutations:[_]}),!0):!1}},m={id:`sheet.command.toggle-note-popup`,type:t.CommandType.COMMAND,handler:e=>{let r=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!r)return!1;let i=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!(i!=null&&i.primary))return!1;let a=e.get(c),{unitId:o,subUnitId:s}=r,{actualColumn:l,actualRow:u}=i.primary,f=a.getNote(o,s,{row:u,col:l});if(!f)return!1;let p=e.get(t.ICommandService),m=e.get(t.IUndoRedoService),h={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}},g={id:d.id,params:{unitId:o,sheetId:s,noteId:f.id}};return p.syncExecuteCommand(h.id,h.params)?(m.pushUndoRedo({unitID:o,redoMutations:[h],undoMutations:[g]}),!0):!1}},h={id:`sheet.command.update-note`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(c),{unitId:d,subUnitId:f}=i,{row:p,col:m,note:h}=r,g=s.getNote(d,f,{noteId:h.id,row:p,col:m}),_={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:h}},v=[];if(g){let e={id:l.id,params:{unitId:d,sheetId:f,row:p,col:m,note:{...g}}};v.push(e)}else{let e={id:u.id,params:{unitId:d,sheetId:f,row:p,col:m}};v.push(e)}return a.syncExecuteCommand(_.id,_.params)?(o.pushUndoRedo({unitID:d,redoMutations:[_],undoMutations:v}),!0):!1}},g=`SHEET_NOTE_PLUGIN`;function _(e,t){return function(n,r){t(n,r,e)}}function v(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let y=class extends t.Disposable{constructor(e,t,n,r){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._sheetsNoteModel=r,this._initSnapshot(),this._initSheetChange()}_initSnapshot(){let e=e=>{let t=this._sheetsNoteModel.getUnitNotes(e);if(!t)return``;let n={};return t.forEach((e,t)=>{let r={};e.forEach(e=>{let{row:t,col:n}=e;r[t]||(r[t]={}),r[t][n]=e}),Object.keys(r).length>0&&(n[t]=r)}),JSON.stringify(n)},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:g,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._sheetsNoteModel.deleteUnitNotes(e)},onLoad:(e,t)=>{Object.entries(t).forEach(([t,n])=>{Object.entries(n).forEach(([n,r])=>{Object.entries(r).forEach(([r,i])=>{this._sheetsNoteModel.updateNote(e,t,Number(n),Number(r),i)})})})}}))}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===n.RemoveSheetCommand.id){var r;let n=e.params,i=n.unitId||this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=n.subUnitId||((r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:r.getSheetId());if(!i||!a)return{redos:[],undos:[]};let o=this._sheetsNoteModel.getSheetNotes(i,a);if(!o)return{redos:[],undos:[]};let s=[],c=[];return o.forEach(e=>{s.push({id:u.id,params:{unitId:i,sheetId:a,noteId:e.id,row:e.row,col:e.col}}),c.push({id:l.id,params:{unitId:i,sheetId:a,row:e.row,col:e.col,note:e}})}),{redos:s,undos:c}}else if(e.id===n.CopySheetCommand.id){let{unitId:n,subUnitId:r,targetSubUnitId:i}=e.params;if(!n||!r||!i)return{redos:[],undos:[]};let a=this._sheetsNoteModel.getSheetNotes(n,r);if(!a)return{redos:[],undos:[]};let o=[],s=[];return a.forEach(e=>{let r={...e,id:(0,t.generateRandomId)(6)};o.push({id:l.id,params:{unitId:n,sheetId:i,row:r.row,col:r.col,note:r}}),s.push({id:u.id,params:{unitId:n,sheetId:i,noteId:r.id,row:r.row,col:r.col}})}),{redos:o,undos:s}}return{redos:[],undos:[]}}}))}};y=v([_(0,t.IResourceManagerService),_(1,t.IUniverInstanceService),_(2,(0,t.Inject)(n.SheetInterceptorService)),_(3,(0,t.Inject)(c))],y);var b=`@univerjs/sheets-note`,x=`1.0.0-alpha.1`;let S={},C=class extends t.Disposable{constructor(e,t,n,r){super(),this._refRangeService=e,this._sheetsNoteModel=t,this._selectionManagerService=n,this._commandService=r,s(this,`_disposableMap`,new Map),s(this,`_watcherMap`,new Map),s(this,`_handleRangeChange`,(e,t,n,r,i,a,o)=>a?{redos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:a.startRow,col:a.startColumn},silent:o}}],undos:[{id:f.id,params:{unitId:e,sheetId:t,noteId:n.id,newPosition:{row:r,col:i},note:n,silent:o}}]}:{redos:[{id:u.id,params:{unitId:e,sheetId:t,noteId:n.id}}],undos:[{id:l.id,params:{unitId:e,sheetId:t,row:r,col:i,note:n}}]}),this._initData(),this._initRefRange()}_getIdWithUnitId(e,t,n,r){return`${e}-${t}-${n}-${r}`}_register(e,t,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._disposableMap.set(this._getIdWithUnitId(e,t,i,a),this._refRangeService.registerRefRange(o,s=>{let c=(0,n.handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests)(o,s,{selectionManagerService:this._selectionManagerService}),l=Array.isArray(c)?c[0]:c;return l&&l.startColumn===o.startColumn&&l.startRow===o.startRow?{undos:[],redos:[]}:this._handleRangeChange(e,t,r,i,a,l,!1)},e,t))}_watch(e,n,r,i,a){let o={startColumn:a,endColumn:a,startRow:i,endRow:i};this._watcherMap.set(this._getIdWithUnitId(e,n,i,a),this._refRangeService.watchRange(e,n,o,(i,a)=>{let{redos:o}=this._handleRangeChange(e,n,r,i.startRow,i.startColumn,a,!0);(0,t.sequenceExecuteAsync)(o,this._commandService,{onlyLocal:!0})},!0))}_unwatch(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._watcherMap.get(a))==null||i.dispose(),this._watcherMap.delete(a)}_unregister(e,t,n,r){var i;let a=this._getIdWithUnitId(e,t,n,r);(i=this._disposableMap.get(a))==null||i.dispose(),this._disposableMap.delete(a)}_initData(){let e=this._sheetsNoteModel.getNotes();for(let[t,n]of e)for(let[e,r]of n)r.forEach(n=>{this._register(t,e,n,n.row,n.col),this._watch(t,e,n,n.row,n.col)})}_initRefRange(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{switch(e.type){case`update`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i}=e,a=i?i.row:r.row,o=i?i.col:r.col,s=this._getIdWithUnitId(t,n,a,o);i?this._disposableMap.has(s)||(this._register(t,n,i,a,o),this._watch(t,n,i,a,o)):(this._unregister(t,n,a,o),this._unwatch(t,n,a,o));break}case`ref`:{let{unitId:t,subUnitId:n,oldNote:r,newNote:i,silent:a}=e,{row:o,col:s}=r,{row:c,col:l}=i;this._unregister(t,n,o,s),a||(this._unwatch(t,n,o,s),this._watch(t,n,i,c,l)),this._register(t,n,i,c,l);break}}}))}};C=v([_(0,(0,t.Inject)(n.RefRangeService)),_(1,(0,t.Inject)(c)),_(2,(0,t.Inject)(n.SheetsSelectionsService)),_(3,t.ICommandService)],C);let w=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._initialize()}_initialize(){[f,d,l,u,p,m,h].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}};w=v([_(0,t.ICommandService)],w);let T=class extends t.Plugin{constructor(e=S,n,r){super(),this._config=e,this._configService=n,this._injector=r;let{...i}=(0,t.merge)({},S,this._config);this._configService.setConfig(`sheets-note.config`,i)}onStarting(){[[c],[w],[y],[C]].forEach(e=>{this._injector.add(e)}),(0,t.touchDependencies)(this._injector,[[c],[w],[y]])}onReady(){(0,t.touchDependencies)(this._injector,[[C]])}};s(T,`pluginName`,g),s(T,`packageName`,b),s(T,`version`,x),s(T,`type`,t.UniverInstanceType.UNIVER_SHEET),T=v([(0,t.DependentOn)(n.UniverSheetsPlugin),_(1,t.IConfigService),_(2,(0,t.Inject)(t.Injector))],T),e.RemoveNoteMutation=u,e.SheetDeleteNoteCommand=p,e.SheetToggleNotePopupCommand=m,e.SheetUpdateNoteCommand=h,e.SheetsNoteModel=c,Object.defineProperty(e,"SheetsNoteResourceController",{enumerable:!0,get:function(){return y}}),e.ToggleNotePopupMutation=d,Object.defineProperty(e,"UniverSheetsNotePlugin",{enumerable:!0,get:function(){return T}}),e.UpdateNoteMutation=l,e.UpdateNotePositionMutation=f});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Cell note model and commands for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
"rxjs": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/
|
|
65
|
+
"@univerjs/sheets": "1.0.0-alpha.1",
|
|
66
|
+
"@univerjs/core": "1.0.0-alpha.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"rxjs": "^7.8.2",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
|
-
"vitest": "^4.1.
|
|
72
|
-
"@univerjs/
|
|
73
|
-
"@univerjs-
|
|
74
|
-
"@univerjs/engine-render": "0.
|
|
75
|
-
"@univerjs/network": "0.
|
|
71
|
+
"vitest": "^4.1.9",
|
|
72
|
+
"@univerjs-infra/shared": "1.0.0-alpha.1",
|
|
73
|
+
"@univerjs/engine-formula": "1.0.0-alpha.1",
|
|
74
|
+
"@univerjs/engine-render": "1.0.0-alpha.1",
|
|
75
|
+
"@univerjs/network": "1.0.0-alpha.1"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|