@univerjs/sheets 0.4.2 → 0.5.0-alpha.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.
Files changed (53) hide show
  1. package/lib/cjs/facade.js +1 -0
  2. package/lib/cjs/index.js +3 -3
  3. package/lib/cjs/locale/en-US.js +1 -0
  4. package/lib/cjs/locale/fa-IR.js +1 -0
  5. package/lib/cjs/locale/ru-RU.js +1 -0
  6. package/lib/cjs/locale/vi-VN.js +1 -0
  7. package/lib/cjs/locale/zh-CN.js +1 -0
  8. package/lib/cjs/locale/zh-TW.js +1 -0
  9. package/lib/es/facade.js +1806 -0
  10. package/lib/es/index.js +7447 -7530
  11. package/lib/es/locale/en-US.js +17 -0
  12. package/lib/es/locale/fa-IR.js +17 -0
  13. package/lib/es/locale/ru-RU.js +17 -0
  14. package/lib/es/locale/vi-VN.js +17 -0
  15. package/lib/es/locale/zh-CN.js +17 -0
  16. package/lib/es/locale/zh-TW.js +17 -0
  17. package/lib/types/commands/commands/add-worksheet-protection.command.d.ts +7 -0
  18. package/lib/types/commands/commands/delete-worksheet-protection.command.d.ts +8 -0
  19. package/lib/types/commands/commands/set-frozen.command.d.ts +13 -0
  20. package/lib/types/commands/commands/set-protection.command.d.ts +13 -0
  21. package/lib/types/commands/commands/set-worksheet-protection.command.d.ts +8 -0
  22. package/lib/types/commands/mutations/reorder-range.mutation.d.ts +1 -1
  23. package/lib/types/facade/__tests__/utils.spec.d.ts +16 -0
  24. package/lib/types/facade/f-permission.d.ts +106 -0
  25. package/lib/types/facade/f-range.d.ts +193 -0
  26. package/lib/types/facade/f-selection.d.ts +11 -0
  27. package/lib/types/facade/f-univer.d.ts +36 -0
  28. package/lib/types/facade/f-workbook.d.ts +105 -0
  29. package/lib/types/facade/f-worksheet.d.ts +408 -0
  30. package/lib/types/facade/index.d.ts +22 -0
  31. package/lib/types/facade/utils.d.ts +24 -0
  32. package/lib/types/index.d.ts +8 -5
  33. package/lib/types/model/range-protection-rule.model.d.ts +10 -1
  34. package/lib/types/services/permission/type.d.ts +3 -1
  35. package/lib/types/services/permission/worksheet-permission/worksheet-permission.service.d.ts +3 -2
  36. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +38 -7
  37. package/lib/umd/facade.js +1 -0
  38. package/lib/umd/index.js +3 -3
  39. package/lib/umd/locale/en-US.js +1 -0
  40. package/lib/umd/locale/fa-IR.js +1 -0
  41. package/lib/umd/locale/ru-RU.js +1 -0
  42. package/lib/umd/locale/vi-VN.js +1 -0
  43. package/lib/umd/locale/zh-CN.js +1 -0
  44. package/lib/umd/locale/zh-TW.js +1 -0
  45. package/package.json +36 -17
  46. package/lib/locale/en-US.json +0 -14
  47. package/lib/locale/fa-IR.json +0 -14
  48. package/lib/locale/ru-RU.json +0 -14
  49. package/lib/locale/vi-VN.json +0 -14
  50. package/lib/locale/zh-CN.json +0 -14
  51. package/lib/locale/zh-TW.json +0 -14
  52. package/lib/types/commands/commands/set-frozen-cancel.command.d.ts +0 -2
  53. package/lib/types/commands/commands/set-range-protection.command.d.ts +0 -8
@@ -0,0 +1,408 @@
1
+ import { CustomData, ICellData, IDisposable, IFreeze, IObjectArrayPrimitiveType, IStyleData, Nullable, Workbook, Worksheet, FBase, ICommandService, Injector, ObjectMatrix } from '@univerjs/core';
2
+ import { FWorkbook } from './f-workbook';
3
+ import { SheetsSelectionsService } from '@univerjs/sheets';
4
+ import { FRange } from './f-range';
5
+ import { FSelection } from './f-selection';
6
+ export declare class FWorksheet extends FBase {
7
+ protected readonly _fWorkbook: FWorkbook;
8
+ protected readonly _workbook: Workbook;
9
+ protected readonly _worksheet: Worksheet;
10
+ protected readonly _injector: Injector;
11
+ protected readonly _selectionManagerService: SheetsSelectionsService;
12
+ protected readonly _commandService: ICommandService;
13
+ constructor(_fWorkbook: FWorkbook, _workbook: Workbook, _worksheet: Worksheet, _injector: Injector, _selectionManagerService: SheetsSelectionsService, _commandService: ICommandService);
14
+ /**
15
+ * Returns the injector
16
+ * @returns The injector
17
+ */
18
+ getInject(): Injector;
19
+ /**
20
+ * Returns the workbook
21
+ * @returns The workbook
22
+ */
23
+ getWorkbook(): Workbook;
24
+ /**
25
+ * Returns the worksheet id
26
+ * @returns The id of the worksheet
27
+ */
28
+ getSheetId(): string;
29
+ /**
30
+ * Returns the worksheet name
31
+ * @returns The name of the worksheet
32
+ */
33
+ getSheetName(): string;
34
+ getSelection(): FSelection | null;
35
+ /**
36
+ * Get the default style of the worksheet
37
+ * @returns Default style
38
+ */
39
+ getDefaultStyle(): Nullable<IStyleData> | string;
40
+ /**
41
+ * Get the default style of the worksheet row
42
+ * @param {number} index The row index
43
+ * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from row manager
44
+ * @returns {Nullable<IStyleData> | string} The default style of the worksheet row name or style data
45
+ */
46
+ getRowDefaultStyle(index: number, keepRaw?: boolean): Nullable<IStyleData> | string;
47
+ /**
48
+ * Get the default style of the worksheet column
49
+ * @param {number} index The column index
50
+ * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
51
+ * @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data
52
+ */
53
+ getColumnDefaultStyle(index: number, keepRaw?: boolean): Nullable<IStyleData> | string;
54
+ /**
55
+ * Set the default style of the worksheet
56
+ * @param style default style
57
+ * @returns this worksheet
58
+ */
59
+ setDefaultStyle(style: string): Promise<FWorksheet>;
60
+ /**
61
+ * Set the default style of the worksheet row
62
+ * @param {number} index The row index
63
+ * @param {string | Nullable<IStyleData>} style The style name or style data
64
+ */
65
+ setColumnDefaultStyle(index: number, style: string | Nullable<IStyleData>): Promise<FWorksheet>;
66
+ /**
67
+ * Set the default style of the worksheet column
68
+ * @param {number} index The column index
69
+ * @param {string | Nullable<IStyleData>} style The style name or style data
70
+ */
71
+ setRowDefaultStyle(index: number, style: string | Nullable<IStyleData>): Promise<FWorksheet>;
72
+ /**
73
+ * Returns a Range object representing a single cell at the specified row and column.
74
+ * @param row The row index of the cell.
75
+ * @param column The column index of the cell.
76
+ * @returns A Range object representing the specified cell.
77
+ */
78
+ getRange(row: number, column: number): FRange;
79
+ /**
80
+ * Returns a Range object representing a range starting at the specified row and column, with the specified number of rows.
81
+ * @param row The starting row index of the range.
82
+ * @param column The starting column index of the range.
83
+ * @param numRows The number of rows in the range.
84
+ * @returns A Range object representing the specified range.
85
+ */
86
+ getRange(row: number, column: number, numRows: number): FRange;
87
+ /**
88
+ * Returns a Range object representing a range starting at the specified row and column, with the specified number of rows and columns.
89
+ * @param row The starting row index of the range.
90
+ * @param column The starting column index of the range.
91
+ * @param numRows The number of rows in the range.
92
+ * @param numColumns The number of columns in the range.
93
+ * @returns A Range object representing the specified range.
94
+ */
95
+ getRange(row: number, column: number, numRows: number, numColumns: number): FRange;
96
+ /**
97
+ * Returns a Range object specified by A1 notation.
98
+ * @param a1Notation A string representing a range in A1 notation.
99
+ * @returns A Range object representing the specified range.
100
+ */
101
+ getRange(a1Notation: string): FRange;
102
+ /**
103
+ * Returns the current number of columns in the sheet, regardless of content.
104
+ * @return The maximum columns count of the sheet
105
+ */
106
+ getMaxColumns(): number;
107
+ /**
108
+ * Returns the current number of rows in the sheet, regardless of content.
109
+ * @return The maximum rows count of the sheet
110
+ */
111
+ getMaxRows(): number;
112
+ /**
113
+ * Inserts a row after the given row position.
114
+ * @param afterPosition The row after which the new row should be added, starting at 0 for the first row.
115
+ * @returns This sheet, for chaining.
116
+ */
117
+ insertRowAfter(afterPosition: number): Promise<FWorksheet>;
118
+ /**
119
+ * Inserts a row before the given row position.
120
+ * @param beforePosition The row before which the new row should be added, starting at 0 for the first row.
121
+ * @returns This sheet, for chaining.
122
+ */
123
+ insertRowBefore(beforePosition: number): Promise<FWorksheet>;
124
+ /**
125
+ * Inserts one or more consecutive blank rows in a sheet starting at the specified location.
126
+ * @param rowIndex The index indicating where to insert a row, starting at 0 for the first row.
127
+ * @param numRows The number of rows to insert.
128
+ * @returns This sheet, for chaining.
129
+ */
130
+ insertRows(rowIndex: number, numRows?: number): Promise<FWorksheet>;
131
+ /**
132
+ * Inserts a number of rows after the given row position.
133
+ * @param afterPosition The row after which the new rows should be added, starting at 0 for the first row.
134
+ * @param howMany The number of rows to insert.
135
+ * @returns This sheet, for chaining.
136
+ */
137
+ insertRowsAfter(afterPosition: number, howMany: number): Promise<FWorksheet>;
138
+ /**
139
+ * Inserts a number of rows before the given row position.
140
+ * @param beforePosition The row before which the new rows should be added, starting at 0 for the first row.
141
+ * @param howMany The number of rows to insert.
142
+ * @returns This sheet, for chaining.
143
+ */
144
+ insertRowsBefore(beforePosition: number, howMany: number): Promise<FWorksheet>;
145
+ /**
146
+ * Deletes the row at the given row position.
147
+ * @param rowPosition The position of the row, starting at 0 for the first row.
148
+ * @returns This sheet, for chaining.
149
+ */
150
+ deleteRow(rowPosition: number): Promise<FWorksheet>;
151
+ /**
152
+ * Deletes a number of rows starting at the given row position.
153
+ * @param rowPosition The position of the first row to delete, starting at 0 for the first row.
154
+ * @param howMany The number of rows to delete.
155
+ * @returns This sheet, for chaining.
156
+ */
157
+ deleteRows(rowPosition: number, howMany: number): Promise<FWorksheet>;
158
+ /**
159
+ * Moves the rows selected by the given range to the position indicated by the destinationIndex. The rowSpec itself does not have to exactly represent an entire row or group of rows to move—it selects all rows that the range spans.
160
+ * @param rowSpec A range spanning the rows that should be moved.
161
+ * @param destinationIndex The index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.
162
+ * @returns This sheet, for chaining.
163
+ */
164
+ moveRows(rowSpec: FRange, destinationIndex: number): Promise<FWorksheet>;
165
+ /**
166
+ * Hides the rows in the given range.
167
+ * @param row The row range to hide.
168
+ * @returns This sheet, for chaining.
169
+ */
170
+ hideRow(row: FRange): Promise<FWorksheet>;
171
+ /**
172
+ * Hides one or more consecutive rows starting at the given index. Use 0-index for this method.
173
+ * @param rowIndex The starting index of the rows to hide.
174
+ * @param numRows The number of rows to hide.
175
+ * @returns This sheet, for chaining.
176
+ */
177
+ hideRows(rowIndex: number, numRows?: number): Promise<FWorksheet>;
178
+ /**
179
+ * Unhides the row in the given range.
180
+ * @param row The range to unhide, if hidden.
181
+ * @returns This sheet, for chaining.
182
+ */
183
+ unhideRow(row: FRange): Promise<FWorksheet>;
184
+ /**
185
+ * Unhides one or more consecutive rows starting at the given index. Use 0-index for this method.
186
+ * @param rowIndex The starting index of the rows to unhide.
187
+ * @param numRows The number of rows to unhide.
188
+ * @returns This sheet, for chaining.
189
+ */
190
+ showRows(rowIndex: number, numRows?: number): Promise<FWorksheet>;
191
+ /**
192
+ * Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
193
+ * @param rowPosition The row position to change.
194
+ * @param height The height in pixels to set it to.
195
+ * @returns This sheet, for chaining.
196
+ */
197
+ setRowHeight(rowPosition: number, height: number): Promise<FWorksheet>;
198
+ /**
199
+ * Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
200
+ * @param startRow The starting row position to change.
201
+ * @param numRows The number of rows to change.
202
+ * @param height The height in pixels to set it to.
203
+ * @returns This sheet, for chaining.
204
+ */
205
+ setRowHeights(startRow: number, numRows: number, height: number): Promise<FWorksheet>;
206
+ /**
207
+ * Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use setRowHeightsForced, rows are forced to the specified height even if the cell contents are taller than the row height.
208
+ * @param startRow The starting row position to change.
209
+ * @param numRows The number of rows to change.
210
+ * @param height The height in pixels to set it to.
211
+ * @returns This sheet, for chaining.
212
+ */
213
+ setRowHeightsForced(startRow: number, numRows: number, height: number): Promise<FWorksheet>;
214
+ /**
215
+ * Set custom properties for given rows.
216
+ * @param custom The custom properties to set.
217
+ * @returns This sheet, for chaining.
218
+ */
219
+ setRowCustom(custom: IObjectArrayPrimitiveType<CustomData>): Promise<FWorksheet>;
220
+ /**
221
+ * Inserts a column after the given column position.
222
+ * @param afterPosition The column after which the new column should be added, starting at 0 for the first column.
223
+ * @returns This sheet, for chaining.
224
+ */
225
+ insertColumnAfter(afterPosition: number): Promise<FWorksheet>;
226
+ /**
227
+ * Inserts a column before the given column position.
228
+ * @param beforePosition The column before which the new column should be added, starting at 0 for the first column.
229
+ * @returns This sheet, for chaining.
230
+ */
231
+ insertColumnBefore(beforePosition: number): Promise<FWorksheet>;
232
+ /**
233
+ * Inserts one or more consecutive blank columns in a sheet starting at the specified location.
234
+ * @param columnIndex The index indicating where to insert a column, starting at 0 for the first column.
235
+ * @param numColumns The number of columns to insert.
236
+ * @returns This sheet, for chaining.
237
+ */
238
+ insertColumns(columnIndex: number, numColumns?: number): Promise<FWorksheet>;
239
+ /**
240
+ * Inserts a given number of columns after the given column position.
241
+ * @param afterPosition The column after which the new column should be added, starting at 0 for the first column.
242
+ * @param howMany The number of columns to insert.
243
+ * @returns This sheet, for chaining.
244
+ */
245
+ insertColumnsAfter(afterPosition: number, howMany: number): Promise<FWorksheet>;
246
+ /**
247
+ * Inserts a number of columns before the given column position.
248
+ * @param beforePosition The column before which the new column should be added, starting at 0 for the first column.
249
+ * @param howMany The number of columns to insert.
250
+ * @returns This sheet, for chaining.
251
+ */
252
+ insertColumnsBefore(beforePosition: number, howMany: number): Promise<FWorksheet>;
253
+ /**
254
+ * Deletes the column at the given column position.
255
+ * @param columnPosition The position of the column, starting at 0 for the first column.
256
+ * @returns This sheet, for chaining.
257
+ */
258
+ deleteColumn(columnPosition: number): Promise<FWorksheet>;
259
+ /**
260
+ * Deletes a number of columns starting at the given column position.
261
+ * @param columnPosition The position of the first column to delete, starting at 0 for the first column.
262
+ * @param howMany The number of columns to delete.
263
+ * @returns This sheet, for chaining.
264
+ */
265
+ deleteColumns(columnPosition: number, howMany: number): Promise<FWorksheet>;
266
+ /**
267
+ * Moves the columns selected by the given range to the position indicated by the destinationIndex. The columnSpec itself does not have to exactly represent an entire column or group of columns to move—it selects all columns that the range spans.
268
+ * @param columnSpec A range spanning the columns that should be moved.
269
+ * @param destinationIndex The index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.
270
+ * @returns This sheet, for chaining.
271
+ */
272
+ moveColumns(columnSpec: FRange, destinationIndex: number): Promise<FWorksheet>;
273
+ /**
274
+ * Hides the column or columns in the given range.
275
+ * @param column The column range to hide.
276
+ * @returns This sheet, for chaining.
277
+ */
278
+ hideColumn(column: FRange): Promise<FWorksheet>;
279
+ /**
280
+ * Hides one or more consecutive columns starting at the given index. Use 0-index for this method.
281
+ * @param columnIndex The starting index of the columns to hide.
282
+ * @param numColumns The number of columns to hide.
283
+ * @returns This sheet, for chaining.
284
+ */
285
+ hideColumns(columnIndex: number, numColumns?: number): Promise<FWorksheet>;
286
+ /**
287
+ * Unhides the column in the given range.
288
+ * @param column The range to unhide, if hidden.
289
+ * @returns This sheet, for chaining.
290
+ */
291
+ unhideColumn(column: FRange): Promise<FWorksheet>;
292
+ /**
293
+ * Unhides one or more consecutive columns starting at the given index. Use 0-index for this method.
294
+ * @param columnIndex The starting index of the columns to unhide.
295
+ * @param numColumns The number of columns to unhide.
296
+ * @returns This sheet, for chaining.
297
+ */
298
+ showColumns(columnIndex: number, numColumns?: number): Promise<FWorksheet>;
299
+ /**
300
+ * Sets the width of the given column in pixels.
301
+ * @param columnPosition The position of the given column to set.
302
+ * @param width The width in pixels to set it to.
303
+ * @returns This sheet, for chaining.
304
+ */
305
+ setColumnWidth(columnPosition: number, width: number): Promise<FWorksheet>;
306
+ /**
307
+ * Sets the width of the given columns in pixels.
308
+ * @param startColumn The starting column position to change.
309
+ * @param numColumns The number of columns to change.
310
+ * @param width The width in pixels to set it to.
311
+ * @returns This sheet, for chaining.
312
+ */
313
+ setColumnWidths(startColumn: number, numColumns: number, width: number): Promise<FWorksheet>;
314
+ /**
315
+ * Set custom properties for given columns.
316
+ * @param custom The custom properties to set.
317
+ * @returns This sheet, for chaining.
318
+ */
319
+ setColumnCustom(custom: IObjectArrayPrimitiveType<CustomData>): Promise<FWorksheet>;
320
+ /**
321
+ * Get all merged cells in the current sheet
322
+ * @returns all merged cells
323
+ */
324
+ getMergedRanges(): FRange[];
325
+ /**
326
+ * Get the merged cell data of the specified row and column.
327
+ * @param {number} row The row index.
328
+ * @param {number} column The column index.
329
+ * @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged.
330
+ */
331
+ getCellMergeData(row: number, column: number): FRange | undefined;
332
+ /**
333
+ * Returns the selected range in the active sheet, or null if there is no active range.
334
+ * @returns the active range
335
+ */
336
+ getActiveRange(): FRange | null;
337
+ /**
338
+ * Sets the active selection region for this sheet.
339
+ * @param range The range to set as the active selection.
340
+ */
341
+ setActiveRange(range: FRange): void;
342
+ /**
343
+ * Sets the active selection region for this sheet.
344
+ * @param range The range to set as the active selection.
345
+ */
346
+ setActiveSelection: (range: FRange) => void;
347
+ /**
348
+ * Sets the frozen state of the current sheet.
349
+ * @param freeze - The freeze object containing the parameters for freezing the sheet.
350
+ * @returns True if the command was successful, false otherwise.
351
+ */
352
+ setFreeze(freeze: IFreeze): boolean;
353
+ /**
354
+ * Cancels the frozen state of the current sheet.
355
+ * @returns True if the command was successful, false otherwise.
356
+ */
357
+ cancelFreeze(): boolean;
358
+ /**
359
+ * Get the freeze state of the current sheet.
360
+ * @returns The freeze state of the current sheet.
361
+ */
362
+ getFreeze(): IFreeze;
363
+ /**
364
+ * Set the number of frozen columns.
365
+ * @param columns The number of columns to freeze.
366
+ * To unfreeze all columns, set this value to 0.
367
+ */
368
+ setFrozenColumns(columns: number): void;
369
+ /**
370
+ * Set the number of frozen rows.
371
+ * @param rows The number of rows to freeze.
372
+ * To unfreeze all rows, set this value to 0.
373
+ */
374
+ setFrozenRows(rows: number): void;
375
+ /**
376
+ * Get the number of frozen columns.
377
+ * @returns The number of frozen columns.
378
+ * Returns 0 if no columns are frozen.
379
+ */
380
+ getFrozenColumns(): number;
381
+ /**
382
+ * Get the number of frozen rows.
383
+ * @returns The number of frozen rows.
384
+ * Returns 0 if no rows are frozen.
385
+ */
386
+ getFrozenRows(): number;
387
+ /**
388
+ * Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.
389
+ */
390
+ hasHiddenGridLines(): boolean;
391
+ /**
392
+ * Hides or reveals the sheet gridlines.
393
+ * @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.
394
+ */
395
+ setHiddenGridlines(hidden: boolean): Promise<boolean>;
396
+ /**
397
+ * Subscribe to the cell data change event.
398
+ * @param callback - The callback function to be executed when the cell data changes.
399
+ * @returns - A disposable object to unsubscribe from the event.
400
+ */
401
+ onCellDataChange(callback: (cellValue: ObjectMatrix<Nullable<ICellData>>) => void): IDisposable;
402
+ /**
403
+ * Subscribe to the cell data change event.
404
+ * @param callback - The callback function to be executed before the cell data changes.
405
+ * @returns - A disposable object to unsubscribe from the event.
406
+ */
407
+ onBeforeCellDataChange(callback: (cellValue: ObjectMatrix<Nullable<ICellData>>) => void): IDisposable;
408
+ }
@@ -0,0 +1,22 @@
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 './f-univer';
17
+ export { FPermission } from './f-permission';
18
+ export { FRange } from './f-range';
19
+ export type { FontLine, FontStyle, FontWeight } from './f-range';
20
+ export { FSelection } from './f-selection';
21
+ export { FWorkbook } from './f-workbook';
22
+ export { FWorksheet } from './f-worksheet';
@@ -0,0 +1,24 @@
1
+ import { CellValue, ICellData, IObjectMatrixPrimitiveType, IRange, IRangeWithCoord, Worksheet, HorizontalAlign, VerticalAlign } from '@univerjs/core';
2
+ export type FHorizontalAlignment = 'left' | 'center' | 'normal';
3
+ export type FVerticalAlignment = 'top' | 'middle' | 'bottom';
4
+ export declare function transformFacadeHorizontalAlignment(value: FHorizontalAlignment): HorizontalAlign;
5
+ export declare function transformCoreHorizontalAlignment(value: HorizontalAlign): FHorizontalAlignment;
6
+ export declare function transformFacadeVerticalAlignment(value: FVerticalAlignment): VerticalAlign;
7
+ export declare function transformCoreVerticalAlignment(value: VerticalAlign): FVerticalAlignment;
8
+ /**
9
+ * covert cell value to cell data
10
+ * @param value
11
+ * @returns
12
+ */
13
+ export declare function covertCellValue(value: CellValue | ICellData): ICellData;
14
+ /**
15
+ * covert cell value array or matrix to cell data
16
+ * @param value
17
+ * @param range
18
+ * @returns
19
+ */
20
+ export declare function covertCellValues(value: CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>, range: IRange): IObjectMatrixPrimitiveType<ICellData>;
21
+ export declare function isCellMerged(mergeInfo: IRangeWithCoord, range: IRange): boolean;
22
+ export declare function isSingleCell(mergeInfo: IRangeWithCoord, range: IRange): boolean;
23
+ export declare function covertToRowRange(range: IRange, worksheet: Worksheet): IRange;
24
+ export declare function covertToColRange(range: IRange, worksheet: Worksheet): IRange;
@@ -36,7 +36,7 @@ export { EffectRefRangId, OperatorType } from './services/ref-range/type';
36
36
  export { DefinedNameDataController } from './controllers/defined-name-data.controller';
37
37
  export { handleBaseInsertRange, handleBaseMoveRowsCols, handleBaseRemoveRange, handleCommonDefaultRangeChangeWithEffectRefCommands, handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests, handleDefaultRangeChangeWithEffectRefCommands, handleDefaultRangeChangeWithEffectRefCommandsSkipNoInterests, handleDeleteRangeMoveLeft, handleDeleteRangeMoveUp, handleInsertCol, handleInsertRangeMoveDown, handleInsertRangeMoveRight, handleInsertRow, handleIRemoveCol, handleIRemoveRow, handleMoveCols, handleMoveRange, handleMoveRows, rotateRange, runRefRangeMutations, } from './services/ref-range/util';
38
38
  export { InterceptCellContentPriority, INTERCEPTOR_POINT } from './services/sheet-interceptor/interceptor-const';
39
- export { SheetInterceptorService } from './services/sheet-interceptor/sheet-interceptor.service';
39
+ export { AFTER_CELL_EDIT, AFTER_CELL_EDIT_ASYNC, BEFORE_CELL_EDIT, SheetInterceptorService } from './services/sheet-interceptor/sheet-interceptor.service';
40
40
  export type { ISheetLocation, ISheetLocationBase, ISheetRowLocation } from './services/sheet-interceptor/utils/interceptor';
41
41
  export { MERGE_CELL_INTERCEPTOR_CHECK, MergeCellController } from './controllers/merge-cell.controller';
42
42
  export { AddMergeRedoSelectionsOperationFactory, AddMergeUndoSelectionsOperationFactory } from './commands/utils/handle-merge-operation';
@@ -51,7 +51,7 @@ export { WorkbookCommentPermission, WorkbookCopyPermission, WorkbookCreateProtec
51
51
  export { UnitAction, UnitObject } from '@univerjs/protocol';
52
52
  export { checkRangesEditablePermission } from './services/permission/util';
53
53
  export { type ICellPermission, RangeProtectionRenderModel } from './model/range-protection-render.model';
54
- export { type IModel, type IObjectModel, type IRangeProtectionRule, RangeProtectionRuleModel } from './model/range-protection-rule.model';
54
+ export { EditStateEnum, type IModel, type IObjectModel, type IRangeProtectionRule, RangeProtectionRuleModel, ViewStateEnum } from './model/range-protection-rule.model';
55
55
  export { RangeProtectionCache } from './model/range-protection.cache';
56
56
  export type { IWorksheetProtectionRenderCellData } from './services/permission/worksheet-permission/type';
57
57
  export { RangeProtectionRefRangeService } from './services/permission/range-permission/range-protection.ref-range';
@@ -73,6 +73,9 @@ export { handleInsertRangeMutation } from './commands/utils/handle-range-mutatio
73
73
  export { type ISheetCommandSharedParams } from './commands/utils/interface';
74
74
  export { copyRangeStyles } from './commands/commands/utils/selection-utils';
75
75
  export { AddRangeProtectionCommand, type IAddRangeProtectionCommandParams } from './commands/commands/add-range-protection.command';
76
+ export { AddWorksheetProtectionCommand } from './commands/commands/add-worksheet-protection.command';
77
+ export { SetWorksheetProtectionCommand } from './commands/commands/set-worksheet-protection.command';
78
+ export { DeleteWorksheetProtectionCommand } from './commands/commands/delete-worksheet-protection.command';
76
79
  export { addMergeCellsUtil, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeVerticalCommand, } from './commands/commands/add-worksheet-merge.command';
77
80
  export { ClearSelectionAllCommand } from './commands/commands/clear-selection-all.command';
78
81
  export { ClearSelectionContentCommand } from './commands/commands/clear-selection-content.command';
@@ -103,10 +106,9 @@ export { type IReorderRangeCommandParams, ReorderRangeCommand } from './commands
103
106
  export { type ISetBorderBasicCommandParams, type ISetBorderColorCommandParams, type ISetBorderCommandParams, type ISetBorderPositionCommandParams, type ISetBorderStyleCommandParams, SetBorderBasicCommand, SetBorderColorCommand, SetBorderCommand, SetBorderPositionCommand, SetBorderStyleCommand, } from './commands/commands/set-border-command';
104
107
  export { type ISetSpecificColsVisibleCommandParams, SetColHiddenCommand, SetSelectedColsVisibleCommand, SetSpecificColsVisibleCommand, } from './commands/commands/set-col-visible.command';
105
108
  export { SetDefinedNameCommand } from './commands/commands/set-defined-name.command';
106
- export { SetFrozenCancelCommand } from './commands/commands/set-frozen-cancel.command';
107
- export { SetFrozenCommand } from './commands/commands/set-frozen.command';
109
+ export { type ICancelFrozenCommandParams, type ISetFrozenCommandParams } from './commands/commands/set-frozen.command';
110
+ export { CancelFrozenCommand, SetFrozenCommand } from './commands/commands/set-frozen.command';
108
111
  export { type IToggleGridlinesCommandParams, ToggleGridlinesCommand } from './commands/commands/toggle-gridlines.command';
109
- export { type ISetRangeProtectionCommandParams, SetRangeProtectionCommand } from './commands/commands/set-range-protection.command';
110
112
  export { type ISetRangeValuesCommandParams, SetRangeValuesCommand } from './commands/commands/set-range-values.command';
111
113
  export { type ISetSpecificRowsVisibleCommandParams, SetRowHiddenCommand, SetSelectedRowsVisibleCommand, SetSpecificRowsVisibleCommand, } from './commands/commands/set-row-visible.command';
112
114
  export { type ISetColorCommandParams, type ISetFontFamilyCommandParams, type ISetFontSizeCommandParams, type ISetHorizontalTextAlignCommandParams, type ISetStyleCommandParams, type ISetTextRotationCommandParams, type ISetTextWrapCommandParams, type ISetVerticalTextAlignCommandParams, type IStyleTypeValue, ResetBackgroundColorCommand, ResetTextColorCommand, SetBackgroundColorCommand, SetBoldCommand, SetFontFamilyCommand, SetFontSizeCommand, SetHorizontalTextAlignCommand, SetItalicCommand, SetOverlineCommand, SetStrikeThroughCommand, SetStyleCommand, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, } from './commands/commands/set-style.command';
@@ -123,6 +125,7 @@ export { DeltaRowHeightCommand, type IDeltaRowHeightCommand, type ISetWorksheetR
123
125
  export { SetWorksheetShowCommand } from './commands/commands/set-worksheet-show.command';
124
126
  export type { ISetWorksheetShowCommandParams } from './commands/commands/set-worksheet-show.command';
125
127
  export { AddRangeProtectionMutation, FactoryAddRangeProtectionMutation, type IAddRangeProtectionMutationParams } from './commands/mutations/add-range-protection.mutation';
128
+ export { SetProtectionCommand } from './commands/commands/set-protection.command';
126
129
  export { AddMergeUndoMutationFactory, AddWorksheetMergeMutation } from './commands/mutations/add-worksheet-merge.mutation';
127
130
  export { AddWorksheetProtectionMutation, type IAddWorksheetProtectionParams } from './commands/mutations/add-worksheet-protection.mutation';
128
131
  export { DeleteRangeProtectionMutation, FactoryDeleteRangeProtectionMutation, type IDeleteRangeProtectionMutationParams } from './commands/mutations/delete-range-protection.mutation';
@@ -1,14 +1,23 @@
1
1
  import { IRange } from '@univerjs/core';
2
2
  import { UnitObject } from '@univerjs/protocol';
3
+ export declare enum ViewStateEnum {
4
+ OthersCanView = "othersCanView",
5
+ NoOneElseCanView = "noOneElseCanView"
6
+ }
7
+ export declare enum EditStateEnum {
8
+ DesignedUserCanEdit = "designedUserCanEdit",
9
+ OnlyMe = "onlyMe"
10
+ }
3
11
  export interface IRangeProtectionRule {
4
12
  ranges: IRange[];
5
13
  permissionId: string;
6
14
  id: string;
7
- name: string;
8
15
  description?: string;
9
16
  unitType: UnitObject;
10
17
  unitId: string;
11
18
  subUnitId: string;
19
+ viewState: ViewStateEnum;
20
+ editState: EditStateEnum;
12
21
  }
13
22
  export type IObjectModel = Record<string, Record<string, IRangeProtectionRule[]>>;
14
23
  export type IModel = Map<string, Map<string, Map<string, IRangeProtectionRule>>>;
@@ -1,11 +1,13 @@
1
1
  import { UnitObject } from '@univerjs/protocol';
2
+ import { EditStateEnum, ViewStateEnum } from '../../model/range-protection-rule.model';
2
3
  export interface IWorksheetProtectionRule {
3
4
  permissionId: string;
4
5
  description?: string;
5
6
  unitType: UnitObject;
6
7
  unitId: string;
7
8
  subUnitId: string;
8
- name: string;
9
+ viewState: ViewStateEnum;
10
+ editState: EditStateEnum;
9
11
  }
10
12
  export interface IWorksheetProtectionPointRule {
11
13
  unitId: string;
@@ -1,4 +1,4 @@
1
- import { Injector, IPermissionService, IResourceManagerService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
1
+ import { ILogService, Injector, IPermissionService, IResourceManagerService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
2
2
  import { RangeProtectionRuleModel } from '../../../model/range-protection-rule.model';
3
3
  import { WorksheetProtectionPointModel } from './worksheet-permission-point.model';
4
4
  import { WorksheetProtectionRuleModel } from './worksheet-permission-rule.model';
@@ -12,7 +12,8 @@ export declare class WorksheetPermissionService extends RxDisposable {
12
12
  private _worksheetProtectionPointRuleModel;
13
13
  private _resourceManagerService;
14
14
  private _rangeProtectionRuleModel;
15
- constructor(_permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService, _injector: Injector, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel, _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel, _resourceManagerService: IResourceManagerService, _rangeProtectionRuleModel: RangeProtectionRuleModel);
15
+ private _logService;
16
+ constructor(_permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService, _injector: Injector, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel, _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel, _resourceManagerService: IResourceManagerService, _rangeProtectionRuleModel: RangeProtectionRuleModel, _logService: ILogService);
16
17
  private _init;
17
18
  private _initRuleChange;
18
19
  private _initRuleSnapshot;
@@ -1,4 +1,5 @@
1
- import { ICommandInfo, IDisposable, IInterceptor, IRange, IUndoRedoCommandInfosByInterceptor, Nullable, Disposable, InterceptorEffectEnum, IUniverInstanceService } from '@univerjs/core';
1
+ import { ICellData, ICellDataForSheetInterceptor, ICommandInfo, IDisposable, IInterceptor, IRange, IUndoRedoCommandInfosByInterceptor, Nullable, Workbook, Worksheet, Disposable, InterceptorEffectEnum, InterceptorManager, IUniverInstanceService } from '@univerjs/core';
2
+ import { ISheetLocation } from './utils/interceptor';
2
3
  export interface IBeforeCommandInterceptor {
3
4
  priority?: number;
4
5
  performCheck(info: ICommandInfo): Promise<boolean>;
@@ -16,6 +17,12 @@ export interface IRangeInterceptors {
16
17
  priority?: number;
17
18
  getMutations(rangesInfo: IRangesInfo): IUndoRedoCommandInfosByInterceptor;
18
19
  }
20
+ interface ISheetLocationForEditor extends ISheetLocation {
21
+ origin: Nullable<ICellData>;
22
+ }
23
+ export declare const BEFORE_CELL_EDIT: IInterceptor<ICellDataForSheetInterceptor, ISheetLocationForEditor>;
24
+ export declare const AFTER_CELL_EDIT: IInterceptor<ICellDataForSheetInterceptor, ISheetLocationForEditor>;
25
+ export declare const AFTER_CELL_EDIT_ASYNC: IInterceptor<Promise<Nullable<ICellDataForSheetInterceptor>>, ISheetLocationForEditor>;
19
26
  /**
20
27
  * This class expose methods for sheet features to inject code to sheet underlying logic.
21
28
  */
@@ -27,10 +34,38 @@ export declare class SheetInterceptorService extends Disposable {
27
34
  private _beforeCommandInterceptor;
28
35
  private readonly _workbookDisposables;
29
36
  private readonly _worksheetDisposables;
37
+ readonly writeCellInterceptor: InterceptorManager<{
38
+ BEFORE_CELL_EDIT: IInterceptor<ICellDataForSheetInterceptor, ISheetLocationForEditor>;
39
+ AFTER_CELL_EDIT: IInterceptor<ICellDataForSheetInterceptor, ISheetLocationForEditor>;
40
+ AFTER_CELL_EDIT_ASYNC: IInterceptor<Promise<Nullable<ICellDataForSheetInterceptor>>, ISheetLocationForEditor>;
41
+ }>;
30
42
  /** @ignore */
31
43
  constructor(_univerInstanceService: IUniverInstanceService);
32
44
  dispose(): void;
45
+ /**
46
+ * Add a listener function to a specific command to add affiliated mutations. It should be called in controllers.
47
+ *
48
+ * Pairs with {@link onCommandExecute}.
49
+ *
50
+ * @param interceptor
51
+ * @returns
52
+ */
33
53
  interceptCommand(interceptor: ICommandInterceptor): IDisposable;
54
+ /**
55
+ * When command is executing, call this method to gether undo redo mutations from upper features.
56
+ * @param command
57
+ * @returns
58
+ */
59
+ onCommandExecute(info: ICommandInfo): IUndoRedoCommandInfosByInterceptor;
60
+ /**
61
+ * Add a listener function to a specific command to deteminte if the command can execute mutations. It should be
62
+ * called in controllers.
63
+ *
64
+ * Pairs with {@link beforeCommandExecute}.
65
+ *
66
+ * @param interceptor
67
+ * @returns
68
+ */
34
69
  interceptBeforeCommand(interceptor: IBeforeCommandInterceptor): IDisposable;
35
70
  /**
36
71
  * before command execute, call this method to get the flag of whether it can be executed the command,
@@ -44,16 +79,12 @@ export declare class SheetInterceptorService extends Disposable {
44
79
  * @returns IDisposable
45
80
  */
46
81
  interceptRanges(interceptor: IRangeInterceptors): IDisposable;
47
- /**
48
- * When command is executing, call this method to gether undo redo mutations from upper features.
49
- * @param command
50
- * @returns
51
- */
52
- onCommandExecute(info: ICommandInfo): IUndoRedoCommandInfosByInterceptor;
53
82
  generateMutationsByRanges(info: IRangesInfo): IUndoRedoCommandInfosByInterceptor;
83
+ onWriteCell(workbook: Workbook, worksheet: Worksheet, row: number, col: number, cellData: ICellData): Promise<Nullable<ICellDataForSheetInterceptor>>;
54
84
  intercept<T extends IInterceptor<any, any>>(name: T, interceptor: T): IDisposable;
55
85
  fetchThroughInterceptors<T, C>(name: IInterceptor<T, C>, effect?: InterceptorEffectEnum): (initValue: Nullable<T>, initContext: C) => Nullable<T>;
56
86
  private _interceptWorkbook;
57
87
  private _disposeWorkbookInterceptor;
58
88
  private _disposeSheetInterceptor;
59
89
  }
90
+ export {};