@univerjs/sheets-formula 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,17 @@ import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/c
17
17
  import { FormulaDataModel, LexerTreeBuilder } from '@univerjs/engine-formula';
18
18
  import { SelectionManagerService, SheetInterceptorService } from '@univerjs/sheets';
19
19
  import { Injector } from '@wendellhu/redi';
20
+ /**
21
+ * Update formula process
22
+ *
23
+ * 1. Command intercepts, converts the command information to adapt refRange, offsets the formula content, and obtains the formula that requires offset content.
24
+ *
25
+ 2. Use refRange to offset the formula position and return undo/redo data to setRangeValues mutation
26
+ - Redo data: Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)
27
+ - Undo data: the old position on the match saves the old value, and the new position is left blank
28
+
29
+ 3. onCommandExecuted, before formula calculation, use the setRangeValues information to delete the old formulaData, ArrayFormula and ArrayFormulaCellData, and send the worker (complementary setRangeValues after collaborative conflicts, normal operation triggers formula update, undo/redo are captured and processed here)
30
+ */
20
31
  export declare class UpdateFormulaController extends Disposable {
21
32
  private readonly _currentUniverService;
22
33
  private readonly _commandService;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IMutationInfo, IRange } from '@univerjs/core';
17
+ import type { IFormulaData } from '@univerjs/engine-formula';
18
+ export declare enum FormulaReferenceMoveType {
19
+ MoveRange = 0,// range
20
+ MoveRows = 1,// move rows
21
+ MoveCols = 2,// move columns
22
+ InsertRow = 3,// row
23
+ InsertColumn = 4,// column
24
+ RemoveRow = 5,// row
25
+ RemoveColumn = 6,// column
26
+ DeleteMoveLeft = 7,// range
27
+ DeleteMoveUp = 8,// range
28
+ InsertMoveDown = 9,// range
29
+ InsertMoveRight = 10,// range
30
+ SetName = 11,
31
+ RemoveSheet = 12
32
+ }
33
+ export interface IFormulaReferenceMoveParam {
34
+ type: FormulaReferenceMoveType;
35
+ unitId: string;
36
+ sheetId: string;
37
+ range?: IRange;
38
+ from?: IRange;
39
+ to?: IRange;
40
+ sheetName?: string;
41
+ }
42
+ /**
43
+ * For different Command operations, it may be necessary to perform traversal in reverse or in forward order, so first determine the type of Command and then perform traversal.
44
+ * @param oldFormulaData
45
+ * @param newFormulaData
46
+ * @param formulaReferenceMoveParam
47
+ * @returns
48
+ */
49
+ export declare function refRangeFormula(oldFormulaData: IFormulaData, newFormulaData: IFormulaData, formulaReferenceMoveParam: IFormulaReferenceMoveParam): {
50
+ redos: IMutationInfo<object>[];
51
+ undos: IMutationInfo<object>[];
52
+ } | undefined;
@@ -2453,11 +2453,11 @@ declare const _default: {
2453
2453
  url: string;
2454
2454
  }[];
2455
2455
  functionParameter: {
2456
- number1: {
2456
+ logical1: {
2457
2457
  name: string;
2458
2458
  detail: string;
2459
2459
  };
2460
- number2: {
2460
+ logical2: {
2461
2461
  name: string;
2462
2462
  detail: string;
2463
2463
  };
@@ -2849,11 +2849,7 @@ declare const _default: {
2849
2849
  url: string;
2850
2850
  }[];
2851
2851
  functionParameter: {
2852
- number1: {
2853
- name: string;
2854
- detail: string;
2855
- };
2856
- number2: {
2852
+ text: {
2857
2853
  name: string;
2858
2854
  detail: string;
2859
2855
  };
@@ -2867,11 +2863,7 @@ declare const _default: {
2867
2863
  url: string;
2868
2864
  }[];
2869
2865
  functionParameter: {
2870
- number1: {
2871
- name: string;
2872
- detail: string;
2873
- };
2874
- number2: {
2866
+ text: {
2875
2867
  name: string;
2876
2868
  detail: string;
2877
2869
  };
@@ -3155,11 +3147,11 @@ declare const _default: {
3155
3147
  url: string;
3156
3148
  }[];
3157
3149
  functionParameter: {
3158
- number1: {
3150
+ value: {
3159
3151
  name: string;
3160
3152
  detail: string;
3161
3153
  };
3162
- number2: {
3154
+ formatText: {
3163
3155
  name: string;
3164
3156
  detail: string;
3165
3157
  };
@@ -264,11 +264,11 @@ declare const _default: {
264
264
  url: string;
265
265
  }[];
266
266
  functionParameter: {
267
- number1: {
267
+ logical1: {
268
268
  name: string;
269
269
  detail: string;
270
270
  };
271
- number2: {
271
+ logical2: {
272
272
  name: string;
273
273
  detail: string;
274
274
  };
@@ -264,11 +264,11 @@ declare const _default: {
264
264
  url: string;
265
265
  }[];
266
266
  functionParameter: {
267
- number1: {
267
+ logical1: {
268
268
  name: string;
269
269
  detail: string;
270
270
  };
271
- number2: {
271
+ logical2: {
272
272
  name: string;
273
273
  detail: string;
274
274
  };
@@ -264,11 +264,11 @@ declare const _default: {
264
264
  url: string;
265
265
  }[];
266
266
  functionParameter: {
267
- number1: {
267
+ logical1: {
268
268
  name: string;
269
269
  detail: string;
270
270
  };
271
- number2: {
271
+ logical2: {
272
272
  name: string;
273
273
  detail: string;
274
274
  };
@@ -310,11 +310,7 @@ declare const _default: {
310
310
  url: string;
311
311
  }[];
312
312
  functionParameter: {
313
- number1: {
314
- name: string;
315
- detail: string;
316
- };
317
- number2: {
313
+ text: {
318
314
  name: string;
319
315
  detail: string;
320
316
  };
@@ -328,11 +324,7 @@ declare const _default: {
328
324
  url: string;
329
325
  }[];
330
326
  functionParameter: {
331
- number1: {
332
- name: string;
333
- detail: string;
334
- };
335
- number2: {
327
+ text: {
336
328
  name: string;
337
329
  detail: string;
338
330
  };
@@ -616,11 +608,11 @@ declare const _default: {
616
608
  url: string;
617
609
  }[];
618
610
  functionParameter: {
619
- number1: {
611
+ value: {
620
612
  name: string;
621
613
  detail: string;
622
614
  };
623
- number2: {
615
+ formatText: {
624
616
  name: string;
625
617
  detail: string;
626
618
  };
@@ -311,11 +311,7 @@ declare const _default: {
311
311
  url: string;
312
312
  }[];
313
313
  functionParameter: {
314
- number1: {
315
- name: string;
316
- detail: string;
317
- };
318
- number2: {
314
+ text: {
319
315
  name: string;
320
316
  detail: string;
321
317
  };
@@ -329,11 +325,7 @@ declare const _default: {
329
325
  url: string;
330
326
  }[];
331
327
  functionParameter: {
332
- number1: {
333
- name: string;
334
- detail: string;
335
- };
336
- number2: {
328
+ text: {
337
329
  name: string;
338
330
  detail: string;
339
331
  };
@@ -617,11 +609,11 @@ declare const _default: {
617
609
  url: string;
618
610
  }[];
619
611
  functionParameter: {
620
- number1: {
612
+ value: {
621
613
  name: string;
622
614
  detail: string;
623
615
  };
624
- number2: {
616
+ formatText: {
625
617
  name: string;
626
618
  detail: string;
627
619
  };
@@ -310,11 +310,7 @@ declare const _default: {
310
310
  url: string;
311
311
  }[];
312
312
  functionParameter: {
313
- number1: {
314
- name: string;
315
- detail: string;
316
- };
317
- number2: {
313
+ text: {
318
314
  name: string;
319
315
  detail: string;
320
316
  };
@@ -328,11 +324,7 @@ declare const _default: {
328
324
  url: string;
329
325
  }[];
330
326
  functionParameter: {
331
- number1: {
332
- name: string;
333
- detail: string;
334
- };
335
- number2: {
327
+ text: {
336
328
  name: string;
337
329
  detail: string;
338
330
  };
@@ -616,11 +608,11 @@ declare const _default: {
616
608
  url: string;
617
609
  }[];
618
610
  functionParameter: {
619
- number1: {
611
+ value: {
620
612
  name: string;
621
613
  detail: string;
622
614
  };
623
- number2: {
615
+ formatText: {
624
616
  name: string;
625
617
  detail: string;
626
618
  };
@@ -2453,11 +2453,11 @@ declare const _default: {
2453
2453
  url: string;
2454
2454
  }[];
2455
2455
  functionParameter: {
2456
- number1: {
2456
+ logical1: {
2457
2457
  name: string;
2458
2458
  detail: string;
2459
2459
  };
2460
- number2: {
2460
+ logical2: {
2461
2461
  name: string;
2462
2462
  detail: string;
2463
2463
  };
@@ -2849,11 +2849,7 @@ declare const _default: {
2849
2849
  url: string;
2850
2850
  }[];
2851
2851
  functionParameter: {
2852
- number1: {
2853
- name: string;
2854
- detail: string;
2855
- };
2856
- number2: {
2852
+ text: {
2857
2853
  name: string;
2858
2854
  detail: string;
2859
2855
  };
@@ -2867,11 +2863,7 @@ declare const _default: {
2867
2863
  url: string;
2868
2864
  }[];
2869
2865
  functionParameter: {
2870
- number1: {
2871
- name: string;
2872
- detail: string;
2873
- };
2874
- number2: {
2866
+ text: {
2875
2867
  name: string;
2876
2868
  detail: string;
2877
2869
  };
@@ -3155,11 +3147,11 @@ declare const _default: {
3155
3147
  url: string;
3156
3148
  }[];
3157
3149
  functionParameter: {
3158
- number1: {
3150
+ value: {
3159
3151
  name: string;
3160
3152
  detail: string;
3161
3153
  };
3162
- number2: {
3154
+ formatText: {
3163
3155
  name: string;
3164
3156
  detail: string;
3165
3157
  };