@univerjs/sheets 1.0.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +80 -40
- package/lib/cjs/index.js +322 -186
- package/lib/es/facade.js +76 -36
- package/lib/es/index.js +298 -164
- package/lib/facade.js +76 -36
- package/lib/index.js +298 -164
- package/lib/types/commands/commands/set-workbook-calculation-settings.command.d.ts +18 -0
- package/lib/types/commands/mutations/set-workbook-calculation-settings.mutation.d.ts +21 -0
- package/lib/types/config/config.d.ts +8 -0
- package/lib/types/controllers/auto-fill.controller.d.ts +3 -0
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +10 -4
- package/lib/types/facade/f-range.d.ts +2 -1
- package/lib/types/facade/f-workbook.d.ts +31 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/services/auto-fill/auto-fill.service.d.ts +3 -3
- package/lib/types/services/auto-fill/type.d.ts +8 -1
- package/lib/types/services/permission/workbook-permission/util.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
package/lib/facade.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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, WorksheetHiddenState, 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, SetShrinkToFitCommand, 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";
|
|
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, SetShrinkToFitCommand, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorkbookCalculationSettingsCommand, 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
5
|
import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protocol";
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ import { ObjectScope, UnitAction, UnitObject, UnitRole } from "@univerjs/protoco
|
|
|
23
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
24
|
|
|
25
25
|
//#endregion
|
|
26
|
-
//#region \0@oxc-project+runtime@0.
|
|
26
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
27
27
|
function _typeof(o) {
|
|
28
28
|
"@babel/helpers - typeof";
|
|
29
29
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -34,7 +34,7 @@ function _typeof(o) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
38
38
|
function toPrimitive(t, r) {
|
|
39
39
|
if ("object" != _typeof(t) || !t) return t;
|
|
40
40
|
var e = t[Symbol.toPrimitive];
|
|
@@ -47,14 +47,14 @@ function toPrimitive(t, r) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region \0@oxc-project+runtime@0.
|
|
50
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
51
51
|
function toPropertyKey(t) {
|
|
52
52
|
var i = toPrimitive(t, "string");
|
|
53
53
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
|
-
//#region \0@oxc-project+runtime@0.
|
|
57
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
58
58
|
function _defineProperty(e, r, t) {
|
|
59
59
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
60
60
|
value: t,
|
|
@@ -65,7 +65,7 @@ function _defineProperty(e, r, t) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region \0@oxc-project+runtime@0.
|
|
68
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
69
69
|
function __decorateParam(paramIndex, decorator) {
|
|
70
70
|
return function(target, key) {
|
|
71
71
|
decorator(target, key, paramIndex);
|
|
@@ -73,7 +73,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region \0@oxc-project+runtime@0.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
77
77
|
function __decorate(decorators, target, key, desc) {
|
|
78
78
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
79
79
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6545,6 +6545,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
6545
6545
|
* Returns a copy of the range expanded `Direction.UP` and `Direction.DOWN` if the specified dimension is `Dimension.ROWS`, or `Direction.NEXT` and `Direction.PREVIOUS` if the dimension is `Dimension.COLUMNS`.
|
|
6546
6546
|
* The expansion of the range is based on detecting data next to the range that is organized like a table.
|
|
6547
6547
|
* The expanded range covers all adjacent cells with data in them along the specified dimension including the table boundaries.
|
|
6548
|
+
* Cells connected only diagonally do not cause the range to expand.
|
|
6548
6549
|
* If the original range is surrounded by empty cells along the specified dimension, the range itself is returned.
|
|
6549
6550
|
* @param {Dimension} [dimension] - The dimension along which to expand the range. If not provided, the range will be expanded in both dimensions.
|
|
6550
6551
|
* @returns {FRange} The range's data region or a range covering each column or each row spanned by the original range.
|
|
@@ -6565,7 +6566,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
6565
6566
|
* fWorksheet.getRange('D3').setValue(100);
|
|
6566
6567
|
* fWorksheet.getRange('C4').setValue(100);
|
|
6567
6568
|
*
|
|
6568
|
-
* // Get C3 data region along the rows dimension, the range will be C2:
|
|
6569
|
+
* // Get C3 data region along the rows dimension, the range will be C2:C4
|
|
6569
6570
|
* const range = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.ROWS);
|
|
6570
6571
|
* console.log(range.getA1Notation()); // C2:C4
|
|
6571
6572
|
*
|
|
@@ -6579,41 +6580,43 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
6579
6580
|
* ```
|
|
6580
6581
|
*/
|
|
6581
6582
|
getDataRegion(dimension) {
|
|
6582
|
-
|
|
6583
|
+
let { startRow, startColumn, endRow, endColumn } = this._range;
|
|
6583
6584
|
const maxRows = this._worksheet.getMaxRows();
|
|
6584
6585
|
const maxColumns = this._worksheet.getMaxColumns();
|
|
6585
6586
|
const cellMatrix = this._worksheet.getCellMatrix();
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
let
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6587
|
+
const rowHasData = (row) => {
|
|
6588
|
+
for (let c = startColumn; c <= endColumn; c++) if (!isNullCell(cellMatrix.getValue(row, c))) return true;
|
|
6589
|
+
return false;
|
|
6590
|
+
};
|
|
6591
|
+
const columnHasData = (column) => {
|
|
6592
|
+
for (let r = startRow; r <= endRow; r++) if (!isNullCell(cellMatrix.getValue(r, column))) return true;
|
|
6593
|
+
return false;
|
|
6594
|
+
};
|
|
6595
|
+
let expanded = true;
|
|
6596
|
+
while (expanded) {
|
|
6597
|
+
expanded = false;
|
|
6598
|
+
while (dimension !== Dimension.COLUMNS && startRow > 0 && rowHasData(startRow - 1)) {
|
|
6599
|
+
startRow--;
|
|
6600
|
+
expanded = true;
|
|
6597
6601
|
}
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6602
|
+
while (dimension !== Dimension.COLUMNS && endRow < maxRows - 1 && rowHasData(endRow + 1)) {
|
|
6603
|
+
endRow++;
|
|
6604
|
+
expanded = true;
|
|
6605
|
+
}
|
|
6606
|
+
while (dimension !== Dimension.ROWS && startColumn > 0 && columnHasData(startColumn - 1)) {
|
|
6607
|
+
startColumn--;
|
|
6608
|
+
expanded = true;
|
|
6609
|
+
}
|
|
6610
|
+
while (dimension !== Dimension.ROWS && endColumn < maxColumns - 1 && columnHasData(endColumn + 1)) {
|
|
6611
|
+
endColumn++;
|
|
6612
|
+
expanded = true;
|
|
6608
6613
|
}
|
|
6609
|
-
if (leftColumnHasValue) newStartColumn = startColumn - 1;
|
|
6610
|
-
if (rightColumnHasValue) newEndColumn = endColumn + 1;
|
|
6611
6614
|
}
|
|
6612
6615
|
return this._injector.createInstance(_FRange, this._workbook, this._worksheet, {
|
|
6613
|
-
startRow
|
|
6614
|
-
startColumn
|
|
6615
|
-
endRow
|
|
6616
|
-
endColumn
|
|
6616
|
+
startRow,
|
|
6617
|
+
startColumn,
|
|
6618
|
+
endRow,
|
|
6619
|
+
endColumn
|
|
6617
6620
|
});
|
|
6618
6621
|
}
|
|
6619
6622
|
/**
|
|
@@ -8110,6 +8113,43 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
8110
8113
|
removeStyles(styleKeys) {
|
|
8111
8114
|
this._workbook.removeStyles(styleKeys);
|
|
8112
8115
|
}
|
|
8116
|
+
/**
|
|
8117
|
+
* Get the workbook's iterative calculation settings.
|
|
8118
|
+
* Missing or invalid settings use the defaults: iteration disabled, 100 iterations and a maximum change of 0.001.
|
|
8119
|
+
* @returns {IWorkbookCalculationSettings} A copy of the normalized workbook calculation settings.
|
|
8120
|
+
* @example
|
|
8121
|
+
* ```ts
|
|
8122
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
8123
|
+
* const settings = fWorkbook.getCalculationSettings();
|
|
8124
|
+
* console.log(settings.iterativeCalculation, settings.maxIterations, settings.maxChange);
|
|
8125
|
+
* ```
|
|
8126
|
+
*/
|
|
8127
|
+
getCalculationSettings() {
|
|
8128
|
+
return this._workbook.getCalculationSettings();
|
|
8129
|
+
}
|
|
8130
|
+
/**
|
|
8131
|
+
* Set iterative calculation settings for the entire workbook through an undoable command.
|
|
8132
|
+
* @param {IWorkbookCalculationSettings} settings The complete calculation settings.
|
|
8133
|
+
* Set `iterativeCalculation` to enable or disable iterative evaluation of circular references.
|
|
8134
|
+
* `maxIterations` must be an integer from 1 to 32767, and `maxChange` must be a finite positive number.
|
|
8135
|
+
* @returns {boolean} Whether the settings command succeeded. Returns false if the workbook cannot be edited or found.
|
|
8136
|
+
* @example
|
|
8137
|
+
* ```ts
|
|
8138
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
8139
|
+
* const success = fWorkbook.setCalculationSettings({
|
|
8140
|
+
* iterativeCalculation: true,
|
|
8141
|
+
* maxIterations: 100,
|
|
8142
|
+
* maxChange: 0.001,
|
|
8143
|
+
* });
|
|
8144
|
+
* console.log('Calculation settings updated:', success);
|
|
8145
|
+
* ```
|
|
8146
|
+
*/
|
|
8147
|
+
setCalculationSettings(settings) {
|
|
8148
|
+
return this._commandService.syncExecuteCommand(SetWorkbookCalculationSettingsCommand.id, {
|
|
8149
|
+
unitId: this.id,
|
|
8150
|
+
settings
|
|
8151
|
+
});
|
|
8152
|
+
}
|
|
8113
8153
|
};
|
|
8114
8154
|
FWorkbook = __decorate([
|
|
8115
8155
|
__decorateParam(1, Inject(Injector)),
|