@univerjs/sheets-formula 0.21.1 → 0.22.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/README.md +33 -22
- package/lib/cjs/index.js +80 -106
- package/lib/es/index.js +80 -106
- package/lib/index.js +80 -106
- package/lib/umd/index.js +1 -1
- package/package.json +17 -12
package/README.md
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
1
|
# @univerjs/sheets-formula
|
|
2
2
|
|
|
3
|
+
[](https://npmjs.com/package/@univerjs/sheets-formula)
|
|
4
|
+
[](https://npmjs.com/package/@univerjs/sheets-formula)
|
|
5
|
+
[](https://npmjs.com/package/@univerjs/sheets-formula)
|
|
6
|
+
|
|
7
|
+
`@univerjs/sheets-formula` connects the formula engine to Univer Sheets, including formula data services, dependency handling, and sheet-aware calculation.
|
|
8
|
+
|
|
3
9
|
## Package Overview
|
|
4
10
|
|
|
5
|
-
| Package
|
|
6
|
-
| --- | --- |
|
|
7
|
-
| `@univerjs/sheets-formula` | `UniverSheetsFormula` |
|
|
11
|
+
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
|
+
| --- | --- | :---: | :---: | :---: |
|
|
13
|
+
| `@univerjs/sheets-formula` | `UniverSheetsFormula` | No | Yes | Yes |
|
|
8
14
|
|
|
9
|
-
##
|
|
15
|
+
## Installation
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
```sh
|
|
18
|
+
pnpm add @univerjs/sheets-formula
|
|
19
|
+
# or
|
|
20
|
+
npm install @univerjs/sheets-formula
|
|
21
|
+
```
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
> Formula calculation is one of the core functionalities of spreadsheets, and formula calculation scheduling is done in `@univerjs/sheets`.
|
|
23
|
+
Keep all `@univerjs/*` packages on the same version.
|
|
15
24
|
|
|
16
25
|
## Usage
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
```ts
|
|
28
|
+
import EnUS from '@univerjs/sheets-formula/locale/en-US';
|
|
29
|
+
import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
# Using npm
|
|
22
|
-
npm install @univerjs/sheets-formula
|
|
31
|
+
univer.registerPlugin(UniverSheetsFormulaPlugin);
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
pnpm add @univerjs/sheets-formula
|
|
33
|
+
// Merge EnUS into your Univer locale map when this package contributes UI text.
|
|
26
34
|
```
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
Exported plugin classes:
|
|
37
|
+
|
|
38
|
+
- `UniverSheetsFormulaPlugin`
|
|
39
|
+
- `UniverRemoteSheetsFormulaPlugin`
|
|
40
|
+
|
|
41
|
+
## Integration Notes
|
|
42
|
+
|
|
43
|
+
Register this package with `@univerjs/engine-formula` and `@univerjs/sheets` before adding formula UI packages.
|
|
29
44
|
|
|
30
|
-
|
|
45
|
+
## Resources
|
|
31
46
|
|
|
32
|
-
- [
|
|
33
|
-
- [
|
|
47
|
+
- [Documentation](https://docs.univer.ai)
|
|
48
|
+
- [NPM package](https://npmjs.com/package/@univerjs/sheets-formula)
|
|
49
|
+
- [GitHub repository](https://github.com/dream-num/univer)
|
|
34
50
|
|
|
35
|
-
<!-- Links -->
|
|
36
|
-
[npm-version-shield]: https://img.shields.io/npm/v/@univerjs/sheets-formula?style=flat-square
|
|
37
|
-
[npm-version-link]: https://npmjs.com/package/@univerjs/sheets-formula
|
|
38
|
-
[npm-license-shield]: https://img.shields.io/npm/l/@univerjs/sheets-formula?style=flat-square
|
|
39
|
-
[npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/sheets-formula?style=flat-square
|
package/lib/cjs/index.js
CHANGED
|
@@ -153,7 +153,7 @@ const PLUGIN_CONFIG_KEY_MOBILE = "sheets-formula.mobile.config";
|
|
|
153
153
|
const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
|
|
154
154
|
|
|
155
155
|
//#endregion
|
|
156
|
-
//#region \0@oxc-project+runtime@0.
|
|
156
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
157
157
|
function __decorateParam(paramIndex, decorator) {
|
|
158
158
|
return function(target, key) {
|
|
159
159
|
decorator(target, key, paramIndex);
|
|
@@ -161,7 +161,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
//#endregion
|
|
164
|
-
//#region \0@oxc-project+runtime@0.
|
|
164
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
165
165
|
function __decorate(decorators, target, key, desc) {
|
|
166
166
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
167
167
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -275,7 +275,7 @@ function getDataLength(copyDataPiece) {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
//#endregion
|
|
278
|
-
//#region \0@oxc-project+runtime@0.
|
|
278
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
279
279
|
function _typeof(o) {
|
|
280
280
|
"@babel/helpers - typeof";
|
|
281
281
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -286,7 +286,7 @@ function _typeof(o) {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
//#endregion
|
|
289
|
-
//#region \0@oxc-project+runtime@0.
|
|
289
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
290
290
|
function toPrimitive(t, r) {
|
|
291
291
|
if ("object" != _typeof(t) || !t) return t;
|
|
292
292
|
var e = t[Symbol.toPrimitive];
|
|
@@ -299,14 +299,14 @@ function toPrimitive(t, r) {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
//#endregion
|
|
302
|
-
//#region \0@oxc-project+runtime@0.
|
|
302
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
303
303
|
function toPropertyKey(t) {
|
|
304
304
|
var i = toPrimitive(t, "string");
|
|
305
305
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
//#endregion
|
|
309
|
-
//#region \0@oxc-project+runtime@0.
|
|
309
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
310
310
|
function _defineProperty(e, r, t) {
|
|
311
311
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
312
312
|
value: t,
|
|
@@ -553,7 +553,7 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
553
553
|
_getCalculationMode() {
|
|
554
554
|
var _config$initialFormul;
|
|
555
555
|
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
556
|
-
return (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul :
|
|
556
|
+
return (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul : 1;
|
|
557
557
|
}
|
|
558
558
|
_commandExecutedListener() {
|
|
559
559
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
@@ -774,8 +774,8 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
774
774
|
}
|
|
775
775
|
_getDirtyDataByCalculationMode(calculationMode) {
|
|
776
776
|
return {
|
|
777
|
-
forceCalculation: calculationMode ===
|
|
778
|
-
dirtyRanges: calculationMode ===
|
|
777
|
+
forceCalculation: calculationMode === 0,
|
|
778
|
+
dirtyRanges: calculationMode === 1 ? this._formulaDataModel.getFormulaDirtyRanges() : [],
|
|
779
779
|
dirtyNameMap: {},
|
|
780
780
|
dirtyDefinedNameMap: {},
|
|
781
781
|
dirtyUnitFeatureMap: {},
|
|
@@ -816,29 +816,11 @@ function removeFormulaData(formulaData, unitId, sheetId) {
|
|
|
816
816
|
|
|
817
817
|
//#endregion
|
|
818
818
|
//#region src/controllers/utils/ref-range-formula.ts
|
|
819
|
-
let FormulaReferenceMoveType = /* @__PURE__ */ function(FormulaReferenceMoveType) {
|
|
820
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["MoveRange"] = 0] = "MoveRange";
|
|
821
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["MoveRows"] = 1] = "MoveRows";
|
|
822
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["MoveCols"] = 2] = "MoveCols";
|
|
823
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertRow"] = 3] = "InsertRow";
|
|
824
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertColumn"] = 4] = "InsertColumn";
|
|
825
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveRow"] = 5] = "RemoveRow";
|
|
826
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveColumn"] = 6] = "RemoveColumn";
|
|
827
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["DeleteMoveLeft"] = 7] = "DeleteMoveLeft";
|
|
828
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["DeleteMoveUp"] = 8] = "DeleteMoveUp";
|
|
829
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertMoveDown"] = 9] = "InsertMoveDown";
|
|
830
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertMoveRight"] = 10] = "InsertMoveRight";
|
|
831
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["SetName"] = 11] = "SetName";
|
|
832
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveSheet"] = 12] = "RemoveSheet";
|
|
833
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["SetDefinedName"] = 13] = "SetDefinedName";
|
|
834
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveDefinedName"] = 14] = "RemoveDefinedName";
|
|
835
|
-
return FormulaReferenceMoveType;
|
|
836
|
-
}({});
|
|
837
819
|
const formulaReferenceSheetList = [
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
820
|
+
11,
|
|
821
|
+
12,
|
|
822
|
+
13,
|
|
823
|
+
14
|
|
842
824
|
];
|
|
843
825
|
function getFormulaReferenceMoveUndoRedo(oldFormulaData, newFormulaData, formulaReferenceMoveParam) {
|
|
844
826
|
const { type } = formulaReferenceMoveParam;
|
|
@@ -988,9 +970,9 @@ function processFormulaChanges(oldFormulaMatrix, newFormulaMatrix, formulaRefere
|
|
|
988
970
|
let newCell = null;
|
|
989
971
|
let isReverse = false;
|
|
990
972
|
if ([
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
973
|
+
0,
|
|
974
|
+
1,
|
|
975
|
+
2
|
|
994
976
|
].includes(type)) newCell = handleMove(type, from, to, oldCell);
|
|
995
977
|
else if (range !== void 0 && range !== null) {
|
|
996
978
|
const result = handleInsertDelete(oldCell, formulaReferenceMoveParam);
|
|
@@ -1023,9 +1005,9 @@ function processFormulaRange(newFormulaMatrix) {
|
|
|
1023
1005
|
function handleMove(type, from, to, oldCell) {
|
|
1024
1006
|
if (from == null || to == null) return null;
|
|
1025
1007
|
switch (type) {
|
|
1026
|
-
case
|
|
1027
|
-
case
|
|
1028
|
-
case
|
|
1008
|
+
case 0: return handleRefMoveRange$1(from, to, oldCell);
|
|
1009
|
+
case 1: return handleRefMoveRows$1(from, to, oldCell);
|
|
1010
|
+
case 2: return handleRefMoveCols$1(from, to, oldCell);
|
|
1029
1011
|
default: return null;
|
|
1030
1012
|
}
|
|
1031
1013
|
}
|
|
@@ -1035,31 +1017,31 @@ function handleInsertDelete(oldCell, formulaReferenceMoveParam) {
|
|
|
1035
1017
|
let newCell = null;
|
|
1036
1018
|
let isReverse = false;
|
|
1037
1019
|
switch (type) {
|
|
1038
|
-
case
|
|
1020
|
+
case 3:
|
|
1039
1021
|
newCell = handleRefInsertRow$1(range, oldCell);
|
|
1040
1022
|
isReverse = true;
|
|
1041
1023
|
break;
|
|
1042
|
-
case
|
|
1024
|
+
case 4:
|
|
1043
1025
|
newCell = handleRefInsertCol$1(range, oldCell);
|
|
1044
1026
|
isReverse = true;
|
|
1045
1027
|
break;
|
|
1046
|
-
case
|
|
1028
|
+
case 5:
|
|
1047
1029
|
newCell = handleRefRemoveRow$1(range, oldCell, rangeFilteredRows);
|
|
1048
1030
|
break;
|
|
1049
|
-
case
|
|
1031
|
+
case 6:
|
|
1050
1032
|
newCell = handleRefRemoveCol$1(range, oldCell);
|
|
1051
1033
|
break;
|
|
1052
|
-
case
|
|
1034
|
+
case 7:
|
|
1053
1035
|
newCell = handleRefDeleteMoveLeft(range, oldCell);
|
|
1054
1036
|
break;
|
|
1055
|
-
case
|
|
1037
|
+
case 8:
|
|
1056
1038
|
newCell = handleRefDeleteMoveUp(range, oldCell);
|
|
1057
1039
|
break;
|
|
1058
|
-
case
|
|
1040
|
+
case 9:
|
|
1059
1041
|
newCell = handleRefInsertMoveDown(range, oldCell);
|
|
1060
1042
|
isReverse = true;
|
|
1061
1043
|
break;
|
|
1062
|
-
case
|
|
1044
|
+
case 10:
|
|
1063
1045
|
newCell = handleRefInsertMoveRight(range, oldCell);
|
|
1064
1046
|
isReverse = true;
|
|
1065
1047
|
break;
|
|
@@ -1295,14 +1277,6 @@ function updateRefOffset(sequenceNodes, refChangeIds, refOffsetX = 0, refOffsetY
|
|
|
1295
1277
|
|
|
1296
1278
|
//#endregion
|
|
1297
1279
|
//#region src/controllers/utils/ref-range-move.ts
|
|
1298
|
-
let OriginRangeEdgeType = /* @__PURE__ */ function(OriginRangeEdgeType) {
|
|
1299
|
-
OriginRangeEdgeType[OriginRangeEdgeType["UP"] = 0] = "UP";
|
|
1300
|
-
OriginRangeEdgeType[OriginRangeEdgeType["DOWN"] = 1] = "DOWN";
|
|
1301
|
-
OriginRangeEdgeType[OriginRangeEdgeType["LEFT"] = 2] = "LEFT";
|
|
1302
|
-
OriginRangeEdgeType[OriginRangeEdgeType["RIGHT"] = 3] = "RIGHT";
|
|
1303
|
-
OriginRangeEdgeType[OriginRangeEdgeType["ALL"] = 4] = "ALL";
|
|
1304
|
-
return OriginRangeEdgeType;
|
|
1305
|
-
}({});
|
|
1306
1280
|
function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam, currentFormulaUnitId, currentFormulaSheetId, options = {}) {
|
|
1307
1281
|
const { type, unitId: userUnitId, sheetId: userSheetId, targetUnitId, targetSheetId, targetSheetName, range, from, to, rangeFilteredRows } = formulaReferenceMoveParam;
|
|
1308
1282
|
const { range: unitRange, sheetId: sequenceRangeSheetId, unitId: sequenceRangeUnitId, sheetName: sequenceRangeSheetName, refOffsetX, refOffsetY } = unitRangeWidthOffset;
|
|
@@ -1310,11 +1284,11 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1310
1284
|
if (!checkIsSameUnitAndSheet(userUnitId, userSheetId, currentFormulaUnitId, currentFormulaSheetId, sequenceRangeUnitId, sequenceRangeSheetId)) return;
|
|
1311
1285
|
const sequenceRange = _univerjs_core.Rectangle.moveOffset(unitRange, refOffsetX, refOffsetY);
|
|
1312
1286
|
let newRange = null;
|
|
1313
|
-
if (type ===
|
|
1287
|
+
if (type === 0) {
|
|
1314
1288
|
if (from == null || to == null) return;
|
|
1315
1289
|
const moveEdge = checkMoveEdge(sequenceRange, from);
|
|
1316
1290
|
const remainRange = (0, _univerjs_core.getIntersectRange)(sequenceRange, from);
|
|
1317
|
-
if (remainRange == null || moveEdge !==
|
|
1291
|
+
if (remainRange == null || moveEdge !== 4) return;
|
|
1318
1292
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveRange)({
|
|
1319
1293
|
id: _univerjs_sheets.EffectRefRangId.MoveRangeCommandId,
|
|
1320
1294
|
params: {
|
|
@@ -1324,7 +1298,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1324
1298
|
}, remainRange), remainRange);
|
|
1325
1299
|
if (result == null) return _univerjs_engine_formula.ErrorType.REF;
|
|
1326
1300
|
newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
|
|
1327
|
-
} else if (type ===
|
|
1301
|
+
} else if (type === 1) {
|
|
1328
1302
|
if (from == null || to == null) return;
|
|
1329
1303
|
const moveEdge = checkMoveEdge(sequenceRange, from);
|
|
1330
1304
|
let remainRange = (0, _univerjs_core.getIntersectRange)(sequenceRange, from);
|
|
@@ -1345,7 +1319,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1345
1319
|
}, remainRange), remainRange);
|
|
1346
1320
|
if (result == null) return _univerjs_engine_formula.ErrorType.REF;
|
|
1347
1321
|
newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
|
|
1348
|
-
} else if (type ===
|
|
1322
|
+
} else if (type === 2) {
|
|
1349
1323
|
if (from == null || to == null) return;
|
|
1350
1324
|
const moveEdge = checkMoveEdge(sequenceRange, from);
|
|
1351
1325
|
let remainRange = (0, _univerjs_core.getIntersectRange)(sequenceRange, from);
|
|
@@ -1368,7 +1342,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1368
1342
|
newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
|
|
1369
1343
|
}
|
|
1370
1344
|
if (range != null) {
|
|
1371
|
-
if (type ===
|
|
1345
|
+
if (type === 3) {
|
|
1372
1346
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRow)({
|
|
1373
1347
|
id: _univerjs_sheets.EffectRefRangId.InsertRowCommandId,
|
|
1374
1348
|
params: {
|
|
@@ -1383,7 +1357,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1383
1357
|
...sequenceRange,
|
|
1384
1358
|
...result
|
|
1385
1359
|
};
|
|
1386
|
-
} else if (type ===
|
|
1360
|
+
} else if (type === 4) {
|
|
1387
1361
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertCol)({
|
|
1388
1362
|
id: _univerjs_sheets.EffectRefRangId.InsertColCommandId,
|
|
1389
1363
|
params: {
|
|
@@ -1398,7 +1372,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1398
1372
|
...sequenceRange,
|
|
1399
1373
|
...result
|
|
1400
1374
|
};
|
|
1401
|
-
} else if (type ===
|
|
1375
|
+
} else if (type === 5) {
|
|
1402
1376
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleIRemoveRow)({
|
|
1403
1377
|
id: _univerjs_sheets.EffectRefRangId.RemoveRowCommandId,
|
|
1404
1378
|
params: { range }
|
|
@@ -1408,7 +1382,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1408
1382
|
...sequenceRange,
|
|
1409
1383
|
...result
|
|
1410
1384
|
};
|
|
1411
|
-
} else if (type ===
|
|
1385
|
+
} else if (type === 6) {
|
|
1412
1386
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleIRemoveCol)({
|
|
1413
1387
|
id: _univerjs_sheets.EffectRefRangId.RemoveColCommandId,
|
|
1414
1388
|
params: { range }
|
|
@@ -1418,7 +1392,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1418
1392
|
...sequenceRange,
|
|
1419
1393
|
...result
|
|
1420
1394
|
};
|
|
1421
|
-
} else if (type ===
|
|
1395
|
+
} else if (type === 7) {
|
|
1422
1396
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleDeleteRangeMoveLeft)({
|
|
1423
1397
|
id: _univerjs_sheets.EffectRefRangId.DeleteRangeMoveLeftCommandId,
|
|
1424
1398
|
params: { range }
|
|
@@ -1428,7 +1402,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1428
1402
|
...sequenceRange,
|
|
1429
1403
|
...result
|
|
1430
1404
|
};
|
|
1431
|
-
} else if (type ===
|
|
1405
|
+
} else if (type === 8) {
|
|
1432
1406
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleDeleteRangeMoveUp)({
|
|
1433
1407
|
id: _univerjs_sheets.EffectRefRangId.DeleteRangeMoveUpCommandId,
|
|
1434
1408
|
params: { range }
|
|
@@ -1438,7 +1412,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1438
1412
|
...sequenceRange,
|
|
1439
1413
|
...result
|
|
1440
1414
|
};
|
|
1441
|
-
} else if (type ===
|
|
1415
|
+
} else if (type === 9) {
|
|
1442
1416
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRangeMoveDown)({
|
|
1443
1417
|
id: _univerjs_sheets.EffectRefRangId.InsertRangeMoveDownCommandId,
|
|
1444
1418
|
params: { range }
|
|
@@ -1448,7 +1422,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1448
1422
|
...sequenceRange,
|
|
1449
1423
|
...result
|
|
1450
1424
|
};
|
|
1451
|
-
} else if (type ===
|
|
1425
|
+
} else if (type === 10) {
|
|
1452
1426
|
const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRangeMoveRight)({
|
|
1453
1427
|
id: _univerjs_sheets.EffectRefRangId.InsertRangeMoveRightCommandId,
|
|
1454
1428
|
params: { range }
|
|
@@ -1461,7 +1435,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1461
1435
|
}
|
|
1462
1436
|
}
|
|
1463
1437
|
if (newRange == null) return;
|
|
1464
|
-
const shouldRewriteSheet = type ===
|
|
1438
|
+
const shouldRewriteSheet = type === 0 && !!targetSheetId && targetSheetId !== userSheetId && !inCrossSheetCutRange;
|
|
1465
1439
|
const rewrittenSheetId = shouldRewriteSheet ? targetSheetId : sequenceRangeSheetId;
|
|
1466
1440
|
const rewrittenSheetName = shouldRewriteSheet ? targetSheetName || sequenceRangeSheetName : sequenceRangeSheetName;
|
|
1467
1441
|
const rewrittenUnitId = shouldRewriteSheet ? targetUnitId || sequenceRangeUnitId : sequenceRangeUnitId;
|
|
@@ -1497,23 +1471,23 @@ function getMoveNewRange(moveEdge, result, from, to, origin, remain) {
|
|
|
1497
1471
|
if (rangeType === _univerjs_core.RANGE_TYPE.ROW && originRangeType === _univerjs_core.RANGE_TYPE.ROW) return true;
|
|
1498
1472
|
return startRow >= originStartRow && endRow <= originEndRow;
|
|
1499
1473
|
}
|
|
1500
|
-
if (moveEdge ===
|
|
1474
|
+
if (moveEdge === 0) if (rowsCover()) if (startRow < originStartRow) newRange.startRow = startRow;
|
|
1501
1475
|
else if (startRow >= originEndRow) newRange.endRow -= fromEndRow + 1 - originStartRow;
|
|
1502
1476
|
else return;
|
|
1503
1477
|
else return;
|
|
1504
|
-
else if (moveEdge ===
|
|
1478
|
+
else if (moveEdge === 1) if (rowsCover()) if (endRow > originEndRow) newRange.endRow = endRow;
|
|
1505
1479
|
else if (endRow <= originStartRow) newRange.startRow += originEndRow - fromStartRow + 1;
|
|
1506
1480
|
else return;
|
|
1507
1481
|
else return;
|
|
1508
|
-
else if (moveEdge ===
|
|
1482
|
+
else if (moveEdge === 2) if (columnsCover()) if (startColumn < originStartColumn) newRange.startColumn = startColumn;
|
|
1509
1483
|
else if (startColumn >= originEndColumn) newRange.endColumn -= fromEndColumn + 1 - originStartColumn;
|
|
1510
1484
|
else return;
|
|
1511
1485
|
else return;
|
|
1512
|
-
else if (moveEdge ===
|
|
1486
|
+
else if (moveEdge === 3) if (columnsCover()) if (endColumn > originEndColumn) newRange.endColumn = endColumn;
|
|
1513
1487
|
else if (endColumn <= originStartColumn) newRange.startColumn += originEndColumn - fromStartColumn + 1;
|
|
1514
1488
|
else return;
|
|
1515
1489
|
else return;
|
|
1516
|
-
else if (moveEdge ===
|
|
1490
|
+
else if (moveEdge === 4) {
|
|
1517
1491
|
newRange.startRow = startRow;
|
|
1518
1492
|
newRange.startColumn = startColumn;
|
|
1519
1493
|
newRange.endRow = endRow;
|
|
@@ -1584,11 +1558,11 @@ function checkMoveEdge(originRange, fromRange) {
|
|
|
1584
1558
|
function allCover() {
|
|
1585
1559
|
return originRange.rangeType === _univerjs_core.RANGE_TYPE.ALL && fromRange.rangeType === _univerjs_core.RANGE_TYPE.ALL;
|
|
1586
1560
|
}
|
|
1587
|
-
if (rowsCover() && columnsCover() || allCover()) return
|
|
1588
|
-
if (columnsCover() && startRow >= fromStartRow && startRow <= fromEndRow && endRow > fromEndRow) return
|
|
1589
|
-
if (columnsCover() && endRow >= fromStartRow && endRow <= fromEndRow && startRow < fromStartRow) return
|
|
1590
|
-
if (rowsCover() && startColumn >= fromStartColumn && startColumn <= fromEndColumn && endColumn > fromEndColumn) return
|
|
1591
|
-
if (rowsCover() && endColumn >= fromStartColumn && endColumn <= fromEndColumn && startColumn < fromStartColumn) return
|
|
1561
|
+
if (rowsCover() && columnsCover() || allCover()) return 4;
|
|
1562
|
+
if (columnsCover() && startRow >= fromStartRow && startRow <= fromEndRow && endRow > fromEndRow) return 0;
|
|
1563
|
+
if (columnsCover() && endRow >= fromStartRow && endRow <= fromEndRow && startRow < fromStartRow) return 1;
|
|
1564
|
+
if (rowsCover() && startColumn >= fromStartColumn && startColumn <= fromEndColumn && endColumn > fromEndColumn) return 2;
|
|
1565
|
+
if (rowsCover() && endColumn >= fromStartColumn && endColumn <= fromEndColumn && startColumn < fromStartColumn) return 3;
|
|
1592
1566
|
return null;
|
|
1593
1567
|
}
|
|
1594
1568
|
function getStartValue(value) {
|
|
@@ -1683,7 +1657,7 @@ function handleRefMoveRange(command, workbook) {
|
|
|
1683
1657
|
const targetUnitId = toUnitId || fromUnitId || currentUnitId;
|
|
1684
1658
|
const targetSheetName = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(targetSheetId)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName();
|
|
1685
1659
|
return {
|
|
1686
|
-
type:
|
|
1660
|
+
type: 0,
|
|
1687
1661
|
from: fromRange,
|
|
1688
1662
|
to: toRange,
|
|
1689
1663
|
unitId,
|
|
@@ -1717,7 +1691,7 @@ function handleRefMoveRows(command, workbook) {
|
|
|
1717
1691
|
rangeType: _univerjs_core.RANGE_TYPE.ROW
|
|
1718
1692
|
};
|
|
1719
1693
|
return {
|
|
1720
|
-
type:
|
|
1694
|
+
type: 1,
|
|
1721
1695
|
from,
|
|
1722
1696
|
to,
|
|
1723
1697
|
unitId,
|
|
@@ -1747,7 +1721,7 @@ function handleRefMoveCols(command, workbook) {
|
|
|
1747
1721
|
rangeType: _univerjs_core.RANGE_TYPE.COLUMN
|
|
1748
1722
|
};
|
|
1749
1723
|
return {
|
|
1750
|
-
type:
|
|
1724
|
+
type: 2,
|
|
1751
1725
|
from,
|
|
1752
1726
|
to,
|
|
1753
1727
|
unitId,
|
|
@@ -1759,7 +1733,7 @@ function handleRefInsertRow(command) {
|
|
|
1759
1733
|
if (!params) return null;
|
|
1760
1734
|
const { range, unitId, subUnitId } = params;
|
|
1761
1735
|
return {
|
|
1762
|
-
type:
|
|
1736
|
+
type: 3,
|
|
1763
1737
|
range,
|
|
1764
1738
|
unitId,
|
|
1765
1739
|
sheetId: subUnitId
|
|
@@ -1770,7 +1744,7 @@ function handleRefInsertCol(command) {
|
|
|
1770
1744
|
if (!params) return null;
|
|
1771
1745
|
const { range, unitId, subUnitId } = params;
|
|
1772
1746
|
return {
|
|
1773
|
-
type:
|
|
1747
|
+
type: 4,
|
|
1774
1748
|
range,
|
|
1775
1749
|
unitId,
|
|
1776
1750
|
sheetId: subUnitId
|
|
@@ -1782,7 +1756,7 @@ function handleRefInsertRangeMoveRight(command, workbook) {
|
|
|
1782
1756
|
const { range } = params;
|
|
1783
1757
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1784
1758
|
return {
|
|
1785
|
-
type:
|
|
1759
|
+
type: 10,
|
|
1786
1760
|
range,
|
|
1787
1761
|
unitId,
|
|
1788
1762
|
sheetId
|
|
@@ -1794,7 +1768,7 @@ function handleRefInsertRangeMoveDown(command, workbook) {
|
|
|
1794
1768
|
const { range } = params;
|
|
1795
1769
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1796
1770
|
return {
|
|
1797
|
-
type:
|
|
1771
|
+
type: 9,
|
|
1798
1772
|
range,
|
|
1799
1773
|
unitId,
|
|
1800
1774
|
sheetId
|
|
@@ -1807,7 +1781,7 @@ function handleRefRemoveRow(command, workbook) {
|
|
|
1807
1781
|
const { range } = params;
|
|
1808
1782
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1809
1783
|
return {
|
|
1810
|
-
type:
|
|
1784
|
+
type: 5,
|
|
1811
1785
|
range,
|
|
1812
1786
|
unitId,
|
|
1813
1787
|
sheetId,
|
|
@@ -1820,7 +1794,7 @@ function handleRefRemoveCol(command, workbook) {
|
|
|
1820
1794
|
const { range } = params;
|
|
1821
1795
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1822
1796
|
return {
|
|
1823
|
-
type:
|
|
1797
|
+
type: 6,
|
|
1824
1798
|
range,
|
|
1825
1799
|
unitId,
|
|
1826
1800
|
sheetId
|
|
@@ -1832,7 +1806,7 @@ function handleRefDeleteRangeMoveUp(command, workbook) {
|
|
|
1832
1806
|
const { range } = params;
|
|
1833
1807
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1834
1808
|
return {
|
|
1835
|
-
type:
|
|
1809
|
+
type: 8,
|
|
1836
1810
|
range,
|
|
1837
1811
|
unitId,
|
|
1838
1812
|
sheetId
|
|
@@ -1844,7 +1818,7 @@ function handleRefDeleteRangeMoveLeft(command, workbook) {
|
|
|
1844
1818
|
const { range } = params;
|
|
1845
1819
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1846
1820
|
return {
|
|
1847
|
-
type:
|
|
1821
|
+
type: 7,
|
|
1848
1822
|
range,
|
|
1849
1823
|
unitId,
|
|
1850
1824
|
sheetId
|
|
@@ -1856,7 +1830,7 @@ function handleRefSetWorksheetName(command, workbook) {
|
|
|
1856
1830
|
const { unitId, subUnitId, name } = params;
|
|
1857
1831
|
const { unitId: workbookId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1858
1832
|
return {
|
|
1859
|
-
type:
|
|
1833
|
+
type: 11,
|
|
1860
1834
|
unitId: unitId || workbookId,
|
|
1861
1835
|
sheetId: subUnitId || sheetId,
|
|
1862
1836
|
sheetName: name
|
|
@@ -1868,7 +1842,7 @@ function handleRefRemoveWorksheet(command, workbook) {
|
|
|
1868
1842
|
const { unitId, subUnitId } = params;
|
|
1869
1843
|
const { unitId: workbookId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1870
1844
|
return {
|
|
1871
|
-
type:
|
|
1845
|
+
type: 12,
|
|
1872
1846
|
unitId: unitId || workbookId,
|
|
1873
1847
|
sheetId: subUnitId || sheetId
|
|
1874
1848
|
};
|
|
@@ -1879,7 +1853,7 @@ function handleRefSetDefinedName(command, workbook) {
|
|
|
1879
1853
|
const { unitId, name, id } = params;
|
|
1880
1854
|
const { sheetId } = getCurrentSheetInfo(workbook);
|
|
1881
1855
|
return {
|
|
1882
|
-
type:
|
|
1856
|
+
type: 13,
|
|
1883
1857
|
unitId,
|
|
1884
1858
|
sheetId,
|
|
1885
1859
|
definedName: name,
|
|
@@ -1892,7 +1866,7 @@ function handleRefRemoveDefinedName(command, workbook) {
|
|
|
1892
1866
|
const { unitId, name, id } = params;
|
|
1893
1867
|
const { sheetId } = getCurrentSheetInfo(workbook);
|
|
1894
1868
|
return {
|
|
1895
|
-
type:
|
|
1869
|
+
type: 14,
|
|
1896
1870
|
unitId,
|
|
1897
1871
|
sheetId,
|
|
1898
1872
|
definedName: name,
|
|
@@ -1964,8 +1938,8 @@ let UpdateDefinedNameController = class UpdateDefinedNameController extends _uni
|
|
|
1964
1938
|
refOffsetY: 0
|
|
1965
1939
|
};
|
|
1966
1940
|
let newRefString = null;
|
|
1967
|
-
if (type ===
|
|
1968
|
-
else if (type ===
|
|
1941
|
+
if (type === 12) newRefString = this._removeSheet(item, unitId, sheetId);
|
|
1942
|
+
else if (type === 11) {
|
|
1969
1943
|
const { sheetId: userSheetId, sheetName: newSheetName } = moveParams;
|
|
1970
1944
|
if (newSheetName == null) continue;
|
|
1971
1945
|
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
@@ -2117,14 +2091,14 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2117
2091
|
});
|
|
2118
2092
|
this._commandService.executeCommand(_univerjs_engine_formula.SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
|
|
2119
2093
|
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
2120
|
-
const calculationMode = (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul :
|
|
2094
|
+
const calculationMode = (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul : 1;
|
|
2121
2095
|
const params = this._getDirtyDataByCalculationMode(calculationMode);
|
|
2122
2096
|
this._commandService.executeCommand(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, params, { onlyLocal: true });
|
|
2123
2097
|
}
|
|
2124
2098
|
_getDirtyDataByCalculationMode(calculationMode) {
|
|
2125
2099
|
return {
|
|
2126
|
-
forceCalculation: calculationMode ===
|
|
2127
|
-
dirtyRanges: calculationMode ===
|
|
2100
|
+
forceCalculation: calculationMode === 0,
|
|
2101
|
+
dirtyRanges: calculationMode === 1 ? this._formulaDataModel.getFormulaDirtyRanges() : [],
|
|
2128
2102
|
dirtyNameMap: {},
|
|
2129
2103
|
dirtyDefinedNameMap: {},
|
|
2130
2104
|
dirtyUnitFeatureMap: {},
|
|
@@ -2177,14 +2151,14 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2177
2151
|
if (sequenceNodes == null) return true;
|
|
2178
2152
|
let shouldModify = false;
|
|
2179
2153
|
const refChangeIds = [];
|
|
2180
|
-
const inCrossSheetCutRange = type ===
|
|
2154
|
+
const inCrossSheetCutRange = type === 0 && (targetUnitId !== fromUnitId || targetSheetId !== fromSheetId) && unitId === fromUnitId && sheetId === fromSheetId && from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn;
|
|
2181
2155
|
const inCrossSheetCutRangeSequenceNodes = [...sequenceNodes];
|
|
2182
2156
|
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2183
2157
|
var _unitSheetNameMap$map;
|
|
2184
2158
|
const node = sequenceNodes[i];
|
|
2185
2159
|
if (typeof node === "string") continue;
|
|
2186
2160
|
const { token, nodeType } = node;
|
|
2187
|
-
if ((type ===
|
|
2161
|
+
if ((type === 13 || type === 14) && (nodeType === _univerjs_engine_formula.sequenceNodeType.DEFINED_NAME || nodeType === _univerjs_engine_formula.sequenceNodeType.FUNCTION)) {
|
|
2188
2162
|
const { definedNameId, definedName } = formulaReferenceMoveParam;
|
|
2189
2163
|
if (definedNameId === void 0 || definedName === void 0) continue;
|
|
2190
2164
|
const oldDefinedName = this._definedNamesService.getValueById(unitId, definedNameId);
|
|
@@ -2192,7 +2166,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2192
2166
|
if (oldDefinedName.name !== token) continue;
|
|
2193
2167
|
sequenceNodes[i] = {
|
|
2194
2168
|
...node,
|
|
2195
|
-
token: type ===
|
|
2169
|
+
token: type === 13 ? definedName : _univerjs_engine_formula.ErrorType.REF
|
|
2196
2170
|
};
|
|
2197
2171
|
shouldModify = true;
|
|
2198
2172
|
refChangeIds.push(i);
|
|
@@ -2211,7 +2185,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2211
2185
|
refOffsetY: y || 0
|
|
2212
2186
|
};
|
|
2213
2187
|
let newRefString = null;
|
|
2214
|
-
if (type ===
|
|
2188
|
+
if (type === 11) {
|
|
2215
2189
|
const { unitId: userUnitId, sheetId: userSheetId, sheetName: newSheetName } = formulaReferenceMoveParam;
|
|
2216
2190
|
if (newSheetName == null) continue;
|
|
2217
2191
|
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
@@ -2221,12 +2195,12 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2221
2195
|
sheetName: newSheetName,
|
|
2222
2196
|
unitId: sequenceUnitId
|
|
2223
2197
|
});
|
|
2224
|
-
} else if (type ===
|
|
2198
|
+
} else if (type === 12) {
|
|
2225
2199
|
const { unitId: userUnitId, sheetId: userSheetId, sheetName: newSheetName } = formulaReferenceMoveParam;
|
|
2226
2200
|
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
2227
2201
|
if (userSheetId !== sequenceSheetId) continue;
|
|
2228
2202
|
newRefString = _univerjs_engine_formula.ErrorType.REF;
|
|
2229
|
-
} else if (type !==
|
|
2203
|
+
} else if (type !== 13) newRefString = getNewRangeByMoveParam(sequenceUnitRangeWidthOffset, formulaReferenceMoveParam, unitId, sheetId, { inCrossSheetCutRange });
|
|
2230
2204
|
if (newRefString != null) {
|
|
2231
2205
|
sequenceNodes[i] = {
|
|
2232
2206
|
...node,
|
|
@@ -2270,9 +2244,9 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2270
2244
|
* This is to ensure that the si formula can be recalculated correctly after the move.
|
|
2271
2245
|
*/
|
|
2272
2246
|
if (si && [
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2247
|
+
1,
|
|
2248
|
+
2,
|
|
2249
|
+
0
|
|
2276
2250
|
].includes(type)) {
|
|
2277
2251
|
if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
|
|
2278
2252
|
if ((x !== null && x !== void 0 ? x : 0) === 0 && (y !== null && y !== void 0 ? y : 0) === 0) shouldModifySi.push(si);
|
|
@@ -2322,7 +2296,7 @@ UpdateFormulaController = __decorate([
|
|
|
2322
2296
|
//#endregion
|
|
2323
2297
|
//#region package.json
|
|
2324
2298
|
var name = "@univerjs/sheets-formula";
|
|
2325
|
-
var version = "0.
|
|
2299
|
+
var version = "0.22.0";
|
|
2326
2300
|
|
|
2327
2301
|
//#endregion
|
|
2328
2302
|
//#region src/common/plugin-name.ts
|