@univerjs/sheets 0.25.1 → 1.0.0-alpha.1

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 (44) hide show
  1. package/lib/cjs/facade.js +199 -264
  2. package/lib/cjs/index.js +171 -124
  3. package/lib/es/facade.js +200 -259
  4. package/lib/es/index.js +374 -321
  5. package/lib/facade.js +200 -259
  6. package/lib/index.js +374 -321
  7. package/lib/types/commands/commands/add-range-protection.command.d.ts +1 -1
  8. package/lib/types/commands/commands/delete-range-protection.command.d.ts +1 -1
  9. package/lib/types/commands/commands/register-range-theme.command.d.ts +1 -1
  10. package/lib/types/commands/commands/set-protection.command.d.ts +1 -1
  11. package/lib/types/commands/mutations/add-range-protection.mutation.d.ts +1 -1
  12. package/lib/types/commands/mutations/add-range-theme.mutation.d.ts +1 -1
  13. package/lib/types/commands/mutations/register-range-theme.mutation.d.ts +1 -1
  14. package/lib/types/commands/mutations/set-range-protection.mutation.d.ts +1 -1
  15. package/lib/types/commands/mutations/set-range-theme.mutation.d.ts +1 -1
  16. package/lib/types/commands/mutations/set-range-values.mutation.d.ts +4 -3
  17. package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +1 -1
  18. package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +1 -1
  19. package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +1 -1
  20. package/lib/types/controllers/zebar-crossing.controller.d.ts +1 -1
  21. package/lib/types/facade/{f-sheet-hooks.d.ts → const.d.ts} +1 -9
  22. package/lib/types/facade/f-range.d.ts +3 -2
  23. package/lib/types/facade/f-univer.d.ts +33 -64
  24. package/lib/types/facade/f-workbook.d.ts +3 -45
  25. package/lib/types/facade/index.d.ts +0 -1
  26. package/lib/types/index.d.ts +186 -106
  27. package/lib/types/locale/types.d.ts +18 -0
  28. package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +3 -3
  29. package/lib/types/services/permission/range-permission/range-protection.service.d.ts +2 -2
  30. package/lib/types/services/permission/type.d.ts +1 -1
  31. package/lib/types/services/permission/workbook-permission/workbook-permission.service.d.ts +1 -1
  32. package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +1 -1
  33. package/lib/types/services/range-theme.service.d.ts +3 -3
  34. package/lib/umd/facade.js +1 -1
  35. package/lib/umd/index.js +1 -1
  36. package/package.json +9 -9
  37. /package/lib/types/{model → models}/range-protection-render.model.d.ts +0 -0
  38. /package/lib/types/{model → models}/range-protection-rule.model.d.ts +0 -0
  39. /package/lib/types/{model → models}/range-protection.cache.d.ts +0 -0
  40. /package/lib/types/{model → models}/range-theme-model.d.ts +0 -0
  41. /package/lib/types/{model → models}/range-theme-util.d.ts +0 -0
  42. /package/lib/types/{model → models}/range-themes/build-in-theme.factory.d.ts +0 -0
  43. /package/lib/types/{model → models}/range-themes/default.d.ts +0 -0
  44. /package/lib/types/{model → models}/zebra-crossing-cache.d.ts +0 -0
package/lib/es/facade.js CHANGED
@@ -1,10 +1,29 @@
1
- import { BooleanNumber, CanceledError, DEFAULT_STYLES, Dimension, Direction, HorizontalAlign, IAuthzIoService, ICommandService, ILogService, IPermissionService, IResourceLoaderService, IUniverInstanceService, Inject, Injector, LocaleService, ObjectMatrix, RANGE_TYPE, Rectangle, RedoCommand, RichTextValue, TextStyleValue, Tools, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, cellToRange, covertCellValue, covertCellValues, generateIntervalsByPoints, generateRandomId, isNullCell, mergeWorksheetSnapshotWithDefault, toDisposable } from "@univerjs/core";
1
+ import { BooleanNumber, CanceledError, DEFAULT_STYLES, Dimension, Direction, HorizontalAlign, IAuthzIoService, ICommandService, ILogService, IPermissionService, IResourceLoaderService, IUniverInstanceService, Inject, Injector, LocaleService, ObjectMatrix, RANGE_TYPE, Rectangle, RedoCommand, RichTextValue, TextStyleValue, Tools, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, cellToRange, covertCellValue, covertCellValues, generateIntervalsByPoints, generateRandomId, getDisplayValueFromCell, getOriginCellValue, isNullCell, mergeWorksheetSnapshotWithDefault, toDisposable } from "@univerjs/core";
2
2
  import { FBase, FBaseInitialable, FEnum, FEventName, FUniver } from "@univerjs/core/facade";
3
- import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, AppendRowCommand, AutoFillCommand, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionMutation, DeleteWorksheetRangeThemeStyleCommand, EditStateEnum, InsertColByRangeCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowByRangeCommand, InsertSheetCommand, MoveColsCommand, MoveRowsCommand, RangeProtectionPermissionDeleteProtectionPoint, RangeProtectionPermissionEditPoint, RangeProtectionPermissionManageCollaPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RangeThemeStyle, RegisterWorksheetRangeThemeStyleCommand, RemoveColByRangeCommand, RemoveDefinedNameCommand, RemoveRowByRangeCommand, RemoveSheetCommand, RemoveWorksheetMergeCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetBorderBasicCommand, SetColDataCommand, SetColHiddenCommand, SetColWidthCommand, SetDefinedNameCommand, SetFrozenCommand, SetGridlinesColorCommand, SetHorizontalTextAlignCommand, SetRangeCustomMetadataCommand, SetRangeProtectionMutation, SetRangeValuesCommand, SetRowDataCommand, SetRowHeightCommand, SetRowHiddenCommand, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorkbookNameCommand, SetWorksheetActiveOperation, SetWorksheetColumnCountCommand, SetWorksheetDefaultStyleMutation, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetRangeThemeStyleCommand, SetWorksheetRowCountCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetRangeThemeService, SheetSkeletonChangeType, SheetValueChangeType, SheetsFreezeSyncController, SheetsSelectionsService, SplitDelimiterEnum, SplitTextToColumnsCommand, ToggleGridlinesCommand, UnitObject, UnregisterWorksheetRangeThemeStyleCommand, ViewStateEnum, WorkbookCommentPermission, WorkbookCopyPermission, WorkbookCopySheetPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookDuplicatePermission, WorkbookEditablePermission, WorkbookExportPermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookMoveSheetPermission, WorkbookPrintPermission, WorkbookRecoverHistoryPermission, WorkbookRenameSheetPermission, WorkbookSharePermission, WorkbookViewHistoryPermission, WorkbookViewPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditExtraObjectPermission, WorksheetEditPermission, WorksheetFilterPermission, WorksheetInsertColumnPermission, WorksheetInsertHyperlinkPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetPivotTablePermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSelectProtectedCellsPermission, WorksheetSelectUnProtectedCellsPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetSortPermission, WorksheetViewPermission, addMergeCellsUtil, copyRangeStyles, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, getNextPrimaryCell, getPrimaryForRange, getValueChangedEffectedRange, validateDefinedName } from "@univerjs/sheets";
3
+ import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, AppendRowCommand, AutoFillCommand, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionMutation, DeleteWorksheetRangeThemeStyleCommand, EditStateEnum, InsertColByRangeCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowByRangeCommand, InsertSheetCommand, MoveColsCommand, MoveRowsCommand, RangeProtectionPermissionDeleteProtectionPoint, RangeProtectionPermissionEditPoint, RangeProtectionPermissionManageCollaPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RangeThemeStyle, RegisterWorksheetRangeThemeStyleCommand, RemoveColByRangeCommand, RemoveDefinedNameCommand, RemoveRowByRangeCommand, RemoveSheetCommand, RemoveWorksheetMergeCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetBorderBasicCommand, SetColDataCommand, SetColHiddenCommand, SetColWidthCommand, SetDefinedNameCommand, SetFrozenCommand, SetGridlinesColorCommand, SetHorizontalTextAlignCommand, SetRangeCustomMetadataCommand, SetRangeProtectionMutation, SetRangeValuesCommand, SetRowDataCommand, SetRowHeightCommand, SetRowHiddenCommand, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorkbookNameCommand, SetWorksheetActiveOperation, SetWorksheetColumnCountCommand, SetWorksheetDefaultStyleMutation, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetRangeThemeStyleCommand, SetWorksheetRowCountCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetRangeThemeService, SheetSkeletonChangeType, SheetValueChangeType, SheetsFreezeSyncController, SheetsSelectionsService, SplitDelimiterEnum, SplitTextToColumnsCommand, ToggleGridlinesCommand, UnregisterWorksheetRangeThemeStyleCommand, ViewStateEnum, WorkbookCommentPermission, WorkbookCopyPermission, WorkbookCopySheetPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookDuplicatePermission, WorkbookEditablePermission, WorkbookExportPermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookMoveSheetPermission, WorkbookPrintPermission, WorkbookRecoverHistoryPermission, WorkbookRenameSheetPermission, WorkbookSharePermission, WorkbookViewHistoryPermission, WorkbookViewPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditExtraObjectPermission, WorksheetEditPermission, WorksheetFilterPermission, WorksheetInsertColumnPermission, WorksheetInsertHyperlinkPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetPivotTablePermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSelectProtectedCellsPermission, WorksheetSelectUnProtectedCellsPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetSortPermission, WorksheetViewPermission, addMergeCellsUtil, copyRangeStyles, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, getNextPrimaryCell, getPrimaryForRange, getValueChangedEffectedRange, validateDefinedName } from "@univerjs/sheets";
4
4
  import { FormulaDataModel, IDefinedNamesService, IFunctionService, ISuperTableService, deserializeRangeWithSheet, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
5
- import { ObjectScope, UnitAction, UnitObject as UnitObject$1, UnitRole } from "@univerjs/protocol";
5
+ import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protocol";
6
6
 
7
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
7
+ //#region src/facade/const.ts
8
+ /**
9
+ * Copyright 2023-present DreamNum Co., Ltd.
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ const SHEETS_CUSTOM_FIELD_WARNING_MESSAGE = "[Facade]: The sheets custom field is not recommended for external use. Use it at your own risk.";
24
+
25
+ //#endregion
26
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
8
27
  function _typeof(o) {
9
28
  "@babel/helpers - typeof";
10
29
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -15,7 +34,7 @@ function _typeof(o) {
15
34
  }
16
35
 
17
36
  //#endregion
18
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
37
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
19
38
  function toPrimitive(t, r) {
20
39
  if ("object" != _typeof(t) || !t) return t;
21
40
  var e = t[Symbol.toPrimitive];
@@ -28,14 +47,14 @@ function toPrimitive(t, r) {
28
47
  }
29
48
 
30
49
  //#endregion
31
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
50
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
32
51
  function toPropertyKey(t) {
33
52
  var i = toPrimitive(t, "string");
34
53
  return "symbol" == _typeof(i) ? i : i + "";
35
54
  }
36
55
 
37
56
  //#endregion
38
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
57
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
39
58
  function _defineProperty(e, r, t) {
40
59
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
60
  value: t,
@@ -46,7 +65,7 @@ function _defineProperty(e, r, t) {
46
65
  }
47
66
 
48
67
  //#endregion
49
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
68
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
50
69
  function __decorateParam(paramIndex, decorator) {
51
70
  return function(target, key) {
52
71
  decorator(target, key, paramIndex);
@@ -54,7 +73,7 @@ function __decorateParam(paramIndex, decorator) {
54
73
  }
55
74
 
56
75
  //#endregion
57
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
76
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
58
77
  function __decorate(decorators, target, key, desc) {
59
78
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
79
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -74,7 +93,7 @@ function __decorate(decorators, target, key, desc) {
74
93
  function getDefinedNameFieldName(unitId, localeService, definedNamesService) {
75
94
  const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
76
95
  if (definedNameMap == null) return localeService.t("sheets.definedName.defaultName") + 1;
77
- const count = Array.from(Object.values(definedNameMap)).length + 1;
96
+ const count = Object.values(definedNameMap).length + 1;
78
97
  const name = localeService.t("sheets.definedName.defaultName") + count;
79
98
  if (definedNamesService.getValueByName(unitId, name) == null) return name;
80
99
  let i = count + 1;
@@ -2865,6 +2884,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
2865
2884
  * ```
2866
2885
  */
2867
2886
  setRowCustom(custom) {
2887
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
2868
2888
  const unitId = this._workbook.getUnitId();
2869
2889
  const subUnitId = this._worksheet.getSheetId();
2870
2890
  const rowData = {};
@@ -3307,6 +3327,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3307
3327
  * ```
3308
3328
  */
3309
3329
  setColumnCustom(custom) {
3330
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
3310
3331
  const unitId = this._workbook.getUnitId();
3311
3332
  const subUnitId = this._worksheet.getSheetId();
3312
3333
  const columnData = {};
@@ -4020,6 +4041,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4020
4041
  * ```
4021
4042
  */
4022
4043
  setCustomMetadata(custom) {
4044
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
4023
4045
  this._worksheet.setCustomMetadata(custom);
4024
4046
  return this;
4025
4047
  }
@@ -4036,6 +4058,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4036
4058
  * ```
4037
4059
  */
4038
4060
  getCustomMetadata() {
4061
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
4039
4062
  return this._worksheet.getCustomMetadata();
4040
4063
  }
4041
4064
  /**
@@ -4052,6 +4075,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4052
4075
  * ```
4053
4076
  */
4054
4077
  setRowCustomMetadata(index, custom) {
4078
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
4055
4079
  this._worksheet.getRowManager().setCustomMetadata(index, custom);
4056
4080
  return this;
4057
4081
  }
@@ -4069,6 +4093,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4069
4093
  * ```
4070
4094
  */
4071
4095
  setColumnCustomMetadata(index, custom) {
4096
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
4072
4097
  this._worksheet.getColumnManager().setCustomMetadata(index, custom);
4073
4098
  return this;
4074
4099
  }
@@ -4086,6 +4111,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4086
4111
  * ```
4087
4112
  */
4088
4113
  getRowCustomMetadata(index) {
4114
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
4089
4115
  return this._worksheet.getRowManager().getCustomMetadata(index);
4090
4116
  }
4091
4117
  /**
@@ -4102,6 +4128,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
4102
4128
  * ```
4103
4129
  */
4104
4130
  getColumnCustomMetadata(index) {
4131
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
4105
4132
  return this._worksheet.getColumnManager().getCustomMetadata(index);
4106
4133
  }
4107
4134
  /**
@@ -4299,7 +4326,7 @@ let FRangePermission = class FRangePermission extends FBase {
4299
4326
  });
4300
4327
  }
4301
4328
  const permissionId = await this._authzIoService.create({
4302
- objectType: UnitObject$1.SelectRange,
4329
+ objectType: UnitObject.SelectRange,
4303
4330
  selectRangeObject: {
4304
4331
  collaborators,
4305
4332
  unitID: this._unitId,
@@ -4316,7 +4343,7 @@ let FRangePermission = class FRangePermission extends FBase {
4316
4343
  permissionId,
4317
4344
  id: ruleId,
4318
4345
  description: options === null || options === void 0 ? void 0 : options.name,
4319
- unitType: UnitObject$1.SelectRange,
4346
+ unitType: UnitObject.SelectRange,
4320
4347
  unitId: this._unitId,
4321
4348
  subUnitId: this._subUnitId,
4322
4349
  viewState,
@@ -4380,7 +4407,7 @@ FRangePermission = __decorate([
4380
4407
  //#region src/facade/f-range.ts
4381
4408
  var _FRange, _FRange2;
4382
4409
  let FRange = _FRange = class FRange extends FBaseInitialable {
4383
- constructor(_workbook, _worksheet, _range, _injector, _commandService, _formulaDataModel) {
4410
+ constructor(_workbook, _worksheet, _range, _injector, _commandService, _formulaDataModel, _logService) {
4384
4411
  super(_injector);
4385
4412
  this._workbook = _workbook;
4386
4413
  this._worksheet = _worksheet;
@@ -4388,6 +4415,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4388
4415
  this._injector = _injector;
4389
4416
  this._commandService = _commandService;
4390
4417
  this._formulaDataModel = _formulaDataModel;
4418
+ this._logService = _logService;
4391
4419
  const maxRows = this._worksheet.getRowCount();
4392
4420
  const maxColumns = this._worksheet.getColumnCount();
4393
4421
  if (this._range.startRow < 0 || this._range.startColumn < 0 || this._range.endRow >= maxRows || this._range.endColumn >= maxColumns) throw new Error(`Range is out of bounds. Max rows: ${maxRows}, Max columns: ${maxColumns}, Given range: ${JSON.stringify(this._range)}`);
@@ -4704,10 +4732,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4704
4732
  * ```
4705
4733
  */
4706
4734
  getRawValue() {
4707
- var _cell$p$body, _cell$v;
4708
- const cell = this._worksheet.getCellMatrix().getValue(this._range.startRow, this._range.startColumn);
4709
- if ((cell === null || cell === void 0 ? void 0 : cell.p) && ((_cell$p$body = cell.p.body) === null || _cell$p$body === void 0 ? void 0 : _cell$p$body.dataStream)) return cell.p.body.dataStream;
4710
- return (_cell$v = cell === null || cell === void 0 ? void 0 : cell.v) !== null && _cell$v !== void 0 ? _cell$v : null;
4735
+ return getOriginCellValue(this._worksheet.getCellMatrix().getValue(this._range.startRow, this._range.startColumn));
4711
4736
  }
4712
4737
  /**
4713
4738
  * Returns the displayed value of the top-left cell in the range. The value is a String. Empty cells return an empty string.
@@ -4730,10 +4755,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4730
4755
  * ```
4731
4756
  */
4732
4757
  getDisplayValue() {
4733
- var _cell$p$body2, _cell$v$toString, _cell$v2;
4734
- const cell = this._worksheet.getCell(this._range.startRow, this._range.startColumn);
4735
- if ((cell === null || cell === void 0 ? void 0 : cell.p) && ((_cell$p$body2 = cell.p.body) === null || _cell$p$body2 === void 0 ? void 0 : _cell$p$body2.dataStream)) return cell.p.body.dataStream;
4736
- return (_cell$v$toString = cell === null || cell === void 0 || (_cell$v2 = cell.v) === null || _cell$v2 === void 0 ? void 0 : _cell$v2.toString()) !== null && _cell$v$toString !== void 0 ? _cell$v$toString : "";
4758
+ return getDisplayValueFromCell(this._worksheet.getCell(this._range.startRow, this._range.startColumn));
4737
4759
  }
4738
4760
  getValues(includeRichText) {
4739
4761
  if (includeRichText) return this.getValueAndRichTextValues();
@@ -4799,13 +4821,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4799
4821
  for (let r = startRow; r <= endRow; r++) {
4800
4822
  const row = [];
4801
4823
  for (let c = startColumn; c <= endColumn; c++) {
4802
- var _cell$p$body3;
4803
- const cell = cellMatrix.getValue(r, c);
4804
- if ((cell === null || cell === void 0 ? void 0 : cell.p) && ((_cell$p$body3 = cell.p.body) === null || _cell$p$body3 === void 0 ? void 0 : _cell$p$body3.dataStream)) row.push(cell.p.body.dataStream);
4805
- else {
4806
- var _cell$v3;
4807
- row.push((_cell$v3 = cell === null || cell === void 0 ? void 0 : cell.v) !== null && _cell$v3 !== void 0 ? _cell$v3 : null);
4808
- }
4824
+ const rawValue = getOriginCellValue(cellMatrix.getValue(r, c));
4825
+ row.push(rawValue);
4809
4826
  }
4810
4827
  values.push(row);
4811
4828
  }
@@ -4860,13 +4877,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
4860
4877
  for (let r = startRow; r <= endRow; r++) {
4861
4878
  const row = [];
4862
4879
  for (let c = startColumn; c <= endColumn; c++) {
4863
- var _cell$p$body4;
4864
- const cell = this._worksheet.getCell(r, c);
4865
- if ((cell === null || cell === void 0 ? void 0 : cell.p) && ((_cell$p$body4 = cell.p.body) === null || _cell$p$body4 === void 0 ? void 0 : _cell$p$body4.dataStream)) row.push(cell.p.body.dataStream);
4866
- else {
4867
- var _cell$v$toString2, _cell$v4;
4868
- row.push((_cell$v$toString2 = cell === null || cell === void 0 || (_cell$v4 = cell.v) === null || _cell$v4 === void 0 ? void 0 : _cell$v4.toString()) !== null && _cell$v$toString2 !== void 0 ? _cell$v$toString2 : "");
4869
- }
4880
+ const displayValue = getDisplayValueFromCell(this._worksheet.getCell(r, c));
4881
+ row.push(displayValue);
4870
4882
  }
4871
4883
  values.push(row);
4872
4884
  }
@@ -5160,6 +5172,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5160
5172
  * ```
5161
5173
  */
5162
5174
  setCustomMetaData(data) {
5175
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5163
5176
  const params = {
5164
5177
  unitId: this._workbook.getUnitId(),
5165
5178
  subUnitId: this._worksheet.getSheetId(),
@@ -5186,6 +5199,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5186
5199
  * ```
5187
5200
  */
5188
5201
  setCustomMetaDatas(datas) {
5202
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5189
5203
  const params = {
5190
5204
  unitId: this._workbook.getUnitId(),
5191
5205
  subUnitId: this._worksheet.getSheetId(),
@@ -5209,6 +5223,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5209
5223
  */
5210
5224
  getCustomMetaData() {
5211
5225
  var _cell$custom;
5226
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5212
5227
  const cell = this.getCellData();
5213
5228
  return (_cell$custom = cell === null || cell === void 0 ? void 0 : cell.custom) !== null && _cell$custom !== void 0 ? _cell$custom : null;
5214
5229
  }
@@ -5225,6 +5240,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
5225
5240
  * ```
5226
5241
  */
5227
5242
  getCustomMetaDatas() {
5243
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
5228
5244
  return this.getCellDataGrid().map((row) => row.map((data) => {
5229
5245
  var _data$custom;
5230
5246
  return (_data$custom = data === null || data === void 0 ? void 0 : data.custom) !== null && _data$custom !== void 0 ? _data$custom : null;
@@ -6663,7 +6679,8 @@ _FRange2._enableManualInit();
6663
6679
  FRange = _FRange = __decorate([
6664
6680
  __decorateParam(3, Inject(Injector)),
6665
6681
  __decorateParam(4, ICommandService),
6666
- __decorateParam(5, Inject(FormulaDataModel))
6682
+ __decorateParam(5, Inject(FormulaDataModel)),
6683
+ __decorateParam(6, ILogService)
6667
6684
  ], FRange);
6668
6685
 
6669
6686
  //#endregion
@@ -6780,7 +6797,7 @@ let FWorkbookPermission = class FWorkbookPermission extends FBase {
6780
6797
  if (permissionPoint && permissionPoint.value === value) return;
6781
6798
  if (!permissionPoint) this._permissionService.addPermissionPoint(instance);
6782
6799
  await this._authzIoService.update({
6783
- objectType: UnitObject$1.Workbook,
6800
+ objectType: UnitObject.Workbook,
6784
6801
  objectID: this._unitId,
6785
6802
  unitID: this._unitId,
6786
6803
  share: void 0,
@@ -6999,7 +7016,7 @@ FWorkbookPermission = __decorate([
6999
7016
  //#endregion
7000
7017
  //#region src/facade/f-workbook.ts
7001
7018
  let FWorkbook = class FWorkbook extends FBaseInitialable {
7002
- constructor(_workbook, _injector, _resourceLoaderService, _selectionManagerService, _univerInstanceService, _commandService, _permissionService, _logService, _localeService, _definedNamesService) {
7019
+ constructor(_workbook, _injector, _resourceLoaderService, _selectionManagerService, _univerInstanceService, _commandService, _permissionService, _logService, _definedNamesService) {
7003
7020
  super(_injector);
7004
7021
  this._workbook = _workbook;
7005
7022
  this._injector = _injector;
@@ -7009,7 +7026,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7009
7026
  this._commandService = _commandService;
7010
7027
  this._permissionService = _permissionService;
7011
7028
  this._logService = _logService;
7012
- this._localeService = _localeService;
7013
7029
  this._definedNamesService = _definedNamesService;
7014
7030
  _defineProperty(this, "id", void 0);
7015
7031
  this.id = this._workbook.getUnitId();
@@ -7092,21 +7108,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7092
7108
  return this._resourceLoaderService.saveUnit(this._workbook.getUnitId());
7093
7109
  }
7094
7110
  /**
7095
- * @deprecated use 'save' instead.
7096
- * @returns {IWorkbookData} Workbook snapshot data
7097
- * @memberof FWorkbook
7098
- * @example
7099
- * ```ts
7100
- * // The code below saves the workbook snapshot data
7101
- * const activeSpreadsheet = univerAPI.getActiveWorkbook();
7102
- * const snapshot = activeSpreadsheet.getSnapshot();
7103
- * ```
7104
- */
7105
- getSnapshot() {
7106
- this._logService.warn("use 'save' instead of 'getSnapshot'");
7107
- return this.save();
7108
- }
7109
- /**
7110
7111
  * Get the active sheet of the workbook.
7111
7112
  * @returns {FWorksheet} The active sheet of the workbook
7112
7113
  * @example
@@ -7580,42 +7581,6 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7580
7581
  return this._workbook.getSheets().length;
7581
7582
  }
7582
7583
  /**
7583
- * Get the locale of the workbook.
7584
- * @returns {LocaleType} The locale of the workbook
7585
- * @example
7586
- * ```ts
7587
- * // The code below gets the locale of the workbook
7588
- * const fWorkbook = univerAPI.getActiveWorkbook();
7589
- * console.log(fWorkbook.getLocale());
7590
- * ```
7591
- */
7592
- getLocale() {
7593
- return this._localeService.getCurrentLocale();
7594
- }
7595
- /**
7596
- * @deprecated use `setSpreadsheetLocale` instead.
7597
- * @param {LocaleType} locale - The locale to set
7598
- */
7599
- setLocale(locale) {
7600
- this._localeService.setLocale(locale);
7601
- }
7602
- /**
7603
- * Set the locale of the workbook.
7604
- * @param {LocaleType} locale The locale to set
7605
- * @returns {FWorkbook} This workbook, for chaining
7606
- * @example
7607
- * ```ts
7608
- * // The code below sets the locale of the workbook
7609
- * const fWorkbook = univerAPI.getActiveWorkbook();
7610
- * fWorkbook.setSpreadsheetLocale(univerAPI.Enum.LocaleType.EN_US);
7611
- * console.log(fWorkbook.getLocale());
7612
- * ```
7613
- */
7614
- setSpreadsheetLocale(locale) {
7615
- this._localeService.setLocale(locale);
7616
- return this;
7617
- }
7618
- /**
7619
7584
  * Get the URL of the workbook.
7620
7585
  * @returns {string} The URL of the workbook
7621
7586
  * @example
@@ -7920,6 +7885,7 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7920
7885
  * ```
7921
7886
  */
7922
7887
  setCustomMetadata(custom) {
7888
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
7923
7889
  this._workbook.setCustomMetadata(custom);
7924
7890
  return this;
7925
7891
  }
@@ -7934,6 +7900,7 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
7934
7900
  * ```
7935
7901
  */
7936
7902
  getCustomMetadata() {
7903
+ this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
7937
7904
  return this._workbook.getCustomMetadata();
7938
7905
  }
7939
7906
  /**
@@ -8023,62 +7990,52 @@ FWorkbook = __decorate([
8023
7990
  __decorateParam(5, ICommandService),
8024
7991
  __decorateParam(6, IPermissionService),
8025
7992
  __decorateParam(7, ILogService),
8026
- __decorateParam(8, Inject(LocaleService)),
8027
- __decorateParam(9, IDefinedNamesService)
7993
+ __decorateParam(8, IDefinedNamesService)
8028
7994
  ], FWorkbook);
8029
7995
 
8030
7996
  //#endregion
8031
7997
  //#region src/facade/f-univer.ts
8032
7998
  var FUniverSheetsMixin = class extends FUniver {
8033
- getCommandSheetTarget(commandInfo) {
8034
- var _this$getActiveWorkbo;
8035
- const params = commandInfo.params;
8036
- if (!params) return this.getActiveSheet();
8037
- const workbook = params.unitId ? this.getUniverSheet(params.unitId) : (_this$getActiveWorkbo = this.getActiveWorkbook) === null || _this$getActiveWorkbo === void 0 ? void 0 : _this$getActiveWorkbo.call(this);
8038
- if (!workbook) return;
8039
- const worksheet = workbook.getSheetBySheetId(params.subUnitId || params.sheetId) || workbook.getActiveSheet();
8040
- if (!worksheet) return;
7999
+ createWorkbook(data, options) {
8000
+ const workbook = this._injector.get(IUniverInstanceService).createUnit(UniverInstanceType.UNIVER_SHEET, data, options);
8001
+ return this._injector.createInstance(FWorkbook, workbook);
8002
+ }
8003
+ getActiveWorkbook() {
8004
+ const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
8005
+ if (!workbook) return null;
8006
+ return this._injector.createInstance(FWorkbook, workbook);
8007
+ }
8008
+ getWorkbook(id) {
8009
+ const workbook = this._univerInstanceService.getUnit(id, UniverInstanceType.UNIVER_SHEET);
8010
+ if (!workbook) return null;
8011
+ return this._injector.createInstance(FWorkbook, workbook);
8012
+ }
8013
+ getSheetCommandTarget(params = {}) {
8014
+ const { unitId, subUnitId, sheetId } = params;
8015
+ const workbook = unitId ? this.getWorkbook(unitId) : this.getActiveWorkbook();
8016
+ if (!workbook) return null;
8017
+ const sheetIdToFind = subUnitId || sheetId;
8018
+ const worksheet = sheetIdToFind ? workbook.getSheetBySheetId(sheetIdToFind) : workbook.getActiveSheet();
8019
+ if (!worksheet) return null;
8041
8020
  return {
8042
8021
  workbook,
8043
- worksheet
8022
+ worksheet,
8023
+ unitId: workbook.getId(),
8024
+ subUnitId: worksheet.getSheetId()
8044
8025
  };
8045
8026
  }
8046
- getSheetTarget(unitId, subUnitId) {
8047
- const workbook = this.getUniverSheet(unitId);
8048
- if (!workbook) return;
8049
- const worksheet = workbook.getSheetBySheetId(subUnitId);
8050
- if (!worksheet) return;
8027
+ getActiveSheet() {
8028
+ const workbook = this.getActiveWorkbook();
8029
+ if (!workbook) return null;
8030
+ const worksheet = workbook.getActiveSheet();
8031
+ if (!worksheet) return null;
8051
8032
  return {
8052
8033
  workbook,
8053
8034
  worksheet
8054
8035
  };
8055
8036
  }
8056
- _initWorkbookEvent(injector) {
8057
- const univerInstanceService = injector.get(IUniverInstanceService);
8058
- this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookDisposed, () => univerInstanceService.unitDisposed$.subscribe((unit) => {
8059
- if (unit.type === UniverInstanceType.UNIVER_SHEET) {
8060
- const eventParams = {
8061
- unitId: unit.getUnitId(),
8062
- unitType: unit.type,
8063
- snapshot: unit.getSnapshot()
8064
- };
8065
- this.fireEvent(this.Event.WorkbookDisposed, eventParams);
8066
- }
8067
- })));
8068
- this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookCreated, () => univerInstanceService.unitAdded$.subscribe((event) => {
8069
- const { unit } = event;
8070
- if (unit.type === UniverInstanceType.UNIVER_SHEET) {
8071
- const workbook = unit;
8072
- const workbookUnit = injector.createInstance(FWorkbook, workbook);
8073
- const eventParams = {
8074
- unitId: unit.getUnitId(),
8075
- type: unit.type,
8076
- workbook: workbookUnit,
8077
- unit: workbookUnit
8078
- };
8079
- this.fireEvent(this.Event.WorkbookCreated, eventParams);
8080
- }
8081
- })));
8037
+ setFreezeSync(enabled) {
8038
+ this._injector.get(SheetsFreezeSyncController).setEnabled(enabled);
8082
8039
  }
8083
8040
  /**
8084
8041
  * @ignore
@@ -8088,9 +8045,8 @@ var FUniverSheetsMixin = class extends FUniver {
8088
8045
  const commandService = injector.get(ICommandService);
8089
8046
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetCreate, () => commandService.beforeCommandExecuted((commandInfo) => {
8090
8047
  if (commandInfo.id === InsertSheetCommand.id) {
8091
- var _this$getActiveWorkbo2;
8092
8048
  const { unitId, index, sheet } = commandInfo.params || {};
8093
- const workbook = unitId ? this.getUniverSheet(unitId) : (_this$getActiveWorkbo2 = this.getActiveWorkbook) === null || _this$getActiveWorkbo2 === void 0 ? void 0 : _this$getActiveWorkbo2.call(this);
8049
+ const workbook = unitId ? this.getWorkbook(unitId) : this.getActiveWorkbook();
8094
8050
  if (!workbook) return;
8095
8051
  const eventParams = {
8096
8052
  workbook,
@@ -8103,11 +8059,10 @@ var FUniverSheetsMixin = class extends FUniver {
8103
8059
  })));
8104
8060
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeActiveSheetChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8105
8061
  if (commandInfo.id === SetWorksheetActiveOperation.id) {
8106
- var _this$getActiveWorkbo3;
8107
- const { subUnitId: sheetId, unitId } = commandInfo.params;
8108
- const workbook = unitId ? this.getUniverSheet(unitId) : (_this$getActiveWorkbo3 = this.getActiveWorkbook) === null || _this$getActiveWorkbo3 === void 0 ? void 0 : _this$getActiveWorkbo3.call(this);
8109
- if (!workbook || !sheetId) return;
8110
- const activeSheet = workbook.getSheetBySheetId(sheetId);
8062
+ const params = commandInfo.params;
8063
+ const target = this.getSheetCommandTarget(params);
8064
+ if (!target) return;
8065
+ const { workbook, worksheet: activeSheet } = target;
8111
8066
  const oldActiveSheet = workbook.getActiveSheet();
8112
8067
  if (!activeSheet || !oldActiveSheet) return;
8113
8068
  const eventParams = {
@@ -8121,7 +8076,8 @@ var FUniverSheetsMixin = class extends FUniver {
8121
8076
  })));
8122
8077
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDelete, () => commandService.beforeCommandExecuted((commandInfo) => {
8123
8078
  if (commandInfo.id === RemoveSheetCommand.id) {
8124
- const target = this.getCommandSheetTarget(commandInfo);
8079
+ const params = commandInfo.params;
8080
+ const target = this.getSheetCommandTarget(params);
8125
8081
  if (!target) return;
8126
8082
  const { workbook, worksheet } = target;
8127
8083
  const eventParams = {
@@ -8134,14 +8090,16 @@ var FUniverSheetsMixin = class extends FUniver {
8134
8090
  })));
8135
8091
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetMove, () => commandService.beforeCommandExecuted((commandInfo) => {
8136
8092
  if (commandInfo.id === SetWorksheetOrderMutation.id) {
8137
- const { fromOrder, toOrder } = commandInfo.params;
8138
- const target = this.getCommandSheetTarget(commandInfo);
8093
+ const params = commandInfo.params;
8094
+ const target = this.getSheetCommandTarget(params);
8139
8095
  if (!target) return;
8096
+ const { workbook, worksheet } = target;
8097
+ const { fromOrder: oldIndex, toOrder: newIndex } = params;
8140
8098
  const eventParams = {
8141
- workbook: target.workbook,
8142
- worksheet: target.worksheet,
8143
- newIndex: toOrder,
8144
- oldIndex: fromOrder
8099
+ workbook,
8100
+ worksheet,
8101
+ newIndex,
8102
+ oldIndex
8145
8103
  };
8146
8104
  this.fireEvent(this.Event.BeforeSheetMove, eventParams);
8147
8105
  if (eventParams.cancel) throw new CanceledError();
@@ -8149,14 +8107,17 @@ var FUniverSheetsMixin = class extends FUniver {
8149
8107
  })));
8150
8108
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNameChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8151
8109
  if (commandInfo.id === SetWorksheetNameCommand.id) {
8152
- const { name } = commandInfo.params;
8153
- const target = this.getCommandSheetTarget(commandInfo);
8110
+ const params = commandInfo.params;
8111
+ const target = this.getSheetCommandTarget(params);
8154
8112
  if (!target) return;
8113
+ const { workbook, worksheet } = target;
8114
+ const oldName = worksheet.getSheetName();
8115
+ const { name: newName } = params;
8155
8116
  const eventParams = {
8156
- workbook: target.workbook,
8157
- worksheet: target.worksheet,
8158
- newName: name,
8159
- oldName: target.worksheet.getSheetName()
8117
+ workbook,
8118
+ worksheet,
8119
+ newName,
8120
+ oldName
8160
8121
  };
8161
8122
  this.fireEvent(this.Event.BeforeSheetNameChange, eventParams);
8162
8123
  if (eventParams.cancel) throw new CanceledError();
@@ -8164,14 +8125,17 @@ var FUniverSheetsMixin = class extends FUniver {
8164
8125
  })));
8165
8126
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetTabColorChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8166
8127
  if (commandInfo.id === SetTabColorMutation.id) {
8167
- const { color } = commandInfo.params;
8168
- const target = this.getCommandSheetTarget(commandInfo);
8128
+ const params = commandInfo.params;
8129
+ const target = this.getSheetCommandTarget(params);
8169
8130
  if (!target) return;
8131
+ const { workbook, worksheet } = target;
8132
+ const oldColor = worksheet.getTabColor();
8133
+ const { color: newColor } = params;
8170
8134
  const eventParams = {
8171
- workbook: target.workbook,
8172
- worksheet: target.worksheet,
8173
- newColor: color,
8174
- oldColor: target.worksheet.getTabColor()
8135
+ workbook,
8136
+ worksheet,
8137
+ newColor,
8138
+ oldColor
8175
8139
  };
8176
8140
  this.fireEvent(this.Event.BeforeSheetTabColorChange, eventParams);
8177
8141
  if (eventParams.cancel) throw new CanceledError();
@@ -8179,12 +8143,14 @@ var FUniverSheetsMixin = class extends FUniver {
8179
8143
  })));
8180
8144
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetHideChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8181
8145
  if (commandInfo.id === SetWorksheetHideMutation.id) {
8182
- const { hidden } = commandInfo.params;
8183
- const target = this.getCommandSheetTarget(commandInfo);
8146
+ const params = commandInfo.params;
8147
+ const target = this.getSheetCommandTarget(params);
8184
8148
  if (!target) return;
8149
+ const { workbook, worksheet } = target;
8150
+ const { hidden } = params;
8185
8151
  const eventParams = {
8186
- workbook: target.workbook,
8187
- worksheet: target.worksheet,
8152
+ workbook,
8153
+ worksheet,
8188
8154
  hidden: Boolean(hidden)
8189
8155
  };
8190
8156
  this.fireEvent(this.Event.BeforeSheetHideChange, eventParams);
@@ -8193,12 +8159,15 @@ var FUniverSheetsMixin = class extends FUniver {
8193
8159
  })));
8194
8160
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineColorChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8195
8161
  if (commandInfo.id === SetGridlinesColorCommand.id) {
8196
- var _commandInfo$params;
8197
- const target = this.getCommandSheetTarget(commandInfo);
8162
+ const params = commandInfo.params;
8163
+ const target = this.getSheetCommandTarget(params);
8198
8164
  if (!target) return;
8165
+ const { workbook, worksheet } = target;
8166
+ const { color } = params;
8199
8167
  const eventParams = {
8200
- ...target,
8201
- color: (_commandInfo$params = commandInfo.params) === null || _commandInfo$params === void 0 ? void 0 : _commandInfo$params.color
8168
+ workbook,
8169
+ worksheet,
8170
+ color
8202
8171
  };
8203
8172
  this.fireEvent(this.Event.BeforeGridlineColorChange, eventParams);
8204
8173
  if (eventParams.cancel) throw new CanceledError();
@@ -8206,12 +8175,15 @@ var FUniverSheetsMixin = class extends FUniver {
8206
8175
  })));
8207
8176
  this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineEnableChange, () => commandService.beforeCommandExecuted((commandInfo) => {
8208
8177
  if (commandInfo.id === ToggleGridlinesCommand.id) {
8209
- var _showGridlines, _commandInfo$params2;
8210
- const target = this.getCommandSheetTarget(commandInfo);
8178
+ var _params$showGridlines;
8179
+ const params = commandInfo.params;
8180
+ const target = this.getSheetCommandTarget(params);
8211
8181
  if (!target) return;
8212
- const showGridlines = (_showGridlines = (_commandInfo$params2 = commandInfo.params) === null || _commandInfo$params2 === void 0 ? void 0 : _commandInfo$params2.showGridlines) !== null && _showGridlines !== void 0 ? _showGridlines : !target.worksheet.hasHiddenGridLines();
8182
+ const { workbook, worksheet } = target;
8183
+ const showGridlines = (_params$showGridlines = params.showGridlines) !== null && _params$showGridlines !== void 0 ? _params$showGridlines : !worksheet.hasHiddenGridLines();
8213
8184
  const eventParams = {
8214
- ...target,
8185
+ workbook,
8186
+ worksheet,
8215
8187
  enabled: Boolean(showGridlines)
8216
8188
  };
8217
8189
  this.fireEvent(this.Event.BeforeGridlineEnableChange, eventParams);
@@ -8235,11 +8207,12 @@ var FUniverSheetsMixin = class extends FUniver {
8235
8207
  })));
8236
8208
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetCreated, () => commandService.onCommandExecuted((commandInfo) => {
8237
8209
  if (commandInfo.id === InsertSheetCommand.id) {
8238
- var _this$getActiveWorkbo4;
8239
- const { unitId } = commandInfo.params || {};
8240
- const workbook = unitId ? this.getUniverSheet(unitId) : (_this$getActiveWorkbo4 = this.getActiveWorkbook) === null || _this$getActiveWorkbo4 === void 0 ? void 0 : _this$getActiveWorkbo4.call(this);
8210
+ var _params$sheet, _params$index;
8211
+ const params = commandInfo.params;
8212
+ const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? this.getWorkbook(params.unitId) : this.getActiveWorkbook();
8241
8213
  if (!workbook) return;
8242
- const worksheet = workbook.getActiveSheet();
8214
+ const sheets = workbook.getSheets();
8215
+ const worksheet = (params === null || params === void 0 || (_params$sheet = params.sheet) === null || _params$sheet === void 0 ? void 0 : _params$sheet.id) ? workbook.getSheetBySheetId(params.sheet.id) : sheets[(_params$index = params === null || params === void 0 ? void 0 : params.index) !== null && _params$index !== void 0 ? _params$index : sheets.length - 1];
8243
8216
  if (!worksheet) return;
8244
8217
  const eventParams = {
8245
8218
  workbook,
@@ -8250,7 +8223,8 @@ var FUniverSheetsMixin = class extends FUniver {
8250
8223
  })));
8251
8224
  this.disposeWithMe(this.registerEventHandler(this.Event.ActiveSheetChanged, () => commandService.onCommandExecuted((commandInfo) => {
8252
8225
  if (commandInfo.id === SetWorksheetActiveOperation.id) {
8253
- const target = this.getActiveSheet();
8226
+ const params = commandInfo.params;
8227
+ const target = this.getSheetCommandTarget(params);
8254
8228
  if (!target) return;
8255
8229
  const { workbook, worksheet: activeSheet } = target;
8256
8230
  const eventParams = {
@@ -8262,9 +8236,8 @@ var FUniverSheetsMixin = class extends FUniver {
8262
8236
  })));
8263
8237
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetDeleted, () => commandService.onCommandExecuted((commandInfo) => {
8264
8238
  if (commandInfo.id === RemoveSheetCommand.id) {
8265
- var _this$getActiveWorkbo5;
8266
- const { subUnitId: sheetId, unitId } = commandInfo.params;
8267
- const workbook = unitId ? this.getUniverSheet(unitId) : (_this$getActiveWorkbo5 = this.getActiveWorkbook) === null || _this$getActiveWorkbo5 === void 0 ? void 0 : _this$getActiveWorkbo5.call(this);
8239
+ const { unitId, subUnitId: sheetId } = commandInfo.params;
8240
+ const workbook = unitId ? this.getWorkbook(unitId) : this.getActiveWorkbook();
8268
8241
  if (!workbook || !sheetId) return;
8269
8242
  const eventParams = {
8270
8243
  workbook,
@@ -8275,52 +8248,56 @@ var FUniverSheetsMixin = class extends FUniver {
8275
8248
  })));
8276
8249
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetMoved, () => commandService.onCommandExecuted((commandInfo) => {
8277
8250
  if (commandInfo.id === SetWorksheetOrderMutation.id) {
8278
- const { toOrder: toIndex } = commandInfo.params;
8279
- const target = this.getCommandSheetTarget(commandInfo);
8251
+ const params = commandInfo.params;
8252
+ const target = this.getSheetCommandTarget(params);
8280
8253
  if (!target) return;
8281
8254
  const { workbook, worksheet } = target;
8255
+ const { toOrder: newIndex } = params;
8282
8256
  const eventParams = {
8283
8257
  workbook,
8284
8258
  worksheet,
8285
- newIndex: toIndex
8259
+ newIndex
8286
8260
  };
8287
8261
  this.fireEvent(this.Event.SheetMoved, eventParams);
8288
8262
  }
8289
8263
  })));
8290
8264
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetNameChanged, () => commandService.onCommandExecuted((commandInfo) => {
8291
8265
  if (commandInfo.id === SetWorksheetNameCommand.id) {
8292
- const { name } = commandInfo.params;
8293
- const target = this.getCommandSheetTarget(commandInfo);
8266
+ const params = commandInfo.params;
8267
+ const target = this.getSheetCommandTarget(params);
8294
8268
  if (!target) return;
8295
8269
  const { workbook, worksheet } = target;
8270
+ const { name: newName } = params;
8296
8271
  const eventParams = {
8297
8272
  workbook,
8298
8273
  worksheet,
8299
- newName: name
8274
+ newName
8300
8275
  };
8301
8276
  this.fireEvent(this.Event.SheetNameChanged, eventParams);
8302
8277
  }
8303
8278
  })));
8304
8279
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetTabColorChanged, () => commandService.onCommandExecuted((commandInfo) => {
8305
8280
  if (commandInfo.id === SetTabColorMutation.id) {
8306
- const { color } = commandInfo.params;
8307
- const target = this.getCommandSheetTarget(commandInfo);
8281
+ const params = commandInfo.params;
8282
+ const target = this.getSheetCommandTarget(params);
8308
8283
  if (!target) return;
8309
8284
  const { workbook, worksheet } = target;
8285
+ const { color: newColor } = params;
8310
8286
  const eventParams = {
8311
8287
  workbook,
8312
8288
  worksheet,
8313
- newColor: color
8289
+ newColor
8314
8290
  };
8315
8291
  this.fireEvent(this.Event.SheetTabColorChanged, eventParams);
8316
8292
  }
8317
8293
  })));
8318
8294
  this.disposeWithMe(this.registerEventHandler(this.Event.SheetHideChanged, () => commandService.onCommandExecuted((commandInfo) => {
8319
8295
  if (commandInfo.id === SetWorksheetHideMutation.id) {
8320
- const { hidden } = commandInfo.params;
8321
- const target = this.getCommandSheetTarget(commandInfo);
8296
+ const params = commandInfo.params;
8297
+ const target = this.getSheetCommandTarget(params);
8322
8298
  if (!target) return;
8323
8299
  const { workbook, worksheet } = target;
8300
+ const { hidden } = params;
8324
8301
  const eventParams = {
8325
8302
  workbook,
8326
8303
  worksheet,
@@ -8331,58 +8308,47 @@ var FUniverSheetsMixin = class extends FUniver {
8331
8308
  })));
8332
8309
  this.disposeWithMe(this.registerEventHandler(this.Event.GridlineChanged, () => commandService.onCommandExecuted((commandInfo) => {
8333
8310
  if (commandInfo.id === SetGridlinesColorCommand.id || commandInfo.id === ToggleGridlinesCommand.id) {
8334
- const target = this.getCommandSheetTarget(commandInfo);
8311
+ const params = commandInfo.params;
8312
+ const target = this.getSheetCommandTarget(params);
8335
8313
  if (!target) return;
8314
+ const { workbook, worksheet } = target;
8336
8315
  const eventParams = {
8337
- ...target,
8338
- enabled: !target.worksheet.hasHiddenGridLines(),
8339
- color: target.worksheet.getGridLinesColor()
8316
+ workbook,
8317
+ worksheet,
8318
+ enabled: !worksheet.hasHiddenGridLines(),
8319
+ color: worksheet.getGridLinesColor()
8340
8320
  };
8341
8321
  this.fireEvent(this.Event.GridlineChanged, eventParams);
8342
8322
  }
8343
8323
  })));
8344
8324
  this._initWorkbookEvent(injector);
8345
8325
  }
8346
- createUniverSheet(data, options) {
8347
- const workbook = this._injector.get(IUniverInstanceService).createUnit(UniverInstanceType.UNIVER_SHEET, data, options);
8348
- return this._injector.createInstance(FWorkbook, workbook);
8349
- }
8350
- createWorkbook(data, options) {
8351
- return this.createUniverSheet(data, options);
8352
- }
8353
- getActiveWorkbook() {
8354
- const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
8355
- if (!workbook) return null;
8356
- return this._injector.createInstance(FWorkbook, workbook);
8357
- }
8358
- getActiveUniverSheet() {
8359
- return this.getActiveWorkbook();
8360
- }
8361
- getUniverSheet(id) {
8362
- const workbook = this._univerInstanceService.getUnit(id, UniverInstanceType.UNIVER_SHEET);
8363
- if (!workbook) return null;
8364
- return this._injector.createInstance(FWorkbook, workbook);
8365
- }
8366
- getWorkbook(id) {
8367
- return this.getUniverSheet(id);
8368
- }
8369
- onUniverSheetCreated(callback) {
8370
- return toDisposable(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((event) => {
8371
- callback(this._injector.createInstance(FWorkbook, event.unit));
8372
- }));
8373
- }
8374
- getActiveSheet() {
8375
- const workbook = this.getActiveWorkbook();
8376
- if (!workbook) return null;
8377
- const worksheet = workbook.getActiveSheet();
8378
- if (!worksheet) return null;
8379
- return {
8380
- workbook,
8381
- worksheet
8382
- };
8383
- }
8384
- setFreezeSync(enabled) {
8385
- this._injector.get(SheetsFreezeSyncController).setEnabled(enabled);
8326
+ _initWorkbookEvent(injector) {
8327
+ const univerInstanceService = injector.get(IUniverInstanceService);
8328
+ this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookDisposed, () => univerInstanceService.unitDisposed$.subscribe((unit) => {
8329
+ if (unit.type === UniverInstanceType.UNIVER_SHEET) {
8330
+ const eventParams = {
8331
+ unitId: unit.getUnitId(),
8332
+ unitType: unit.type,
8333
+ snapshot: unit.getSnapshot()
8334
+ };
8335
+ this.fireEvent(this.Event.WorkbookDisposed, eventParams);
8336
+ }
8337
+ })));
8338
+ this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookCreated, () => univerInstanceService.unitAdded$.subscribe((event) => {
8339
+ const { unit } = event;
8340
+ if (unit.type === UniverInstanceType.UNIVER_SHEET) {
8341
+ const workbook = unit;
8342
+ const workbookUnit = injector.createInstance(FWorkbook, workbook);
8343
+ const eventParams = {
8344
+ unitId: unit.getUnitId(),
8345
+ type: unit.type,
8346
+ workbook: workbookUnit,
8347
+ unit: workbookUnit
8348
+ };
8349
+ this.fireEvent(this.Event.WorkbookCreated, eventParams);
8350
+ }
8351
+ })));
8386
8352
  }
8387
8353
  };
8388
8354
  FUniver.extend(FUniverSheetsMixin);
@@ -8496,29 +8462,4 @@ var FSheetsEventNameMixin = class extends FEventName {
8496
8462
  FEventName.extend(FSheetsEventNameMixin);
8497
8463
 
8498
8464
  //#endregion
8499
- //#region src/facade/f-sheet-hooks.ts
8500
- /**
8501
- * Copyright 2023-present DreamNum Co., Ltd.
8502
- *
8503
- * Licensed under the Apache License, Version 2.0 (the "License");
8504
- * you may not use this file except in compliance with the License.
8505
- * You may obtain a copy of the License at
8506
- *
8507
- * http://www.apache.org/licenses/LICENSE-2.0
8508
- *
8509
- * Unless required by applicable law or agreed to in writing, software
8510
- * distributed under the License is distributed on an "AS IS" BASIS,
8511
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8512
- * See the License for the specific language governing permissions and
8513
- * limitations under the License.
8514
- */
8515
- let FSheetHooks = class FSheetHooks extends FBase {
8516
- constructor(_injector) {
8517
- super();
8518
- this._injector = _injector;
8519
- }
8520
- };
8521
- FSheetHooks = __decorate([__decorateParam(0, Inject(Injector))], FSheetHooks);
8522
-
8523
- //#endregion
8524
- export { FRange, FSelection, FSheetHooks, FSheetsEnumMixin, FSheetsEventNameMixin, FWorkbook, FWorkbookPermission, FWorksheet };
8465
+ export { FRange, FSelection, FSheetsEnumMixin, FSheetsEventNameMixin, FWorkbook, FWorkbookPermission, FWorksheet };