@univerjs/sheets 1.0.0-alpha.7 → 1.0.0-beta.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 +65 -66
- package/lib/cjs/index.js +285 -337
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +65 -66
- package/lib/es/index.js +286 -339
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/es/locale/zh-HK.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/facade.js +65 -66
- package/lib/index.js +286 -339
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-HK.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/types/basics/cell-type.d.ts +2 -1
- package/lib/types/basics/selection.d.ts +0 -9
- package/lib/types/commands/commands/remove-row-col.command.d.ts +2 -0
- package/lib/types/commands/utils/selection-command-util.d.ts +2 -1
- package/lib/types/facade/f-worksheet.d.ts +10 -9
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/models/range-protection-render.model.d.ts +3 -2
- package/lib/types/services/ref-range/ref-range.service.d.ts +2 -0
- package/lib/types/services/selections/selection-data-model.d.ts +0 -6
- package/lib/types/services/selections/selection.service.d.ts +0 -6
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +8 -8
- package/lib/types/facade/f-types.d.ts +0 -16
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -18,7 +18,7 @@ const locale = { sheets: {
|
|
|
18
18
|
nameSheetConflict: "名称与工作表名称冲突",
|
|
19
19
|
formulaOrRefStringEmpty: "公式或引用字符串不能为空",
|
|
20
20
|
nameConflict: "名称与函数名称冲突",
|
|
21
|
-
defaultName: "
|
|
21
|
+
defaultName: "定义名称"
|
|
22
22
|
},
|
|
23
23
|
permission: { dialog: {
|
|
24
24
|
autoFillErr: "该范围已被保护,目前无自动填充权限。如需自动填充,请联系创建者。",
|
package/lib/cjs/locale/zh-HK.js
CHANGED
|
@@ -18,7 +18,7 @@ const locale = { sheets: {
|
|
|
18
18
|
nameSheetConflict: "名稱與工作表名稱衝突",
|
|
19
19
|
formulaOrRefStringEmpty: "公式或引用字串不能為空",
|
|
20
20
|
nameConflict: "名稱與函數名稱衝突",
|
|
21
|
-
defaultName: "
|
|
21
|
+
defaultName: "定義名稱"
|
|
22
22
|
},
|
|
23
23
|
permission: { dialog: {
|
|
24
24
|
autoFillErr: "範圍已被保護,目前無自動填入權限。如需自動填充,請聯絡建立者。 ",
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -18,7 +18,7 @@ const locale = { sheets: {
|
|
|
18
18
|
nameSheetConflict: "名稱與工作表名稱衝突",
|
|
19
19
|
formulaOrRefStringEmpty: "公式或引用字串不能為空",
|
|
20
20
|
nameConflict: "名稱與函數名稱衝突",
|
|
21
|
-
defaultName: "
|
|
21
|
+
defaultName: "定義名稱"
|
|
22
22
|
},
|
|
23
23
|
permission: { dialog: {
|
|
24
24
|
autoFillErr: "範圍已被保護,目前無自動填入權限。如需自動填充,請聯絡建立者。 ",
|
package/lib/es/facade.js
CHANGED
|
@@ -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.140.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.140.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.140.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.140.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.140.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.140.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);
|
|
@@ -190,9 +190,9 @@ let FDefinedNameBuilder = class FDefinedNameBuilder {
|
|
|
190
190
|
setRefByRange(row, column, numRows, numColumns) {
|
|
191
191
|
this._definedNameParam.formulaOrRefString = serializeRange({
|
|
192
192
|
startRow: row,
|
|
193
|
-
endRow: row + (numRows
|
|
193
|
+
endRow: row + (numRows ?? 1) - 1,
|
|
194
194
|
startColumn: column,
|
|
195
|
-
endColumn: column + (numColumns
|
|
195
|
+
endColumn: column + (numColumns ?? 1) - 1
|
|
196
196
|
});
|
|
197
197
|
return this;
|
|
198
198
|
}
|
|
@@ -432,9 +432,9 @@ let FDefinedName = class FDefinedName extends FBase {
|
|
|
432
432
|
setRefByRange(row, column, numRows, numColumns) {
|
|
433
433
|
this._definedNameParam.formulaOrRefString = serializeRange({
|
|
434
434
|
startRow: row,
|
|
435
|
-
endRow: row + (numRows
|
|
435
|
+
endRow: row + (numRows ?? 1) - 1,
|
|
436
436
|
startColumn: column,
|
|
437
|
-
endColumn: column + (numColumns
|
|
437
|
+
endColumn: column + (numColumns ?? 1) - 1
|
|
438
438
|
});
|
|
439
439
|
this._apply();
|
|
440
440
|
}
|
|
@@ -1618,10 +1618,9 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
|
|
|
1618
1618
|
if (!this.canEdit()) return false;
|
|
1619
1619
|
const rules = this._rangeProtectionRuleModel.getSubunitRuleList(this._unitId, this._subUnitId);
|
|
1620
1620
|
for (const rule of rules) for (const range of rule.ranges) if (row >= range.startRow && row <= range.endRow && col >= range.startColumn && col <= range.endColumn) {
|
|
1621
|
-
var _permission$value;
|
|
1622
1621
|
const permissionPoint = new RangeProtectionPermissionEditPoint(this._unitId, this._subUnitId, rule.permissionId);
|
|
1623
1622
|
const permission = this._permissionService.getPermissionPoint(permissionPoint.id);
|
|
1624
|
-
return (
|
|
1623
|
+
return (permission === null || permission === void 0 ? void 0 : permission.value) ?? false;
|
|
1625
1624
|
}
|
|
1626
1625
|
return true;
|
|
1627
1626
|
}
|
|
@@ -1660,10 +1659,9 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
|
|
|
1660
1659
|
if (!this.canView()) return false;
|
|
1661
1660
|
const rules = this._rangeProtectionRuleModel.getSubunitRuleList(this._unitId, this._subUnitId);
|
|
1662
1661
|
for (const rule of rules) for (const range of rule.ranges) if (row >= range.startRow && row <= range.endRow && col >= range.startColumn && col <= range.endColumn) {
|
|
1663
|
-
var _permission$value2;
|
|
1664
1662
|
const permissionPoint = new RangeProtectionPermissionViewPoint(this._unitId, this._subUnitId, rule.permissionId);
|
|
1665
1663
|
const permission = this._permissionService.getPermissionPoint(permissionPoint.id);
|
|
1666
|
-
return (
|
|
1664
|
+
return (permission === null || permission === void 0 ? void 0 : permission.value) ?? false;
|
|
1667
1665
|
}
|
|
1668
1666
|
return true;
|
|
1669
1667
|
}
|
|
@@ -1682,12 +1680,11 @@ let FWorksheetPermission = class FWorksheetPermission extends FBase {
|
|
|
1682
1680
|
* ```
|
|
1683
1681
|
*/
|
|
1684
1682
|
getPoint(point) {
|
|
1685
|
-
var _permissionPoint$valu;
|
|
1686
1683
|
const PointClass = WORKSHEET_PERMISSION_POINT_MAP[point];
|
|
1687
1684
|
if (!PointClass) throw new Error(`Unknown worksheet permission point: ${point}`);
|
|
1688
1685
|
const instance = new PointClass(this._unitId, this._subUnitId);
|
|
1689
1686
|
const permissionPoint = this._permissionService.getPermissionPoint(instance.id);
|
|
1690
|
-
return (
|
|
1687
|
+
return (permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) ?? true;
|
|
1691
1688
|
}
|
|
1692
1689
|
/**
|
|
1693
1690
|
* Get a snapshot of all permission points.
|
|
@@ -2019,6 +2016,11 @@ function covertToColRange(range, worksheet) {
|
|
|
2019
2016
|
//#endregion
|
|
2020
2017
|
//#region src/facade/f-worksheet.ts
|
|
2021
2018
|
var _FWorksheet;
|
|
2019
|
+
function assertValidRowInsertion(methodName, rowIndex, rowCount, howMany) {
|
|
2020
|
+
if (!Number.isInteger(howMany) || howMany <= 0) throw new RangeError(`${methodName}(): row count ${howMany} must be a positive integer.`);
|
|
2021
|
+
const lastRowIndex = rowCount - 1;
|
|
2022
|
+
if (!Number.isInteger(rowIndex) || rowIndex < 0 || rowIndex > lastRowIndex) throw new RangeError(`${methodName}(): row index ${rowIndex} is out of bounds. The worksheet has ${rowCount} rows; expected an integer from 0 to ${lastRowIndex}. To insert ${howMany} row(s) at the bottom, use insertRowsAfter(${lastRowIndex}, ${howMany}). To resize the worksheet directly, use setRowCount(${rowCount + howMany}).`);
|
|
2023
|
+
}
|
|
2022
2024
|
let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
2023
2025
|
/**
|
|
2024
2026
|
* Creates a new worksheet facade instance
|
|
@@ -2299,9 +2301,9 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2299
2301
|
sheet = this._worksheet;
|
|
2300
2302
|
range = {
|
|
2301
2303
|
startRow: rowOrA1Notation,
|
|
2302
|
-
endRow: rowOrA1Notation + (numRows
|
|
2304
|
+
endRow: rowOrA1Notation + (numRows ?? 1) - 1,
|
|
2303
2305
|
startColumn: column,
|
|
2304
|
-
endColumn: column + (numColumns
|
|
2306
|
+
endColumn: column + (numColumns ?? 1) - 1,
|
|
2305
2307
|
unitId: this._workbook.getUnitId(),
|
|
2306
2308
|
sheetId: this._worksheet.getSheetId()
|
|
2307
2309
|
};
|
|
@@ -2338,7 +2340,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2338
2340
|
}
|
|
2339
2341
|
/**
|
|
2340
2342
|
* Inserts a row after the given row position.
|
|
2341
|
-
* @param {number} afterPosition - The row after which the new row should be added
|
|
2343
|
+
* @param {number} afterPosition - The existing row after which the new row should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
2342
2344
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2343
2345
|
* @example
|
|
2344
2346
|
* ```typescript
|
|
@@ -2355,7 +2357,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2355
2357
|
}
|
|
2356
2358
|
/**
|
|
2357
2359
|
* Inserts a row before the given row position.
|
|
2358
|
-
* @param {number} beforePosition - The row before which the new row should be added
|
|
2360
|
+
* @param {number} beforePosition - The existing row before which the new row should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
2359
2361
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2360
2362
|
* @example
|
|
2361
2363
|
* ```typescript
|
|
@@ -2372,8 +2374,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2372
2374
|
}
|
|
2373
2375
|
/**
|
|
2374
2376
|
* Inserts one or more consecutive blank rows in a sheet starting at the specified location.
|
|
2375
|
-
* @param {number} rowIndex - The
|
|
2376
|
-
* @param {number} numRows - The number of rows to insert.
|
|
2377
|
+
* @param {number} rowIndex - The existing row before which rows are inserted. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
2378
|
+
* @param {number} numRows - The positive number of rows to insert.
|
|
2377
2379
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2378
2380
|
* @example
|
|
2379
2381
|
* ```typescript
|
|
@@ -2386,12 +2388,13 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2386
2388
|
* ```
|
|
2387
2389
|
*/
|
|
2388
2390
|
insertRows(rowIndex, numRows = 1) {
|
|
2391
|
+
assertValidRowInsertion("insertRows", rowIndex, this.getMaxRows(), numRows);
|
|
2389
2392
|
return this.insertRowsBefore(rowIndex, numRows);
|
|
2390
2393
|
}
|
|
2391
2394
|
/**
|
|
2392
2395
|
* Inserts a number of rows after the given row position.
|
|
2393
|
-
* @param {number} afterPosition - The row after which the new rows should be added
|
|
2394
|
-
* @param {number} howMany - The number of rows to insert.
|
|
2396
|
+
* @param {number} afterPosition - The existing row after which the new rows should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
2397
|
+
* @param {number} howMany - The positive number of rows to insert.
|
|
2395
2398
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2396
2399
|
* @example
|
|
2397
2400
|
* ```typescript
|
|
@@ -2404,6 +2407,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2404
2407
|
* ```
|
|
2405
2408
|
*/
|
|
2406
2409
|
insertRowsAfter(afterPosition, howMany) {
|
|
2410
|
+
assertValidRowInsertion("insertRowsAfter", afterPosition, this.getMaxRows(), howMany);
|
|
2407
2411
|
const unitId = this._workbook.getUnitId();
|
|
2408
2412
|
const subUnitId = this._worksheet.getSheetId();
|
|
2409
2413
|
const direction = Direction.DOWN;
|
|
@@ -2428,8 +2432,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2428
2432
|
}
|
|
2429
2433
|
/**
|
|
2430
2434
|
* Inserts a number of rows before the given row position.
|
|
2431
|
-
* @param {number} beforePosition - The row before which the new rows should be added
|
|
2432
|
-
* @param {number} howMany - The number of rows to insert.
|
|
2435
|
+
* @param {number} beforePosition - The existing row before which the new rows should be added. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
2436
|
+
* @param {number} howMany - The positive number of rows to insert.
|
|
2433
2437
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2434
2438
|
* @example
|
|
2435
2439
|
* ```typescript
|
|
@@ -2442,6 +2446,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
2442
2446
|
* ```
|
|
2443
2447
|
*/
|
|
2444
2448
|
insertRowsBefore(beforePosition, howMany) {
|
|
2449
|
+
assertValidRowInsertion("insertRowsBefore", beforePosition, this.getMaxRows(), howMany);
|
|
2445
2450
|
const unitId = this._workbook.getUnitId();
|
|
2446
2451
|
const subUnitId = this._worksheet.getSheetId();
|
|
2447
2452
|
const direction = Direction.UP;
|
|
@@ -4145,7 +4150,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
|
|
|
4145
4150
|
return this._worksheet.getColumnManager().getCustomMetadata(index);
|
|
4146
4151
|
}
|
|
4147
4152
|
/**
|
|
4148
|
-
* Appends a row to the bottom of the current data region in the sheet. If
|
|
4153
|
+
* Appends a row to the bottom of the current data region in the sheet. If the destination row is already within the worksheet capacity,
|
|
4154
|
+
* this method writes into that row without increasing `getMaxRows()`. If a cell's content begins with =, it's interpreted as a formula.
|
|
4149
4155
|
* @param {CellValue[]} rowContents - An array of values for the new row.
|
|
4150
4156
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining.
|
|
4151
4157
|
* @example
|
|
@@ -4420,7 +4426,8 @@ FRangePermission = __decorate([
|
|
|
4420
4426
|
|
|
4421
4427
|
//#endregion
|
|
4422
4428
|
//#region src/facade/f-range.ts
|
|
4423
|
-
var _FRange
|
|
4429
|
+
var _FRange;
|
|
4430
|
+
var _FRange2;
|
|
4424
4431
|
let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
4425
4432
|
constructor(_workbook, _worksheet, _range, _injector, _commandService, _formulaDataModel, _logService) {
|
|
4426
4433
|
super(_injector);
|
|
@@ -4649,8 +4656,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
4649
4656
|
* ```
|
|
4650
4657
|
*/
|
|
4651
4658
|
getFontFamily(type = "row") {
|
|
4652
|
-
var _this$getCellStyleDat
|
|
4653
|
-
return (_this$getCellStyleDat =
|
|
4659
|
+
var _this$getCellStyleDat;
|
|
4660
|
+
return ((_this$getCellStyleDat = this.getCellStyleData(type)) === null || _this$getCellStyleDat === void 0 ? void 0 : _this$getCellStyleDat.ff) ?? null;
|
|
4654
4661
|
}
|
|
4655
4662
|
/**
|
|
4656
4663
|
* Get the font size of the cell.
|
|
@@ -4671,8 +4678,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
4671
4678
|
* ```
|
|
4672
4679
|
*/
|
|
4673
4680
|
getFontSize(type = "row") {
|
|
4674
|
-
var _this$
|
|
4675
|
-
return (
|
|
4681
|
+
var _this$getCellStyleDat2;
|
|
4682
|
+
return ((_this$getCellStyleDat2 = this.getCellStyleData(type)) === null || _this$getCellStyleDat2 === void 0 ? void 0 : _this$getCellStyleDat2.fs) ?? null;
|
|
4676
4683
|
}
|
|
4677
4684
|
/**
|
|
4678
4685
|
* Return first cell style in this range.
|
|
@@ -4722,9 +4729,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
4722
4729
|
}));
|
|
4723
4730
|
}
|
|
4724
4731
|
getValue(includeRichText) {
|
|
4725
|
-
var _this$_worksheet$getC
|
|
4732
|
+
var _this$_worksheet$getC;
|
|
4726
4733
|
if (includeRichText) return this.getValueAndRichTextValue();
|
|
4727
|
-
return (_this$_worksheet$getC =
|
|
4734
|
+
return ((_this$_worksheet$getC = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) === null || _this$_worksheet$getC === void 0 ? void 0 : _this$_worksheet$getC.v) ?? null;
|
|
4728
4735
|
}
|
|
4729
4736
|
/**
|
|
4730
4737
|
* Returns the raw value of the top-left cell in the range. Empty cells return `null`.
|
|
@@ -4779,8 +4786,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
4779
4786
|
for (let r = startRow; r <= endRow; r++) {
|
|
4780
4787
|
const row = [];
|
|
4781
4788
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
4782
|
-
var _this$_worksheet$
|
|
4783
|
-
row.push((
|
|
4789
|
+
var _this$_worksheet$getC2;
|
|
4790
|
+
row.push(((_this$_worksheet$getC2 = this._worksheet.getCell(r, c)) === null || _this$_worksheet$getC2 === void 0 ? void 0 : _this$_worksheet$getC2.v) ?? null);
|
|
4784
4791
|
}
|
|
4785
4792
|
range.push(row);
|
|
4786
4793
|
}
|
|
@@ -4912,8 +4919,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
4912
4919
|
* ```
|
|
4913
4920
|
*/
|
|
4914
4921
|
getCellData() {
|
|
4915
|
-
|
|
4916
|
-
return (_this$_worksheet$getC5 = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) !== null && _this$_worksheet$getC5 !== void 0 ? _this$_worksheet$getC5 : null;
|
|
4922
|
+
return this._worksheet.getCell(this._range.startRow, this._range.startColumn) ?? null;
|
|
4917
4923
|
}
|
|
4918
4924
|
/**
|
|
4919
4925
|
* Alias for getCellDataGrid.
|
|
@@ -5034,8 +5040,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
5034
5040
|
* ```
|
|
5035
5041
|
*/
|
|
5036
5042
|
getFormula() {
|
|
5037
|
-
|
|
5038
|
-
return (_this$_formulaDataMod = this._formulaDataModel.getFormulaStringByCell(this._range.startRow, this._range.startColumn, this._worksheet.getSheetId(), this._workbook.getUnitId())) !== null && _this$_formulaDataMod !== void 0 ? _this$_formulaDataMod : "";
|
|
5043
|
+
return this._formulaDataModel.getFormulaStringByCell(this._range.startRow, this._range.startColumn, this._worksheet.getSheetId(), this._workbook.getUnitId()) ?? "";
|
|
5039
5044
|
}
|
|
5040
5045
|
/**
|
|
5041
5046
|
* Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
|
|
@@ -5081,9 +5086,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
5081
5086
|
}
|
|
5082
5087
|
/** Gets whether the top-left cell shrinks its font size to fit the cell width. */
|
|
5083
5088
|
getShrinkToFit() {
|
|
5084
|
-
var _this$_worksheet$
|
|
5089
|
+
var _this$_worksheet$getC3;
|
|
5085
5090
|
const { startRow, startColumn } = this._range;
|
|
5086
|
-
return ((_this$_worksheet$
|
|
5091
|
+
return ((_this$_worksheet$getC3 = this._worksheet.getComposedCellStyle(startRow, startColumn)) === null || _this$_worksheet$getC3 === void 0 ? void 0 : _this$_worksheet$getC3.stf) === BooleanNumber.TRUE;
|
|
5087
5092
|
}
|
|
5088
5093
|
/**
|
|
5089
5094
|
* Gets whether text wrapping is enabled for cells in the range.
|
|
@@ -5243,10 +5248,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
5243
5248
|
* ```
|
|
5244
5249
|
*/
|
|
5245
5250
|
getCustomMetaData() {
|
|
5246
|
-
var _cell$custom;
|
|
5247
5251
|
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
5248
5252
|
const cell = this.getCellData();
|
|
5249
|
-
return (
|
|
5253
|
+
return (cell === null || cell === void 0 ? void 0 : cell.custom) ?? null;
|
|
5250
5254
|
}
|
|
5251
5255
|
/**
|
|
5252
5256
|
* Returns the custom meta data for the cells in the range.
|
|
@@ -5262,10 +5266,7 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
5262
5266
|
*/
|
|
5263
5267
|
getCustomMetaDatas() {
|
|
5264
5268
|
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
5265
|
-
return this.getCellDataGrid().map((row) => row.map((data) =>
|
|
5266
|
-
var _data$custom;
|
|
5267
|
-
return (_data$custom = data === null || data === void 0 ? void 0 : data.custom) !== null && _data$custom !== void 0 ? _data$custom : null;
|
|
5268
|
-
}));
|
|
5269
|
+
return this.getCellDataGrid().map((row) => row.map((data) => (data === null || data === void 0 ? void 0 : data.custom) ?? null));
|
|
5269
5270
|
}
|
|
5270
5271
|
/**
|
|
5271
5272
|
* Sets basic border properties for the current range.
|
|
@@ -5308,9 +5309,9 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
5308
5309
|
* ```
|
|
5309
5310
|
*/
|
|
5310
5311
|
getBackground() {
|
|
5311
|
-
var _style$background
|
|
5312
|
+
var _style$background;
|
|
5312
5313
|
const style = this.getCellStyle();
|
|
5313
|
-
return (
|
|
5314
|
+
return (style === null || style === void 0 || (_style$background = style.background) === null || _style$background === void 0 ? void 0 : _style$background.rgb) ?? DEFAULT_STYLES.bg.rgb;
|
|
5314
5315
|
}
|
|
5315
5316
|
/**
|
|
5316
5317
|
* Returns the background colors of the cells in the range.
|
|
@@ -5326,8 +5327,8 @@ let FRange = _FRange = class FRange extends FBaseInitialable {
|
|
|
5326
5327
|
*/
|
|
5327
5328
|
getBackgrounds() {
|
|
5328
5329
|
return this.getCellStyles().map((row) => row.map((style) => {
|
|
5329
|
-
var _style$
|
|
5330
|
-
return (
|
|
5330
|
+
var _style$background2;
|
|
5331
|
+
return (style === null || style === void 0 || (_style$background2 = style.background) === null || _style$background2 === void 0 ? void 0 : _style$background2.rgb) ?? DEFAULT_STYLES.bg.rgb;
|
|
5331
5332
|
}));
|
|
5332
5333
|
}
|
|
5333
5334
|
/**
|
|
@@ -6869,12 +6870,11 @@ let FWorkbookPermission = class FWorkbookPermission extends FBase {
|
|
|
6869
6870
|
* ```
|
|
6870
6871
|
*/
|
|
6871
6872
|
getPoint(point) {
|
|
6872
|
-
var _permissionPoint$valu;
|
|
6873
6873
|
const PointClass = WORKBOOK_PERMISSION_POINT_MAP[point];
|
|
6874
6874
|
if (!PointClass) throw new Error(`Unknown workbook permission point: ${point}`);
|
|
6875
6875
|
const instance = new PointClass(this._unitId);
|
|
6876
6876
|
const permissionPoint = this._permissionService.getPermissionPoint(instance.id);
|
|
6877
|
-
return (
|
|
6877
|
+
return (permissionPoint === null || permissionPoint === void 0 ? void 0 : permissionPoint.value) ?? true;
|
|
6878
6878
|
}
|
|
6879
6879
|
/**
|
|
6880
6880
|
* Get a snapshot of all permission points.
|
|
@@ -7208,13 +7208,13 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
7208
7208
|
* ```
|
|
7209
7209
|
*/
|
|
7210
7210
|
create(name, rows, columns, options) {
|
|
7211
|
-
var _options$sheet
|
|
7212
|
-
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((
|
|
7211
|
+
var _options$sheet;
|
|
7212
|
+
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((options === null || options === void 0 ? void 0 : options.sheet) ?? {}));
|
|
7213
7213
|
newSheet.name = name;
|
|
7214
7214
|
newSheet.rowCount = rows;
|
|
7215
7215
|
newSheet.columnCount = columns;
|
|
7216
|
-
newSheet.id = options === null || options === void 0 || (_options$
|
|
7217
|
-
const newSheetIndex = (
|
|
7216
|
+
newSheet.id = options === null || options === void 0 || (_options$sheet = options.sheet) === null || _options$sheet === void 0 ? void 0 : _options$sheet.id;
|
|
7217
|
+
const newSheetIndex = (options === null || options === void 0 ? void 0 : options.index) ?? this._workbook.getSheets().length;
|
|
7218
7218
|
this._commandService.syncExecuteCommand(InsertSheetCommand.id, {
|
|
7219
7219
|
unitId: this.id,
|
|
7220
7220
|
index: newSheetIndex,
|
|
@@ -7321,12 +7321,12 @@ let FWorkbook = class FWorkbook extends FBaseInitialable {
|
|
|
7321
7321
|
* ```
|
|
7322
7322
|
*/
|
|
7323
7323
|
insertSheet(sheetName, options) {
|
|
7324
|
-
var _options$
|
|
7325
|
-
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((
|
|
7324
|
+
var _options$sheet2;
|
|
7325
|
+
const newSheet = mergeWorksheetSnapshotWithDefault(Tools.deepClone((options === null || options === void 0 ? void 0 : options.sheet) ?? {}));
|
|
7326
7326
|
if (sheetName !== void 0) newSheet.name = sheetName;
|
|
7327
7327
|
else delete newSheet.name;
|
|
7328
|
-
newSheet.id = options === null || options === void 0 || (_options$
|
|
7329
|
-
const newSheetIndex = (
|
|
7328
|
+
newSheet.id = options === null || options === void 0 || (_options$sheet2 = options.sheet) === null || _options$sheet2 === void 0 ? void 0 : _options$sheet2.id;
|
|
7329
|
+
const newSheetIndex = (options === null || options === void 0 ? void 0 : options.index) ?? this._workbook.getSheets().length;
|
|
7330
7330
|
this._commandService.syncExecuteCommand(InsertSheetCommand.id, {
|
|
7331
7331
|
unitId: this.id,
|
|
7332
7332
|
index: newSheetIndex,
|
|
@@ -8203,12 +8203,11 @@ var FUniverSheetsMixin = class extends FUniver {
|
|
|
8203
8203
|
})));
|
|
8204
8204
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineEnableChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8205
8205
|
if (commandInfo.id === ToggleGridlinesCommand.id) {
|
|
8206
|
-
var _params$showGridlines;
|
|
8207
8206
|
const params = commandInfo.params;
|
|
8208
8207
|
const target = this.getSheetCommandTarget(params);
|
|
8209
8208
|
if (!target) return;
|
|
8210
8209
|
const { workbook, worksheet } = target;
|
|
8211
|
-
const showGridlines =
|
|
8210
|
+
const showGridlines = params.showGridlines ?? !worksheet.hasHiddenGridLines();
|
|
8212
8211
|
const eventParams = {
|
|
8213
8212
|
workbook,
|
|
8214
8213
|
worksheet,
|
|
@@ -8235,12 +8234,12 @@ var FUniverSheetsMixin = class extends FUniver {
|
|
|
8235
8234
|
})));
|
|
8236
8235
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetCreated, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8237
8236
|
if (commandInfo.id === InsertSheetCommand.id) {
|
|
8238
|
-
var _params$sheet
|
|
8237
|
+
var _params$sheet;
|
|
8239
8238
|
const params = commandInfo.params;
|
|
8240
8239
|
const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? this.getWorkbook(params.unitId) : this.getActiveWorkbook();
|
|
8241
8240
|
if (!workbook) return;
|
|
8242
8241
|
const sheets = workbook.getSheets();
|
|
8243
|
-
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[(
|
|
8242
|
+
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 === null || params === void 0 ? void 0 : params.index) ?? sheets.length - 1];
|
|
8244
8243
|
if (!worksheet) return;
|
|
8245
8244
|
const eventParams = {
|
|
8246
8245
|
workbook,
|