@univerjs/sheets-note-ui 1.0.0-insiders.20260813-7c9aa50 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +0 -1
- package/lib/cjs/index.js +151 -119
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/index.js +146 -120
- package/lib/index.css +2 -2
- package/lib/index.js +146 -120
- package/lib/types/controllers/sheets-note-attachment.controller.d.ts +7 -0
- package/lib/types/controllers/sheets-note-ui.controller.d.ts +26 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +12 -12
package/lib/es/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Textarea, clsx } from "@univerjs/design";
|
|
|
11
11
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
12
12
|
import { jsx } from "react/jsx-runtime";
|
|
13
13
|
|
|
14
|
-
//#region \0@oxc-project+runtime@0.
|
|
14
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
15
15
|
function __decorateParam(paramIndex, decorator) {
|
|
16
16
|
return function(target, key) {
|
|
17
17
|
decorator(target, key, paramIndex);
|
|
@@ -19,7 +19,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region \0@oxc-project+runtime@0.
|
|
22
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
23
23
|
function __decorate(decorators, target, key, desc) {
|
|
24
24
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
25
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -104,7 +104,7 @@ SheetsCellContentController = __decorate([
|
|
|
104
104
|
const SHEET_NOTE_COMPONENT = "SHEET_NOTE_COMPONENT";
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region \0@oxc-project+runtime@0.
|
|
107
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
108
108
|
function _typeof(o) {
|
|
109
109
|
"@babel/helpers - typeof";
|
|
110
110
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -115,7 +115,7 @@ function _typeof(o) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
//#endregion
|
|
118
|
-
//#region \0@oxc-project+runtime@0.
|
|
118
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
119
119
|
function toPrimitive(t, r) {
|
|
120
120
|
if ("object" != _typeof(t) || !t) return t;
|
|
121
121
|
var e = t[Symbol.toPrimitive];
|
|
@@ -128,14 +128,14 @@ function toPrimitive(t, r) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region \0@oxc-project+runtime@0.
|
|
131
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
132
132
|
function toPropertyKey(t) {
|
|
133
133
|
var i = toPrimitive(t, "string");
|
|
134
134
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
//#endregion
|
|
138
|
-
//#region \0@oxc-project+runtime@0.
|
|
138
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
139
139
|
function _defineProperty(e, r, t) {
|
|
140
140
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
141
141
|
value: t,
|
|
@@ -218,6 +218,143 @@ 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
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
_initNoteChangeListener() {
|
|
324
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe((sheet) => {
|
|
325
|
+
var _this$_noteChangeSubs2;
|
|
326
|
+
(_this$_noteChangeSubs2 = this._noteChangeSubscription) === null || _this$_noteChangeSubs2 === void 0 || _this$_noteChangeSubs2.unsubscribe();
|
|
327
|
+
this._noteChangeSubscription = null;
|
|
328
|
+
if (sheet) this._noteChangeSubscription = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
329
|
+
else {
|
|
330
|
+
this._clearNoteMatrix();
|
|
331
|
+
this._activeUnitId = null;
|
|
332
|
+
this._activeSheetId = null;
|
|
333
|
+
}
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
_showPersistentNotes(unitId, sheetId) {
|
|
337
|
+
var _this$_sheetsNoteMode;
|
|
338
|
+
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(unitId, sheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
339
|
+
if (!note.show || this._noteMatrix.getValue(note.row, note.col)) return;
|
|
340
|
+
const disposable = this._showPopup(unitId, sheetId, note.row, note.col);
|
|
341
|
+
if (disposable) this._noteMatrix.setValue(note.row, note.col, disposable);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
_clearNoteMatrix() {
|
|
345
|
+
this._noteMatrix.forValue((_, __, disposable) => {
|
|
346
|
+
disposable.dispose();
|
|
347
|
+
});
|
|
348
|
+
this._noteMatrix = new ObjectMatrix();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
SheetsNoteAttachmentController = __decorate([
|
|
352
|
+
__decorateParam(0, Inject(SheetsNoteModel)),
|
|
353
|
+
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
354
|
+
__decorateParam(2, Inject(CellPopupManagerService)),
|
|
355
|
+
__decorateParam(3, Inject(SheetsNotePopupService))
|
|
356
|
+
], SheetsNoteAttachmentController);
|
|
357
|
+
|
|
221
358
|
//#endregion
|
|
222
359
|
//#region src/controllers/sheets-note-popup.controller.ts
|
|
223
360
|
let SheetsNotePopupController = class SheetsNotePopupController extends Disposable {
|
|
@@ -435,7 +572,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
435
572
|
//#endregion
|
|
436
573
|
//#region package.json
|
|
437
574
|
var name = "@univerjs/sheets-note-ui";
|
|
438
|
-
var version = "1.0.0
|
|
575
|
+
var version = "1.0.0";
|
|
439
576
|
|
|
440
577
|
//#endregion
|
|
441
578
|
//#region src/config/config.ts
|
|
@@ -552,7 +689,7 @@ function SheetsNoteContent({ activePopup }) {
|
|
|
552
689
|
return /* @__PURE__ */ jsx(Textarea, {
|
|
553
690
|
ref: textareaRef,
|
|
554
691
|
"data-u-comp": "note-textarea",
|
|
555
|
-
className: clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-
|
|
692
|
+
className: 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"),
|
|
556
693
|
value: note === null || note === void 0 ? void 0 : note.note,
|
|
557
694
|
placeholder: localeService.t("sheets-note-ui.note.placeholder"),
|
|
558
695
|
onResize: handleResize,
|
|
@@ -603,117 +740,6 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
603
740
|
};
|
|
604
741
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
605
742
|
|
|
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
743
|
//#endregion
|
|
718
744
|
//#region src/controllers/ui.controller.ts
|
|
719
745
|
/**
|
|
@@ -791,4 +817,4 @@ UniverSheetsNoteUIPlugin = __decorate([
|
|
|
791
817
|
], UniverSheetsNoteUIPlugin);
|
|
792
818
|
|
|
793
819
|
//#endregion
|
|
794
|
-
export { SheetsCellContentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
|
820
|
+
export { SheetsCellContentController, SheetsNoteAttachmentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
package/lib/index.css
CHANGED
package/lib/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Textarea, clsx } from "@univerjs/design";
|
|
|
11
11
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
12
12
|
import { jsx } from "react/jsx-runtime";
|
|
13
13
|
|
|
14
|
-
//#region \0@oxc-project+runtime@0.
|
|
14
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
15
15
|
function __decorateParam(paramIndex, decorator) {
|
|
16
16
|
return function(target, key) {
|
|
17
17
|
decorator(target, key, paramIndex);
|
|
@@ -19,7 +19,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region \0@oxc-project+runtime@0.
|
|
22
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
23
23
|
function __decorate(decorators, target, key, desc) {
|
|
24
24
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
25
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -104,7 +104,7 @@ SheetsCellContentController = __decorate([
|
|
|
104
104
|
const SHEET_NOTE_COMPONENT = "SHEET_NOTE_COMPONENT";
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
//#region \0@oxc-project+runtime@0.
|
|
107
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
108
108
|
function _typeof(o) {
|
|
109
109
|
"@babel/helpers - typeof";
|
|
110
110
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -115,7 +115,7 @@ function _typeof(o) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
//#endregion
|
|
118
|
-
//#region \0@oxc-project+runtime@0.
|
|
118
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
119
119
|
function toPrimitive(t, r) {
|
|
120
120
|
if ("object" != _typeof(t) || !t) return t;
|
|
121
121
|
var e = t[Symbol.toPrimitive];
|
|
@@ -128,14 +128,14 @@ function toPrimitive(t, r) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
//#endregion
|
|
131
|
-
//#region \0@oxc-project+runtime@0.
|
|
131
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
132
132
|
function toPropertyKey(t) {
|
|
133
133
|
var i = toPrimitive(t, "string");
|
|
134
134
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
//#endregion
|
|
138
|
-
//#region \0@oxc-project+runtime@0.
|
|
138
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
139
139
|
function _defineProperty(e, r, t) {
|
|
140
140
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
141
141
|
value: t,
|
|
@@ -218,6 +218,143 @@ 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
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
_initNoteChangeListener() {
|
|
324
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe((sheet) => {
|
|
325
|
+
var _this$_noteChangeSubs2;
|
|
326
|
+
(_this$_noteChangeSubs2 = this._noteChangeSubscription) === null || _this$_noteChangeSubs2 === void 0 || _this$_noteChangeSubs2.unsubscribe();
|
|
327
|
+
this._noteChangeSubscription = null;
|
|
328
|
+
if (sheet) this._noteChangeSubscription = this._initSheet(sheet.getUnitId(), sheet.getSheetId());
|
|
329
|
+
else {
|
|
330
|
+
this._clearNoteMatrix();
|
|
331
|
+
this._activeUnitId = null;
|
|
332
|
+
this._activeSheetId = null;
|
|
333
|
+
}
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
_showPersistentNotes(unitId, sheetId) {
|
|
337
|
+
var _this$_sheetsNoteMode;
|
|
338
|
+
(_this$_sheetsNoteMode = this._sheetsNoteModel.getSheetNotes(unitId, sheetId)) === null || _this$_sheetsNoteMode === void 0 || _this$_sheetsNoteMode.forEach((note) => {
|
|
339
|
+
if (!note.show || this._noteMatrix.getValue(note.row, note.col)) return;
|
|
340
|
+
const disposable = this._showPopup(unitId, sheetId, note.row, note.col);
|
|
341
|
+
if (disposable) this._noteMatrix.setValue(note.row, note.col, disposable);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
_clearNoteMatrix() {
|
|
345
|
+
this._noteMatrix.forValue((_, __, disposable) => {
|
|
346
|
+
disposable.dispose();
|
|
347
|
+
});
|
|
348
|
+
this._noteMatrix = new ObjectMatrix();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
SheetsNoteAttachmentController = __decorate([
|
|
352
|
+
__decorateParam(0, Inject(SheetsNoteModel)),
|
|
353
|
+
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
354
|
+
__decorateParam(2, Inject(CellPopupManagerService)),
|
|
355
|
+
__decorateParam(3, Inject(SheetsNotePopupService))
|
|
356
|
+
], SheetsNoteAttachmentController);
|
|
357
|
+
|
|
221
358
|
//#endregion
|
|
222
359
|
//#region src/controllers/sheets-note-popup.controller.ts
|
|
223
360
|
let SheetsNotePopupController = class SheetsNotePopupController extends Disposable {
|
|
@@ -435,7 +572,7 @@ const menuSchema = { [ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.OTHERS
|
|
|
435
572
|
//#endregion
|
|
436
573
|
//#region package.json
|
|
437
574
|
var name = "@univerjs/sheets-note-ui";
|
|
438
|
-
var version = "1.0.0
|
|
575
|
+
var version = "1.0.0";
|
|
439
576
|
|
|
440
577
|
//#endregion
|
|
441
578
|
//#region src/config/config.ts
|
|
@@ -552,7 +689,7 @@ function SheetsNoteContent({ activePopup }) {
|
|
|
552
689
|
return /* @__PURE__ */ jsx(Textarea, {
|
|
553
690
|
ref: textareaRef,
|
|
554
691
|
"data-u-comp": "note-textarea",
|
|
555
|
-
className: clsx("univer-ml-px univer-min-h-1 univer-min-w-1 univer-bg-
|
|
692
|
+
className: 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"),
|
|
556
693
|
value: note === null || note === void 0 ? void 0 : note.note,
|
|
557
694
|
placeholder: localeService.t("sheets-note-ui.note.placeholder"),
|
|
558
695
|
onResize: handleResize,
|
|
@@ -603,117 +740,6 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
603
740
|
};
|
|
604
741
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
605
742
|
|
|
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
743
|
//#endregion
|
|
718
744
|
//#region src/controllers/ui.controller.ts
|
|
719
745
|
/**
|
|
@@ -791,4 +817,4 @@ UniverSheetsNoteUIPlugin = __decorate([
|
|
|
791
817
|
], UniverSheetsNoteUIPlugin);
|
|
792
818
|
|
|
793
819
|
//#endregion
|
|
794
|
-
export { SheetsCellContentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|
|
820
|
+
export { SheetsCellContentController, SheetsNoteAttachmentController, SheetsNotePopupController, SheetsNotePopupService, menuSchema as SheetsNoteUIMenuSchema, UniverSheetsNoteUIPlugin };
|