@univerjs/sheets 1.0.0-rc.0 → 1.0.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/lib/cjs/facade.js +211 -110
- package/lib/cjs/index.js +350 -246
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/facade.js +212 -111
- package/lib/es/index.js +351 -248
- package/lib/facade.js +212 -111
- package/lib/index.js +351 -248
- package/lib/types/commands/commands/set-worksheet-hide.command.d.ts +4 -0
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +12 -1
- package/lib/types/commands/mutations/set-worksheet-hide.mutation.d.ts +2 -1
- package/lib/types/controllers/calculate-result-apply.controller.d.ts +1 -1
- package/lib/types/facade/f-defined-name.d.ts +2 -2
- package/lib/types/facade/f-range.d.ts +118 -45
- package/lib/types/facade/f-selection.d.ts +1 -1
- package/lib/types/facade/f-sheet-hooks.d.ts +24 -0
- package/lib/types/facade/f-univer.d.ts +4 -5
- package/lib/types/facade/f-workbook.d.ts +8 -13
- package/lib/types/facade/f-worksheet.d.ts +43 -28
- package/lib/types/facade/permission/f-range-permission.d.ts +1 -1
- package/lib/types/facade/permission/f-range-protection-rule.d.ts +2 -2
- package/lib/types/facade/permission/f-workbook-permission.d.ts +3 -3
- package/lib/types/facade/permission/f-worksheet-permission.d.ts +5 -4
- package/lib/types/facade/utils.d.ts +1 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/model/range-protection-render.model.d.ts +33 -0
- package/lib/types/model/range-protection-rule.model.d.ts +75 -0
- package/lib/types/model/range-protection.cache.d.ts +55 -0
- package/lib/types/model/range-theme-model.d.ts +102 -0
- package/lib/types/model/range-theme-util.d.ts +113 -0
- package/lib/types/model/range-themes/build-in-theme.factory.d.ts +20 -0
- package/lib/types/model/range-themes/default.d.ts +18 -0
- package/lib/types/model/zebra-crossing-cache.d.ts +57 -0
- package/lib/types/services/auto-fill/tools.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +9 -9
|
@@ -16,14 +16,16 @@
|
|
|
16
16
|
import type { CellValue, CustomData, IColumnRange, IFreeze, IObjectArrayPrimitiveType, IRange, IRowRange, IStyleData, Nullable, Workbook, Worksheet } from '@univerjs/core';
|
|
17
17
|
import type { FDefinedName } from './f-defined-name';
|
|
18
18
|
import type { FWorkbook } from './f-workbook';
|
|
19
|
-
import { BooleanNumber, ICommandService, ILogService, Injector } from '@univerjs/core';
|
|
19
|
+
import { BooleanNumber, ICommandService, ILogService, Injector, WorksheetHiddenState } from '@univerjs/core';
|
|
20
20
|
import { FBaseInitialable } from '@univerjs/core/facade';
|
|
21
21
|
import { SheetsSelectionsService } from '@univerjs/sheets';
|
|
22
22
|
import { FRange } from './f-range';
|
|
23
23
|
import { FSelection } from './f-selection';
|
|
24
24
|
import { FWorksheetPermission } from './permission/f-worksheet-permission';
|
|
25
25
|
export interface IFacadeClearOptions {
|
|
26
|
+
/** Clears only content when true and `formatOnly` is false. */
|
|
26
27
|
contentsOnly?: boolean;
|
|
28
|
+
/** Clears only formatting when true and `contentsOnly` is false. */
|
|
27
29
|
formatOnly?: boolean;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
@@ -49,6 +51,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
49
51
|
* @param {ICommandService} _commandService - The command service
|
|
50
52
|
*/
|
|
51
53
|
constructor(_fWorkbook: FWorkbook, _workbook: Workbook, _worksheet: Worksheet, _injector: Injector, _selectionManagerService: SheetsSelectionsService, _logService: ILogService, _commandService: ICommandService);
|
|
54
|
+
/** Releases this facade's resources. Use `univerAPI.disposeUnit()` to unload the owning unit. */
|
|
52
55
|
dispose(): void;
|
|
53
56
|
/**
|
|
54
57
|
* Get the worksheet instance.
|
|
@@ -112,7 +115,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
112
115
|
getSheetName(): string;
|
|
113
116
|
/**
|
|
114
117
|
* Get the current selection of the worksheet.
|
|
115
|
-
* @returns {FSelection}
|
|
118
|
+
* @returns {FSelection | null} The current selections, or `null` when no selection data is available.
|
|
116
119
|
* @example
|
|
117
120
|
* ```typescript
|
|
118
121
|
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
@@ -124,7 +127,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
124
127
|
getSelection(): FSelection | null;
|
|
125
128
|
/**
|
|
126
129
|
* Get the default style of the worksheet.
|
|
127
|
-
* @returns {IStyleData}
|
|
130
|
+
* @returns {Nullable<IStyleData> | string} The default style object or style ID, or a nullish value when no default style is set.
|
|
128
131
|
* @example
|
|
129
132
|
* ```typescript
|
|
130
133
|
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
@@ -172,7 +175,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
172
175
|
getColumnDefaultStyle(index: number, keepRaw?: boolean): Nullable<IStyleData> | string;
|
|
173
176
|
/**
|
|
174
177
|
* Set the default style of the worksheet
|
|
175
|
-
* @param {string} style -
|
|
178
|
+
* @param {string | Nullable<IStyleData>} style - A style ID or style object, or `null` to clear the default style.
|
|
176
179
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
177
180
|
* @example
|
|
178
181
|
* ```typescript
|
|
@@ -185,8 +188,8 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
185
188
|
*/
|
|
186
189
|
setDefaultStyle(style: string | Nullable<IStyleData>): FWorksheet;
|
|
187
190
|
/**
|
|
188
|
-
* Set the default style of the worksheet
|
|
189
|
-
* @param {number} index - The
|
|
191
|
+
* Set the default style of the worksheet column
|
|
192
|
+
* @param {number} index - The zero-based column index
|
|
190
193
|
* @param {string | Nullable<IStyleData>} style - The style name or style data
|
|
191
194
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
192
195
|
* @example
|
|
@@ -201,8 +204,8 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
201
204
|
*/
|
|
202
205
|
setColumnDefaultStyle(index: number, style: string | Nullable<IStyleData>): FWorksheet;
|
|
203
206
|
/**
|
|
204
|
-
* Set the default style of the worksheet
|
|
205
|
-
* @param {number} index - The
|
|
207
|
+
* Set the default style of the worksheet row
|
|
208
|
+
* @param {number} index - The zero-based row index
|
|
206
209
|
* @param {string | Nullable<IStyleData>} style - The style name or style data
|
|
207
210
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
208
211
|
* @example
|
|
@@ -340,7 +343,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
340
343
|
/**
|
|
341
344
|
* Inserts one or more consecutive blank rows in a sheet starting at the specified location.
|
|
342
345
|
* @param {number} rowIndex - The existing row before which rows are inserted. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
343
|
-
* @param {number} numRows - The positive number of rows to insert.
|
|
346
|
+
* @param {number} [numRows] - The positive number of rows to insert.
|
|
344
347
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
345
348
|
* @example
|
|
346
349
|
* ```typescript
|
|
@@ -467,7 +470,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
467
470
|
/**
|
|
468
471
|
* Hides one or more consecutive rows starting at the given index. Use 0-index for this method
|
|
469
472
|
* @param {number} rowIndex - The starting index of the rows to hide
|
|
470
|
-
* @param {number} numRow - The number of rows to hide
|
|
473
|
+
* @param {number} [numRow] - The number of rows to hide
|
|
471
474
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
472
475
|
* @example
|
|
473
476
|
* ```typescript
|
|
@@ -498,9 +501,9 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
498
501
|
*/
|
|
499
502
|
unhideRow(row: FRange): FWorksheet;
|
|
500
503
|
/**
|
|
501
|
-
*
|
|
504
|
+
* Unhides one or more consecutive rows starting at the given zero-based index.
|
|
502
505
|
* @param {number} rowIndex - The starting index of the rows
|
|
503
|
-
* @param {number} numRows - The number of rows
|
|
506
|
+
* @param {number} [numRows] - The number of rows
|
|
504
507
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
505
508
|
* @example
|
|
506
509
|
* ```typescript
|
|
@@ -532,7 +535,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
532
535
|
/**
|
|
533
536
|
* Make certain row wrap and auto height.
|
|
534
537
|
* @param {number} rowPosition - The row position to change.
|
|
535
|
-
* @param {BooleanNumber} auto - Whether to auto fit the row height.
|
|
538
|
+
* @param {BooleanNumber} [auto] - Whether to auto fit the row height.
|
|
536
539
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
537
540
|
* @example
|
|
538
541
|
* ```ts
|
|
@@ -664,7 +667,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
664
667
|
/**
|
|
665
668
|
* Inserts one or more consecutive blank columns in a sheet starting at the specified location.
|
|
666
669
|
* @param {number} columnIndex - The index indicating where to insert a column, starting at 0 for the first column
|
|
667
|
-
* @param {number} numColumns - The number of columns to insert
|
|
670
|
+
* @param {number} [numColumns] - The number of columns to insert
|
|
668
671
|
* @returns {FWorksheet} This sheet, for chaining
|
|
669
672
|
* @example
|
|
670
673
|
* ```typescript
|
|
@@ -791,7 +794,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
791
794
|
/**
|
|
792
795
|
* Hides one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
793
796
|
* @param {number} columnIndex - The starting index of the columns to hide
|
|
794
|
-
* @param {number} numColumn - The number of columns to hide
|
|
797
|
+
* @param {number} [numColumn] - The number of columns to hide
|
|
795
798
|
* @returns {FWorksheet} This sheet, for chaining
|
|
796
799
|
* @example
|
|
797
800
|
* ```typescript
|
|
@@ -824,7 +827,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
824
827
|
/**
|
|
825
828
|
* Show one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
826
829
|
* @param {number} columnIndex - The starting index of the columns to unhide
|
|
827
|
-
* @param {number} numColumns - The number of columns to unhide
|
|
830
|
+
* @param {number} [numColumns] - The number of columns to unhide
|
|
828
831
|
* @returns {FWorksheet} This sheet, for chaining
|
|
829
832
|
* @example
|
|
830
833
|
* ```typescript
|
|
@@ -881,7 +884,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
881
884
|
* fRange.setValue('Whenever it is a damp, drizzly November in my soul...');
|
|
882
885
|
*
|
|
883
886
|
* // Set the column A to a width which fits the text
|
|
884
|
-
* fWorksheet.
|
|
887
|
+
* fWorksheet.autoResizeColumns(0);
|
|
885
888
|
*
|
|
886
889
|
* // Get the width of the column A
|
|
887
890
|
* console.log(fWorksheet.getColumnWidth(0));
|
|
@@ -1209,7 +1212,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1209
1212
|
getGridLinesColor(): string | undefined;
|
|
1210
1213
|
/**
|
|
1211
1214
|
* Sets the sheet tab color.
|
|
1212
|
-
* @param {string
|
|
1215
|
+
* @param {string} color - A color in CSS notation, such as '#ffffff' or 'white'.
|
|
1213
1216
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
1214
1217
|
* @example
|
|
1215
1218
|
* ```ts
|
|
@@ -1223,8 +1226,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1223
1226
|
setTabColor(color: string): FWorksheet;
|
|
1224
1227
|
/**
|
|
1225
1228
|
* Get the tab color of the sheet.
|
|
1226
|
-
* @returns {string} The tab color
|
|
1227
|
-
* The default color is css style property 'unset'.
|
|
1229
|
+
* @returns {string | undefined} The tab color, or `undefined` when no color is set.
|
|
1228
1230
|
* @example
|
|
1229
1231
|
* ```ts
|
|
1230
1232
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1261,7 +1263,7 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1261
1263
|
*/
|
|
1262
1264
|
showSheet(): FWorksheet;
|
|
1263
1265
|
/**
|
|
1264
|
-
* Returns true
|
|
1266
|
+
* Returns true for both HIDDEN and VERY_HIDDEN sheets.
|
|
1265
1267
|
* @returns {boolean} True if the sheet is hidden; otherwise, false.
|
|
1266
1268
|
* @example
|
|
1267
1269
|
* ```ts
|
|
@@ -1272,6 +1274,18 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1272
1274
|
* ```
|
|
1273
1275
|
*/
|
|
1274
1276
|
isSheetHidden(): boolean;
|
|
1277
|
+
/**
|
|
1278
|
+
* Returns 0 (visible), 1 (hidden), or 2 (very hidden).
|
|
1279
|
+
* @example fWorksheet.getHiddenState() === univerAPI.Enum.WorksheetHiddenState.VERY_HIDDEN
|
|
1280
|
+
*/
|
|
1281
|
+
getHiddenState(): WorksheetHiddenState;
|
|
1282
|
+
/**
|
|
1283
|
+
* Changes the persisted hiding state through an undoable command.
|
|
1284
|
+
* VERY_HIDDEN removes the sheet from Unhide UI; showSheet() can reveal it through the API.
|
|
1285
|
+
* The last visible sheet cannot be hidden. Existing isSheetHidden() stays a boolean predicate.
|
|
1286
|
+
* @example fWorksheet.setHiddenState(univerAPI.Enum.WorksheetHiddenState.VERY_HIDDEN)
|
|
1287
|
+
*/
|
|
1288
|
+
setHiddenState(hidden: WorksheetHiddenState): FWorksheet;
|
|
1275
1289
|
/**
|
|
1276
1290
|
* Sets the sheet name.
|
|
1277
1291
|
* @param {string} name - The new name for the sheet.
|
|
@@ -1313,10 +1327,11 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1313
1327
|
*/
|
|
1314
1328
|
getIndex(): number;
|
|
1315
1329
|
/**
|
|
1316
|
-
* Clears the sheet
|
|
1330
|
+
* Clears the sheet content and formatting, or only one of them as specified by the options.
|
|
1331
|
+
* Both content and formatting are cleared when both flags are true or both are false.
|
|
1317
1332
|
* @param {IFacadeClearOptions} [options] - Options for clearing the sheet. If not provided, the contents and formatting are cleared both.
|
|
1318
|
-
* @param {boolean} [options.contentsOnly] - If true, the contents of the sheet are cleared.
|
|
1319
|
-
* @param {boolean} [options.formatOnly] -
|
|
1333
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the sheet are cleared. Effective only when `formatOnly` is false. Defaults to false.
|
|
1334
|
+
* @param {boolean} [options.formatOnly] - Clears only formatting when true and `contentsOnly` is false. Defaults to false.
|
|
1320
1335
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
1321
1336
|
* @example
|
|
1322
1337
|
* ```ts
|
|
@@ -1373,8 +1388,8 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1373
1388
|
*/
|
|
1374
1389
|
getDataRange(): FRange;
|
|
1375
1390
|
/**
|
|
1376
|
-
* Returns the
|
|
1377
|
-
* @returns {number}
|
|
1391
|
+
* Returns the zero-based index of the last column with stored cell data, including formatting-only cells.
|
|
1392
|
+
* @returns {number} The last stored column index, or 0 for an empty sheet.
|
|
1378
1393
|
* @example
|
|
1379
1394
|
* ```ts
|
|
1380
1395
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1388,8 +1403,8 @@ export declare class FWorksheet extends FBaseInitialable {
|
|
|
1388
1403
|
*/
|
|
1389
1404
|
getLastColumn(): number;
|
|
1390
1405
|
/**
|
|
1391
|
-
* Returns the
|
|
1392
|
-
* @returns {number}
|
|
1406
|
+
* Returns the zero-based index of the last row with stored cell data, including formatting-only cells.
|
|
1407
|
+
* @returns {number} The last stored row index, or 0 for an empty sheet.
|
|
1393
1408
|
* @example
|
|
1394
1409
|
* ```ts
|
|
1395
1410
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -53,7 +53,7 @@ export declare class FRangePermission extends FBase {
|
|
|
53
53
|
isProtected(): boolean;
|
|
54
54
|
/**
|
|
55
55
|
* Protect the current range.
|
|
56
|
-
* @param {IRangeProtectionOptions} options Protection options.
|
|
56
|
+
* @param {IRangeProtectionOptions} [options] Protection options.
|
|
57
57
|
* @returns {Promise<FRangeProtectionRule>} The created protection rule.
|
|
58
58
|
* @example
|
|
59
59
|
* ```ts
|
|
@@ -56,7 +56,7 @@ export declare class FRangeProtectionRule {
|
|
|
56
56
|
/**
|
|
57
57
|
* Update the protected ranges.
|
|
58
58
|
* @param {FRange[]} ranges New ranges to protect.
|
|
59
|
-
* @returns {Promise<
|
|
59
|
+
* @returns {Promise<boolean>} A promise resolving to whether the protected ranges were updated.
|
|
60
60
|
* @example
|
|
61
61
|
* ```ts
|
|
62
62
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -74,7 +74,7 @@ export declare class FRangeProtectionRule {
|
|
|
74
74
|
updateRanges(ranges: FRange[]): Promise<boolean>;
|
|
75
75
|
/**
|
|
76
76
|
* Delete the current protection rule.
|
|
77
|
-
* @returns {Promise<
|
|
77
|
+
* @returns {Promise<boolean>} A promise resolving to whether the rule was removed.
|
|
78
78
|
* @example
|
|
79
79
|
* ```ts
|
|
80
80
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -116,7 +116,7 @@ export declare class FWorkbookPermission extends FBase {
|
|
|
116
116
|
getSnapshot(): WorkbookPermissionSnapshot;
|
|
117
117
|
/**
|
|
118
118
|
* Set multiple collaborators at once (replaces existing collaborators).
|
|
119
|
-
* @param {Array<{ user:
|
|
119
|
+
* @param {Array<{ user: ICollaboratorUser; role: UnitRole }>} collaborators Array of collaborators with user information and role.
|
|
120
120
|
* @returns {Promise<void>} A promise that resolves when the collaborators are set.
|
|
121
121
|
* @example
|
|
122
122
|
* ```ts
|
|
@@ -140,7 +140,7 @@ export declare class FWorkbookPermission extends FBase {
|
|
|
140
140
|
}>): Promise<void>;
|
|
141
141
|
/**
|
|
142
142
|
* Add a single collaborator.
|
|
143
|
-
* @param {
|
|
143
|
+
* @param {ICollaboratorUser} user The user information (userID, name, avatar).
|
|
144
144
|
* @param {UnitRole} role The role to assign.
|
|
145
145
|
* @returns {Promise<void>} A promise that resolves when the collaborator is added.
|
|
146
146
|
* @example
|
|
@@ -156,7 +156,7 @@ export declare class FWorkbookPermission extends FBase {
|
|
|
156
156
|
addCollaborator(user: ICollaboratorUser, role: UnitRole): Promise<void>;
|
|
157
157
|
/**
|
|
158
158
|
* Update an existing collaborator's role and information.
|
|
159
|
-
* @param {
|
|
159
|
+
* @param {ICollaboratorUser} user The updated user information (userID, name, avatar).
|
|
160
160
|
* @param {UnitRole} role The new role to assign.
|
|
161
161
|
* @returns {Promise<void>} A promise that resolves when the collaborator is updated.
|
|
162
162
|
* @example
|
|
@@ -56,7 +56,7 @@ export declare class FWorksheetPermission extends FBase {
|
|
|
56
56
|
/**
|
|
57
57
|
* Create worksheet protection with collaborators support.
|
|
58
58
|
* This must be called before setting permission points for collaboration to work.
|
|
59
|
-
* @param {IWorksheetProtectionOptions} options Protection options including allowed users.
|
|
59
|
+
* @param {IWorksheetProtectionOptions} [options] Protection options including allowed users.
|
|
60
60
|
* @returns {Promise<string>} The permissionId for the created protection.
|
|
61
61
|
* @example
|
|
62
62
|
* ```ts
|
|
@@ -79,7 +79,7 @@ export declare class FWorksheetPermission extends FBase {
|
|
|
79
79
|
/**
|
|
80
80
|
* Remove worksheet protection.
|
|
81
81
|
* This deletes the protection rule and resets all permission points to allowed.
|
|
82
|
-
* @returns {Promise<
|
|
82
|
+
* @returns {Promise<boolean>} A promise resolving to whether protection was removed; also resolves to `true` if already unprotected.
|
|
83
83
|
* @example
|
|
84
84
|
* ```ts
|
|
85
85
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -190,6 +190,7 @@ export declare class FWorksheetPermission extends FBase {
|
|
|
190
190
|
* if (fWorksheet.getWorksheetPermission().canView()) {
|
|
191
191
|
* console.log('Worksheet is viewable');
|
|
192
192
|
* }
|
|
193
|
+
* ```
|
|
193
194
|
*/
|
|
194
195
|
canView(): boolean;
|
|
195
196
|
/**
|
|
@@ -285,7 +286,7 @@ export declare class FWorksheetPermission extends FBase {
|
|
|
285
286
|
/**
|
|
286
287
|
* Remove multiple protection rules at once.
|
|
287
288
|
* @param {string[]} ruleIds Array of rule IDs to remove.
|
|
288
|
-
* @returns {Promise<
|
|
289
|
+
* @returns {Promise<boolean>} A promise resolving to whether the rules were removed; also resolves to `true` for an empty ID list.
|
|
289
290
|
* @example
|
|
290
291
|
* ```ts
|
|
291
292
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -322,7 +323,7 @@ export declare class FWorksheetPermission extends FBase {
|
|
|
322
323
|
* Debug cell permission information.
|
|
323
324
|
* @param {number} row Row index.
|
|
324
325
|
* @param {number} col Column index.
|
|
325
|
-
* @returns {FRangeProtectionRule | undefined}
|
|
326
|
+
* @returns {Promise<FRangeProtectionRule | undefined>} A promise resolving to the protection rule affecting this cell, or `undefined` if no range protection rule applies.
|
|
326
327
|
* @example
|
|
327
328
|
* ```ts
|
|
328
329
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import type { IRange, IRangeWithCoord, Worksheet } from '@univerjs/core';
|
|
17
17
|
import { HorizontalAlign, VerticalAlign } from '@univerjs/core';
|
|
18
18
|
export type FDefaultAlignment = 'general';
|
|
19
|
+
/** Horizontal alignment accepted by the Facade API. `normal` means right alignment. */
|
|
19
20
|
export type FHorizontalAlignment = 'left' | 'center' | 'normal';
|
|
20
21
|
export type FVerticalAlignment = 'top' | 'middle' | 'bottom';
|
|
21
22
|
/**
|
package/lib/types/index.d.ts
CHANGED
|
@@ -185,7 +185,7 @@ export { FactorySetRangeProtectionMutation, SetRangeProtectionMutation, } from '
|
|
|
185
185
|
export type { ISetRangeProtectionMutationParams } from './commands/mutations/set-range-protection.mutation';
|
|
186
186
|
export { SetRangeThemeMutation } from './commands/mutations/set-range-theme.mutation';
|
|
187
187
|
export type { ISetRangeThemeMutationParams } from './commands/mutations/set-range-theme.mutation';
|
|
188
|
-
export { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, } from './commands/mutations/set-range-values.mutation';
|
|
188
|
+
export { prepareSetRangeValuesMutation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, } from './commands/mutations/set-range-values.mutation';
|
|
189
189
|
export type { ISetRangeValuesMutationParams, ISetRangeValuesRangeMutationParams, } from './commands/mutations/set-range-values.mutation';
|
|
190
190
|
export { SetRowDataMutation, SetRowDataMutationFactory } from './commands/mutations/set-row-data.mutation';
|
|
191
191
|
export type { ISetRowDataMutationParams } from './commands/mutations/set-row-data.mutation';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { IRange } from '@univerjs/core';
|
|
17
|
+
import type { UnitAction } from '@univerjs/protocol';
|
|
18
|
+
import { IPermissionService } from '@univerjs/core';
|
|
19
|
+
import { RangeProtectionRuleModel } from './range-protection-rule.model';
|
|
20
|
+
export type ICellPermission = Record<UnitAction, boolean> & {
|
|
21
|
+
ruleId?: string;
|
|
22
|
+
ranges?: IRange[];
|
|
23
|
+
};
|
|
24
|
+
export declare class RangeProtectionRenderModel {
|
|
25
|
+
private _selectionProtectionRuleModel;
|
|
26
|
+
private _permissionService;
|
|
27
|
+
private _cache;
|
|
28
|
+
constructor(_selectionProtectionRuleModel: RangeProtectionRuleModel, _permissionService: IPermissionService);
|
|
29
|
+
private _init;
|
|
30
|
+
private _createKey;
|
|
31
|
+
getCellInfo(unitId: string, subUnitId: string, row: number, col: number): ICellPermission[];
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { IDisposable, IRange } from '@univerjs/core';
|
|
17
|
+
import type { UnitObject } from '@univerjs/protocol';
|
|
18
|
+
export declare enum ViewStateEnum {
|
|
19
|
+
OthersCanView = "othersCanView",
|
|
20
|
+
NoOneElseCanView = "noOneElseCanView"
|
|
21
|
+
}
|
|
22
|
+
export declare enum EditStateEnum {
|
|
23
|
+
DesignedUserCanEdit = "designedUserCanEdit",
|
|
24
|
+
OnlyMe = "onlyMe"
|
|
25
|
+
}
|
|
26
|
+
export interface IRangeProtectionRule {
|
|
27
|
+
ranges: IRange[];
|
|
28
|
+
permissionId: string;
|
|
29
|
+
id: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
unitType: UnitObject;
|
|
32
|
+
unitId: string;
|
|
33
|
+
subUnitId: string;
|
|
34
|
+
viewState: ViewStateEnum;
|
|
35
|
+
editState: EditStateEnum;
|
|
36
|
+
}
|
|
37
|
+
export type IObjectModel = Record<string, Record<string, IRangeProtectionRule[]>>;
|
|
38
|
+
export type IModel = Map<string, Map<string, Map<string, IRangeProtectionRule>>>;
|
|
39
|
+
export interface IRuleChange {
|
|
40
|
+
unitId: string;
|
|
41
|
+
subUnitId: string;
|
|
42
|
+
rule: IRangeProtectionRule;
|
|
43
|
+
oldRule?: IRangeProtectionRule;
|
|
44
|
+
type: IRuleChangeType;
|
|
45
|
+
}
|
|
46
|
+
type IRuleChangeType = 'add' | 'set' | 'delete';
|
|
47
|
+
export declare class RangeProtectionRuleModel implements IDisposable {
|
|
48
|
+
/**
|
|
49
|
+
* Map<unitId, Map<subUnitId, Map<ruleId, IRangeProtectionRule>>>
|
|
50
|
+
*/
|
|
51
|
+
private _model;
|
|
52
|
+
private readonly _ruleChange$;
|
|
53
|
+
readonly ruleChange$: import("rxjs").Observable<IRuleChange>;
|
|
54
|
+
private _ruleRefresh$;
|
|
55
|
+
ruleRefresh$: import("rxjs").Observable<string>;
|
|
56
|
+
dispose(): void;
|
|
57
|
+
ruleRefresh(id: string): void;
|
|
58
|
+
private _rangeRuleInitStateChange;
|
|
59
|
+
rangeRuleInitStateChange$: import("rxjs").Observable<boolean>;
|
|
60
|
+
getRangeRuleInitState(): boolean;
|
|
61
|
+
changeRuleInitState(state: boolean): void;
|
|
62
|
+
addRule(unitId: string, subUnitId: string, rule: IRangeProtectionRule): void;
|
|
63
|
+
deleteRule(unitId: string, subUnitId: string, id: string): void;
|
|
64
|
+
setRule(unitId: string, subUnitId: string, id: string, rule: IRangeProtectionRule): void;
|
|
65
|
+
getRule(unitId: string, subUnitId: string, id: string): IRangeProtectionRule | undefined;
|
|
66
|
+
getSubunitRuleList(unitId: string, subUnitId: string): IRangeProtectionRule[];
|
|
67
|
+
getSubunitRuleListLength(unitId: string, subUnitId: string): number;
|
|
68
|
+
private _ensureRuleMap;
|
|
69
|
+
toObject(): IObjectModel;
|
|
70
|
+
fromObject(obj: IObjectModel): void;
|
|
71
|
+
deleteUnitModel(unitId: string): void;
|
|
72
|
+
createRuleId(unitId: string, subUnitId: string): string;
|
|
73
|
+
getTargetByPermissionId(unitId: string, permissionId: string): string[] | null;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { IRange } from '@univerjs/core';
|
|
17
|
+
import { Disposable, IPermissionService, IUniverInstanceService } from '@univerjs/core';
|
|
18
|
+
import { UnitAction } from '@univerjs/protocol';
|
|
19
|
+
import { RangeProtectionRuleModel } from './range-protection-rule.model';
|
|
20
|
+
export declare class RangeProtectionCache extends Disposable {
|
|
21
|
+
private readonly _ruleModel;
|
|
22
|
+
private readonly _permissionService;
|
|
23
|
+
private readonly _univerInstanceService;
|
|
24
|
+
private readonly _cellRuleCache;
|
|
25
|
+
private readonly _permissionIdCache;
|
|
26
|
+
private readonly _cellInfoCache;
|
|
27
|
+
private readonly _rowInfoCache;
|
|
28
|
+
private readonly _colInfoCache;
|
|
29
|
+
constructor(_ruleModel: RangeProtectionRuleModel, _permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService);
|
|
30
|
+
private _initCache;
|
|
31
|
+
private _initUpdateCellInfoCache;
|
|
32
|
+
private _initUpdateCellRuleCache;
|
|
33
|
+
private _ensureRuleMap;
|
|
34
|
+
private _ensureCellInfoMap;
|
|
35
|
+
private _ensureRowColInfoMap;
|
|
36
|
+
private _addCellRuleCache;
|
|
37
|
+
private _deleteCellRuleCache;
|
|
38
|
+
private _getSelectionActions;
|
|
39
|
+
reBuildCache(unitId: string, subUnitId: string): void;
|
|
40
|
+
getRowPermissionInfo(unitId: string, subUnitId: string, row: number, types: UnitAction[]): boolean;
|
|
41
|
+
getColPermissionInfo(unitId: string, subUnitId: string, col: number, types: UnitAction[]): boolean;
|
|
42
|
+
private _initUpdateRowColInfoCache;
|
|
43
|
+
getCellInfo(unitId: string, subUnitId: string, row: number, col: number): (Partial<Record<UnitAction, boolean>> & {
|
|
44
|
+
ruleId?: string;
|
|
45
|
+
ranges?: IRange[];
|
|
46
|
+
}) | {
|
|
47
|
+
ruleId: string;
|
|
48
|
+
ranges: IRange[];
|
|
49
|
+
1: boolean;
|
|
50
|
+
0: boolean;
|
|
51
|
+
2: boolean;
|
|
52
|
+
42: boolean;
|
|
53
|
+
} | undefined;
|
|
54
|
+
deleteUnit(unitId: string): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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 { IRange, Nullable } from '@univerjs/core';
|
|
17
|
+
import type { IRangeThemeStyleItem, IRangeThemeStyleJSON } from './range-theme-util';
|
|
18
|
+
import { Disposable, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
19
|
+
import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';
|
|
20
|
+
import { RangeThemeStyle } from './range-theme-util';
|
|
21
|
+
export interface IRangeThemeRangeInfo {
|
|
22
|
+
range: IRange;
|
|
23
|
+
unitId: string;
|
|
24
|
+
subUnitId: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IRangeThemeStyleRule {
|
|
27
|
+
rangeInfo: IRangeThemeRangeInfo;
|
|
28
|
+
themeName: string;
|
|
29
|
+
}
|
|
30
|
+
interface ISheetRangeThemeModelJSON {
|
|
31
|
+
rangeThemeStyleRuleMap: Record<string, IRangeThemeStyleRule>;
|
|
32
|
+
rangeThemeStyleMapJson: Record<string, IRangeThemeStyleJSON>;
|
|
33
|
+
}
|
|
34
|
+
export declare class SheetRangeThemeModel extends Disposable {
|
|
35
|
+
private _sheetInterceptorService;
|
|
36
|
+
private _resourceManagerService;
|
|
37
|
+
private readonly _univerInstanceService;
|
|
38
|
+
private _rangeThemeStyleMap;
|
|
39
|
+
private _rangeThemeStyleRuleMap;
|
|
40
|
+
private _rTreeCollection;
|
|
41
|
+
private _defaultRangeThemeMap;
|
|
42
|
+
/**
|
|
43
|
+
* This map is used to cache zebra crossing toggle ranges for each unitId and subUnitId, IRangeThemeStyleRule id
|
|
44
|
+
*/
|
|
45
|
+
private _zebraCrossingCacheMap;
|
|
46
|
+
private _rowVisibleFuncSet;
|
|
47
|
+
private _rangeThemeMapChanged$;
|
|
48
|
+
rangeThemeMapChange$: import("rxjs").Observable<{
|
|
49
|
+
type: "add" | "remove";
|
|
50
|
+
styleName: string;
|
|
51
|
+
}>;
|
|
52
|
+
constructor(_sheetInterceptorService: SheetInterceptorService, _resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
|
|
53
|
+
private _initDefaultTheme;
|
|
54
|
+
private _ensureRangeThemeStyleMap;
|
|
55
|
+
private _ensureRangeThemeStyleRuleMap;
|
|
56
|
+
private _ensureRTreeCollection;
|
|
57
|
+
getDefaultRangeThemeStyle(name: string): RangeThemeStyle;
|
|
58
|
+
getCustomRangeThemeStyle(unitId: string, name: string): RangeThemeStyle | undefined;
|
|
59
|
+
private _getSheetRowVisibleFuncSet;
|
|
60
|
+
private _getSheetRowVisibleHasInit;
|
|
61
|
+
refreshSheetRowVisibleFuncSet(unitId: string, subUnitId: string): void;
|
|
62
|
+
private _ensureZebraCrossingCache;
|
|
63
|
+
/**
|
|
64
|
+
* Register range theme styles
|
|
65
|
+
* @param {string} themeName
|
|
66
|
+
* @param {IRangeThemeRangeInfo} rangeInfo
|
|
67
|
+
*/
|
|
68
|
+
registerRangeThemeRule(themeName: string, rangeInfo: IRangeThemeRangeInfo): void;
|
|
69
|
+
getRegisteredRangeThemeStyle(rangeInfo: IRangeThemeRangeInfo): string | undefined;
|
|
70
|
+
refreshZebraCrossingCacheBySheet(unitId: string, subUnitId: string): void;
|
|
71
|
+
removeRangeThemeRule(themeName: string, rangeInfo: IRangeThemeRangeInfo): void;
|
|
72
|
+
registerDefaultRangeTheme(rangeThemeStyle: RangeThemeStyle): void;
|
|
73
|
+
unRegisterDefaultRangeTheme(themeName: string): void;
|
|
74
|
+
getRegisteredRangeThemes(): string[];
|
|
75
|
+
/**
|
|
76
|
+
* Register custom range theme style.
|
|
77
|
+
* @param {string} unitId The unit id.
|
|
78
|
+
* @param {RangeThemeStyle} rangeThemeStyle The range theme style.
|
|
79
|
+
*/
|
|
80
|
+
registerRangeThemeStyle(unitId: string, rangeThemeStyle: RangeThemeStyle): void;
|
|
81
|
+
/**
|
|
82
|
+
* Unregister custom range theme style.
|
|
83
|
+
* @param {string} unitId The unit id.
|
|
84
|
+
* @param {string} name The name of the range theme style.
|
|
85
|
+
*/
|
|
86
|
+
unregisterRangeThemeStyle(unitId: string, name: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Gets all custom register themes
|
|
89
|
+
* @param {string} unitId Which unit to register the range theme style.
|
|
90
|
+
* @return {string[]} The array of all custom registered themes.
|
|
91
|
+
*/
|
|
92
|
+
getALLRegisteredTheme(unitId: string): string[];
|
|
93
|
+
getRangeThemeStyle(unitId: string, name: string): RangeThemeStyle;
|
|
94
|
+
getCellStyle(unitId: string, subUnitId: string, row: number, col: number): Nullable<IRangeThemeStyleItem>;
|
|
95
|
+
private _registerIntercept;
|
|
96
|
+
toJson(unitId: string): string;
|
|
97
|
+
fromJSON(unitId: string, json: ISheetRangeThemeModelJSON): void;
|
|
98
|
+
deleteUnitId(unitId: string): void;
|
|
99
|
+
private _initSnapshot;
|
|
100
|
+
dispose(): void;
|
|
101
|
+
}
|
|
102
|
+
export {};
|