@univerjs/sheets 1.0.2 → 1.0.4
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/index.js +45 -16
- package/lib/es/index.js +46 -17
- package/lib/index.js +46 -17
- package/lib/types/commands/commands/copy-worksheet.command.d.ts +1 -0
- package/lib/types/commands/commands/set-style.command.d.ts +2 -2
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +3 -1
- package/lib/types/controllers/calculate-result-apply.controller.d.ts +1 -0
- package/lib/umd/index.js +2 -2
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -1649,7 +1649,7 @@ const MoveRangeMutation = {
|
|
|
1649
1649
|
handler: (accessor, params) => {
|
|
1650
1650
|
const { from, to } = params;
|
|
1651
1651
|
if (!from || !to) return false;
|
|
1652
|
-
const workbook = accessor.get(_univerjs_core.IUniverInstanceService).
|
|
1652
|
+
const workbook = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(params.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
1653
1653
|
if (!workbook) return false;
|
|
1654
1654
|
const fromWorksheet = workbook.getSheetBySheetId(params.from.subUnitId);
|
|
1655
1655
|
const toWorksheet = workbook.getSheetBySheetId(params.to.subUnitId);
|
|
@@ -2320,7 +2320,9 @@ function prepareSetRangeValuesMutation(cells, styles, params) {
|
|
|
2320
2320
|
const before = new _univerjs_core.ObjectMatrix();
|
|
2321
2321
|
const after = new _univerjs_core.ObjectMatrix();
|
|
2322
2322
|
new _univerjs_core.ObjectMatrix(_univerjs_core.Tools.deepClone(params.cellValue)).forValue((row, column, value) => {
|
|
2323
|
+
var _params$sourceFormula;
|
|
2323
2324
|
const original = _univerjs_core.Tools.deepClone(cells.getValue(row, column) ?? null);
|
|
2325
|
+
if (isStaleFormulaResult(original, (_params$sourceFormula = params.sourceFormulaData) === null || _params$sourceFormula === void 0 || (_params$sourceFormula = _params$sourceFormula[row]) === null || _params$sourceFormula === void 0 ? void 0 : _params$sourceFormula[column])) return;
|
|
2324
2326
|
before.setValue(row, column, original);
|
|
2325
2327
|
const next = value ? mergeCellData(value, _univerjs_core.Tools.deepClone(original ?? {}), detachedStyles, !!params.isOverrideStyle) : null;
|
|
2326
2328
|
after.setValue(row, column, next && !_univerjs_core.Tools.isEmptyObject(next) ? next : null);
|
|
@@ -2370,7 +2372,7 @@ const SetRangeValuesMutation = {
|
|
|
2370
2372
|
id: "sheet.mutation.set-range-values",
|
|
2371
2373
|
type: _univerjs_core.CommandType.MUTATION,
|
|
2372
2374
|
handler: (accessor, params) => {
|
|
2373
|
-
const { cellValue, subUnitId, unitId, isOverrideStyle } = params;
|
|
2375
|
+
const { cellValue, subUnitId, unitId, isOverrideStyle, sourceFormulaData } = params;
|
|
2374
2376
|
const workbook = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId);
|
|
2375
2377
|
if (!workbook) return false;
|
|
2376
2378
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
@@ -2378,6 +2380,8 @@ const SetRangeValuesMutation = {
|
|
|
2378
2380
|
const cellMatrix = worksheet.getCellMatrix();
|
|
2379
2381
|
const styles = workbook.getStyles();
|
|
2380
2382
|
new _univerjs_core.ObjectMatrix(cellValue).forValue((row, col, newVal) => {
|
|
2383
|
+
var _sourceFormulaData$ro;
|
|
2384
|
+
if (isStaleFormulaResult(cellMatrix.getValue(row, col), sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$ro = sourceFormulaData[row]) === null || _sourceFormulaData$ro === void 0 ? void 0 : _sourceFormulaData$ro[col])) return;
|
|
2381
2385
|
if (!newVal) cellMatrix.realDeleteValue(row, col);
|
|
2382
2386
|
else {
|
|
2383
2387
|
let oldVal = cellMatrix.getValue(row, col) || {};
|
|
@@ -2389,6 +2393,9 @@ const SetRangeValuesMutation = {
|
|
|
2389
2393
|
return true;
|
|
2390
2394
|
}
|
|
2391
2395
|
};
|
|
2396
|
+
function isStaleFormulaResult(cell, source) {
|
|
2397
|
+
return source != null && (source.f !== ((cell === null || cell === void 0 ? void 0 : cell.f) ?? "") || source.si !== ((cell === null || cell === void 0 ? void 0 : cell.si) ?? void 0));
|
|
2398
|
+
}
|
|
2392
2399
|
const overwriteCellPropertiesSet = /* @__PURE__ */ new Set([
|
|
2393
2400
|
"f",
|
|
2394
2401
|
"p",
|
|
@@ -10349,6 +10356,27 @@ const AFFECT_LAYOUT_STYLES = [
|
|
|
10349
10356
|
"tr",
|
|
10350
10357
|
"tb"
|
|
10351
10358
|
];
|
|
10359
|
+
function createStyleCellValue(worksheet, ranges, style) {
|
|
10360
|
+
const cellValue = new _univerjs_core.ObjectMatrix();
|
|
10361
|
+
const iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
10362
|
+
if (_univerjs_core.Tools.isArray(style.value)) for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c, range) => {
|
|
10363
|
+
cellValue.setValue(r, c, { s: { [style.type]: style.value[r - range.startRow][c - range.startColumn] } });
|
|
10364
|
+
});
|
|
10365
|
+
else {
|
|
10366
|
+
const styleObj = { s: { [style.type]: style.value } };
|
|
10367
|
+
for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c) => cellValue.setValue(r, c, styleObj));
|
|
10368
|
+
}
|
|
10369
|
+
if (style.type === "tb" || style.type === "stf") cellValue.forValue((row, column, cell) => {
|
|
10370
|
+
var _worksheet$getCompose;
|
|
10371
|
+
const cellStyle = cell.s;
|
|
10372
|
+
if (cellStyle.tb === _univerjs_core.WrapStrategy.WRAP) cellStyle.stf = _univerjs_core.BooleanNumber.FALSE;
|
|
10373
|
+
else if (cellStyle.stf === _univerjs_core.BooleanNumber.TRUE && ((_worksheet$getCompose = worksheet.getComposedCellStyle(row, column)) === null || _worksheet$getCompose === void 0 ? void 0 : _worksheet$getCompose.tb) === _univerjs_core.WrapStrategy.WRAP) cellValue.setValue(row, column, { s: {
|
|
10374
|
+
...cellStyle,
|
|
10375
|
+
tb: _univerjs_core.WrapStrategy.UNSPECIFIED
|
|
10376
|
+
} });
|
|
10377
|
+
});
|
|
10378
|
+
return cellValue;
|
|
10379
|
+
}
|
|
10352
10380
|
/**
|
|
10353
10381
|
* The command to set cell style.
|
|
10354
10382
|
* Set style to a bunch of ranges.
|
|
@@ -10368,19 +10396,10 @@ const SetStyleCommand = {
|
|
|
10368
10396
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
10369
10397
|
const ranges = range ? [range] : (_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range);
|
|
10370
10398
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return false;
|
|
10371
|
-
const cellValue = new _univerjs_core.ObjectMatrix();
|
|
10372
|
-
const iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
10373
|
-
if (_univerjs_core.Tools.isArray(style.value)) for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c, range) => {
|
|
10374
|
-
cellValue.setValue(r, c, { s: { [style.type]: style.value[r - range.startRow][c - range.startColumn] } });
|
|
10375
|
-
});
|
|
10376
|
-
else for (let i = 0; i < ranges.length; i++) {
|
|
10377
|
-
const styleObj = { s: { [style.type]: style.value } };
|
|
10378
|
-
iterator.forOperableEach(ranges[i], (r, c) => cellValue.setValue(r, c, styleObj));
|
|
10379
|
-
}
|
|
10380
10399
|
const setRangeValuesMutationParams = {
|
|
10381
10400
|
subUnitId,
|
|
10382
10401
|
unitId,
|
|
10383
|
-
cellValue:
|
|
10402
|
+
cellValue: createStyleCellValue(worksheet, ranges, style).getMatrix()
|
|
10384
10403
|
};
|
|
10385
10404
|
const skeleton = accessor.get(SheetSkeletonService).getSkeleton(unitId, subUnitId);
|
|
10386
10405
|
const undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams);
|
|
@@ -12724,6 +12743,7 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
|
|
|
12724
12743
|
unitId,
|
|
12725
12744
|
subUnitId,
|
|
12726
12745
|
targetSubUnitId: config.id,
|
|
12746
|
+
targetSubUnitName: config.name,
|
|
12727
12747
|
copyContext
|
|
12728
12748
|
}
|
|
12729
12749
|
});
|
|
@@ -17807,7 +17827,7 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17807
17827
|
_initialize() {
|
|
17808
17828
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
17809
17829
|
if (command.id !== _univerjs_engine_formula.SetFormulaCalculationResultMutation.id) return;
|
|
17810
|
-
const { unitData } = command.params;
|
|
17830
|
+
const { unitData, sourceFormulaData } = command.params;
|
|
17811
17831
|
const unitIds = Object.keys(unitData);
|
|
17812
17832
|
const redoMutationsInfo = [];
|
|
17813
17833
|
for (let i = 0; i < unitIds.length; i++) {
|
|
@@ -17818,6 +17838,7 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17818
17838
|
if (sheetData == null) continue;
|
|
17819
17839
|
const sheetIds = Object.keys(sheetData);
|
|
17820
17840
|
for (let j = 0; j < sheetIds.length; j++) {
|
|
17841
|
+
var _sourceFormulaData$un;
|
|
17821
17842
|
const sheetId = sheetIds[j];
|
|
17822
17843
|
const cellData = sheetData[sheetId];
|
|
17823
17844
|
if (cellData == null) continue;
|
|
@@ -17825,7 +17846,8 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17825
17846
|
const setRangeValuesMutation = {
|
|
17826
17847
|
subUnitId: sheetId,
|
|
17827
17848
|
unitId,
|
|
17828
|
-
cellValue: this._getMergedCellData(unitId, sheetId, cellData)
|
|
17849
|
+
cellValue: this._getMergedCellData(unitId, sheetId, cellData, sourceFormulaData),
|
|
17850
|
+
sourceFormulaData: sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$un = sourceFormulaData[unitId]) === null || _sourceFormulaData$un === void 0 ? void 0 : _sourceFormulaData$un[sheetId]
|
|
17829
17851
|
};
|
|
17830
17852
|
redoMutationsInfo.push({
|
|
17831
17853
|
id: SetRangeValuesMutation.id,
|
|
@@ -17845,16 +17867,23 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17845
17867
|
* @param unitId
|
|
17846
17868
|
* @param sheetId
|
|
17847
17869
|
* @param cellData
|
|
17870
|
+
* @param sourceFormulaData Formula identities captured before scalar evaluation.
|
|
17848
17871
|
* @returns Calculated cell data merged with number formats.
|
|
17849
17872
|
*/
|
|
17850
|
-
_getMergedCellData(unitId, sheetId, cellData) {
|
|
17873
|
+
_getMergedCellData(unitId, sheetId, cellData, sourceFormulaData) {
|
|
17851
17874
|
const workbook = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
17852
17875
|
const styles = workbook === null || workbook === void 0 ? void 0 : workbook.getStyles();
|
|
17853
17876
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
17854
17877
|
const oldCellDataMatrix = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellMatrix();
|
|
17855
17878
|
const cellDataMatrix = new _univerjs_core.ObjectMatrix(cellData);
|
|
17856
17879
|
cellDataMatrix.forValue((row, col, cell) => {
|
|
17880
|
+
var _sourceFormulaData$un2;
|
|
17857
17881
|
const oldCell = oldCellDataMatrix === null || oldCellDataMatrix === void 0 ? void 0 : oldCellDataMatrix.getValue(row, col);
|
|
17882
|
+
const sourceFormula = sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$un2 = sourceFormulaData[unitId]) === null || _sourceFormulaData$un2 === void 0 || (_sourceFormulaData$un2 = _sourceFormulaData$un2[sheetId]) === null || _sourceFormulaData$un2 === void 0 || (_sourceFormulaData$un2 = _sourceFormulaData$un2[row]) === null || _sourceFormulaData$un2 === void 0 ? void 0 : _sourceFormulaData$un2[col];
|
|
17883
|
+
if (sourceFormula != null && (sourceFormula.f !== ((oldCell === null || oldCell === void 0 ? void 0 : oldCell.f) ?? "") || sourceFormula.si !== ((oldCell === null || oldCell === void 0 ? void 0 : oldCell.si) ?? void 0))) {
|
|
17884
|
+
cellDataMatrix.realDeleteValue(row, col);
|
|
17885
|
+
return;
|
|
17886
|
+
}
|
|
17858
17887
|
const newCell = (0, _univerjs_engine_formula.handleNumfmtInCell)(oldCell, cell, styles);
|
|
17859
17888
|
cellDataMatrix.setValue(row, col, newCell);
|
|
17860
17889
|
});
|
|
@@ -19490,7 +19519,7 @@ RangeProtectionCache = __decorate([
|
|
|
19490
19519
|
//#endregion
|
|
19491
19520
|
//#region package.json
|
|
19492
19521
|
var name = "@univerjs/sheets";
|
|
19493
|
-
var version = "1.0.
|
|
19522
|
+
var version = "1.0.4";
|
|
19494
19523
|
|
|
19495
19524
|
//#endregion
|
|
19496
19525
|
//#region src/controllers/active-worksheet.controller.ts
|
package/lib/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, Styles, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, WorksheetHiddenState, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, getIntersectRange, getNumfmtLocaleTag, getNumfmtParseValueFilter, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, regexp, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
1
|
+
import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, Styles, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, WorksheetHiddenState, WrapStrategy, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, getIntersectRange, getNumfmtLocaleTag, getNumfmtParseValueFilter, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, regexp, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
2
2
|
import { BehaviorSubject, Subject, distinctUntilChanged, filter, map, merge as merge$1, of, share, shareReplay, skip, switchMap, take, takeUntil } from "rxjs";
|
|
3
3
|
import { IDefinedNamesService, LexerTreeBuilder, RemoveDefinedNameMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFormulaCalculationResultMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, handleNumfmtInCell, isReferenceStringWithEffectiveColumn, operatorToken, sequenceNodeType, stripErrorMargin } from "@univerjs/engine-formula";
|
|
4
4
|
import { SpreadsheetSkeleton, cjk, precisionTo } from "@univerjs/engine-render";
|
|
@@ -1648,7 +1648,7 @@ const MoveRangeMutation = {
|
|
|
1648
1648
|
handler: (accessor, params) => {
|
|
1649
1649
|
const { from, to } = params;
|
|
1650
1650
|
if (!from || !to) return false;
|
|
1651
|
-
const workbook = accessor.get(IUniverInstanceService).
|
|
1651
|
+
const workbook = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET);
|
|
1652
1652
|
if (!workbook) return false;
|
|
1653
1653
|
const fromWorksheet = workbook.getSheetBySheetId(params.from.subUnitId);
|
|
1654
1654
|
const toWorksheet = workbook.getSheetBySheetId(params.to.subUnitId);
|
|
@@ -2319,7 +2319,9 @@ function prepareSetRangeValuesMutation(cells, styles, params) {
|
|
|
2319
2319
|
const before = new ObjectMatrix();
|
|
2320
2320
|
const after = new ObjectMatrix();
|
|
2321
2321
|
new ObjectMatrix(Tools.deepClone(params.cellValue)).forValue((row, column, value) => {
|
|
2322
|
+
var _params$sourceFormula;
|
|
2322
2323
|
const original = Tools.deepClone(cells.getValue(row, column) ?? null);
|
|
2324
|
+
if (isStaleFormulaResult(original, (_params$sourceFormula = params.sourceFormulaData) === null || _params$sourceFormula === void 0 || (_params$sourceFormula = _params$sourceFormula[row]) === null || _params$sourceFormula === void 0 ? void 0 : _params$sourceFormula[column])) return;
|
|
2323
2325
|
before.setValue(row, column, original);
|
|
2324
2326
|
const next = value ? mergeCellData(value, Tools.deepClone(original ?? {}), detachedStyles, !!params.isOverrideStyle) : null;
|
|
2325
2327
|
after.setValue(row, column, next && !Tools.isEmptyObject(next) ? next : null);
|
|
@@ -2369,7 +2371,7 @@ const SetRangeValuesMutation = {
|
|
|
2369
2371
|
id: "sheet.mutation.set-range-values",
|
|
2370
2372
|
type: CommandType.MUTATION,
|
|
2371
2373
|
handler: (accessor, params) => {
|
|
2372
|
-
const { cellValue, subUnitId, unitId, isOverrideStyle } = params;
|
|
2374
|
+
const { cellValue, subUnitId, unitId, isOverrideStyle, sourceFormulaData } = params;
|
|
2373
2375
|
const workbook = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
2374
2376
|
if (!workbook) return false;
|
|
2375
2377
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
@@ -2377,6 +2379,8 @@ const SetRangeValuesMutation = {
|
|
|
2377
2379
|
const cellMatrix = worksheet.getCellMatrix();
|
|
2378
2380
|
const styles = workbook.getStyles();
|
|
2379
2381
|
new ObjectMatrix(cellValue).forValue((row, col, newVal) => {
|
|
2382
|
+
var _sourceFormulaData$ro;
|
|
2383
|
+
if (isStaleFormulaResult(cellMatrix.getValue(row, col), sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$ro = sourceFormulaData[row]) === null || _sourceFormulaData$ro === void 0 ? void 0 : _sourceFormulaData$ro[col])) return;
|
|
2380
2384
|
if (!newVal) cellMatrix.realDeleteValue(row, col);
|
|
2381
2385
|
else {
|
|
2382
2386
|
let oldVal = cellMatrix.getValue(row, col) || {};
|
|
@@ -2388,6 +2392,9 @@ const SetRangeValuesMutation = {
|
|
|
2388
2392
|
return true;
|
|
2389
2393
|
}
|
|
2390
2394
|
};
|
|
2395
|
+
function isStaleFormulaResult(cell, source) {
|
|
2396
|
+
return source != null && (source.f !== ((cell === null || cell === void 0 ? void 0 : cell.f) ?? "") || source.si !== ((cell === null || cell === void 0 ? void 0 : cell.si) ?? void 0));
|
|
2397
|
+
}
|
|
2391
2398
|
const overwriteCellPropertiesSet = /* @__PURE__ */ new Set([
|
|
2392
2399
|
"f",
|
|
2393
2400
|
"p",
|
|
@@ -10348,6 +10355,27 @@ const AFFECT_LAYOUT_STYLES = [
|
|
|
10348
10355
|
"tr",
|
|
10349
10356
|
"tb"
|
|
10350
10357
|
];
|
|
10358
|
+
function createStyleCellValue(worksheet, ranges, style) {
|
|
10359
|
+
const cellValue = new ObjectMatrix();
|
|
10360
|
+
const iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
10361
|
+
if (Tools.isArray(style.value)) for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c, range) => {
|
|
10362
|
+
cellValue.setValue(r, c, { s: { [style.type]: style.value[r - range.startRow][c - range.startColumn] } });
|
|
10363
|
+
});
|
|
10364
|
+
else {
|
|
10365
|
+
const styleObj = { s: { [style.type]: style.value } };
|
|
10366
|
+
for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c) => cellValue.setValue(r, c, styleObj));
|
|
10367
|
+
}
|
|
10368
|
+
if (style.type === "tb" || style.type === "stf") cellValue.forValue((row, column, cell) => {
|
|
10369
|
+
var _worksheet$getCompose;
|
|
10370
|
+
const cellStyle = cell.s;
|
|
10371
|
+
if (cellStyle.tb === WrapStrategy.WRAP) cellStyle.stf = BooleanNumber.FALSE;
|
|
10372
|
+
else if (cellStyle.stf === BooleanNumber.TRUE && ((_worksheet$getCompose = worksheet.getComposedCellStyle(row, column)) === null || _worksheet$getCompose === void 0 ? void 0 : _worksheet$getCompose.tb) === WrapStrategy.WRAP) cellValue.setValue(row, column, { s: {
|
|
10373
|
+
...cellStyle,
|
|
10374
|
+
tb: WrapStrategy.UNSPECIFIED
|
|
10375
|
+
} });
|
|
10376
|
+
});
|
|
10377
|
+
return cellValue;
|
|
10378
|
+
}
|
|
10351
10379
|
/**
|
|
10352
10380
|
* The command to set cell style.
|
|
10353
10381
|
* Set style to a bunch of ranges.
|
|
@@ -10367,19 +10395,10 @@ const SetStyleCommand = {
|
|
|
10367
10395
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
10368
10396
|
const ranges = range ? [range] : (_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range);
|
|
10369
10397
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return false;
|
|
10370
|
-
const cellValue = new ObjectMatrix();
|
|
10371
|
-
const iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
10372
|
-
if (Tools.isArray(style.value)) for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c, range) => {
|
|
10373
|
-
cellValue.setValue(r, c, { s: { [style.type]: style.value[r - range.startRow][c - range.startColumn] } });
|
|
10374
|
-
});
|
|
10375
|
-
else for (let i = 0; i < ranges.length; i++) {
|
|
10376
|
-
const styleObj = { s: { [style.type]: style.value } };
|
|
10377
|
-
iterator.forOperableEach(ranges[i], (r, c) => cellValue.setValue(r, c, styleObj));
|
|
10378
|
-
}
|
|
10379
10398
|
const setRangeValuesMutationParams = {
|
|
10380
10399
|
subUnitId,
|
|
10381
10400
|
unitId,
|
|
10382
|
-
cellValue:
|
|
10401
|
+
cellValue: createStyleCellValue(worksheet, ranges, style).getMatrix()
|
|
10383
10402
|
};
|
|
10384
10403
|
const skeleton = accessor.get(SheetSkeletonService).getSkeleton(unitId, subUnitId);
|
|
10385
10404
|
const undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams);
|
|
@@ -12723,6 +12742,7 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
|
|
|
12723
12742
|
unitId,
|
|
12724
12743
|
subUnitId,
|
|
12725
12744
|
targetSubUnitId: config.id,
|
|
12745
|
+
targetSubUnitName: config.name,
|
|
12726
12746
|
copyContext
|
|
12727
12747
|
}
|
|
12728
12748
|
});
|
|
@@ -17806,7 +17826,7 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17806
17826
|
_initialize() {
|
|
17807
17827
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
17808
17828
|
if (command.id !== SetFormulaCalculationResultMutation.id) return;
|
|
17809
|
-
const { unitData } = command.params;
|
|
17829
|
+
const { unitData, sourceFormulaData } = command.params;
|
|
17810
17830
|
const unitIds = Object.keys(unitData);
|
|
17811
17831
|
const redoMutationsInfo = [];
|
|
17812
17832
|
for (let i = 0; i < unitIds.length; i++) {
|
|
@@ -17817,6 +17837,7 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17817
17837
|
if (sheetData == null) continue;
|
|
17818
17838
|
const sheetIds = Object.keys(sheetData);
|
|
17819
17839
|
for (let j = 0; j < sheetIds.length; j++) {
|
|
17840
|
+
var _sourceFormulaData$un;
|
|
17820
17841
|
const sheetId = sheetIds[j];
|
|
17821
17842
|
const cellData = sheetData[sheetId];
|
|
17822
17843
|
if (cellData == null) continue;
|
|
@@ -17824,7 +17845,8 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17824
17845
|
const setRangeValuesMutation = {
|
|
17825
17846
|
subUnitId: sheetId,
|
|
17826
17847
|
unitId,
|
|
17827
|
-
cellValue: this._getMergedCellData(unitId, sheetId, cellData)
|
|
17848
|
+
cellValue: this._getMergedCellData(unitId, sheetId, cellData, sourceFormulaData),
|
|
17849
|
+
sourceFormulaData: sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$un = sourceFormulaData[unitId]) === null || _sourceFormulaData$un === void 0 ? void 0 : _sourceFormulaData$un[sheetId]
|
|
17828
17850
|
};
|
|
17829
17851
|
redoMutationsInfo.push({
|
|
17830
17852
|
id: SetRangeValuesMutation.id,
|
|
@@ -17844,16 +17866,23 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17844
17866
|
* @param unitId
|
|
17845
17867
|
* @param sheetId
|
|
17846
17868
|
* @param cellData
|
|
17869
|
+
* @param sourceFormulaData Formula identities captured before scalar evaluation.
|
|
17847
17870
|
* @returns Calculated cell data merged with number formats.
|
|
17848
17871
|
*/
|
|
17849
|
-
_getMergedCellData(unitId, sheetId, cellData) {
|
|
17872
|
+
_getMergedCellData(unitId, sheetId, cellData, sourceFormulaData) {
|
|
17850
17873
|
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
17851
17874
|
const styles = workbook === null || workbook === void 0 ? void 0 : workbook.getStyles();
|
|
17852
17875
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
17853
17876
|
const oldCellDataMatrix = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellMatrix();
|
|
17854
17877
|
const cellDataMatrix = new ObjectMatrix(cellData);
|
|
17855
17878
|
cellDataMatrix.forValue((row, col, cell) => {
|
|
17879
|
+
var _sourceFormulaData$un2;
|
|
17856
17880
|
const oldCell = oldCellDataMatrix === null || oldCellDataMatrix === void 0 ? void 0 : oldCellDataMatrix.getValue(row, col);
|
|
17881
|
+
const sourceFormula = sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$un2 = sourceFormulaData[unitId]) === null || _sourceFormulaData$un2 === void 0 || (_sourceFormulaData$un2 = _sourceFormulaData$un2[sheetId]) === null || _sourceFormulaData$un2 === void 0 || (_sourceFormulaData$un2 = _sourceFormulaData$un2[row]) === null || _sourceFormulaData$un2 === void 0 ? void 0 : _sourceFormulaData$un2[col];
|
|
17882
|
+
if (sourceFormula != null && (sourceFormula.f !== ((oldCell === null || oldCell === void 0 ? void 0 : oldCell.f) ?? "") || sourceFormula.si !== ((oldCell === null || oldCell === void 0 ? void 0 : oldCell.si) ?? void 0))) {
|
|
17883
|
+
cellDataMatrix.realDeleteValue(row, col);
|
|
17884
|
+
return;
|
|
17885
|
+
}
|
|
17857
17886
|
const newCell = handleNumfmtInCell(oldCell, cell, styles);
|
|
17858
17887
|
cellDataMatrix.setValue(row, col, newCell);
|
|
17859
17888
|
});
|
|
@@ -19489,7 +19518,7 @@ RangeProtectionCache = __decorate([
|
|
|
19489
19518
|
//#endregion
|
|
19490
19519
|
//#region package.json
|
|
19491
19520
|
var name = "@univerjs/sheets";
|
|
19492
|
-
var version = "1.0.
|
|
19521
|
+
var version = "1.0.4";
|
|
19493
19522
|
|
|
19494
19523
|
//#endregion
|
|
19495
19524
|
//#region src/controllers/active-worksheet.controller.ts
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, Styles, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, WorksheetHiddenState, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, getIntersectRange, getNumfmtLocaleTag, getNumfmtParseValueFilter, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, regexp, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
1
|
+
import { AUTO_HEIGHT_FOR_MERGED_CELLS, BORDER_KEYS, BORDER_STYLE_KEYS, BooleanNumber, BorderStyleTypes, BorderType, BuildTextUtils, COLOR_STYLE_KEYS, CellModeEnum, CellValueType, CommandType, CustomCommandExecutionError, DependentOn, Dimension, Direction, Disposable, DisposableCollection, DocumentDataModel, ErrorService, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IResourceManagerService, IS_ROW_STYLE_PRECEDE_COLUMN_STYLE, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, PADDING_KEYS, PermissionStatus, Plugin, RANGE_TYPE, RTree, Range, Rectangle, RxDisposable, STYLE_KEYS, Styles, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, WorksheetHiddenState, WrapStrategy, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, getIntersectRange, getNumfmtLocaleTag, getNumfmtParseValueFilter, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, regexp, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
2
2
|
import { BehaviorSubject, Subject, distinctUntilChanged, filter, map, merge as merge$1, of, share, shareReplay, skip, switchMap, take, takeUntil } from "rxjs";
|
|
3
3
|
import { IDefinedNamesService, LexerTreeBuilder, RemoveDefinedNameMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFormulaCalculationResultMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, handleNumfmtInCell, isReferenceStringWithEffectiveColumn, operatorToken, sequenceNodeType, stripErrorMargin } from "@univerjs/engine-formula";
|
|
4
4
|
import { SpreadsheetSkeleton, cjk, precisionTo } from "@univerjs/engine-render";
|
|
@@ -1648,7 +1648,7 @@ const MoveRangeMutation = {
|
|
|
1648
1648
|
handler: (accessor, params) => {
|
|
1649
1649
|
const { from, to } = params;
|
|
1650
1650
|
if (!from || !to) return false;
|
|
1651
|
-
const workbook = accessor.get(IUniverInstanceService).
|
|
1651
|
+
const workbook = accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET);
|
|
1652
1652
|
if (!workbook) return false;
|
|
1653
1653
|
const fromWorksheet = workbook.getSheetBySheetId(params.from.subUnitId);
|
|
1654
1654
|
const toWorksheet = workbook.getSheetBySheetId(params.to.subUnitId);
|
|
@@ -2319,7 +2319,9 @@ function prepareSetRangeValuesMutation(cells, styles, params) {
|
|
|
2319
2319
|
const before = new ObjectMatrix();
|
|
2320
2320
|
const after = new ObjectMatrix();
|
|
2321
2321
|
new ObjectMatrix(Tools.deepClone(params.cellValue)).forValue((row, column, value) => {
|
|
2322
|
+
var _params$sourceFormula;
|
|
2322
2323
|
const original = Tools.deepClone(cells.getValue(row, column) ?? null);
|
|
2324
|
+
if (isStaleFormulaResult(original, (_params$sourceFormula = params.sourceFormulaData) === null || _params$sourceFormula === void 0 || (_params$sourceFormula = _params$sourceFormula[row]) === null || _params$sourceFormula === void 0 ? void 0 : _params$sourceFormula[column])) return;
|
|
2323
2325
|
before.setValue(row, column, original);
|
|
2324
2326
|
const next = value ? mergeCellData(value, Tools.deepClone(original ?? {}), detachedStyles, !!params.isOverrideStyle) : null;
|
|
2325
2327
|
after.setValue(row, column, next && !Tools.isEmptyObject(next) ? next : null);
|
|
@@ -2369,7 +2371,7 @@ const SetRangeValuesMutation = {
|
|
|
2369
2371
|
id: "sheet.mutation.set-range-values",
|
|
2370
2372
|
type: CommandType.MUTATION,
|
|
2371
2373
|
handler: (accessor, params) => {
|
|
2372
|
-
const { cellValue, subUnitId, unitId, isOverrideStyle } = params;
|
|
2374
|
+
const { cellValue, subUnitId, unitId, isOverrideStyle, sourceFormulaData } = params;
|
|
2373
2375
|
const workbook = accessor.get(IUniverInstanceService).getUnit(unitId);
|
|
2374
2376
|
if (!workbook) return false;
|
|
2375
2377
|
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
@@ -2377,6 +2379,8 @@ const SetRangeValuesMutation = {
|
|
|
2377
2379
|
const cellMatrix = worksheet.getCellMatrix();
|
|
2378
2380
|
const styles = workbook.getStyles();
|
|
2379
2381
|
new ObjectMatrix(cellValue).forValue((row, col, newVal) => {
|
|
2382
|
+
var _sourceFormulaData$ro;
|
|
2383
|
+
if (isStaleFormulaResult(cellMatrix.getValue(row, col), sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$ro = sourceFormulaData[row]) === null || _sourceFormulaData$ro === void 0 ? void 0 : _sourceFormulaData$ro[col])) return;
|
|
2380
2384
|
if (!newVal) cellMatrix.realDeleteValue(row, col);
|
|
2381
2385
|
else {
|
|
2382
2386
|
let oldVal = cellMatrix.getValue(row, col) || {};
|
|
@@ -2388,6 +2392,9 @@ const SetRangeValuesMutation = {
|
|
|
2388
2392
|
return true;
|
|
2389
2393
|
}
|
|
2390
2394
|
};
|
|
2395
|
+
function isStaleFormulaResult(cell, source) {
|
|
2396
|
+
return source != null && (source.f !== ((cell === null || cell === void 0 ? void 0 : cell.f) ?? "") || source.si !== ((cell === null || cell === void 0 ? void 0 : cell.si) ?? void 0));
|
|
2397
|
+
}
|
|
2391
2398
|
const overwriteCellPropertiesSet = /* @__PURE__ */ new Set([
|
|
2392
2399
|
"f",
|
|
2393
2400
|
"p",
|
|
@@ -10348,6 +10355,27 @@ const AFFECT_LAYOUT_STYLES = [
|
|
|
10348
10355
|
"tr",
|
|
10349
10356
|
"tb"
|
|
10350
10357
|
];
|
|
10358
|
+
function createStyleCellValue(worksheet, ranges, style) {
|
|
10359
|
+
const cellValue = new ObjectMatrix();
|
|
10360
|
+
const iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
10361
|
+
if (Tools.isArray(style.value)) for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c, range) => {
|
|
10362
|
+
cellValue.setValue(r, c, { s: { [style.type]: style.value[r - range.startRow][c - range.startColumn] } });
|
|
10363
|
+
});
|
|
10364
|
+
else {
|
|
10365
|
+
const styleObj = { s: { [style.type]: style.value } };
|
|
10366
|
+
for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c) => cellValue.setValue(r, c, styleObj));
|
|
10367
|
+
}
|
|
10368
|
+
if (style.type === "tb" || style.type === "stf") cellValue.forValue((row, column, cell) => {
|
|
10369
|
+
var _worksheet$getCompose;
|
|
10370
|
+
const cellStyle = cell.s;
|
|
10371
|
+
if (cellStyle.tb === WrapStrategy.WRAP) cellStyle.stf = BooleanNumber.FALSE;
|
|
10372
|
+
else if (cellStyle.stf === BooleanNumber.TRUE && ((_worksheet$getCompose = worksheet.getComposedCellStyle(row, column)) === null || _worksheet$getCompose === void 0 ? void 0 : _worksheet$getCompose.tb) === WrapStrategy.WRAP) cellValue.setValue(row, column, { s: {
|
|
10373
|
+
...cellStyle,
|
|
10374
|
+
tb: WrapStrategy.UNSPECIFIED
|
|
10375
|
+
} });
|
|
10376
|
+
});
|
|
10377
|
+
return cellValue;
|
|
10378
|
+
}
|
|
10351
10379
|
/**
|
|
10352
10380
|
* The command to set cell style.
|
|
10353
10381
|
* Set style to a bunch of ranges.
|
|
@@ -10367,19 +10395,10 @@ const SetStyleCommand = {
|
|
|
10367
10395
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
10368
10396
|
const ranges = range ? [range] : (_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range);
|
|
10369
10397
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return false;
|
|
10370
|
-
const cellValue = new ObjectMatrix();
|
|
10371
|
-
const iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
|
|
10372
|
-
if (Tools.isArray(style.value)) for (let i = 0; i < ranges.length; i++) iterator.forOperableEach(ranges[i], (r, c, range) => {
|
|
10373
|
-
cellValue.setValue(r, c, { s: { [style.type]: style.value[r - range.startRow][c - range.startColumn] } });
|
|
10374
|
-
});
|
|
10375
|
-
else for (let i = 0; i < ranges.length; i++) {
|
|
10376
|
-
const styleObj = { s: { [style.type]: style.value } };
|
|
10377
|
-
iterator.forOperableEach(ranges[i], (r, c) => cellValue.setValue(r, c, styleObj));
|
|
10378
|
-
}
|
|
10379
10398
|
const setRangeValuesMutationParams = {
|
|
10380
10399
|
subUnitId,
|
|
10381
10400
|
unitId,
|
|
10382
|
-
cellValue:
|
|
10401
|
+
cellValue: createStyleCellValue(worksheet, ranges, style).getMatrix()
|
|
10383
10402
|
};
|
|
10384
10403
|
const skeleton = accessor.get(SheetSkeletonService).getSkeleton(unitId, subUnitId);
|
|
10385
10404
|
const undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams);
|
|
@@ -12723,6 +12742,7 @@ function buildCopySheetMutations(accessor, workbook, worksheet, unitId, subUnitI
|
|
|
12723
12742
|
unitId,
|
|
12724
12743
|
subUnitId,
|
|
12725
12744
|
targetSubUnitId: config.id,
|
|
12745
|
+
targetSubUnitName: config.name,
|
|
12726
12746
|
copyContext
|
|
12727
12747
|
}
|
|
12728
12748
|
});
|
|
@@ -17806,7 +17826,7 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17806
17826
|
_initialize() {
|
|
17807
17827
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
17808
17828
|
if (command.id !== SetFormulaCalculationResultMutation.id) return;
|
|
17809
|
-
const { unitData } = command.params;
|
|
17829
|
+
const { unitData, sourceFormulaData } = command.params;
|
|
17810
17830
|
const unitIds = Object.keys(unitData);
|
|
17811
17831
|
const redoMutationsInfo = [];
|
|
17812
17832
|
for (let i = 0; i < unitIds.length; i++) {
|
|
@@ -17817,6 +17837,7 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17817
17837
|
if (sheetData == null) continue;
|
|
17818
17838
|
const sheetIds = Object.keys(sheetData);
|
|
17819
17839
|
for (let j = 0; j < sheetIds.length; j++) {
|
|
17840
|
+
var _sourceFormulaData$un;
|
|
17820
17841
|
const sheetId = sheetIds[j];
|
|
17821
17842
|
const cellData = sheetData[sheetId];
|
|
17822
17843
|
if (cellData == null) continue;
|
|
@@ -17824,7 +17845,8 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17824
17845
|
const setRangeValuesMutation = {
|
|
17825
17846
|
subUnitId: sheetId,
|
|
17826
17847
|
unitId,
|
|
17827
|
-
cellValue: this._getMergedCellData(unitId, sheetId, cellData)
|
|
17848
|
+
cellValue: this._getMergedCellData(unitId, sheetId, cellData, sourceFormulaData),
|
|
17849
|
+
sourceFormulaData: sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$un = sourceFormulaData[unitId]) === null || _sourceFormulaData$un === void 0 ? void 0 : _sourceFormulaData$un[sheetId]
|
|
17828
17850
|
};
|
|
17829
17851
|
redoMutationsInfo.push({
|
|
17830
17852
|
id: SetRangeValuesMutation.id,
|
|
@@ -17844,16 +17866,23 @@ let CalculateResultApplyController = class CalculateResultApplyController extend
|
|
|
17844
17866
|
* @param unitId
|
|
17845
17867
|
* @param sheetId
|
|
17846
17868
|
* @param cellData
|
|
17869
|
+
* @param sourceFormulaData Formula identities captured before scalar evaluation.
|
|
17847
17870
|
* @returns Calculated cell data merged with number formats.
|
|
17848
17871
|
*/
|
|
17849
|
-
_getMergedCellData(unitId, sheetId, cellData) {
|
|
17872
|
+
_getMergedCellData(unitId, sheetId, cellData, sourceFormulaData) {
|
|
17850
17873
|
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
17851
17874
|
const styles = workbook === null || workbook === void 0 ? void 0 : workbook.getStyles();
|
|
17852
17875
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
|
|
17853
17876
|
const oldCellDataMatrix = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getCellMatrix();
|
|
17854
17877
|
const cellDataMatrix = new ObjectMatrix(cellData);
|
|
17855
17878
|
cellDataMatrix.forValue((row, col, cell) => {
|
|
17879
|
+
var _sourceFormulaData$un2;
|
|
17856
17880
|
const oldCell = oldCellDataMatrix === null || oldCellDataMatrix === void 0 ? void 0 : oldCellDataMatrix.getValue(row, col);
|
|
17881
|
+
const sourceFormula = sourceFormulaData === null || sourceFormulaData === void 0 || (_sourceFormulaData$un2 = sourceFormulaData[unitId]) === null || _sourceFormulaData$un2 === void 0 || (_sourceFormulaData$un2 = _sourceFormulaData$un2[sheetId]) === null || _sourceFormulaData$un2 === void 0 || (_sourceFormulaData$un2 = _sourceFormulaData$un2[row]) === null || _sourceFormulaData$un2 === void 0 ? void 0 : _sourceFormulaData$un2[col];
|
|
17882
|
+
if (sourceFormula != null && (sourceFormula.f !== ((oldCell === null || oldCell === void 0 ? void 0 : oldCell.f) ?? "") || sourceFormula.si !== ((oldCell === null || oldCell === void 0 ? void 0 : oldCell.si) ?? void 0))) {
|
|
17883
|
+
cellDataMatrix.realDeleteValue(row, col);
|
|
17884
|
+
return;
|
|
17885
|
+
}
|
|
17857
17886
|
const newCell = handleNumfmtInCell(oldCell, cell, styles);
|
|
17858
17887
|
cellDataMatrix.setValue(row, col, newCell);
|
|
17859
17888
|
});
|
|
@@ -19489,7 +19518,7 @@ RangeProtectionCache = __decorate([
|
|
|
19489
19518
|
//#endregion
|
|
19490
19519
|
//#region package.json
|
|
19491
19520
|
var name = "@univerjs/sheets";
|
|
19492
|
-
var version = "1.0.
|
|
19521
|
+
var version = "1.0.4";
|
|
19493
19522
|
|
|
19494
19523
|
//#endregion
|
|
19495
19524
|
//#region src/controllers/active-worksheet.controller.ts
|
|
@@ -21,6 +21,7 @@ export interface ICopySheetCommandParams {
|
|
|
21
21
|
}
|
|
22
22
|
export interface ICopySheetCommandInterceptorParams extends ICopySheetCommandParams {
|
|
23
23
|
targetSubUnitId: string;
|
|
24
|
+
targetSubUnitName: string;
|
|
24
25
|
copyContext: Map<string, unknown>;
|
|
25
26
|
}
|
|
26
27
|
export declare const CopySheetCommand: ICommand;
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { HorizontalAlign, ICommand, IRange, IStyleData, VerticalAlign
|
|
16
|
+
import type { HorizontalAlign, ICommand, IRange, IStyleData, VerticalAlign } from '@univerjs/core';
|
|
17
17
|
import type { ISheetCommandSharedParams } from '../utils/interface';
|
|
18
|
-
import { BooleanNumber } from '@univerjs/core';
|
|
18
|
+
import { BooleanNumber, WrapStrategy } from '@univerjs/core';
|
|
19
19
|
export interface IStyleTypeValue<T> {
|
|
20
20
|
type: keyof IStyleData;
|
|
21
21
|
value: T | T[][];
|
|
@@ -28,6 +28,8 @@ export interface ISetRangeValuesMutationParams extends IMutationCommonParams {
|
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
isOverrideStyle?: boolean;
|
|
31
|
+
/** Formula identities retained for conditional result application across Worker replay. */
|
|
32
|
+
sourceFormulaData?: IObjectMatrixPrimitiveType<Pick<ICellData, 'f' | 'si'>>;
|
|
31
33
|
}
|
|
32
34
|
export interface ISetRangeValuesRangeMutationParams extends ISetRangeValuesMutationParams {
|
|
33
35
|
range: IRange[];
|
|
@@ -37,7 +39,7 @@ export interface ISetRangeValuesRangeMutationParams extends ISetRangeValuesMutat
|
|
|
37
39
|
* must travel with the prepared cells; replay installs them and must not allocate replacement IDs.
|
|
38
40
|
* This does not execute handlers, publish notifications, or own style garbage collection.
|
|
39
41
|
*/
|
|
40
|
-
export declare function prepareSetRangeValuesMutation(cells: ObjectMatrix<Nullable<ICellData>>, styles: Styles, params: Pick<ISetRangeValuesMutationParams, 'cellValue' | 'isOverrideStyle'>): {
|
|
42
|
+
export declare function prepareSetRangeValuesMutation(cells: ObjectMatrix<Nullable<ICellData>>, styles: Styles, params: Pick<ISetRangeValuesMutationParams, 'cellValue' | 'isOverrideStyle' | 'sourceFormulaData'>): {
|
|
41
43
|
before: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
|
|
42
44
|
after: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
|
|
43
45
|
styles: Record<string, IStyleData>;
|
|
@@ -24,6 +24,7 @@ export declare class CalculateResultApplyController extends Disposable {
|
|
|
24
24
|
* @param unitId
|
|
25
25
|
* @param sheetId
|
|
26
26
|
* @param cellData
|
|
27
|
+
* @param sourceFormulaData Formula identities captured before scalar evaluation.
|
|
27
28
|
* @returns Calculated cell data merged with number formats.
|
|
28
29
|
*/
|
|
29
30
|
private _getMergedCellData;
|