@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.
- package/lib/cjs/facade.js +199 -264
- package/lib/cjs/index.js +171 -124
- package/lib/es/facade.js +200 -259
- package/lib/es/index.js +374 -321
- package/lib/facade.js +200 -259
- package/lib/index.js +374 -321
- package/lib/types/commands/commands/add-range-protection.command.d.ts +1 -1
- package/lib/types/commands/commands/delete-range-protection.command.d.ts +1 -1
- package/lib/types/commands/commands/register-range-theme.command.d.ts +1 -1
- package/lib/types/commands/commands/set-protection.command.d.ts +1 -1
- package/lib/types/commands/mutations/add-range-protection.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/add-range-theme.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/register-range-theme.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/set-range-protection.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/set-range-theme.mutation.d.ts +1 -1
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +4 -3
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +1 -1
- package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +1 -1
- package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +1 -1
- package/lib/types/controllers/zebar-crossing.controller.d.ts +1 -1
- package/lib/types/facade/{f-sheet-hooks.d.ts → const.d.ts} +1 -9
- package/lib/types/facade/f-range.d.ts +3 -2
- package/lib/types/facade/f-univer.d.ts +33 -64
- package/lib/types/facade/f-workbook.d.ts +3 -45
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/index.d.ts +186 -106
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +3 -3
- package/lib/types/services/permission/range-permission/range-protection.service.d.ts +2 -2
- package/lib/types/services/permission/type.d.ts +1 -1
- package/lib/types/services/permission/workbook-permission/workbook-permission.service.d.ts +1 -1
- package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +1 -1
- package/lib/types/services/range-theme.service.d.ts +3 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +9 -9
- /package/lib/types/{model → models}/range-protection-render.model.d.ts +0 -0
- /package/lib/types/{model → models}/range-protection-rule.model.d.ts +0 -0
- /package/lib/types/{model → models}/range-protection.cache.d.ts +0 -0
- /package/lib/types/{model → models}/range-theme-model.d.ts +0 -0
- /package/lib/types/{model → models}/range-theme-util.d.ts +0 -0
- /package/lib/types/{model → models}/range-themes/build-in-theme.factory.d.ts +0 -0
- /package/lib/types/{model → models}/range-themes/default.d.ts +0 -0
- /package/lib/types/{model → models}/zebra-crossing-cache.d.ts +0 -0
package/lib/cjs/facade.js
CHANGED
|
@@ -5,7 +5,26 @@ let _univerjs_sheets = require("@univerjs/sheets");
|
|
|
5
5
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
6
6
|
let _univerjs_protocol = require("@univerjs/protocol");
|
|
7
7
|
|
|
8
|
-
//#region
|
|
8
|
+
//#region src/facade/const.ts
|
|
9
|
+
/**
|
|
10
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const SHEETS_CUSTOM_FIELD_WARNING_MESSAGE = "[Facade]: The sheets custom field is not recommended for external use. Use it at your own risk.";
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
9
28
|
function _typeof(o) {
|
|
10
29
|
"@babel/helpers - typeof";
|
|
11
30
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -16,7 +35,7 @@ function _typeof(o) {
|
|
|
16
35
|
}
|
|
17
36
|
|
|
18
37
|
//#endregion
|
|
19
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
20
39
|
function toPrimitive(t, r) {
|
|
21
40
|
if ("object" != _typeof(t) || !t) return t;
|
|
22
41
|
var e = t[Symbol.toPrimitive];
|
|
@@ -29,14 +48,14 @@ function toPrimitive(t, r) {
|
|
|
29
48
|
}
|
|
30
49
|
|
|
31
50
|
//#endregion
|
|
32
|
-
//#region \0@oxc-project+runtime@0.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
33
52
|
function toPropertyKey(t) {
|
|
34
53
|
var i = toPrimitive(t, "string");
|
|
35
54
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
//#endregion
|
|
39
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
40
59
|
function _defineProperty(e, r, t) {
|
|
41
60
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
61
|
value: t,
|
|
@@ -47,7 +66,7 @@ function _defineProperty(e, r, t) {
|
|
|
47
66
|
}
|
|
48
67
|
|
|
49
68
|
//#endregion
|
|
50
|
-
//#region \0@oxc-project+runtime@0.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
51
70
|
function __decorateParam(paramIndex, decorator) {
|
|
52
71
|
return function(target, key) {
|
|
53
72
|
decorator(target, key, paramIndex);
|
|
@@ -55,7 +74,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
55
74
|
}
|
|
56
75
|
|
|
57
76
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
77
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
59
78
|
function __decorate(decorators, target, key, desc) {
|
|
60
79
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
80
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -75,7 +94,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
75
94
|
function getDefinedNameFieldName(unitId, localeService, definedNamesService) {
|
|
76
95
|
const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
|
|
77
96
|
if (definedNameMap == null) return localeService.t("sheets.definedName.defaultName") + 1;
|
|
78
|
-
const count =
|
|
97
|
+
const count = Object.values(definedNameMap).length + 1;
|
|
79
98
|
const name = localeService.t("sheets.definedName.defaultName") + count;
|
|
80
99
|
if (definedNamesService.getValueByName(unitId, name) == null) return name;
|
|
81
100
|
let i = count + 1;
|
|
@@ -1152,7 +1171,7 @@ let FRangeProtectionRule = class FRangeProtectionRule {
|
|
|
1152
1171
|
if (permissionPoint && permissionPoint.value === value) return;
|
|
1153
1172
|
if (!permissionPoint) this._permissionService.addPermissionPoint(instance);
|
|
1154
1173
|
await this._authzIoService.update({
|
|
1155
|
-
objectType:
|
|
1174
|
+
objectType: _univerjs_protocol.UnitObject.SelectRange,
|
|
1156
1175
|
objectID: this._permissionId,
|
|
1157
1176
|
unitID: this._unitId,
|
|
1158
1177
|
share: void 0,
|
|
@@ -1388,7 +1407,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1388
1407
|
});
|
|
1389
1408
|
}
|
|
1390
1409
|
const permissionId = await this._authzIoService.create({
|
|
1391
|
-
objectType:
|
|
1410
|
+
objectType: _univerjs_protocol.UnitObject.Worksheet,
|
|
1392
1411
|
worksheetObject: {
|
|
1393
1412
|
collaborators,
|
|
1394
1413
|
unitID: this._unitId,
|
|
@@ -1409,7 +1428,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1409
1428
|
rule: {
|
|
1410
1429
|
permissionId,
|
|
1411
1430
|
description: options === null || options === void 0 ? void 0 : options.name,
|
|
1412
|
-
unitType:
|
|
1431
|
+
unitType: _univerjs_protocol.UnitObject.Worksheet,
|
|
1413
1432
|
unitId: this._unitId,
|
|
1414
1433
|
subUnitId: this._subUnitId,
|
|
1415
1434
|
viewState,
|
|
@@ -1539,7 +1558,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1539
1558
|
if (permissionPoint && permissionPoint.value === value) return;
|
|
1540
1559
|
if (!permissionPoint) this._permissionService.addPermissionPoint(instance);
|
|
1541
1560
|
await this._authzIoService.update({
|
|
1542
|
-
objectType:
|
|
1561
|
+
objectType: _univerjs_protocol.UnitObject.Worksheet,
|
|
1543
1562
|
objectID: worksheetProtectionRule.permissionId,
|
|
1544
1563
|
unitID: this._unitId,
|
|
1545
1564
|
share: void 0,
|
|
@@ -1771,7 +1790,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1771
1790
|
});
|
|
1772
1791
|
}
|
|
1773
1792
|
const permissionId = await this._authzIoService.create({
|
|
1774
|
-
objectType:
|
|
1793
|
+
objectType: _univerjs_protocol.UnitObject.SelectRange,
|
|
1775
1794
|
selectRangeObject: {
|
|
1776
1795
|
collaborators,
|
|
1777
1796
|
unitID: this._unitId,
|
|
@@ -1785,7 +1804,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1785
1804
|
permissionId,
|
|
1786
1805
|
id: ruleId,
|
|
1787
1806
|
description: options === null || options === void 0 ? void 0 : options.name,
|
|
1788
|
-
unitType:
|
|
1807
|
+
unitType: _univerjs_protocol.UnitObject.SelectRange,
|
|
1789
1808
|
unitId: this._unitId,
|
|
1790
1809
|
subUnitId: this._subUnitId,
|
|
1791
1810
|
viewState,
|
|
@@ -2866,6 +2885,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2866
2885
|
* ```
|
|
2867
2886
|
*/
|
|
2868
2887
|
setRowCustom(custom) {
|
|
2888
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
2869
2889
|
const unitId = this._workbook.getUnitId();
|
|
2870
2890
|
const subUnitId = this._worksheet.getSheetId();
|
|
2871
2891
|
const rowData = {};
|
|
@@ -3308,6 +3328,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3308
3328
|
* ```
|
|
3309
3329
|
*/
|
|
3310
3330
|
setColumnCustom(custom) {
|
|
3331
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
3311
3332
|
const unitId = this._workbook.getUnitId();
|
|
3312
3333
|
const subUnitId = this._worksheet.getSheetId();
|
|
3313
3334
|
const columnData = {};
|
|
@@ -4021,6 +4042,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
4021
4042
|
* ```
|
|
4022
4043
|
*/
|
|
4023
4044
|
setCustomMetadata(custom) {
|
|
4045
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
4024
4046
|
this._worksheet.setCustomMetadata(custom);
|
|
4025
4047
|
return this;
|
|
4026
4048
|
}
|
|
@@ -4037,6 +4059,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
4037
4059
|
* ```
|
|
4038
4060
|
*/
|
|
4039
4061
|
getCustomMetadata() {
|
|
4062
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
4040
4063
|
return this._worksheet.getCustomMetadata();
|
|
4041
4064
|
}
|
|
4042
4065
|
/**
|
|
@@ -4053,6 +4076,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
4053
4076
|
* ```
|
|
4054
4077
|
*/
|
|
4055
4078
|
setRowCustomMetadata(index, custom) {
|
|
4079
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
4056
4080
|
this._worksheet.getRowManager().setCustomMetadata(index, custom);
|
|
4057
4081
|
return this;
|
|
4058
4082
|
}
|
|
@@ -4070,6 +4094,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
4070
4094
|
* ```
|
|
4071
4095
|
*/
|
|
4072
4096
|
setColumnCustomMetadata(index, custom) {
|
|
4097
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
4073
4098
|
this._worksheet.getColumnManager().setCustomMetadata(index, custom);
|
|
4074
4099
|
return this;
|
|
4075
4100
|
}
|
|
@@ -4087,6 +4112,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
4087
4112
|
* ```
|
|
4088
4113
|
*/
|
|
4089
4114
|
getRowCustomMetadata(index) {
|
|
4115
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
4090
4116
|
return this._worksheet.getRowManager().getCustomMetadata(index);
|
|
4091
4117
|
}
|
|
4092
4118
|
/**
|
|
@@ -4103,6 +4129,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
4103
4129
|
* ```
|
|
4104
4130
|
*/
|
|
4105
4131
|
getColumnCustomMetadata(index) {
|
|
4132
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
4106
4133
|
return this._worksheet.getColumnManager().getCustomMetadata(index);
|
|
4107
4134
|
}
|
|
4108
4135
|
/**
|
|
@@ -4381,7 +4408,7 @@ FRangePermission = __decorate([
|
|
|
4381
4408
|
//#region src/facade/f-range.ts
|
|
4382
4409
|
var _FRange, _FRange2;
|
|
4383
4410
|
let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialable {
|
|
4384
|
-
constructor(_workbook, _worksheet, _range, _injector, _commandService, _formulaDataModel) {
|
|
4411
|
+
constructor(_workbook, _worksheet, _range, _injector, _commandService, _formulaDataModel, _logService) {
|
|
4385
4412
|
super(_injector);
|
|
4386
4413
|
this._workbook = _workbook;
|
|
4387
4414
|
this._worksheet = _worksheet;
|
|
@@ -4389,6 +4416,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4389
4416
|
this._injector = _injector;
|
|
4390
4417
|
this._commandService = _commandService;
|
|
4391
4418
|
this._formulaDataModel = _formulaDataModel;
|
|
4419
|
+
this._logService = _logService;
|
|
4392
4420
|
const maxRows = this._worksheet.getRowCount();
|
|
4393
4421
|
const maxColumns = this._worksheet.getColumnCount();
|
|
4394
4422
|
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)}`);
|
|
@@ -4705,10 +4733,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4705
4733
|
* ```
|
|
4706
4734
|
*/
|
|
4707
4735
|
getRawValue() {
|
|
4708
|
-
|
|
4709
|
-
const cell = this._worksheet.getCellMatrix().getValue(this._range.startRow, this._range.startColumn);
|
|
4710
|
-
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;
|
|
4711
|
-
return (_cell$v = cell === null || cell === void 0 ? void 0 : cell.v) !== null && _cell$v !== void 0 ? _cell$v : null;
|
|
4736
|
+
return (0, _univerjs_core.getOriginCellValue)(this._worksheet.getCellMatrix().getValue(this._range.startRow, this._range.startColumn));
|
|
4712
4737
|
}
|
|
4713
4738
|
/**
|
|
4714
4739
|
* Returns the displayed value of the top-left cell in the range. The value is a String. Empty cells return an empty string.
|
|
@@ -4731,10 +4756,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4731
4756
|
* ```
|
|
4732
4757
|
*/
|
|
4733
4758
|
getDisplayValue() {
|
|
4734
|
-
|
|
4735
|
-
const cell = this._worksheet.getCell(this._range.startRow, this._range.startColumn);
|
|
4736
|
-
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;
|
|
4737
|
-
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 : "";
|
|
4759
|
+
return (0, _univerjs_core.getDisplayValueFromCell)(this._worksheet.getCell(this._range.startRow, this._range.startColumn));
|
|
4738
4760
|
}
|
|
4739
4761
|
getValues(includeRichText) {
|
|
4740
4762
|
if (includeRichText) return this.getValueAndRichTextValues();
|
|
@@ -4800,13 +4822,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4800
4822
|
for (let r = startRow; r <= endRow; r++) {
|
|
4801
4823
|
const row = [];
|
|
4802
4824
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
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);
|
|
4806
|
-
else {
|
|
4807
|
-
var _cell$v3;
|
|
4808
|
-
row.push((_cell$v3 = cell === null || cell === void 0 ? void 0 : cell.v) !== null && _cell$v3 !== void 0 ? _cell$v3 : null);
|
|
4809
|
-
}
|
|
4825
|
+
const rawValue = (0, _univerjs_core.getOriginCellValue)(cellMatrix.getValue(r, c));
|
|
4826
|
+
row.push(rawValue);
|
|
4810
4827
|
}
|
|
4811
4828
|
values.push(row);
|
|
4812
4829
|
}
|
|
@@ -4861,13 +4878,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4861
4878
|
for (let r = startRow; r <= endRow; r++) {
|
|
4862
4879
|
const row = [];
|
|
4863
4880
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
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);
|
|
4867
|
-
else {
|
|
4868
|
-
var _cell$v$toString2, _cell$v4;
|
|
4869
|
-
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 : "");
|
|
4870
|
-
}
|
|
4881
|
+
const displayValue = (0, _univerjs_core.getDisplayValueFromCell)(this._worksheet.getCell(r, c));
|
|
4882
|
+
row.push(displayValue);
|
|
4871
4883
|
}
|
|
4872
4884
|
values.push(row);
|
|
4873
4885
|
}
|
|
@@ -5161,6 +5173,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5161
5173
|
* ```
|
|
5162
5174
|
*/
|
|
5163
5175
|
setCustomMetaData(data) {
|
|
5176
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
5164
5177
|
const params = {
|
|
5165
5178
|
unitId: this._workbook.getUnitId(),
|
|
5166
5179
|
subUnitId: this._worksheet.getSheetId(),
|
|
@@ -5187,6 +5200,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5187
5200
|
* ```
|
|
5188
5201
|
*/
|
|
5189
5202
|
setCustomMetaDatas(datas) {
|
|
5203
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
5190
5204
|
const params = {
|
|
5191
5205
|
unitId: this._workbook.getUnitId(),
|
|
5192
5206
|
subUnitId: this._worksheet.getSheetId(),
|
|
@@ -5210,6 +5224,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5210
5224
|
*/
|
|
5211
5225
|
getCustomMetaData() {
|
|
5212
5226
|
var _cell$custom;
|
|
5227
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
5213
5228
|
const cell = this.getCellData();
|
|
5214
5229
|
return (_cell$custom = cell === null || cell === void 0 ? void 0 : cell.custom) !== null && _cell$custom !== void 0 ? _cell$custom : null;
|
|
5215
5230
|
}
|
|
@@ -5226,6 +5241,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5226
5241
|
* ```
|
|
5227
5242
|
*/
|
|
5228
5243
|
getCustomMetaDatas() {
|
|
5244
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
5229
5245
|
return this.getCellDataGrid().map((row) => row.map((data) => {
|
|
5230
5246
|
var _data$custom;
|
|
5231
5247
|
return (_data$custom = data === null || data === void 0 ? void 0 : data.custom) !== null && _data$custom !== void 0 ? _data$custom : null;
|
|
@@ -6664,7 +6680,8 @@ _FRange2._enableManualInit();
|
|
|
6664
6680
|
FRange = _FRange = __decorate([
|
|
6665
6681
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
6666
6682
|
__decorateParam(4, _univerjs_core.ICommandService),
|
|
6667
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel))
|
|
6683
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
6684
|
+
__decorateParam(6, _univerjs_core.ILogService)
|
|
6668
6685
|
], FRange);
|
|
6669
6686
|
|
|
6670
6687
|
//#endregion
|
|
@@ -7000,7 +7017,7 @@ FWorkbookPermission = __decorate([
|
|
|
7000
7017
|
//#endregion
|
|
7001
7018
|
//#region src/facade/f-workbook.ts
|
|
7002
7019
|
let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
7003
|
-
constructor(_workbook, _injector, _resourceLoaderService, _selectionManagerService, _univerInstanceService, _commandService, _permissionService, _logService,
|
|
7020
|
+
constructor(_workbook, _injector, _resourceLoaderService, _selectionManagerService, _univerInstanceService, _commandService, _permissionService, _logService, _definedNamesService) {
|
|
7004
7021
|
super(_injector);
|
|
7005
7022
|
this._workbook = _workbook;
|
|
7006
7023
|
this._injector = _injector;
|
|
@@ -7010,7 +7027,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7010
7027
|
this._commandService = _commandService;
|
|
7011
7028
|
this._permissionService = _permissionService;
|
|
7012
7029
|
this._logService = _logService;
|
|
7013
|
-
this._localeService = _localeService;
|
|
7014
7030
|
this._definedNamesService = _definedNamesService;
|
|
7015
7031
|
_defineProperty(this, "id", void 0);
|
|
7016
7032
|
this.id = this._workbook.getUnitId();
|
|
@@ -7093,21 +7109,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7093
7109
|
return this._resourceLoaderService.saveUnit(this._workbook.getUnitId());
|
|
7094
7110
|
}
|
|
7095
7111
|
/**
|
|
7096
|
-
* @deprecated use 'save' instead.
|
|
7097
|
-
* @returns {IWorkbookData} Workbook snapshot data
|
|
7098
|
-
* @memberof FWorkbook
|
|
7099
|
-
* @example
|
|
7100
|
-
* ```ts
|
|
7101
|
-
* // The code below saves the workbook snapshot data
|
|
7102
|
-
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
7103
|
-
* const snapshot = activeSpreadsheet.getSnapshot();
|
|
7104
|
-
* ```
|
|
7105
|
-
*/
|
|
7106
|
-
getSnapshot() {
|
|
7107
|
-
this._logService.warn("use 'save' instead of 'getSnapshot'");
|
|
7108
|
-
return this.save();
|
|
7109
|
-
}
|
|
7110
|
-
/**
|
|
7111
7112
|
* Get the active sheet of the workbook.
|
|
7112
7113
|
* @returns {FWorksheet} The active sheet of the workbook
|
|
7113
7114
|
* @example
|
|
@@ -7581,42 +7582,6 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7581
7582
|
return this._workbook.getSheets().length;
|
|
7582
7583
|
}
|
|
7583
7584
|
/**
|
|
7584
|
-
* Get the locale of the workbook.
|
|
7585
|
-
* @returns {LocaleType} The locale of the workbook
|
|
7586
|
-
* @example
|
|
7587
|
-
* ```ts
|
|
7588
|
-
* // The code below gets the locale of the workbook
|
|
7589
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
7590
|
-
* console.log(fWorkbook.getLocale());
|
|
7591
|
-
* ```
|
|
7592
|
-
*/
|
|
7593
|
-
getLocale() {
|
|
7594
|
-
return this._localeService.getCurrentLocale();
|
|
7595
|
-
}
|
|
7596
|
-
/**
|
|
7597
|
-
* @deprecated use `setSpreadsheetLocale` instead.
|
|
7598
|
-
* @param {LocaleType} locale - The locale to set
|
|
7599
|
-
*/
|
|
7600
|
-
setLocale(locale) {
|
|
7601
|
-
this._localeService.setLocale(locale);
|
|
7602
|
-
}
|
|
7603
|
-
/**
|
|
7604
|
-
* Set the locale of the workbook.
|
|
7605
|
-
* @param {LocaleType} locale The locale to set
|
|
7606
|
-
* @returns {FWorkbook} This workbook, for chaining
|
|
7607
|
-
* @example
|
|
7608
|
-
* ```ts
|
|
7609
|
-
* // The code below sets the locale of the workbook
|
|
7610
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
7611
|
-
* fWorkbook.setSpreadsheetLocale(univerAPI.Enum.LocaleType.EN_US);
|
|
7612
|
-
* console.log(fWorkbook.getLocale());
|
|
7613
|
-
* ```
|
|
7614
|
-
*/
|
|
7615
|
-
setSpreadsheetLocale(locale) {
|
|
7616
|
-
this._localeService.setLocale(locale);
|
|
7617
|
-
return this;
|
|
7618
|
-
}
|
|
7619
|
-
/**
|
|
7620
7585
|
* Get the URL of the workbook.
|
|
7621
7586
|
* @returns {string} The URL of the workbook
|
|
7622
7587
|
* @example
|
|
@@ -7921,6 +7886,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7921
7886
|
* ```
|
|
7922
7887
|
*/
|
|
7923
7888
|
setCustomMetadata(custom) {
|
|
7889
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
7924
7890
|
this._workbook.setCustomMetadata(custom);
|
|
7925
7891
|
return this;
|
|
7926
7892
|
}
|
|
@@ -7935,6 +7901,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7935
7901
|
* ```
|
|
7936
7902
|
*/
|
|
7937
7903
|
getCustomMetadata() {
|
|
7904
|
+
this._logService.warn(SHEETS_CUSTOM_FIELD_WARNING_MESSAGE);
|
|
7938
7905
|
return this._workbook.getCustomMetadata();
|
|
7939
7906
|
}
|
|
7940
7907
|
/**
|
|
@@ -8024,62 +7991,52 @@ FWorkbook = __decorate([
|
|
|
8024
7991
|
__decorateParam(5, _univerjs_core.ICommandService),
|
|
8025
7992
|
__decorateParam(6, _univerjs_core.IPermissionService),
|
|
8026
7993
|
__decorateParam(7, _univerjs_core.ILogService),
|
|
8027
|
-
__decorateParam(8,
|
|
8028
|
-
__decorateParam(9, _univerjs_engine_formula.IDefinedNamesService)
|
|
7994
|
+
__decorateParam(8, _univerjs_engine_formula.IDefinedNamesService)
|
|
8029
7995
|
], FWorkbook);
|
|
8030
7996
|
|
|
8031
7997
|
//#endregion
|
|
8032
7998
|
//#region src/facade/f-univer.ts
|
|
8033
7999
|
var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8000
|
+
createWorkbook(data, options) {
|
|
8001
|
+
const workbook = this._injector.get(_univerjs_core.IUniverInstanceService).createUnit(_univerjs_core.UniverInstanceType.UNIVER_SHEET, data, options);
|
|
8002
|
+
return this._injector.createInstance(FWorkbook, workbook);
|
|
8003
|
+
}
|
|
8004
|
+
getActiveWorkbook() {
|
|
8005
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
8006
|
+
if (!workbook) return null;
|
|
8007
|
+
return this._injector.createInstance(FWorkbook, workbook);
|
|
8008
|
+
}
|
|
8009
|
+
getWorkbook(id) {
|
|
8010
|
+
const workbook = this._univerInstanceService.getUnit(id, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
8011
|
+
if (!workbook) return null;
|
|
8012
|
+
return this._injector.createInstance(FWorkbook, workbook);
|
|
8013
|
+
}
|
|
8014
|
+
getSheetCommandTarget(params = {}) {
|
|
8015
|
+
const { unitId, subUnitId, sheetId } = params;
|
|
8016
|
+
const workbook = unitId ? this.getWorkbook(unitId) : this.getActiveWorkbook();
|
|
8017
|
+
if (!workbook) return null;
|
|
8018
|
+
const sheetIdToFind = subUnitId || sheetId;
|
|
8019
|
+
const worksheet = sheetIdToFind ? workbook.getSheetBySheetId(sheetIdToFind) : workbook.getActiveSheet();
|
|
8020
|
+
if (!worksheet) return null;
|
|
8042
8021
|
return {
|
|
8043
8022
|
workbook,
|
|
8044
|
-
worksheet
|
|
8023
|
+
worksheet,
|
|
8024
|
+
unitId: workbook.getId(),
|
|
8025
|
+
subUnitId: worksheet.getSheetId()
|
|
8045
8026
|
};
|
|
8046
8027
|
}
|
|
8047
|
-
|
|
8048
|
-
const workbook = this.
|
|
8049
|
-
if (!workbook) return;
|
|
8050
|
-
const worksheet = workbook.
|
|
8051
|
-
if (!worksheet) return;
|
|
8028
|
+
getActiveSheet() {
|
|
8029
|
+
const workbook = this.getActiveWorkbook();
|
|
8030
|
+
if (!workbook) return null;
|
|
8031
|
+
const worksheet = workbook.getActiveSheet();
|
|
8032
|
+
if (!worksheet) return null;
|
|
8052
8033
|
return {
|
|
8053
8034
|
workbook,
|
|
8054
8035
|
worksheet
|
|
8055
8036
|
};
|
|
8056
8037
|
}
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookDisposed, () => univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
8060
|
-
if (unit.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET) {
|
|
8061
|
-
const eventParams = {
|
|
8062
|
-
unitId: unit.getUnitId(),
|
|
8063
|
-
unitType: unit.type,
|
|
8064
|
-
snapshot: unit.getSnapshot()
|
|
8065
|
-
};
|
|
8066
|
-
this.fireEvent(this.Event.WorkbookDisposed, eventParams);
|
|
8067
|
-
}
|
|
8068
|
-
})));
|
|
8069
|
-
this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookCreated, () => univerInstanceService.unitAdded$.subscribe((event) => {
|
|
8070
|
-
const { unit } = event;
|
|
8071
|
-
if (unit.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET) {
|
|
8072
|
-
const workbook = unit;
|
|
8073
|
-
const workbookUnit = injector.createInstance(FWorkbook, workbook);
|
|
8074
|
-
const eventParams = {
|
|
8075
|
-
unitId: unit.getUnitId(),
|
|
8076
|
-
type: unit.type,
|
|
8077
|
-
workbook: workbookUnit,
|
|
8078
|
-
unit: workbookUnit
|
|
8079
|
-
};
|
|
8080
|
-
this.fireEvent(this.Event.WorkbookCreated, eventParams);
|
|
8081
|
-
}
|
|
8082
|
-
})));
|
|
8038
|
+
setFreezeSync(enabled) {
|
|
8039
|
+
this._injector.get(_univerjs_sheets.SheetsFreezeSyncController).setEnabled(enabled);
|
|
8083
8040
|
}
|
|
8084
8041
|
/**
|
|
8085
8042
|
* @ignore
|
|
@@ -8089,9 +8046,8 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8089
8046
|
const commandService = injector.get(_univerjs_core.ICommandService);
|
|
8090
8047
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetCreate, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8091
8048
|
if (commandInfo.id === _univerjs_sheets.InsertSheetCommand.id) {
|
|
8092
|
-
var _this$getActiveWorkbo2;
|
|
8093
8049
|
const { unitId, index, sheet } = commandInfo.params || {};
|
|
8094
|
-
const workbook = unitId ? this.
|
|
8050
|
+
const workbook = unitId ? this.getWorkbook(unitId) : this.getActiveWorkbook();
|
|
8095
8051
|
if (!workbook) return;
|
|
8096
8052
|
const eventParams = {
|
|
8097
8053
|
workbook,
|
|
@@ -8104,11 +8060,10 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8104
8060
|
})));
|
|
8105
8061
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeActiveSheetChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8106
8062
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetActiveOperation.id) {
|
|
8107
|
-
|
|
8108
|
-
const
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
const activeSheet = workbook.getSheetBySheetId(sheetId);
|
|
8063
|
+
const params = commandInfo.params;
|
|
8064
|
+
const target = this.getSheetCommandTarget(params);
|
|
8065
|
+
if (!target) return;
|
|
8066
|
+
const { workbook, worksheet: activeSheet } = target;
|
|
8112
8067
|
const oldActiveSheet = workbook.getActiveSheet();
|
|
8113
8068
|
if (!activeSheet || !oldActiveSheet) return;
|
|
8114
8069
|
const eventParams = {
|
|
@@ -8122,7 +8077,8 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8122
8077
|
})));
|
|
8123
8078
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetDelete, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8124
8079
|
if (commandInfo.id === _univerjs_sheets.RemoveSheetCommand.id) {
|
|
8125
|
-
const
|
|
8080
|
+
const params = commandInfo.params;
|
|
8081
|
+
const target = this.getSheetCommandTarget(params);
|
|
8126
8082
|
if (!target) return;
|
|
8127
8083
|
const { workbook, worksheet } = target;
|
|
8128
8084
|
const eventParams = {
|
|
@@ -8135,14 +8091,16 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8135
8091
|
})));
|
|
8136
8092
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetMove, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8137
8093
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetOrderMutation.id) {
|
|
8138
|
-
const
|
|
8139
|
-
const target = this.
|
|
8094
|
+
const params = commandInfo.params;
|
|
8095
|
+
const target = this.getSheetCommandTarget(params);
|
|
8140
8096
|
if (!target) return;
|
|
8097
|
+
const { workbook, worksheet } = target;
|
|
8098
|
+
const { fromOrder: oldIndex, toOrder: newIndex } = params;
|
|
8141
8099
|
const eventParams = {
|
|
8142
|
-
workbook
|
|
8143
|
-
worksheet
|
|
8144
|
-
newIndex
|
|
8145
|
-
oldIndex
|
|
8100
|
+
workbook,
|
|
8101
|
+
worksheet,
|
|
8102
|
+
newIndex,
|
|
8103
|
+
oldIndex
|
|
8146
8104
|
};
|
|
8147
8105
|
this.fireEvent(this.Event.BeforeSheetMove, eventParams);
|
|
8148
8106
|
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
@@ -8150,14 +8108,17 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8150
8108
|
})));
|
|
8151
8109
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetNameChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8152
8110
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetNameCommand.id) {
|
|
8153
|
-
const
|
|
8154
|
-
const target = this.
|
|
8111
|
+
const params = commandInfo.params;
|
|
8112
|
+
const target = this.getSheetCommandTarget(params);
|
|
8155
8113
|
if (!target) return;
|
|
8114
|
+
const { workbook, worksheet } = target;
|
|
8115
|
+
const oldName = worksheet.getSheetName();
|
|
8116
|
+
const { name: newName } = params;
|
|
8156
8117
|
const eventParams = {
|
|
8157
|
-
workbook
|
|
8158
|
-
worksheet
|
|
8159
|
-
newName
|
|
8160
|
-
oldName
|
|
8118
|
+
workbook,
|
|
8119
|
+
worksheet,
|
|
8120
|
+
newName,
|
|
8121
|
+
oldName
|
|
8161
8122
|
};
|
|
8162
8123
|
this.fireEvent(this.Event.BeforeSheetNameChange, eventParams);
|
|
8163
8124
|
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
@@ -8165,14 +8126,17 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8165
8126
|
})));
|
|
8166
8127
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetTabColorChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8167
8128
|
if (commandInfo.id === _univerjs_sheets.SetTabColorMutation.id) {
|
|
8168
|
-
const
|
|
8169
|
-
const target = this.
|
|
8129
|
+
const params = commandInfo.params;
|
|
8130
|
+
const target = this.getSheetCommandTarget(params);
|
|
8170
8131
|
if (!target) return;
|
|
8132
|
+
const { workbook, worksheet } = target;
|
|
8133
|
+
const oldColor = worksheet.getTabColor();
|
|
8134
|
+
const { color: newColor } = params;
|
|
8171
8135
|
const eventParams = {
|
|
8172
|
-
workbook
|
|
8173
|
-
worksheet
|
|
8174
|
-
newColor
|
|
8175
|
-
oldColor
|
|
8136
|
+
workbook,
|
|
8137
|
+
worksheet,
|
|
8138
|
+
newColor,
|
|
8139
|
+
oldColor
|
|
8176
8140
|
};
|
|
8177
8141
|
this.fireEvent(this.Event.BeforeSheetTabColorChange, eventParams);
|
|
8178
8142
|
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
@@ -8180,12 +8144,14 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8180
8144
|
})));
|
|
8181
8145
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeSheetHideChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8182
8146
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetHideMutation.id) {
|
|
8183
|
-
const
|
|
8184
|
-
const target = this.
|
|
8147
|
+
const params = commandInfo.params;
|
|
8148
|
+
const target = this.getSheetCommandTarget(params);
|
|
8185
8149
|
if (!target) return;
|
|
8150
|
+
const { workbook, worksheet } = target;
|
|
8151
|
+
const { hidden } = params;
|
|
8186
8152
|
const eventParams = {
|
|
8187
|
-
workbook
|
|
8188
|
-
worksheet
|
|
8153
|
+
workbook,
|
|
8154
|
+
worksheet,
|
|
8189
8155
|
hidden: Boolean(hidden)
|
|
8190
8156
|
};
|
|
8191
8157
|
this.fireEvent(this.Event.BeforeSheetHideChange, eventParams);
|
|
@@ -8194,12 +8160,15 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8194
8160
|
})));
|
|
8195
8161
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineColorChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8196
8162
|
if (commandInfo.id === _univerjs_sheets.SetGridlinesColorCommand.id) {
|
|
8197
|
-
|
|
8198
|
-
const target = this.
|
|
8163
|
+
const params = commandInfo.params;
|
|
8164
|
+
const target = this.getSheetCommandTarget(params);
|
|
8199
8165
|
if (!target) return;
|
|
8166
|
+
const { workbook, worksheet } = target;
|
|
8167
|
+
const { color } = params;
|
|
8200
8168
|
const eventParams = {
|
|
8201
|
-
|
|
8202
|
-
|
|
8169
|
+
workbook,
|
|
8170
|
+
worksheet,
|
|
8171
|
+
color
|
|
8203
8172
|
};
|
|
8204
8173
|
this.fireEvent(this.Event.BeforeGridlineColorChange, eventParams);
|
|
8205
8174
|
if (eventParams.cancel) throw new _univerjs_core.CanceledError();
|
|
@@ -8207,12 +8176,15 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8207
8176
|
})));
|
|
8208
8177
|
this.disposeWithMe(this.registerEventHandler(this.Event.BeforeGridlineEnableChange, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
8209
8178
|
if (commandInfo.id === _univerjs_sheets.ToggleGridlinesCommand.id) {
|
|
8210
|
-
var
|
|
8211
|
-
const
|
|
8179
|
+
var _params$showGridlines;
|
|
8180
|
+
const params = commandInfo.params;
|
|
8181
|
+
const target = this.getSheetCommandTarget(params);
|
|
8212
8182
|
if (!target) return;
|
|
8213
|
-
const
|
|
8183
|
+
const { workbook, worksheet } = target;
|
|
8184
|
+
const showGridlines = (_params$showGridlines = params.showGridlines) !== null && _params$showGridlines !== void 0 ? _params$showGridlines : !worksheet.hasHiddenGridLines();
|
|
8214
8185
|
const eventParams = {
|
|
8215
|
-
|
|
8186
|
+
workbook,
|
|
8187
|
+
worksheet,
|
|
8216
8188
|
enabled: Boolean(showGridlines)
|
|
8217
8189
|
};
|
|
8218
8190
|
this.fireEvent(this.Event.BeforeGridlineEnableChange, eventParams);
|
|
@@ -8236,11 +8208,12 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8236
8208
|
})));
|
|
8237
8209
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetCreated, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8238
8210
|
if (commandInfo.id === _univerjs_sheets.InsertSheetCommand.id) {
|
|
8239
|
-
var
|
|
8240
|
-
const
|
|
8241
|
-
const workbook =
|
|
8211
|
+
var _params$sheet, _params$index;
|
|
8212
|
+
const params = commandInfo.params;
|
|
8213
|
+
const workbook = (params === null || params === void 0 ? void 0 : params.unitId) ? this.getWorkbook(params.unitId) : this.getActiveWorkbook();
|
|
8242
8214
|
if (!workbook) return;
|
|
8243
|
-
const
|
|
8215
|
+
const sheets = workbook.getSheets();
|
|
8216
|
+
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];
|
|
8244
8217
|
if (!worksheet) return;
|
|
8245
8218
|
const eventParams = {
|
|
8246
8219
|
workbook,
|
|
@@ -8251,7 +8224,8 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8251
8224
|
})));
|
|
8252
8225
|
this.disposeWithMe(this.registerEventHandler(this.Event.ActiveSheetChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8253
8226
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetActiveOperation.id) {
|
|
8254
|
-
const
|
|
8227
|
+
const params = commandInfo.params;
|
|
8228
|
+
const target = this.getSheetCommandTarget(params);
|
|
8255
8229
|
if (!target) return;
|
|
8256
8230
|
const { workbook, worksheet: activeSheet } = target;
|
|
8257
8231
|
const eventParams = {
|
|
@@ -8263,9 +8237,8 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8263
8237
|
})));
|
|
8264
8238
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetDeleted, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8265
8239
|
if (commandInfo.id === _univerjs_sheets.RemoveSheetCommand.id) {
|
|
8266
|
-
|
|
8267
|
-
const
|
|
8268
|
-
const workbook = unitId ? this.getUniverSheet(unitId) : (_this$getActiveWorkbo5 = this.getActiveWorkbook) === null || _this$getActiveWorkbo5 === void 0 ? void 0 : _this$getActiveWorkbo5.call(this);
|
|
8240
|
+
const { unitId, subUnitId: sheetId } = commandInfo.params;
|
|
8241
|
+
const workbook = unitId ? this.getWorkbook(unitId) : this.getActiveWorkbook();
|
|
8269
8242
|
if (!workbook || !sheetId) return;
|
|
8270
8243
|
const eventParams = {
|
|
8271
8244
|
workbook,
|
|
@@ -8276,52 +8249,56 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8276
8249
|
})));
|
|
8277
8250
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetMoved, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8278
8251
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetOrderMutation.id) {
|
|
8279
|
-
const
|
|
8280
|
-
const target = this.
|
|
8252
|
+
const params = commandInfo.params;
|
|
8253
|
+
const target = this.getSheetCommandTarget(params);
|
|
8281
8254
|
if (!target) return;
|
|
8282
8255
|
const { workbook, worksheet } = target;
|
|
8256
|
+
const { toOrder: newIndex } = params;
|
|
8283
8257
|
const eventParams = {
|
|
8284
8258
|
workbook,
|
|
8285
8259
|
worksheet,
|
|
8286
|
-
newIndex
|
|
8260
|
+
newIndex
|
|
8287
8261
|
};
|
|
8288
8262
|
this.fireEvent(this.Event.SheetMoved, eventParams);
|
|
8289
8263
|
}
|
|
8290
8264
|
})));
|
|
8291
8265
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetNameChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8292
8266
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetNameCommand.id) {
|
|
8293
|
-
const
|
|
8294
|
-
const target = this.
|
|
8267
|
+
const params = commandInfo.params;
|
|
8268
|
+
const target = this.getSheetCommandTarget(params);
|
|
8295
8269
|
if (!target) return;
|
|
8296
8270
|
const { workbook, worksheet } = target;
|
|
8271
|
+
const { name: newName } = params;
|
|
8297
8272
|
const eventParams = {
|
|
8298
8273
|
workbook,
|
|
8299
8274
|
worksheet,
|
|
8300
|
-
newName
|
|
8275
|
+
newName
|
|
8301
8276
|
};
|
|
8302
8277
|
this.fireEvent(this.Event.SheetNameChanged, eventParams);
|
|
8303
8278
|
}
|
|
8304
8279
|
})));
|
|
8305
8280
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetTabColorChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8306
8281
|
if (commandInfo.id === _univerjs_sheets.SetTabColorMutation.id) {
|
|
8307
|
-
const
|
|
8308
|
-
const target = this.
|
|
8282
|
+
const params = commandInfo.params;
|
|
8283
|
+
const target = this.getSheetCommandTarget(params);
|
|
8309
8284
|
if (!target) return;
|
|
8310
8285
|
const { workbook, worksheet } = target;
|
|
8286
|
+
const { color: newColor } = params;
|
|
8311
8287
|
const eventParams = {
|
|
8312
8288
|
workbook,
|
|
8313
8289
|
worksheet,
|
|
8314
|
-
newColor
|
|
8290
|
+
newColor
|
|
8315
8291
|
};
|
|
8316
8292
|
this.fireEvent(this.Event.SheetTabColorChanged, eventParams);
|
|
8317
8293
|
}
|
|
8318
8294
|
})));
|
|
8319
8295
|
this.disposeWithMe(this.registerEventHandler(this.Event.SheetHideChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8320
8296
|
if (commandInfo.id === _univerjs_sheets.SetWorksheetHideMutation.id) {
|
|
8321
|
-
const
|
|
8322
|
-
const target = this.
|
|
8297
|
+
const params = commandInfo.params;
|
|
8298
|
+
const target = this.getSheetCommandTarget(params);
|
|
8323
8299
|
if (!target) return;
|
|
8324
8300
|
const { workbook, worksheet } = target;
|
|
8301
|
+
const { hidden } = params;
|
|
8325
8302
|
const eventParams = {
|
|
8326
8303
|
workbook,
|
|
8327
8304
|
worksheet,
|
|
@@ -8332,58 +8309,47 @@ var FUniverSheetsMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
8332
8309
|
})));
|
|
8333
8310
|
this.disposeWithMe(this.registerEventHandler(this.Event.GridlineChanged, () => commandService.onCommandExecuted((commandInfo) => {
|
|
8334
8311
|
if (commandInfo.id === _univerjs_sheets.SetGridlinesColorCommand.id || commandInfo.id === _univerjs_sheets.ToggleGridlinesCommand.id) {
|
|
8335
|
-
const
|
|
8312
|
+
const params = commandInfo.params;
|
|
8313
|
+
const target = this.getSheetCommandTarget(params);
|
|
8336
8314
|
if (!target) return;
|
|
8315
|
+
const { workbook, worksheet } = target;
|
|
8337
8316
|
const eventParams = {
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8317
|
+
workbook,
|
|
8318
|
+
worksheet,
|
|
8319
|
+
enabled: !worksheet.hasHiddenGridLines(),
|
|
8320
|
+
color: worksheet.getGridLinesColor()
|
|
8341
8321
|
};
|
|
8342
8322
|
this.fireEvent(this.Event.GridlineChanged, eventParams);
|
|
8343
8323
|
}
|
|
8344
8324
|
})));
|
|
8345
8325
|
this._initWorkbookEvent(injector);
|
|
8346
8326
|
}
|
|
8347
|
-
|
|
8348
|
-
const
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
}));
|
|
8374
|
-
}
|
|
8375
|
-
getActiveSheet() {
|
|
8376
|
-
const workbook = this.getActiveWorkbook();
|
|
8377
|
-
if (!workbook) return null;
|
|
8378
|
-
const worksheet = workbook.getActiveSheet();
|
|
8379
|
-
if (!worksheet) return null;
|
|
8380
|
-
return {
|
|
8381
|
-
workbook,
|
|
8382
|
-
worksheet
|
|
8383
|
-
};
|
|
8384
|
-
}
|
|
8385
|
-
setFreezeSync(enabled) {
|
|
8386
|
-
this._injector.get(_univerjs_sheets.SheetsFreezeSyncController).setEnabled(enabled);
|
|
8327
|
+
_initWorkbookEvent(injector) {
|
|
8328
|
+
const univerInstanceService = injector.get(_univerjs_core.IUniverInstanceService);
|
|
8329
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookDisposed, () => univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
8330
|
+
if (unit.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET) {
|
|
8331
|
+
const eventParams = {
|
|
8332
|
+
unitId: unit.getUnitId(),
|
|
8333
|
+
unitType: unit.type,
|
|
8334
|
+
snapshot: unit.getSnapshot()
|
|
8335
|
+
};
|
|
8336
|
+
this.fireEvent(this.Event.WorkbookDisposed, eventParams);
|
|
8337
|
+
}
|
|
8338
|
+
})));
|
|
8339
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.WorkbookCreated, () => univerInstanceService.unitAdded$.subscribe((event) => {
|
|
8340
|
+
const { unit } = event;
|
|
8341
|
+
if (unit.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET) {
|
|
8342
|
+
const workbook = unit;
|
|
8343
|
+
const workbookUnit = injector.createInstance(FWorkbook, workbook);
|
|
8344
|
+
const eventParams = {
|
|
8345
|
+
unitId: unit.getUnitId(),
|
|
8346
|
+
type: unit.type,
|
|
8347
|
+
workbook: workbookUnit,
|
|
8348
|
+
unit: workbookUnit
|
|
8349
|
+
};
|
|
8350
|
+
this.fireEvent(this.Event.WorkbookCreated, eventParams);
|
|
8351
|
+
}
|
|
8352
|
+
})));
|
|
8387
8353
|
}
|
|
8388
8354
|
};
|
|
8389
8355
|
_univerjs_core_facade.FUniver.extend(FUniverSheetsMixin);
|
|
@@ -8496,31 +8462,6 @@ var FSheetsEventNameMixin = class extends _univerjs_core_facade.FEventName {
|
|
|
8496
8462
|
};
|
|
8497
8463
|
_univerjs_core_facade.FEventName.extend(FSheetsEventNameMixin);
|
|
8498
8464
|
|
|
8499
|
-
//#endregion
|
|
8500
|
-
//#region src/facade/f-sheet-hooks.ts
|
|
8501
|
-
/**
|
|
8502
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
8503
|
-
*
|
|
8504
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8505
|
-
* you may not use this file except in compliance with the License.
|
|
8506
|
-
* You may obtain a copy of the License at
|
|
8507
|
-
*
|
|
8508
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8509
|
-
*
|
|
8510
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8511
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8512
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8513
|
-
* See the License for the specific language governing permissions and
|
|
8514
|
-
* limitations under the License.
|
|
8515
|
-
*/
|
|
8516
|
-
let FSheetHooks = class FSheetHooks extends _univerjs_core_facade.FBase {
|
|
8517
|
-
constructor(_injector) {
|
|
8518
|
-
super();
|
|
8519
|
-
this._injector = _injector;
|
|
8520
|
-
}
|
|
8521
|
-
};
|
|
8522
|
-
FSheetHooks = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], FSheetHooks);
|
|
8523
|
-
|
|
8524
8465
|
//#endregion
|
|
8525
8466
|
Object.defineProperty(exports, 'FRange', {
|
|
8526
8467
|
enumerable: true,
|
|
@@ -8534,12 +8475,6 @@ Object.defineProperty(exports, 'FSelection', {
|
|
|
8534
8475
|
return FSelection;
|
|
8535
8476
|
}
|
|
8536
8477
|
});
|
|
8537
|
-
Object.defineProperty(exports, 'FSheetHooks', {
|
|
8538
|
-
enumerable: true,
|
|
8539
|
-
get: function () {
|
|
8540
|
-
return FSheetHooks;
|
|
8541
|
-
}
|
|
8542
|
-
});
|
|
8543
8478
|
exports.FSheetsEnumMixin = FSheetsEnumMixin;
|
|
8544
8479
|
exports.FSheetsEventNameMixin = FSheetsEventNameMixin;
|
|
8545
8480
|
Object.defineProperty(exports, 'FWorkbook', {
|