@univerjs/sheets-note 1.5.2 → 1.6.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.
Files changed (111) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/facade.js +45 -14
  3. package/lib/cjs/index.js +95 -31
  4. package/lib/cjs/locale/ar-SA.js +4 -0
  5. package/lib/cjs/locale/ca-ES.js +4 -0
  6. package/lib/cjs/locale/de-DE.js +4 -0
  7. package/lib/cjs/locale/en-US.js +19 -0
  8. package/lib/cjs/locale/es-ES.js +4 -0
  9. package/lib/cjs/locale/fa-IR.js +4 -0
  10. package/lib/cjs/locale/fr-FR.js +4 -0
  11. package/lib/cjs/locale/id-ID.js +4 -0
  12. package/lib/cjs/locale/it-IT.js +4 -0
  13. package/lib/cjs/locale/ja-JP.js +4 -0
  14. package/lib/cjs/locale/ko-KR.js +4 -0
  15. package/lib/cjs/locale/pl-PL.js +4 -0
  16. package/lib/cjs/locale/pt-BR.js +4 -0
  17. package/lib/cjs/locale/ru-RU.js +4 -0
  18. package/lib/cjs/locale/sk-SK.js +4 -0
  19. package/lib/cjs/locale/vi-VN.js +4 -0
  20. package/lib/cjs/locale/zh-CN.js +4 -0
  21. package/lib/cjs/locale/zh-HK.js +4 -0
  22. package/lib/cjs/locale/zh-TW.js +4 -0
  23. package/lib/es/facade.js +46 -15
  24. package/lib/es/index.js +97 -34
  25. package/lib/es/locale/ar-SA.js +4 -0
  26. package/lib/es/locale/ca-ES.js +4 -0
  27. package/lib/es/locale/de-DE.js +4 -0
  28. package/lib/es/locale/en-US.js +19 -0
  29. package/lib/es/locale/es-ES.js +4 -0
  30. package/lib/es/locale/fa-IR.js +4 -0
  31. package/lib/es/locale/fr-FR.js +4 -0
  32. package/lib/es/locale/id-ID.js +4 -0
  33. package/lib/es/locale/it-IT.js +4 -0
  34. package/lib/es/locale/ja-JP.js +4 -0
  35. package/lib/es/locale/ko-KR.js +4 -0
  36. package/lib/es/locale/pl-PL.js +4 -0
  37. package/lib/es/locale/pt-BR.js +4 -0
  38. package/lib/es/locale/ru-RU.js +4 -0
  39. package/lib/es/locale/sk-SK.js +4 -0
  40. package/lib/es/locale/vi-VN.js +4 -0
  41. package/lib/es/locale/zh-CN.js +4 -0
  42. package/lib/es/locale/zh-HK.js +4 -0
  43. package/lib/es/locale/zh-TW.js +4 -0
  44. package/lib/facade.js +46 -15
  45. package/lib/index.js +97 -34
  46. package/lib/locale/ar-SA.js +4 -0
  47. package/lib/locale/ca-ES.js +4 -0
  48. package/lib/locale/de-DE.js +4 -0
  49. package/lib/locale/en-US.js +19 -0
  50. package/lib/locale/es-ES.js +4 -0
  51. package/lib/locale/fa-IR.js +4 -0
  52. package/lib/locale/fr-FR.js +4 -0
  53. package/lib/locale/id-ID.js +4 -0
  54. package/lib/locale/it-IT.js +4 -0
  55. package/lib/locale/ja-JP.js +4 -0
  56. package/lib/locale/ko-KR.js +4 -0
  57. package/lib/locale/pl-PL.js +4 -0
  58. package/lib/locale/pt-BR.js +4 -0
  59. package/lib/locale/ru-RU.js +4 -0
  60. package/lib/locale/sk-SK.js +4 -0
  61. package/lib/locale/vi-VN.js +4 -0
  62. package/lib/locale/zh-CN.js +4 -0
  63. package/lib/locale/zh-HK.js +4 -0
  64. package/lib/locale/zh-TW.js +4 -0
  65. package/lib/types/commands/commands/note.command.d.ts +7 -1
  66. package/lib/types/const.d.ts +6 -0
  67. package/lib/types/controllers/sheets-note-permission.controller.d.ts +34 -0
  68. package/lib/types/index.d.ts +1 -0
  69. package/lib/types/locale/ar-SA.d.ts +18 -0
  70. package/lib/types/locale/ca-ES.d.ts +18 -0
  71. package/lib/types/locale/de-DE.d.ts +18 -0
  72. package/lib/types/locale/en-US.d.ts +23 -0
  73. package/lib/types/locale/es-ES.d.ts +18 -0
  74. package/lib/types/locale/fa-IR.d.ts +18 -0
  75. package/lib/types/locale/fr-FR.d.ts +18 -0
  76. package/lib/types/locale/id-ID.d.ts +18 -0
  77. package/lib/types/locale/it-IT.d.ts +18 -0
  78. package/lib/types/locale/ja-JP.d.ts +18 -0
  79. package/lib/types/locale/ko-KR.d.ts +18 -0
  80. package/lib/types/locale/pl-PL.d.ts +18 -0
  81. package/lib/types/locale/pt-BR.d.ts +18 -0
  82. package/lib/types/locale/ru-RU.d.ts +18 -0
  83. package/lib/types/locale/sk-SK.d.ts +18 -0
  84. package/lib/types/locale/types.d.ts +18 -0
  85. package/lib/types/locale/vi-VN.d.ts +18 -0
  86. package/lib/types/locale/zh-CN.d.ts +18 -0
  87. package/lib/types/locale/zh-HK.d.ts +18 -0
  88. package/lib/types/locale/zh-TW.d.ts +18 -0
  89. package/lib/types/plugin.d.ts +1 -1
  90. package/lib/umd/facade.js +1 -1
  91. package/lib/umd/index.js +1 -1
  92. package/lib/umd/locale/ar-SA.js +1 -0
  93. package/lib/umd/locale/ca-ES.js +1 -0
  94. package/lib/umd/locale/de-DE.js +1 -0
  95. package/lib/umd/locale/en-US.js +1 -0
  96. package/lib/umd/locale/es-ES.js +1 -0
  97. package/lib/umd/locale/fa-IR.js +1 -0
  98. package/lib/umd/locale/fr-FR.js +1 -0
  99. package/lib/umd/locale/id-ID.js +1 -0
  100. package/lib/umd/locale/it-IT.js +1 -0
  101. package/lib/umd/locale/ja-JP.js +1 -0
  102. package/lib/umd/locale/ko-KR.js +1 -0
  103. package/lib/umd/locale/pl-PL.js +1 -0
  104. package/lib/umd/locale/pt-BR.js +1 -0
  105. package/lib/umd/locale/ru-RU.js +1 -0
  106. package/lib/umd/locale/sk-SK.js +1 -0
  107. package/lib/umd/locale/vi-VN.js +1 -0
  108. package/lib/umd/locale/zh-CN.js +1 -0
  109. package/lib/umd/locale/zh-HK.js +1 -0
  110. package/lib/umd/locale/zh-TW.js +1 -0
  111. package/package.json +14 -9
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  | Package | UMD global | CSS | Locales | Facade entry | Worker entry |
12
12
  | --- | --- | :---: | :---: | :---: | :---: |
13
- | `@univerjs/sheets-note` | `UniverSheetsNote` | No | No | Yes | No |
13
+ | `@univerjs/sheets-note` | `UniverSheetsNote` | No | Yes | Yes | No |
14
14
 
15
15
  ## Installation
16
16
 
package/lib/cjs/facade.js CHANGED
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  let _univerjs_core_facade = require("@univerjs/core/facade");
3
+ let _univerjs_core = require("@univerjs/core");
3
4
  let _univerjs_sheets_note = require("@univerjs/sheets-note");
4
5
  let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
5
- let _univerjs_core = require("@univerjs/core");
6
6
  let _univerjs_sheets = require("@univerjs/sheets");
7
7
 
8
8
  // src/facade/f-event.ts
@@ -46,17 +46,33 @@ _univerjs_core_facade.FEventName.extend(FSheetsNoteEventNameMixin);
46
46
  // src/facade/f-range.ts
47
47
  var FRangeSheetsNoteMixin = class extends _univerjs_sheets_facade.FRange {
48
48
  createOrUpdateNote(note) {
49
- this._commandService.syncExecuteCommand(_univerjs_sheets_note.UpdateNoteMutation.id, {
50
- unitId: this.getUnitId(),
51
- sheetId: this.getSheetId(),
52
- row: this.getRow(),
53
- col: this.getColumn(),
54
- note
49
+ const unitId = this.getUnitId();
50
+ const sheetId = this.getSheetId();
51
+ const row = this.getRow();
52
+ const col = this.getColumn();
53
+ const oldNote = this._injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, sheetId, {
54
+ row,
55
+ col
56
+ });
57
+ this._commandService.syncExecuteCommand(_univerjs_sheets_note.SheetUpdateNoteCommand.id, {
58
+ unitId,
59
+ sheetId,
60
+ row,
61
+ col,
62
+ note: {
63
+ id: (oldNote === null || oldNote === void 0 ? void 0 : oldNote.id) ?? note.id ?? (0, _univerjs_core.generateRandomId)(6),
64
+ row,
65
+ col,
66
+ width: note.width,
67
+ height: note.height,
68
+ note: note.note,
69
+ show: note.show
70
+ }
55
71
  });
56
72
  return this;
57
73
  }
58
74
  deleteNote() {
59
- this._commandService.syncExecuteCommand(_univerjs_sheets_note.RemoveNoteMutation.id, {
75
+ this._commandService.syncExecuteCommand(_univerjs_sheets_note.SheetDeleteNoteCommand.id, {
60
76
  unitId: this.getUnitId(),
61
77
  sheetId: this.getSheetId(),
62
78
  row: this.getRow(),
@@ -184,7 +200,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
184
200
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
185
201
  if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
186
202
  const params = command.params;
187
- const target = this.getSheetCommandTarget(params);
203
+ const target = this.getSheetCommandTarget({
204
+ unitId: params.unitId,
205
+ subUnitId: params.sheetId
206
+ });
188
207
  if (!target) return;
189
208
  const { workbook, worksheet, unitId, subUnitId } = target;
190
209
  const { row, col, note } = params;
@@ -205,12 +224,21 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
205
224
  })));
206
225
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
207
226
  if (command.id === _univerjs_sheets_note.SheetDeleteNoteCommand.id) {
208
- const target = this.getSheetCommandTarget();
227
+ const params = command.params;
228
+ const target = this.getSheetCommandTarget(params ? {
229
+ unitId: params.unitId,
230
+ subUnitId: params.sheetId
231
+ } : {});
209
232
  if (!target) return;
210
- const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
211
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
212
233
  const { workbook, worksheet, unitId, subUnitId } = target;
213
- const { actualRow: row, actualColumn: col } = selection.primary;
234
+ let row;
235
+ let col;
236
+ if (params) ({row, col} = params);
237
+ else {
238
+ const selection = injector.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
239
+ if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
240
+ ({actualRow: row, actualColumn: col} = selection.primary);
241
+ }
214
242
  const oldNote = injector.get(_univerjs_sheets_note.SheetsNoteModel).getNote(unitId, subUnitId, {
215
243
  row,
216
244
  col
@@ -229,7 +257,10 @@ var FUniverSheetsNoteMixin = class extends _univerjs_core_facade.FUniver {
229
257
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
230
258
  if (command.id === _univerjs_sheets_note.SheetUpdateNoteCommand.id) {
231
259
  const params = command.params;
232
- const target = this.getSheetCommandTarget(params);
260
+ const target = this.getSheetCommandTarget({
261
+ unitId: params.unitId,
262
+ subUnitId: params.sheetId
263
+ });
233
264
  if (!target) return;
234
265
  const { workbook, worksheet, unitId, subUnitId } = target;
235
266
  const { row, col, note } = params;
package/lib/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ let _univerjs_core = require("@univerjs/core");
3
3
  let _univerjs_sheets = require("@univerjs/sheets");
4
4
  let rxjs = require("rxjs");
5
5
 
6
- // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
6
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -13,7 +13,7 @@ function _typeof(o) {
13
13
  }, _typeof(o);
14
14
  }
15
15
 
16
- // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
16
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
17
17
  function toPrimitive(t, e) {
18
18
  if ("object" != _typeof(t) || !t) return t;
19
19
  var r;
@@ -25,13 +25,13 @@ function toPrimitive(t, e) {
25
25
  return ("string" === e ? String : Number)(t);
26
26
  }
27
27
 
28
- // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
28
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
29
29
  function toPropertyKey(t) {
30
30
  var i = toPrimitive(t, "string");
31
31
  return "symbol" == _typeof(i) ? i : i + "";
32
32
  }
33
33
 
34
- // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
34
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
35
35
  function _defineProperty(e, r, t) {
36
36
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
37
37
  value: t,
@@ -284,15 +284,30 @@ const UpdateNotePositionMutation = {
284
284
  const SheetDeleteNoteCommand = {
285
285
  id: "sheet.command.delete-note",
286
286
  type: _univerjs_core.CommandType.COMMAND,
287
- handler: (accessor) => {
288
- const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService));
289
- if (!target) return false;
290
- const selection = accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
291
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return false;
292
- const sheetsNoteModel = accessor.get(SheetsNoteModel);
293
- const { unitId, subUnitId } = target;
294
- const { actualColumn, actualRow } = selection.primary;
295
- const note = sheetsNoteModel.getNote(unitId, subUnitId, {
287
+ handler: (accessor, params) => {
288
+ const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
289
+ let unitId;
290
+ let subUnitId;
291
+ let actualRow;
292
+ let actualColumn;
293
+ if (params) {
294
+ const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, {
295
+ unitId: params.unitId,
296
+ subUnitId: params.sheetId
297
+ });
298
+ if (!target) return false;
299
+ ({unitId, subUnitId} = target);
300
+ actualRow = params.row;
301
+ actualColumn = params.col;
302
+ } else {
303
+ const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
304
+ if (!target) return false;
305
+ const selection = accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
306
+ if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return false;
307
+ ({unitId, subUnitId} = target);
308
+ ({actualColumn, actualRow} = selection.primary);
309
+ }
310
+ const note = accessor.get(SheetsNoteModel).getNote(unitId, subUnitId, {
296
311
  row: actualRow,
297
312
  col: actualColumn
298
313
  });
@@ -377,7 +392,10 @@ const SheetUpdateNoteCommand = {
377
392
  id: "sheet.command.update-note",
378
393
  type: _univerjs_core.CommandType.COMMAND,
379
394
  handler: (accessor, params) => {
380
- const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService), params);
395
+ const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService), {
396
+ unitId: params.unitId,
397
+ subUnitId: params.sheetId
398
+ });
381
399
  if (!target) return false;
382
400
  const commandService = accessor.get(_univerjs_core.ICommandService);
383
401
  const undoRedoService = accessor.get(_univerjs_core.IUndoRedoService);
@@ -437,31 +455,27 @@ const SheetUpdateNoteCommand = {
437
455
  };
438
456
 
439
457
  // src/const.ts
458
+ const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
459
+ const SHEET_NOTE_TOGGLE_PERMISSIONS = {
460
+ workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
461
+ worksheetTypes: [_univerjs_sheets.WorksheetEditPermission]
462
+ };
440
463
  /**
441
- * Copyright 2023-present DreamNum Co., Ltd.
442
- *
443
- * Licensed under the Apache License, Version 2.0 (the "License");
444
- * you may not use this file except in compliance with the License.
445
- * You may obtain a copy of the License at
446
- *
447
- * http://www.apache.org/licenses/LICENSE-2.0
448
- *
449
- * Unless required by applicable law or agreed to in writing, software
450
- * distributed under the License is distributed on an "AS IS" BASIS,
451
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
452
- * See the License for the specific language governing permissions and
453
- * limitations under the License.
464
+ * Notes have no permission point of their own; they follow the cell edit points.
454
465
  */
455
- const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
466
+ const SHEET_NOTE_EDIT_PERMISSIONS = {
467
+ ...SHEET_NOTE_TOGGLE_PERMISSIONS,
468
+ rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
469
+ };
456
470
 
457
- // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
471
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
458
472
  function __decorateParam(paramIndex, decorator) {
459
473
  return function(target, key) {
460
474
  decorator(target, key, paramIndex);
461
475
  };
462
476
  }
463
477
 
464
- // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
478
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
465
479
  function __decorate(decorators, target, key, desc) {
466
480
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
467
481
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -627,7 +641,7 @@ SheetsNoteResourceController = __decorate([
627
641
 
628
642
  // package.json
629
643
  var name = "@univerjs/sheets-note";
630
- var version = "1.5.2";
644
+ var version = "1.6.0";
631
645
 
632
646
  // src/config/config.ts
633
647
  /**
@@ -649,6 +663,53 @@ const SHEETS_NOTE_PLUGIN_CONFIG_KEY = "sheets-note.config";
649
663
  const configSymbol = Symbol(SHEETS_NOTE_PLUGIN_CONFIG_KEY);
650
664
  const defaultPluginConfig = {};
651
665
 
666
+ // src/controllers/sheets-note-permission.controller.ts
667
+ let SheetsNotePermissionController = class SheetsNotePermissionController extends _univerjs_core.Disposable {
668
+ constructor(_commandService, _sheetPermissionCheckController, _noteModel, _localeService) {
669
+ super();
670
+ this._commandService = _commandService;
671
+ this._sheetPermissionCheckController = _sheetPermissionCheckController;
672
+ this._noteModel = _noteModel;
673
+ this._localeService = _localeService;
674
+ this._initCommandListener();
675
+ }
676
+ _initCommandListener() {
677
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
678
+ const { id } = command;
679
+ if (id === SheetUpdateNoteCommand.id) {
680
+ const params = command.params;
681
+ if (!params) return;
682
+ const { unitId, sheetId, row, col, note } = params;
683
+ const previous = this._noteModel.getNote(unitId, sheetId, { noteId: note.id });
684
+ const moving = previous && (previous.row !== row || previous.col !== col);
685
+ if (!this._checkCell(unitId, sheetId, row, col) || moving && !this._checkCell(unitId, sheetId, previous.row, previous.col)) this._blockExecute();
686
+ } else if (id === SheetDeleteNoteCommand.id) {
687
+ const params = command.params;
688
+ if (!(params ? this._checkCell(params.unitId, params.sheetId, params.row, params.col) : this._sheetPermissionCheckController.permissionCheckWithoutRange(SHEET_NOTE_EDIT_PERMISSIONS))) this._blockExecute();
689
+ } else if (id === SheetToggleNotePopupCommand.id) {
690
+ if (!this._sheetPermissionCheckController.permissionCheckWithoutRange(SHEET_NOTE_TOGGLE_PERMISSIONS)) this._blockExecute();
691
+ }
692
+ }));
693
+ }
694
+ _checkCell(unitId, sheetId, row, col) {
695
+ return this._sheetPermissionCheckController.permissionCheckWithRanges(SHEET_NOTE_EDIT_PERMISSIONS, [{
696
+ startRow: row,
697
+ startColumn: col,
698
+ endRow: row,
699
+ endColumn: col
700
+ }], unitId, sheetId);
701
+ }
702
+ _blockExecute() {
703
+ this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-note.permission.editErr"));
704
+ }
705
+ };
706
+ SheetsNotePermissionController = __decorate([
707
+ __decorateParam(0, _univerjs_core.ICommandService),
708
+ __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController)),
709
+ __decorateParam(2, (0, _univerjs_core.Inject)(SheetsNoteModel)),
710
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
711
+ ], SheetsNotePermissionController);
712
+
652
713
  // src/controllers/sheets-note-ref-range.controller.ts
653
714
  let SheetsNoteRefRangeController = class SheetsNoteRefRangeController extends _univerjs_core.Disposable {
654
715
  constructor(_refRangeService, _sheetsNoteModel, _selectionManagerService, _commandService) {
@@ -858,6 +919,7 @@ let UniverSheetsNotePlugin = class UniverSheetsNotePlugin extends _univerjs_core
858
919
  [
859
920
  [SheetsNoteModel],
860
921
  [SheetsNoteController],
922
+ [SheetsNotePermissionController],
861
923
  [SheetsNoteResourceController],
862
924
  [SheetsNoteRefRangeController]
863
925
  ].forEach((dependency) => {
@@ -866,6 +928,7 @@ let UniverSheetsNotePlugin = class UniverSheetsNotePlugin extends _univerjs_core
866
928
  (0, _univerjs_core.touchDependencies)(this._injector, [
867
929
  [SheetsNoteModel],
868
930
  [SheetsNoteController],
931
+ [SheetsNotePermissionController],
869
932
  [SheetsNoteResourceController]
870
933
  ]);
871
934
  }
@@ -884,6 +947,7 @@ UniverSheetsNotePlugin = __decorate([
884
947
  ], UniverSheetsNotePlugin);
885
948
 
886
949
  exports.RemoveNoteMutation = RemoveNoteMutation;
950
+ exports.SHEET_NOTE_EDIT_PERMISSIONS = SHEET_NOTE_EDIT_PERMISSIONS;
887
951
  exports.SheetDeleteNoteCommand = SheetDeleteNoteCommand;
888
952
  exports.SheetToggleNotePopupCommand = SheetToggleNotePopupCommand;
889
953
  exports.SheetUpdateNoteCommand = SheetUpdateNoteCommand;
@@ -0,0 +1,4 @@
1
+ // src/locale/ar-SA.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "ليس لديك إذن لتعديل الملاحظات." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/ca-ES.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "No teniu permís per editar les notes." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/de-DE.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Sie haben keine Berechtigung, Notizen zu bearbeiten." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,19 @@
1
+ // src/locale/en-US.ts
2
+ /**
3
+ * Copyright 2023-present DreamNum Co., Ltd.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ const locale = { "sheets-note": { permission: { editErr: "You do not have permission to edit notes." } } };
18
+
19
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/es-ES.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "No tienes permiso para editar las notas." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/fa-IR.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "شما اجازه ویرایش یادداشت‌ها را ندارید." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/fr-FR.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Vous n'avez pas la permission de modifier les notes." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/id-ID.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Anda tidak memiliki izin untuk mengedit catatan." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/it-IT.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Non hai il permesso di modificare le note." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/ja-JP.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "メモを編集する権限がありません。" } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/ko-KR.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "메모를 편집할 권한이 없습니다." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/pl-PL.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Nie masz uprawnień do edytowania notatek." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/pt-BR.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Você não tem permissão para editar notas." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/ru-RU.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "У вас нет разрешения на редактирование примечаний." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/sk-SK.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Nemáte povolenie upravovať poznámky." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/vi-VN.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "Bạn không có quyền chỉnh sửa ghi chú." } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/zh-CN.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "暂无编辑批注的权限。" } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/zh-HK.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "暫無編輯批註的權限。" } } };
3
+
4
+ module.exports = locale;
@@ -0,0 +1,4 @@
1
+ // src/locale/zh-TW.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "暫無編輯批註的權限。" } } };
3
+
4
+ module.exports = locale;
package/lib/es/facade.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FEventName, FUniver } from "@univerjs/core/facade";
2
- import { RemoveNoteMutation, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, UpdateNoteMutation } from "@univerjs/sheets-note";
2
+ import { CanceledError, ICommandService, generateRandomId } from "@univerjs/core";
3
+ import { SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel } from "@univerjs/sheets-note";
3
4
  import { FRange, FWorksheet } from "@univerjs/sheets/facade";
4
- import { CanceledError, ICommandService } from "@univerjs/core";
5
5
  import { SheetsSelectionsService } from "@univerjs/sheets";
6
6
 
7
7
  // src/facade/f-event.ts
@@ -45,17 +45,33 @@ FEventName.extend(FSheetsNoteEventNameMixin);
45
45
  // src/facade/f-range.ts
46
46
  var FRangeSheetsNoteMixin = class extends FRange {
47
47
  createOrUpdateNote(note) {
48
- this._commandService.syncExecuteCommand(UpdateNoteMutation.id, {
49
- unitId: this.getUnitId(),
50
- sheetId: this.getSheetId(),
51
- row: this.getRow(),
52
- col: this.getColumn(),
53
- note
48
+ const unitId = this.getUnitId();
49
+ const sheetId = this.getSheetId();
50
+ const row = this.getRow();
51
+ const col = this.getColumn();
52
+ const oldNote = this._injector.get(SheetsNoteModel).getNote(unitId, sheetId, {
53
+ row,
54
+ col
55
+ });
56
+ this._commandService.syncExecuteCommand(SheetUpdateNoteCommand.id, {
57
+ unitId,
58
+ sheetId,
59
+ row,
60
+ col,
61
+ note: {
62
+ id: (oldNote === null || oldNote === void 0 ? void 0 : oldNote.id) ?? note.id ?? generateRandomId(6),
63
+ row,
64
+ col,
65
+ width: note.width,
66
+ height: note.height,
67
+ note: note.note,
68
+ show: note.show
69
+ }
54
70
  });
55
71
  return this;
56
72
  }
57
73
  deleteNote() {
58
- this._commandService.syncExecuteCommand(RemoveNoteMutation.id, {
74
+ this._commandService.syncExecuteCommand(SheetDeleteNoteCommand.id, {
59
75
  unitId: this.getUnitId(),
60
76
  sheetId: this.getSheetId(),
61
77
  row: this.getRow(),
@@ -183,7 +199,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
183
199
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteAdd, () => commandService.beforeCommandExecuted((command) => {
184
200
  if (command.id === SheetUpdateNoteCommand.id) {
185
201
  const params = command.params;
186
- const target = this.getSheetCommandTarget(params);
202
+ const target = this.getSheetCommandTarget({
203
+ unitId: params.unitId,
204
+ subUnitId: params.sheetId
205
+ });
187
206
  if (!target) return;
188
207
  const { workbook, worksheet, unitId, subUnitId } = target;
189
208
  const { row, col, note } = params;
@@ -204,12 +223,21 @@ var FUniverSheetsNoteMixin = class extends FUniver {
204
223
  })));
205
224
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteDelete, () => commandService.beforeCommandExecuted((command) => {
206
225
  if (command.id === SheetDeleteNoteCommand.id) {
207
- const target = this.getSheetCommandTarget();
226
+ const params = command.params;
227
+ const target = this.getSheetCommandTarget(params ? {
228
+ unitId: params.unitId,
229
+ subUnitId: params.sheetId
230
+ } : {});
208
231
  if (!target) return;
209
- const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
210
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
211
232
  const { workbook, worksheet, unitId, subUnitId } = target;
212
- const { actualRow: row, actualColumn: col } = selection.primary;
233
+ let row;
234
+ let col;
235
+ if (params) ({row, col} = params);
236
+ else {
237
+ const selection = injector.get(SheetsSelectionsService).getCurrentLastSelection();
238
+ if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return;
239
+ ({actualRow: row, actualColumn: col} = selection.primary);
240
+ }
213
241
  const oldNote = injector.get(SheetsNoteModel).getNote(unitId, subUnitId, {
214
242
  row,
215
243
  col
@@ -228,7 +256,10 @@ var FUniverSheetsNoteMixin = class extends FUniver {
228
256
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNoteUpdate, () => commandService.beforeCommandExecuted((command) => {
229
257
  if (command.id === SheetUpdateNoteCommand.id) {
230
258
  const params = command.params;
231
- const target = this.getSheetCommandTarget(params);
259
+ const target = this.getSheetCommandTarget({
260
+ unitId: params.unitId,
261
+ subUnitId: params.sheetId
262
+ });
232
263
  if (!target) return;
233
264
  const { workbook, worksheet, unitId, subUnitId } = target;
234
265
  const { row, col, note } = params;