@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/lib/es/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { CommandType, DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, ObjectMatrix, Plugin, UniverInstanceType, generateRandomId, merge, sequenceExecuteAsync, touchDependencies } from "@univerjs/core";
2
- import { CopySheetCommand, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, getSheetCommandTarget, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
1
+ import { CommandType, DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LocaleService, ObjectMatrix, Plugin, UniverInstanceType, generateRandomId, merge, sequenceExecuteAsync, touchDependencies } from "@univerjs/core";
2
+ import { CopySheetCommand, RangeProtectionPermissionEditPoint, RefRangeService, RemoveSheetCommand, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, getSheetCommandTarget, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests } from "@univerjs/sheets";
3
3
  import { Subject, filter, map } from "rxjs";
4
4
 
5
- // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
5
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
6
6
  function _typeof(o) {
7
7
  "@babel/helpers - typeof";
8
8
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -12,7 +12,7 @@ function _typeof(o) {
12
12
  }, _typeof(o);
13
13
  }
14
14
 
15
- // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
15
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
16
16
  function toPrimitive(t, e) {
17
17
  if ("object" != _typeof(t) || !t) return t;
18
18
  var r;
@@ -24,13 +24,13 @@ function toPrimitive(t, e) {
24
24
  return ("string" === e ? String : Number)(t);
25
25
  }
26
26
 
27
- // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
27
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
28
28
  function toPropertyKey(t) {
29
29
  var i = toPrimitive(t, "string");
30
30
  return "symbol" == _typeof(i) ? i : i + "";
31
31
  }
32
32
 
33
- // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
33
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
34
34
  function _defineProperty(e, r, t) {
35
35
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
36
36
  value: t,
@@ -283,15 +283,30 @@ const UpdateNotePositionMutation = {
283
283
  const SheetDeleteNoteCommand = {
284
284
  id: "sheet.command.delete-note",
285
285
  type: CommandType.COMMAND,
286
- handler: (accessor) => {
287
- const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
288
- if (!target) return false;
289
- const selection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
290
- if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return false;
291
- const sheetsNoteModel = accessor.get(SheetsNoteModel);
292
- const { unitId, subUnitId } = target;
293
- const { actualColumn, actualRow } = selection.primary;
294
- const note = sheetsNoteModel.getNote(unitId, subUnitId, {
286
+ handler: (accessor, params) => {
287
+ const univerInstanceService = accessor.get(IUniverInstanceService);
288
+ let unitId;
289
+ let subUnitId;
290
+ let actualRow;
291
+ let actualColumn;
292
+ if (params) {
293
+ const target = getSheetCommandTarget(univerInstanceService, {
294
+ unitId: params.unitId,
295
+ subUnitId: params.sheetId
296
+ });
297
+ if (!target) return false;
298
+ ({unitId, subUnitId} = target);
299
+ actualRow = params.row;
300
+ actualColumn = params.col;
301
+ } else {
302
+ const target = getSheetCommandTarget(univerInstanceService);
303
+ if (!target) return false;
304
+ const selection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
305
+ if (!(selection === null || selection === void 0 ? void 0 : selection.primary)) return false;
306
+ ({unitId, subUnitId} = target);
307
+ ({actualColumn, actualRow} = selection.primary);
308
+ }
309
+ const note = accessor.get(SheetsNoteModel).getNote(unitId, subUnitId, {
295
310
  row: actualRow,
296
311
  col: actualColumn
297
312
  });
@@ -376,7 +391,10 @@ const SheetUpdateNoteCommand = {
376
391
  id: "sheet.command.update-note",
377
392
  type: CommandType.COMMAND,
378
393
  handler: (accessor, params) => {
379
- const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
394
+ const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), {
395
+ unitId: params.unitId,
396
+ subUnitId: params.sheetId
397
+ });
380
398
  if (!target) return false;
381
399
  const commandService = accessor.get(ICommandService);
382
400
  const undoRedoService = accessor.get(IUndoRedoService);
@@ -436,31 +454,27 @@ const SheetUpdateNoteCommand = {
436
454
  };
437
455
 
438
456
  // src/const.ts
457
+ const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
458
+ const SHEET_NOTE_TOGGLE_PERMISSIONS = {
459
+ workbookTypes: [WorkbookEditablePermission],
460
+ worksheetTypes: [WorksheetEditPermission]
461
+ };
439
462
  /**
440
- * Copyright 2023-present DreamNum Co., Ltd.
441
- *
442
- * Licensed under the Apache License, Version 2.0 (the "License");
443
- * you may not use this file except in compliance with the License.
444
- * You may obtain a copy of the License at
445
- *
446
- * http://www.apache.org/licenses/LICENSE-2.0
447
- *
448
- * Unless required by applicable law or agreed to in writing, software
449
- * distributed under the License is distributed on an "AS IS" BASIS,
450
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
451
- * See the License for the specific language governing permissions and
452
- * limitations under the License.
463
+ * Notes have no permission point of their own; they follow the cell edit points.
453
464
  */
454
- const PLUGIN_NAME = "SHEET_NOTE_PLUGIN";
465
+ const SHEET_NOTE_EDIT_PERMISSIONS = {
466
+ ...SHEET_NOTE_TOGGLE_PERMISSIONS,
467
+ rangeTypes: [RangeProtectionPermissionEditPoint]
468
+ };
455
469
 
456
- // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
470
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/decorateParam.js
457
471
  function __decorateParam(paramIndex, decorator) {
458
472
  return function(target, key) {
459
473
  decorator(target, key, paramIndex);
460
474
  };
461
475
  }
462
476
 
463
- // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
477
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/decorate.js
464
478
  function __decorate(decorators, target, key, desc) {
465
479
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
466
480
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -626,7 +640,7 @@ SheetsNoteResourceController = __decorate([
626
640
 
627
641
  // package.json
628
642
  var name = "@univerjs/sheets-note";
629
- var version = "1.5.2";
643
+ var version = "1.6.0";
630
644
 
631
645
  // src/config/config.ts
632
646
  /**
@@ -648,6 +662,53 @@ const SHEETS_NOTE_PLUGIN_CONFIG_KEY = "sheets-note.config";
648
662
  const configSymbol = Symbol(SHEETS_NOTE_PLUGIN_CONFIG_KEY);
649
663
  const defaultPluginConfig = {};
650
664
 
665
+ // src/controllers/sheets-note-permission.controller.ts
666
+ let SheetsNotePermissionController = class SheetsNotePermissionController extends Disposable {
667
+ constructor(_commandService, _sheetPermissionCheckController, _noteModel, _localeService) {
668
+ super();
669
+ this._commandService = _commandService;
670
+ this._sheetPermissionCheckController = _sheetPermissionCheckController;
671
+ this._noteModel = _noteModel;
672
+ this._localeService = _localeService;
673
+ this._initCommandListener();
674
+ }
675
+ _initCommandListener() {
676
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
677
+ const { id } = command;
678
+ if (id === SheetUpdateNoteCommand.id) {
679
+ const params = command.params;
680
+ if (!params) return;
681
+ const { unitId, sheetId, row, col, note } = params;
682
+ const previous = this._noteModel.getNote(unitId, sheetId, { noteId: note.id });
683
+ const moving = previous && (previous.row !== row || previous.col !== col);
684
+ if (!this._checkCell(unitId, sheetId, row, col) || moving && !this._checkCell(unitId, sheetId, previous.row, previous.col)) this._blockExecute();
685
+ } else if (id === SheetDeleteNoteCommand.id) {
686
+ const params = command.params;
687
+ if (!(params ? this._checkCell(params.unitId, params.sheetId, params.row, params.col) : this._sheetPermissionCheckController.permissionCheckWithoutRange(SHEET_NOTE_EDIT_PERMISSIONS))) this._blockExecute();
688
+ } else if (id === SheetToggleNotePopupCommand.id) {
689
+ if (!this._sheetPermissionCheckController.permissionCheckWithoutRange(SHEET_NOTE_TOGGLE_PERMISSIONS)) this._blockExecute();
690
+ }
691
+ }));
692
+ }
693
+ _checkCell(unitId, sheetId, row, col) {
694
+ return this._sheetPermissionCheckController.permissionCheckWithRanges(SHEET_NOTE_EDIT_PERMISSIONS, [{
695
+ startRow: row,
696
+ startColumn: col,
697
+ endRow: row,
698
+ endColumn: col
699
+ }], unitId, sheetId);
700
+ }
701
+ _blockExecute() {
702
+ this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("sheets-note.permission.editErr"));
703
+ }
704
+ };
705
+ SheetsNotePermissionController = __decorate([
706
+ __decorateParam(0, ICommandService),
707
+ __decorateParam(1, Inject(SheetPermissionCheckController)),
708
+ __decorateParam(2, Inject(SheetsNoteModel)),
709
+ __decorateParam(3, Inject(LocaleService))
710
+ ], SheetsNotePermissionController);
711
+
651
712
  // src/controllers/sheets-note-ref-range.controller.ts
652
713
  let SheetsNoteRefRangeController = class SheetsNoteRefRangeController extends Disposable {
653
714
  constructor(_refRangeService, _sheetsNoteModel, _selectionManagerService, _commandService) {
@@ -857,6 +918,7 @@ let UniverSheetsNotePlugin = class UniverSheetsNotePlugin extends Plugin {
857
918
  [
858
919
  [SheetsNoteModel],
859
920
  [SheetsNoteController],
921
+ [SheetsNotePermissionController],
860
922
  [SheetsNoteResourceController],
861
923
  [SheetsNoteRefRangeController]
862
924
  ].forEach((dependency) => {
@@ -865,6 +927,7 @@ let UniverSheetsNotePlugin = class UniverSheetsNotePlugin extends Plugin {
865
927
  touchDependencies(this._injector, [
866
928
  [SheetsNoteModel],
867
929
  [SheetsNoteController],
930
+ [SheetsNotePermissionController],
868
931
  [SheetsNoteResourceController]
869
932
  ]);
870
933
  }
@@ -882,4 +945,4 @@ UniverSheetsNotePlugin = __decorate([
882
945
  __decorateParam(2, Inject(Injector))
883
946
  ], UniverSheetsNotePlugin);
884
947
 
885
- export { RemoveNoteMutation, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, SheetsNoteResourceController, ToggleNotePopupMutation, UniverSheetsNotePlugin, UpdateNoteMutation, UpdateNotePositionMutation };
948
+ export { RemoveNoteMutation, SHEET_NOTE_EDIT_PERMISSIONS, SheetDeleteNoteCommand, SheetToggleNotePopupCommand, SheetUpdateNoteCommand, SheetsNoteModel, SheetsNoteResourceController, ToggleNotePopupMutation, UniverSheetsNotePlugin, UpdateNoteMutation, UpdateNotePositionMutation };
@@ -0,0 +1,4 @@
1
+ // src/locale/ar-SA.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "ليس لديك إذن لتعديل الملاحظات." } } };
3
+
4
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/fa-IR.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "شما اجازه ویرایش یادداشت‌ها را ندارید." } } };
3
+
4
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/ja-JP.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "メモを編集する権限がありません。" } } };
3
+
4
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/ko-KR.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "메모를 편집할 권한이 없습니다." } } };
3
+
4
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/ru-RU.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "У вас нет разрешения на редактирование примечаний." } } };
3
+
4
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -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
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/zh-CN.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "暂无编辑批注的权限。" } } };
3
+
4
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/zh-HK.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "暫無編輯批註的權限。" } } };
3
+
4
+ export { locale as default };
@@ -0,0 +1,4 @@
1
+ // src/locale/zh-TW.ts
2
+ const locale = { "sheets-note": { permission: { editErr: "暫無編輯批註的權限。" } } };
3
+
4
+ export { locale as default };
package/lib/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;