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