@univerjs/sheets-note-ui 1.0.0-beta.1 → 1.0.0-beta.2
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/index.js +145 -112
- package/lib/es/index.js +140 -113
- package/lib/index.js +140 -113
- package/lib/types/controllers/sheets-note-attachment.controller.d.ts +7 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -219,6 +219,144 @@ let SheetsNotePopupService = class SheetsNotePopupService extends _univerjs_core
|
|
|
219
219
|
};
|
|
220
220
|
SheetsNotePopupService = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellPopupManagerService))], SheetsNotePopupService);
|
|
221
221
|
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
224
|
+
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends _univerjs_core.Disposable {
|
|
225
|
+
constructor(_sheetsNoteModel, _univerInstanceService, _cellPopupManagerService, _sheetsNotePopupService) {
|
|
226
|
+
super();
|
|
227
|
+
this._sheetsNoteModel = _sheetsNoteModel;
|
|
228
|
+
this._univerInstanceService = _univerInstanceService;
|
|
229
|
+
this._cellPopupManagerService = _cellPopupManagerService;
|
|
230
|
+
this._sheetsNotePopupService = _sheetsNotePopupService;
|
|
231
|
+
_defineProperty(this, "_noteMatrix", new _univerjs_core.ObjectMatrix());
|
|
232
|
+
_defineProperty(this, "_suppressedUnitIds", /* @__PURE__ */ new Set());
|
|
233
|
+
_defineProperty(this, "_activeUnitId", null);
|
|
234
|
+
_defineProperty(this, "_activeSheetId", null);
|
|
235
|
+
_defineProperty(this, "_noteChangeSubscription", null);
|
|
236
|
+
this._initNoteChangeListener();
|
|
237
|
+
}
|
|
238
|
+
_showPopup(unitId, sheetId, row, col) {
|
|
239
|
+
this._sheetsNotePopupService.hidePopup(true);
|
|
240
|
+
return this._cellPopupManagerService.showPopup({
|
|
241
|
+
unitId,
|
|
242
|
+
subUnitId: sheetId,
|
|
243
|
+
row,
|
|
244
|
+
col
|
|
245
|
+
}, {
|
|
246
|
+
componentKey: SHEET_NOTE_COMPONENT,
|
|
247
|
+
direction: "horizontal",
|
|
248
|
+
extraProps: { location: {
|
|
249
|
+
unitId,
|
|
250
|
+
subUnitId: sheetId,
|
|
251
|
+
row,
|
|
252
|
+
col
|
|
253
|
+
} },
|
|
254
|
+
priority: 3
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
dispose() {
|
|
258
|
+
var _this$_noteChangeSubs;
|
|
259
|
+
super.dispose();
|
|
260
|
+
this._clearNoteMatrix();
|
|
261
|
+
this._suppressedUnitIds.clear();
|
|
262
|
+
this._activeUnitId = null;
|
|
263
|
+
this._activeSheetId = null;
|
|
264
|
+
(_this$_noteChangeSubs = this._noteChangeSubscription) === null || _this$_noteChangeSubs === void 0 || _this$_noteChangeSubs.unsubscribe();
|
|
265
|
+
this._noteChangeSubscription = null;
|
|
266
|
+
}
|
|
267
|
+
setPopupSuppressed(unitId, suppressed) {
|
|
268
|
+
if (suppressed) this._suppressedUnitIds.add(unitId);
|
|
269
|
+
else this._suppressedUnitIds.delete(unitId);
|
|
270
|
+
if (unitId !== this._activeUnitId || !this._activeSheetId) return;
|
|
271
|
+
if (suppressed) this._clearNoteMatrix();
|
|
272
|
+
else this._showPersistentNotes(unitId, this._activeSheetId);
|
|
273
|
+
}
|
|
274
|
+
_initSheet(targetUnitId, targetSheetId) {
|
|
275
|
+
this._clearNoteMatrix();
|
|
276
|
+
this._activeUnitId = targetUnitId;
|
|
277
|
+
this._activeSheetId = targetSheetId;
|
|
278
|
+
const handleNote = (unitId, sheetId, row, col, note) => {
|
|
279
|
+
const matrix = this._noteMatrix;
|
|
280
|
+
const disposable = matrix.getValue(row, col);
|
|
281
|
+
if (note === null || note === void 0 ? void 0 : note.show) {
|
|
282
|
+
if (this._suppressedUnitIds.has(unitId)) {
|
|
283
|
+
disposable === null || disposable === void 0 || disposable.dispose();
|
|
284
|
+
matrix.realDeleteValue(row, col);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (!disposable) {
|
|
288
|
+
const newDisposable = this._showPopup(unitId, sheetId, row, col);
|
|
289
|
+
if (newDisposable) matrix.setValue(row, col, newDisposable);
|
|
290
|
+
}
|
|
291
|
+
} else if (disposable) {
|
|
292
|
+
disposable.dispose();
|
|
293
|
+
matrix.realDeleteValue(row, col);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
if (!this._suppressedUnitIds.has(targetUnitId)) this._showPersistentNotes(targetUnitId, targetSheetId);
|
|
297
|
+
return this._sheetsNoteModel.change$.subscribe((change) => {
|
|
298
|
+
if (change.unitId !== targetUnitId || change.subUnitId !== targetSheetId) return;
|
|
299
|
+
switch (change.type) {
|
|
300
|
+
case "ref": {
|
|
301
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
302
|
+
if (!newNote.show) return;
|
|
303
|
+
const matrix = this._noteMatrix;
|
|
304
|
+
const { row: oldRow, col: oldCol } = oldNote;
|
|
305
|
+
const { row: newRow, col: newCol } = newNote;
|
|
306
|
+
const disposable = matrix.getValue(oldRow, oldCol);
|
|
307
|
+
if (disposable) {
|
|
308
|
+
disposable.dispose();
|
|
309
|
+
matrix.realDeleteValue(oldRow, oldCol);
|
|
310
|
+
}
|
|
311
|
+
handleNote(unitId, subUnitId, newRow, newCol, newNote);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case "update": {
|
|
315
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
316
|
+
const row = newNote ? newNote.row : oldNote.row;
|
|
317
|
+
const col = newNote ? newNote.col : oldNote.col;
|
|
318
|
+
handleNote(unitId, subUnitId, row, col, newNote);
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
default: break;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
_initNoteChangeListener() {
|
|
326
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null))).subscribe((sheet) => {
|
|
327
|
+
var _this$_noteChangeSubs2;
|
|
328
|
+
(_this$_noteChangeSubs2 = this._noteChangeSubscription) === null || _this$_noteChangeSubs2 === void 0 || _this$_noteChangeSubs2.unsubscribe();
|
|
329
|
+
this._noteChangeSubscription = null;
|
|
330
|
+
if (sheet) this._noteChangeSubscription = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
331
|
+
else {
|
|
332
|
+
this._clearNoteMatrix();
|
|
333
|
+
this._activeUnitId = null;
|
|
334
|
+
this._activeSheetId = null;
|
|
335
|
+
}
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
_showPersistentNotes(unitId, sheetId) {
|
|
339
|
+
var _this$_sheetsNoteMode;
|
|
340
|
+
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(unitId, sheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
341
|
+
if (!note.show || this._noteMatrix.getValue(note.row, note.col)) return;
|
|
342
|
+
const disposable = this._showPopup(unitId, sheetId, note.row, note.col);
|
|
343
|
+
if (disposable) this._noteMatrix.setValue(note.row, note.col, disposable);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
_clearNoteMatrix() {
|
|
347
|
+
this._noteMatrix.forValue((_, __, disposable) => {
|
|
348
|
+
disposable.dispose();
|
|
349
|
+
});
|
|
350
|
+
this._noteMatrix = new _univerjs_core.ObjectMatrix();
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
SheetsNoteAttachmentController = __decorate([
|
|
354
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_note.SheetsNoteModel)),
|
|
355
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
356
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellPopupManagerService)),
|
|
357
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(SheetsNotePopupService))
|
|
358
|
+
], SheetsNoteAttachmentController);
|
|
359
|
+
|
|
222
360
|
//#endregion
|
|
223
361
|
//#region src/controllers/sheets-note-popup.controller.ts
|
|
224
362
|
let SheetsNotePopupController = class SheetsNotePopupController extends _univerjs_core.Disposable {
|
|
@@ -436,7 +574,7 @@ const menuSchema = { [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_
|
|
|
436
574
|
//#endregion
|
|
437
575
|
//#region package.json
|
|
438
576
|
var name = "@univerjs/sheets-note-ui";
|
|
439
|
-
var version = "1.0.0-beta.
|
|
577
|
+
var version = "1.0.0-beta.2";
|
|
440
578
|
|
|
441
579
|
//#endregion
|
|
442
580
|
//#region src/config/config.ts
|
|
@@ -604,117 +742,6 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
604
742
|
};
|
|
605
743
|
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
606
744
|
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
609
|
-
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends _univerjs_core.Disposable {
|
|
610
|
-
constructor(_sheetsNoteModel, _univerInstanceService, _cellPopupManagerService, _sheetsNotePopupService) {
|
|
611
|
-
super();
|
|
612
|
-
this._sheetsNoteModel = _sheetsNoteModel;
|
|
613
|
-
this._univerInstanceService = _univerInstanceService;
|
|
614
|
-
this._cellPopupManagerService = _cellPopupManagerService;
|
|
615
|
-
this._sheetsNotePopupService = _sheetsNotePopupService;
|
|
616
|
-
_defineProperty(this, "_noteMatrix", new _univerjs_core.ObjectMatrix());
|
|
617
|
-
this._initNoteChangeListener();
|
|
618
|
-
}
|
|
619
|
-
_showPopup(unitId, sheetId, row, col) {
|
|
620
|
-
this._sheetsNotePopupService.hidePopup(true);
|
|
621
|
-
return this._cellPopupManagerService.showPopup({
|
|
622
|
-
unitId,
|
|
623
|
-
subUnitId: sheetId,
|
|
624
|
-
row,
|
|
625
|
-
col
|
|
626
|
-
}, {
|
|
627
|
-
componentKey: SHEET_NOTE_COMPONENT,
|
|
628
|
-
direction: "horizontal",
|
|
629
|
-
extraProps: { location: {
|
|
630
|
-
unitId,
|
|
631
|
-
subUnitId: sheetId,
|
|
632
|
-
row,
|
|
633
|
-
col
|
|
634
|
-
} },
|
|
635
|
-
priority: 3
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
dispose() {
|
|
639
|
-
super.dispose();
|
|
640
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
641
|
-
disposable.dispose();
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
_initSheet(targetUnitId, targetSheetId) {
|
|
645
|
-
var _this$_sheetsNoteMode;
|
|
646
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
647
|
-
disposable.dispose();
|
|
648
|
-
});
|
|
649
|
-
this._noteMatrix = new _univerjs_core.ObjectMatrix();
|
|
650
|
-
const handleNote = (unitId, sheetId, row, col, note) => {
|
|
651
|
-
const matrix = this._noteMatrix;
|
|
652
|
-
const disposable = matrix.getValue(row, col);
|
|
653
|
-
if (note === null || note === void 0 ? void 0 : note.show) {
|
|
654
|
-
if (!disposable) {
|
|
655
|
-
const newDisposable = this._showPopup(unitId, sheetId, row, col);
|
|
656
|
-
if (newDisposable) matrix.setValue(row, col, newDisposable);
|
|
657
|
-
}
|
|
658
|
-
} else if (disposable) {
|
|
659
|
-
disposable.dispose();
|
|
660
|
-
matrix.realDeleteValue(row, col);
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(targetUnitId, targetSheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
664
|
-
handleNote(targetUnitId, targetSheetId, note.row, note.col, note);
|
|
665
|
-
});
|
|
666
|
-
return this._sheetsNoteModel.change$.subscribe((change) => {
|
|
667
|
-
if (change.unitId !== targetUnitId || change.subUnitId !== targetSheetId) return;
|
|
668
|
-
switch (change.type) {
|
|
669
|
-
case "ref": {
|
|
670
|
-
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
671
|
-
if (!newNote.show) return;
|
|
672
|
-
const matrix = this._noteMatrix;
|
|
673
|
-
const { row: oldRow, col: oldCol } = oldNote;
|
|
674
|
-
const { row: newRow, col: newCol } = newNote;
|
|
675
|
-
const disposable = matrix.getValue(oldRow, oldCol);
|
|
676
|
-
if (disposable) {
|
|
677
|
-
disposable.dispose();
|
|
678
|
-
matrix.realDeleteValue(oldRow, oldCol);
|
|
679
|
-
}
|
|
680
|
-
const newDisposable = this._showPopup(unitId, subUnitId, newRow, newCol);
|
|
681
|
-
if (newDisposable) matrix.setValue(newRow, newCol, newDisposable);
|
|
682
|
-
break;
|
|
683
|
-
}
|
|
684
|
-
case "update": {
|
|
685
|
-
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
686
|
-
const row = newNote ? newNote.row : oldNote.row;
|
|
687
|
-
const col = newNote ? newNote.col : oldNote.col;
|
|
688
|
-
handleNote(unitId, subUnitId, row, col, newNote);
|
|
689
|
-
break;
|
|
690
|
-
}
|
|
691
|
-
default: break;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
_initNoteChangeListener() {
|
|
696
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null))).subscribe((sheet) => {
|
|
697
|
-
if (sheet) {
|
|
698
|
-
const disposable = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
699
|
-
return () => {
|
|
700
|
-
disposable.unsubscribe();
|
|
701
|
-
};
|
|
702
|
-
} else {
|
|
703
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
704
|
-
disposable.dispose();
|
|
705
|
-
});
|
|
706
|
-
this._noteMatrix = new _univerjs_core.ObjectMatrix();
|
|
707
|
-
}
|
|
708
|
-
}));
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
SheetsNoteAttachmentController = __decorate([
|
|
712
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_note.SheetsNoteModel)),
|
|
713
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
714
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellPopupManagerService)),
|
|
715
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(SheetsNotePopupService))
|
|
716
|
-
], SheetsNoteAttachmentController);
|
|
717
|
-
|
|
718
745
|
//#endregion
|
|
719
746
|
//#region src/controllers/ui.controller.ts
|
|
720
747
|
/**
|
|
@@ -798,6 +825,12 @@ Object.defineProperty(exports, 'SheetsCellContentController', {
|
|
|
798
825
|
return SheetsCellContentController;
|
|
799
826
|
}
|
|
800
827
|
});
|
|
828
|
+
Object.defineProperty(exports, 'SheetsNoteAttachmentController', {
|
|
829
|
+
enumerable: true,
|
|
830
|
+
get: function () {
|
|
831
|
+
return SheetsNoteAttachmentController;
|
|
832
|
+
}
|
|
833
|
+
});
|
|
801
834
|
Object.defineProperty(exports, 'SheetsNotePopupController', {
|
|
802
835
|
enumerable: true,
|
|
803
836
|
get: function () {
|
package/lib/es/index.js
CHANGED
|
@@ -218,6 +218,144 @@ let SheetsNotePopupService = class SheetsNotePopupService extends Disposable {
|
|
|
218
218
|
};
|
|
219
219
|
SheetsNotePopupService = __decorate([__decorateParam(0, Inject(CellPopupManagerService))], SheetsNotePopupService);
|
|
220
220
|
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
223
|
+
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends Disposable {
|
|
224
|
+
constructor(_sheetsNoteModel, _univerInstanceService, _cellPopupManagerService, _sheetsNotePopupService) {
|
|
225
|
+
super();
|
|
226
|
+
this._sheetsNoteModel = _sheetsNoteModel;
|
|
227
|
+
this._univerInstanceService = _univerInstanceService;
|
|
228
|
+
this._cellPopupManagerService = _cellPopupManagerService;
|
|
229
|
+
this._sheetsNotePopupService = _sheetsNotePopupService;
|
|
230
|
+
_defineProperty(this, "_noteMatrix", new ObjectMatrix());
|
|
231
|
+
_defineProperty(this, "_suppressedUnitIds", /* @__PURE__ */ new Set());
|
|
232
|
+
_defineProperty(this, "_activeUnitId", null);
|
|
233
|
+
_defineProperty(this, "_activeSheetId", null);
|
|
234
|
+
_defineProperty(this, "_noteChangeSubscription", null);
|
|
235
|
+
this._initNoteChangeListener();
|
|
236
|
+
}
|
|
237
|
+
_showPopup(unitId, sheetId, row, col) {
|
|
238
|
+
this._sheetsNotePopupService.hidePopup(true);
|
|
239
|
+
return this._cellPopupManagerService.showPopup({
|
|
240
|
+
unitId,
|
|
241
|
+
subUnitId: sheetId,
|
|
242
|
+
row,
|
|
243
|
+
col
|
|
244
|
+
}, {
|
|
245
|
+
componentKey: SHEET_NOTE_COMPONENT,
|
|
246
|
+
direction: "horizontal",
|
|
247
|
+
extraProps: { location: {
|
|
248
|
+
unitId,
|
|
249
|
+
subUnitId: sheetId,
|
|
250
|
+
row,
|
|
251
|
+
col
|
|
252
|
+
} },
|
|
253
|
+
priority: 3
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
dispose() {
|
|
257
|
+
var _this$_noteChangeSubs;
|
|
258
|
+
super.dispose();
|
|
259
|
+
this._clearNoteMatrix();
|
|
260
|
+
this._suppressedUnitIds.clear();
|
|
261
|
+
this._activeUnitId = null;
|
|
262
|
+
this._activeSheetId = null;
|
|
263
|
+
(_this$_noteChangeSubs = this._noteChangeSubscription) === null || _this$_noteChangeSubs === void 0 || _this$_noteChangeSubs.unsubscribe();
|
|
264
|
+
this._noteChangeSubscription = null;
|
|
265
|
+
}
|
|
266
|
+
setPopupSuppressed(unitId, suppressed) {
|
|
267
|
+
if (suppressed) this._suppressedUnitIds.add(unitId);
|
|
268
|
+
else this._suppressedUnitIds.delete(unitId);
|
|
269
|
+
if (unitId !== this._activeUnitId || !this._activeSheetId) return;
|
|
270
|
+
if (suppressed) this._clearNoteMatrix();
|
|
271
|
+
else this._showPersistentNotes(unitId, this._activeSheetId);
|
|
272
|
+
}
|
|
273
|
+
_initSheet(targetUnitId, targetSheetId) {
|
|
274
|
+
this._clearNoteMatrix();
|
|
275
|
+
this._activeUnitId = targetUnitId;
|
|
276
|
+
this._activeSheetId = targetSheetId;
|
|
277
|
+
const handleNote = (unitId, sheetId, row, col, note) => {
|
|
278
|
+
const matrix = this._noteMatrix;
|
|
279
|
+
const disposable = matrix.getValue(row, col);
|
|
280
|
+
if (note === null || note === void 0 ? void 0 : note.show) {
|
|
281
|
+
if (this._suppressedUnitIds.has(unitId)) {
|
|
282
|
+
disposable === null || disposable === void 0 || disposable.dispose();
|
|
283
|
+
matrix.realDeleteValue(row, col);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (!disposable) {
|
|
287
|
+
const newDisposable = this._showPopup(unitId, sheetId, row, col);
|
|
288
|
+
if (newDisposable) matrix.setValue(row, col, newDisposable);
|
|
289
|
+
}
|
|
290
|
+
} else if (disposable) {
|
|
291
|
+
disposable.dispose();
|
|
292
|
+
matrix.realDeleteValue(row, col);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
if (!this._suppressedUnitIds.has(targetUnitId)) this._showPersistentNotes(targetUnitId, targetSheetId);
|
|
296
|
+
return this._sheetsNoteModel.change$.subscribe((change) => {
|
|
297
|
+
if (change.unitId !== targetUnitId || change.subUnitId !== targetSheetId) return;
|
|
298
|
+
switch (change.type) {
|
|
299
|
+
case "ref": {
|
|
300
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
301
|
+
if (!newNote.show) return;
|
|
302
|
+
const matrix = this._noteMatrix;
|
|
303
|
+
const { row: oldRow, col: oldCol } = oldNote;
|
|
304
|
+
const { row: newRow, col: newCol } = newNote;
|
|
305
|
+
const disposable = matrix.getValue(oldRow, oldCol);
|
|
306
|
+
if (disposable) {
|
|
307
|
+
disposable.dispose();
|
|
308
|
+
matrix.realDeleteValue(oldRow, oldCol);
|
|
309
|
+
}
|
|
310
|
+
handleNote(unitId, subUnitId, newRow, newCol, newNote);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case "update": {
|
|
314
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
315
|
+
const row = newNote ? newNote.row : oldNote.row;
|
|
316
|
+
const col = newNote ? newNote.col : oldNote.col;
|
|
317
|
+
handleNote(unitId, subUnitId, row, col, newNote);
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
default: break;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
_initNoteChangeListener() {
|
|
325
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe((sheet) => {
|
|
326
|
+
var _this$_noteChangeSubs2;
|
|
327
|
+
(_this$_noteChangeSubs2 = this._noteChangeSubscription) === null || _this$_noteChangeSubs2 === void 0 || _this$_noteChangeSubs2.unsubscribe();
|
|
328
|
+
this._noteChangeSubscription = null;
|
|
329
|
+
if (sheet) this._noteChangeSubscription = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
330
|
+
else {
|
|
331
|
+
this._clearNoteMatrix();
|
|
332
|
+
this._activeUnitId = null;
|
|
333
|
+
this._activeSheetId = null;
|
|
334
|
+
}
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
_showPersistentNotes(unitId, sheetId) {
|
|
338
|
+
var _this$_sheetsNoteMode;
|
|
339
|
+
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(unitId, sheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
340
|
+
if (!note.show || this._noteMatrix.getValue(note.row, note.col)) return;
|
|
341
|
+
const disposable = this._showPopup(unitId, sheetId, note.row, note.col);
|
|
342
|
+
if (disposable) this._noteMatrix.setValue(note.row, note.col, disposable);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
_clearNoteMatrix() {
|
|
346
|
+
this._noteMatrix.forValue((_, __, disposable) => {
|
|
347
|
+
disposable.dispose();
|
|
348
|
+
});
|
|
349
|
+
this._noteMatrix = new ObjectMatrix();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
SheetsNoteAttachmentController = __decorate([
|
|
353
|
+
__decorateParam(0, Inject(SheetsNoteModel)),
|
|
354
|
+
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
355
|
+
__decorateParam(2, Inject(CellPopupManagerService)),
|
|
356
|
+
__decorateParam(3, Inject(SheetsNotePopupService))
|
|
357
|
+
], SheetsNoteAttachmentController);
|
|
358
|
+
|
|
221
359
|
//#endregion
|
|
222
360
|
//#region src/controllers/sheets-note-popup.controller.ts
|
|
223
361
|
let SheetsNotePopupController = class SheetsNotePopupController extends Disposable {
|
|
@@ -435,7 +573,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
435
573
|
//#endregion
|
|
436
574
|
//#region package.json
|
|
437
575
|
var name = "@univerjs/sheets-note-ui";
|
|
438
|
-
var version = "1.0.0-beta.
|
|
576
|
+
var version = "1.0.0-beta.2";
|
|
439
577
|
|
|
440
578
|
//#endregion
|
|
441
579
|
//#region src/config/config.ts
|
|
@@ -603,117 +741,6 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
603
741
|
};
|
|
604
742
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
605
743
|
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
608
|
-
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends Disposable {
|
|
609
|
-
constructor(_sheetsNoteModel, _univerInstanceService, _cellPopupManagerService, _sheetsNotePopupService) {
|
|
610
|
-
super();
|
|
611
|
-
this._sheetsNoteModel = _sheetsNoteModel;
|
|
612
|
-
this._univerInstanceService = _univerInstanceService;
|
|
613
|
-
this._cellPopupManagerService = _cellPopupManagerService;
|
|
614
|
-
this._sheetsNotePopupService = _sheetsNotePopupService;
|
|
615
|
-
_defineProperty(this, "_noteMatrix", new ObjectMatrix());
|
|
616
|
-
this._initNoteChangeListener();
|
|
617
|
-
}
|
|
618
|
-
_showPopup(unitId, sheetId, row, col) {
|
|
619
|
-
this._sheetsNotePopupService.hidePopup(true);
|
|
620
|
-
return this._cellPopupManagerService.showPopup({
|
|
621
|
-
unitId,
|
|
622
|
-
subUnitId: sheetId,
|
|
623
|
-
row,
|
|
624
|
-
col
|
|
625
|
-
}, {
|
|
626
|
-
componentKey: SHEET_NOTE_COMPONENT,
|
|
627
|
-
direction: "horizontal",
|
|
628
|
-
extraProps: { location: {
|
|
629
|
-
unitId,
|
|
630
|
-
subUnitId: sheetId,
|
|
631
|
-
row,
|
|
632
|
-
col
|
|
633
|
-
} },
|
|
634
|
-
priority: 3
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
dispose() {
|
|
638
|
-
super.dispose();
|
|
639
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
640
|
-
disposable.dispose();
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
_initSheet(targetUnitId, targetSheetId) {
|
|
644
|
-
var _this$_sheetsNoteMode;
|
|
645
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
646
|
-
disposable.dispose();
|
|
647
|
-
});
|
|
648
|
-
this._noteMatrix = new ObjectMatrix();
|
|
649
|
-
const handleNote = (unitId, sheetId, row, col, note) => {
|
|
650
|
-
const matrix = this._noteMatrix;
|
|
651
|
-
const disposable = matrix.getValue(row, col);
|
|
652
|
-
if (note === null || note === void 0 ? void 0 : note.show) {
|
|
653
|
-
if (!disposable) {
|
|
654
|
-
const newDisposable = this._showPopup(unitId, sheetId, row, col);
|
|
655
|
-
if (newDisposable) matrix.setValue(row, col, newDisposable);
|
|
656
|
-
}
|
|
657
|
-
} else if (disposable) {
|
|
658
|
-
disposable.dispose();
|
|
659
|
-
matrix.realDeleteValue(row, col);
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(targetUnitId, targetSheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
663
|
-
handleNote(targetUnitId, targetSheetId, note.row, note.col, note);
|
|
664
|
-
});
|
|
665
|
-
return this._sheetsNoteModel.change$.subscribe((change) => {
|
|
666
|
-
if (change.unitId !== targetUnitId || change.subUnitId !== targetSheetId) return;
|
|
667
|
-
switch (change.type) {
|
|
668
|
-
case "ref": {
|
|
669
|
-
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
670
|
-
if (!newNote.show) return;
|
|
671
|
-
const matrix = this._noteMatrix;
|
|
672
|
-
const { row: oldRow, col: oldCol } = oldNote;
|
|
673
|
-
const { row: newRow, col: newCol } = newNote;
|
|
674
|
-
const disposable = matrix.getValue(oldRow, oldCol);
|
|
675
|
-
if (disposable) {
|
|
676
|
-
disposable.dispose();
|
|
677
|
-
matrix.realDeleteValue(oldRow, oldCol);
|
|
678
|
-
}
|
|
679
|
-
const newDisposable = this._showPopup(unitId, subUnitId, newRow, newCol);
|
|
680
|
-
if (newDisposable) matrix.setValue(newRow, newCol, newDisposable);
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
case "update": {
|
|
684
|
-
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
685
|
-
const row = newNote ? newNote.row : oldNote.row;
|
|
686
|
-
const col = newNote ? newNote.col : oldNote.col;
|
|
687
|
-
handleNote(unitId, subUnitId, row, col, newNote);
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
default: break;
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
_initNoteChangeListener() {
|
|
695
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe((sheet) => {
|
|
696
|
-
if (sheet) {
|
|
697
|
-
const disposable = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
698
|
-
return () => {
|
|
699
|
-
disposable.unsubscribe();
|
|
700
|
-
};
|
|
701
|
-
} else {
|
|
702
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
703
|
-
disposable.dispose();
|
|
704
|
-
});
|
|
705
|
-
this._noteMatrix = new ObjectMatrix();
|
|
706
|
-
}
|
|
707
|
-
}));
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
SheetsNoteAttachmentController = __decorate([
|
|
711
|
-
__decorateParam(0, Inject(SheetsNoteModel)),
|
|
712
|
-
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
713
|
-
__decorateParam(2, Inject(CellPopupManagerService)),
|
|
714
|
-
__decorateParam(3, Inject(SheetsNotePopupService))
|
|
715
|
-
], SheetsNoteAttachmentController);
|
|
716
|
-
|
|
717
744
|
//#endregion
|
|
718
745
|
//#region src/controllers/ui.controller.ts
|
|
719
746
|
/**
|
|
@@ -791,4 +818,4 @@ UniverSheetsNoteUIPlugin = __decorate([
|
|
|
791
818
|
], UniverSheetsNoteUIPlugin);
|
|
792
819
|
|
|
793
820
|
//#endregion
|
|
794
|
-
export { SheetsCellContentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
|
821
|
+
export { SheetsCellContentController, SheetsNoteAttachmentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
package/lib/index.js
CHANGED
|
@@ -218,6 +218,144 @@ let SheetsNotePopupService = class SheetsNotePopupService extends Disposable {
|
|
|
218
218
|
};
|
|
219
219
|
SheetsNotePopupService = __decorate([__decorateParam(0, Inject(CellPopupManagerService))], SheetsNotePopupService);
|
|
220
220
|
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
223
|
+
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends Disposable {
|
|
224
|
+
constructor(_sheetsNoteModel, _univerInstanceService, _cellPopupManagerService, _sheetsNotePopupService) {
|
|
225
|
+
super();
|
|
226
|
+
this._sheetsNoteModel = _sheetsNoteModel;
|
|
227
|
+
this._univerInstanceService = _univerInstanceService;
|
|
228
|
+
this._cellPopupManagerService = _cellPopupManagerService;
|
|
229
|
+
this._sheetsNotePopupService = _sheetsNotePopupService;
|
|
230
|
+
_defineProperty(this, "_noteMatrix", new ObjectMatrix());
|
|
231
|
+
_defineProperty(this, "_suppressedUnitIds", /* @__PURE__ */ new Set());
|
|
232
|
+
_defineProperty(this, "_activeUnitId", null);
|
|
233
|
+
_defineProperty(this, "_activeSheetId", null);
|
|
234
|
+
_defineProperty(this, "_noteChangeSubscription", null);
|
|
235
|
+
this._initNoteChangeListener();
|
|
236
|
+
}
|
|
237
|
+
_showPopup(unitId, sheetId, row, col) {
|
|
238
|
+
this._sheetsNotePopupService.hidePopup(true);
|
|
239
|
+
return this._cellPopupManagerService.showPopup({
|
|
240
|
+
unitId,
|
|
241
|
+
subUnitId: sheetId,
|
|
242
|
+
row,
|
|
243
|
+
col
|
|
244
|
+
}, {
|
|
245
|
+
componentKey: SHEET_NOTE_COMPONENT,
|
|
246
|
+
direction: "horizontal",
|
|
247
|
+
extraProps: { location: {
|
|
248
|
+
unitId,
|
|
249
|
+
subUnitId: sheetId,
|
|
250
|
+
row,
|
|
251
|
+
col
|
|
252
|
+
} },
|
|
253
|
+
priority: 3
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
dispose() {
|
|
257
|
+
var _this$_noteChangeSubs;
|
|
258
|
+
super.dispose();
|
|
259
|
+
this._clearNoteMatrix();
|
|
260
|
+
this._suppressedUnitIds.clear();
|
|
261
|
+
this._activeUnitId = null;
|
|
262
|
+
this._activeSheetId = null;
|
|
263
|
+
(_this$_noteChangeSubs = this._noteChangeSubscription) === null || _this$_noteChangeSubs === void 0 || _this$_noteChangeSubs.unsubscribe();
|
|
264
|
+
this._noteChangeSubscription = null;
|
|
265
|
+
}
|
|
266
|
+
setPopupSuppressed(unitId, suppressed) {
|
|
267
|
+
if (suppressed) this._suppressedUnitIds.add(unitId);
|
|
268
|
+
else this._suppressedUnitIds.delete(unitId);
|
|
269
|
+
if (unitId !== this._activeUnitId || !this._activeSheetId) return;
|
|
270
|
+
if (suppressed) this._clearNoteMatrix();
|
|
271
|
+
else this._showPersistentNotes(unitId, this._activeSheetId);
|
|
272
|
+
}
|
|
273
|
+
_initSheet(targetUnitId, targetSheetId) {
|
|
274
|
+
this._clearNoteMatrix();
|
|
275
|
+
this._activeUnitId = targetUnitId;
|
|
276
|
+
this._activeSheetId = targetSheetId;
|
|
277
|
+
const handleNote = (unitId, sheetId, row, col, note) => {
|
|
278
|
+
const matrix = this._noteMatrix;
|
|
279
|
+
const disposable = matrix.getValue(row, col);
|
|
280
|
+
if (note === null || note === void 0 ? void 0 : note.show) {
|
|
281
|
+
if (this._suppressedUnitIds.has(unitId)) {
|
|
282
|
+
disposable === null || disposable === void 0 || disposable.dispose();
|
|
283
|
+
matrix.realDeleteValue(row, col);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (!disposable) {
|
|
287
|
+
const newDisposable = this._showPopup(unitId, sheetId, row, col);
|
|
288
|
+
if (newDisposable) matrix.setValue(row, col, newDisposable);
|
|
289
|
+
}
|
|
290
|
+
} else if (disposable) {
|
|
291
|
+
disposable.dispose();
|
|
292
|
+
matrix.realDeleteValue(row, col);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
if (!this._suppressedUnitIds.has(targetUnitId)) this._showPersistentNotes(targetUnitId, targetSheetId);
|
|
296
|
+
return this._sheetsNoteModel.change$.subscribe((change) => {
|
|
297
|
+
if (change.unitId !== targetUnitId || change.subUnitId !== targetSheetId) return;
|
|
298
|
+
switch (change.type) {
|
|
299
|
+
case "ref": {
|
|
300
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
301
|
+
if (!newNote.show) return;
|
|
302
|
+
const matrix = this._noteMatrix;
|
|
303
|
+
const { row: oldRow, col: oldCol } = oldNote;
|
|
304
|
+
const { row: newRow, col: newCol } = newNote;
|
|
305
|
+
const disposable = matrix.getValue(oldRow, oldCol);
|
|
306
|
+
if (disposable) {
|
|
307
|
+
disposable.dispose();
|
|
308
|
+
matrix.realDeleteValue(oldRow, oldCol);
|
|
309
|
+
}
|
|
310
|
+
handleNote(unitId, subUnitId, newRow, newCol, newNote);
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case "update": {
|
|
314
|
+
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
315
|
+
const row = newNote ? newNote.row : oldNote.row;
|
|
316
|
+
const col = newNote ? newNote.col : oldNote.col;
|
|
317
|
+
handleNote(unitId, subUnitId, row, col, newNote);
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
default: break;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
_initNoteChangeListener() {
|
|
325
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe((sheet) => {
|
|
326
|
+
var _this$_noteChangeSubs2;
|
|
327
|
+
(_this$_noteChangeSubs2 = this._noteChangeSubscription) === null || _this$_noteChangeSubs2 === void 0 || _this$_noteChangeSubs2.unsubscribe();
|
|
328
|
+
this._noteChangeSubscription = null;
|
|
329
|
+
if (sheet) this._noteChangeSubscription = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
330
|
+
else {
|
|
331
|
+
this._clearNoteMatrix();
|
|
332
|
+
this._activeUnitId = null;
|
|
333
|
+
this._activeSheetId = null;
|
|
334
|
+
}
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
_showPersistentNotes(unitId, sheetId) {
|
|
338
|
+
var _this$_sheetsNoteMode;
|
|
339
|
+
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(unitId, sheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
340
|
+
if (!note.show || this._noteMatrix.getValue(note.row, note.col)) return;
|
|
341
|
+
const disposable = this._showPopup(unitId, sheetId, note.row, note.col);
|
|
342
|
+
if (disposable) this._noteMatrix.setValue(note.row, note.col, disposable);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
_clearNoteMatrix() {
|
|
346
|
+
this._noteMatrix.forValue((_, __, disposable) => {
|
|
347
|
+
disposable.dispose();
|
|
348
|
+
});
|
|
349
|
+
this._noteMatrix = new ObjectMatrix();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
SheetsNoteAttachmentController = __decorate([
|
|
353
|
+
__decorateParam(0, Inject(SheetsNoteModel)),
|
|
354
|
+
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
355
|
+
__decorateParam(2, Inject(CellPopupManagerService)),
|
|
356
|
+
__decorateParam(3, Inject(SheetsNotePopupService))
|
|
357
|
+
], SheetsNoteAttachmentController);
|
|
358
|
+
|
|
221
359
|
//#endregion
|
|
222
360
|
//#region src/controllers/sheets-note-popup.controller.ts
|
|
223
361
|
let SheetsNotePopupController = class SheetsNotePopupController extends Disposable {
|
|
@@ -435,7 +573,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
435
573
|
//#endregion
|
|
436
574
|
//#region package.json
|
|
437
575
|
var name = "@univerjs/sheets-note-ui";
|
|
438
|
-
var version = "1.0.0-beta.
|
|
576
|
+
var version = "1.0.0-beta.2";
|
|
439
577
|
|
|
440
578
|
//#endregion
|
|
441
579
|
//#region src/config/config.ts
|
|
@@ -603,117 +741,6 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
603
741
|
};
|
|
604
742
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
605
743
|
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/controllers/sheets-note-attachment.controller.ts
|
|
608
|
-
let SheetsNoteAttachmentController = class SheetsNoteAttachmentController extends Disposable {
|
|
609
|
-
constructor(_sheetsNoteModel, _univerInstanceService, _cellPopupManagerService, _sheetsNotePopupService) {
|
|
610
|
-
super();
|
|
611
|
-
this._sheetsNoteModel = _sheetsNoteModel;
|
|
612
|
-
this._univerInstanceService = _univerInstanceService;
|
|
613
|
-
this._cellPopupManagerService = _cellPopupManagerService;
|
|
614
|
-
this._sheetsNotePopupService = _sheetsNotePopupService;
|
|
615
|
-
_defineProperty(this, "_noteMatrix", new ObjectMatrix());
|
|
616
|
-
this._initNoteChangeListener();
|
|
617
|
-
}
|
|
618
|
-
_showPopup(unitId, sheetId, row, col) {
|
|
619
|
-
this._sheetsNotePopupService.hidePopup(true);
|
|
620
|
-
return this._cellPopupManagerService.showPopup({
|
|
621
|
-
unitId,
|
|
622
|
-
subUnitId: sheetId,
|
|
623
|
-
row,
|
|
624
|
-
col
|
|
625
|
-
}, {
|
|
626
|
-
componentKey: SHEET_NOTE_COMPONENT,
|
|
627
|
-
direction: "horizontal",
|
|
628
|
-
extraProps: { location: {
|
|
629
|
-
unitId,
|
|
630
|
-
subUnitId: sheetId,
|
|
631
|
-
row,
|
|
632
|
-
col
|
|
633
|
-
} },
|
|
634
|
-
priority: 3
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
dispose() {
|
|
638
|
-
super.dispose();
|
|
639
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
640
|
-
disposable.dispose();
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
_initSheet(targetUnitId, targetSheetId) {
|
|
644
|
-
var _this$_sheetsNoteMode;
|
|
645
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
646
|
-
disposable.dispose();
|
|
647
|
-
});
|
|
648
|
-
this._noteMatrix = new ObjectMatrix();
|
|
649
|
-
const handleNote = (unitId, sheetId, row, col, note) => {
|
|
650
|
-
const matrix = this._noteMatrix;
|
|
651
|
-
const disposable = matrix.getValue(row, col);
|
|
652
|
-
if (note === null || note === void 0 ? void 0 : note.show) {
|
|
653
|
-
if (!disposable) {
|
|
654
|
-
const newDisposable = this._showPopup(unitId, sheetId, row, col);
|
|
655
|
-
if (newDisposable) matrix.setValue(row, col, newDisposable);
|
|
656
|
-
}
|
|
657
|
-
} else if (disposable) {
|
|
658
|
-
disposable.dispose();
|
|
659
|
-
matrix.realDeleteValue(row, col);
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(targetUnitId, targetSheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
663
|
-
handleNote(targetUnitId, targetSheetId, note.row, note.col, note);
|
|
664
|
-
});
|
|
665
|
-
return this._sheetsNoteModel.change$.subscribe((change) => {
|
|
666
|
-
if (change.unitId !== targetUnitId || change.subUnitId !== targetSheetId) return;
|
|
667
|
-
switch (change.type) {
|
|
668
|
-
case "ref": {
|
|
669
|
-
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
670
|
-
if (!newNote.show) return;
|
|
671
|
-
const matrix = this._noteMatrix;
|
|
672
|
-
const { row: oldRow, col: oldCol } = oldNote;
|
|
673
|
-
const { row: newRow, col: newCol } = newNote;
|
|
674
|
-
const disposable = matrix.getValue(oldRow, oldCol);
|
|
675
|
-
if (disposable) {
|
|
676
|
-
disposable.dispose();
|
|
677
|
-
matrix.realDeleteValue(oldRow, oldCol);
|
|
678
|
-
}
|
|
679
|
-
const newDisposable = this._showPopup(unitId, subUnitId, newRow, newCol);
|
|
680
|
-
if (newDisposable) matrix.setValue(newRow, newCol, newDisposable);
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
case "update": {
|
|
684
|
-
const { unitId, subUnitId, oldNote, newNote } = change;
|
|
685
|
-
const row = newNote ? newNote.row : oldNote.row;
|
|
686
|
-
const col = newNote ? newNote.col : oldNote.col;
|
|
687
|
-
handleNote(unitId, subUnitId, row, col, newNote);
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
default: break;
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
_initNoteChangeListener() {
|
|
695
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe((sheet) => {
|
|
696
|
-
if (sheet) {
|
|
697
|
-
const disposable = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
698
|
-
return () => {
|
|
699
|
-
disposable.unsubscribe();
|
|
700
|
-
};
|
|
701
|
-
} else {
|
|
702
|
-
this._noteMatrix.forValue((_, __, disposable) => {
|
|
703
|
-
disposable.dispose();
|
|
704
|
-
});
|
|
705
|
-
this._noteMatrix = new ObjectMatrix();
|
|
706
|
-
}
|
|
707
|
-
}));
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
SheetsNoteAttachmentController = __decorate([
|
|
711
|
-
__decorateParam(0, Inject(SheetsNoteModel)),
|
|
712
|
-
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
713
|
-
__decorateParam(2, Inject(CellPopupManagerService)),
|
|
714
|
-
__decorateParam(3, Inject(SheetsNotePopupService))
|
|
715
|
-
], SheetsNoteAttachmentController);
|
|
716
|
-
|
|
717
744
|
//#endregion
|
|
718
745
|
//#region src/controllers/ui.controller.ts
|
|
719
746
|
/**
|
|
@@ -791,4 +818,4 @@ UniverSheetsNoteUIPlugin = __decorate([
|
|
|
791
818
|
], UniverSheetsNoteUIPlugin);
|
|
792
819
|
|
|
793
820
|
//#endregion
|
|
794
|
-
export { SheetsCellContentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
|
821
|
+
export { SheetsCellContentController, SheetsNoteAttachmentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
|
@@ -23,9 +23,16 @@ export declare class SheetsNoteAttachmentController extends Disposable {
|
|
|
23
23
|
private readonly _cellPopupManagerService;
|
|
24
24
|
private readonly _sheetsNotePopupService;
|
|
25
25
|
private _noteMatrix;
|
|
26
|
+
private readonly _suppressedUnitIds;
|
|
27
|
+
private _activeUnitId;
|
|
28
|
+
private _activeSheetId;
|
|
29
|
+
private _noteChangeSubscription;
|
|
26
30
|
constructor(_sheetsNoteModel: SheetsNoteModel, _univerInstanceService: IUniverInstanceService, _cellPopupManagerService: CellPopupManagerService, _sheetsNotePopupService: SheetsNotePopupService);
|
|
27
31
|
private _showPopup;
|
|
28
32
|
dispose(): void;
|
|
33
|
+
setPopupSuppressed(unitId: string, suppressed: boolean): void;
|
|
29
34
|
private _initSheet;
|
|
30
35
|
private _initNoteChangeListener;
|
|
36
|
+
private _showPersistentNotes;
|
|
37
|
+
private _clearNoteMatrix;
|
|
31
38
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import './global.css';
|
|
17
17
|
export type { IUniverSheetsNoteUIConfig } from './config/config';
|
|
18
18
|
export { SheetsCellContentController } from './controllers/sheets-cell-content.controller';
|
|
19
|
+
export { SheetsNoteAttachmentController } from './controllers/sheets-note-attachment.controller';
|
|
19
20
|
export { SheetsNotePopupController } from './controllers/sheets-note-popup.controller';
|
|
20
21
|
export { menuSchema as SheetsNoteUIMenuSchema } from './menu/schema';
|
|
21
22
|
export { UniverSheetsNoteUIPlugin } from './plugin';
|
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/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-note`,`rxjs`,`@univerjs/sheets-ui`,`rxjs/operators`,`@univerjs/ui`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteUi={},e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsNote,e.rxjs,e.UniverSheetsUi,e.rxjs.operators,e.UniverUi,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function f(e,t){return function(n,r){t(n,r,e)}}function p(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 m=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=n,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsNoteModel.getNote(a,o,{row:r,col:i})?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let e=()=>{var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderUnitById(r);i==null||(e=i.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe((0,a.debounceTime)(16)).subscribe(()=>{e()}))}};m=p([f(0,(0,t.Inject)(r.SheetInterceptorService)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,n.IRenderManagerService),f(3,t.IUniverInstanceService)],m);let h=`SHEET_NOTE_COMPONENT`;function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends t.Disposable{get activePopup(){return this._activePopup}constructor(e){super(),this._cellPopupManagerService=e,y(this,`_lastPopup`,null),y(this,`_activePopup`,void 0),y(this,`_activePopup$`,new a.BehaviorSubject(null)),y(this,`activePopup$`,this._activePopup$.asObservable()),this.disposeWithMe(()=>{this._activePopup$.complete()})}dispose(){super.dispose(),this.hidePopup()}showPopup(e,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=e;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}this._lastPopup&&this._lastPopup.dispose(),this._activePopup=e,this._activePopup$.next(e);let c=this._cellPopupManagerService.showPopup({unitId:o,subUnitId:s,row:i,col:a},{componentKey:h,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,extraProps:{location:e},priority:3});if(!c)throw Error(`[SheetsNotePopupService]: cannot show popup!`);let l=new t.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};b=p([f(0,(0,t.Inject)(o.CellPopupManagerService))],b);let x=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetsNotePopupService=e,this._sheetsNoteModel=t,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=i,this._hoverManagerService=a,y(this,`_isSwitchingSheet`,!1),this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,n,r){var i,a;let s=(i=e[0])==null?void 0:i.range,c=this._renderManagerService.getRenderUnitById(n),l=c==null||(a=c.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:a.skeleton;if(!l||!s)return;let u=l.getCellWithCoordByIndex(s.startRow,s.startColumn);if(((s.rangeType??t.RANGE_TYPE.NORMAL)!==t.RANGE_TYPE.NORMAL||s.endColumn-s.startColumn>0||s.endRow-s.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&t.Rectangle.equals(u.mergeInfo,s))){this._sheetsNotePopupService.hidePopup();return}let d=u.actualRow,f=u.actualColumn,p=this._sheetsNoteModel.getNote(n,r,{row:d,col:f});p!=null&&p.show||(p?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:p.id,row:d,col:f}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{var t;if(!(e!=null&&e.location))return;let{unitId:n,subUnitId:r,row:i,col:a}=e.location,s=this._renderManagerService.getRenderUnitById(n),c=s==null||(t=s.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:t.skeleton,l=i,u=a,d=this._sheetsNoteModel.getNote(n,r,{row:l,col:u});if(!d&&c){let{startRow:e,endRow:t,startColumn:o,endColumn:s}=c.getCellWithCoordByIndex(i,a).mergeInfo;if(e!==t||o!==s){let i=this._sheetsNoteModel.getSheetNotes(n,r);if(i){for(let[n,r]of i)if(r.row>=e&&r.row<=t&&r.col>=o&&r.col<=s){d=r,l=r.row,u=r.col;break}}}}d!=null&&d.show||(d?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:d.id,row:l,col:u,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;let{unitId:t,subUnitId:n,noteId:r,row:i,col:a}=this._sheetsNotePopupService.activePopup,{oldNote:o,newNote:s}=e;s===null&&e.unitId===t&&e.subUnitId===n&&(o!=null&&o.id&&o.id===r||(o==null?void 0:o.row)===i&&o.col===a)&&this._sheetsNotePopupService.hidePopup(!0)}))}};x=p([f(0,(0,t.Inject)(b)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,(0,t.Inject)(r.SheetsSelectionsService)),f(3,o.IEditorBridgeService),f(4,n.IRenderManagerService),f(5,(0,t.Inject)(o.HoverManagerService))],x);let S={id:`sheet.operation.add-note-popup`,type:t.CommandType.OPERATION,handler:async(e,n)=>{let i=e.get(r.SheetsSelectionsService),a=e.get(b),o=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;let s=o.getActiveSheet(),c=i.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;let{primary:l}=c;return a.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:(n==null?void 0:n.trigger)??`add-note`}),!0}};function C(e){let n=e.get(r.SheetsSelectionsService),o=e.get(t.IUniverInstanceService);return n.selectionMoveEnd$.pipe((0,a.map)(()=>{let t=n.getCurrentLastSelection();if(!(t!=null&&t.primary))return!1;let a=(0,r.getSheetCommandTarget)(o);if(!a)return!1;let{actualColumn:s,actualRow:c}=t.primary;return!!e.get(i.SheetsNoteModel).getNote(a.unitId,a.subUnitId,{row:c,col:s})}))}function w(e){return{id:S.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.addNote`,icon:`AddNoteIcon`,hidden$:(0,a.combineLatest)([(0,c.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),C(e)]).pipe((0,a.map)(([e,t])=>e||t)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]}),commandId:S.id}}function T(e){return{id:i.SheetDeleteNoteCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.deleteNote`,icon:`DeleteNoteIcon`,hidden$:C(e).pipe((0,a.map)(e=>!e)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]})}}function E(e){return{id:i.SheetToggleNotePopupCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.toggleNote`,icon:`HideNoteIcon`,hidden$:C(e).pipe((0,a.map)(e=>!e))}}let D={[c.ContextMenuPosition.MAIN_AREA]:{[c.ContextMenuGroup.OTHERS]:{order:0,[S.id]:{order:0,menuItemFactory:w},[i.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:T},[i.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:E}}}};var O=`@univerjs/sheets-note-ui`,k=`1.0.0-beta.1`;let A=`sheets-note-ui.config`,j={};function M({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,l.useRef)(`_${I()}`);return N(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function N(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...P(e,n,i),...r},(F(e,n).children||[]).map((r,a)=>N(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function P(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function F(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function I(){return Math.random().toString(36).substring(2,8)}M.displayName=`UniverIcon`;let L={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z`}}]},R=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`add-note-icon`,ref:t,icon:L}))});R.displayName=`AddNoteIcon`;let z={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z`}}]},B=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`delete-note-icon`,ref:t,icon:z}))});B.displayName=`DeleteNoteIcon`;let V={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z`}}]},H=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(M,Object.assign({},e,{id:`hide-note-icon`,ref:t,icon:V}))});H.displayName=`HideNoteIcon`;let U=e=>{var t;let n=(t=e.popup.extraProps)==null?void 0:t.location;return n?(0,d.jsx)(W,{activePopup:n}):(console.error(`Popup extraProps or location is undefined.`),null)};function W({activePopup:e}){let r=(0,c.useDependency)(i.SheetsNoteModel),a=(0,c.useDependency)(t.LocaleService),o=(0,c.useDependency)(n.IRenderManagerService),s=(0,c.useDependency)(b),f=(0,c.useConfigValue)(A),p=(0,l.useRef)(null),m=(0,l.useRef)(null),h=o.getRenderUnitById(e.unitId),[g,_]=(0,l.useState)(null),v=(0,l.useCallback)(e=>{let t=p.current;if(t)if(a.getDirection()===`rtl`&&m.current!=null){let n=m.current-e;t.style.transform=n?`translateX(${n}px)`:``}else t.style.transform=``},[a]);(0,l.useEffect)(()=>{var n,i;let{unitId:a,subUnitId:o,row:s,col:c}=e,l=r.getNote(a,o,{row:s,col:c}),u=(l==null?void 0:l.width)??(f==null||(n=f.defaultNoteSize)==null?void 0:n.width)??160,d=(l==null?void 0:l.height)??(f==null||(i=f.defaultNoteSize)==null?void 0:i.height)??72;if(l)_(l);else{let e={id:(0,t.generateRandomId)(6),width:u,height:d,note:``};_(e),x(e)}p.current&&(m.current=u,p.current.style.width=`${u}px`,p.current.style.height=`${d}px`,p.current.style.transform=``)},[e,p]),(0,l.useEffect)(()=>{if(!e||e.temp||!e.trigger||!p.current)return;let t=requestAnimationFrame(()=>{var e;(e=p.current)==null||e.focus()});return()=>cancelAnimationFrame(t)},[e]);let y=(0,c.useDependency)(t.ICommandService),x=(0,c.useDebounceFn)(t=>{if(!e)return;let{unitId:n,subUnitId:a,row:o,col:c}=e;if(!y.syncExecuteCommand(i.SheetUpdateNoteCommand.id,{unitId:n,sheetId:a,row:o,col:c,note:t})){let e=r.getNote(n,a,{noteId:t.id,row:o,col:c});e?_(e):s.hidePopup(!0)}}),S=(0,l.useCallback)(e=>{if(!g||e===g.note)return;let t={...g,note:e};_(t),x(t)},[g]),C=(0,l.useCallback)((e,t)=>{if(!g||(v(e),e===g.width&&t===g.height))return;let n={...g,width:e,height:t};_(n),x(n)},[v,g]);return(0,d.jsx)(u.Textarea,{ref:p,"data-u-comp":`note-textarea`,className:(0,u.clsx)(`univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-gray-0 !univer-text-sm univer-shadow dark:!univer-bg-gray-800`),value:g==null?void 0:g.note,placeholder:a.t(`sheets-note-ui.note.placeholder`),onResize:C,onValueChange:S,onWheel:e=>{document.activeElement!==p.current&&h.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type,e.nativeEvent))}})}let G=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[h,U]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddNoteIcon:R,DeleteNoteIcon:B,HideNoteIcon:H}))}};G=p([f(0,(0,t.Inject)(c.ComponentManager)),f(1,(0,t.Inject)(c.IconManager))],G);let K=class extends t.Disposable{constructor(e,n,r,i){super(),this._sheetsNoteModel=e,this._univerInstanceService=n,this._cellPopupManagerService=r,this._sheetsNotePopupService=i,y(this,`_noteMatrix`,new t.ObjectMatrix),this._initNoteChangeListener()}_showPopup(e,t,n,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:n,col:r},{componentKey:h,direction:`horizontal`,extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}dispose(){super.dispose(),this._noteMatrix.forValue((e,t,n)=>{n.dispose()})}_initSheet(e,n){var r;this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix;let i=(e,t,n,r,i)=>{let a=this._noteMatrix,o=a.getValue(n,r);if(i!=null&&i.show){if(!o){let i=this._showPopup(e,t,n,r);i&&a.setValue(n,r,i)}}else o&&(o.dispose(),a.realDeleteValue(n,r))};return(r=this._sheetsNoteModel.getSheetNotes(e,n))==null||r.forEach(t=>{i(e,n,t.row,t.col,t)}),this._sheetsNoteModel.change$.subscribe(t=>{if(t.unitId===e&&t.subUnitId===n)switch(t.type){case`ref`:{let{unitId:e,subUnitId:n,oldNote:r,newNote:i}=t;if(!i.show)return;let a=this._noteMatrix,{row:o,col:s}=r,{row:c,col:l}=i,u=a.getValue(o,s);u&&(u.dispose(),a.realDeleteValue(o,s));let d=this._showPopup(e,n,c,l);d&&a.setValue(c,l,d);break}case`update`:{let{unitId:e,subUnitId:n,oldNote:r,newNote:a}=t,o=a?a.row:r.row,s=a?a.col:r.col;i(e,n,o,s,a);break}default:break}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>(e==null?void 0:e.activeSheet$)??(0,a.of)(null))).subscribe(e=>{if(e){let t=this._initSheet(e.getUnitId(),e.getSheetId());return()=>{t.unsubscribe()}}else this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix}))}};K=p([f(0,(0,t.Inject)(i.SheetsNoteModel)),f(1,(0,t.Inject)(t.IUniverInstanceService)),f(2,(0,t.Inject)(o.CellPopupManagerService)),f(3,(0,t.Inject)(b))],K);let q=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._commandService=t,this._initMenu(),this._initCommands()}_initMenu(){this._menuManagerService.mergeMenu(D)}_initCommands(){this._commandService.registerCommand(S)}};q=p([f(0,(0,t.Inject)(c.IMenuManagerService)),f(1,t.ICommandService)],q);let J=class extends t.Plugin{constructor(e=j,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},j,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(A,a)}onStarting(){this._injector.add([G]),this._injector.get(G),[[b],[m],[x],[q],[K]].forEach(e=>{this._injector.add(e)})}onReady(){(0,t.touchDependencies)(this._injector,[[q],[m]])}onRendered(){(0,t.touchDependencies)(this._injector,[[x],[K]])}};y(J,`pluginName`,`SHEET_NOTE_UI_PLUGIN`),y(J,`packageName`,O),y(J,`version`,k),y(J,`type`,t.UniverInstanceType.UNIVER_SHEET),J=p([(0,t.DependentOn)(n.UniverRenderEnginePlugin,r.UniverSheetsPlugin,i.UniverSheetsNotePlugin,o.UniverSheetsUIPlugin),f(1,(0,t.Inject)(t.Injector)),f(2,t.IConfigService)],J),Object.defineProperty(e,"SheetsCellContentController",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SheetsNotePopupController",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"SheetsNotePopupService",{enumerable:!0,get:function(){return b}}),e.SheetsNoteUIMenuSchema=D,Object.defineProperty(e,"UniverSheetsNoteUIPlugin",{enumerable:!0,get:function(){return J}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-note"),require("rxjs"),require("@univerjs/sheets-ui"),require("rxjs/operators"),require("@univerjs/ui"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-note`,`rxjs`,`@univerjs/sheets-ui`,`rxjs/operators`,`@univerjs/ui`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNoteUi={},e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsNote,e.rxjs,e.UniverSheetsUi,e.rxjs.operators,e.UniverUi,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function f(e,t){return function(n,r){t(n,r,e)}}function p(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 m=class extends t.Disposable{constructor(e,t,n,r){super(),this._sheetInterceptorService=e,this._sheetsNoteModel=t,this._renderManagerService=n,this._univerInstanceService=r,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let{row:r,col:i,unitId:a,subUnitId:o}=t;return this._sheetsNoteModel.getNote(a,o,{row:r,col:i})?((!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,tr:{color:`#FFBD37`,size:6}},n(e)):n(e)},priority:100}))}_initSkeletonChange(){let e=()=>{var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=n.getUnitId(),i=this._renderManagerService.getRenderUnitById(r);i==null||(e=i.mainComponent)==null||e.makeForceDirty()};this.disposeWithMe(this._sheetsNoteModel.change$.pipe((0,a.debounceTime)(16)).subscribe(()=>{e()}))}};m=p([f(0,(0,t.Inject)(r.SheetInterceptorService)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,n.IRenderManagerService),f(3,t.IUniverInstanceService)],m);let h=`SHEET_NOTE_COMPONENT`;function g(e){"@babel/helpers - typeof";return g=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},g(e)}function _(e,t){if(g(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(g(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function v(e){var t=_(e,`string`);return g(t)==`symbol`?t:t+``}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let b=class extends t.Disposable{get activePopup(){return this._activePopup}constructor(e){super(),this._cellPopupManagerService=e,y(this,`_lastPopup`,null),y(this,`_activePopup`,void 0),y(this,`_activePopup$`,new a.BehaviorSubject(null)),y(this,`activePopup$`,this._activePopup$.asObservable()),this.disposeWithMe(()=>{this._activePopup$.complete()})}dispose(){super.dispose(),this.hidePopup()}showPopup(e,n){var r;let{row:i,col:a,unitId:o,subUnitId:s}=e;if(this._activePopup&&i===this._activePopup.row&&a===this._activePopup.col&&o===this._activePopup.unitId&&s===((r=this.activePopup)==null?void 0:r.subUnitId)){this._activePopup=e,this._activePopup$.next(e);return}this._lastPopup&&this._lastPopup.dispose(),this._activePopup=e,this._activePopup$.next(e);let c=this._cellPopupManagerService.showPopup({unitId:o,subUnitId:s,row:i,col:a},{componentKey:h,onClickOutside:()=>{this.hidePopup()},direction:`horizontal`,extraProps:{location:e},priority:3});if(!c)throw Error(`[SheetsNotePopupService]: cannot show popup!`);let l=new t.DisposableCollection;l.add(c),l.add({dispose:()=>{n==null||n()}}),this._lastPopup=l}hidePopup(e){this._activePopup&&(!e&&!this._activePopup.temp||(this._lastPopup&&this._lastPopup.dispose(),this._lastPopup=null,this._activePopup=null,this._activePopup$.next(null)))}persistPopup(){!this._activePopup||!this._activePopup.temp||(this._activePopup={...this._activePopup,temp:!1},this._activePopup$.next(this._activePopup))}};b=p([f(0,(0,t.Inject)(o.CellPopupManagerService))],b);let x=class extends t.Disposable{constructor(e,n,r,i){super(),this._sheetsNoteModel=e,this._univerInstanceService=n,this._cellPopupManagerService=r,this._sheetsNotePopupService=i,y(this,`_noteMatrix`,new t.ObjectMatrix),y(this,`_suppressedUnitIds`,new Set),y(this,`_activeUnitId`,null),y(this,`_activeSheetId`,null),y(this,`_noteChangeSubscription`,null),this._initNoteChangeListener()}_showPopup(e,t,n,r){return this._sheetsNotePopupService.hidePopup(!0),this._cellPopupManagerService.showPopup({unitId:e,subUnitId:t,row:n,col:r},{componentKey:h,direction:`horizontal`,extraProps:{location:{unitId:e,subUnitId:t,row:n,col:r}},priority:3})}dispose(){var e;super.dispose(),this._clearNoteMatrix(),this._suppressedUnitIds.clear(),this._activeUnitId=null,this._activeSheetId=null,(e=this._noteChangeSubscription)==null||e.unsubscribe(),this._noteChangeSubscription=null}setPopupSuppressed(e,t){t?this._suppressedUnitIds.add(e):this._suppressedUnitIds.delete(e),!(e!==this._activeUnitId||!this._activeSheetId)&&(t?this._clearNoteMatrix():this._showPersistentNotes(e,this._activeSheetId))}_initSheet(e,t){this._clearNoteMatrix(),this._activeUnitId=e,this._activeSheetId=t;let n=(e,t,n,r,i)=>{let a=this._noteMatrix,o=a.getValue(n,r);if(i!=null&&i.show){if(this._suppressedUnitIds.has(e)){o==null||o.dispose(),a.realDeleteValue(n,r);return}if(!o){let i=this._showPopup(e,t,n,r);i&&a.setValue(n,r,i)}}else o&&(o.dispose(),a.realDeleteValue(n,r))};return this._suppressedUnitIds.has(e)||this._showPersistentNotes(e,t),this._sheetsNoteModel.change$.subscribe(r=>{if(r.unitId===e&&r.subUnitId===t)switch(r.type){case`ref`:{let{unitId:e,subUnitId:t,oldNote:i,newNote:a}=r;if(!a.show)return;let o=this._noteMatrix,{row:s,col:c}=i,{row:l,col:u}=a,d=o.getValue(s,c);d&&(d.dispose(),o.realDeleteValue(s,c)),n(e,t,l,u,a);break}case`update`:{let{unitId:e,subUnitId:t,oldNote:i,newNote:a}=r,o=a?a.row:i.row,s=a?a.col:i.col;n(e,t,o,s,a);break}default:break}})}_initNoteChangeListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>(e==null?void 0:e.activeSheet$)??(0,a.of)(null))).subscribe(e=>{var t;(t=this._noteChangeSubscription)==null||t.unsubscribe(),this._noteChangeSubscription=null,e?this._noteChangeSubscription=this._initSheet(e.getUnitId(),e.getSheetId()):(this._clearNoteMatrix(),this._activeUnitId=null,this._activeSheetId=null)}))}_showPersistentNotes(e,t){var n;(n=this._sheetsNoteModel.getSheetNotes(e,t))==null||n.forEach(n=>{if(!n.show||this._noteMatrix.getValue(n.row,n.col))return;let r=this._showPopup(e,t,n.row,n.col);r&&this._noteMatrix.setValue(n.row,n.col,r)})}_clearNoteMatrix(){this._noteMatrix.forValue((e,t,n)=>{n.dispose()}),this._noteMatrix=new t.ObjectMatrix}};x=p([f(0,(0,t.Inject)(i.SheetsNoteModel)),f(1,(0,t.Inject)(t.IUniverInstanceService)),f(2,(0,t.Inject)(o.CellPopupManagerService)),f(3,(0,t.Inject)(b))],x);let S=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetsNotePopupService=e,this._sheetsNoteModel=t,this._sheetSelectionService=n,this._editorBridgeService=r,this._renderManagerService=i,this._hoverManagerService=a,y(this,`_isSwitchingSheet`,!1),this._initSelectionUpdateListener(),this._initEditorBridge(),this._initHoverEvent(),this._initDeleteNoteListener()}_handleSelectionChange(e,n,r){var i,a;let s=(i=e[0])==null?void 0:i.range,c=this._renderManagerService.getRenderUnitById(n),l=c==null||(a=c.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:a.skeleton;if(!l||!s)return;let u=l.getCellWithCoordByIndex(s.startRow,s.startColumn);if(((s.rangeType??t.RANGE_TYPE.NORMAL)!==t.RANGE_TYPE.NORMAL||s.endColumn-s.startColumn>0||s.endRow-s.startRow>0)&&!((u.isMerged||u.isMergedMainCell)&&t.Rectangle.equals(u.mergeInfo,s))){this._sheetsNotePopupService.hidePopup();return}let d=u.actualRow,f=u.actualColumn,p=this._sheetsNoteModel.getNote(n,r,{row:d,col:f});p!=null&&p.show||(p?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:p.id,row:d,col:f}):this._sheetsNotePopupService.hidePopup(!0))}_initSelectionUpdateListener(){this.disposeWithMe(this._sheetSelectionService.selectionMoveEnd$.subscribe(e=>{if(this._isSwitchingSheet)return;let t=this._sheetSelectionService.currentSelectionParam;t&&this._handleSelectionChange(e,t.unitId,t.sheetId)}))}_initEditorBridge(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{e.visible&&this._sheetsNotePopupService.hidePopup(!0)}))}_initHoverEvent(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{var t;if(!(e!=null&&e.location))return;let{unitId:n,subUnitId:r,row:i,col:a}=e.location,s=this._renderManagerService.getRenderUnitById(n),c=s==null||(t=s.with(o.SheetSkeletonManagerService).getSkeletonParam(r))==null?void 0:t.skeleton,l=i,u=a,d=this._sheetsNoteModel.getNote(n,r,{row:l,col:u});if(!d&&c){let{startRow:e,endRow:t,startColumn:o,endColumn:s}=c.getCellWithCoordByIndex(i,a).mergeInfo;if(e!==t||o!==s){let i=this._sheetsNoteModel.getSheetNotes(n,r);if(i){for(let[n,r]of i)if(r.row>=e&&r.row<=t&&r.col>=o&&r.col<=s){d=r,l=r.row,u=r.col;break}}}}d!=null&&d.show||(d?this._sheetsNotePopupService.showPopup({unitId:n,subUnitId:r,noteId:d.id,row:l,col:u,temp:!0}):this._sheetsNotePopupService.hidePopup())}))}_initDeleteNoteListener(){this.disposeWithMe(this._sheetsNoteModel.change$.subscribe(e=>{if(!this._sheetsNotePopupService.activePopup)return;let{unitId:t,subUnitId:n,noteId:r,row:i,col:a}=this._sheetsNotePopupService.activePopup,{oldNote:o,newNote:s}=e;s===null&&e.unitId===t&&e.subUnitId===n&&(o!=null&&o.id&&o.id===r||(o==null?void 0:o.row)===i&&o.col===a)&&this._sheetsNotePopupService.hidePopup(!0)}))}};S=p([f(0,(0,t.Inject)(b)),f(1,(0,t.Inject)(i.SheetsNoteModel)),f(2,(0,t.Inject)(r.SheetsSelectionsService)),f(3,o.IEditorBridgeService),f(4,n.IRenderManagerService),f(5,(0,t.Inject)(o.HoverManagerService))],S);let C={id:`sheet.operation.add-note-popup`,type:t.CommandType.OPERATION,handler:async(e,n)=>{let i=e.get(r.SheetsSelectionsService),a=e.get(b),o=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET);if(!o)return!1;let s=o.getActiveSheet(),c=i.getCurrentLastSelection();if(!(c!=null&&c.primary))return!1;let{primary:l}=c;return a.showPopup({unitId:o.getUnitId(),subUnitId:s.getSheetId(),row:l.actualRow,col:l.actualColumn,temp:!1,trigger:(n==null?void 0:n.trigger)??`add-note`}),!0}};function w(e){let n=e.get(r.SheetsSelectionsService),o=e.get(t.IUniverInstanceService);return n.selectionMoveEnd$.pipe((0,a.map)(()=>{let t=n.getCurrentLastSelection();if(!(t!=null&&t.primary))return!1;let a=(0,r.getSheetCommandTarget)(o);if(!a)return!1;let{actualColumn:s,actualRow:c}=t.primary;return!!e.get(i.SheetsNoteModel).getNote(a.unitId,a.subUnitId,{row:c,col:s})}))}function T(e){return{id:C.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.addNote`,icon:`AddNoteIcon`,hidden$:(0,a.combineLatest)([(0,c.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),w(e)]).pipe((0,a.map)(([e,t])=>e||t)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]}),commandId:C.id}}function E(e){return{id:i.SheetDeleteNoteCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.deleteNote`,icon:`DeleteNoteIcon`,hidden$:w(e).pipe((0,a.map)(e=>!e)),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetEditPermission]})}}function D(e){return{id:i.SheetToggleNotePopupCommand.id,type:c.MenuItemType.BUTTON,title:`sheets-note-ui.rightClick.toggleNote`,icon:`HideNoteIcon`,hidden$:w(e).pipe((0,a.map)(e=>!e))}}let O={[c.ContextMenuPosition.MAIN_AREA]:{[c.ContextMenuGroup.OTHERS]:{order:0,[C.id]:{order:0,menuItemFactory:T},[i.SheetDeleteNoteCommand.id]:{order:0,menuItemFactory:E},[i.SheetToggleNotePopupCommand.id]:{order:0,menuItemFactory:D}}}};var k=`@univerjs/sheets-note-ui`,A=`1.0.0-beta.2`;let j=`sheets-note-ui.config`,M={};function N({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(!(!n||!d.current||d.current.localName!==r.tag))return L(d.current)},[n,r]),P(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function P(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...F(e,n,i),...r},(I(e,n).children||[]).map((r,a)=>P(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function F(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function I(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function L(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:R(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(z(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function R(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function z(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}N.displayName=`UniverIcon`;let B={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.8813 14.4312V10.2925C10.8813 9.92522 11.1791 9.62745 11.5463 9.62745C11.9136 9.62745 12.2114 9.92522 12.2114 10.2925V14.4312C12.2112 14.7983 11.9135 15.0962 11.5463 15.0962C11.1791 15.0962 10.8814 14.7983 10.8813 14.4312Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47697 11.6968H11.5463H13.6156C13.9829 11.6968 14.2807 11.9946 14.2807 12.3618C14.2807 12.7291 13.9829 13.0269 13.6156 13.0269H9.47697C9.10981 13.0267 8.81193 12.729 8.81193 12.3618C8.81193 11.9946 9.10981 11.6969 9.47697 11.6968Z`}}]},V=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(N,Object.assign({},e,{id:`add-note-icon`,ref:t,icon:B}))});V.displayName=`AddNoteIcon`;let H={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.47489 11.6968H13.6175C13.9847 11.6968 14.2825 11.9946 14.2825 12.3618C14.2825 12.7291 13.9847 13.0269 13.6175 13.0269H9.47489C9.10762 13.0269 8.80985 12.7291 8.80985 12.3618C8.80985 11.9946 9.10762 11.6968 9.47489 11.6968Z`}}]},U=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(N,Object.assign({},e,{id:`delete-note-icon`,ref:t,icon:H}))});U.displayName=`DeleteNoteIcon`;let W={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.8481 8.00049V3.87451C12.8481 3.13737 12.2503 2.5398 11.5132 2.53955H4.48682C3.74952 2.53955 3.15186 3.13721 3.15186 3.87451V12.1255C3.15186 12.8628 3.74952 13.4604 4.48682 13.4604H6.99951L7.1333 13.4741C7.43655 13.536 7.66454 13.804 7.66455 14.1255C7.66455 14.447 7.43655 14.715 7.1333 14.7769L6.99951 14.7905H4.48682C3.01498 14.7905 1.82178 13.5973 1.82178 12.1255V3.87451C1.82178 2.40267 3.01498 1.20947 4.48682 1.20947H11.5132C12.9848 1.20972 14.1772 2.40283 14.1772 3.87451V8.00049C14.177 8.36738 13.8801 8.6643 13.5132 8.66455C13.1461 8.66455 12.8484 8.36754 12.8481 8.00049Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.1463 4.53859L10.2801 4.55226C10.5832 4.61419 10.8113 4.8822 10.8113 5.20363C10.8113 5.52506 10.5832 5.79306 10.2801 5.85499L10.1463 5.86867H5.85331C5.48604 5.86867 5.18827 5.5709 5.18827 5.20363C5.18827 4.83636 5.48604 4.53859 5.85331 4.53859H10.1463Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.11307 7.33497L8.24686 7.34865C8.54984 7.41069 8.77811 7.67869 8.77811 8.00001C8.77811 8.32134 8.54984 8.58933 8.24686 8.65138L8.11307 8.66505H5.85331C5.48604 8.66505 5.18827 8.36728 5.18827 8.00001C5.18827 7.63274 5.48604 7.33497 5.85331 7.33497H8.11307Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.98319 10.1314L7.11698 10.145C7.42003 10.207 7.64823 10.475 7.64823 10.7964C7.64823 11.1178 7.42003 11.3858 7.11698 11.4478L6.98319 11.4614H5.85331C5.48604 11.4614 5.18827 11.1637 5.18827 10.7964C5.18827 10.4291 5.48604 10.1314 5.85331 10.1314H6.98319Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.8743 12.6147C13.8742 12.5394 13.7749 12.2553 13.3909 11.9477C13.039 11.6659 12.5573 11.4614 12.0394 11.4614C11.5213 11.4614 11.0398 11.6666 10.6878 11.9487C10.3037 12.2565 10.2045 12.5399 10.2044 12.6147C10.2044 12.6893 10.3034 12.9737 10.6878 13.2817C11.0398 13.5636 11.5215 13.768 12.0394 13.768C12.5574 13.768 13.039 13.5635 13.3909 13.2817C13.7751 12.9739 13.8743 12.6897 13.8743 12.6147ZM15.2044 12.6147C15.2044 13.2772 14.7436 13.9027 14.223 14.3198C13.6701 14.7627 12.9019 15.0981 12.0394 15.0981C11.1768 15.0981 10.4085 14.7627 9.85577 14.3198C9.33533 13.9027 8.87433 13.2769 8.87433 12.6147C8.8744 11.9526 9.33541 11.3276 9.85577 10.9106C10.4086 10.4676 11.1767 10.1313 12.0394 10.1313C12.9018 10.1313 13.6701 10.4668 14.223 10.9096C14.7435 11.3267 15.2043 11.9523 15.2044 12.6147Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.0394 13.299C12.4172 13.299 12.7234 12.9927 12.7234 12.6149C12.7234 12.2371 12.4172 11.9308 12.0394 11.9308C11.6616 11.9308 11.3553 12.2371 11.3553 12.6149C11.3553 12.9927 11.6616 13.299 12.0394 13.299Z`}}]},G=(0,l.forwardRef)(function(e,t){return(0,l.createElement)(N,Object.assign({},e,{id:`hide-note-icon`,ref:t,icon:W}))});G.displayName=`HideNoteIcon`;let K=e=>{var t;let n=(t=e.popup.extraProps)==null?void 0:t.location;return n?(0,d.jsx)(q,{activePopup:n}):(console.error(`Popup extraProps or location is undefined.`),null)};function q({activePopup:e}){let r=(0,c.useDependency)(i.SheetsNoteModel),a=(0,c.useDependency)(t.LocaleService),o=(0,c.useDependency)(n.IRenderManagerService),s=(0,c.useDependency)(b),f=(0,c.useConfigValue)(j),p=(0,l.useRef)(null),m=(0,l.useRef)(null),h=o.getRenderUnitById(e.unitId),[g,_]=(0,l.useState)(null),v=(0,l.useCallback)(e=>{let t=p.current;if(t)if(a.getDirection()===`rtl`&&m.current!=null){let n=m.current-e;t.style.transform=n?`translateX(${n}px)`:``}else t.style.transform=``},[a]);(0,l.useEffect)(()=>{var n,i;let{unitId:a,subUnitId:o,row:s,col:c}=e,l=r.getNote(a,o,{row:s,col:c}),u=(l==null?void 0:l.width)??(f==null||(n=f.defaultNoteSize)==null?void 0:n.width)??160,d=(l==null?void 0:l.height)??(f==null||(i=f.defaultNoteSize)==null?void 0:i.height)??72;if(l)_(l);else{let e={id:(0,t.generateRandomId)(6),width:u,height:d,note:``};_(e),x(e)}p.current&&(m.current=u,p.current.style.width=`${u}px`,p.current.style.height=`${d}px`,p.current.style.transform=``)},[e,p]),(0,l.useEffect)(()=>{if(!e||e.temp||!e.trigger||!p.current)return;let t=requestAnimationFrame(()=>{var e;(e=p.current)==null||e.focus()});return()=>cancelAnimationFrame(t)},[e]);let y=(0,c.useDependency)(t.ICommandService),x=(0,c.useDebounceFn)(t=>{if(!e)return;let{unitId:n,subUnitId:a,row:o,col:c}=e;if(!y.syncExecuteCommand(i.SheetUpdateNoteCommand.id,{unitId:n,sheetId:a,row:o,col:c,note:t})){let e=r.getNote(n,a,{noteId:t.id,row:o,col:c});e?_(e):s.hidePopup(!0)}}),S=(0,l.useCallback)(e=>{if(!g||e===g.note)return;let t={...g,note:e};_(t),x(t)},[g]),C=(0,l.useCallback)((e,t)=>{if(!g||(v(e),e===g.width&&t===g.height))return;let n={...g,width:e,height:t};_(n),x(n)},[v,g]);return(0,d.jsx)(u.Textarea,{ref:p,"data-u-comp":`note-textarea`,className:(0,u.clsx)(`univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-gray-0 !univer-text-sm univer-shadow dark:!univer-bg-gray-800`),value:g==null?void 0:g.note,placeholder:a.t(`sheets-note-ui.note.placeholder`),onResize:C,onValueChange:S,onWheel:e=>{document.activeElement!==p.current&&h.engine.getCanvasElement().dispatchEvent(new WheelEvent(e.type,e.nativeEvent))}})}let J=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[h,K]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddNoteIcon:V,DeleteNoteIcon:U,HideNoteIcon:G}))}};J=p([f(0,(0,t.Inject)(c.ComponentManager)),f(1,(0,t.Inject)(c.IconManager))],J);let Y=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._commandService=t,this._initMenu(),this._initCommands()}_initMenu(){this._menuManagerService.mergeMenu(O)}_initCommands(){this._commandService.registerCommand(C)}};Y=p([f(0,(0,t.Inject)(c.IMenuManagerService)),f(1,t.ICommandService)],Y);let X=class extends t.Plugin{constructor(e=M,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},M,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(j,a)}onStarting(){this._injector.add([J]),this._injector.get(J),[[b],[m],[S],[Y],[x]].forEach(e=>{this._injector.add(e)})}onReady(){(0,t.touchDependencies)(this._injector,[[Y],[m]])}onRendered(){(0,t.touchDependencies)(this._injector,[[S],[x]])}};y(X,`pluginName`,`SHEET_NOTE_UI_PLUGIN`),y(X,`packageName`,k),y(X,`version`,A),y(X,`type`,t.UniverInstanceType.UNIVER_SHEET),X=p([(0,t.DependentOn)(n.UniverRenderEnginePlugin,r.UniverSheetsPlugin,i.UniverSheetsNotePlugin,o.UniverSheetsUIPlugin),f(1,(0,t.Inject)(t.Injector)),f(2,t.IConfigService)],X),Object.defineProperty(e,"SheetsCellContentController",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SheetsNoteAttachmentController",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"SheetsNotePopupController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SheetsNotePopupService",{enumerable:!0,get:function(){return b}}),e.SheetsNoteUIMenuSchema=O,Object.defineProperty(e,"UniverSheetsNoteUIPlugin",{enumerable:!0,get:function(){return X}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-note-ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Cell note UI for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"rxjs": ">=7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@univerjs/icons": "1.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/sheets
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/ui": "1.0.0-beta.
|
|
66
|
-
"@univerjs/
|
|
59
|
+
"@univerjs/icons": "1.38.0",
|
|
60
|
+
"@univerjs/core": "1.0.0-beta.2",
|
|
61
|
+
"@univerjs/design": "1.0.0-beta.2",
|
|
62
|
+
"@univerjs/engine-render": "1.0.0-beta.2",
|
|
63
|
+
"@univerjs/sheets": "1.0.0-beta.2",
|
|
64
|
+
"@univerjs/sheets-note": "1.0.0-beta.2",
|
|
65
|
+
"@univerjs/sheets-ui": "1.0.0-beta.2",
|
|
66
|
+
"@univerjs/ui": "1.0.0-beta.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"postcss": "^8.5.25",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"tailwindcss": "3.4.18",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
74
|
"vitest": "^4.1.10",
|
|
75
|
-
"@univerjs-infra/shared": "1.0.0-beta.
|
|
75
|
+
"@univerjs-infra/shared": "1.0.0-beta.2"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"test": "vitest run",
|