@univerjs/sheets 0.5.2 → 0.5.3-experimental.20250106-e3b7a39

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.
Files changed (42) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +3 -3
  3. package/lib/es/facade.js +747 -497
  4. package/lib/es/index.js +5559 -4090
  5. package/lib/types/basics/interfaces/mutation-interface.d.ts +7 -0
  6. package/lib/types/commands/commands/__tests__/range-template-command.sepc.d.ts +16 -0
  7. package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +1 -1
  8. package/lib/types/commands/commands/add-worksheet-range-theme.command.d.ts +2 -0
  9. package/lib/types/commands/commands/delete-worksheet-range-theme.command.d.ts +2 -0
  10. package/lib/types/commands/commands/insert-row-col.command.d.ts +2 -0
  11. package/lib/types/commands/commands/register-range-theme.command.d.ts +7 -0
  12. package/lib/types/commands/commands/remove-row-col.command.d.ts +12 -0
  13. package/lib/types/commands/commands/unregister-range-theme.command.d.ts +6 -0
  14. package/lib/types/commands/mutations/add-worksheet-range-theme.mutation.d.ts +9 -0
  15. package/lib/types/commands/mutations/delete-worksheet-range-theme.mutation.d.ts +9 -0
  16. package/lib/types/commands/mutations/register-range-theme.mutation.d.ts +8 -0
  17. package/lib/types/commands/mutations/unregister-range-theme-style.mutation.d.ts +6 -0
  18. package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +33 -0
  19. package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +29 -0
  20. package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +13 -0
  21. package/lib/types/facade/f-defined-name.d.ts +61 -61
  22. package/lib/types/facade/f-event.d.ts +30 -0
  23. package/lib/types/facade/f-permission.d.ts +0 -6
  24. package/lib/types/facade/f-range.d.ts +121 -36
  25. package/lib/types/facade/f-selection.d.ts +1 -1
  26. package/lib/types/facade/f-univer.d.ts +22 -6
  27. package/lib/types/facade/f-workbook.d.ts +78 -31
  28. package/lib/types/facade/f-worksheet.d.ts +130 -117
  29. package/lib/types/facade/index.d.ts +2 -1
  30. package/lib/types/facade/utils.d.ts +38 -2
  31. package/lib/types/index.d.ts +17 -3
  32. package/lib/types/model/range-theme-model.d.ts +66 -0
  33. package/lib/types/model/range-theme-util.d.ts +97 -0
  34. package/lib/types/model/range-themes/build-in-theme.factory.d.ts +5 -0
  35. package/lib/types/model/range-themes/default.d.ts +2 -0
  36. package/lib/types/services/range-theme-service.d.ts +34 -0
  37. package/lib/types/services/sheet-interceptor/interceptor-const.d.ts +2 -0
  38. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +5 -3
  39. package/lib/umd/facade.js +1 -1
  40. package/lib/umd/index.js +3 -3
  41. package/package.json +8 -31
  42. package/LICENSE +0 -176
@@ -1,11 +1,11 @@
1
- import { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, Workbook, Worksheet, FBase, ICommandService, Injector, WrapStrategy } from '@univerjs/core';
1
+ import { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, Workbook, Worksheet, FBaseInitialable, ICommandService, Injector, WrapStrategy } from '@univerjs/core';
2
2
  import { SplitDelimiterEnum } from '@univerjs/sheets';
3
3
  import { FHorizontalAlignment, FVerticalAlignment } from './utils';
4
4
  import { FormulaDataModel } from '@univerjs/engine-formula';
5
5
  export type FontLine = 'none' | 'underline' | 'line-through';
6
6
  export type FontStyle = 'normal' | 'italic';
7
7
  export type FontWeight = 'normal' | 'bold';
8
- export declare class FRange extends FBase {
8
+ export declare class FRange extends FBaseInitialable {
9
9
  protected readonly _workbook: Workbook;
10
10
  protected readonly _worksheet: Worksheet;
11
11
  protected readonly _range: IRange;
@@ -15,44 +15,37 @@ export declare class FRange extends FBase {
15
15
  constructor(_workbook: Workbook, _worksheet: Worksheet, _range: IRange, _injector: Injector, _commandService: ICommandService, _formulaDataModel: FormulaDataModel);
16
16
  /**
17
17
  * Get the unit ID of the current workbook
18
- *
19
- * @return The unit ID of the workbook
18
+ * @returns The unit ID of the workbook
20
19
  */
21
20
  getUnitId(): string;
22
21
  /**
23
22
  * Gets the name of the worksheet
24
- *
25
- * @return The name of the worksheet
23
+ * @returns The name of the worksheet
26
24
  */
27
25
  getSheetName(): string;
28
26
  /**
29
27
  * Gets the area where the statement is applied
30
- *
31
- * @return The area where the statement is applied
28
+ * @returns The area where the statement is applied
32
29
  */
33
30
  getRange(): IRange;
34
31
  /**
35
32
  * Gets the starting row number of the applied area
36
- *
37
- * @return The starting row number of the area
33
+ * @returns The starting row number of the area
38
34
  */
39
35
  getRow(): number;
40
36
  /**
41
37
  * Gets the starting column number of the applied area
42
- *
43
- * @return The starting column number of the area
38
+ * @returns The starting column number of the area
44
39
  */
45
40
  getColumn(): number;
46
41
  /**
47
42
  * Gets the width of the applied area
48
- *
49
- * @return The width of the area
43
+ * @returns The width of the area
50
44
  */
51
45
  getWidth(): number;
52
46
  /**
53
47
  * Gets the height of the applied area
54
- *
55
- * @return The height of the area
48
+ * @returns The height of the area
56
49
  */
57
50
  getHeight(): number;
58
51
  /**
@@ -97,46 +90,53 @@ export declare class FRange extends FBase {
97
90
  getVerticalAlignment(): string;
98
91
  /**
99
92
  * Set background color for current range.
93
+ * @param color {string}
100
94
  * @example
101
- * ```
95
+ * ```typescript
102
96
  * univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackgroundColor('red')
103
97
  * ```
104
- * @param color {string}
105
98
  */
106
- setBackgroundColor(color: string): Promise<boolean>;
99
+ setBackgroundColor(color: string): FRange;
107
100
  /**
108
101
  * Set background color for current range.
109
- * e.g. `univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')`
102
+ * @example
103
+ * ```typescript
104
+ * univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')
105
+ * ```
110
106
  * @param color {string}
111
107
  */
112
- setBackground(color: string): Promise<boolean>;
108
+ setBackground(color: string): FRange;
113
109
  /**
114
110
  * The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
115
111
  * @param value
116
112
  */
117
- setValue(value: CellValue | ICellData): Promise<boolean>;
113
+ setValue(value: CellValue | ICellData): FRange;
118
114
  /**
119
115
  * Set the cell wrap of the given range.
120
116
  * Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
117
+ * @param isWrapEnabled
121
118
  */
122
- setWrap(isWrapEnabled: boolean): Promise<boolean>;
119
+ setWrap(isWrapEnabled: boolean): FRange;
123
120
  /**
124
121
  * Sets the text wrapping strategy for the cells in the range.
122
+ * @param strategy
125
123
  */
126
- setWrapStrategy(strategy: WrapStrategy): Promise<boolean>;
124
+ setWrapStrategy(strategy: WrapStrategy): FRange;
127
125
  /**
128
126
  * Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
127
+ * @param alignment
129
128
  */
130
- setVerticalAlignment(alignment: FVerticalAlignment): Promise<boolean>;
129
+ setVerticalAlignment(alignment: FVerticalAlignment): FRange;
131
130
  /**
132
131
  * Set the horizontal (left to right) alignment for the given range (left/center/right).
132
+ * @param alignment
133
133
  */
134
- setHorizontalAlignment(alignment: FHorizontalAlignment): Promise<boolean>;
134
+ setHorizontalAlignment(alignment: FHorizontalAlignment): FRange;
135
135
  /**
136
136
  * Sets a different value for each cell in the range. The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats. If a value begins with `=`, it is interpreted as a formula.
137
137
  * @param value
138
138
  */
139
- setValues(value: CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>): Promise<boolean>;
139
+ setValues(value: CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>): FRange;
140
140
  /**
141
141
  * Sets the font weight for the given range (normal/bold),
142
142
  * @param fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
@@ -154,10 +154,12 @@ export declare class FRange extends FBase {
154
154
  setFontLine(fontLine: FontLine | null): this;
155
155
  /**
156
156
  * Sets the font underline style of the given ITextDecoration
157
+ * @param value
157
158
  */
158
159
  private _setFontUnderline;
159
160
  /**
160
161
  * Sets the font strikethrough style of the given ITextDecoration
162
+ * @param value
161
163
  */
162
164
  private _setFontStrikethrough;
163
165
  /**
@@ -177,36 +179,80 @@ export declare class FRange extends FBase {
177
179
  setFontColor(color: string | null): this;
178
180
  /**
179
181
  * Merge cells in a range into one merged cell
180
- *
181
182
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
182
- *
183
183
  * @returns This range, for chaining
184
+ * @example
185
+ * ```ts
186
+ * const workbook = univerAPI.getActiveWorkbook();
187
+ * const worksheet = workbook.getActiveSheet();
188
+ * const range = worksheet.getRange(0, 0, 2, 2);
189
+ * const merge = range.merge();
190
+ * const isMerged = merge.isMerged();
191
+ * console.log('debugger', isMerged);
192
+ * ```
184
193
  */
185
- merge(defaultMerge?: boolean): Promise<FRange>;
194
+ merge(defaultMerge?: boolean): FRange;
186
195
  /**
187
196
  * Merges cells in a range horizontally.
188
- *
189
197
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
190
- *
191
198
  * @returns This range, for chaining
199
+ * @example
200
+ * ```ts
201
+ * const workbook = univerAPI.getActiveWorkbook();
202
+ * const worksheet = workbook.getActiveSheet();
203
+ * const range = worksheet.getRange(2, 2, 2, 2);
204
+ * const merge = range.mergeAcross();
205
+ * const allMerge = worksheet.getMergeData();
206
+ * console.log(allMerge.length); // There will be two merged cells.
207
+ * ```
192
208
  */
193
- mergeAcross(defaultMerge?: boolean): Promise<FRange>;
209
+ mergeAcross(defaultMerge?: boolean): FRange;
194
210
  /**
195
211
  * Merges cells in a range vertically.
196
- *
197
212
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
198
- *
199
213
  * @returns This range, for chaining
214
+ * @example
215
+ * ```ts
216
+ * const workbook = univerAPI.getActiveWorkbook();
217
+ * const worksheet = workbook.getActiveSheet();
218
+ * const range = worksheet.getRange(4, 4, 2, 2);
219
+ * const merge = range.mergeVertically();
220
+ * const allMerge = worksheet.getMergeData();
221
+ * console.log(allMerge.length); // There will be two merged cells.
222
+ * ```
200
223
  */
201
- mergeVertically(defaultMerge?: boolean): Promise<FRange>;
224
+ mergeVertically(defaultMerge?: boolean): FRange;
202
225
  /**
203
226
  * Returns true if cells in the current range overlap a merged cell.
204
227
  * @returns {boolean} is overlap with a merged cell
228
+ * @example
229
+ * ```ts
230
+ * const workbook = univerAPI.getActiveWorkbook();
231
+ * const worksheet = workbook.getActiveSheet();
232
+ * const range = worksheet.getRange(0,0,2,2);
233
+ * const merge = range.merge();
234
+ * const anchor = worksheet.getRange(0,0);
235
+ * const isPartOfMerge = anchor.isPartOfMerge();
236
+ * console.log('debugger, isPartOfMerge) // true
237
+ * ```
205
238
  */
206
239
  isPartOfMerge(): boolean;
207
240
  /**
208
241
  * Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
209
242
  * @returns This range, for chaining
243
+ * @example
244
+ * ```ts
245
+ * const workbook = univerAPI.getActiveWorkbook();
246
+ * const worksheet = workbook.getActiveSheet();
247
+ * const range = worksheet.getRange(0,0,2,2);
248
+ * const merge = range.merge();
249
+ * const anchor = worksheet.getRange(0,0);
250
+ * const isPartOfMergeFirst = anchor.isPartOfMerge();
251
+ * console.log('debugger' isPartOfMergeFirst) // true
252
+ * range.breakApart();
253
+ * const isPartOfMergeSecond = anchor.isPartOfMerge();
254
+ * console.log('debugger' isPartOfMergeSecond) // false
255
+ * ```
210
256
  */
211
257
  breakApart(): FRange;
212
258
  /**
@@ -227,6 +273,7 @@ export declare class FRange extends FBase {
227
273
  forEach(callback: (row: number, col: number, cell: ICellData) => void): void;
228
274
  /**
229
275
  * Returns a string description of the range, in A1 notation.
276
+ * @param withSheet
230
277
  * @returns {string} The A1 notation of the range.
231
278
  * ```ts
232
279
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -281,4 +328,42 @@ export declare class FRange extends FBase {
281
328
  * @returns {void}
282
329
  */
283
330
  splitTextToColumns(treatMultipleDelimitersAsOne?: boolean, delimiter?: SplitDelimiterEnum): void;
331
+ /**
332
+ * Set the theme style for the range.
333
+ * @param {string|undefined} themeName The name of the theme style to apply.If a undefined value is passed, the theme style will be removed if it exist.
334
+ * @example
335
+ * ```ts
336
+ * const fWorkbook = univerAPI.getActiveWorkbook();
337
+ * const fWorksheet = fWorkbook.getActiveSheet();
338
+ * const fRange = fWorksheet.getRange('A1:E20');
339
+ * fRange.useThemeStyle('default');
340
+ * ```
341
+ */
342
+ useThemeStyle(themeName: string | undefined): void;
343
+ /**
344
+ * Remove the theme style for the range.
345
+ * @param {string} themeName The name of the theme style to remove.
346
+ * @example
347
+ * ```ts
348
+ * const fWorkbook = univerAPI.getActiveWorkbook();
349
+ * const fWorksheet = fWorkbook.getActiveSheet();
350
+ * const fRange = fWorksheet.getRange('A1:E20');
351
+ * fRange.removeThemeStyle('default');
352
+ * ```
353
+ */
354
+ removeThemeStyle(themeName: string): void;
355
+ /**
356
+ * Gets the theme style applied to the range.
357
+ * @returns {string | undefined} The name of the theme style applied to the range or not exist.
358
+ * @example
359
+ * ```ts
360
+ * const fWorkbook = univerAPI.getActiveWorkbook();
361
+ * const fWorksheet = fWorkbook.getActiveSheet();
362
+ * const fRange = fWorksheet.getRange('A1:E20');
363
+ * fRange.useThemeStyle('default');
364
+ * const themeStyle = fRange.getUsedThemeStyle();
365
+ * console.log(themeStyle); // 'default'
366
+ * ```
367
+ */
368
+ getUsedThemeStyle(): string | undefined;
284
369
  }
@@ -61,7 +61,7 @@ export declare class FSelection {
61
61
  * console.log(newSelection.getActiveRange().getA1Notation()); // A1
62
62
  * ```
63
63
  */
64
- updatePrimaryCell(cell: FRange): Promise<FSelection>;
64
+ updatePrimaryCell(cell: FRange): FSelection;
65
65
  /**
66
66
  *Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
67
67
  * @param {Direction} direction The direction to move the primary cell.The enum value is maybe one of the following: UP(0),RIGHT(1), DOWN(2), LEFT(3).
@@ -1,4 +1,4 @@
1
- import { IDisposable, IWorkbookData, FUniver } from '@univerjs/core';
1
+ import { IDisposable, Injector, IWorkbookData, FUniver } from '@univerjs/core';
2
2
  import { FDefinedNameBuilder } from './f-defined-name';
3
3
  import { FPermission } from './f-permission';
4
4
  import { FWorkbook } from './f-workbook';
@@ -8,12 +8,23 @@ export interface IFUniverSheetsMixin {
8
8
  *
9
9
  * @param {Partial<IWorkbookData>} data The snapshot of the spreadsheet.
10
10
  * @returns {FWorkbook} FWorkbook API instance.
11
+ * @example
12
+ * ```ts
13
+ * univerAPI.createUniverSheet({ id: 'Sheet1', name: 'Sheet1' });
14
+ * ```
11
15
  */
12
16
  createUniverSheet(data: Partial<IWorkbookData>): FWorkbook;
13
17
  /**
14
18
  * Get the currently focused Univer spreadsheet.
15
- *
16
19
  * @returns {FWorkbook | null} The currently focused Univer spreadsheet.
20
+ * @example
21
+ * ```ts
22
+ * univerAPI.getActiveUniverSheet();
23
+ * ```
24
+ */
25
+ getActiveUniverSheet(): FWorkbook | null;
26
+ /**
27
+ * @deprecated use `getActiveUniverSheet` as instead.
17
28
  */
18
29
  getActiveWorkbook(): FWorkbook | null;
19
30
  /**
@@ -25,23 +36,28 @@ export interface IFUniverSheetsMixin {
25
36
  getUniverSheet(id: string): FWorkbook | null;
26
37
  /**
27
38
  * Get the PermissionInstance.
28
- * @deprecated This function is deprecated and will be removed in version 0.6.0.
29
- * Please use the function with the same name on the `FWorkbook` instance instead.
30
- * @returns {FPermission} - The PermissionInstance.
39
+ * @deprecated This function is deprecated and will be removed in version 0.6.0. Please use the function with the same name on the `FWorkbook` instance instead.
31
40
  */
32
41
  getPermission(): FPermission;
33
42
  /**
34
- * Register a callback that will be triggered when a Univer Sheet is created.
43
+ * @deprecated Use `univerAPI.addEvent(univerAPI.Event.UnitCreated, () => {})`
35
44
  */
36
45
  onUniverSheetCreated(callback: (workbook: FWorkbook) => void): IDisposable;
37
46
  /**
38
47
  * Create a new defined name builder.
39
48
  * @returns {FDefinedNameBuilder} - The defined name builder.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * univerAPI.newDefinedName();
53
+ * ```
40
54
  */
41
55
  newDefinedName(): FDefinedNameBuilder;
42
56
  }
43
57
  export declare class FUniverSheetsMixin extends FUniver implements IFUniverSheetsMixin {
58
+ _initialize(injector: Injector): void;
44
59
  createUniverSheet(data: Partial<IWorkbookData>): FWorkbook;
60
+ getActiveUniverSheet(): FWorkbook | null;
45
61
  getActiveWorkbook(): FWorkbook | null;
46
62
  getUniverSheet(id: string): FWorkbook | null;
47
63
  getPermission(): FPermission;
@@ -1,11 +1,11 @@
1
- import { CommandListener, IDisposable, IRange, IWorkbookData, LocaleType, Workbook, FBase, ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService, LocaleService } from '@univerjs/core';
1
+ import { CommandListener, IDisposable, IRange, IWorkbookData, LocaleType, Workbook, FBaseInitialable, ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { ISetDefinedNameMutationParam, IDefinedNamesService } from '@univerjs/engine-formula';
3
- import { SheetsSelectionsService } from '@univerjs/sheets';
3
+ import { RangeThemeStyle, SheetsSelectionsService } from '@univerjs/sheets';
4
4
  import { FDefinedName } from './f-defined-name';
5
5
  import { FPermission } from './f-permission';
6
6
  import { FRange } from './f-range';
7
7
  import { FWorksheet } from './f-worksheet';
8
- export declare class FWorkbook extends FBase {
8
+ export declare class FWorkbook extends FBaseInitialable {
9
9
  protected readonly _workbook: Workbook;
10
10
  protected readonly _injector: Injector;
11
11
  protected readonly _resourceLoaderService: IResourceLoaderService;
@@ -52,8 +52,8 @@ export declare class FWorkbook extends FBase {
52
52
  */
53
53
  setName(name: string): void;
54
54
  /**
55
- * save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
56
- * @return Workbook snapshot data
55
+ * Save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
56
+ * @returns {IWorkbookData} Workbook snapshot data
57
57
  * @example
58
58
  * ```ts
59
59
  * // The code below saves the workbook snapshot data
@@ -64,13 +64,13 @@ export declare class FWorkbook extends FBase {
64
64
  save(): IWorkbookData;
65
65
  /**
66
66
  * @deprecated use 'save' instead.
67
- * @return {*} {IWorkbookData} Workbook snapshot data
67
+ * @returns {*} {IWorkbookData} Workbook snapshot data
68
68
  * @memberof FWorkbook
69
69
  */
70
70
  getSnapshot(): IWorkbookData;
71
71
  /**
72
72
  * Get the active sheet of the workbook.
73
- * @returns The active sheet of the workbook
73
+ * @returns {FWorksheet} The active sheet of the workbook
74
74
  * @example
75
75
  * ```ts
76
76
  * // The code below gets the active sheet of the workbook
@@ -81,7 +81,7 @@ export declare class FWorkbook extends FBase {
81
81
  getActiveSheet(): FWorksheet;
82
82
  /**
83
83
  * Gets all the worksheets in this workbook
84
- * @returns An array of all the worksheets in the workbook
84
+ * @returns {FWorksheet[]} An array of all the worksheets in the workbook
85
85
  * @example
86
86
  * ```ts
87
87
  * // The code below gets all the worksheets in the workbook
@@ -107,7 +107,7 @@ export declare class FWorkbook extends FBase {
107
107
  /**
108
108
  * Get a worksheet by sheet id.
109
109
  * @param sheetId The id of the sheet to get.
110
- * @return The worksheet with given sheet id
110
+ * @returns The worksheet with given sheet id
111
111
  * @example
112
112
  * ```ts
113
113
  * // The code below gets a worksheet by sheet id
@@ -161,6 +161,7 @@ export declare class FWorkbook extends FBase {
161
161
  /**
162
162
  * Deletes the specified worksheet.
163
163
  * @param sheet The worksheet to delete.
164
+ * @returns {boolean} True if the worksheet was deleted, false otherwise.
164
165
  * @example
165
166
  * ```ts
166
167
  * // The code below deletes the specified worksheet
@@ -169,10 +170,10 @@ export declare class FWorkbook extends FBase {
169
170
  * activeSpreadsheet.deleteSheet(sheet);
170
171
  * ```
171
172
  */
172
- deleteSheet(sheet: FWorksheet): Promise<boolean>;
173
+ deleteSheet(sheet: FWorksheet): boolean;
173
174
  /**
174
175
  * Undo the last action.
175
- * @returns A promise that resolves to true if the undo was successful, false otherwise.
176
+ * @returns {FWorkbook} A promise that resolves to true if the undo was successful, false otherwise.
176
177
  * @example
177
178
  * ```ts
178
179
  * // The code below undoes the last action
@@ -180,7 +181,7 @@ export declare class FWorkbook extends FBase {
180
181
  * activeSpreadsheet.undo();
181
182
  * ```
182
183
  */
183
- undo(): Promise<boolean>;
184
+ undo(): FWorkbook;
184
185
  /**
185
186
  * Redo the last undone action.
186
187
  * @returns A promise that resolves to true if the redo was successful, false otherwise.
@@ -191,7 +192,7 @@ export declare class FWorkbook extends FBase {
191
192
  * activeSpreadsheet.redo();
192
193
  * ```
193
194
  */
194
- redo(): Promise<boolean>;
195
+ redo(): FWorkbook;
195
196
  /**
196
197
  * Callback for command execution.
197
198
  * @callback onBeforeCommandExecuteCallback
@@ -231,7 +232,6 @@ export declare class FWorkbook extends FBase {
231
232
  onCommandExecuted(callback: CommandListener): IDisposable;
232
233
  /**
233
234
  * Callback for selection changes.
234
- *
235
235
  * @callback onSelectionChangeCallback
236
236
  * @param {IRange[]} selections The new selection.
237
237
  */
@@ -244,13 +244,15 @@ export declare class FWorkbook extends FBase {
244
244
  /**
245
245
  * Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
246
246
  * @param {boolean} value editable value want to set
247
+ * @returns {FWorkbook} FWorkbook instance
247
248
  */
248
- setEditable(value: boolean): void;
249
+ setEditable(value: boolean): FWorkbook;
249
250
  /**
250
- * Sets the active selection region for this sheet.
251
+ * Sets the selection region for active sheet.
251
252
  * @param range The range to set as the active selection.
253
+ * @returns {FWorkbook} FWorkbook instance
252
254
  */
253
- setActiveRange(range: FRange): void;
255
+ setActiveRange(range: FRange): FWorkbook;
254
256
  /**
255
257
  * Returns the selected range in the active sheet, or null if there is no active range.
256
258
  * @returns the active range
@@ -258,6 +260,7 @@ export declare class FWorkbook extends FBase {
258
260
  getActiveRange(): FRange | null;
259
261
  /**
260
262
  * Deletes the currently active sheet.
263
+ * @returns {boolean} true if the sheet was deleted, false otherwise
261
264
  * @example
262
265
  * ```ts
263
266
  * // The code below deletes the currently active sheet and stores the new active
@@ -265,11 +268,11 @@ export declare class FWorkbook extends FBase {
265
268
  * const sheet = univerAPI.getActiveWorkbook().deleteActiveSheet();
266
269
  * ```
267
270
  */
268
- deleteActiveSheet(): Promise<boolean>;
271
+ deleteActiveSheet(): boolean;
269
272
  /**
270
273
  * Duplicates the given worksheet.
271
274
  * @param {FWorksheet} sheet The worksheet to duplicate.
272
- * @returns {Promise<boolean>} true if the sheet was duplicated, false otherwise
275
+ * @returns {FWorksheet} The duplicated worksheet
273
276
  * @example
274
277
  * ```ts
275
278
  * // The code below duplicates the given worksheet
@@ -278,10 +281,10 @@ export declare class FWorkbook extends FBase {
278
281
  * activeSpreadsheet.duplicateSheet(activeSheet);
279
282
  * ```
280
283
  */
281
- duplicateSheet(sheet: FWorksheet): Promise<boolean>;
284
+ duplicateSheet(sheet: FWorksheet): FWorksheet;
282
285
  /**
283
286
  * Duplicates the active sheet.
284
- * @returns {Promise<boolean>} true if the sheet was duplicated, false otherwise
287
+ * @returns {FWorksheet} The duplicated worksheet
285
288
  * @example
286
289
  * ```ts
287
290
  * // The code below duplicates the active sheet
@@ -289,7 +292,7 @@ export declare class FWorkbook extends FBase {
289
292
  * activeSpreadsheet.duplicateActiveSheet();
290
293
  * ```
291
294
  */
292
- duplicateActiveSheet(): Promise<boolean>;
295
+ duplicateActiveSheet(): FWorksheet;
293
296
  /**
294
297
  * Get the number of sheets in the workbook.
295
298
  * @returns The number of sheets in the workbook
@@ -312,9 +315,15 @@ export declare class FWorkbook extends FBase {
312
315
  * ```
313
316
  */
314
317
  getLocale(): LocaleType;
318
+ /**
319
+ * @deprecated use setSpreadsheetLocale instead.
320
+ * @param {LocaleType} locale - The locale to set
321
+ */
322
+ setLocale(locale: LocaleType): void;
315
323
  /**
316
324
  * Set the locale of the workbook.
317
325
  * @param {LocaleType} locale The locale to set
326
+ * @returns {FWorkbook} This workbook, for chaining
318
327
  * @example
319
328
  * ```ts
320
329
  * // The code below sets the locale of the workbook
@@ -322,7 +331,7 @@ export declare class FWorkbook extends FBase {
322
331
  * activeSpreadsheet.setLocale(LocaleType.EN_US);
323
332
  * ```
324
333
  */
325
- setLocale(locale: LocaleType): void;
334
+ setSpreadsheetLocale(locale: LocaleType): FWorkbook;
326
335
  /**
327
336
  * Get the URL of the workbook.
328
337
  * @returns {string} The URL of the workbook
@@ -338,7 +347,7 @@ export declare class FWorkbook extends FBase {
338
347
  * Move the sheet to the specified index.
339
348
  * @param {FWorksheet} sheet The sheet to move
340
349
  * @param {number} index The index to move the sheet to
341
- * @returns {Promise<boolean>} true if the sheet was moved, false otherwise
350
+ * @returns {FWorkbook} This workbook, for chaining
342
351
  * @example
343
352
  * ```ts
344
353
  * // The code below moves the sheet to the specified index
@@ -347,11 +356,11 @@ export declare class FWorkbook extends FBase {
347
356
  * activeSpreadsheet.moveSheet(sheet, 1);
348
357
  * ```
349
358
  */
350
- moveSheet(sheet: FWorksheet, index: number): Promise<boolean>;
359
+ moveSheet(sheet: FWorksheet, index: number): FWorkbook;
351
360
  /**
352
361
  * Move the active sheet to the specified index.
353
362
  * @param {number} index The index to move the active sheet to
354
- * @returns {Promise<boolean>} true if the sheet was moved, false otherwise
363
+ * @returns {FWorkbook} This workbook, for chaining
355
364
  * @example
356
365
  * ```ts
357
366
  * // The code below moves the active sheet to the specified index
@@ -359,10 +368,9 @@ export declare class FWorkbook extends FBase {
359
368
  * activeSpreadsheet.moveActiveSheet(1);
360
369
  * ```
361
370
  */
362
- moveActiveSheet(index: number): Promise<boolean>;
371
+ moveActiveSheet(index: number): FWorkbook;
363
372
  /**
364
373
  * Get the PermissionInstance.
365
- *
366
374
  * @returns {FPermission} - The PermissionInstance.
367
375
  */
368
376
  getPermission(): FPermission;
@@ -393,6 +401,7 @@ export declare class FWorkbook extends FBase {
393
401
  * Insert a defined name.
394
402
  * @param {string} name The name of the defined name to insert
395
403
  * @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
404
+ * @returns {FWorkbook} The current FWorkbook instance
396
405
  * @example
397
406
  * ```ts
398
407
  * // The code below inserts a defined name
@@ -400,7 +409,7 @@ export declare class FWorkbook extends FBase {
400
409
  * activeSpreadsheet.insertDefinedName('MyDefinedName', 'Sheet1!A1');
401
410
  * ```
402
411
  */
403
- insertDefinedName(name: string, formulaOrRefString: string): void;
412
+ insertDefinedName(name: string, formulaOrRefString: string): FWorkbook;
404
413
  /**
405
414
  * Delete the defined name with the given name.
406
415
  * @param {string} name The name of the defined name to delete
@@ -414,7 +423,7 @@ export declare class FWorkbook extends FBase {
414
423
  */
415
424
  deleteDefinedName(name: string): boolean;
416
425
  /**
417
- * insert a defined name by builder param
426
+ * Insert a defined name by builder param.
418
427
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
419
428
  * @example
420
429
  * ```ts
@@ -436,8 +445,46 @@ export declare class FWorkbook extends FBase {
436
445
  * const builder = activeSpreadsheet.getDefinedName('MyDefinedName').toBuilder();
437
446
  * builder.setRef('Sheet1!A2').setName('MyDefinedName1').build();
438
447
  * activeSpreadsheet.updateDefinedNameBuilder(param);
439
- *
440
448
  * ```
441
449
  */
442
450
  updateDefinedNameBuilder(param: ISetDefinedNameMutationParam): void;
451
+ /**
452
+ * Gets the registered range themes.
453
+ * @returns {string[]} The name list of registered range themes.
454
+ * @example
455
+ * ```ts
456
+ * // The code below gets the registered range themes
457
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
458
+ * const themes = activeSpreadsheet.getRegisteredRangeThemes();
459
+ * console.log(themes);
460
+ * ```
461
+ */
462
+ getRegisteredRangeThemes(): string[];
463
+ /**
464
+ * Register a custom range theme style.
465
+ * @param rangeThemeStyle
466
+ * @example
467
+ * ```ts
468
+ * // import {RangeThemeStyle} from '@univerjs/sheets';
469
+ * const fWorkbook = univerAPI.getActiveWorkbook();
470
+ * const rangeThemeStyle = new RangeThemeStyle('MyTheme');
471
+ * rangeThemeStyle.setSecondRowStyle({
472
+ * bg: {
473
+ * rgb: 'rgb(214,231,241)',
474
+ * },
475
+ * });
476
+ * fWorkbook.registerRangeTheme(rangeThemeStyle);
477
+ * ```
478
+ */
479
+ registerRangeTheme(rangeThemeStyle: RangeThemeStyle): void;
480
+ /**
481
+ * Unregister a custom range theme style.
482
+ * @param themeName
483
+ * @example
484
+ * ```ts
485
+ * const fWorkbook = univerAPI.getActiveWorkbook();
486
+ * fWorkbook.unregisterRangeTheme('MyTheme');
487
+ * ```
488
+ */
489
+ unregisterRangeTheme(themeName: string): void;
443
490
  }