@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/lib/es/index.js
CHANGED
|
@@ -152,7 +152,7 @@ const PLUGIN_CONFIG_KEY_MOBILE = "sheets-formula.mobile.config";
|
|
|
152
152
|
const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
|
|
153
153
|
|
|
154
154
|
//#endregion
|
|
155
|
-
//#region \0@oxc-project+runtime@0.
|
|
155
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
156
156
|
function __decorateParam(paramIndex, decorator) {
|
|
157
157
|
return function(target, key) {
|
|
158
158
|
decorator(target, key, paramIndex);
|
|
@@ -160,7 +160,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
//#endregion
|
|
163
|
-
//#region \0@oxc-project+runtime@0.
|
|
163
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
164
164
|
function __decorate(decorators, target, key, desc) {
|
|
165
165
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
166
166
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -274,7 +274,7 @@ function getDataLength(copyDataPiece) {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
//#endregion
|
|
277
|
-
//#region \0@oxc-project+runtime@0.
|
|
277
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
278
278
|
function _typeof(o) {
|
|
279
279
|
"@babel/helpers - typeof";
|
|
280
280
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -285,7 +285,7 @@ function _typeof(o) {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
//#endregion
|
|
288
|
-
//#region \0@oxc-project+runtime@0.
|
|
288
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
289
289
|
function toPrimitive(t, r) {
|
|
290
290
|
if ("object" != _typeof(t) || !t) return t;
|
|
291
291
|
var e = t[Symbol.toPrimitive];
|
|
@@ -298,14 +298,14 @@ function toPrimitive(t, r) {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
//#endregion
|
|
301
|
-
//#region \0@oxc-project+runtime@0.
|
|
301
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
302
302
|
function toPropertyKey(t) {
|
|
303
303
|
var i = toPrimitive(t, "string");
|
|
304
304
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
//#endregion
|
|
308
|
-
//#region \0@oxc-project+runtime@0.
|
|
308
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
309
309
|
function _defineProperty(e, r, t) {
|
|
310
310
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
311
311
|
value: t,
|
|
@@ -552,7 +552,7 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
552
552
|
_getCalculationMode() {
|
|
553
553
|
var _config$initialFormul;
|
|
554
554
|
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
555
|
-
return (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul :
|
|
555
|
+
return (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul : 1;
|
|
556
556
|
}
|
|
557
557
|
_commandExecutedListener() {
|
|
558
558
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
@@ -773,8 +773,8 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
773
773
|
}
|
|
774
774
|
_getDirtyDataByCalculationMode(calculationMode) {
|
|
775
775
|
return {
|
|
776
|
-
forceCalculation: calculationMode ===
|
|
777
|
-
dirtyRanges: calculationMode ===
|
|
776
|
+
forceCalculation: calculationMode === 0,
|
|
777
|
+
dirtyRanges: calculationMode === 1 ? this._formulaDataModel.getFormulaDirtyRanges() : [],
|
|
778
778
|
dirtyNameMap: {},
|
|
779
779
|
dirtyDefinedNameMap: {},
|
|
780
780
|
dirtyUnitFeatureMap: {},
|
|
@@ -815,29 +815,11 @@ function removeFormulaData(formulaData, unitId, sheetId) {
|
|
|
815
815
|
|
|
816
816
|
//#endregion
|
|
817
817
|
//#region src/controllers/utils/ref-range-formula.ts
|
|
818
|
-
let FormulaReferenceMoveType = /* @__PURE__ */ function(FormulaReferenceMoveType) {
|
|
819
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["MoveRange"] = 0] = "MoveRange";
|
|
820
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["MoveRows"] = 1] = "MoveRows";
|
|
821
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["MoveCols"] = 2] = "MoveCols";
|
|
822
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertRow"] = 3] = "InsertRow";
|
|
823
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertColumn"] = 4] = "InsertColumn";
|
|
824
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveRow"] = 5] = "RemoveRow";
|
|
825
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveColumn"] = 6] = "RemoveColumn";
|
|
826
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["DeleteMoveLeft"] = 7] = "DeleteMoveLeft";
|
|
827
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["DeleteMoveUp"] = 8] = "DeleteMoveUp";
|
|
828
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertMoveDown"] = 9] = "InsertMoveDown";
|
|
829
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["InsertMoveRight"] = 10] = "InsertMoveRight";
|
|
830
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["SetName"] = 11] = "SetName";
|
|
831
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveSheet"] = 12] = "RemoveSheet";
|
|
832
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["SetDefinedName"] = 13] = "SetDefinedName";
|
|
833
|
-
FormulaReferenceMoveType[FormulaReferenceMoveType["RemoveDefinedName"] = 14] = "RemoveDefinedName";
|
|
834
|
-
return FormulaReferenceMoveType;
|
|
835
|
-
}({});
|
|
836
818
|
const formulaReferenceSheetList = [
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
819
|
+
11,
|
|
820
|
+
12,
|
|
821
|
+
13,
|
|
822
|
+
14
|
|
841
823
|
];
|
|
842
824
|
function getFormulaReferenceMoveUndoRedo(oldFormulaData, newFormulaData, formulaReferenceMoveParam) {
|
|
843
825
|
const { type } = formulaReferenceMoveParam;
|
|
@@ -987,9 +969,9 @@ function processFormulaChanges(oldFormulaMatrix, newFormulaMatrix, formulaRefere
|
|
|
987
969
|
let newCell = null;
|
|
988
970
|
let isReverse = false;
|
|
989
971
|
if ([
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
972
|
+
0,
|
|
973
|
+
1,
|
|
974
|
+
2
|
|
993
975
|
].includes(type)) newCell = handleMove(type, from, to, oldCell);
|
|
994
976
|
else if (range !== void 0 && range !== null) {
|
|
995
977
|
const result = handleInsertDelete(oldCell, formulaReferenceMoveParam);
|
|
@@ -1022,9 +1004,9 @@ function processFormulaRange(newFormulaMatrix) {
|
|
|
1022
1004
|
function handleMove(type, from, to, oldCell) {
|
|
1023
1005
|
if (from == null || to == null) return null;
|
|
1024
1006
|
switch (type) {
|
|
1025
|
-
case
|
|
1026
|
-
case
|
|
1027
|
-
case
|
|
1007
|
+
case 0: return handleRefMoveRange$1(from, to, oldCell);
|
|
1008
|
+
case 1: return handleRefMoveRows$1(from, to, oldCell);
|
|
1009
|
+
case 2: return handleRefMoveCols$1(from, to, oldCell);
|
|
1028
1010
|
default: return null;
|
|
1029
1011
|
}
|
|
1030
1012
|
}
|
|
@@ -1034,31 +1016,31 @@ function handleInsertDelete(oldCell, formulaReferenceMoveParam) {
|
|
|
1034
1016
|
let newCell = null;
|
|
1035
1017
|
let isReverse = false;
|
|
1036
1018
|
switch (type) {
|
|
1037
|
-
case
|
|
1019
|
+
case 3:
|
|
1038
1020
|
newCell = handleRefInsertRow$1(range, oldCell);
|
|
1039
1021
|
isReverse = true;
|
|
1040
1022
|
break;
|
|
1041
|
-
case
|
|
1023
|
+
case 4:
|
|
1042
1024
|
newCell = handleRefInsertCol$1(range, oldCell);
|
|
1043
1025
|
isReverse = true;
|
|
1044
1026
|
break;
|
|
1045
|
-
case
|
|
1027
|
+
case 5:
|
|
1046
1028
|
newCell = handleRefRemoveRow$1(range, oldCell, rangeFilteredRows);
|
|
1047
1029
|
break;
|
|
1048
|
-
case
|
|
1030
|
+
case 6:
|
|
1049
1031
|
newCell = handleRefRemoveCol$1(range, oldCell);
|
|
1050
1032
|
break;
|
|
1051
|
-
case
|
|
1033
|
+
case 7:
|
|
1052
1034
|
newCell = handleRefDeleteMoveLeft(range, oldCell);
|
|
1053
1035
|
break;
|
|
1054
|
-
case
|
|
1036
|
+
case 8:
|
|
1055
1037
|
newCell = handleRefDeleteMoveUp(range, oldCell);
|
|
1056
1038
|
break;
|
|
1057
|
-
case
|
|
1039
|
+
case 9:
|
|
1058
1040
|
newCell = handleRefInsertMoveDown(range, oldCell);
|
|
1059
1041
|
isReverse = true;
|
|
1060
1042
|
break;
|
|
1061
|
-
case
|
|
1043
|
+
case 10:
|
|
1062
1044
|
newCell = handleRefInsertMoveRight(range, oldCell);
|
|
1063
1045
|
isReverse = true;
|
|
1064
1046
|
break;
|
|
@@ -1294,14 +1276,6 @@ function updateRefOffset(sequenceNodes, refChangeIds, refOffsetX = 0, refOffsetY
|
|
|
1294
1276
|
|
|
1295
1277
|
//#endregion
|
|
1296
1278
|
//#region src/controllers/utils/ref-range-move.ts
|
|
1297
|
-
let OriginRangeEdgeType = /* @__PURE__ */ function(OriginRangeEdgeType) {
|
|
1298
|
-
OriginRangeEdgeType[OriginRangeEdgeType["UP"] = 0] = "UP";
|
|
1299
|
-
OriginRangeEdgeType[OriginRangeEdgeType["DOWN"] = 1] = "DOWN";
|
|
1300
|
-
OriginRangeEdgeType[OriginRangeEdgeType["LEFT"] = 2] = "LEFT";
|
|
1301
|
-
OriginRangeEdgeType[OriginRangeEdgeType["RIGHT"] = 3] = "RIGHT";
|
|
1302
|
-
OriginRangeEdgeType[OriginRangeEdgeType["ALL"] = 4] = "ALL";
|
|
1303
|
-
return OriginRangeEdgeType;
|
|
1304
|
-
}({});
|
|
1305
1279
|
function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam, currentFormulaUnitId, currentFormulaSheetId, options = {}) {
|
|
1306
1280
|
const { type, unitId: userUnitId, sheetId: userSheetId, targetUnitId, targetSheetId, targetSheetName, range, from, to, rangeFilteredRows } = formulaReferenceMoveParam;
|
|
1307
1281
|
const { range: unitRange, sheetId: sequenceRangeSheetId, unitId: sequenceRangeUnitId, sheetName: sequenceRangeSheetName, refOffsetX, refOffsetY } = unitRangeWidthOffset;
|
|
@@ -1309,11 +1283,11 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1309
1283
|
if (!checkIsSameUnitAndSheet(userUnitId, userSheetId, currentFormulaUnitId, currentFormulaSheetId, sequenceRangeUnitId, sequenceRangeSheetId)) return;
|
|
1310
1284
|
const sequenceRange = Rectangle.moveOffset(unitRange, refOffsetX, refOffsetY);
|
|
1311
1285
|
let newRange = null;
|
|
1312
|
-
if (type ===
|
|
1286
|
+
if (type === 0) {
|
|
1313
1287
|
if (from == null || to == null) return;
|
|
1314
1288
|
const moveEdge = checkMoveEdge(sequenceRange, from);
|
|
1315
1289
|
const remainRange = getIntersectRange(sequenceRange, from);
|
|
1316
|
-
if (remainRange == null || moveEdge !==
|
|
1290
|
+
if (remainRange == null || moveEdge !== 4) return;
|
|
1317
1291
|
const result = runRefRangeMutations(handleMoveRange({
|
|
1318
1292
|
id: EffectRefRangId.MoveRangeCommandId,
|
|
1319
1293
|
params: {
|
|
@@ -1323,7 +1297,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1323
1297
|
}, remainRange), remainRange);
|
|
1324
1298
|
if (result == null) return ErrorType.REF;
|
|
1325
1299
|
newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
|
|
1326
|
-
} else if (type ===
|
|
1300
|
+
} else if (type === 1) {
|
|
1327
1301
|
if (from == null || to == null) return;
|
|
1328
1302
|
const moveEdge = checkMoveEdge(sequenceRange, from);
|
|
1329
1303
|
let remainRange = getIntersectRange(sequenceRange, from);
|
|
@@ -1344,7 +1318,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1344
1318
|
}, remainRange), remainRange);
|
|
1345
1319
|
if (result == null) return ErrorType.REF;
|
|
1346
1320
|
newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
|
|
1347
|
-
} else if (type ===
|
|
1321
|
+
} else if (type === 2) {
|
|
1348
1322
|
if (from == null || to == null) return;
|
|
1349
1323
|
const moveEdge = checkMoveEdge(sequenceRange, from);
|
|
1350
1324
|
let remainRange = getIntersectRange(sequenceRange, from);
|
|
@@ -1367,7 +1341,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1367
1341
|
newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
|
|
1368
1342
|
}
|
|
1369
1343
|
if (range != null) {
|
|
1370
|
-
if (type ===
|
|
1344
|
+
if (type === 3) {
|
|
1371
1345
|
const result = runRefRangeMutations(handleInsertRow({
|
|
1372
1346
|
id: EffectRefRangId.InsertRowCommandId,
|
|
1373
1347
|
params: {
|
|
@@ -1382,7 +1356,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1382
1356
|
...sequenceRange,
|
|
1383
1357
|
...result
|
|
1384
1358
|
};
|
|
1385
|
-
} else if (type ===
|
|
1359
|
+
} else if (type === 4) {
|
|
1386
1360
|
const result = runRefRangeMutations(handleInsertCol({
|
|
1387
1361
|
id: EffectRefRangId.InsertColCommandId,
|
|
1388
1362
|
params: {
|
|
@@ -1397,7 +1371,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1397
1371
|
...sequenceRange,
|
|
1398
1372
|
...result
|
|
1399
1373
|
};
|
|
1400
|
-
} else if (type ===
|
|
1374
|
+
} else if (type === 5) {
|
|
1401
1375
|
const result = runRefRangeMutations(handleIRemoveRow({
|
|
1402
1376
|
id: EffectRefRangId.RemoveRowCommandId,
|
|
1403
1377
|
params: { range }
|
|
@@ -1407,7 +1381,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1407
1381
|
...sequenceRange,
|
|
1408
1382
|
...result
|
|
1409
1383
|
};
|
|
1410
|
-
} else if (type ===
|
|
1384
|
+
} else if (type === 6) {
|
|
1411
1385
|
const result = runRefRangeMutations(handleIRemoveCol({
|
|
1412
1386
|
id: EffectRefRangId.RemoveColCommandId,
|
|
1413
1387
|
params: { range }
|
|
@@ -1417,7 +1391,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1417
1391
|
...sequenceRange,
|
|
1418
1392
|
...result
|
|
1419
1393
|
};
|
|
1420
|
-
} else if (type ===
|
|
1394
|
+
} else if (type === 7) {
|
|
1421
1395
|
const result = runRefRangeMutations(handleDeleteRangeMoveLeft({
|
|
1422
1396
|
id: EffectRefRangId.DeleteRangeMoveLeftCommandId,
|
|
1423
1397
|
params: { range }
|
|
@@ -1427,7 +1401,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1427
1401
|
...sequenceRange,
|
|
1428
1402
|
...result
|
|
1429
1403
|
};
|
|
1430
|
-
} else if (type ===
|
|
1404
|
+
} else if (type === 8) {
|
|
1431
1405
|
const result = runRefRangeMutations(handleDeleteRangeMoveUp({
|
|
1432
1406
|
id: EffectRefRangId.DeleteRangeMoveUpCommandId,
|
|
1433
1407
|
params: { range }
|
|
@@ -1437,7 +1411,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1437
1411
|
...sequenceRange,
|
|
1438
1412
|
...result
|
|
1439
1413
|
};
|
|
1440
|
-
} else if (type ===
|
|
1414
|
+
} else if (type === 9) {
|
|
1441
1415
|
const result = runRefRangeMutations(handleInsertRangeMoveDown({
|
|
1442
1416
|
id: EffectRefRangId.InsertRangeMoveDownCommandId,
|
|
1443
1417
|
params: { range }
|
|
@@ -1447,7 +1421,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1447
1421
|
...sequenceRange,
|
|
1448
1422
|
...result
|
|
1449
1423
|
};
|
|
1450
|
-
} else if (type ===
|
|
1424
|
+
} else if (type === 10) {
|
|
1451
1425
|
const result = runRefRangeMutations(handleInsertRangeMoveRight({
|
|
1452
1426
|
id: EffectRefRangId.InsertRangeMoveRightCommandId,
|
|
1453
1427
|
params: { range }
|
|
@@ -1460,7 +1434,7 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
|
|
|
1460
1434
|
}
|
|
1461
1435
|
}
|
|
1462
1436
|
if (newRange == null) return;
|
|
1463
|
-
const shouldRewriteSheet = type ===
|
|
1437
|
+
const shouldRewriteSheet = type === 0 && !!targetSheetId && targetSheetId !== userSheetId && !inCrossSheetCutRange;
|
|
1464
1438
|
const rewrittenSheetId = shouldRewriteSheet ? targetSheetId : sequenceRangeSheetId;
|
|
1465
1439
|
const rewrittenSheetName = shouldRewriteSheet ? targetSheetName || sequenceRangeSheetName : sequenceRangeSheetName;
|
|
1466
1440
|
const rewrittenUnitId = shouldRewriteSheet ? targetUnitId || sequenceRangeUnitId : sequenceRangeUnitId;
|
|
@@ -1496,23 +1470,23 @@ function getMoveNewRange(moveEdge, result, from, to, origin, remain) {
|
|
|
1496
1470
|
if (rangeType === RANGE_TYPE.ROW && originRangeType === RANGE_TYPE.ROW) return true;
|
|
1497
1471
|
return startRow >= originStartRow && endRow <= originEndRow;
|
|
1498
1472
|
}
|
|
1499
|
-
if (moveEdge ===
|
|
1473
|
+
if (moveEdge === 0) if (rowsCover()) if (startRow < originStartRow) newRange.startRow = startRow;
|
|
1500
1474
|
else if (startRow >= originEndRow) newRange.endRow -= fromEndRow + 1 - originStartRow;
|
|
1501
1475
|
else return;
|
|
1502
1476
|
else return;
|
|
1503
|
-
else if (moveEdge ===
|
|
1477
|
+
else if (moveEdge === 1) if (rowsCover()) if (endRow > originEndRow) newRange.endRow = endRow;
|
|
1504
1478
|
else if (endRow <= originStartRow) newRange.startRow += originEndRow - fromStartRow + 1;
|
|
1505
1479
|
else return;
|
|
1506
1480
|
else return;
|
|
1507
|
-
else if (moveEdge ===
|
|
1481
|
+
else if (moveEdge === 2) if (columnsCover()) if (startColumn < originStartColumn) newRange.startColumn = startColumn;
|
|
1508
1482
|
else if (startColumn >= originEndColumn) newRange.endColumn -= fromEndColumn + 1 - originStartColumn;
|
|
1509
1483
|
else return;
|
|
1510
1484
|
else return;
|
|
1511
|
-
else if (moveEdge ===
|
|
1485
|
+
else if (moveEdge === 3) if (columnsCover()) if (endColumn > originEndColumn) newRange.endColumn = endColumn;
|
|
1512
1486
|
else if (endColumn <= originStartColumn) newRange.startColumn += originEndColumn - fromStartColumn + 1;
|
|
1513
1487
|
else return;
|
|
1514
1488
|
else return;
|
|
1515
|
-
else if (moveEdge ===
|
|
1489
|
+
else if (moveEdge === 4) {
|
|
1516
1490
|
newRange.startRow = startRow;
|
|
1517
1491
|
newRange.startColumn = startColumn;
|
|
1518
1492
|
newRange.endRow = endRow;
|
|
@@ -1583,11 +1557,11 @@ function checkMoveEdge(originRange, fromRange) {
|
|
|
1583
1557
|
function allCover() {
|
|
1584
1558
|
return originRange.rangeType === RANGE_TYPE.ALL && fromRange.rangeType === RANGE_TYPE.ALL;
|
|
1585
1559
|
}
|
|
1586
|
-
if (rowsCover() && columnsCover() || allCover()) return
|
|
1587
|
-
if (columnsCover() && startRow >= fromStartRow && startRow <= fromEndRow && endRow > fromEndRow) return
|
|
1588
|
-
if (columnsCover() && endRow >= fromStartRow && endRow <= fromEndRow && startRow < fromStartRow) return
|
|
1589
|
-
if (rowsCover() && startColumn >= fromStartColumn && startColumn <= fromEndColumn && endColumn > fromEndColumn) return
|
|
1590
|
-
if (rowsCover() && endColumn >= fromStartColumn && endColumn <= fromEndColumn && startColumn < fromStartColumn) return
|
|
1560
|
+
if (rowsCover() && columnsCover() || allCover()) return 4;
|
|
1561
|
+
if (columnsCover() && startRow >= fromStartRow && startRow <= fromEndRow && endRow > fromEndRow) return 0;
|
|
1562
|
+
if (columnsCover() && endRow >= fromStartRow && endRow <= fromEndRow && startRow < fromStartRow) return 1;
|
|
1563
|
+
if (rowsCover() && startColumn >= fromStartColumn && startColumn <= fromEndColumn && endColumn > fromEndColumn) return 2;
|
|
1564
|
+
if (rowsCover() && endColumn >= fromStartColumn && endColumn <= fromEndColumn && startColumn < fromStartColumn) return 3;
|
|
1591
1565
|
return null;
|
|
1592
1566
|
}
|
|
1593
1567
|
function getStartValue(value) {
|
|
@@ -1682,7 +1656,7 @@ function handleRefMoveRange(command, workbook) {
|
|
|
1682
1656
|
const targetUnitId = toUnitId || fromUnitId || currentUnitId;
|
|
1683
1657
|
const targetSheetName = (_workbook$getSheetByS2 = workbook.getSheetBySheetId(targetSheetId)) === null || _workbook$getSheetByS2 === void 0 ? void 0 : _workbook$getSheetByS2.getName();
|
|
1684
1658
|
return {
|
|
1685
|
-
type:
|
|
1659
|
+
type: 0,
|
|
1686
1660
|
from: fromRange,
|
|
1687
1661
|
to: toRange,
|
|
1688
1662
|
unitId,
|
|
@@ -1716,7 +1690,7 @@ function handleRefMoveRows(command, workbook) {
|
|
|
1716
1690
|
rangeType: RANGE_TYPE.ROW
|
|
1717
1691
|
};
|
|
1718
1692
|
return {
|
|
1719
|
-
type:
|
|
1693
|
+
type: 1,
|
|
1720
1694
|
from,
|
|
1721
1695
|
to,
|
|
1722
1696
|
unitId,
|
|
@@ -1746,7 +1720,7 @@ function handleRefMoveCols(command, workbook) {
|
|
|
1746
1720
|
rangeType: RANGE_TYPE.COLUMN
|
|
1747
1721
|
};
|
|
1748
1722
|
return {
|
|
1749
|
-
type:
|
|
1723
|
+
type: 2,
|
|
1750
1724
|
from,
|
|
1751
1725
|
to,
|
|
1752
1726
|
unitId,
|
|
@@ -1758,7 +1732,7 @@ function handleRefInsertRow(command) {
|
|
|
1758
1732
|
if (!params) return null;
|
|
1759
1733
|
const { range, unitId, subUnitId } = params;
|
|
1760
1734
|
return {
|
|
1761
|
-
type:
|
|
1735
|
+
type: 3,
|
|
1762
1736
|
range,
|
|
1763
1737
|
unitId,
|
|
1764
1738
|
sheetId: subUnitId
|
|
@@ -1769,7 +1743,7 @@ function handleRefInsertCol(command) {
|
|
|
1769
1743
|
if (!params) return null;
|
|
1770
1744
|
const { range, unitId, subUnitId } = params;
|
|
1771
1745
|
return {
|
|
1772
|
-
type:
|
|
1746
|
+
type: 4,
|
|
1773
1747
|
range,
|
|
1774
1748
|
unitId,
|
|
1775
1749
|
sheetId: subUnitId
|
|
@@ -1781,7 +1755,7 @@ function handleRefInsertRangeMoveRight(command, workbook) {
|
|
|
1781
1755
|
const { range } = params;
|
|
1782
1756
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1783
1757
|
return {
|
|
1784
|
-
type:
|
|
1758
|
+
type: 10,
|
|
1785
1759
|
range,
|
|
1786
1760
|
unitId,
|
|
1787
1761
|
sheetId
|
|
@@ -1793,7 +1767,7 @@ function handleRefInsertRangeMoveDown(command, workbook) {
|
|
|
1793
1767
|
const { range } = params;
|
|
1794
1768
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1795
1769
|
return {
|
|
1796
|
-
type:
|
|
1770
|
+
type: 9,
|
|
1797
1771
|
range,
|
|
1798
1772
|
unitId,
|
|
1799
1773
|
sheetId
|
|
@@ -1806,7 +1780,7 @@ function handleRefRemoveRow(command, workbook) {
|
|
|
1806
1780
|
const { range } = params;
|
|
1807
1781
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1808
1782
|
return {
|
|
1809
|
-
type:
|
|
1783
|
+
type: 5,
|
|
1810
1784
|
range,
|
|
1811
1785
|
unitId,
|
|
1812
1786
|
sheetId,
|
|
@@ -1819,7 +1793,7 @@ function handleRefRemoveCol(command, workbook) {
|
|
|
1819
1793
|
const { range } = params;
|
|
1820
1794
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1821
1795
|
return {
|
|
1822
|
-
type:
|
|
1796
|
+
type: 6,
|
|
1823
1797
|
range,
|
|
1824
1798
|
unitId,
|
|
1825
1799
|
sheetId
|
|
@@ -1831,7 +1805,7 @@ function handleRefDeleteRangeMoveUp(command, workbook) {
|
|
|
1831
1805
|
const { range } = params;
|
|
1832
1806
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1833
1807
|
return {
|
|
1834
|
-
type:
|
|
1808
|
+
type: 8,
|
|
1835
1809
|
range,
|
|
1836
1810
|
unitId,
|
|
1837
1811
|
sheetId
|
|
@@ -1843,7 +1817,7 @@ function handleRefDeleteRangeMoveLeft(command, workbook) {
|
|
|
1843
1817
|
const { range } = params;
|
|
1844
1818
|
const { unitId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1845
1819
|
return {
|
|
1846
|
-
type:
|
|
1820
|
+
type: 7,
|
|
1847
1821
|
range,
|
|
1848
1822
|
unitId,
|
|
1849
1823
|
sheetId
|
|
@@ -1855,7 +1829,7 @@ function handleRefSetWorksheetName(command, workbook) {
|
|
|
1855
1829
|
const { unitId, subUnitId, name } = params;
|
|
1856
1830
|
const { unitId: workbookId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1857
1831
|
return {
|
|
1858
|
-
type:
|
|
1832
|
+
type: 11,
|
|
1859
1833
|
unitId: unitId || workbookId,
|
|
1860
1834
|
sheetId: subUnitId || sheetId,
|
|
1861
1835
|
sheetName: name
|
|
@@ -1867,7 +1841,7 @@ function handleRefRemoveWorksheet(command, workbook) {
|
|
|
1867
1841
|
const { unitId, subUnitId } = params;
|
|
1868
1842
|
const { unitId: workbookId, sheetId } = getCurrentSheetInfo(workbook);
|
|
1869
1843
|
return {
|
|
1870
|
-
type:
|
|
1844
|
+
type: 12,
|
|
1871
1845
|
unitId: unitId || workbookId,
|
|
1872
1846
|
sheetId: subUnitId || sheetId
|
|
1873
1847
|
};
|
|
@@ -1878,7 +1852,7 @@ function handleRefSetDefinedName(command, workbook) {
|
|
|
1878
1852
|
const { unitId, name, id } = params;
|
|
1879
1853
|
const { sheetId } = getCurrentSheetInfo(workbook);
|
|
1880
1854
|
return {
|
|
1881
|
-
type:
|
|
1855
|
+
type: 13,
|
|
1882
1856
|
unitId,
|
|
1883
1857
|
sheetId,
|
|
1884
1858
|
definedName: name,
|
|
@@ -1891,7 +1865,7 @@ function handleRefRemoveDefinedName(command, workbook) {
|
|
|
1891
1865
|
const { unitId, name, id } = params;
|
|
1892
1866
|
const { sheetId } = getCurrentSheetInfo(workbook);
|
|
1893
1867
|
return {
|
|
1894
|
-
type:
|
|
1868
|
+
type: 14,
|
|
1895
1869
|
unitId,
|
|
1896
1870
|
sheetId,
|
|
1897
1871
|
definedName: name,
|
|
@@ -1963,8 +1937,8 @@ let UpdateDefinedNameController = class UpdateDefinedNameController extends Disp
|
|
|
1963
1937
|
refOffsetY: 0
|
|
1964
1938
|
};
|
|
1965
1939
|
let newRefString = null;
|
|
1966
|
-
if (type ===
|
|
1967
|
-
else if (type ===
|
|
1940
|
+
if (type === 12) newRefString = this._removeSheet(item, unitId, sheetId);
|
|
1941
|
+
else if (type === 11) {
|
|
1968
1942
|
const { sheetId: userSheetId, sheetName: newSheetName } = moveParams;
|
|
1969
1943
|
if (newSheetName == null) continue;
|
|
1970
1944
|
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
@@ -2116,14 +2090,14 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2116
2090
|
});
|
|
2117
2091
|
this._commandService.executeCommand(SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
|
|
2118
2092
|
const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
|
|
2119
|
-
const calculationMode = (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul :
|
|
2093
|
+
const calculationMode = (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul : 1;
|
|
2120
2094
|
const params = this._getDirtyDataByCalculationMode(calculationMode);
|
|
2121
2095
|
this._commandService.executeCommand(SetTriggerFormulaCalculationStartMutation.id, params, { onlyLocal: true });
|
|
2122
2096
|
}
|
|
2123
2097
|
_getDirtyDataByCalculationMode(calculationMode) {
|
|
2124
2098
|
return {
|
|
2125
|
-
forceCalculation: calculationMode ===
|
|
2126
|
-
dirtyRanges: calculationMode ===
|
|
2099
|
+
forceCalculation: calculationMode === 0,
|
|
2100
|
+
dirtyRanges: calculationMode === 1 ? this._formulaDataModel.getFormulaDirtyRanges() : [],
|
|
2127
2101
|
dirtyNameMap: {},
|
|
2128
2102
|
dirtyDefinedNameMap: {},
|
|
2129
2103
|
dirtyUnitFeatureMap: {},
|
|
@@ -2176,14 +2150,14 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2176
2150
|
if (sequenceNodes == null) return true;
|
|
2177
2151
|
let shouldModify = false;
|
|
2178
2152
|
const refChangeIds = [];
|
|
2179
|
-
const inCrossSheetCutRange = type ===
|
|
2153
|
+
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;
|
|
2180
2154
|
const inCrossSheetCutRangeSequenceNodes = [...sequenceNodes];
|
|
2181
2155
|
for (let i = 0, len = sequenceNodes.length; i < len; i++) {
|
|
2182
2156
|
var _unitSheetNameMap$map;
|
|
2183
2157
|
const node = sequenceNodes[i];
|
|
2184
2158
|
if (typeof node === "string") continue;
|
|
2185
2159
|
const { token, nodeType } = node;
|
|
2186
|
-
if ((type ===
|
|
2160
|
+
if ((type === 13 || type === 14) && (nodeType === sequenceNodeType.DEFINED_NAME || nodeType === sequenceNodeType.FUNCTION)) {
|
|
2187
2161
|
const { definedNameId, definedName } = formulaReferenceMoveParam;
|
|
2188
2162
|
if (definedNameId === void 0 || definedName === void 0) continue;
|
|
2189
2163
|
const oldDefinedName = this._definedNamesService.getValueById(unitId, definedNameId);
|
|
@@ -2191,7 +2165,7 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2191
2165
|
if (oldDefinedName.name !== token) continue;
|
|
2192
2166
|
sequenceNodes[i] = {
|
|
2193
2167
|
...node,
|
|
2194
|
-
token: type ===
|
|
2168
|
+
token: type === 13 ? definedName : ErrorType.REF
|
|
2195
2169
|
};
|
|
2196
2170
|
shouldModify = true;
|
|
2197
2171
|
refChangeIds.push(i);
|
|
@@ -2210,7 +2184,7 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2210
2184
|
refOffsetY: y || 0
|
|
2211
2185
|
};
|
|
2212
2186
|
let newRefString = null;
|
|
2213
|
-
if (type ===
|
|
2187
|
+
if (type === 11) {
|
|
2214
2188
|
const { unitId: userUnitId, sheetId: userSheetId, sheetName: newSheetName } = formulaReferenceMoveParam;
|
|
2215
2189
|
if (newSheetName == null) continue;
|
|
2216
2190
|
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
@@ -2220,12 +2194,12 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2220
2194
|
sheetName: newSheetName,
|
|
2221
2195
|
unitId: sequenceUnitId
|
|
2222
2196
|
});
|
|
2223
|
-
} else if (type ===
|
|
2197
|
+
} else if (type === 12) {
|
|
2224
2198
|
const { unitId: userUnitId, sheetId: userSheetId, sheetName: newSheetName } = formulaReferenceMoveParam;
|
|
2225
2199
|
if (sequenceSheetId == null || sequenceSheetId.length === 0) continue;
|
|
2226
2200
|
if (userSheetId !== sequenceSheetId) continue;
|
|
2227
2201
|
newRefString = ErrorType.REF;
|
|
2228
|
-
} else if (type !==
|
|
2202
|
+
} else if (type !== 13) newRefString = getNewRangeByMoveParam(sequenceUnitRangeWidthOffset, formulaReferenceMoveParam, unitId, sheetId, { inCrossSheetCutRange });
|
|
2229
2203
|
if (newRefString != null) {
|
|
2230
2204
|
sequenceNodes[i] = {
|
|
2231
2205
|
...node,
|
|
@@ -2269,9 +2243,9 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2269
2243
|
* This is to ensure that the si formula can be recalculated correctly after the move.
|
|
2270
2244
|
*/
|
|
2271
2245
|
if (si && [
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2246
|
+
1,
|
|
2247
|
+
2,
|
|
2248
|
+
0
|
|
2275
2249
|
].includes(type)) {
|
|
2276
2250
|
if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
|
|
2277
2251
|
if ((x !== null && x !== void 0 ? x : 0) === 0 && (y !== null && y !== void 0 ? y : 0) === 0) shouldModifySi.push(si);
|
|
@@ -2321,7 +2295,7 @@ UpdateFormulaController = __decorate([
|
|
|
2321
2295
|
//#endregion
|
|
2322
2296
|
//#region package.json
|
|
2323
2297
|
var name = "@univerjs/sheets-formula";
|
|
2324
|
-
var version = "0.
|
|
2298
|
+
var version = "0.22.0";
|
|
2325
2299
|
|
|
2326
2300
|
//#endregion
|
|
2327
2301
|
//#region src/common/plugin-name.ts
|