@univerjs/sheets 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 +24 -36
- package/lib/cjs/facade.js +86 -86
- package/lib/cjs/index.js +681 -514
- package/lib/es/facade.js +86 -86
- package/lib/es/index.js +682 -515
- package/lib/facade.js +86 -86
- package/lib/index.js +682 -515
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +17 -13
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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, TEXT_DECORATION_KEYS, TEXT_ROTATION_KEYS, TextX, Tools, UniverInstanceType, UserManagerService, cellToRange, cloneWorksheetData, composeInterceptors, concatMatrixArray, createIdentifier, createInterceptorKey, createRowColIter, generateRandomId, getArrayLength, isBooleanString, isDefaultFormat, isFormulaId, isFormulaString, isICellData, isRealNum, isSafeNumeric, isTextFormat, mapObjectMatrix, merge, mergeIntervals, mergeOverrideWithDependencies, mergeWorksheetSnapshotWithDefault, moveMatrixArray, normalizeTextRuns, numfmt, queryObjectMatrix, registerDependencies, remove, selectionToArray, sequenceExecute, sliceMatrixArray, spliceArray, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
2
|
-
import { BehaviorSubject, Subject, distinctUntilChanged, filter, first, map, merge as merge$1, of, shareReplay, skip, switchMap, takeUntil } from "rxjs";
|
|
2
|
+
import { BehaviorSubject, Subject, distinctUntilChanged, filter, first, map, merge as merge$1, of, share, shareReplay, skip, switchMap, 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, hasCJKText, precisionTo } from "@univerjs/engine-render";
|
|
5
5
|
import { UnitAction, UnitAction as UnitAction$1, UnitObject, UnitObject as UnitObject$1 } from "@univerjs/protocol";
|
|
@@ -158,7 +158,7 @@ const RangeThemeInterceptorId = "sheet.interceptor.range-theme-id";
|
|
|
158
158
|
const IgnoreRangeThemeInterceptorKey = "sheet.interceptor.ignore-range-theme";
|
|
159
159
|
|
|
160
160
|
//#endregion
|
|
161
|
-
//#region \0@oxc-project+runtime@0.
|
|
161
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
|
|
162
162
|
function _typeof(o) {
|
|
163
163
|
"@babel/helpers - typeof";
|
|
164
164
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -169,7 +169,7 @@ function _typeof(o) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
//#endregion
|
|
172
|
-
//#region \0@oxc-project+runtime@0.
|
|
172
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
|
|
173
173
|
function toPrimitive(t, r) {
|
|
174
174
|
if ("object" != _typeof(t) || !t) return t;
|
|
175
175
|
var e = t[Symbol.toPrimitive];
|
|
@@ -182,14 +182,14 @@ function toPrimitive(t, r) {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
//#endregion
|
|
185
|
-
//#region \0@oxc-project+runtime@0.
|
|
185
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
|
|
186
186
|
function toPropertyKey(t) {
|
|
187
187
|
var i = toPrimitive(t, "string");
|
|
188
188
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
192
|
-
//#region \0@oxc-project+runtime@0.
|
|
192
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
|
|
193
193
|
function _defineProperty(e, r, t) {
|
|
194
194
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
195
195
|
value: t,
|
|
@@ -200,7 +200,7 @@ function _defineProperty(e, r, t) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
//#endregion
|
|
203
|
-
//#region \0@oxc-project+runtime@0.
|
|
203
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
|
|
204
204
|
function __decorateParam(paramIndex, decorator) {
|
|
205
205
|
return function(target, key) {
|
|
206
206
|
decorator(target, key, paramIndex);
|
|
@@ -208,7 +208,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
//#endregion
|
|
211
|
-
//#region \0@oxc-project+runtime@0.
|
|
211
|
+
//#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
|
|
212
212
|
function __decorate(decorators, target, key, desc) {
|
|
213
213
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
214
214
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2801,7 +2801,7 @@ const COMMAND_LISTENER_VALUE_CHANGE = [
|
|
|
2801
2801
|
];
|
|
2802
2802
|
function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
2803
2803
|
switch (commandInfo.id) {
|
|
2804
|
-
case
|
|
2804
|
+
case "sheet.mutation.set-range-values": {
|
|
2805
2805
|
const params = commandInfo.params;
|
|
2806
2806
|
const range = new ObjectMatrix(params.cellValue).getDataRange();
|
|
2807
2807
|
if (range.endRow === -1) return [];
|
|
@@ -2811,7 +2811,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2811
2811
|
range
|
|
2812
2812
|
}] : [];
|
|
2813
2813
|
}
|
|
2814
|
-
case
|
|
2814
|
+
case "sheet.mutation.move-range": {
|
|
2815
2815
|
const params = commandInfo.params;
|
|
2816
2816
|
return [{
|
|
2817
2817
|
unitId: params.unitId,
|
|
@@ -2823,7 +2823,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2823
2823
|
range: new ObjectMatrix(params.to.value).getRange()
|
|
2824
2824
|
}];
|
|
2825
2825
|
}
|
|
2826
|
-
case
|
|
2826
|
+
case "sheet.mutation.remove-worksheet-merge": {
|
|
2827
2827
|
const params = commandInfo.params;
|
|
2828
2828
|
return params.ranges.map((range) => ({
|
|
2829
2829
|
unitId: params.unitId,
|
|
@@ -2831,7 +2831,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2831
2831
|
range
|
|
2832
2832
|
}));
|
|
2833
2833
|
}
|
|
2834
|
-
case
|
|
2834
|
+
case "sheet.mutation.add-worksheet-merge": {
|
|
2835
2835
|
const params = commandInfo.params;
|
|
2836
2836
|
return params.ranges.map((range) => ({
|
|
2837
2837
|
unitId: params.unitId,
|
|
@@ -2839,7 +2839,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2839
2839
|
range
|
|
2840
2840
|
}));
|
|
2841
2841
|
}
|
|
2842
|
-
case
|
|
2842
|
+
case "sheet.mutation.reorder-range": {
|
|
2843
2843
|
const params = commandInfo.params;
|
|
2844
2844
|
return [{
|
|
2845
2845
|
unitId: params.unitId,
|
|
@@ -2847,7 +2847,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2847
2847
|
range: params.range
|
|
2848
2848
|
}];
|
|
2849
2849
|
}
|
|
2850
|
-
case
|
|
2850
|
+
case "sheet.mutation.set-worksheet-default-style": {
|
|
2851
2851
|
const target = getSheetCommandTarget(univerInstanceService, commandInfo.params);
|
|
2852
2852
|
if (!target) return [];
|
|
2853
2853
|
const { worksheet, unitId, subUnitId } = target;
|
|
@@ -2862,7 +2862,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2862
2862
|
}
|
|
2863
2863
|
}];
|
|
2864
2864
|
}
|
|
2865
|
-
case
|
|
2865
|
+
case "sheet.mutation.set-row-data": {
|
|
2866
2866
|
const target = getSheetCommandTarget(univerInstanceService, commandInfo.params);
|
|
2867
2867
|
if (!target) return [];
|
|
2868
2868
|
const { worksheet, unitId, subUnitId } = target;
|
|
@@ -2880,7 +2880,7 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2880
2880
|
}
|
|
2881
2881
|
}];
|
|
2882
2882
|
}
|
|
2883
|
-
case
|
|
2883
|
+
case "sheet.mutation.set-col-data": {
|
|
2884
2884
|
const target = getSheetCommandTarget(univerInstanceService, commandInfo.params);
|
|
2885
2885
|
if (!target) return [];
|
|
2886
2886
|
const { worksheet, unitId, subUnitId } = target;
|
|
@@ -2898,8 +2898,8 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2898
2898
|
}
|
|
2899
2899
|
}];
|
|
2900
2900
|
}
|
|
2901
|
-
case
|
|
2902
|
-
case
|
|
2901
|
+
case "sheet.mutation.set-worksheet-range-theme-style":
|
|
2902
|
+
case "sheet.mutation.delete-worksheet-range-theme-style": {
|
|
2903
2903
|
const params = commandInfo.params;
|
|
2904
2904
|
return [{
|
|
2905
2905
|
unitId: params.unitId,
|
|
@@ -2917,8 +2917,8 @@ function getValueChangedEffectedRange(univerInstanceService, commandInfo) {
|
|
|
2917
2917
|
*/
|
|
2918
2918
|
function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
2919
2919
|
switch (commandInfo.id) {
|
|
2920
|
-
case
|
|
2921
|
-
case
|
|
2920
|
+
case "sheet.mutation.set-worksheet-row-height":
|
|
2921
|
+
case "sheet.mutation.set-worksheet-row-is-auto-height": {
|
|
2922
2922
|
const params = commandInfo.params;
|
|
2923
2923
|
return params.ranges.map((range) => ({
|
|
2924
2924
|
unitId: params.unitId,
|
|
@@ -2929,7 +2929,7 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
2929
2929
|
}
|
|
2930
2930
|
}));
|
|
2931
2931
|
}
|
|
2932
|
-
case
|
|
2932
|
+
case "sheet.mutation.set-worksheet-row-auto-height": {
|
|
2933
2933
|
const params = commandInfo.params;
|
|
2934
2934
|
return params.rowsAutoHeightInfo.map((rowAutoHeightInfo) => ({
|
|
2935
2935
|
unitId: params.unitId,
|
|
@@ -2943,7 +2943,7 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
2943
2943
|
}
|
|
2944
2944
|
}));
|
|
2945
2945
|
}
|
|
2946
|
-
case
|
|
2946
|
+
case "sheet.mutation.set-worksheet-col-width": {
|
|
2947
2947
|
const params = commandInfo.params;
|
|
2948
2948
|
return params.ranges.map((range) => ({
|
|
2949
2949
|
unitId: params.unitId,
|
|
@@ -2954,8 +2954,8 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
2954
2954
|
}
|
|
2955
2955
|
}));
|
|
2956
2956
|
}
|
|
2957
|
-
case
|
|
2958
|
-
case
|
|
2957
|
+
case "sheet.mutation.move-rows":
|
|
2958
|
+
case "sheet.mutation.move-columns": {
|
|
2959
2959
|
const params = commandInfo.params;
|
|
2960
2960
|
return [{
|
|
2961
2961
|
unitId: params.unitId,
|
|
@@ -2967,8 +2967,8 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
2967
2967
|
range: params.sourceRange
|
|
2968
2968
|
}];
|
|
2969
2969
|
}
|
|
2970
|
-
case
|
|
2971
|
-
case
|
|
2970
|
+
case "sheet.mutation.set-col-hidden":
|
|
2971
|
+
case "sheet.mutation.set-col-visible": {
|
|
2972
2972
|
const params = commandInfo.params;
|
|
2973
2973
|
return params.ranges.map((range) => ({
|
|
2974
2974
|
unitId: params.unitId,
|
|
@@ -2979,8 +2979,8 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
2979
2979
|
}
|
|
2980
2980
|
}));
|
|
2981
2981
|
}
|
|
2982
|
-
case
|
|
2983
|
-
case
|
|
2982
|
+
case "sheet.mutation.set-row-hidden":
|
|
2983
|
+
case "sheet.mutation.set-row-visible": {
|
|
2984
2984
|
const params = commandInfo.params;
|
|
2985
2985
|
return params.ranges.map((range) => ({
|
|
2986
2986
|
unitId: params.unitId,
|
|
@@ -2991,7 +2991,7 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
2991
2991
|
}
|
|
2992
2992
|
}));
|
|
2993
2993
|
}
|
|
2994
|
-
case
|
|
2994
|
+
case "sheet.mutation.insert-col": {
|
|
2995
2995
|
const params = commandInfo.params;
|
|
2996
2996
|
return [{
|
|
2997
2997
|
unitId: params.unitId,
|
|
@@ -3002,7 +3002,7 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
3002
3002
|
}
|
|
3003
3003
|
}];
|
|
3004
3004
|
}
|
|
3005
|
-
case
|
|
3005
|
+
case "sheet.mutation.insert-row": {
|
|
3006
3006
|
const params = commandInfo.params;
|
|
3007
3007
|
return [{
|
|
3008
3008
|
unitId: params.unitId,
|
|
@@ -3013,7 +3013,7 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
3013
3013
|
}
|
|
3014
3014
|
}];
|
|
3015
3015
|
}
|
|
3016
|
-
case
|
|
3016
|
+
case "sheet.mutation.remove-col": {
|
|
3017
3017
|
const params = commandInfo.params;
|
|
3018
3018
|
return [{
|
|
3019
3019
|
unitId: params.unitId,
|
|
@@ -3024,7 +3024,7 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
3024
3024
|
}
|
|
3025
3025
|
}];
|
|
3026
3026
|
}
|
|
3027
|
-
case
|
|
3027
|
+
case "sheet.mutation.remove-rows": {
|
|
3028
3028
|
const params = commandInfo.params;
|
|
3029
3029
|
return [{
|
|
3030
3030
|
unitId: params.unitId,
|
|
@@ -3035,8 +3035,8 @@ function getSkeletonChangedEffectedRange(commandInfo, columnCount) {
|
|
|
3035
3035
|
}
|
|
3036
3036
|
}];
|
|
3037
3037
|
}
|
|
3038
|
-
case
|
|
3039
|
-
case
|
|
3038
|
+
case "sheet.mutation.toggle-gridlines":
|
|
3039
|
+
case "sheet.mutation.set-gridlines-color": return [];
|
|
3040
3040
|
default: return [];
|
|
3041
3041
|
}
|
|
3042
3042
|
}
|
|
@@ -3639,21 +3639,21 @@ var DelimiterCounter = class {
|
|
|
3639
3639
|
}
|
|
3640
3640
|
getDelimiter() {
|
|
3641
3641
|
const maxCount = Math.max(this._tabCount, this._commaCount, this._semicolonCount, this._spaceCount);
|
|
3642
|
-
if (maxCount === 0) return
|
|
3643
|
-
if (maxCount === this._tabCount) return
|
|
3644
|
-
if (maxCount === this._commaCount) return
|
|
3645
|
-
if (maxCount === this._semicolonCount) return
|
|
3646
|
-
if (maxCount === this._spaceCount) return
|
|
3647
|
-
return
|
|
3642
|
+
if (maxCount === 0) return 1;
|
|
3643
|
+
if (maxCount === this._tabCount) return 1;
|
|
3644
|
+
if (maxCount === this._commaCount) return 2;
|
|
3645
|
+
if (maxCount === this._semicolonCount) return 4;
|
|
3646
|
+
if (maxCount === this._spaceCount) return 8;
|
|
3647
|
+
return 1;
|
|
3648
3648
|
}
|
|
3649
3649
|
};
|
|
3650
3650
|
function getDelimiterRegexItem(delimiter, treatMultipleDelimitersAsOne, customDelimiter) {
|
|
3651
3651
|
const delimiterList = [];
|
|
3652
|
-
if (customDelimiter !== void 0 && (delimiter &
|
|
3653
|
-
if ((delimiter &
|
|
3654
|
-
if ((delimiter &
|
|
3655
|
-
if ((delimiter &
|
|
3656
|
-
if ((delimiter &
|
|
3652
|
+
if (customDelimiter !== void 0 && (delimiter & 16) > 0) delimiterList.push(customDelimiter);
|
|
3653
|
+
if ((delimiter & 1) > 0) delimiterList.push(" ");
|
|
3654
|
+
if ((delimiter & 2) > 0) delimiterList.push(",");
|
|
3655
|
+
if ((delimiter & 4) > 0) delimiterList.push(";");
|
|
3656
|
+
if ((delimiter & 8) > 0) delimiterList.push(" ");
|
|
3657
3657
|
let str = "";
|
|
3658
3658
|
for (const delimiter of delimiterList) str += escapeRegExp(delimiter);
|
|
3659
3659
|
let allStr = "[".concat(str, "]");
|
|
@@ -3685,7 +3685,7 @@ function cellValueToString(cellData) {
|
|
|
3685
3685
|
function splitRangeText(sheet, range, delimiter, customDelimiter, treatMultipleDelimitersAsOne = false) {
|
|
3686
3686
|
const { startColumn, startRow, endColumn, endRow } = Range.transformRange(range, sheet);
|
|
3687
3687
|
if (startColumn !== endColumn) throw new Error("The range must be in the same column.");
|
|
3688
|
-
if (delimiter && (delimiter &
|
|
3688
|
+
if (delimiter && (delimiter & 16) > 0 && (customDelimiter === void 0 || customDelimiter.length !== 1)) throw new Error("The custom delimiter must a character.");
|
|
3689
3689
|
const needAutoDelimiter = delimiter === void 0;
|
|
3690
3690
|
const delimiterCounter = needAutoDelimiter ? new DelimiterCounter() : null;
|
|
3691
3691
|
const textList = [];
|
|
@@ -4168,17 +4168,17 @@ var WorkbookSelectionModel = class extends Disposable {
|
|
|
4168
4168
|
setSelections(sheetId, selectionDatas = [], type) {
|
|
4169
4169
|
this.setSelectionsOfWorksheet(sheetId, selectionDatas);
|
|
4170
4170
|
switch (type) {
|
|
4171
|
-
case
|
|
4171
|
+
case 0:
|
|
4172
4172
|
this._selectionMoveStart$.next(selectionDatas);
|
|
4173
4173
|
break;
|
|
4174
|
-
case
|
|
4174
|
+
case 1:
|
|
4175
4175
|
this._selectionMoving$.next(selectionDatas);
|
|
4176
4176
|
break;
|
|
4177
|
-
case
|
|
4177
|
+
case 2:
|
|
4178
4178
|
this._beforeSelectionMoveEnd$.next(selectionDatas);
|
|
4179
4179
|
this._selectionMoveEnd$.next(selectionDatas);
|
|
4180
4180
|
break;
|
|
4181
|
-
case
|
|
4181
|
+
case 3:
|
|
4182
4182
|
this._selectionSet$.next(selectionDatas);
|
|
4183
4183
|
break;
|
|
4184
4184
|
default:
|
|
@@ -4292,17 +4292,17 @@ let SheetsSelectionsService = class SheetsSelectionsService extends RxDisposable
|
|
|
4292
4292
|
}
|
|
4293
4293
|
_init() {
|
|
4294
4294
|
const c$ = this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(shareReplay(1), takeUntil(this.dispose$));
|
|
4295
|
-
this.selectionMoveStart$ = c$.pipe(
|
|
4296
|
-
this.selectionMoving$ = c$.pipe(switchMap((workbook) => !workbook ? of() : this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoving$)
|
|
4297
|
-
this.selectionMoveEnd$ = c$.pipe(switchMap((workbook) => !workbook ? of([]) : this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoveEnd$)
|
|
4298
|
-
this.selectionSet$ = c$.pipe(switchMap((workbook) => !workbook ? of([]) : this._ensureWorkbookSelection(workbook.getUnitId()).selectionSet$)
|
|
4299
|
-
this.selectionChanged$ = c$.pipe(switchMap((workbook) => !workbook ? of([]) : this._ensureWorkbookSelection(workbook.getUnitId()).selectionChanged$)
|
|
4295
|
+
this.selectionMoveStart$ = c$.pipe(switchMap((workbook) => !workbook ? of() : this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoveStart$), takeUntil(this.dispose$));
|
|
4296
|
+
this.selectionMoving$ = c$.pipe(switchMap((workbook) => !workbook ? of() : this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoving$), takeUntil(this.dispose$));
|
|
4297
|
+
this.selectionMoveEnd$ = c$.pipe(switchMap((workbook) => !workbook ? of([]) : this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoveEnd$), takeUntil(this.dispose$));
|
|
4298
|
+
this.selectionSet$ = c$.pipe(switchMap((workbook) => !workbook ? of([]) : this._ensureWorkbookSelection(workbook.getUnitId()).selectionSet$), takeUntil(this.dispose$));
|
|
4299
|
+
this.selectionChanged$ = c$.pipe(switchMap((workbook) => !workbook ? of([]) : this._ensureWorkbookSelection(workbook.getUnitId()).selectionChanged$), distinctUntilChanged((prev, curr) => {
|
|
4300
4300
|
if (prev.length !== curr.length) return false;
|
|
4301
4301
|
if (prev.length === 0 && curr.length === 0) return true;
|
|
4302
4302
|
return prev.every((item, index) => {
|
|
4303
4303
|
return JSON.stringify(item) === JSON.stringify(curr[index]);
|
|
4304
4304
|
});
|
|
4305
|
-
}), skip(1)
|
|
4305
|
+
}), skip(1), takeUntil(this.dispose$), share());
|
|
4306
4306
|
this.disposeWithMe(this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => {
|
|
4307
4307
|
this._removeWorkbookSelection(workbook.getUnitId());
|
|
4308
4308
|
}));
|
|
@@ -4354,7 +4354,7 @@ let SheetsSelectionsService = class SheetsSelectionsService extends RxDisposable
|
|
|
4354
4354
|
setSelections(unitIdOrSelections, worksheetIdOrType, selectionDatas, type) {
|
|
4355
4355
|
if (typeof unitIdOrSelections === "string" && typeof worksheetIdOrType === "string") {
|
|
4356
4356
|
const unitId = unitIdOrSelections;
|
|
4357
|
-
this._ensureWorkbookSelection(unitId).setSelections(worksheetIdOrType, selectionDatas || [], type !== null && type !== void 0 ? type :
|
|
4357
|
+
this._ensureWorkbookSelection(unitId).setSelections(worksheetIdOrType, selectionDatas || [], type !== null && type !== void 0 ? type : 3);
|
|
4358
4358
|
return;
|
|
4359
4359
|
}
|
|
4360
4360
|
const current = this._currentSelectionPos;
|
|
@@ -4363,7 +4363,7 @@ let SheetsSelectionsService = class SheetsSelectionsService extends RxDisposable
|
|
|
4363
4363
|
if (typeof unitIdOrSelections === "object") {
|
|
4364
4364
|
var _ref;
|
|
4365
4365
|
const selectionData = unitIdOrSelections !== null && unitIdOrSelections !== void 0 ? unitIdOrSelections : selectionDatas;
|
|
4366
|
-
const type = (_ref = worksheetIdOrType) !== null && _ref !== void 0 ? _ref :
|
|
4366
|
+
const type = (_ref = worksheetIdOrType) !== null && _ref !== void 0 ? _ref : 3;
|
|
4367
4367
|
this._ensureWorkbookSelection(unitId).setSelections(sheetId, selectionData, type);
|
|
4368
4368
|
}
|
|
4369
4369
|
}
|
|
@@ -4450,6 +4450,203 @@ const DISABLE_NORMAL_SELECTIONS = "DISABLE_NORMAL_SELECTIONS";
|
|
|
4450
4450
|
const SELECTIONS_ENABLED = "SELECTIONS_ENABLED";
|
|
4451
4451
|
const REF_SELECTIONS_ENABLED = "REF_SELECTIONS_ENABLED";
|
|
4452
4452
|
|
|
4453
|
+
//#endregion
|
|
4454
|
+
//#region src/skeleton/skeleton.service.ts
|
|
4455
|
+
let SheetSkeletonService = class SheetSkeletonService extends Disposable {
|
|
4456
|
+
constructor(_injector, _univerInstanceService) {
|
|
4457
|
+
super();
|
|
4458
|
+
this._injector = _injector;
|
|
4459
|
+
this._univerInstanceService = _univerInstanceService;
|
|
4460
|
+
_defineProperty(this, "_sceneMap", /* @__PURE__ */ new Map());
|
|
4461
|
+
_defineProperty(this, "_sheetSkeletonParamStore", /* @__PURE__ */ new Map());
|
|
4462
|
+
_defineProperty(this, "_buildSkeleton$", new Subject());
|
|
4463
|
+
_defineProperty(this, "buildSkeleton$", this._buildSkeleton$.asObservable());
|
|
4464
|
+
this._init();
|
|
4465
|
+
}
|
|
4466
|
+
dispose() {
|
|
4467
|
+
super.dispose();
|
|
4468
|
+
this._sheetSkeletonParamStore.forEach((subUnitMap) => subUnitMap.forEach((skeletonParam) => skeletonParam.skeleton.dispose()));
|
|
4469
|
+
this._sheetSkeletonParamStore.clear();
|
|
4470
|
+
}
|
|
4471
|
+
_disposeByUnitId(unitId) {
|
|
4472
|
+
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4473
|
+
if (!sheetSkeletonMap) return;
|
|
4474
|
+
sheetSkeletonMap.forEach((skeletonParam) => skeletonParam.skeleton.dispose());
|
|
4475
|
+
this._sheetSkeletonParamStore.delete(unitId);
|
|
4476
|
+
}
|
|
4477
|
+
_init() {
|
|
4478
|
+
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((event) => this._initWorkbookSkeleton(event.unit)));
|
|
4479
|
+
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => this._disposeByUnitId(workbook.getUnitId())));
|
|
4480
|
+
}
|
|
4481
|
+
_initWorkbookSkeleton(workbook) {
|
|
4482
|
+
const unitId = workbook.getUnitId();
|
|
4483
|
+
this._initSheetsSkeleton(workbook);
|
|
4484
|
+
this.disposeWithMe(workbook.sheetCreated$.subscribe((worksheet) => {
|
|
4485
|
+
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4486
|
+
if (!sheetSkeletonMap) return;
|
|
4487
|
+
const sheetId = worksheet.getSheetId();
|
|
4488
|
+
const skeleton = this._buildSkeleton(worksheet, workbook.getStyles());
|
|
4489
|
+
sheetSkeletonMap.set(sheetId, {
|
|
4490
|
+
unitId,
|
|
4491
|
+
sheetId,
|
|
4492
|
+
skeleton,
|
|
4493
|
+
dirty: false
|
|
4494
|
+
});
|
|
4495
|
+
}));
|
|
4496
|
+
this.disposeWithMe(workbook.sheetDisposed$.subscribe((worksheet) => {
|
|
4497
|
+
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4498
|
+
if (!sheetSkeletonMap) return;
|
|
4499
|
+
const sheetId = worksheet.getSheetId();
|
|
4500
|
+
const skeletonParam = sheetSkeletonMap.get(sheetId);
|
|
4501
|
+
if (skeletonParam) skeletonParam.skeleton.dispose();
|
|
4502
|
+
sheetSkeletonMap.delete(sheetId);
|
|
4503
|
+
}));
|
|
4504
|
+
}
|
|
4505
|
+
_initSheetsSkeleton(workbook) {
|
|
4506
|
+
const unitId = workbook.getUnitId();
|
|
4507
|
+
const sheetSkeletonMap = /* @__PURE__ */ new Map();
|
|
4508
|
+
workbook.getWorksheets().forEach((worksheet) => {
|
|
4509
|
+
const sheetId = worksheet.getSheetId();
|
|
4510
|
+
const skeleton = this._buildSkeleton(worksheet, workbook.getStyles());
|
|
4511
|
+
sheetSkeletonMap.set(sheetId, {
|
|
4512
|
+
unitId,
|
|
4513
|
+
sheetId,
|
|
4514
|
+
skeleton,
|
|
4515
|
+
dirty: false
|
|
4516
|
+
});
|
|
4517
|
+
});
|
|
4518
|
+
this._sheetSkeletonParamStore.set(unitId, sheetSkeletonMap);
|
|
4519
|
+
}
|
|
4520
|
+
_buildSkeleton(worksheet, styles) {
|
|
4521
|
+
const spreadsheetSkeleton = this._injector.createInstance(SpreadsheetSkeleton, worksheet, styles);
|
|
4522
|
+
const unitId = worksheet.getUnitId();
|
|
4523
|
+
const scene = this._sceneMap.get(unitId);
|
|
4524
|
+
if (scene) spreadsheetSkeleton.setScene(scene);
|
|
4525
|
+
this._buildSkeleton$.next(spreadsheetSkeleton);
|
|
4526
|
+
return spreadsheetSkeleton;
|
|
4527
|
+
}
|
|
4528
|
+
setScene(unitId, scene) {
|
|
4529
|
+
this._sceneMap.set(unitId, scene);
|
|
4530
|
+
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4531
|
+
if (!sheetSkeletonMap) return;
|
|
4532
|
+
sheetSkeletonMap.forEach((skeletonParam) => skeletonParam.skeleton.setScene(scene));
|
|
4533
|
+
}
|
|
4534
|
+
getSkeletonsByUnitId(unitId) {
|
|
4535
|
+
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4536
|
+
if (!sheetSkeletonMap) return [];
|
|
4537
|
+
return Array.from(sheetSkeletonMap.values()).map((param) => param.skeleton);
|
|
4538
|
+
}
|
|
4539
|
+
getSkeleton(unitId, subUnitId) {
|
|
4540
|
+
var _this$getSkeletonPara;
|
|
4541
|
+
return (_this$getSkeletonPara = this.getSkeletonParam(unitId, subUnitId)) === null || _this$getSkeletonPara === void 0 ? void 0 : _this$getSkeletonPara.skeleton;
|
|
4542
|
+
}
|
|
4543
|
+
getSkeletonParam(unitId, subUnitId) {
|
|
4544
|
+
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4545
|
+
if (!sheetSkeletonMap) return;
|
|
4546
|
+
return sheetSkeletonMap.get(subUnitId);
|
|
4547
|
+
}
|
|
4548
|
+
newSkeleton(unitId, subUnitId, worksheet, styles) {
|
|
4549
|
+
return this.newSkeletonParam(unitId, subUnitId, worksheet, styles).skeleton;
|
|
4550
|
+
}
|
|
4551
|
+
newSkeletonParam(unitId, subUnitId, worksheet, styles) {
|
|
4552
|
+
const skeleton = this._buildSkeleton(worksheet, styles);
|
|
4553
|
+
let sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
4554
|
+
if (!sheetSkeletonMap) {
|
|
4555
|
+
sheetSkeletonMap = /* @__PURE__ */ new Map();
|
|
4556
|
+
this._sheetSkeletonParamStore.set(unitId, sheetSkeletonMap);
|
|
4557
|
+
}
|
|
4558
|
+
const skeletonParam = {
|
|
4559
|
+
unitId,
|
|
4560
|
+
sheetId: subUnitId,
|
|
4561
|
+
skeleton,
|
|
4562
|
+
dirty: false
|
|
4563
|
+
};
|
|
4564
|
+
sheetSkeletonMap.set(subUnitId, skeletonParam);
|
|
4565
|
+
return skeletonParam;
|
|
4566
|
+
}
|
|
4567
|
+
ensureSkeleton(unitId, subUnitId) {
|
|
4568
|
+
const skeleton = this.getSkeleton(unitId, subUnitId);
|
|
4569
|
+
if (skeleton) return skeleton;
|
|
4570
|
+
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
4571
|
+
if (!workbook) return;
|
|
4572
|
+
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
4573
|
+
if (!worksheet) return;
|
|
4574
|
+
return this.newSkeleton(unitId, subUnitId, worksheet, workbook.getStyles());
|
|
4575
|
+
}
|
|
4576
|
+
};
|
|
4577
|
+
SheetSkeletonService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, Inject(IUniverInstanceService))], SheetSkeletonService);
|
|
4578
|
+
|
|
4579
|
+
//#endregion
|
|
4580
|
+
//#region src/commands/commands/util.ts
|
|
4581
|
+
function getRangesHeight(ranges, worksheet) {
|
|
4582
|
+
const cellHeights = new ObjectMatrix();
|
|
4583
|
+
ranges.map((range) => Range.transformRange(range, worksheet)).forEach((range) => {
|
|
4584
|
+
Range.foreach(range, (row, col) => {
|
|
4585
|
+
const cellHeight = worksheet.getCellHeight(row, col);
|
|
4586
|
+
if (cellHeight) cellHeights.setValue(row, col, cellHeight);
|
|
4587
|
+
});
|
|
4588
|
+
});
|
|
4589
|
+
return cellHeights;
|
|
4590
|
+
}
|
|
4591
|
+
const MAX_RANGE_CELL_COUNT = 1e4;
|
|
4592
|
+
function getSuitableRangesInView(ranges, skeleton) {
|
|
4593
|
+
if (!skeleton) return {
|
|
4594
|
+
suitableRanges: ranges,
|
|
4595
|
+
remainingRanges: []
|
|
4596
|
+
};
|
|
4597
|
+
const colCount = skeleton.worksheet.getColumnCount();
|
|
4598
|
+
const maxRowCount = Math.ceil(MAX_RANGE_CELL_COUNT / colCount);
|
|
4599
|
+
const suitableRanges = [];
|
|
4600
|
+
const remainingRanges = [];
|
|
4601
|
+
const row = skeleton.getOffsetRelativeToRowCol(0, skeleton.scrollY).row;
|
|
4602
|
+
const rangesWithDistance = ranges.map((range) => {
|
|
4603
|
+
let distance;
|
|
4604
|
+
if (row >= range.startRow && row <= range.endRow) distance = 0;
|
|
4605
|
+
else if (row < range.startRow) distance = range.startRow - row;
|
|
4606
|
+
else distance = row - range.endRow;
|
|
4607
|
+
return {
|
|
4608
|
+
range,
|
|
4609
|
+
distance,
|
|
4610
|
+
rowCount: range.endRow - range.startRow + 1
|
|
4611
|
+
};
|
|
4612
|
+
});
|
|
4613
|
+
rangesWithDistance.sort((a, b) => {
|
|
4614
|
+
if (a.distance !== b.distance) return a.distance - b.distance;
|
|
4615
|
+
return a.rowCount - b.rowCount;
|
|
4616
|
+
});
|
|
4617
|
+
let totalRowCount = 0;
|
|
4618
|
+
for (const item of rangesWithDistance) if (totalRowCount + item.rowCount <= maxRowCount) {
|
|
4619
|
+
suitableRanges.push(item.range);
|
|
4620
|
+
totalRowCount += item.rowCount;
|
|
4621
|
+
} else {
|
|
4622
|
+
const remainingQuota = maxRowCount - totalRowCount;
|
|
4623
|
+
if (remainingQuota > 0) {
|
|
4624
|
+
const suitablePart = {
|
|
4625
|
+
...item.range,
|
|
4626
|
+
endRow: item.range.startRow + remainingQuota - 1
|
|
4627
|
+
};
|
|
4628
|
+
const remainingPart = {
|
|
4629
|
+
...item.range,
|
|
4630
|
+
startRow: item.range.startRow + remainingQuota
|
|
4631
|
+
};
|
|
4632
|
+
suitableRanges.push(suitablePart);
|
|
4633
|
+
remainingRanges.push(remainingPart);
|
|
4634
|
+
totalRowCount = maxRowCount;
|
|
4635
|
+
} else remainingRanges.push(item.range);
|
|
4636
|
+
}
|
|
4637
|
+
return {
|
|
4638
|
+
suitableRanges,
|
|
4639
|
+
remainingRanges
|
|
4640
|
+
};
|
|
4641
|
+
}
|
|
4642
|
+
function countCells(cellMatrix) {
|
|
4643
|
+
let count = 0;
|
|
4644
|
+
cellMatrix.forEach(() => {
|
|
4645
|
+
count++;
|
|
4646
|
+
});
|
|
4647
|
+
return count;
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4453
4650
|
//#endregion
|
|
4454
4651
|
//#region src/commands/commands/clear-selection-all.command.ts
|
|
4455
4652
|
/**
|
|
@@ -4467,25 +4664,26 @@ const ClearSelectionAllCommand = {
|
|
|
4467
4664
|
if (!target) return false;
|
|
4468
4665
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
4469
4666
|
const { unitId, subUnitId } = target;
|
|
4470
|
-
const
|
|
4471
|
-
if (!(
|
|
4667
|
+
const ranges = (params === null || params === void 0 ? void 0 : params.ranges) || ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range));
|
|
4668
|
+
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return false;
|
|
4669
|
+
const skeleton = accessor.get(SheetSkeletonService).getSkeleton(unitId, subUnitId);
|
|
4670
|
+
if (!skeleton) return false;
|
|
4472
4671
|
const commandService = accessor.get(ICommandService);
|
|
4473
4672
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
4474
4673
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
4475
|
-
const
|
|
4476
|
-
const
|
|
4477
|
-
const sequenceExecuteUndoList = [];
|
|
4674
|
+
const redoMutations = [];
|
|
4675
|
+
const undoMutations = [];
|
|
4478
4676
|
const clearMutationParams = {
|
|
4479
4677
|
subUnitId,
|
|
4480
4678
|
unitId,
|
|
4481
|
-
cellValue: generateNullCell(
|
|
4679
|
+
cellValue: generateNullCell(getVisibleRanges(ranges, accessor, unitId, subUnitId))
|
|
4482
4680
|
};
|
|
4483
4681
|
const undoClearMutationParams = SetRangeValuesUndoMutationFactory(accessor, clearMutationParams);
|
|
4484
|
-
|
|
4682
|
+
redoMutations.push({
|
|
4485
4683
|
id: SetRangeValuesMutation.id,
|
|
4486
4684
|
params: clearMutationParams
|
|
4487
4685
|
});
|
|
4488
|
-
|
|
4686
|
+
undoMutations.push({
|
|
4489
4687
|
id: SetRangeValuesMutation.id,
|
|
4490
4688
|
params: undoClearMutationParams
|
|
4491
4689
|
});
|
|
@@ -4493,13 +4691,25 @@ const ClearSelectionAllCommand = {
|
|
|
4493
4691
|
id: ClearSelectionAllCommand.id,
|
|
4494
4692
|
params
|
|
4495
4693
|
});
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4694
|
+
redoMutations.push(...intercepted.redos);
|
|
4695
|
+
undoMutations.unshift(...intercepted.undos);
|
|
4696
|
+
const result = sequenceExecute(redoMutations, commandService);
|
|
4697
|
+
const { suitableRanges, remainingRanges } = getSuitableRangesInView(ranges, skeleton);
|
|
4698
|
+
const { undos: autoHeightUndos, redos: autoHeightRedos } = sheetInterceptorService.generateMutationsOfAutoHeight({
|
|
4699
|
+
unitId,
|
|
4700
|
+
subUnitId,
|
|
4701
|
+
ranges: suitableRanges,
|
|
4702
|
+
autoHeightRanges: suitableRanges,
|
|
4703
|
+
lazyAutoHeightRanges: remainingRanges
|
|
4704
|
+
});
|
|
4705
|
+
const autoHeightExecuteResult = sequenceExecute(autoHeightRedos, commandService);
|
|
4706
|
+
if (result.result && autoHeightExecuteResult.result) {
|
|
4707
|
+
redoMutations.push(...autoHeightRedos);
|
|
4708
|
+
undoMutations.push(...autoHeightUndos);
|
|
4499
4709
|
undoRedoService.pushUndoRedo({
|
|
4500
4710
|
unitID: unitId,
|
|
4501
|
-
undoMutations
|
|
4502
|
-
redoMutations
|
|
4711
|
+
undoMutations,
|
|
4712
|
+
redoMutations
|
|
4503
4713
|
});
|
|
4504
4714
|
return true;
|
|
4505
4715
|
}
|
|
@@ -4526,23 +4736,24 @@ const ClearSelectionFormatCommand = {
|
|
|
4526
4736
|
const { unitId, subUnitId } = target;
|
|
4527
4737
|
const ranges = (params === null || params === void 0 ? void 0 : params.ranges) || ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range));
|
|
4528
4738
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return false;
|
|
4739
|
+
const skeleton = accessor.get(SheetSkeletonService).getSkeleton(unitId, subUnitId);
|
|
4740
|
+
if (!skeleton) return false;
|
|
4529
4741
|
const commandService = accessor.get(ICommandService);
|
|
4530
4742
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
4531
4743
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
4532
|
-
const
|
|
4533
|
-
const
|
|
4534
|
-
const sequenceExecuteUndoList = [];
|
|
4744
|
+
const redoMutations = [];
|
|
4745
|
+
const undoMutations = [];
|
|
4535
4746
|
const clearMutationParams = {
|
|
4536
4747
|
subUnitId,
|
|
4537
4748
|
unitId,
|
|
4538
|
-
cellValue: generateNullCellStyle(
|
|
4749
|
+
cellValue: generateNullCellStyle(getVisibleRanges(ranges, accessor, unitId, subUnitId))
|
|
4539
4750
|
};
|
|
4540
4751
|
const undoClearMutationParams = SetRangeValuesUndoMutationFactory(accessor, clearMutationParams);
|
|
4541
|
-
|
|
4752
|
+
redoMutations.push({
|
|
4542
4753
|
id: SetRangeValuesMutation.id,
|
|
4543
4754
|
params: clearMutationParams
|
|
4544
4755
|
});
|
|
4545
|
-
|
|
4756
|
+
undoMutations.push({
|
|
4546
4757
|
id: SetRangeValuesMutation.id,
|
|
4547
4758
|
params: undoClearMutationParams
|
|
4548
4759
|
});
|
|
@@ -4550,13 +4761,25 @@ const ClearSelectionFormatCommand = {
|
|
|
4550
4761
|
id: ClearSelectionFormatCommand.id,
|
|
4551
4762
|
params
|
|
4552
4763
|
});
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4764
|
+
redoMutations.push(...intercepted.redos);
|
|
4765
|
+
undoMutations.unshift(...intercepted.undos);
|
|
4766
|
+
const result = sequenceExecute(redoMutations, commandService);
|
|
4767
|
+
const { suitableRanges, remainingRanges } = getSuitableRangesInView(ranges, skeleton);
|
|
4768
|
+
const { undos: autoHeightUndos, redos: autoHeightRedos } = sheetInterceptorService.generateMutationsOfAutoHeight({
|
|
4769
|
+
unitId,
|
|
4770
|
+
subUnitId,
|
|
4771
|
+
ranges: suitableRanges,
|
|
4772
|
+
autoHeightRanges: suitableRanges,
|
|
4773
|
+
lazyAutoHeightRanges: remainingRanges
|
|
4774
|
+
});
|
|
4775
|
+
const autoHeightExecuteResult = sequenceExecute(autoHeightRedos, commandService);
|
|
4776
|
+
if (result.result && autoHeightExecuteResult.result) {
|
|
4777
|
+
redoMutations.push(...autoHeightRedos);
|
|
4778
|
+
undoMutations.push(...autoHeightUndos);
|
|
4556
4779
|
undoRedoService.pushUndoRedo({
|
|
4557
4780
|
unitID: unitId,
|
|
4558
|
-
undoMutations
|
|
4559
|
-
redoMutations
|
|
4781
|
+
undoMutations,
|
|
4782
|
+
redoMutations
|
|
4560
4783
|
});
|
|
4561
4784
|
return true;
|
|
4562
4785
|
}
|
|
@@ -4909,7 +5132,7 @@ function getMoveRangeCommandMutations(accessor, params, options = {}) {
|
|
|
4909
5132
|
range: params.toRange,
|
|
4910
5133
|
primary: getPrimaryAfterMove(params.fromRange, params.toRange, fromWorksheet, toWorksheet)
|
|
4911
5134
|
}],
|
|
4912
|
-
type:
|
|
5135
|
+
type: 2
|
|
4913
5136
|
}
|
|
4914
5137
|
});
|
|
4915
5138
|
undos.push({
|
|
@@ -4921,7 +5144,7 @@ function getMoveRangeCommandMutations(accessor, params, options = {}) {
|
|
|
4921
5144
|
range: params.fromRange,
|
|
4922
5145
|
primary: getPrimaryForRange(params.fromRange, fromWorksheet)
|
|
4923
5146
|
}],
|
|
4924
|
-
type:
|
|
5147
|
+
type: 2
|
|
4925
5148
|
}
|
|
4926
5149
|
});
|
|
4927
5150
|
}
|
|
@@ -5103,15 +5326,7 @@ const SetRangeValuesCommand = {
|
|
|
5103
5326
|
...undos,
|
|
5104
5327
|
...autoHeightUndos
|
|
5105
5328
|
];
|
|
5106
|
-
if (currentSelections && currentSelections.length) undoMutations.push(
|
|
5107
|
-
id: SetSelectionsOperation.id,
|
|
5108
|
-
params: {
|
|
5109
|
-
unitId,
|
|
5110
|
-
subUnitId,
|
|
5111
|
-
selections: currentSelections,
|
|
5112
|
-
reveal: true
|
|
5113
|
-
}
|
|
5114
|
-
});
|
|
5329
|
+
if (currentSelections && currentSelections.length) undoMutations.push(followSelectionOperation(currentSelections[currentSelections.length - 1], workbook, worksheet));
|
|
5115
5330
|
undoRedoService.pushUndoRedo({
|
|
5116
5331
|
unitID: unitId,
|
|
5117
5332
|
undoMutations,
|
|
@@ -5569,7 +5784,7 @@ const InsertRangeMoveDownCommand = {
|
|
|
5569
5784
|
undoMutations.push(...(_sheetInterceptor$pre = sheetInterceptor.preUndos) !== null && _sheetInterceptor$pre !== void 0 ? _sheetInterceptor$pre : []);
|
|
5570
5785
|
redoMutations.unshift(...(_sheetInterceptor$pre2 = sheetInterceptor.preRedos) !== null && _sheetInterceptor$pre2 !== void 0 ? _sheetInterceptor$pre2 : []);
|
|
5571
5786
|
undoMutations.unshift(...sheetInterceptor.undos);
|
|
5572
|
-
if (sequenceExecute(redoMutations, commandService)) {
|
|
5787
|
+
if (sequenceExecute(redoMutations, commandService).result) {
|
|
5573
5788
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
5574
5789
|
id: InsertRangeMoveDownCommand.id,
|
|
5575
5790
|
params: { range }
|
|
@@ -6486,7 +6701,7 @@ const MoveRowsCommand = {
|
|
|
6486
6701
|
const setSelectionsParam = {
|
|
6487
6702
|
unitId,
|
|
6488
6703
|
subUnitId,
|
|
6489
|
-
type:
|
|
6704
|
+
type: 2,
|
|
6490
6705
|
selections: [{
|
|
6491
6706
|
range: destSelection,
|
|
6492
6707
|
primary: getPrimaryForRange(destSelection, worksheet),
|
|
@@ -6496,7 +6711,7 @@ const MoveRowsCommand = {
|
|
|
6496
6711
|
const undoSetSelectionsParam = {
|
|
6497
6712
|
unitId,
|
|
6498
6713
|
subUnitId,
|
|
6499
|
-
type:
|
|
6714
|
+
type: 2,
|
|
6500
6715
|
selections: [{
|
|
6501
6716
|
range: rangeToMove,
|
|
6502
6717
|
primary: beforePrimary,
|
|
@@ -6550,303 +6765,106 @@ const MoveColsCommand = {
|
|
|
6550
6765
|
const unitId = workbook.getUnitId();
|
|
6551
6766
|
const subUnitId = worksheet.getSheetId();
|
|
6552
6767
|
const errorService = accessor.get(ErrorService);
|
|
6553
|
-
const localeService = accessor.get(LocaleService);
|
|
6554
|
-
const rangeToMove = filteredSelections[0].range;
|
|
6555
|
-
const beforePrimary = filteredSelections[0].primary;
|
|
6556
|
-
const alignedRange = alignToMergedCellsBorders(rangeToMove, worksheet, false);
|
|
6557
|
-
if (!Rectangle.equals(rangeToMove, alignedRange)) {
|
|
6558
|
-
errorService.emit(localeService.t("sheets.info.partOfCell"));
|
|
6559
|
-
return false;
|
|
6560
|
-
}
|
|
6561
|
-
if (columnAcrossMergedCell(toCol, worksheet)) {
|
|
6562
|
-
errorService.emit(localeService.t("sheets.info.acrossMergedCell"));
|
|
6563
|
-
return false;
|
|
6564
|
-
}
|
|
6565
|
-
const destinationRange = {
|
|
6566
|
-
...rangeToMove,
|
|
6567
|
-
startColumn: toCol,
|
|
6568
|
-
endColumn: toCol + rangeToMove.endColumn - rangeToMove.startColumn
|
|
6569
|
-
};
|
|
6570
|
-
const moveColsParams = {
|
|
6571
|
-
unitId,
|
|
6572
|
-
subUnitId,
|
|
6573
|
-
sourceRange: rangeToMove,
|
|
6574
|
-
targetRange: destinationRange
|
|
6575
|
-
};
|
|
6576
|
-
const undoMoveColsParams = MoveColsMutationUndoFactory(accessor, moveColsParams);
|
|
6577
|
-
const commandService = accessor.get(ICommandService);
|
|
6578
|
-
const interceptorCommands = sheetInterceptorService.onCommandExecute({
|
|
6579
|
-
id: MoveColsCommand.id,
|
|
6580
|
-
params
|
|
6581
|
-
});
|
|
6582
|
-
const redos = [...(_interceptorCommands$3 = interceptorCommands.preRedos) !== null && _interceptorCommands$3 !== void 0 ? _interceptorCommands$3 : [], {
|
|
6583
|
-
id: MoveColsMutation.id,
|
|
6584
|
-
params: moveColsParams
|
|
6585
|
-
}];
|
|
6586
|
-
const undos = [...(_interceptorCommands$4 = interceptorCommands.preUndos) !== null && _interceptorCommands$4 !== void 0 ? _interceptorCommands$4 : [], {
|
|
6587
|
-
id: MoveColsMutation.id,
|
|
6588
|
-
params: undoMoveColsParams
|
|
6589
|
-
}];
|
|
6590
|
-
if (beforePrimary) {
|
|
6591
|
-
const count = rangeToMove.endColumn - rangeToMove.startColumn + 1;
|
|
6592
|
-
const destSelection = toCol - fromCol < 0 ? destinationRange : {
|
|
6593
|
-
...destinationRange,
|
|
6594
|
-
startColumn: destinationRange.startColumn - count,
|
|
6595
|
-
endColumn: destinationRange.endColumn - count
|
|
6596
|
-
};
|
|
6597
|
-
const setSelectionsParam = {
|
|
6598
|
-
unitId,
|
|
6599
|
-
subUnitId,
|
|
6600
|
-
type: SelectionMoveType.MOVE_END,
|
|
6601
|
-
selections: [{
|
|
6602
|
-
range: destSelection,
|
|
6603
|
-
primary: getPrimaryForRange(destSelection, worksheet),
|
|
6604
|
-
style: null
|
|
6605
|
-
}]
|
|
6606
|
-
};
|
|
6607
|
-
const undoSetSelectionsParam = {
|
|
6608
|
-
unitId,
|
|
6609
|
-
subUnitId,
|
|
6610
|
-
type: SelectionMoveType.MOVE_END,
|
|
6611
|
-
selections: [{
|
|
6612
|
-
range: rangeToMove,
|
|
6613
|
-
primary: beforePrimary,
|
|
6614
|
-
style: null
|
|
6615
|
-
}]
|
|
6616
|
-
};
|
|
6617
|
-
redos.push({
|
|
6618
|
-
id: SetSelectionsOperation.id,
|
|
6619
|
-
params: setSelectionsParam
|
|
6620
|
-
});
|
|
6621
|
-
undos.push({
|
|
6622
|
-
id: SetSelectionsOperation.id,
|
|
6623
|
-
params: undoSetSelectionsParam
|
|
6624
|
-
});
|
|
6625
|
-
}
|
|
6626
|
-
redos.push(...interceptorCommands.redos);
|
|
6627
|
-
undos.push(...interceptorCommands.undos);
|
|
6628
|
-
if (sequenceExecute(redos, commandService).result) {
|
|
6629
|
-
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
6630
|
-
id: MoveColsCommand.id,
|
|
6631
|
-
params
|
|
6632
|
-
});
|
|
6633
|
-
sequenceExecute(afterInterceptors.redos, commandService);
|
|
6634
|
-
redos.push(...afterInterceptors.redos);
|
|
6635
|
-
undos.push(...afterInterceptors.undos);
|
|
6636
|
-
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
6637
|
-
unitID: unitId,
|
|
6638
|
-
undoMutations: undos,
|
|
6639
|
-
redoMutations: redos
|
|
6640
|
-
});
|
|
6641
|
-
return true;
|
|
6642
|
-
}
|
|
6643
|
-
return false;
|
|
6644
|
-
}
|
|
6645
|
-
};
|
|
6646
|
-
function covertRangeToSelection(range) {
|
|
6647
|
-
return {
|
|
6648
|
-
range,
|
|
6649
|
-
primary: null,
|
|
6650
|
-
style: null
|
|
6651
|
-
};
|
|
6652
|
-
}
|
|
6653
|
-
|
|
6654
|
-
//#endregion
|
|
6655
|
-
//#region src/skeleton/skeleton.service.ts
|
|
6656
|
-
let SheetSkeletonService = class SheetSkeletonService extends Disposable {
|
|
6657
|
-
constructor(_injector, _univerInstanceService) {
|
|
6658
|
-
super();
|
|
6659
|
-
this._injector = _injector;
|
|
6660
|
-
this._univerInstanceService = _univerInstanceService;
|
|
6661
|
-
_defineProperty(this, "_sceneMap", /* @__PURE__ */ new Map());
|
|
6662
|
-
_defineProperty(this, "_sheetSkeletonParamStore", /* @__PURE__ */ new Map());
|
|
6663
|
-
_defineProperty(this, "_buildSkeleton$", new Subject());
|
|
6664
|
-
_defineProperty(this, "buildSkeleton$", this._buildSkeleton$.asObservable());
|
|
6665
|
-
this._init();
|
|
6666
|
-
}
|
|
6667
|
-
dispose() {
|
|
6668
|
-
super.dispose();
|
|
6669
|
-
this._sheetSkeletonParamStore.forEach((subUnitMap) => subUnitMap.forEach((skeletonParam) => skeletonParam.skeleton.dispose()));
|
|
6670
|
-
this._sheetSkeletonParamStore.clear();
|
|
6671
|
-
}
|
|
6672
|
-
_disposeByUnitId(unitId) {
|
|
6673
|
-
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6674
|
-
if (!sheetSkeletonMap) return;
|
|
6675
|
-
sheetSkeletonMap.forEach((skeletonParam) => skeletonParam.skeleton.dispose());
|
|
6676
|
-
this._sheetSkeletonParamStore.delete(unitId);
|
|
6677
|
-
}
|
|
6678
|
-
_init() {
|
|
6679
|
-
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((event) => this._initWorkbookSkeleton(event.unit)));
|
|
6680
|
-
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => this._disposeByUnitId(workbook.getUnitId())));
|
|
6681
|
-
}
|
|
6682
|
-
_initWorkbookSkeleton(workbook) {
|
|
6683
|
-
const unitId = workbook.getUnitId();
|
|
6684
|
-
this._initSheetsSkeleton(workbook);
|
|
6685
|
-
this.disposeWithMe(workbook.sheetCreated$.subscribe((worksheet) => {
|
|
6686
|
-
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6687
|
-
if (!sheetSkeletonMap) return;
|
|
6688
|
-
const sheetId = worksheet.getSheetId();
|
|
6689
|
-
const skeleton = this._buildSkeleton(worksheet, workbook.getStyles());
|
|
6690
|
-
sheetSkeletonMap.set(sheetId, {
|
|
6691
|
-
unitId,
|
|
6692
|
-
sheetId,
|
|
6693
|
-
skeleton,
|
|
6694
|
-
dirty: false
|
|
6695
|
-
});
|
|
6696
|
-
}));
|
|
6697
|
-
this.disposeWithMe(workbook.sheetDisposed$.subscribe((worksheet) => {
|
|
6698
|
-
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6699
|
-
if (!sheetSkeletonMap) return;
|
|
6700
|
-
const sheetId = worksheet.getSheetId();
|
|
6701
|
-
const skeletonParam = sheetSkeletonMap.get(sheetId);
|
|
6702
|
-
if (skeletonParam) skeletonParam.skeleton.dispose();
|
|
6703
|
-
sheetSkeletonMap.delete(sheetId);
|
|
6704
|
-
}));
|
|
6705
|
-
}
|
|
6706
|
-
_initSheetsSkeleton(workbook) {
|
|
6707
|
-
const unitId = workbook.getUnitId();
|
|
6708
|
-
const sheetSkeletonMap = /* @__PURE__ */ new Map();
|
|
6709
|
-
workbook.getWorksheets().forEach((worksheet) => {
|
|
6710
|
-
const sheetId = worksheet.getSheetId();
|
|
6711
|
-
const skeleton = this._buildSkeleton(worksheet, workbook.getStyles());
|
|
6712
|
-
sheetSkeletonMap.set(sheetId, {
|
|
6713
|
-
unitId,
|
|
6714
|
-
sheetId,
|
|
6715
|
-
skeleton,
|
|
6716
|
-
dirty: false
|
|
6717
|
-
});
|
|
6718
|
-
});
|
|
6719
|
-
this._sheetSkeletonParamStore.set(unitId, sheetSkeletonMap);
|
|
6720
|
-
}
|
|
6721
|
-
_buildSkeleton(worksheet, styles) {
|
|
6722
|
-
const spreadsheetSkeleton = this._injector.createInstance(SpreadsheetSkeleton, worksheet, styles);
|
|
6723
|
-
const unitId = worksheet.getUnitId();
|
|
6724
|
-
const scene = this._sceneMap.get(unitId);
|
|
6725
|
-
if (scene) spreadsheetSkeleton.setScene(scene);
|
|
6726
|
-
this._buildSkeleton$.next(spreadsheetSkeleton);
|
|
6727
|
-
return spreadsheetSkeleton;
|
|
6728
|
-
}
|
|
6729
|
-
setScene(unitId, scene) {
|
|
6730
|
-
this._sceneMap.set(unitId, scene);
|
|
6731
|
-
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6732
|
-
if (!sheetSkeletonMap) return;
|
|
6733
|
-
sheetSkeletonMap.forEach((skeletonParam) => skeletonParam.skeleton.setScene(scene));
|
|
6734
|
-
}
|
|
6735
|
-
getSkeletonsByUnitId(unitId) {
|
|
6736
|
-
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6737
|
-
if (!sheetSkeletonMap) return [];
|
|
6738
|
-
return Array.from(sheetSkeletonMap.values()).map((param) => param.skeleton);
|
|
6739
|
-
}
|
|
6740
|
-
getSkeleton(unitId, subUnitId) {
|
|
6741
|
-
var _this$getSkeletonPara;
|
|
6742
|
-
return (_this$getSkeletonPara = this.getSkeletonParam(unitId, subUnitId)) === null || _this$getSkeletonPara === void 0 ? void 0 : _this$getSkeletonPara.skeleton;
|
|
6743
|
-
}
|
|
6744
|
-
getSkeletonParam(unitId, subUnitId) {
|
|
6745
|
-
const sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6746
|
-
if (!sheetSkeletonMap) return;
|
|
6747
|
-
return sheetSkeletonMap.get(subUnitId);
|
|
6748
|
-
}
|
|
6749
|
-
newSkeleton(unitId, subUnitId, worksheet, styles) {
|
|
6750
|
-
return this.newSkeletonParam(unitId, subUnitId, worksheet, styles).skeleton;
|
|
6751
|
-
}
|
|
6752
|
-
newSkeletonParam(unitId, subUnitId, worksheet, styles) {
|
|
6753
|
-
const skeleton = this._buildSkeleton(worksheet, styles);
|
|
6754
|
-
let sheetSkeletonMap = this._sheetSkeletonParamStore.get(unitId);
|
|
6755
|
-
if (!sheetSkeletonMap) {
|
|
6756
|
-
sheetSkeletonMap = /* @__PURE__ */ new Map();
|
|
6757
|
-
this._sheetSkeletonParamStore.set(unitId, sheetSkeletonMap);
|
|
6758
|
-
}
|
|
6759
|
-
const skeletonParam = {
|
|
6760
|
-
unitId,
|
|
6761
|
-
sheetId: subUnitId,
|
|
6762
|
-
skeleton,
|
|
6763
|
-
dirty: false
|
|
6764
|
-
};
|
|
6765
|
-
sheetSkeletonMap.set(subUnitId, skeletonParam);
|
|
6766
|
-
return skeletonParam;
|
|
6767
|
-
}
|
|
6768
|
-
ensureSkeleton(unitId, subUnitId) {
|
|
6769
|
-
const skeleton = this.getSkeleton(unitId, subUnitId);
|
|
6770
|
-
if (skeleton) return skeleton;
|
|
6771
|
-
const workbook = this._univerInstanceService.getUnit(unitId);
|
|
6772
|
-
if (!workbook) return;
|
|
6773
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
6774
|
-
if (!worksheet) return;
|
|
6775
|
-
return this.newSkeleton(unitId, subUnitId, worksheet, workbook.getStyles());
|
|
6776
|
-
}
|
|
6777
|
-
};
|
|
6778
|
-
SheetSkeletonService = __decorate([__decorateParam(0, Inject(Injector)), __decorateParam(1, Inject(IUniverInstanceService))], SheetSkeletonService);
|
|
6779
|
-
|
|
6780
|
-
//#endregion
|
|
6781
|
-
//#region src/commands/commands/util.ts
|
|
6782
|
-
function getRangesHeight(ranges, worksheet) {
|
|
6783
|
-
const cellHeights = new ObjectMatrix();
|
|
6784
|
-
ranges.map((range) => Range.transformRange(range, worksheet)).forEach((range) => {
|
|
6785
|
-
Range.foreach(range, (row, col) => {
|
|
6786
|
-
const cellHeight = worksheet.getCellHeight(row, col);
|
|
6787
|
-
if (cellHeight) cellHeights.setValue(row, col, cellHeight);
|
|
6788
|
-
});
|
|
6789
|
-
});
|
|
6790
|
-
return cellHeights;
|
|
6791
|
-
}
|
|
6792
|
-
const MAX_RANGE_CELL_COUNT = 1e4;
|
|
6793
|
-
function getSuitableRangesInView(ranges, skeleton) {
|
|
6794
|
-
if (!skeleton) return {
|
|
6795
|
-
suitableRanges: ranges,
|
|
6796
|
-
remainingRanges: []
|
|
6797
|
-
};
|
|
6798
|
-
const colCount = skeleton.worksheet.getColumnCount();
|
|
6799
|
-
const maxRowCount = Math.ceil(MAX_RANGE_CELL_COUNT / colCount);
|
|
6800
|
-
const suitableRanges = [];
|
|
6801
|
-
const remainingRanges = [];
|
|
6802
|
-
const row = skeleton.getOffsetRelativeToRowCol(0, skeleton.scrollY).row;
|
|
6803
|
-
const rangesWithDistance = ranges.map((range) => {
|
|
6804
|
-
let distance;
|
|
6805
|
-
if (row >= range.startRow && row <= range.endRow) distance = 0;
|
|
6806
|
-
else if (row < range.startRow) distance = range.startRow - row;
|
|
6807
|
-
else distance = row - range.endRow;
|
|
6808
|
-
return {
|
|
6809
|
-
range,
|
|
6810
|
-
distance,
|
|
6811
|
-
rowCount: range.endRow - range.startRow + 1
|
|
6768
|
+
const localeService = accessor.get(LocaleService);
|
|
6769
|
+
const rangeToMove = filteredSelections[0].range;
|
|
6770
|
+
const beforePrimary = filteredSelections[0].primary;
|
|
6771
|
+
const alignedRange = alignToMergedCellsBorders(rangeToMove, worksheet, false);
|
|
6772
|
+
if (!Rectangle.equals(rangeToMove, alignedRange)) {
|
|
6773
|
+
errorService.emit(localeService.t("sheets.info.partOfCell"));
|
|
6774
|
+
return false;
|
|
6775
|
+
}
|
|
6776
|
+
if (columnAcrossMergedCell(toCol, worksheet)) {
|
|
6777
|
+
errorService.emit(localeService.t("sheets.info.acrossMergedCell"));
|
|
6778
|
+
return false;
|
|
6779
|
+
}
|
|
6780
|
+
const destinationRange = {
|
|
6781
|
+
...rangeToMove,
|
|
6782
|
+
startColumn: toCol,
|
|
6783
|
+
endColumn: toCol + rangeToMove.endColumn - rangeToMove.startColumn
|
|
6812
6784
|
};
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6785
|
+
const moveColsParams = {
|
|
6786
|
+
unitId,
|
|
6787
|
+
subUnitId,
|
|
6788
|
+
sourceRange: rangeToMove,
|
|
6789
|
+
targetRange: destinationRange
|
|
6790
|
+
};
|
|
6791
|
+
const undoMoveColsParams = MoveColsMutationUndoFactory(accessor, moveColsParams);
|
|
6792
|
+
const commandService = accessor.get(ICommandService);
|
|
6793
|
+
const interceptorCommands = sheetInterceptorService.onCommandExecute({
|
|
6794
|
+
id: MoveColsCommand.id,
|
|
6795
|
+
params
|
|
6796
|
+
});
|
|
6797
|
+
const redos = [...(_interceptorCommands$3 = interceptorCommands.preRedos) !== null && _interceptorCommands$3 !== void 0 ? _interceptorCommands$3 : [], {
|
|
6798
|
+
id: MoveColsMutation.id,
|
|
6799
|
+
params: moveColsParams
|
|
6800
|
+
}];
|
|
6801
|
+
const undos = [...(_interceptorCommands$4 = interceptorCommands.preUndos) !== null && _interceptorCommands$4 !== void 0 ? _interceptorCommands$4 : [], {
|
|
6802
|
+
id: MoveColsMutation.id,
|
|
6803
|
+
params: undoMoveColsParams
|
|
6804
|
+
}];
|
|
6805
|
+
if (beforePrimary) {
|
|
6806
|
+
const count = rangeToMove.endColumn - rangeToMove.startColumn + 1;
|
|
6807
|
+
const destSelection = toCol - fromCol < 0 ? destinationRange : {
|
|
6808
|
+
...destinationRange,
|
|
6809
|
+
startColumn: destinationRange.startColumn - count,
|
|
6810
|
+
endColumn: destinationRange.endColumn - count
|
|
6828
6811
|
};
|
|
6829
|
-
const
|
|
6830
|
-
|
|
6831
|
-
|
|
6812
|
+
const setSelectionsParam = {
|
|
6813
|
+
unitId,
|
|
6814
|
+
subUnitId,
|
|
6815
|
+
type: 2,
|
|
6816
|
+
selections: [{
|
|
6817
|
+
range: destSelection,
|
|
6818
|
+
primary: getPrimaryForRange(destSelection, worksheet),
|
|
6819
|
+
style: null
|
|
6820
|
+
}]
|
|
6832
6821
|
};
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6822
|
+
const undoSetSelectionsParam = {
|
|
6823
|
+
unitId,
|
|
6824
|
+
subUnitId,
|
|
6825
|
+
type: 2,
|
|
6826
|
+
selections: [{
|
|
6827
|
+
range: rangeToMove,
|
|
6828
|
+
primary: beforePrimary,
|
|
6829
|
+
style: null
|
|
6830
|
+
}]
|
|
6831
|
+
};
|
|
6832
|
+
redos.push({
|
|
6833
|
+
id: SetSelectionsOperation.id,
|
|
6834
|
+
params: setSelectionsParam
|
|
6835
|
+
});
|
|
6836
|
+
undos.push({
|
|
6837
|
+
id: SetSelectionsOperation.id,
|
|
6838
|
+
params: undoSetSelectionsParam
|
|
6839
|
+
});
|
|
6840
|
+
}
|
|
6841
|
+
redos.push(...interceptorCommands.redos);
|
|
6842
|
+
undos.push(...interceptorCommands.undos);
|
|
6843
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
6844
|
+
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
6845
|
+
id: MoveColsCommand.id,
|
|
6846
|
+
params
|
|
6847
|
+
});
|
|
6848
|
+
sequenceExecute(afterInterceptors.redos, commandService);
|
|
6849
|
+
redos.push(...afterInterceptors.redos);
|
|
6850
|
+
undos.push(...afterInterceptors.undos);
|
|
6851
|
+
accessor.get(IUndoRedoService).pushUndoRedo({
|
|
6852
|
+
unitID: unitId,
|
|
6853
|
+
undoMutations: undos,
|
|
6854
|
+
redoMutations: redos
|
|
6855
|
+
});
|
|
6856
|
+
return true;
|
|
6857
|
+
}
|
|
6858
|
+
return false;
|
|
6837
6859
|
}
|
|
6860
|
+
};
|
|
6861
|
+
function covertRangeToSelection(range) {
|
|
6838
6862
|
return {
|
|
6839
|
-
|
|
6840
|
-
|
|
6863
|
+
range,
|
|
6864
|
+
primary: null,
|
|
6865
|
+
style: null
|
|
6841
6866
|
};
|
|
6842
6867
|
}
|
|
6843
|
-
function countCells(cellMatrix) {
|
|
6844
|
-
let count = 0;
|
|
6845
|
-
cellMatrix.forEach(() => {
|
|
6846
|
-
count++;
|
|
6847
|
-
});
|
|
6848
|
-
return count;
|
|
6849
|
-
}
|
|
6850
6868
|
|
|
6851
6869
|
//#endregion
|
|
6852
6870
|
//#region src/commands/commands/reorder-range.command.ts
|
|
@@ -7071,9 +7089,9 @@ const handleMoveRows = (params, targetRange) => {
|
|
|
7071
7089
|
start: _targetRange.startRow,
|
|
7072
7090
|
end: _targetRange.endRow
|
|
7073
7091
|
});
|
|
7074
|
-
if (result === null) return [{ type:
|
|
7092
|
+
if (result === null) return [{ type: 1 }];
|
|
7075
7093
|
return [{
|
|
7076
|
-
type:
|
|
7094
|
+
type: 3,
|
|
7077
7095
|
step: result.step || 0,
|
|
7078
7096
|
length: result.length || 0
|
|
7079
7097
|
}];
|
|
@@ -7128,9 +7146,9 @@ const handleMoveCols = (params, targetRange) => {
|
|
|
7128
7146
|
start: _targetRange.startColumn,
|
|
7129
7147
|
end: _targetRange.endColumn
|
|
7130
7148
|
});
|
|
7131
|
-
if (result === null) return [{ type:
|
|
7149
|
+
if (result === null) return [{ type: 1 }];
|
|
7132
7150
|
return [{
|
|
7133
|
-
type:
|
|
7151
|
+
type: 2,
|
|
7134
7152
|
step: result.step || 0,
|
|
7135
7153
|
length: result.length || 0
|
|
7136
7154
|
}];
|
|
@@ -7154,13 +7172,13 @@ const handleMoveRange = (param, targetRange) => {
|
|
|
7154
7172
|
const fromRange = (_param$params2 = param.params) === null || _param$params2 === void 0 ? void 0 : _param$params2.fromRange;
|
|
7155
7173
|
if (!toRange || !fromRange) return [];
|
|
7156
7174
|
const operators = [];
|
|
7157
|
-
if (Rectangle.contains(toRange, targetRange)) operators.push({ type:
|
|
7175
|
+
if (Rectangle.contains(toRange, targetRange)) operators.push({ type: 1 });
|
|
7158
7176
|
if (Rectangle.contains(fromRange, targetRange)) {
|
|
7159
|
-
operators.push({ type:
|
|
7177
|
+
operators.push({ type: 1 });
|
|
7160
7178
|
const relativeRange = Rectangle.getRelativeRange(targetRange, fromRange);
|
|
7161
7179
|
const positionRange = Rectangle.getPositionRange(relativeRange, toRange);
|
|
7162
7180
|
return [{
|
|
7163
|
-
type:
|
|
7181
|
+
type: 0,
|
|
7164
7182
|
range: positionRange
|
|
7165
7183
|
}];
|
|
7166
7184
|
}
|
|
@@ -7244,11 +7262,11 @@ const handleIRemoveCol = (param, targetRange) => {
|
|
|
7244
7262
|
if (!range) return [];
|
|
7245
7263
|
const operators = [];
|
|
7246
7264
|
const result = handleBaseRemoveRange(range, targetRange);
|
|
7247
|
-
if (!result) operators.push({ type:
|
|
7265
|
+
if (!result) operators.push({ type: 1 });
|
|
7248
7266
|
else {
|
|
7249
7267
|
const { step, length } = result;
|
|
7250
7268
|
operators.push({
|
|
7251
|
-
type:
|
|
7269
|
+
type: 2,
|
|
7252
7270
|
step,
|
|
7253
7271
|
length
|
|
7254
7272
|
});
|
|
@@ -7285,11 +7303,11 @@ const handleIRemoveRow = (param, targetRange, rangeFilteredRows) => {
|
|
|
7285
7303
|
} else _handleBaseRemoveRange(range);
|
|
7286
7304
|
function _handleBaseRemoveRange(removeRange) {
|
|
7287
7305
|
const result = handleBaseRemoveRange(rotateRange(removeRange), rotateRange(targetRange));
|
|
7288
|
-
if (!result) operators.push({ type:
|
|
7306
|
+
if (!result) operators.push({ type: 1 });
|
|
7289
7307
|
else {
|
|
7290
7308
|
const { step, length } = result;
|
|
7291
7309
|
operators.push({
|
|
7292
|
-
type:
|
|
7310
|
+
type: 3,
|
|
7293
7311
|
step,
|
|
7294
7312
|
length
|
|
7295
7313
|
});
|
|
@@ -7306,7 +7324,7 @@ const handleReorderRange = (param, targetRange) => {
|
|
|
7306
7324
|
for (const k in order) if (order[k] === targetRow) {
|
|
7307
7325
|
const toRow = Number(k);
|
|
7308
7326
|
operators.push({
|
|
7309
|
-
type:
|
|
7327
|
+
type: 3,
|
|
7310
7328
|
step: toRow - targetRow,
|
|
7311
7329
|
length: 0
|
|
7312
7330
|
});
|
|
@@ -7348,13 +7366,13 @@ const handleBaseInsertRange = (_insertRange, _targetRange) => {
|
|
|
7348
7366
|
};
|
|
7349
7367
|
function handleBaseMoveRange(fromRange, toRange, targetRange) {
|
|
7350
7368
|
const operators = [];
|
|
7351
|
-
if (Rectangle.contains(toRange, targetRange)) operators.push({ type:
|
|
7369
|
+
if (Rectangle.contains(toRange, targetRange)) operators.push({ type: 1 });
|
|
7352
7370
|
if (Rectangle.contains(fromRange, targetRange)) {
|
|
7353
|
-
operators.push({ type:
|
|
7371
|
+
operators.push({ type: 1 });
|
|
7354
7372
|
const relativeRange = Rectangle.getRelativeRange(targetRange, fromRange);
|
|
7355
7373
|
const positionRange = Rectangle.getPositionRange(relativeRange, toRange);
|
|
7356
7374
|
return [{
|
|
7357
|
-
type:
|
|
7375
|
+
type: 0,
|
|
7358
7376
|
range: positionRange
|
|
7359
7377
|
}];
|
|
7360
7378
|
}
|
|
@@ -7367,7 +7385,7 @@ const handleInsertRow = (param, targetRange) => {
|
|
|
7367
7385
|
const operators = [];
|
|
7368
7386
|
const { step, length } = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange));
|
|
7369
7387
|
operators.push({
|
|
7370
|
-
type:
|
|
7388
|
+
type: 3,
|
|
7371
7389
|
step,
|
|
7372
7390
|
length
|
|
7373
7391
|
});
|
|
@@ -7380,7 +7398,7 @@ const handleInsertCol = (param, targetRange) => {
|
|
|
7380
7398
|
const operators = [];
|
|
7381
7399
|
const { step, length } = handleBaseInsertRange(range, targetRange);
|
|
7382
7400
|
operators.push({
|
|
7383
|
-
type:
|
|
7401
|
+
type: 2,
|
|
7384
7402
|
step,
|
|
7385
7403
|
length
|
|
7386
7404
|
});
|
|
@@ -7393,7 +7411,7 @@ const handleInsertRangeMoveDown = (param, targetRange) => {
|
|
|
7393
7411
|
const operators = [];
|
|
7394
7412
|
const { step, length } = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange));
|
|
7395
7413
|
operators.push({
|
|
7396
|
-
type:
|
|
7414
|
+
type: 3,
|
|
7397
7415
|
step,
|
|
7398
7416
|
length
|
|
7399
7417
|
});
|
|
@@ -7430,7 +7448,7 @@ const handleInsertRangeMoveRight = (param, targetRange) => {
|
|
|
7430
7448
|
const operators = [];
|
|
7431
7449
|
const { step, length } = handleBaseInsertRange(range, targetRange);
|
|
7432
7450
|
operators.push({
|
|
7433
|
-
type:
|
|
7451
|
+
type: 2,
|
|
7434
7452
|
step,
|
|
7435
7453
|
length
|
|
7436
7454
|
});
|
|
@@ -7466,11 +7484,11 @@ const handleDeleteRangeMoveLeft = (param, targetRange) => {
|
|
|
7466
7484
|
if (!range) return [];
|
|
7467
7485
|
const operators = [];
|
|
7468
7486
|
const result = handleBaseRemoveRange(range, targetRange);
|
|
7469
|
-
if (!result) operators.push({ type:
|
|
7487
|
+
if (!result) operators.push({ type: 1 });
|
|
7470
7488
|
else {
|
|
7471
7489
|
const { step, length } = result;
|
|
7472
7490
|
operators.push({
|
|
7473
|
-
type:
|
|
7491
|
+
type: 2,
|
|
7474
7492
|
step,
|
|
7475
7493
|
length
|
|
7476
7494
|
});
|
|
@@ -7512,11 +7530,11 @@ const handleDeleteRangeMoveUp = (param, targetRange) => {
|
|
|
7512
7530
|
if (!range) return [];
|
|
7513
7531
|
const operators = [];
|
|
7514
7532
|
const result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
|
|
7515
|
-
if (!result) operators.push({ type:
|
|
7533
|
+
if (!result) operators.push({ type: 1 });
|
|
7516
7534
|
else {
|
|
7517
7535
|
const { step, length } = result;
|
|
7518
7536
|
operators.push({
|
|
7519
|
-
type:
|
|
7537
|
+
type: 3,
|
|
7520
7538
|
step,
|
|
7521
7539
|
length
|
|
7522
7540
|
});
|
|
@@ -7633,20 +7651,20 @@ const runRefRangeMutations = (operators, range) => {
|
|
|
7633
7651
|
let result = { ...range };
|
|
7634
7652
|
operators.forEach((operator) => {
|
|
7635
7653
|
switch (operator.type) {
|
|
7636
|
-
case
|
|
7654
|
+
case 1:
|
|
7637
7655
|
result = null;
|
|
7638
7656
|
break;
|
|
7639
|
-
case
|
|
7657
|
+
case 2:
|
|
7640
7658
|
if (!result) return;
|
|
7641
7659
|
result.startColumn += operator.step;
|
|
7642
7660
|
result.endColumn += operator.step + (operator.length || 0);
|
|
7643
7661
|
break;
|
|
7644
|
-
case
|
|
7662
|
+
case 3:
|
|
7645
7663
|
if (!result) return;
|
|
7646
7664
|
result.startRow += operator.step;
|
|
7647
7665
|
result.endRow += operator.step + (operator.length || 0);
|
|
7648
7666
|
break;
|
|
7649
|
-
case
|
|
7667
|
+
case 0:
|
|
7650
7668
|
result = operator.range;
|
|
7651
7669
|
break;
|
|
7652
7670
|
}
|
|
@@ -7747,11 +7765,11 @@ function adjustRangeOnMutation(range, mutation) {
|
|
|
7747
7765
|
let baseRangeOperator = {
|
|
7748
7766
|
length: 0,
|
|
7749
7767
|
step: 0,
|
|
7750
|
-
type:
|
|
7768
|
+
type: 4
|
|
7751
7769
|
};
|
|
7752
7770
|
switch (id) {
|
|
7753
7771
|
case RemoveSheetMutation.id:
|
|
7754
|
-
baseRangeOperator.type =
|
|
7772
|
+
baseRangeOperator.type = 1;
|
|
7755
7773
|
break;
|
|
7756
7774
|
case MoveRowsMutation.id:
|
|
7757
7775
|
baseRangeOperator = handleBaseMoveRowsCols({
|
|
@@ -7764,7 +7782,7 @@ function adjustRangeOnMutation(range, mutation) {
|
|
|
7764
7782
|
start: range.startRow,
|
|
7765
7783
|
end: range.endRow
|
|
7766
7784
|
});
|
|
7767
|
-
baseRangeOperator.type =
|
|
7785
|
+
baseRangeOperator.type = 3;
|
|
7768
7786
|
break;
|
|
7769
7787
|
case MoveColsMutation.id:
|
|
7770
7788
|
baseRangeOperator = handleBaseMoveRowsCols({
|
|
@@ -7777,33 +7795,33 @@ function adjustRangeOnMutation(range, mutation) {
|
|
|
7777
7795
|
start: range.startColumn,
|
|
7778
7796
|
end: range.endColumn
|
|
7779
7797
|
});
|
|
7780
|
-
baseRangeOperator.type =
|
|
7798
|
+
baseRangeOperator.type = 2;
|
|
7781
7799
|
break;
|
|
7782
7800
|
case RemoveColMutation.id:
|
|
7783
7801
|
baseRangeOperator = handleBaseRemoveRange(params.range, range);
|
|
7784
|
-
if (baseRangeOperator) baseRangeOperator.type =
|
|
7802
|
+
if (baseRangeOperator) baseRangeOperator.type = 2;
|
|
7785
7803
|
else baseRangeOperator = {
|
|
7786
7804
|
step: 0,
|
|
7787
7805
|
length: 0,
|
|
7788
|
-
type:
|
|
7806
|
+
type: 1
|
|
7789
7807
|
};
|
|
7790
7808
|
break;
|
|
7791
7809
|
case RemoveRowMutation.id:
|
|
7792
7810
|
baseRangeOperator = handleBaseRemoveRange(rotateRange(params.range), rotateRange(range));
|
|
7793
|
-
if (baseRangeOperator) baseRangeOperator.type =
|
|
7811
|
+
if (baseRangeOperator) baseRangeOperator.type = 3;
|
|
7794
7812
|
else baseRangeOperator = {
|
|
7795
7813
|
step: 0,
|
|
7796
7814
|
length: 0,
|
|
7797
|
-
type:
|
|
7815
|
+
type: 1
|
|
7798
7816
|
};
|
|
7799
7817
|
break;
|
|
7800
7818
|
case InsertRowMutation.id:
|
|
7801
7819
|
baseRangeOperator = handleBaseInsertRange(rotateRange(params.range), rotateRange(range));
|
|
7802
|
-
baseRangeOperator.type =
|
|
7820
|
+
baseRangeOperator.type = 3;
|
|
7803
7821
|
break;
|
|
7804
7822
|
case InsertColMutation.id:
|
|
7805
7823
|
baseRangeOperator = handleBaseInsertRange(params.range, range);
|
|
7806
|
-
baseRangeOperator.type =
|
|
7824
|
+
baseRangeOperator.type = 2;
|
|
7807
7825
|
break;
|
|
7808
7826
|
case MoveRangeMutation.id:
|
|
7809
7827
|
baseRangeOperator = handleBaseMoveRange(params.fromRange || new ObjectMatrix(params.from).getRange(), params.toRange || new ObjectMatrix(params.to).getRange(), range);
|
|
@@ -9532,7 +9550,7 @@ const AddMergeRedoSelectionsOperationFactory = (accessor, params, ranges) => {
|
|
|
9532
9550
|
const setSelectionsParamByRedo = {
|
|
9533
9551
|
unitId,
|
|
9534
9552
|
subUnitId,
|
|
9535
|
-
type:
|
|
9553
|
+
type: 3,
|
|
9536
9554
|
selections: selectionsByRedo
|
|
9537
9555
|
};
|
|
9538
9556
|
return {
|
|
@@ -9552,7 +9570,7 @@ const AddMergeUndoSelectionsOperationFactory = (accessor, params) => {
|
|
|
9552
9570
|
const setSelectionsParamByUndo = {
|
|
9553
9571
|
unitId,
|
|
9554
9572
|
subUnitId,
|
|
9555
|
-
type:
|
|
9573
|
+
type: 3,
|
|
9556
9574
|
selections: [...selectionsBeforeMutation]
|
|
9557
9575
|
};
|
|
9558
9576
|
return {
|
|
@@ -9627,7 +9645,7 @@ const RemoveWorksheetMergeCommand = {
|
|
|
9627
9645
|
unitId,
|
|
9628
9646
|
subUnitId,
|
|
9629
9647
|
selections: redoSelections,
|
|
9630
|
-
type:
|
|
9648
|
+
type: 3
|
|
9631
9649
|
}
|
|
9632
9650
|
}
|
|
9633
9651
|
];
|
|
@@ -9646,11 +9664,11 @@ const RemoveWorksheetMergeCommand = {
|
|
|
9646
9664
|
unitId,
|
|
9647
9665
|
subUnitId,
|
|
9648
9666
|
selections: undoSelections,
|
|
9649
|
-
type:
|
|
9667
|
+
type: 3
|
|
9650
9668
|
}
|
|
9651
9669
|
}
|
|
9652
9670
|
];
|
|
9653
|
-
if (sequenceExecute(redoMutations, commandService)) {
|
|
9671
|
+
if (sequenceExecute(redoMutations, commandService).result) {
|
|
9654
9672
|
undoRedoService.pushUndoRedo({
|
|
9655
9673
|
unitID: unitId,
|
|
9656
9674
|
undoMutations,
|
|
@@ -9675,12 +9693,6 @@ function getSetRangeStyleParamsForRemoveMerge(worksheet, ranges) {
|
|
|
9675
9693
|
|
|
9676
9694
|
//#endregion
|
|
9677
9695
|
//#region src/commands/commands/add-worksheet-merge.command.ts
|
|
9678
|
-
let MergeType = /* @__PURE__ */ function(MergeType) {
|
|
9679
|
-
MergeType["MergeAll"] = "mergeAll";
|
|
9680
|
-
MergeType["MergeVertical"] = "mergeVertical";
|
|
9681
|
-
MergeType["MergeHorizontal"] = "mergeHorizontal";
|
|
9682
|
-
return MergeType;
|
|
9683
|
-
}({});
|
|
9684
9696
|
function checkCellContentInRanges(worksheet, ranges) {
|
|
9685
9697
|
return ranges.some((range) => checkCellContentInRange(worksheet, range));
|
|
9686
9698
|
}
|
|
@@ -9831,8 +9843,7 @@ const AddWorksheetMergeAllCommand = {
|
|
|
9831
9843
|
id: "sheet.command.add-worksheet-merge-all",
|
|
9832
9844
|
handler: async (accessor) => {
|
|
9833
9845
|
var _selectionManagerServ;
|
|
9834
|
-
const
|
|
9835
|
-
const mergeableSelections = getMergeableSelectionsByType(MergeType.MergeAll, selections);
|
|
9846
|
+
const mergeableSelections = getMergeableSelectionsByType("mergeAll", (_selectionManagerServ = accessor.get(SheetsSelectionsService).getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range));
|
|
9836
9847
|
if (!(mergeableSelections === null || mergeableSelections === void 0 ? void 0 : mergeableSelections.length)) return false;
|
|
9837
9848
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
9838
9849
|
if (!target) return false;
|
|
@@ -9851,8 +9862,7 @@ const AddWorksheetMergeVerticalCommand = {
|
|
|
9851
9862
|
id: "sheet.command.add-worksheet-merge-vertical",
|
|
9852
9863
|
handler: async (accessor) => {
|
|
9853
9864
|
var _selectionManagerServ2;
|
|
9854
|
-
const
|
|
9855
|
-
const mergeableSelections = getMergeableSelectionsByType(MergeType.MergeVertical, selections);
|
|
9865
|
+
const mergeableSelections = getMergeableSelectionsByType("mergeVertical", (_selectionManagerServ2 = accessor.get(SheetsSelectionsService).getCurrentSelections()) === null || _selectionManagerServ2 === void 0 ? void 0 : _selectionManagerServ2.map((s) => s.range));
|
|
9856
9866
|
if (!(mergeableSelections === null || mergeableSelections === void 0 ? void 0 : mergeableSelections.length)) return false;
|
|
9857
9867
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
9858
9868
|
if (!target) return false;
|
|
@@ -9872,8 +9882,7 @@ const AddWorksheetMergeHorizontalCommand = {
|
|
|
9872
9882
|
id: "sheet.command.add-worksheet-merge-horizontal",
|
|
9873
9883
|
handler: async (accessor) => {
|
|
9874
9884
|
var _selectionManagerServ3;
|
|
9875
|
-
const
|
|
9876
|
-
const mergeableSelections = getMergeableSelectionsByType(MergeType.MergeHorizontal, selections);
|
|
9885
|
+
const mergeableSelections = getMergeableSelectionsByType("mergeHorizontal", (_selectionManagerServ3 = accessor.get(SheetsSelectionsService).getCurrentSelections()) === null || _selectionManagerServ3 === void 0 ? void 0 : _selectionManagerServ3.map((s) => s.range));
|
|
9877
9886
|
if (!(mergeableSelections === null || mergeableSelections === void 0 ? void 0 : mergeableSelections.length)) return false;
|
|
9878
9887
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
9879
9888
|
if (!target) return false;
|
|
@@ -9918,15 +9927,15 @@ function addMergeCellsUtil(injector, unitId, subUnitId, ranges, options = {}) {
|
|
|
9918
9927
|
}
|
|
9919
9928
|
function getMergeableSelectionsByType(type, selections) {
|
|
9920
9929
|
if (!selections) return null;
|
|
9921
|
-
if (type ===
|
|
9930
|
+
if (type === "mergeAll") return selections.filter((selection) => {
|
|
9922
9931
|
if (selection.startRow === selection.endRow && selection.startColumn === selection.endColumn) return false;
|
|
9923
9932
|
return true;
|
|
9924
9933
|
});
|
|
9925
|
-
else if (type ===
|
|
9934
|
+
else if (type === "mergeVertical") return selections.filter((selection) => {
|
|
9926
9935
|
if (selection.startRow === selection.endRow) return false;
|
|
9927
9936
|
return true;
|
|
9928
9937
|
});
|
|
9929
|
-
else if (type ===
|
|
9938
|
+
else if (type === "mergeHorizontal") return selections.filter((selection) => {
|
|
9930
9939
|
if (selection.startColumn === selection.endColumn) return false;
|
|
9931
9940
|
return true;
|
|
9932
9941
|
});
|
|
@@ -11315,6 +11324,7 @@ function generateNullCellValueRowCol$1(range) {
|
|
|
11315
11324
|
cols.forEach((j) => {
|
|
11316
11325
|
cellValue.setValue(i, j, {
|
|
11317
11326
|
v: null,
|
|
11327
|
+
s: null,
|
|
11318
11328
|
p: null,
|
|
11319
11329
|
f: null,
|
|
11320
11330
|
si: null,
|
|
@@ -11395,7 +11405,7 @@ let AUTO_FILL_HOOK_TYPE = /* @__PURE__ */ function(AUTO_FILL_HOOK_TYPE) {
|
|
|
11395
11405
|
const { chineseToNumber, fillChnNumber, fillChnWeek, fillCopy: fillCopy$1, fillExtendNumber, fillLoopSeries, fillSeries, getLoopSeriesInfo, isChnNumber, isChnWeek2, isChnWeek3, isEqualDiff, isLoopSeries, matchExtendNumber, reverseIfNeed } = AutoFillTools;
|
|
11396
11406
|
const AutoFillRules = {
|
|
11397
11407
|
dateRule: {
|
|
11398
|
-
type:
|
|
11408
|
+
type: "date",
|
|
11399
11409
|
priority: 1100,
|
|
11400
11410
|
match: (cellData, accessor) => {
|
|
11401
11411
|
if ((cellData === null || cellData === void 0 ? void 0 : cellData.f) || (cellData === null || cellData === void 0 ? void 0 : cellData.si)) return false;
|
|
@@ -11412,10 +11422,10 @@ const AutoFillRules = {
|
|
|
11412
11422
|
return false;
|
|
11413
11423
|
},
|
|
11414
11424
|
isContinue: (prev, cur) => {
|
|
11415
|
-
if (prev.type ===
|
|
11425
|
+
if (prev.type === "date") return true;
|
|
11416
11426
|
return false;
|
|
11417
11427
|
},
|
|
11418
|
-
applyFunctions: { [
|
|
11428
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11419
11429
|
const { data } = dataWithIndex;
|
|
11420
11430
|
if (direction === Direction.LEFT || direction === Direction.UP) {
|
|
11421
11431
|
data.reverse();
|
|
@@ -11425,14 +11435,14 @@ const AutoFillRules = {
|
|
|
11425
11435
|
} }
|
|
11426
11436
|
},
|
|
11427
11437
|
numberRule: {
|
|
11428
|
-
type:
|
|
11438
|
+
type: "number",
|
|
11429
11439
|
priority: 1e3,
|
|
11430
11440
|
match: (cellData) => typeof (cellData === null || cellData === void 0 ? void 0 : cellData.v) === "number" || (cellData === null || cellData === void 0 ? void 0 : cellData.t) === CellValueType.NUMBER,
|
|
11431
11441
|
isContinue: (prev, cur) => {
|
|
11432
|
-
if (prev.type ===
|
|
11442
|
+
if (prev.type === "number") return true;
|
|
11433
11443
|
return false;
|
|
11434
11444
|
},
|
|
11435
|
-
applyFunctions: { [
|
|
11445
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11436
11446
|
const { data } = dataWithIndex;
|
|
11437
11447
|
if (direction === Direction.LEFT || direction === Direction.UP) {
|
|
11438
11448
|
data.reverse();
|
|
@@ -11442,11 +11452,11 @@ const AutoFillRules = {
|
|
|
11442
11452
|
} }
|
|
11443
11453
|
},
|
|
11444
11454
|
extendNumberRule: {
|
|
11445
|
-
type:
|
|
11455
|
+
type: "extendNumber",
|
|
11446
11456
|
priority: 900,
|
|
11447
11457
|
match: (cellData) => matchExtendNumber(`${cellData === null || cellData === void 0 ? void 0 : cellData.v}` || "").isExtendNumber,
|
|
11448
11458
|
isContinue: (prev, cur) => {
|
|
11449
|
-
if (prev.type ===
|
|
11459
|
+
if (prev.type === "extendNumber") {
|
|
11450
11460
|
var _prev$cellData;
|
|
11451
11461
|
const prevMatch = matchExtendNumber(`${(_prev$cellData = prev.cellData) === null || _prev$cellData === void 0 ? void 0 : _prev$cellData.v}` || "");
|
|
11452
11462
|
const curMatch = matchExtendNumber(`${cur === null || cur === void 0 ? void 0 : cur.v}` || "");
|
|
@@ -11458,7 +11468,7 @@ const AutoFillRules = {
|
|
|
11458
11468
|
}
|
|
11459
11469
|
return false;
|
|
11460
11470
|
},
|
|
11461
|
-
applyFunctions: { [
|
|
11471
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11462
11472
|
const { data } = dataWithIndex;
|
|
11463
11473
|
const isReverse = direction === Direction.UP || direction === Direction.LEFT;
|
|
11464
11474
|
let step;
|
|
@@ -11485,17 +11495,17 @@ const AutoFillRules = {
|
|
|
11485
11495
|
} }
|
|
11486
11496
|
},
|
|
11487
11497
|
chnNumberRule: {
|
|
11488
|
-
type:
|
|
11498
|
+
type: "chnNumber",
|
|
11489
11499
|
priority: 830,
|
|
11490
11500
|
match: (cellData) => {
|
|
11491
11501
|
if (isChnNumber(`${cellData === null || cellData === void 0 ? void 0 : cellData.v}` || "")) return true;
|
|
11492
11502
|
return false;
|
|
11493
11503
|
},
|
|
11494
11504
|
isContinue: (prev, cur) => {
|
|
11495
|
-
if (prev.type ===
|
|
11505
|
+
if (prev.type === "chnNumber") return true;
|
|
11496
11506
|
return false;
|
|
11497
11507
|
},
|
|
11498
|
-
applyFunctions: { [
|
|
11508
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11499
11509
|
const { data } = dataWithIndex;
|
|
11500
11510
|
const isReverse = direction === Direction.LEFT || direction === Direction.UP;
|
|
11501
11511
|
if (data.length === 1) {
|
|
@@ -11543,14 +11553,14 @@ const AutoFillRules = {
|
|
|
11543
11553
|
} }
|
|
11544
11554
|
},
|
|
11545
11555
|
chnWeek2Rule: {
|
|
11546
|
-
type:
|
|
11556
|
+
type: "chnWeek2",
|
|
11547
11557
|
priority: 820,
|
|
11548
11558
|
match: (cellData) => {
|
|
11549
11559
|
if (isChnWeek2(`${cellData === null || cellData === void 0 ? void 0 : cellData.v}` || "")) return true;
|
|
11550
11560
|
return false;
|
|
11551
11561
|
},
|
|
11552
|
-
isContinue: (prev, cur) => prev.type ===
|
|
11553
|
-
applyFunctions: { [
|
|
11562
|
+
isContinue: (prev, cur) => prev.type === "chnWeek2",
|
|
11563
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11554
11564
|
const { data } = dataWithIndex;
|
|
11555
11565
|
const isReverse = direction === Direction.LEFT || direction === Direction.UP;
|
|
11556
11566
|
if (data.length === 1) {
|
|
@@ -11584,11 +11594,11 @@ const AutoFillRules = {
|
|
|
11584
11594
|
} }
|
|
11585
11595
|
},
|
|
11586
11596
|
chnWeek3Rule: {
|
|
11587
|
-
type:
|
|
11597
|
+
type: "chnWeek3",
|
|
11588
11598
|
priority: 810,
|
|
11589
11599
|
match: (cellData) => isChnWeek3(`${cellData === null || cellData === void 0 ? void 0 : cellData.v}` || ""),
|
|
11590
|
-
isContinue: (prev, cur) => prev.type ===
|
|
11591
|
-
applyFunctions: { [
|
|
11600
|
+
isContinue: (prev, cur) => prev.type === "chnWeek3",
|
|
11601
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11592
11602
|
const { data } = dataWithIndex;
|
|
11593
11603
|
const isReverse = direction === Direction.LEFT || direction === Direction.UP;
|
|
11594
11604
|
if (data.length === 1) {
|
|
@@ -11624,17 +11634,17 @@ const AutoFillRules = {
|
|
|
11624
11634
|
} }
|
|
11625
11635
|
},
|
|
11626
11636
|
loopSeriesRule: {
|
|
11627
|
-
type:
|
|
11637
|
+
type: "loopSeries",
|
|
11628
11638
|
priority: 800,
|
|
11629
11639
|
match: (cellData) => isLoopSeries(`${cellData === null || cellData === void 0 ? void 0 : cellData.v}` || ""),
|
|
11630
11640
|
isContinue: (prev, cur) => {
|
|
11631
|
-
if (prev.type ===
|
|
11641
|
+
if (prev.type === "loopSeries") {
|
|
11632
11642
|
var _prev$cellData2;
|
|
11633
11643
|
return getLoopSeriesInfo(`${(_prev$cellData2 = prev.cellData) === null || _prev$cellData2 === void 0 ? void 0 : _prev$cellData2.v}` || "").name === getLoopSeriesInfo(`${cur === null || cur === void 0 ? void 0 : cur.v}` || "").name;
|
|
11634
11644
|
}
|
|
11635
11645
|
return false;
|
|
11636
11646
|
},
|
|
11637
|
-
applyFunctions: { [
|
|
11647
|
+
applyFunctions: { ["SERIES"]: (dataWithIndex, len, direction) => {
|
|
11638
11648
|
var _data$2;
|
|
11639
11649
|
const { data } = dataWithIndex;
|
|
11640
11650
|
const isReverse = direction === Direction.LEFT || direction === Direction.UP;
|
|
@@ -11669,11 +11679,11 @@ const AutoFillRules = {
|
|
|
11669
11679
|
} }
|
|
11670
11680
|
},
|
|
11671
11681
|
otherRule: {
|
|
11672
|
-
type:
|
|
11682
|
+
type: "other",
|
|
11673
11683
|
priority: 0,
|
|
11674
11684
|
match: () => true,
|
|
11675
11685
|
isContinue: (prev, cur) => {
|
|
11676
|
-
if (prev.type ===
|
|
11686
|
+
if (prev.type === "other") return true;
|
|
11677
11687
|
return false;
|
|
11678
11688
|
}
|
|
11679
11689
|
}
|
|
@@ -11691,7 +11701,7 @@ let AutoFillService = class AutoFillService extends Disposable {
|
|
|
11691
11701
|
this._injector = _injector;
|
|
11692
11702
|
_defineProperty(this, "_rules", []);
|
|
11693
11703
|
_defineProperty(this, "_hooks", []);
|
|
11694
|
-
_defineProperty(this, "_applyType$", new BehaviorSubject(
|
|
11704
|
+
_defineProperty(this, "_applyType$", new BehaviorSubject("SERIES"));
|
|
11695
11705
|
_defineProperty(this, "_isFillingStyle", true);
|
|
11696
11706
|
_defineProperty(this, "_prevUndos", []);
|
|
11697
11707
|
_defineProperty(this, "_autoFillLocation$", new BehaviorSubject(null));
|
|
@@ -11703,22 +11713,22 @@ let AutoFillService = class AutoFillService extends Disposable {
|
|
|
11703
11713
|
_defineProperty(this, "_menu$", new BehaviorSubject([
|
|
11704
11714
|
{
|
|
11705
11715
|
label: "autoFill.copy",
|
|
11706
|
-
value:
|
|
11716
|
+
value: "COPY",
|
|
11707
11717
|
disable: false
|
|
11708
11718
|
},
|
|
11709
11719
|
{
|
|
11710
11720
|
label: "autoFill.series",
|
|
11711
|
-
value:
|
|
11721
|
+
value: "SERIES",
|
|
11712
11722
|
disable: false
|
|
11713
11723
|
},
|
|
11714
11724
|
{
|
|
11715
11725
|
label: "autoFill.formatOnly",
|
|
11716
|
-
value:
|
|
11726
|
+
value: "ONLY_FORMAT",
|
|
11717
11727
|
disable: false
|
|
11718
11728
|
},
|
|
11719
11729
|
{
|
|
11720
11730
|
label: "autoFill.noFormat",
|
|
11721
|
-
value:
|
|
11731
|
+
value: "NO_FORMAT",
|
|
11722
11732
|
disable: false
|
|
11723
11733
|
}
|
|
11724
11734
|
]));
|
|
@@ -11822,7 +11832,7 @@ let AutoFillService = class AutoFillService extends Disposable {
|
|
|
11822
11832
|
addHook(hook) {
|
|
11823
11833
|
if (this._hooks.find((h) => h.id === hook.id)) throw new Error(`Add hook failed, hook id '${hook.id}' already exist!`);
|
|
11824
11834
|
if (hook.priority === void 0) hook.priority = 0;
|
|
11825
|
-
if (hook.type === void 0) hook.type =
|
|
11835
|
+
if (hook.type === void 0) hook.type = "APPEND";
|
|
11826
11836
|
this._hooks.push(hook);
|
|
11827
11837
|
return toDisposable(() => {
|
|
11828
11838
|
const index = this._hooks.findIndex((item) => item === hook);
|
|
@@ -11852,10 +11862,10 @@ let AutoFillService = class AutoFillService extends Disposable {
|
|
|
11852
11862
|
subUnitId
|
|
11853
11863
|
}, this._direction, this.applyType)) === true;
|
|
11854
11864
|
});
|
|
11855
|
-
const onlyHooks = enabledHooks.filter((h) => h.type ===
|
|
11865
|
+
const onlyHooks = enabledHooks.filter((h) => h.type === "ONLY");
|
|
11856
11866
|
if (onlyHooks.length > 0) return this._getOneByPriority(onlyHooks);
|
|
11857
|
-
const defaultHooks = this._getOneByPriority(enabledHooks.filter((h) => h.type ===
|
|
11858
|
-
const appendHooks = enabledHooks.filter((h) => h.type ===
|
|
11867
|
+
const defaultHooks = this._getOneByPriority(enabledHooks.filter((h) => h.type === "DEFAULT"));
|
|
11868
|
+
const appendHooks = enabledHooks.filter((h) => h.type === "APPEND") || [];
|
|
11859
11869
|
return [...defaultHooks, ...appendHooks];
|
|
11860
11870
|
}
|
|
11861
11871
|
get applyType() {
|
|
@@ -11970,7 +11980,7 @@ let AutoFillService = class AutoFillService extends Disposable {
|
|
|
11970
11980
|
return true;
|
|
11971
11981
|
}
|
|
11972
11982
|
_getAutoHeightUndoRedos(executedRedos, workbook, worksheet) {
|
|
11973
|
-
if (this.applyType ===
|
|
11983
|
+
if (this.applyType === "NO_FORMAT") return {
|
|
11974
11984
|
undos: [],
|
|
11975
11985
|
redos: []
|
|
11976
11986
|
};
|
|
@@ -12066,7 +12076,7 @@ function getSheetCopyFillRange(accessor, direction) {
|
|
|
12066
12076
|
},
|
|
12067
12077
|
unitId,
|
|
12068
12078
|
subUnitId,
|
|
12069
|
-
applyType:
|
|
12079
|
+
applyType: "COPY"
|
|
12070
12080
|
};
|
|
12071
12081
|
}
|
|
12072
12082
|
return {
|
|
@@ -12084,7 +12094,7 @@ function getSheetCopyFillRange(accessor, direction) {
|
|
|
12084
12094
|
},
|
|
12085
12095
|
unitId,
|
|
12086
12096
|
subUnitId,
|
|
12087
|
-
applyType:
|
|
12097
|
+
applyType: "COPY"
|
|
12088
12098
|
};
|
|
12089
12099
|
}
|
|
12090
12100
|
if (startColumn === endColumn) {
|
|
@@ -12104,7 +12114,7 @@ function getSheetCopyFillRange(accessor, direction) {
|
|
|
12104
12114
|
},
|
|
12105
12115
|
unitId,
|
|
12106
12116
|
subUnitId,
|
|
12107
|
-
applyType:
|
|
12117
|
+
applyType: "COPY"
|
|
12108
12118
|
};
|
|
12109
12119
|
}
|
|
12110
12120
|
return {
|
|
@@ -12122,7 +12132,7 @@ function getSheetCopyFillRange(accessor, direction) {
|
|
|
12122
12132
|
},
|
|
12123
12133
|
unitId,
|
|
12124
12134
|
subUnitId,
|
|
12125
|
-
applyType:
|
|
12135
|
+
applyType: "COPY"
|
|
12126
12136
|
};
|
|
12127
12137
|
}
|
|
12128
12138
|
async function executeSheetCopyFill(accessor, direction) {
|
|
@@ -12195,7 +12205,7 @@ const AutoClearContentCommand = {
|
|
|
12195
12205
|
subUnitId
|
|
12196
12206
|
}
|
|
12197
12207
|
}];
|
|
12198
|
-
if (sequenceExecute(redos, commandService)) {
|
|
12208
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
12199
12209
|
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
|
|
12200
12210
|
id: SetRangeValuesMutation.id,
|
|
12201
12211
|
params: clearMutationParams
|
|
@@ -12231,32 +12241,50 @@ const ClearSelectionContentCommand = {
|
|
|
12231
12241
|
const { unitId, subUnitId } = target;
|
|
12232
12242
|
const ranges = (params === null || params === void 0 ? void 0 : params.ranges) || ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range));
|
|
12233
12243
|
if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return false;
|
|
12244
|
+
const skeleton = accessor.get(SheetSkeletonService).getSkeleton(unitId, subUnitId);
|
|
12245
|
+
if (!skeleton) return false;
|
|
12234
12246
|
const commandService = accessor.get(ICommandService);
|
|
12235
12247
|
const undoRedoService = accessor.get(IUndoRedoService);
|
|
12236
12248
|
const sheetInterceptorService = accessor.get(SheetInterceptorService);
|
|
12249
|
+
const redoMutations = [];
|
|
12250
|
+
const undoMutations = [];
|
|
12237
12251
|
const clearMutationParams = {
|
|
12238
12252
|
subUnitId,
|
|
12239
12253
|
unitId,
|
|
12240
12254
|
cellValue: generateNullCellValue(getVisibleRanges(ranges, accessor, unitId, subUnitId))
|
|
12241
12255
|
};
|
|
12242
12256
|
const undoClearMutationParams = SetRangeValuesUndoMutationFactory(accessor, clearMutationParams);
|
|
12243
|
-
|
|
12244
|
-
id: ClearSelectionContentCommand.id,
|
|
12245
|
-
params
|
|
12246
|
-
});
|
|
12247
|
-
const redos = [{
|
|
12257
|
+
redoMutations.push({
|
|
12248
12258
|
id: SetRangeValuesMutation.id,
|
|
12249
12259
|
params: clearMutationParams
|
|
12250
|
-
}
|
|
12251
|
-
|
|
12260
|
+
});
|
|
12261
|
+
undoMutations.push({
|
|
12252
12262
|
id: SetRangeValuesMutation.id,
|
|
12253
12263
|
params: undoClearMutationParams
|
|
12254
|
-
}
|
|
12255
|
-
|
|
12264
|
+
});
|
|
12265
|
+
const intercepted = sheetInterceptorService.onCommandExecute({
|
|
12266
|
+
id: ClearSelectionContentCommand.id,
|
|
12267
|
+
params
|
|
12268
|
+
});
|
|
12269
|
+
redoMutations.push(...intercepted.redos);
|
|
12270
|
+
undoMutations.unshift(...intercepted.undos);
|
|
12271
|
+
const result = sequenceExecute(redoMutations, commandService);
|
|
12272
|
+
const { suitableRanges, remainingRanges } = getSuitableRangesInView(ranges, skeleton);
|
|
12273
|
+
const { undos: autoHeightUndos, redos: autoHeightRedos } = sheetInterceptorService.generateMutationsOfAutoHeight({
|
|
12274
|
+
unitId,
|
|
12275
|
+
subUnitId,
|
|
12276
|
+
ranges: suitableRanges,
|
|
12277
|
+
autoHeightRanges: suitableRanges,
|
|
12278
|
+
lazyAutoHeightRanges: remainingRanges
|
|
12279
|
+
});
|
|
12280
|
+
const autoHeightExecuteResult = sequenceExecute(autoHeightRedos, commandService);
|
|
12281
|
+
if (result.result && autoHeightExecuteResult.result) {
|
|
12282
|
+
redoMutations.push(...autoHeightRedos);
|
|
12283
|
+
undoMutations.push(...autoHeightUndos);
|
|
12256
12284
|
undoRedoService.pushUndoRedo({
|
|
12257
12285
|
unitID: unitId,
|
|
12258
|
-
undoMutations
|
|
12259
|
-
redoMutations
|
|
12286
|
+
undoMutations,
|
|
12287
|
+
redoMutations
|
|
12260
12288
|
});
|
|
12261
12289
|
return true;
|
|
12262
12290
|
}
|
|
@@ -12908,7 +12936,7 @@ const RemoveDefinedNameCommand = {
|
|
|
12908
12936
|
},
|
|
12909
12937
|
...interceptorCommands.undos
|
|
12910
12938
|
];
|
|
12911
|
-
if (sequenceExecute(redos, commandService)) {
|
|
12939
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
12912
12940
|
undoRedoService.pushUndoRedo({
|
|
12913
12941
|
unitID: params.unitId,
|
|
12914
12942
|
undoMutations: undos.filter(Boolean),
|
|
@@ -13756,7 +13784,7 @@ const SetDefinedNameCommand = {
|
|
|
13756
13784
|
}] : [],
|
|
13757
13785
|
...interceptorCommands.undos
|
|
13758
13786
|
];
|
|
13759
|
-
if (sequenceExecute(redos, commandService)) {
|
|
13787
|
+
if (sequenceExecute(redos, commandService).result) {
|
|
13760
13788
|
undoRedoService.pushUndoRedo({
|
|
13761
13789
|
unitID: params.unitId,
|
|
13762
13790
|
undoMutations: undos.filter(Boolean),
|
|
@@ -14083,7 +14111,7 @@ const SetProtectionCommand = {
|
|
|
14083
14111
|
});
|
|
14084
14112
|
}
|
|
14085
14113
|
}
|
|
14086
|
-
if (sequenceExecute(redoMutations, commandService)) undoRedoService.pushUndoRedo({
|
|
14114
|
+
if (sequenceExecute(redoMutations, commandService).result) undoRedoService.pushUndoRedo({
|
|
14087
14115
|
unitID: unitId,
|
|
14088
14116
|
undoMutations,
|
|
14089
14117
|
redoMutations
|
|
@@ -17149,7 +17177,7 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17149
17177
|
_initDefaultHook() {
|
|
17150
17178
|
this.disposeWithMe(this._autoFillService.addHook({
|
|
17151
17179
|
id: "default",
|
|
17152
|
-
type:
|
|
17180
|
+
type: "DEFAULT",
|
|
17153
17181
|
priority: 0,
|
|
17154
17182
|
onBeforeFillData: (location, direction) => {
|
|
17155
17183
|
return this._presetAndCacheData(location, direction);
|
|
@@ -17176,9 +17204,9 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17176
17204
|
this._beforeApplyData = applyData;
|
|
17177
17205
|
this._copyData = this._getCopyData(location, direction);
|
|
17178
17206
|
if (this._shouldDisableSeries(this._copyData)) {
|
|
17179
|
-
this._autoFillService.setDisableApplyType(
|
|
17180
|
-
return
|
|
17181
|
-
} else this._autoFillService.setDisableApplyType(
|
|
17207
|
+
this._autoFillService.setDisableApplyType("SERIES", true);
|
|
17208
|
+
return "COPY";
|
|
17209
|
+
} else this._autoFillService.setDisableApplyType("SERIES", false);
|
|
17182
17210
|
return this._getPreferredApplyType(this._copyData);
|
|
17183
17211
|
}
|
|
17184
17212
|
_getApplyData(copyDataPiece, csLen, asLen, direction, applyType, hasStyle = true, location) {
|
|
@@ -17186,7 +17214,7 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17186
17214
|
const num = Math.floor(asLen / csLen);
|
|
17187
17215
|
const rsd = asLen % csLen;
|
|
17188
17216
|
const rules = this._autoFillService.getRules();
|
|
17189
|
-
if (!hasStyle && applyType ===
|
|
17217
|
+
if (!hasStyle && applyType === "ONLY_FORMAT") {
|
|
17190
17218
|
console.error("ERROR: only format can not be applied when hasStyle is false");
|
|
17191
17219
|
return [];
|
|
17192
17220
|
}
|
|
@@ -17219,21 +17247,21 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17219
17247
|
_applyFunctions(copySquad, len, direction, applyType, customApplyFunctions, copyDataPiece, location) {
|
|
17220
17248
|
const { data } = copySquad;
|
|
17221
17249
|
const isReverse = direction === Direction.UP || direction === Direction.LEFT;
|
|
17222
|
-
if (applyType ===
|
|
17223
|
-
const custom = customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions[
|
|
17250
|
+
if (applyType === "COPY") {
|
|
17251
|
+
const custom = customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions["COPY"];
|
|
17224
17252
|
if (custom) return custom(copySquad, len, direction, copyDataPiece, location);
|
|
17225
17253
|
isReverse && data.reverse();
|
|
17226
17254
|
return fillCopy(data, len);
|
|
17227
17255
|
}
|
|
17228
|
-
if (applyType ===
|
|
17229
|
-
const custom = customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions[
|
|
17256
|
+
if (applyType === "SERIES") {
|
|
17257
|
+
const custom = customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions["SERIES"];
|
|
17230
17258
|
if (custom) return custom(copySquad, len, direction, copyDataPiece);
|
|
17231
17259
|
isReverse && data.reverse();
|
|
17232
|
-
if (customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions[
|
|
17260
|
+
if (customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions["COPY"]) return customApplyFunctions["COPY"](copySquad, len, direction, copyDataPiece, location);
|
|
17233
17261
|
return fillCopy(data, len);
|
|
17234
17262
|
}
|
|
17235
|
-
if (applyType ===
|
|
17236
|
-
const custom = customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions[
|
|
17263
|
+
if (applyType === "ONLY_FORMAT") {
|
|
17264
|
+
const custom = customApplyFunctions === null || customApplyFunctions === void 0 ? void 0 : customApplyFunctions["ONLY_FORMAT"];
|
|
17237
17265
|
if (custom) return custom(copySquad, len, direction, copyDataPiece);
|
|
17238
17266
|
return fillCopyStyles(data, len);
|
|
17239
17267
|
}
|
|
@@ -17368,9 +17396,9 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17368
17396
|
const undos = [];
|
|
17369
17397
|
const redos = [];
|
|
17370
17398
|
let hasStyle = true;
|
|
17371
|
-
if (applyType ===
|
|
17399
|
+
if (applyType === "NO_FORMAT") {
|
|
17372
17400
|
hasStyle = false;
|
|
17373
|
-
applyType =
|
|
17401
|
+
applyType = "SERIES";
|
|
17374
17402
|
}
|
|
17375
17403
|
const { source, target, unitId, subUnitId } = location;
|
|
17376
17404
|
if (!source || !target || direction == null) return {
|
|
@@ -17431,7 +17459,7 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17431
17459
|
if (cellData && style) cellData.s = style.getStyleByCell(this._beforeApplyData[rowIndex][colIndex]) || null;
|
|
17432
17460
|
});
|
|
17433
17461
|
});
|
|
17434
|
-
if (applyType ===
|
|
17462
|
+
if (applyType === "ONLY_FORMAT") applyDatas.forEach((row, rowIndex) => {
|
|
17435
17463
|
row.forEach((cellData, colIndex) => {
|
|
17436
17464
|
if (cellData) {
|
|
17437
17465
|
const old = this._beforeApplyData[rowIndex][colIndex] || {};
|
|
@@ -17529,14 +17557,14 @@ let AutoFillController = class AutoFillController extends Disposable {
|
|
|
17529
17557
|
_shouldDisableSeries(copyData) {
|
|
17530
17558
|
return copyData.every((copyDataPiece) => Object.keys(copyDataPiece).every((type) => {
|
|
17531
17559
|
var _copyDataPiece;
|
|
17532
|
-
return ((_copyDataPiece = copyDataPiece[type]) === null || _copyDataPiece === void 0 ? void 0 : _copyDataPiece.length) === 0 || [
|
|
17560
|
+
return ((_copyDataPiece = copyDataPiece[type]) === null || _copyDataPiece === void 0 ? void 0 : _copyDataPiece.length) === 0 || ["other", "formula"].includes(type);
|
|
17533
17561
|
}));
|
|
17534
17562
|
}
|
|
17535
17563
|
_getPreferredApplyType(copyData) {
|
|
17536
17564
|
return copyData.every((copyDataPiece) => Object.keys(copyDataPiece).every((type) => {
|
|
17537
17565
|
var _copyDataPiece2, _copyDataPiece3;
|
|
17538
|
-
return ((_copyDataPiece2 = copyDataPiece[type]) === null || _copyDataPiece2 === void 0 ? void 0 : _copyDataPiece2.length) === 0 || ((_copyDataPiece3 = copyDataPiece[type]) === null || _copyDataPiece3 === void 0 ? void 0 : _copyDataPiece3.length) === 1 && copyDataPiece[type][0].data.length === 1 &&
|
|
17539
|
-
})) ?
|
|
17566
|
+
return ((_copyDataPiece2 = copyDataPiece[type]) === null || _copyDataPiece2 === void 0 ? void 0 : _copyDataPiece2.length) === 0 || ((_copyDataPiece3 = copyDataPiece[type]) === null || _copyDataPiece3 === void 0 ? void 0 : _copyDataPiece3.length) === 1 && copyDataPiece[type][0].data.length === 1 && "number" === type;
|
|
17567
|
+
})) ? "COPY" : "SERIES";
|
|
17540
17568
|
}
|
|
17541
17569
|
};
|
|
17542
17570
|
AutoFillController = __decorate([
|
|
@@ -17842,6 +17870,15 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
17842
17870
|
}, params.range ? [params.range] : void 0, params.unitId, params.subUnitId);
|
|
17843
17871
|
errorMsg = this._localeService.t("permission.dialog.setStyleErr");
|
|
17844
17872
|
break;
|
|
17873
|
+
case SetBorderCommand.id:
|
|
17874
|
+
params = commandInfo.params;
|
|
17875
|
+
permission = this.permissionCheckWithRanges({
|
|
17876
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
17877
|
+
worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission],
|
|
17878
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
17879
|
+
}, params === null || params === void 0 ? void 0 : params.ranges, params === null || params === void 0 ? void 0 : params.unitId, params === null || params === void 0 ? void 0 : params.subUnitId);
|
|
17880
|
+
errorMsg = this._localeService.t("permission.dialog.setStyleErr");
|
|
17881
|
+
break;
|
|
17845
17882
|
case ClearSelectionAllCommand.id:
|
|
17846
17883
|
params = commandInfo.params;
|
|
17847
17884
|
permission = this.permissionCheckWithRanges({
|
|
@@ -17874,14 +17911,22 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
17874
17911
|
errorMsg = this._localeService.t("permission.dialog.setStyleErr");
|
|
17875
17912
|
break;
|
|
17876
17913
|
case DeltaColumnWidthCommand.id:
|
|
17877
|
-
case SetColWidthCommand.id:
|
|
17878
17914
|
permission = this.permissionCheckWithoutRange({ worksheetTypes: [WorksheetSetColumnStylePermission] });
|
|
17879
17915
|
errorMsg = this._localeService.t("permission.dialog.setRowColStyleErr");
|
|
17880
17916
|
break;
|
|
17917
|
+
case SetColWidthCommand.id:
|
|
17918
|
+
params = commandInfo.params;
|
|
17919
|
+
permission = this.permissionCheckWithoutRange({ worksheetTypes: [WorksheetSetColumnStylePermission] }, params.unitId, params.subUnitId);
|
|
17920
|
+
errorMsg = this._localeService.t("permission.dialog.setRowColStyleErr");
|
|
17921
|
+
break;
|
|
17881
17922
|
case DeltaRowHeightCommand.id:
|
|
17923
|
+
permission = this.permissionCheckWithoutRange({ worksheetTypes: [WorksheetSetRowStylePermission] });
|
|
17924
|
+
errorMsg = this._localeService.t("permission.dialog.setRowColStyleErr");
|
|
17925
|
+
break;
|
|
17882
17926
|
case SetRowHeightCommand.id:
|
|
17883
17927
|
case SetWorksheetRowIsAutoHeightCommand.id:
|
|
17884
|
-
|
|
17928
|
+
params = commandInfo.params;
|
|
17929
|
+
permission = this.permissionCheckWithoutRange({ worksheetTypes: [WorksheetSetRowStylePermission] }, params.unitId, params.subUnitId);
|
|
17885
17930
|
errorMsg = this._localeService.t("permission.dialog.setRowColStyleErr");
|
|
17886
17931
|
break;
|
|
17887
17932
|
case MoveRowsCommand.id:
|
|
@@ -17997,6 +18042,17 @@ let SheetPermissionCheckController = class SheetPermissionCheckController extend
|
|
|
17997
18042
|
}, [params.targetRange], params.unitId, params.subUnitId);
|
|
17998
18043
|
errorMsg = this._localeService.t("permission.dialog.autoFillErr");
|
|
17999
18044
|
break;
|
|
18045
|
+
case InsertDefinedNameCommand.id:
|
|
18046
|
+
case SetDefinedNameCommand.id:
|
|
18047
|
+
case RemoveDefinedNameCommand.id:
|
|
18048
|
+
params = commandInfo.params;
|
|
18049
|
+
if (!params.localSheetId || params.localSheetId === "AllDefaultWorkbook") permission = this.permissionCheckWithoutRange({ workbookTypes: [WorkbookEditablePermission] }, params.unitId);
|
|
18050
|
+
else permission = this.permissionCheckWithoutRange({
|
|
18051
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
18052
|
+
worksheetTypes: [WorksheetEditPermission]
|
|
18053
|
+
}, params.unitId, params.localSheetId);
|
|
18054
|
+
errorMsg = this._localeService.t("permission.dialog.editErr");
|
|
18055
|
+
break;
|
|
18000
18056
|
default: break;
|
|
18001
18057
|
}
|
|
18002
18058
|
if (!permission) this.blockExecuteWithoutPermission(errorMsg);
|
|
@@ -19132,7 +19188,7 @@ RangeProtectionCache = __decorate([
|
|
|
19132
19188
|
//#endregion
|
|
19133
19189
|
//#region package.json
|
|
19134
19190
|
var name = "@univerjs/sheets";
|
|
19135
|
-
var version = "0.
|
|
19191
|
+
var version = "0.22.0";
|
|
19136
19192
|
|
|
19137
19193
|
//#endregion
|
|
19138
19194
|
//#region src/controllers/active-worksheet.controller.ts
|
|
@@ -20650,42 +20706,153 @@ UniverSheetsPlugin = __decorate([
|
|
|
20650
20706
|
* @ignore
|
|
20651
20707
|
*/
|
|
20652
20708
|
const PermissionPointsDefinitions = {
|
|
20709
|
+
/**
|
|
20710
|
+
* The permission point for adding or editing workbook comments
|
|
20711
|
+
*/
|
|
20653
20712
|
WorkbookCommentPermission,
|
|
20713
|
+
/**
|
|
20714
|
+
* The permission point for copy in workbook
|
|
20715
|
+
*/
|
|
20654
20716
|
WorkbookCopyPermission,
|
|
20717
|
+
/**
|
|
20718
|
+
* The permission point for creating protect in a workbook
|
|
20719
|
+
*/
|
|
20655
20720
|
WorkbookCreateProtectPermission,
|
|
20721
|
+
/**
|
|
20722
|
+
* The permission point for creating new sheets in a workbook
|
|
20723
|
+
*/
|
|
20656
20724
|
WorkbookCreateSheetPermission,
|
|
20725
|
+
/**
|
|
20726
|
+
* The permission point for deleting sheets in a workbook
|
|
20727
|
+
*/
|
|
20657
20728
|
WorkbookDeleteSheetPermission,
|
|
20729
|
+
/**
|
|
20730
|
+
* The permission point for duplicating a sheet in a workbook
|
|
20731
|
+
*/
|
|
20658
20732
|
WorkbookDuplicatePermission,
|
|
20733
|
+
/**
|
|
20734
|
+
* The permission point for editing workbook content
|
|
20735
|
+
*/
|
|
20659
20736
|
WorkbookEditablePermission,
|
|
20737
|
+
/**
|
|
20738
|
+
* The permission point for exporting workbook data
|
|
20739
|
+
*/
|
|
20660
20740
|
WorkbookExportPermission,
|
|
20741
|
+
/**
|
|
20742
|
+
* The permission point for hiding sheets in a workbook
|
|
20743
|
+
*/
|
|
20661
20744
|
WorkbookHideSheetPermission,
|
|
20745
|
+
/**
|
|
20746
|
+
* The permission point for managing collaborators in a workbook
|
|
20747
|
+
*/
|
|
20662
20748
|
WorkbookManageCollaboratorPermission,
|
|
20749
|
+
/**
|
|
20750
|
+
* The permission point for moving sheets within a workbook
|
|
20751
|
+
*/
|
|
20663
20752
|
WorkbookMoveSheetPermission,
|
|
20753
|
+
/**
|
|
20754
|
+
* The permission point for printing a workbook
|
|
20755
|
+
*/
|
|
20664
20756
|
WorkbookPrintPermission,
|
|
20757
|
+
/**
|
|
20758
|
+
* The permission point for recovering a previous history state of a workbook
|
|
20759
|
+
*/
|
|
20665
20760
|
WorkbookRecoverHistoryPermission,
|
|
20761
|
+
/**
|
|
20762
|
+
* The permission point for renaming sheets in a workbook
|
|
20763
|
+
*/
|
|
20666
20764
|
WorkbookRenameSheetPermission,
|
|
20765
|
+
/**
|
|
20766
|
+
* The permission point for sharing a workbook with others
|
|
20767
|
+
*/
|
|
20667
20768
|
WorkbookSharePermission,
|
|
20769
|
+
/**
|
|
20770
|
+
* The permission point for viewing the history of a workbook
|
|
20771
|
+
*/
|
|
20668
20772
|
WorkbookViewHistoryPermission,
|
|
20773
|
+
/**
|
|
20774
|
+
* The permission point for viewing a workbook
|
|
20775
|
+
*/
|
|
20669
20776
|
WorkbookViewPermission,
|
|
20777
|
+
/**
|
|
20778
|
+
* The permission point for copying contents from a worksheet
|
|
20779
|
+
*/
|
|
20670
20780
|
WorksheetCopyPermission,
|
|
20781
|
+
/**
|
|
20782
|
+
* The permission point for deleting columns in a worksheet
|
|
20783
|
+
*/
|
|
20671
20784
|
WorksheetDeleteColumnPermission,
|
|
20785
|
+
/**
|
|
20786
|
+
* The permission point for deleting worksheet protection rules
|
|
20787
|
+
*/
|
|
20672
20788
|
WorksheetDeleteProtectionPermission,
|
|
20789
|
+
/**
|
|
20790
|
+
* The permission point for deleting rows in a worksheet
|
|
20791
|
+
*/
|
|
20673
20792
|
WorksheetDeleteRowPermission,
|
|
20793
|
+
/**
|
|
20794
|
+
* The permission point for editing extra objects (e.g. shapes) in a worksheet
|
|
20795
|
+
*/
|
|
20674
20796
|
WorksheetEditExtraObjectPermission,
|
|
20797
|
+
/**
|
|
20798
|
+
* The permission point for editing the content of a worksheet
|
|
20799
|
+
*/
|
|
20675
20800
|
WorksheetEditPermission,
|
|
20801
|
+
/**
|
|
20802
|
+
* The permission point for applying filters in a worksheet
|
|
20803
|
+
*/
|
|
20676
20804
|
WorksheetFilterPermission,
|
|
20805
|
+
/**
|
|
20806
|
+
* The permission point for inserting columns into a worksheet
|
|
20807
|
+
*/
|
|
20677
20808
|
WorksheetInsertColumnPermission,
|
|
20809
|
+
/**
|
|
20810
|
+
* The permission point for inserting hyperlinks in a worksheet
|
|
20811
|
+
*/
|
|
20678
20812
|
WorksheetInsertHyperlinkPermission,
|
|
20813
|
+
/**
|
|
20814
|
+
* The permission point for inserting rows into a worksheet
|
|
20815
|
+
*/
|
|
20679
20816
|
WorksheetInsertRowPermission,
|
|
20817
|
+
/**
|
|
20818
|
+
* The permission point for managing collaborators of a worksheet
|
|
20819
|
+
*/
|
|
20680
20820
|
WorksheetManageCollaboratorPermission,
|
|
20821
|
+
/**
|
|
20822
|
+
* The permission point for creating or modifying pivot tables in a worksheet
|
|
20823
|
+
*/
|
|
20681
20824
|
WorksheetPivotTablePermission,
|
|
20825
|
+
/**
|
|
20826
|
+
* The permission point for setting the style of cells in a worksheet
|
|
20827
|
+
*/
|
|
20682
20828
|
WorksheetSetCellStylePermission,
|
|
20829
|
+
/**
|
|
20830
|
+
* The permission point for setting the value of cells in a worksheet
|
|
20831
|
+
*/
|
|
20683
20832
|
WorksheetSetCellValuePermission,
|
|
20833
|
+
/**
|
|
20834
|
+
* The permission point for setting the style of columns in a worksheet
|
|
20835
|
+
*/
|
|
20684
20836
|
WorksheetSetColumnStylePermission,
|
|
20837
|
+
/**
|
|
20838
|
+
* The permission point for setting the style of rows in a worksheet
|
|
20839
|
+
*/
|
|
20685
20840
|
WorksheetSetRowStylePermission,
|
|
20841
|
+
/**
|
|
20842
|
+
* The permission point for performing sort operations on a worksheet
|
|
20843
|
+
*/
|
|
20686
20844
|
WorksheetSortPermission,
|
|
20845
|
+
/**
|
|
20846
|
+
* The permission point for viewing the content of a worksheet
|
|
20847
|
+
*/
|
|
20687
20848
|
WorksheetViewPermission,
|
|
20849
|
+
/**
|
|
20850
|
+
* The permission point for editing the range protection settings
|
|
20851
|
+
*/
|
|
20688
20852
|
RangeProtectionPermissionEditPoint,
|
|
20853
|
+
/**
|
|
20854
|
+
* The permission point for viewing the range protection settings
|
|
20855
|
+
*/
|
|
20689
20856
|
RangeProtectionPermissionViewPoint
|
|
20690
20857
|
};
|
|
20691
20858
|
|