@univerjs/sheets 0.2.6 → 0.2.8

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 (180) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +208 -81
  3. package/lib/types/basics/cell-style.d.ts +0 -1
  4. package/lib/types/basics/cell-type.d.ts +0 -1
  5. package/lib/types/basics/cell-value.d.ts +0 -1
  6. package/lib/types/basics/const/default-spreadsheet-plugin-data.d.ts +0 -1
  7. package/lib/types/basics/interfaces/i-ruler-manager.d.ts +0 -1
  8. package/lib/types/basics/interfaces/mutation-interface.d.ts +0 -1
  9. package/lib/types/basics/interfaces/selection-config.d.ts +0 -1
  10. package/lib/types/basics/interfaces/spreadsheet-config.d.ts +0 -1
  11. package/lib/types/basics/rangeMerge.d.ts +0 -1
  12. package/lib/types/basics/selection.d.ts +0 -1
  13. package/lib/types/basics/sheet-header.d.ts +0 -1
  14. package/lib/types/basics/utils.d.ts +0 -1
  15. package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +0 -1
  16. package/lib/types/commands/commands/add-range-protection.command.d.ts +0 -1
  17. package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +0 -1
  18. package/lib/types/commands/commands/clear-selection-all.command.d.ts +0 -1
  19. package/lib/types/commands/commands/clear-selection-content.command.d.ts +0 -1
  20. package/lib/types/commands/commands/clear-selection-format.command.d.ts +0 -1
  21. package/lib/types/commands/commands/copy-worksheet.command.d.ts +0 -1
  22. package/lib/types/commands/commands/delete-range-move-left.command.d.ts +0 -1
  23. package/lib/types/commands/commands/delete-range-move-up.command.d.ts +0 -1
  24. package/lib/types/commands/commands/delete-range-protection.command.d.ts +0 -1
  25. package/lib/types/commands/commands/insert-defined-name.command.d.ts +0 -1
  26. package/lib/types/commands/commands/insert-range-move-down.command.d.ts +0 -1
  27. package/lib/types/commands/commands/insert-range-move-right.command.d.ts +0 -1
  28. package/lib/types/commands/commands/insert-row-col.command.d.ts +0 -1
  29. package/lib/types/commands/commands/insert-sheet.command.d.ts +0 -1
  30. package/lib/types/commands/commands/move-range.command.d.ts +0 -1
  31. package/lib/types/commands/commands/move-rows-cols.command.d.ts +0 -1
  32. package/lib/types/commands/commands/remove-defined-name.command.d.ts +0 -1
  33. package/lib/types/commands/commands/remove-row-col.command.d.ts +0 -1
  34. package/lib/types/commands/commands/remove-sheet.command.d.ts +0 -1
  35. package/lib/types/commands/commands/remove-worksheet-merge.command.d.ts +0 -1
  36. package/lib/types/commands/commands/reorder-range.command.d.ts +0 -1
  37. package/lib/types/commands/commands/set-border-command.d.ts +0 -1
  38. package/lib/types/commands/commands/set-col-visible.command.d.ts +0 -1
  39. package/lib/types/commands/commands/set-defined-name.command.d.ts +0 -1
  40. package/lib/types/commands/commands/set-frozen-cancel.command.d.ts +0 -1
  41. package/lib/types/commands/commands/set-frozen.command.d.ts +0 -1
  42. package/lib/types/commands/commands/set-hide-gridlines.command.d.ts +0 -1
  43. package/lib/types/commands/commands/set-range-protection.command.d.ts +0 -1
  44. package/lib/types/commands/commands/set-range-values.command.d.ts +0 -1
  45. package/lib/types/commands/commands/set-row-visible.command.d.ts +0 -1
  46. package/lib/types/commands/commands/set-style.command.d.ts +0 -1
  47. package/lib/types/commands/commands/set-tab-color.command.d.ts +0 -1
  48. package/lib/types/commands/commands/set-workbook-name.command.d.ts +0 -1
  49. package/lib/types/commands/commands/set-worksheet-activate.command.d.ts +0 -1
  50. package/lib/types/commands/commands/set-worksheet-col-width.command.d.ts +0 -1
  51. package/lib/types/commands/commands/set-worksheet-hide.command.d.ts +0 -1
  52. package/lib/types/commands/commands/set-worksheet-name.command.d.ts +0 -1
  53. package/lib/types/commands/commands/set-worksheet-order.command.d.ts +0 -1
  54. package/lib/types/commands/commands/set-worksheet-permission-points.command.d.ts +0 -1
  55. package/lib/types/commands/commands/set-worksheet-right-to-left.command.d.ts +0 -1
  56. package/lib/types/commands/commands/set-worksheet-row-height.command.d.ts +0 -1
  57. package/lib/types/commands/commands/set-worksheet-show.command.d.ts +0 -1
  58. package/lib/types/commands/commands/utils/merged-cell-util.d.ts +0 -1
  59. package/lib/types/commands/commands/utils/selection-utils.d.ts +0 -1
  60. package/lib/types/commands/commands/utils/target-util.d.ts +0 -1
  61. package/lib/types/commands/mutations/__tests__/create-command-test-bed.d.ts +0 -1
  62. package/lib/types/commands/mutations/add-range-protection.mutation.d.ts +0 -1
  63. package/lib/types/commands/mutations/add-worksheet-merge.mutation.d.ts +0 -1
  64. package/lib/types/commands/mutations/add-worksheet-protection.mutation.d.ts +0 -1
  65. package/lib/types/commands/mutations/delete-range-protection.mutation.d.ts +0 -1
  66. package/lib/types/commands/mutations/delete-worksheet-protection.mutation.d.ts +0 -1
  67. package/lib/types/commands/mutations/empty.mutation.d.ts +0 -1
  68. package/lib/types/commands/mutations/insert-row-col.mutation.d.ts +0 -1
  69. package/lib/types/commands/mutations/insert-sheet.mutation.d.ts +0 -1
  70. package/lib/types/commands/mutations/move-range.mutation.d.ts +3 -2
  71. package/lib/types/commands/mutations/move-rows-cols.mutation.d.ts +0 -1
  72. package/lib/types/commands/mutations/numfmt-mutation.d.ts +0 -1
  73. package/lib/types/commands/mutations/remove-row-col.mutation.d.ts +0 -1
  74. package/lib/types/commands/mutations/remove-sheet.mutation.d.ts +0 -1
  75. package/lib/types/commands/mutations/remove-worksheet-merge.mutation.d.ts +0 -1
  76. package/lib/types/commands/mutations/reorder-range.mutation.d.ts +0 -1
  77. package/lib/types/commands/mutations/set-col-visible.mutation.d.ts +0 -1
  78. package/lib/types/commands/mutations/set-frozen.mutation.d.ts +0 -1
  79. package/lib/types/commands/mutations/set-hide-gridlines.mutatiom.d.ts +0 -1
  80. package/lib/types/commands/mutations/set-range-protection.mutation.d.ts +0 -1
  81. package/lib/types/commands/mutations/set-range-values.mutation.d.ts +0 -1
  82. package/lib/types/commands/mutations/set-row-visible.mutation.d.ts +0 -1
  83. package/lib/types/commands/mutations/set-tab-color.mutation.d.ts +0 -1
  84. package/lib/types/commands/mutations/set-workbook-name.mutation.d.ts +0 -1
  85. package/lib/types/commands/mutations/set-worksheet-col-width.mutation.d.ts +0 -1
  86. package/lib/types/commands/mutations/set-worksheet-hide.mutation.d.ts +0 -1
  87. package/lib/types/commands/mutations/set-worksheet-name.mutation.d.ts +0 -1
  88. package/lib/types/commands/mutations/set-worksheet-order.mutation.d.ts +0 -1
  89. package/lib/types/commands/mutations/set-worksheet-permission-points.mutation.d.ts +0 -1
  90. package/lib/types/commands/mutations/set-worksheet-protection.mutation.d.ts +0 -1
  91. package/lib/types/commands/mutations/set-worksheet-right-to-left.mutation.d.ts +0 -1
  92. package/lib/types/commands/mutations/set-worksheet-row-height.mutation.d.ts +0 -1
  93. package/lib/types/commands/operations/scroll-to-cell.operation.d.ts +0 -1
  94. package/lib/types/commands/operations/selection.operation.d.ts +0 -1
  95. package/lib/types/commands/operations/set-worksheet-active.operation.d.ts +0 -1
  96. package/lib/types/commands/utils/handle-merge-operation.d.ts +0 -1
  97. package/lib/types/commands/utils/handle-range-mutation.d.ts +0 -1
  98. package/lib/types/commands/utils/selection-command-util.d.ts +0 -1
  99. package/lib/types/controllers/__tests__/util.d.ts +0 -1
  100. package/lib/types/controllers/basic-worksheet.controller.d.ts +0 -1
  101. package/lib/types/controllers/calculate-result-apply.controller.d.ts +0 -1
  102. package/lib/types/controllers/defined-name-data.controller.d.ts +0 -1
  103. package/lib/types/controllers/merge-cell.controller.d.ts +5 -2
  104. package/lib/types/controllers/number-cell.controller.d.ts +0 -1
  105. package/lib/types/index.d.ts +3 -2
  106. package/lib/types/locale/en-US.d.ts +0 -1
  107. package/lib/types/locale/ru-RU.d.ts +0 -1
  108. package/lib/types/locale/vi-VN.d.ts +0 -1
  109. package/lib/types/locale/zh-TW.d.ts +0 -1
  110. package/lib/types/model/range-protection-render.model.d.ts +0 -1
  111. package/lib/types/model/range-protection-rule.model.d.ts +1 -2
  112. package/lib/types/services/__tests__/util.d.ts +0 -1
  113. package/lib/types/services/border-style-manager.service.d.ts +0 -1
  114. package/lib/types/services/numfmt/numfmt.service.d.ts +0 -1
  115. package/lib/types/services/numfmt/type.d.ts +0 -1
  116. package/lib/types/services/permission/permission-point/range/edit.d.ts +0 -1
  117. package/lib/types/services/permission/permission-point/range/view.d.ts +0 -1
  118. package/lib/types/services/permission/permission-point/workbook/comment.d.ts +0 -1
  119. package/lib/types/services/permission/permission-point/workbook/copy-sheet.d.ts +0 -1
  120. package/lib/types/services/permission/permission-point/workbook/copy.d.ts +0 -1
  121. package/lib/types/services/permission/permission-point/workbook/create-sheet.d.ts +0 -1
  122. package/lib/types/services/permission/permission-point/workbook/delete-sheet.d.ts +0 -1
  123. package/lib/types/services/permission/permission-point/workbook/duplicate.d.ts +0 -1
  124. package/lib/types/services/permission/permission-point/workbook/editable.d.ts +0 -1
  125. package/lib/types/services/permission/permission-point/workbook/export.d.ts +0 -1
  126. package/lib/types/services/permission/permission-point/workbook/hide-sheet.d.ts +0 -1
  127. package/lib/types/services/permission/permission-point/workbook/history.d.ts +0 -1
  128. package/lib/types/services/permission/permission-point/workbook/manage-collaborator.d.ts +0 -1
  129. package/lib/types/services/permission/permission-point/workbook/move-sheet.d.ts +0 -1
  130. package/lib/types/services/permission/permission-point/workbook/print.d.ts +0 -1
  131. package/lib/types/services/permission/permission-point/workbook/recover-history.d.ts +0 -1
  132. package/lib/types/services/permission/permission-point/workbook/rename-sheet.d.ts +0 -1
  133. package/lib/types/services/permission/permission-point/workbook/share.d.ts +0 -1
  134. package/lib/types/services/permission/permission-point/workbook/view-history.d.ts +0 -1
  135. package/lib/types/services/permission/permission-point/workbook/view.d.ts +0 -1
  136. package/lib/types/services/permission/permission-point/worksheet/copy.d.ts +0 -1
  137. package/lib/types/services/permission/permission-point/worksheet/delete-column.d.ts +0 -1
  138. package/lib/types/services/permission/permission-point/worksheet/delete-row.d.ts +0 -1
  139. package/lib/types/services/permission/permission-point/worksheet/edit-extra-object.d.ts +0 -1
  140. package/lib/types/services/permission/permission-point/worksheet/edit.d.ts +0 -1
  141. package/lib/types/services/permission/permission-point/worksheet/filter.d.ts +0 -1
  142. package/lib/types/services/permission/permission-point/worksheet/insert-column.d.ts +0 -1
  143. package/lib/types/services/permission/permission-point/worksheet/insert-hyperlink.d.ts +0 -1
  144. package/lib/types/services/permission/permission-point/worksheet/insert-row.d.ts +0 -1
  145. package/lib/types/services/permission/permission-point/worksheet/manage-collaborator.d.ts +0 -1
  146. package/lib/types/services/permission/permission-point/worksheet/pivot-table.d.ts +0 -1
  147. package/lib/types/services/permission/permission-point/worksheet/select-protected-cells.d.ts +0 -1
  148. package/lib/types/services/permission/permission-point/worksheet/select-un-protected-cells.d.ts +0 -1
  149. package/lib/types/services/permission/permission-point/worksheet/set-cell-style.d.ts +0 -1
  150. package/lib/types/services/permission/permission-point/worksheet/set-cell-value.d.ts +0 -1
  151. package/lib/types/services/permission/permission-point/worksheet/set-column-style.d.ts +0 -1
  152. package/lib/types/services/permission/permission-point/worksheet/set-row-style.d.ts +0 -1
  153. package/lib/types/services/permission/permission-point/worksheet/sort.d.ts +0 -1
  154. package/lib/types/services/permission/permission-point/worksheet/view.d.ts +0 -1
  155. package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +0 -1
  156. package/lib/types/services/permission/range-permission/range-protection.service.d.ts +0 -1
  157. package/lib/types/services/permission/range-permission/util.d.ts +0 -1
  158. package/lib/types/services/permission/type.d.ts +0 -1
  159. package/lib/types/services/permission/util.d.ts +2 -0
  160. package/lib/types/services/permission/workbook-permission/util.d.ts +0 -1
  161. package/lib/types/services/permission/workbook-permission/workbook-permission.service.d.ts +0 -1
  162. package/lib/types/services/permission/worksheet-permission/type.d.ts +0 -1
  163. package/lib/types/services/permission/worksheet-permission/utils.d.ts +0 -1
  164. package/lib/types/services/permission/worksheet-permission/worksheet-permission-point.model.d.ts +1 -2
  165. package/lib/types/services/permission/worksheet-permission/worksheet-permission-rule.model.d.ts +1 -2
  166. package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +0 -1
  167. package/lib/types/services/ref-range/__tests__/__testing__.d.ts +0 -1
  168. package/lib/types/services/ref-range/__tests__/ref-range.service.spec.d.ts +0 -1
  169. package/lib/types/services/ref-range/ref-range.service.d.ts +0 -1
  170. package/lib/types/services/ref-range/type.d.ts +0 -1
  171. package/lib/types/services/ref-range/util.d.ts +0 -1
  172. package/lib/types/services/selections/ref-selections.service.d.ts +0 -1
  173. package/lib/types/services/selections/selection-manager.service.d.ts +0 -1
  174. package/lib/types/services/sheet-interceptor/__tests__/create-core-test-bed.d.ts +0 -1
  175. package/lib/types/services/sheet-interceptor/interceptor-const.d.ts +0 -1
  176. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +31 -3
  177. package/lib/types/services/sheet-interceptor/utils/interceptor.d.ts +0 -1
  178. package/lib/types/sheets-plugin.d.ts +0 -1
  179. package/lib/umd/index.js +2 -2
  180. package/package.json +14 -13
package/lib/es/index.js CHANGED
@@ -8,6 +8,7 @@ import { DataSyncPrimaryController } from "@univerjs/rpc";
8
8
  import { shareReplay, takeUntil, switchMap, of, Subject, BehaviorSubject, merge, map } from "rxjs";
9
9
  import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
10
10
  import { takeUntil as takeUntil$1, filter, map as map$1 } from "rxjs/operators";
11
+ import { RangeProtectionRuleModel as RangeProtectionRuleModel$1, WorkbookEditablePermission as WorkbookEditablePermission$1, WorksheetEditPermission as WorksheetEditPermission$1, RangeProtectionPermissionEditPoint as RangeProtectionPermissionEditPoint$1 } from "@univerjs/sheets";
11
12
  var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
12
13
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
13
14
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -194,6 +195,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
194
195
  super();
195
196
  __publicField(this, "_interceptorsByName", /* @__PURE__ */ new Map());
196
197
  __publicField(this, "_commandInterceptors", []);
198
+ __publicField(this, "_rangeInterceptors", []);
199
+ __publicField(this, "_beforeCommandInterceptor", []);
197
200
  __publicField(this, "_workbookDisposables", /* @__PURE__ */ new Map());
198
201
  __publicField(this, "_worksheetDisposables", /* @__PURE__ */ new Map());
199
202
  this._univerInstanceService = _univerInstanceService, this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
@@ -219,13 +222,58 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
219
222
  return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
220
223
  }), this.disposeWithMe(toDisposable(() => remove(this._commandInterceptors, interceptor)));
221
224
  }
225
+ // Add a listener function to the command, which will be run before the command is run to get whether it can be executed the command
226
+ interceptBeforeCommand(interceptor) {
227
+ if (this._beforeCommandInterceptor.includes(interceptor))
228
+ throw new Error("[SheetInterceptorService]: Interceptor already exists!");
229
+ return this._beforeCommandInterceptor.push(interceptor), this._beforeCommandInterceptor.sort((a, b) => {
230
+ var _a20, _b;
231
+ return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
232
+ }), this.disposeWithMe(toDisposable(() => remove(this._beforeCommandInterceptor, interceptor)));
233
+ }
234
+ /**
235
+ * before command execute, call this method to get the flag of whether it can be executed the command,
236
+ * @param info ICommandInfo
237
+ * @returns Promise<boolean>
238
+ */
239
+ async beforeCommandExecute(info) {
240
+ return (await Promise.all(this._beforeCommandInterceptor.map((i) => i.performCheck(info)))).every((perform) => perform);
241
+ }
242
+ /**
243
+ * By adding callbacks to some Ranges can get some additional mutations, such as clearing all plugin data in a certain area.
244
+ * @param interceptor IRangeInterceptors
245
+ * @returns IDisposable
246
+ */
247
+ interceptRanges(interceptor) {
248
+ if (this._rangeInterceptors.includes(interceptor))
249
+ throw new Error("[SheetInterceptorService]: Interceptor already exists!");
250
+ return this._rangeInterceptors.push(interceptor), this._rangeInterceptors.sort((a, b) => {
251
+ var _a20, _b;
252
+ return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
253
+ }), this.disposeWithMe(toDisposable(() => remove(this._rangeInterceptors, interceptor)));
254
+ }
222
255
  /**
223
256
  * When command is executing, call this method to gether undo redo mutations from upper features.
224
257
  * @param command
225
258
  * @returns
226
259
  */
227
- onCommandExecute(command) {
228
- const infos = this._commandInterceptors.map((i) => i.getMutations(command));
260
+ onCommandExecute(info) {
261
+ const infos = this._commandInterceptors.map((i) => i.getMutations(info));
262
+ return {
263
+ preUndos: infos.map((i) => {
264
+ var _a20;
265
+ return (_a20 = i.preUndos) != null ? _a20 : [];
266
+ }).flat(),
267
+ undos: infos.map((i) => i.undos).flat(),
268
+ preRedos: infos.map((i) => {
269
+ var _a20;
270
+ return (_a20 = i.preRedos) != null ? _a20 : [];
271
+ }).flat(),
272
+ redos: infos.map((i) => i.redos).flat()
273
+ };
274
+ }
275
+ generateMutationsByRanges(info) {
276
+ const infos = this._rangeInterceptors.map((i) => i.getMutations(info));
229
277
  return {
230
278
  preUndos: infos.map((i) => {
231
279
  var _a20;
@@ -966,10 +1014,11 @@ __name(createRangeIteratorWithSkipFilteredRows, "createRangeIteratorWithSkipFilt
966
1014
  const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
967
1015
  type: CommandType.COMMAND,
968
1016
  id: MoveRangeCommandId,
969
- handler: /* @__PURE__ */ __name((accessor, params) => {
1017
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
970
1018
  var _a20, _b;
971
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), target = getSheetCommandTarget(univerInstanceService);
972
- if (!target) return !1;
1019
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
1020
+ if (!target || !await sheetInterceptorService.beforeCommandExecute({ id: MoveRangeCommand.id, params }))
1021
+ return !1;
973
1022
  const { worksheet, subUnitId, unitId } = target, moveRangeMutations = getMoveRangeUndoRedoMutations(
974
1023
  accessor,
975
1024
  { unitId, subUnitId, range: params.fromRange },
@@ -977,7 +1026,7 @@ const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
977
1026
  );
978
1027
  if (moveRangeMutations === null)
979
1028
  return errorService.emit(localeService.t("sheets.info.acrossMergedCell")), !1;
980
- const interceptorCommands = accessor.get(SheetInterceptorService).onCommandExecute({
1029
+ const interceptorCommands = sheetInterceptorService.onCommandExecute({
981
1030
  id: MoveRangeCommand.id,
982
1031
  params: { ...params }
983
1032
  }), redos = [
@@ -1020,18 +1069,18 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = !1) {
1020
1069
  return null;
1021
1070
  const fromCellValue = new ObjectMatrix(), newFromCellValue = new ObjectMatrix();
1022
1071
  Range.foreach(fromRange, (row, col) => {
1023
- fromCellValue.setValue(row, col, fromCellMatrix.getValue(row, col)), newFromCellValue.setValue(row, col, null);
1072
+ fromCellValue.setValue(row, col, Tools.deepClone(fromCellMatrix.getValue(row, col))), newFromCellValue.setValue(row, col, null);
1024
1073
  });
1025
- const toCellValue = new ObjectMatrix();
1074
+ const toCellValue = new ObjectMatrix(), newToCellValue = new ObjectMatrix();
1026
1075
  Range.foreach(toRange, (row, col) => {
1027
- toCellValue.setValue(row, col, toCellMatrix.getValue(row, col));
1028
- });
1029
- const newToCellValue = new ObjectMatrix();
1030
- Range.foreach(fromRange, (row, col) => {
1076
+ toCellValue.setValue(row, col, Tools.deepClone(toCellMatrix.getValue(row, col)));
1077
+ }), Range.foreach(fromRange, (row, col) => {
1031
1078
  const cellRange = cellToRange(row, col), relativeRange = Rectangle.getRelativeRange(cellRange, fromRange), range = Rectangle.getPositionRange(relativeRange, toRange);
1032
- newToCellValue.setValue(range.startRow, range.startColumn, fromCellMatrix.getValue(row, col));
1079
+ newToCellValue.setValue(range.startRow, range.startColumn, Tools.deepClone(fromCellMatrix.getValue(row, col)));
1033
1080
  });
1034
1081
  const doMoveRangeMutation = {
1082
+ fromRange: from.range,
1083
+ toRange: to.range,
1035
1084
  from: {
1036
1085
  value: newFromCellValue.getMatrix(),
1037
1086
  subUnitId: fromSubUnitId
@@ -1042,6 +1091,8 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = !1) {
1042
1091
  },
1043
1092
  unitId
1044
1093
  }, undoMoveRangeMutation = {
1094
+ fromRange: to.range,
1095
+ toRange: from.range,
1045
1096
  from: {
1046
1097
  value: fromCellValue.getMatrix(),
1047
1098
  subUnitId: fromSubUnitId
@@ -1060,11 +1111,11 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = !1) {
1060
1111
  };
1061
1112
  }
1062
1113
  __name(getMoveRangeUndoRedoMutations, "getMoveRangeUndoRedoMutations");
1063
- var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), G = /* @__PURE__ */ ((E) => (E[E.Unkonwn = 0] = "Unkonwn", E[E.Workbook = 1] = "Workbook", E[E.Worksheet = 2] = "Worksheet", E[E.SelectRange = 3] = "SelectRange", E[E.Document = 4] = "Document", E[E.Slide = 5] = "Slide", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(G || {});
1114
+ var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), l = /* @__PURE__ */ ((E) => (E[E.Unkonwn = 0] = "Unkonwn", E[E.Workbook = 1] = "Workbook", E[E.Worksheet = 2] = "Worksheet", E[E.SelectRange = 3] = "SelectRange", E[E.Document = 4] = "Document", E[E.Slide = 5] = "Slide", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(l || {});
1064
1115
  const _WorksheetCopyPermission = class _WorksheetCopyPermission {
1065
1116
  constructor(unitId, subUnitId) {
1066
1117
  __publicField(this, "value", !0);
1067
- __publicField(this, "type", G.Worksheet);
1118
+ __publicField(this, "type", l.Worksheet);
1068
1119
  __publicField(this, "status", PermissionStatus.INIT);
1069
1120
  __publicField(this, "id");
1070
1121
  __publicField(this, "subType", P.Copy);
@@ -1076,7 +1127,7 @@ let WorksheetCopyPermission = _WorksheetCopyPermission;
1076
1127
  const _WorksheetSelectProtectedCellsPermission = class _WorksheetSelectProtectedCellsPermission {
1077
1128
  constructor(unitId, subUnitId) {
1078
1129
  __publicField(this, "value", !0);
1079
- __publicField(this, "type", G.Worksheet);
1130
+ __publicField(this, "type", l.Worksheet);
1080
1131
  __publicField(this, "status", PermissionStatus.INIT);
1081
1132
  __publicField(this, "id");
1082
1133
  __publicField(this, "subType", P.SelectProtectedCells);
@@ -1088,7 +1139,7 @@ let WorksheetSelectProtectedCellsPermission = _WorksheetSelectProtectedCellsPerm
1088
1139
  const _WorksheetSelectUnProtectedCellsPermission = class _WorksheetSelectUnProtectedCellsPermission {
1089
1140
  constructor(unitId, subUnitId) {
1090
1141
  __publicField(this, "value", !0);
1091
- __publicField(this, "type", G.Worksheet);
1142
+ __publicField(this, "type", l.Worksheet);
1092
1143
  __publicField(this, "status", PermissionStatus.INIT);
1093
1144
  __publicField(this, "id");
1094
1145
  __publicField(this, "subType", P.SelectUnProtectedCells);
@@ -1100,7 +1151,7 @@ let WorksheetSelectUnProtectedCellsPermission = _WorksheetSelectUnProtectedCells
1100
1151
  const _WorksheetSetCellStylePermission = class _WorksheetSetCellStylePermission {
1101
1152
  constructor(unitId, subUnitId) {
1102
1153
  __publicField(this, "value", !0);
1103
- __publicField(this, "type", G.Worksheet);
1154
+ __publicField(this, "type", l.Worksheet);
1104
1155
  __publicField(this, "status", PermissionStatus.INIT);
1105
1156
  __publicField(this, "id");
1106
1157
  __publicField(this, "subType", P.SetCellStyle);
@@ -1112,7 +1163,7 @@ let WorksheetSetCellStylePermission = _WorksheetSetCellStylePermission;
1112
1163
  const _WorksheetSetCellValuePermission = class _WorksheetSetCellValuePermission {
1113
1164
  constructor(unitId, subUnitId) {
1114
1165
  __publicField(this, "value", !0);
1115
- __publicField(this, "type", G.Worksheet);
1166
+ __publicField(this, "type", l.Worksheet);
1116
1167
  __publicField(this, "status", PermissionStatus.INIT);
1117
1168
  __publicField(this, "id");
1118
1169
  __publicField(this, "subType", P.SetCellValue);
@@ -1124,7 +1175,7 @@ let WorksheetSetCellValuePermission = _WorksheetSetCellValuePermission;
1124
1175
  const _WorksheetViewPermission = class _WorksheetViewPermission {
1125
1176
  constructor(unitId, subUnitId) {
1126
1177
  __publicField(this, "value", !0);
1127
- __publicField(this, "type", G.Worksheet);
1178
+ __publicField(this, "type", l.Worksheet);
1128
1179
  __publicField(this, "status", PermissionStatus.INIT);
1129
1180
  __publicField(this, "id");
1130
1181
  __publicField(this, "subType", P.View);
@@ -1136,7 +1187,7 @@ let WorksheetViewPermission = _WorksheetViewPermission;
1136
1187
  const _WorksheetSetRowStylePermission = class _WorksheetSetRowStylePermission {
1137
1188
  constructor(unitId, subUnitId) {
1138
1189
  __publicField(this, "value", !0);
1139
- __publicField(this, "type", G.Worksheet);
1190
+ __publicField(this, "type", l.Worksheet);
1140
1191
  __publicField(this, "status", PermissionStatus.INIT);
1141
1192
  __publicField(this, "id");
1142
1193
  __publicField(this, "subType", P.SetRowStyle);
@@ -1148,7 +1199,7 @@ let WorksheetSetRowStylePermission = _WorksheetSetRowStylePermission;
1148
1199
  const _WorksheetSetColumnStylePermission = class _WorksheetSetColumnStylePermission {
1149
1200
  constructor(unitId, subUnitId) {
1150
1201
  __publicField(this, "value", !0);
1151
- __publicField(this, "type", G.Worksheet);
1202
+ __publicField(this, "type", l.Worksheet);
1152
1203
  __publicField(this, "status", PermissionStatus.INIT);
1153
1204
  __publicField(this, "id");
1154
1205
  __publicField(this, "subType", P.SetColumnStyle);
@@ -1160,7 +1211,7 @@ let WorksheetSetColumnStylePermission = _WorksheetSetColumnStylePermission;
1160
1211
  const _WorksheetInsertRowPermission = class _WorksheetInsertRowPermission {
1161
1212
  constructor(unitId, subUnitId) {
1162
1213
  __publicField(this, "value", !0);
1163
- __publicField(this, "type", G.Worksheet);
1214
+ __publicField(this, "type", l.Worksheet);
1164
1215
  __publicField(this, "status", PermissionStatus.INIT);
1165
1216
  __publicField(this, "id");
1166
1217
  __publicField(this, "subType", P.InsertRow);
@@ -1172,7 +1223,7 @@ let WorksheetInsertRowPermission = _WorksheetInsertRowPermission;
1172
1223
  const _WorksheetInsertColumnPermission = class _WorksheetInsertColumnPermission {
1173
1224
  constructor(unitId, subUnitId) {
1174
1225
  __publicField(this, "value", !0);
1175
- __publicField(this, "type", G.Worksheet);
1226
+ __publicField(this, "type", l.Worksheet);
1176
1227
  __publicField(this, "status", PermissionStatus.INIT);
1177
1228
  __publicField(this, "id");
1178
1229
  __publicField(this, "subType", P.InsertColumn);
@@ -1184,7 +1235,7 @@ let WorksheetInsertColumnPermission = _WorksheetInsertColumnPermission;
1184
1235
  const _WorksheetInsertHyperlinkPermission = class _WorksheetInsertHyperlinkPermission {
1185
1236
  constructor(unitId, subUnitId) {
1186
1237
  __publicField(this, "value", !0);
1187
- __publicField(this, "type", G.Worksheet);
1238
+ __publicField(this, "type", l.Worksheet);
1188
1239
  __publicField(this, "status", PermissionStatus.INIT);
1189
1240
  __publicField(this, "id");
1190
1241
  __publicField(this, "subType", P.InsertHyperlink);
@@ -1196,7 +1247,7 @@ let WorksheetInsertHyperlinkPermission = _WorksheetInsertHyperlinkPermission;
1196
1247
  const _WorksheetDeleteRowPermission = class _WorksheetDeleteRowPermission {
1197
1248
  constructor(unitId, subUnitId) {
1198
1249
  __publicField(this, "value", !0);
1199
- __publicField(this, "type", G.Worksheet);
1250
+ __publicField(this, "type", l.Worksheet);
1200
1251
  __publicField(this, "status", PermissionStatus.INIT);
1201
1252
  __publicField(this, "id");
1202
1253
  __publicField(this, "subType", P.DeleteRow);
@@ -1208,7 +1259,7 @@ let WorksheetDeleteRowPermission = _WorksheetDeleteRowPermission;
1208
1259
  const _WorksheetDeleteColumnPermission = class _WorksheetDeleteColumnPermission {
1209
1260
  constructor(unitId, subUnitId) {
1210
1261
  __publicField(this, "value", !0);
1211
- __publicField(this, "type", G.Worksheet);
1262
+ __publicField(this, "type", l.Worksheet);
1212
1263
  __publicField(this, "status", PermissionStatus.INIT);
1213
1264
  __publicField(this, "id");
1214
1265
  __publicField(this, "subType", P.DeleteColumn);
@@ -1220,7 +1271,7 @@ let WorksheetDeleteColumnPermission = _WorksheetDeleteColumnPermission;
1220
1271
  const _WorksheetSortPermission = class _WorksheetSortPermission {
1221
1272
  constructor(unitId, subUnitId) {
1222
1273
  __publicField(this, "value", !0);
1223
- __publicField(this, "type", G.Worksheet);
1274
+ __publicField(this, "type", l.Worksheet);
1224
1275
  __publicField(this, "status", PermissionStatus.INIT);
1225
1276
  __publicField(this, "id");
1226
1277
  __publicField(this, "subType", P.Sort);
@@ -1232,7 +1283,7 @@ let WorksheetSortPermission = _WorksheetSortPermission;
1232
1283
  const _WorksheetFilterPermission = class _WorksheetFilterPermission {
1233
1284
  constructor(unitId, subUnitId) {
1234
1285
  __publicField(this, "value", !0);
1235
- __publicField(this, "type", G.Worksheet);
1286
+ __publicField(this, "type", l.Worksheet);
1236
1287
  __publicField(this, "status", PermissionStatus.INIT);
1237
1288
  __publicField(this, "id");
1238
1289
  __publicField(this, "subType", P.Filter);
@@ -1244,7 +1295,7 @@ let WorksheetFilterPermission = _WorksheetFilterPermission;
1244
1295
  const _WorksheetPivotTablePermission = class _WorksheetPivotTablePermission {
1245
1296
  constructor(unitId, subUnitId) {
1246
1297
  __publicField(this, "value", !0);
1247
- __publicField(this, "type", G.Worksheet);
1298
+ __publicField(this, "type", l.Worksheet);
1248
1299
  __publicField(this, "status", PermissionStatus.INIT);
1249
1300
  __publicField(this, "id");
1250
1301
  __publicField(this, "subType", P.PivotTable);
@@ -1256,7 +1307,7 @@ let WorksheetPivotTablePermission = _WorksheetPivotTablePermission;
1256
1307
  const _WorksheetEditExtraObjectPermission = class _WorksheetEditExtraObjectPermission {
1257
1308
  constructor(unitId, subUnitId) {
1258
1309
  __publicField(this, "value", !0);
1259
- __publicField(this, "type", G.Worksheet);
1310
+ __publicField(this, "type", l.Worksheet);
1260
1311
  __publicField(this, "status", PermissionStatus.INIT);
1261
1312
  __publicField(this, "id");
1262
1313
  __publicField(this, "subType", P.EditExtraObject);
@@ -1268,7 +1319,7 @@ let WorksheetEditExtraObjectPermission = _WorksheetEditExtraObjectPermission;
1268
1319
  const _WorksheetManageCollaboratorPermission = class _WorksheetManageCollaboratorPermission {
1269
1320
  constructor(unitId, subUnitId) {
1270
1321
  __publicField(this, "value", !0);
1271
- __publicField(this, "type", G.Worksheet);
1322
+ __publicField(this, "type", l.Worksheet);
1272
1323
  __publicField(this, "status", PermissionStatus.INIT);
1273
1324
  __publicField(this, "id");
1274
1325
  __publicField(this, "subType", P.ManageCollaborator);
@@ -1280,7 +1331,7 @@ let WorksheetManageCollaboratorPermission = _WorksheetManageCollaboratorPermissi
1280
1331
  const _WorksheetEditPermission = class _WorksheetEditPermission {
1281
1332
  constructor(unitId, subUnitId) {
1282
1333
  __publicField(this, "value", !0);
1283
- __publicField(this, "type", G.Worksheet);
1334
+ __publicField(this, "type", l.Worksheet);
1284
1335
  __publicField(this, "status", PermissionStatus.INIT);
1285
1336
  __publicField(this, "id");
1286
1337
  __publicField(this, "subType", P.Edit);
@@ -1293,7 +1344,7 @@ const _WorkbookCommentPermission = class _WorkbookCommentPermission {
1293
1344
  constructor(unitId) {
1294
1345
  __publicField(this, "id");
1295
1346
  __publicField(this, "value", !0);
1296
- __publicField(this, "type", G.Workbook);
1347
+ __publicField(this, "type", l.Workbook);
1297
1348
  __publicField(this, "status", PermissionStatus.INIT);
1298
1349
  __publicField(this, "subType", P.Comment);
1299
1350
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Comment}_${unitId}`;
@@ -1305,7 +1356,7 @@ const _WorkbookEditablePermission = class _WorkbookEditablePermission {
1305
1356
  constructor(unitId) {
1306
1357
  __publicField(this, "id");
1307
1358
  __publicField(this, "value", !0);
1308
- __publicField(this, "type", G.Workbook);
1359
+ __publicField(this, "type", l.Workbook);
1309
1360
  __publicField(this, "status", PermissionStatus.INIT);
1310
1361
  __publicField(this, "subType", P.Edit);
1311
1362
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Edit}_${unitId}`;
@@ -1317,7 +1368,7 @@ const _WorkbookDuplicatePermission = class _WorkbookDuplicatePermission {
1317
1368
  constructor(unitId) {
1318
1369
  __publicField(this, "id");
1319
1370
  __publicField(this, "value", !0);
1320
- __publicField(this, "type", G.Workbook);
1371
+ __publicField(this, "type", l.Workbook);
1321
1372
  __publicField(this, "status", PermissionStatus.INIT);
1322
1373
  __publicField(this, "subType", P.Duplicate);
1323
1374
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Duplicate}_${unitId}`;
@@ -1329,7 +1380,7 @@ const _WorkbookPrintPermission = class _WorkbookPrintPermission {
1329
1380
  constructor(unitId) {
1330
1381
  __publicField(this, "id");
1331
1382
  __publicField(this, "value", !0);
1332
- __publicField(this, "type", G.Workbook);
1383
+ __publicField(this, "type", l.Workbook);
1333
1384
  __publicField(this, "status", PermissionStatus.INIT);
1334
1385
  __publicField(this, "subType", P.Print);
1335
1386
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Print}_${unitId}`;
@@ -1341,7 +1392,7 @@ const _WorkbookExportPermission = class _WorkbookExportPermission {
1341
1392
  constructor(unitId) {
1342
1393
  __publicField(this, "id");
1343
1394
  __publicField(this, "value", !0);
1344
- __publicField(this, "type", G.Workbook);
1395
+ __publicField(this, "type", l.Workbook);
1345
1396
  __publicField(this, "status", PermissionStatus.INIT);
1346
1397
  __publicField(this, "subType", P.Export);
1347
1398
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Export}_${unitId}`;
@@ -1353,7 +1404,7 @@ const _WorkbookMoveSheetPermission = class _WorkbookMoveSheetPermission {
1353
1404
  constructor(unitId) {
1354
1405
  __publicField(this, "id");
1355
1406
  __publicField(this, "value", !0);
1356
- __publicField(this, "type", G.Workbook);
1407
+ __publicField(this, "type", l.Workbook);
1357
1408
  __publicField(this, "status", PermissionStatus.INIT);
1358
1409
  __publicField(this, "subType", P.MoveSheet);
1359
1410
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.MoveSheet}_${unitId}`;
@@ -1365,7 +1416,7 @@ const _WorkbookDeleteSheetPermission = class _WorkbookDeleteSheetPermission {
1365
1416
  constructor(unitId) {
1366
1417
  __publicField(this, "id");
1367
1418
  __publicField(this, "value", !0);
1368
- __publicField(this, "type", G.Workbook);
1419
+ __publicField(this, "type", l.Workbook);
1369
1420
  __publicField(this, "status", PermissionStatus.INIT);
1370
1421
  __publicField(this, "subType", P.DeleteSheet);
1371
1422
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.DeleteSheet}_${unitId}`;
@@ -1377,7 +1428,7 @@ const _WorkbookHideSheetPermission = class _WorkbookHideSheetPermission {
1377
1428
  constructor(unitId) {
1378
1429
  __publicField(this, "id");
1379
1430
  __publicField(this, "value", !0);
1380
- __publicField(this, "type", G.Workbook);
1431
+ __publicField(this, "type", l.Workbook);
1381
1432
  __publicField(this, "status", PermissionStatus.INIT);
1382
1433
  __publicField(this, "subType", P.HideSheet);
1383
1434
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.HideSheet}_${unitId}`;
@@ -1389,7 +1440,7 @@ const _WorkbookRenameSheetPermission = class _WorkbookRenameSheetPermission {
1389
1440
  constructor(unitId) {
1390
1441
  __publicField(this, "id");
1391
1442
  __publicField(this, "value", !0);
1392
- __publicField(this, "type", G.Workbook);
1443
+ __publicField(this, "type", l.Workbook);
1393
1444
  __publicField(this, "status", PermissionStatus.INIT);
1394
1445
  __publicField(this, "subType", P.RenameSheet);
1395
1446
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.RenameSheet}_${unitId}`;
@@ -1401,7 +1452,7 @@ const _WorkbookCreateSheetPermission = class _WorkbookCreateSheetPermission {
1401
1452
  constructor(unitId) {
1402
1453
  __publicField(this, "id");
1403
1454
  __publicField(this, "value", !0);
1404
- __publicField(this, "type", G.Workbook);
1455
+ __publicField(this, "type", l.Workbook);
1405
1456
  __publicField(this, "status", PermissionStatus.INIT);
1406
1457
  __publicField(this, "subType", P.CreateSheet);
1407
1458
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CreateSheet}_${unitId}`;
@@ -1413,7 +1464,7 @@ const _WorkbookHistoryPermission = class _WorkbookHistoryPermission {
1413
1464
  constructor(unitId) {
1414
1465
  __publicField(this, "id");
1415
1466
  __publicField(this, "value", !0);
1416
- __publicField(this, "type", G.Workbook);
1467
+ __publicField(this, "type", l.Workbook);
1417
1468
  __publicField(this, "status", PermissionStatus.INIT);
1418
1469
  __publicField(this, "subType", P.History);
1419
1470
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.History}_${unitId}`;
@@ -1425,7 +1476,7 @@ const _WorkbookViewPermission = class _WorkbookViewPermission {
1425
1476
  constructor(unitId) {
1426
1477
  __publicField(this, "id");
1427
1478
  __publicField(this, "value", !0);
1428
- __publicField(this, "type", G.Workbook);
1479
+ __publicField(this, "type", l.Workbook);
1429
1480
  __publicField(this, "status", PermissionStatus.INIT);
1430
1481
  __publicField(this, "subType", P.View);
1431
1482
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.View}_${unitId}`;
@@ -1437,7 +1488,7 @@ const _WorkbookSharePermission = class _WorkbookSharePermission {
1437
1488
  constructor(unitId) {
1438
1489
  __publicField(this, "id");
1439
1490
  __publicField(this, "value", !0);
1440
- __publicField(this, "type", G.Workbook);
1491
+ __publicField(this, "type", l.Workbook);
1441
1492
  __publicField(this, "status", PermissionStatus.INIT);
1442
1493
  __publicField(this, "subType", P.Share);
1443
1494
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Share}_${unitId}`;
@@ -1449,7 +1500,7 @@ const _WorkbookCopyPermission = class _WorkbookCopyPermission {
1449
1500
  constructor(unitId) {
1450
1501
  __publicField(this, "id");
1451
1502
  __publicField(this, "value", !0);
1452
- __publicField(this, "type", G.Workbook);
1503
+ __publicField(this, "type", l.Workbook);
1453
1504
  __publicField(this, "status", PermissionStatus.INIT);
1454
1505
  __publicField(this, "subType", P.Copy);
1455
1506
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Copy}_${unitId}`;
@@ -1461,7 +1512,7 @@ const _WorkbookCopySheetPermission = class _WorkbookCopySheetPermission {
1461
1512
  constructor(unitId) {
1462
1513
  __publicField(this, "id");
1463
1514
  __publicField(this, "value", !0);
1464
- __publicField(this, "type", G.Workbook);
1515
+ __publicField(this, "type", l.Workbook);
1465
1516
  __publicField(this, "subType", P.CopySheet);
1466
1517
  __publicField(this, "status", PermissionStatus.INIT);
1467
1518
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CopySheet}_${unitId}`;
@@ -1473,7 +1524,7 @@ const _WorkbookManageCollaboratorPermission = class _WorkbookManageCollaboratorP
1473
1524
  constructor(unitId) {
1474
1525
  __publicField(this, "id");
1475
1526
  __publicField(this, "value", !0);
1476
- __publicField(this, "type", G.Workbook);
1527
+ __publicField(this, "type", l.Workbook);
1477
1528
  __publicField(this, "status", PermissionStatus.INIT);
1478
1529
  __publicField(this, "subType", P.ManageCollaborator);
1479
1530
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}`;
@@ -1485,7 +1536,7 @@ const _WorkbookViewHistoryPermission = class _WorkbookViewHistoryPermission {
1485
1536
  constructor(unitId) {
1486
1537
  __publicField(this, "id");
1487
1538
  __publicField(this, "value", !0);
1488
- __publicField(this, "type", G.Workbook);
1539
+ __publicField(this, "type", l.Workbook);
1489
1540
  __publicField(this, "status", PermissionStatus.INIT);
1490
1541
  __publicField(this, "subType", P.ViewHistory);
1491
1542
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ViewHistory}_${unitId}`;
@@ -1497,7 +1548,7 @@ const _WorkbookRecoverHistoryPermission = class _WorkbookRecoverHistoryPermissio
1497
1548
  constructor(unitId) {
1498
1549
  __publicField(this, "id");
1499
1550
  __publicField(this, "value", !0);
1500
- __publicField(this, "type", G.Workbook);
1551
+ __publicField(this, "type", l.Workbook);
1501
1552
  __publicField(this, "status", PermissionStatus.INIT);
1502
1553
  __publicField(this, "subType", P.RecoverHistory);
1503
1554
  this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.RecoverHistory}_${unitId}`;
@@ -1507,7 +1558,7 @@ __name(_WorkbookRecoverHistoryPermission, "WorkbookRecoverHistoryPermission");
1507
1558
  let WorkbookRecoverHistoryPermission = _WorkbookRecoverHistoryPermission;
1508
1559
  const _RangeProtectionPermissionEditPoint = class _RangeProtectionPermissionEditPoint {
1509
1560
  constructor(unitId, subUnitId, permissionId) {
1510
- __publicField(this, "type", G.SelectRange);
1561
+ __publicField(this, "type", l.SelectRange);
1511
1562
  __publicField(this, "subType", P.Edit);
1512
1563
  __publicField(this, "status", PermissionStatus.INIT);
1513
1564
  __publicField(this, "value", !0);
@@ -1515,14 +1566,14 @@ const _RangeProtectionPermissionEditPoint = class _RangeProtectionPermissionEdit
1515
1566
  __publicField(this, "unitId");
1516
1567
  __publicField(this, "subUnitId");
1517
1568
  __publicField(this, "permissionId");
1518
- this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${G.SelectRange}.${P.Edit}.${permissionId}`;
1569
+ this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${l.SelectRange}.${P.Edit}.${permissionId}`;
1519
1570
  }
1520
1571
  };
1521
1572
  __name(_RangeProtectionPermissionEditPoint, "RangeProtectionPermissionEditPoint");
1522
1573
  let RangeProtectionPermissionEditPoint = _RangeProtectionPermissionEditPoint;
1523
1574
  const _RangeProtectionPermissionViewPoint = class _RangeProtectionPermissionViewPoint {
1524
1575
  constructor(unitId, subUnitId, permissionId) {
1525
- __publicField(this, "type", G.SelectRange);
1576
+ __publicField(this, "type", l.SelectRange);
1526
1577
  __publicField(this, "subType", P.View);
1527
1578
  __publicField(this, "status", PermissionStatus.INIT);
1528
1579
  __publicField(this, "value", !0);
@@ -1530,7 +1581,7 @@ const _RangeProtectionPermissionViewPoint = class _RangeProtectionPermissionView
1530
1581
  __publicField(this, "unitId");
1531
1582
  __publicField(this, "subUnitId");
1532
1583
  __publicField(this, "permissionId");
1533
- this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${G.SelectRange}.${P.View}.${permissionId}`;
1584
+ this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${l.SelectRange}.${P.View}.${permissionId}`;
1534
1585
  }
1535
1586
  };
1536
1587
  __name(_RangeProtectionPermissionViewPoint, "RangeProtectionPermissionViewPoint");
@@ -2095,7 +2146,13 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2095
2146
  }, undoRowInsertionParams = InsertRowMutationUndoFactory(
2096
2147
  accessor,
2097
2148
  insertRowParams
2098
- ), redos = [{ id: InsertRowMutation.id, params: insertRowParams }], undos = [{ id: RemoveRowMutation.id, params: undoRowInsertionParams }];
2149
+ );
2150
+ if (!await sheetInterceptorService.beforeCommandExecute({
2151
+ id: InsertRowCommand.id,
2152
+ params: insertRowParams
2153
+ }))
2154
+ return !1;
2155
+ const redos = [{ id: InsertRowMutation.id, params: insertRowParams }], undos = [{ id: RemoveRowMutation.id, params: undoRowInsertionParams }];
2099
2156
  cellValue && redos.push({
2100
2157
  id: SetRangeValuesMutation.id,
2101
2158
  params: {
@@ -2197,7 +2254,13 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2197
2254
  }, undoColInsertionParams = InsertColMutationUndoFactory(
2198
2255
  accessor,
2199
2256
  insertColParams
2200
- ), redos = [{ id: InsertColMutation.id, params: insertColParams }], undos = [{ id: RemoveColMutation.id, params: undoColInsertionParams }];
2257
+ );
2258
+ if (!await sheetInterceptorService.beforeCommandExecute({
2259
+ id: InsertColCommand.id,
2260
+ params: insertColParams
2261
+ }))
2262
+ return !1;
2263
+ const redos = [{ id: InsertColMutation.id, params: insertColParams }], undos = [{ id: RemoveColMutation.id, params: undoColInsertionParams }];
2201
2264
  cellValue && redos.push({
2202
2265
  id: SetRangeValuesMutation.id,
2203
2266
  params: {
@@ -2545,6 +2608,11 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2545
2608
  });
2546
2609
  } else
2547
2610
  ranges.push(totalRange);
2611
+ if (!await sheetInterceptorService.beforeCommandExecute({
2612
+ id: RemoveRowCommand.id,
2613
+ params: { range: totalRange }
2614
+ }))
2615
+ return !1;
2548
2616
  const redos = [], undos = [];
2549
2617
  ranges.forEach((range) => {
2550
2618
  const removeRowsParams = {
@@ -2611,7 +2679,13 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2611
2679
  unitId,
2612
2680
  subUnitId,
2613
2681
  cellValue: removedCols.getMatrix()
2614
- }, intercepted = sheetInterceptorService.onCommandExecute({
2682
+ };
2683
+ if (!await sheetInterceptorService.beforeCommandExecute({
2684
+ id: RemoveColCommand.id,
2685
+ params: { range }
2686
+ }))
2687
+ return !1;
2688
+ const intercepted = sheetInterceptorService.onCommandExecute({
2615
2689
  id: RemoveColCommand.id,
2616
2690
  params: { range }
2617
2691
  }), commandService = accessor.get(ICommandService);
@@ -4846,8 +4920,8 @@ let WorksheetProtectionRuleModel = (_a4 = class {
4846
4920
  }
4847
4921
  }), this._model = result;
4848
4922
  }
4849
- deleteUnitModel() {
4850
- this._model.clear();
4923
+ deleteUnitModel(unitId) {
4924
+ this._model.delete(unitId);
4851
4925
  }
4852
4926
  _ensureSubUnitMap(unitId) {
4853
4927
  let subUnitMap = this._model.get(unitId);
@@ -4957,8 +5031,8 @@ let RangeProtectionRuleModel = (_a5 = class {
4957
5031
  }), result.set(unitId, map2);
4958
5032
  }), this._model = result;
4959
5033
  }
4960
- deleteUnitModel() {
4961
- this._model.clear();
5034
+ deleteUnitModel(unitId) {
5035
+ this._model.delete(unitId);
4962
5036
  }
4963
5037
  createRuleId(unitId, subUnitId) {
4964
5038
  let id = Tools.generateRandomId(4);
@@ -5050,8 +5124,8 @@ let WorksheetProtectionPointModel = (_a6 = class {
5050
5124
  }
5051
5125
  }), this._model = result;
5052
5126
  }
5053
- deleteUnitModel() {
5054
- this._model.clear();
5127
+ deleteUnitModel(unitId) {
5128
+ this._model.delete(unitId);
5055
5129
  }
5056
5130
  _ensureSubUnitMap(unitId) {
5057
5131
  let subUnitMap = this._model.get(unitId);
@@ -5161,8 +5235,8 @@ let WorksheetPermissionService = (_a7 = class extends RxDisposable {
5161
5235
  });
5162
5236
  }), this._worksheetProtectionRuleModel.changeRuleInitState(!0);
5163
5237
  }, "onLoad"),
5164
- onUnLoad: /* @__PURE__ */ __name(() => {
5165
- this._worksheetProtectionRuleModel.deleteUnitModel();
5238
+ onUnLoad: /* @__PURE__ */ __name((unitId) => {
5239
+ this._worksheetProtectionRuleModel.deleteUnitModel(unitId);
5166
5240
  }, "onUnLoad")
5167
5241
  })
5168
5242
  );
@@ -5194,8 +5268,8 @@ let WorksheetPermissionService = (_a7 = class extends RxDisposable {
5194
5268
  });
5195
5269
  });
5196
5270
  }, "onLoad"),
5197
- onUnLoad: /* @__PURE__ */ __name(() => {
5198
- this._worksheetProtectionPointRuleModel.deleteUnitModel();
5271
+ onUnLoad: /* @__PURE__ */ __name((unitId) => {
5272
+ this._worksheetProtectionPointRuleModel.deleteUnitModel(unitId);
5199
5273
  }, "onUnLoad")
5200
5274
  })
5201
5275
  );
@@ -6148,7 +6222,7 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6148
6222
  }
6149
6223
  }
6150
6224
  return runRefRangeMutations(operator, range);
6151
- }, "handleDefaultRangeChangeWithEffectRefCommands"), handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests = /* @__PURE__ */ __name((range, commandInfo, deps) => getEffectedRangesOnCommand(commandInfo, deps).some((effectRange) => Rectangle.intersects(effectRange, range)) ? handleDefaultRangeChangeWithEffectRefCommands(range, commandInfo) : range, "handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests"), handleCommonDefaultRangeChangeWithEffectRefCommands = /* @__PURE__ */ __name((range, commandInfo) => {
6225
+ }, "handleDefaultRangeChangeWithEffectRefCommands"), handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests = /* @__PURE__ */ __name((range, commandInfo, deps) => [DeleteRangeMoveLeftCommand.id, DeleteRangeMoveUpCommand.id].includes(commandInfo.id) || getEffectedRangesOnCommand(commandInfo, deps).some((effectRange) => Rectangle.intersects(effectRange, range)) ? handleDefaultRangeChangeWithEffectRefCommands(range, commandInfo) : range, "handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests"), handleCommonDefaultRangeChangeWithEffectRefCommands = /* @__PURE__ */ __name((range, commandInfo) => {
6152
6226
  let operator = [];
6153
6227
  switch (commandInfo.id) {
6154
6228
  case EffectRefRangId.DeleteRangeMoveLeftCommandId:
@@ -6224,11 +6298,14 @@ function adjustRangeOnMutation(range, mutation) {
6224
6298
  baseRangeOperator = handleBaseInsertRange(params.range, range), baseRangeOperator.type = OperatorType.HorizontalMove;
6225
6299
  break;
6226
6300
  case MoveRangeMutation.id:
6227
- baseRangeOperator = handleBaseMoveRange(
6228
- new ObjectMatrix(params.from).getRange(),
6229
- new ObjectMatrix(params.to).getRange(),
6230
- range
6231
- );
6301
+ {
6302
+ const fromRange = params.fromRange, toRange = params.toRange;
6303
+ baseRangeOperator = handleBaseMoveRange(
6304
+ fromRange,
6305
+ toRange,
6306
+ range
6307
+ );
6308
+ }
6232
6309
  break;
6233
6310
  }
6234
6311
  return baseRangeOperator ? Array.isArray(baseRangeOperator) ? runRefRangeMutations(baseRangeOperator, range) : runRefRangeMutations([baseRangeOperator], range) : range;
@@ -6338,7 +6415,7 @@ function getEffectedRangesOnMutation(mutation) {
6338
6415
  }
6339
6416
  case MoveRangeMutation.id: {
6340
6417
  const params = mutation.params;
6341
- return [new ObjectMatrix(params.from).getRange(), new ObjectMatrix(params.to).getRange()];
6418
+ return [new ObjectMatrix(params.from.value).getRange(), new ObjectMatrix(params.to.value).getRange()];
6342
6419
  }
6343
6420
  case InsertColMutation.id: {
6344
6421
  const range = mutation.params.range;
@@ -6378,7 +6455,15 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
6378
6455
  }
6379
6456
  onMutation(mutation) {
6380
6457
  var _a20, _b;
6381
- if (((_a20 = mutation.params) == null ? void 0 : _a20.unitId) !== this._unitId || ((_b = mutation.params) == null ? void 0 : _b.subUnitId) !== this._subUnitId || !this._range)
6458
+ if (((_a20 = mutation.params) == null ? void 0 : _a20.unitId) !== this._unitId)
6459
+ return;
6460
+ if (mutation.id === MoveRangeMutation.id) {
6461
+ const params = mutation.params;
6462
+ if (params.from.subUnitId !== this._subUnitId || params.to.subUnitId !== this._subUnitId)
6463
+ return;
6464
+ } else if (((_b = mutation.params) == null ? void 0 : _b.subUnitId) !== this._subUnitId)
6465
+ return;
6466
+ if (!this._range)
6382
6467
  return;
6383
6468
  if (this._skipIntersects) {
6384
6469
  const effectRanges = getEffectedRangesOnMutation(mutation);
@@ -6690,11 +6775,13 @@ function getAddMergeMutationRangeByType(selection, type) {
6690
6775
  return ranges;
6691
6776
  }
6692
6777
  __name(getAddMergeMutationRangeByType, "getAddMergeMutationRangeByType");
6778
+ const MERGE_CELL_INTERCEPTOR_CHECK = createInterceptorKey("mergeCellPermissionCheck");
6693
6779
  var _a11;
6694
6780
  let MergeCellController = (_a11 = class extends Disposable {
6695
6781
  constructor(_commandService, _refRangeService, _univerInstanceService, _injector, _sheetInterceptorService, _selectionManagerService) {
6696
6782
  super();
6697
6783
  __publicField(this, "disposableCollection", new DisposableCollection());
6784
+ __publicField(this, "interceptor", new InterceptorManager({ MERGE_CELL_INTERCEPTOR_CHECK }));
6698
6785
  this._commandService = _commandService, this._refRangeService = _refRangeService, this._univerInstanceService = _univerInstanceService, this._injector = _injector, this._sheetInterceptorService = _sheetInterceptorService, this._selectionManagerService = _selectionManagerService, this._onRefRangeChange(), this._initCommandInterceptor(), this._commandExecutedListener();
6699
6786
  }
6700
6787
  _initCommandInterceptor() {
@@ -6727,6 +6814,31 @@ let MergeCellController = (_a11 = class extends Disposable {
6727
6814
  }
6728
6815
  return { redos: [], undos: [] };
6729
6816
  }
6817
+ }), this._sheetInterceptorService.interceptRanges({
6818
+ getMutations: /* @__PURE__ */ __name(({ unitId, subUnitId, ranges }) => {
6819
+ const redos = [], undos = [], emptyInterceptorArr = { redos, undos };
6820
+ if (!ranges || !ranges.length)
6821
+ return emptyInterceptorArr;
6822
+ const target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId });
6823
+ if (!target)
6824
+ return emptyInterceptorArr;
6825
+ const { worksheet } = target, overlapRanges = worksheet.getMergeData().filter((item) => ranges.some((range) => Rectangle.intersects(item, range)));
6826
+ return overlapRanges.length ? (redos.push({
6827
+ id: RemoveWorksheetMergeMutation.id,
6828
+ params: {
6829
+ unitId,
6830
+ subUnitId,
6831
+ ranges: overlapRanges
6832
+ }
6833
+ }), undos.push({
6834
+ id: AddWorksheetMergeMutation.id,
6835
+ params: {
6836
+ unitId,
6837
+ subUnitId,
6838
+ ranges: overlapRanges
6839
+ }
6840
+ }), { undos, redos }) : emptyInterceptorArr;
6841
+ }, "getMutations")
6730
6842
  });
6731
6843
  }
6732
6844
  refRangeHandle(config, unitId, subUnitId) {
@@ -7614,7 +7726,7 @@ let RangeProtectionRenderModel = (_a15 = class {
7614
7726
  }
7615
7727
  _init() {
7616
7728
  this._permissionService.permissionPointUpdate$.pipe(
7617
- filter((permission) => permission.type === G.SelectRange),
7729
+ filter((permission) => permission.type === l.SelectRange),
7618
7730
  filter((permission) => getAllRangePermissionPoint().some((F) => permission instanceof F)),
7619
7731
  map$1((permission) => permission)
7620
7732
  ).subscribe((permission) => {
@@ -7954,7 +8066,7 @@ let RangeProtectionService = (_a17 = class extends Disposable {
7954
8066
  allAllowedParams.push({
7955
8067
  objectID: rule.permissionId,
7956
8068
  unitID: unitId,
7957
- objectType: G.SelectRange,
8069
+ objectType: l.SelectRange,
7958
8070
  actions: [P.View, P.Edit]
7959
8071
  });
7960
8072
  }), list.forEach((rule) => {
@@ -7965,8 +8077,8 @@ let RangeProtectionService = (_a17 = class extends Disposable {
7965
8077
  });
7966
8078
  });
7967
8079
  }, "onLoad"),
7968
- onUnLoad: /* @__PURE__ */ __name(() => {
7969
- this._selectionProtectionRuleModel.deleteUnitModel();
8080
+ onUnLoad: /* @__PURE__ */ __name((unitId) => {
8081
+ this._selectionProtectionRuleModel.deleteUnitModel(unitId);
7970
8082
  }, "onUnLoad")
7971
8083
  })
7972
8084
  );
@@ -8214,7 +8326,19 @@ const AddMergeRedoSelectionsOperationFactory = /* @__PURE__ */ __name((accessor,
8214
8326
  };
8215
8327
  }
8216
8328
  return null;
8217
- }, "AddMergeUndoSelectionsOperationFactory");
8329
+ }, "AddMergeUndoSelectionsOperationFactory"), checkRangesEditablePermission = /* @__PURE__ */ __name((accessor, unitId, subUnitId, ranges) => {
8330
+ const permissionService = accessor.get(IPermissionService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel$1), workbookEditablePermission = permissionService.getPermissionPoint(new WorkbookEditablePermission$1(unitId).id);
8331
+ if (!(workbookEditablePermission != null && workbookEditablePermission.value))
8332
+ return !1;
8333
+ const worksheetEditPermission = permissionService.getPermissionPoint(new WorksheetEditPermission$1(unitId, subUnitId).id);
8334
+ if (!(worksheetEditPermission != null && worksheetEditPermission.value))
8335
+ return !1;
8336
+ const ruleList = rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((ruleRange) => ranges.some((range) => Rectangle.intersects(ruleRange, range))));
8337
+ return ruleList.length ? ruleList.every((rule) => {
8338
+ const permissionId = rule.permissionId, permissionPoint = permissionService.getPermissionPoint(new RangeProtectionPermissionEditPoint$1(unitId, subUnitId, permissionId).id);
8339
+ return !!(permissionPoint != null && permissionPoint.value);
8340
+ }) : !0;
8341
+ }, "checkRangesEditablePermission");
8218
8342
  function checkCellContentInRanges(worksheet, ranges) {
8219
8343
  return ranges.some((range) => checkCellContentInRange(worksheet, range));
8220
8344
  }
@@ -8477,6 +8601,7 @@ export {
8477
8601
  InsertSheetMutation,
8478
8602
  InsertSheetUndoMutationFactory,
8479
8603
  MAX_CELL_PER_SHEET_KEY,
8604
+ MERGE_CELL_INTERCEPTOR_CHECK,
8480
8605
  MergeCellController,
8481
8606
  MoveColsCommand,
8482
8607
  MoveColsMutation,
@@ -8634,6 +8759,7 @@ export {
8634
8759
  WorksheetSortPermission,
8635
8760
  WorksheetViewPermission,
8636
8761
  alignToMergedCellsBorders,
8762
+ checkRangesEditablePermission,
8637
8763
  convertPrimaryWithCoordToPrimary,
8638
8764
  convertSelectionDataToRange,
8639
8765
  createTopMatrixFromMatrix,
@@ -8645,6 +8771,7 @@ export {
8645
8771
  factorySetNumfmtUndoMutation,
8646
8772
  findAllRectangle,
8647
8773
  followSelectionOperation,
8774
+ generateNullCell,
8648
8775
  generateNullCellValue,
8649
8776
  getAddMergeMutationRangeByType,
8650
8777
  getAllRangePermissionPoint,