@univerjs/sheets 0.5.5 → 0.6.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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/es/facade.js +531 -396
- package/lib/es/index.js +537 -425
- package/lib/types/facade/f-defined-name.d.ts +22 -16
- package/lib/types/facade/f-enum.d.ts +3 -0
- package/lib/types/facade/f-event.d.ts +43 -41
- package/lib/types/facade/f-permission.d.ts +141 -9
- package/lib/types/facade/f-range.d.ts +155 -149
- package/lib/types/facade/f-selection.d.ts +3 -1
- package/lib/types/facade/f-sheet-hooks.d.ts +3 -0
- package/lib/types/facade/f-univer.d.ts +9 -3
- package/lib/types/facade/f-workbook.d.ts +13 -5
- package/lib/types/facade/f-worksheet.d.ts +2 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/model/range-protection-rule.model.d.ts +1 -1
- package/lib/types/services/permission/permission-point/const.d.ts +117 -4
- package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +1 -1
- package/lib/types/services/permission/range-permission/range-protection.service.d.ts +1 -1
- package/lib/types/services/permission/worksheet-permission/worksheet-permission-rule.model.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +8 -8
- package/lib/types/basics/__tests__/cell-type.spec.d.ts +0 -16
- package/lib/types/basics/__tests__/cell-value.spec.d.ts +0 -16
- package/lib/types/basics/__tests__/expand.data.d.ts +0 -2
- package/lib/types/basics/__tests__/expand.spec.d.ts +0 -16
- package/lib/types/basics/__tests__/rangeMerge.spec.d.ts +0 -16
- package/lib/types/basics/__tests__/row-column-value.spec.d.ts +0 -16
- package/lib/types/basics/__tests__/utils.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/add-merge-command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/clear-selection.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/copy-worksheet.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/create-command-test-bed.d.ts +0 -7
- package/lib/types/commands/commands/__tests__/delete-range.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/insert-range.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/insert-remove-rows-cols.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/move-range-commands.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/move-rows-cols.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/range-template-command.sepc.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/remove-rows-cols.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/remove-sheet.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-border.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-col-data.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-col-width.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-frozen.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-gridlines-command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-range-values.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-row-col-visible.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-row-data.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-row-height.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-style.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-tab-color.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-worksheet-default-style.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-worksheet-hide.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-worksheet-name.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-worksheet-order.command.spec.d.ts +0 -16
- package/lib/types/commands/commands/__tests__/set-worksheet-show.command.spec.d.ts +0 -16
- package/lib/types/commands/mutations/__tests__/create-command-test-bed.d.ts +0 -8
- package/lib/types/commands/mutations/__tests__/move-rows-cols.mutation.spec.d.ts +0 -16
- package/lib/types/commands/mutations/__tests__/remove-row-col.mutation.spec.d.ts +0 -16
- package/lib/types/controllers/__tests__/util.d.ts +0 -13
- package/lib/types/facade/__tests__/utils.spec.d.ts +0 -16
- package/lib/types/services/__tests__/move-active-cell.spec.d.ts +0 -16
- package/lib/types/services/__tests__/numfmt.service.test.d.ts +0 -16
- package/lib/types/services/__tests__/ref-range.setvice.spec.d.ts +0 -16
- package/lib/types/services/__tests__/util.d.ts +0 -14
- package/lib/types/services/ref-range/__tests__/__testing__.d.ts +0 -14
- package/lib/types/services/ref-range/__tests__/ref-range.service.spec.d.ts +0 -13
- package/lib/types/services/ref-range/__tests__/utils.spec.d.ts +0 -16
- package/lib/types/services/ref-range/__tests__/watch-range.spec.d.ts +0 -16
- package/lib/types/services/sheet-interceptor/__tests__/create-core-test-bed.d.ts +0 -13
- package/lib/types/services/sheet-interceptor/__tests__/sheet-interceptor.service.spec.d.ts +0 -16
|
@@ -2,6 +2,9 @@ import { FWorksheet } from './f-worksheet';
|
|
|
2
2
|
import { FBase, IAuthzIoService, ICommandService, Injector, IPermissionService, LocaleService } from '@univerjs/core';
|
|
3
3
|
import { IDefinedNamesService, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
|
|
4
4
|
import { RangeProtectionRuleModel, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
|
|
5
|
+
/**
|
|
6
|
+
* @hideconstructor
|
|
7
|
+
*/
|
|
5
8
|
export declare class FDefinedNameBuilder {
|
|
6
9
|
private _definedNameParam;
|
|
7
10
|
constructor();
|
|
@@ -13,8 +16,8 @@ export declare class FDefinedNameBuilder {
|
|
|
13
16
|
* ```ts
|
|
14
17
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
15
18
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
16
|
-
*
|
|
17
|
-
*
|
|
19
|
+
* .setName('MyDefinedName')
|
|
20
|
+
* .build();
|
|
18
21
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
19
22
|
* ```
|
|
20
23
|
*/
|
|
@@ -27,9 +30,9 @@ export declare class FDefinedNameBuilder {
|
|
|
27
30
|
* ```ts
|
|
28
31
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
29
32
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
+
* .setFormula('SUM(Sheet1!$A$1)')
|
|
34
|
+
* .setName('MyDefinedName')
|
|
35
|
+
* .build();
|
|
33
36
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
34
37
|
* ```
|
|
35
38
|
*/
|
|
@@ -42,8 +45,8 @@ export declare class FDefinedNameBuilder {
|
|
|
42
45
|
* ```ts
|
|
43
46
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
44
47
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
45
|
-
*
|
|
46
|
-
*
|
|
48
|
+
* .setRef('Sheet1!$A$1')
|
|
49
|
+
* .build();
|
|
47
50
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
48
51
|
* ```
|
|
49
52
|
*/
|
|
@@ -59,8 +62,8 @@ export declare class FDefinedNameBuilder {
|
|
|
59
62
|
* ```ts
|
|
60
63
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
61
64
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
62
|
-
*
|
|
63
|
-
*
|
|
65
|
+
* .setRefByRange(1, 3, 2, 5)
|
|
66
|
+
* .build();
|
|
64
67
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
65
68
|
* ```
|
|
66
69
|
*/
|
|
@@ -73,8 +76,8 @@ export declare class FDefinedNameBuilder {
|
|
|
73
76
|
* ```ts
|
|
74
77
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
75
78
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
76
|
-
*
|
|
77
|
-
*
|
|
79
|
+
* .setComment('This is a comment')
|
|
80
|
+
* .build();
|
|
78
81
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
79
82
|
* ```
|
|
80
83
|
*/
|
|
@@ -87,8 +90,8 @@ export declare class FDefinedNameBuilder {
|
|
|
87
90
|
* ```ts
|
|
88
91
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
89
92
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
90
|
-
*
|
|
91
|
-
*
|
|
93
|
+
* .setHidden(true)
|
|
94
|
+
* .build();
|
|
92
95
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
93
96
|
* ```
|
|
94
97
|
*/
|
|
@@ -100,15 +103,18 @@ export declare class FDefinedNameBuilder {
|
|
|
100
103
|
* ```ts
|
|
101
104
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
102
105
|
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
+
* .setRef('Sheet1!$A$1')
|
|
107
|
+
* .setName('MyDefinedName')
|
|
108
|
+
* .build();
|
|
106
109
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
107
110
|
* ```
|
|
108
111
|
*/
|
|
109
112
|
build(): ISetDefinedNameMutationParam;
|
|
110
113
|
load(param: ISetDefinedNameMutationParam): FDefinedNameBuilder;
|
|
111
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* @hideconstructor
|
|
117
|
+
*/
|
|
112
118
|
export declare class FDefinedName extends FBase {
|
|
113
119
|
protected _definedNameParam: ISetDefinedNameMutationParam;
|
|
114
120
|
protected readonly _injector: Injector;
|
|
@@ -6,6 +6,7 @@ import { FWorksheet } from './f-worksheet';
|
|
|
6
6
|
/**
|
|
7
7
|
* Interface for sheet-related events
|
|
8
8
|
* Provides event names for sheet creation, workbook creation, and gridline changes
|
|
9
|
+
* @ignore
|
|
9
10
|
*/
|
|
10
11
|
export interface IFSheetEventMixin {
|
|
11
12
|
/**
|
|
@@ -13,10 +14,10 @@ export interface IFSheetEventMixin {
|
|
|
13
14
|
* @see {@link ISheetCreatedEventParams}
|
|
14
15
|
* @example
|
|
15
16
|
* ```ts
|
|
16
|
-
univerAPI.addEvent(univerAPI.Event.SheetCreated, (params) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
17
|
+
* univerAPI.addEvent(univerAPI.Event.SheetCreated, (params) => {
|
|
18
|
+
* const { workbook, worksheet } = params;
|
|
19
|
+
* console.log('sheet created', params);
|
|
20
|
+
* });
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
23
|
get SheetCreated(): 'SheetCreated';
|
|
@@ -26,8 +27,8 @@ export interface IFSheetEventMixin {
|
|
|
26
27
|
* @example
|
|
27
28
|
* ```ts
|
|
28
29
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetCreate, (params) => {
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* const { workbook, index, sheet } = params;
|
|
31
|
+
* console.log('before sheet create', params);
|
|
31
32
|
* });
|
|
32
33
|
* ```
|
|
33
34
|
*/
|
|
@@ -38,8 +39,8 @@ export interface IFSheetEventMixin {
|
|
|
38
39
|
* @example
|
|
39
40
|
* ```ts
|
|
40
41
|
* univerAPI.addEvent(univerAPI.Event.ActiveSheetChanged, (params) => {
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
* const { workbook, activeSheet, oldActiveSheet } = params;
|
|
43
|
+
* console.log('before active sheet changed', params);
|
|
43
44
|
* });
|
|
44
45
|
* ```
|
|
45
46
|
*/
|
|
@@ -50,8 +51,8 @@ export interface IFSheetEventMixin {
|
|
|
50
51
|
* @example
|
|
51
52
|
* ```ts
|
|
52
53
|
* univerAPI.addEvent(univerAPI.Event.ActiveSheetChanged, (params) => {
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* const { workbook, activeSheet } = params;
|
|
55
|
+
* console.log('after active sheet changed', params);
|
|
55
56
|
* });
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
@@ -62,8 +63,8 @@ export interface IFSheetEventMixin {
|
|
|
62
63
|
* @example
|
|
63
64
|
* ```ts
|
|
64
65
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetDelete, (params) => {
|
|
65
|
-
*
|
|
66
|
-
*
|
|
66
|
+
* const { workbook, worksheetId } = params;
|
|
67
|
+
* console.log('before sheet delete', params);
|
|
67
68
|
* });
|
|
68
69
|
* ```
|
|
69
70
|
*/
|
|
@@ -74,8 +75,8 @@ export interface IFSheetEventMixin {
|
|
|
74
75
|
* @example
|
|
75
76
|
* ```ts
|
|
76
77
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetDelete, (params) => {
|
|
77
|
-
*
|
|
78
|
-
*
|
|
78
|
+
* const { workbook, worksheet } = params;
|
|
79
|
+
* console.log('before sheet delete', params);
|
|
79
80
|
* });
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
@@ -86,8 +87,8 @@ export interface IFSheetEventMixin {
|
|
|
86
87
|
* @example
|
|
87
88
|
* ```ts
|
|
88
89
|
* univerAPI.addEvent(univerAPI.Event.SheetMoved, (params) => {
|
|
89
|
-
*
|
|
90
|
-
*
|
|
90
|
+
* const { workbook, worksheet, newIndex } = params;
|
|
91
|
+
* console.log('sheet moved', params);
|
|
91
92
|
* });
|
|
92
93
|
* ```
|
|
93
94
|
*/
|
|
@@ -98,8 +99,8 @@ export interface IFSheetEventMixin {
|
|
|
98
99
|
* @example
|
|
99
100
|
* ```ts
|
|
100
101
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetMove, (params) => {
|
|
101
|
-
*
|
|
102
|
-
*
|
|
102
|
+
* const { workbook, worksheet, newIndex, oldIndex } = params;
|
|
103
|
+
* console.log('before sheet move', params);
|
|
103
104
|
* });
|
|
104
105
|
* ```
|
|
105
106
|
*/
|
|
@@ -110,8 +111,8 @@ export interface IFSheetEventMixin {
|
|
|
110
111
|
* @example
|
|
111
112
|
* ```ts
|
|
112
113
|
* univerAPI.addEvent(univerAPI.Event.SheetNameChanged, (params) => {
|
|
113
|
-
*
|
|
114
|
-
*
|
|
114
|
+
* const { workbook, worksheet, newName } = params;
|
|
115
|
+
* console.log('sheet name changed', params);
|
|
115
116
|
* });
|
|
116
117
|
* ```
|
|
117
118
|
*/
|
|
@@ -122,8 +123,8 @@ export interface IFSheetEventMixin {
|
|
|
122
123
|
* @example
|
|
123
124
|
* ```ts
|
|
124
125
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetNameChange, (params) => {
|
|
125
|
-
*
|
|
126
|
-
*
|
|
126
|
+
* const { workbook, worksheet, newName, oldName } = params;
|
|
127
|
+
* console.log('before sheet name changed', params);
|
|
127
128
|
* });
|
|
128
129
|
* ```
|
|
129
130
|
*/
|
|
@@ -134,8 +135,8 @@ export interface IFSheetEventMixin {
|
|
|
134
135
|
* @example
|
|
135
136
|
* ```ts
|
|
136
137
|
* univerAPI.addEvent(univerAPI.Event.SheetTabColorChanged, (params) => {
|
|
137
|
-
*
|
|
138
|
-
*
|
|
138
|
+
* const { workbook, worksheet, color } = params;
|
|
139
|
+
* console.log('sheet tab color changed', params);
|
|
139
140
|
* });
|
|
140
141
|
* ```
|
|
141
142
|
*/
|
|
@@ -146,8 +147,8 @@ export interface IFSheetEventMixin {
|
|
|
146
147
|
* @example
|
|
147
148
|
* ```ts
|
|
148
149
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetTabColorChange, (params) => {
|
|
149
|
-
*
|
|
150
|
-
*
|
|
150
|
+
* const { workbook, worksheet, color, oldColor } = params;
|
|
151
|
+
* console.log('before sheet tab color changed', params);
|
|
151
152
|
* });
|
|
152
153
|
* ```
|
|
153
154
|
*/
|
|
@@ -158,8 +159,8 @@ export interface IFSheetEventMixin {
|
|
|
158
159
|
* @example
|
|
159
160
|
* ```ts
|
|
160
161
|
* univerAPI.addEvent(univerAPI.Event.SheetHideChanged, (params) => {
|
|
161
|
-
*
|
|
162
|
-
*
|
|
162
|
+
* const { workbook, worksheet } = params;
|
|
163
|
+
* console.log('sheet hide changed', params);
|
|
163
164
|
* });
|
|
164
165
|
* ```
|
|
165
166
|
*/
|
|
@@ -170,8 +171,8 @@ export interface IFSheetEventMixin {
|
|
|
170
171
|
* @example
|
|
171
172
|
* ```ts
|
|
172
173
|
* univerAPI.addEvent(univerAPI.Event.BeforeSheetHideChange, (params) => {
|
|
173
|
-
*
|
|
174
|
-
*
|
|
174
|
+
* const { workbook, worksheet, hide } = params;
|
|
175
|
+
* console.log('before sheet hide changed', params);
|
|
175
176
|
* });
|
|
176
177
|
* ```
|
|
177
178
|
*/
|
|
@@ -182,8 +183,8 @@ export interface IFSheetEventMixin {
|
|
|
182
183
|
* @example
|
|
183
184
|
* ```ts
|
|
184
185
|
* univerAPI.addEvent(univerAPI.Event.WorkbookCreated, (params) => {
|
|
185
|
-
*
|
|
186
|
-
*
|
|
186
|
+
* const { unitId, type, workbook, unit } = params;
|
|
187
|
+
* console.log('workbook created', params);
|
|
187
188
|
* });
|
|
188
189
|
* ```
|
|
189
190
|
*/
|
|
@@ -194,8 +195,8 @@ export interface IFSheetEventMixin {
|
|
|
194
195
|
* @example
|
|
195
196
|
* ```ts
|
|
196
197
|
* univerAPI.addEvent(univerAPI.Event.WorkbookDisposed, (params) => {
|
|
197
|
-
*
|
|
198
|
-
*
|
|
198
|
+
* const { unitId, unitType, snapshot } = params;
|
|
199
|
+
* console.log('unit disposed', params);
|
|
199
200
|
* });
|
|
200
201
|
* ```
|
|
201
202
|
*/
|
|
@@ -206,8 +207,8 @@ export interface IFSheetEventMixin {
|
|
|
206
207
|
* @example
|
|
207
208
|
* ```ts
|
|
208
209
|
* univerAPI.addEvent(univerAPI.Event.GridlineChanged, (params) => {
|
|
209
|
-
*
|
|
210
|
-
*
|
|
210
|
+
* const { workbook, worksheet, enabled, color } = params;
|
|
211
|
+
* console.log('gridline changed', params);
|
|
211
212
|
* });
|
|
212
213
|
* ```
|
|
213
214
|
*/
|
|
@@ -218,8 +219,8 @@ export interface IFSheetEventMixin {
|
|
|
218
219
|
* @example
|
|
219
220
|
* ```ts
|
|
220
221
|
* univerAPI.addEvent(univerAPI.Event.BeforeGridlineEnableChange, (params) => {
|
|
221
|
-
*
|
|
222
|
-
*
|
|
222
|
+
* const { workbook, worksheet, enabled } = params;
|
|
223
|
+
* console.log('gridline changed', params);
|
|
223
224
|
* });
|
|
224
225
|
* ```
|
|
225
226
|
*/
|
|
@@ -230,8 +231,8 @@ export interface IFSheetEventMixin {
|
|
|
230
231
|
* @example
|
|
231
232
|
* ```ts
|
|
232
233
|
* univerAPI.addEvent(univerAPI.Event.BeforeGridlineColorChange, (params) => {
|
|
233
|
-
*
|
|
234
|
-
*
|
|
234
|
+
* const { workbook, worksheet, color } = params;
|
|
235
|
+
* console.log('gridline changed', params);
|
|
235
236
|
* });
|
|
236
237
|
* ```
|
|
237
238
|
*/
|
|
@@ -241,7 +242,7 @@ export interface IFSheetEventMixin {
|
|
|
241
242
|
* @example
|
|
242
243
|
* ```ts
|
|
243
244
|
* univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (p)=> {
|
|
244
|
-
*
|
|
245
|
+
* const { workbook, effectedRanges, payload } = p;
|
|
245
246
|
* });
|
|
246
247
|
* ```
|
|
247
248
|
*/
|
|
@@ -490,6 +491,7 @@ export interface ISheetValueChangedEvent extends IEventBase {
|
|
|
490
491
|
/**
|
|
491
492
|
* Configuration interface for sheet-related events
|
|
492
493
|
* Provides event names and their corresponding event parameter interfaces
|
|
494
|
+
* @ignore
|
|
493
495
|
*/
|
|
494
496
|
export interface ISheetEventParamConfig {
|
|
495
497
|
/** Event fired after a worksheet is created */
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor, FBase, IAuthzIoService, ICommandService, Injector, IPermissionService } from '@univerjs/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
import { FRange } from './f-range';
|
|
3
4
|
import { RangeProtectionRuleModel, WorkbookEditablePermission, WorksheetEditPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetViewPermission } from '@univerjs/sheets';
|
|
5
|
+
/**
|
|
6
|
+
* @description Used to generate permission instances to control permissions for the entire workbook
|
|
7
|
+
* @hideconstructor
|
|
8
|
+
*/
|
|
4
9
|
export declare class FPermission extends FBase {
|
|
5
10
|
protected readonly _injector: Injector;
|
|
6
11
|
protected readonly _commandService: ICommandService;
|
|
@@ -9,6 +14,9 @@ export declare class FPermission extends FBase {
|
|
|
9
14
|
protected readonly _rangeProtectionRuleModel: RangeProtectionRuleModel;
|
|
10
15
|
protected readonly _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel;
|
|
11
16
|
protected readonly _authzIoService: IAuthzIoService;
|
|
17
|
+
/**
|
|
18
|
+
* Permission point definition, can read the point constructor want to modify from here
|
|
19
|
+
*/
|
|
12
20
|
permissionPointsDefinition: {
|
|
13
21
|
WorkbookCommentPermission: typeof import('@univerjs/sheets').WorkbookCommentPermission;
|
|
14
22
|
WorkbookCopyPermission: typeof import('@univerjs/sheets').WorkbookCopyPermission;
|
|
@@ -40,8 +48,6 @@ export declare class FPermission extends FBase {
|
|
|
40
48
|
WorksheetInsertRowPermission: typeof import('@univerjs/sheets').WorksheetInsertRowPermission;
|
|
41
49
|
WorksheetManageCollaboratorPermission: typeof import('@univerjs/sheets').WorksheetManageCollaboratorPermission;
|
|
42
50
|
WorksheetPivotTablePermission: typeof import('@univerjs/sheets').WorksheetPivotTablePermission;
|
|
43
|
-
WorksheetSelectProtectedCellsPermission: typeof import('@univerjs/sheets').WorksheetSelectProtectedCellsPermission;
|
|
44
|
-
WorksheetSelectUnProtectedCellsPermission: typeof import('@univerjs/sheets').WorksheetSelectUnProtectedCellsPermission;
|
|
45
51
|
WorksheetSetCellStylePermission: typeof import('@univerjs/sheets').WorksheetSetCellStylePermission;
|
|
46
52
|
WorksheetSetCellValuePermission: typeof import('@univerjs/sheets').WorksheetSetCellValuePermission;
|
|
47
53
|
WorksheetSetColumnStylePermission: typeof import('@univerjs/sheets').WorksheetSetColumnStylePermission;
|
|
@@ -51,36 +57,83 @@ export declare class FPermission extends FBase {
|
|
|
51
57
|
RangeProtectionPermissionEditPoint: typeof import('@univerjs/sheets').RangeProtectionPermissionEditPoint;
|
|
52
58
|
RangeProtectionPermissionViewPoint: typeof import('@univerjs/sheets').RangeProtectionPermissionViewPoint;
|
|
53
59
|
};
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
/**
|
|
61
|
+
* An observable object used to monitor permission change events within a range, thereby triggering corresponding subsequent processing.
|
|
62
|
+
*/
|
|
63
|
+
rangeRuleChangedAfterAuth$: Observable<string>;
|
|
64
|
+
/**
|
|
65
|
+
* An observable object used to monitor permission change events within a worksheet, thereby triggering corresponding subsequent processing.
|
|
66
|
+
*/
|
|
67
|
+
sheetRuleChangedAfterAuth$: Observable<string>;
|
|
56
68
|
constructor(_injector: Injector, _commandService: ICommandService, _permissionService: IPermissionService, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel, _rangeProtectionRuleModel: RangeProtectionRuleModel, _worksheetProtectionPointRuleModel: WorksheetProtectionPointModel, _authzIoService: IAuthzIoService);
|
|
57
69
|
/**
|
|
58
70
|
* Configures a specific permission point for a workbook.
|
|
59
|
-
*
|
|
60
71
|
* This function sets or updates a permission point for a workbook identified by `unitId`.
|
|
61
72
|
* It creates a new permission point if it does not already exist, and updates the point with the provided value.
|
|
62
73
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
63
74
|
* @param {WorkbookPermissionPointConstructor} FPointClass - The constructor function for creating a permission point instance. Other point constructors can See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
64
75
|
* @param {boolean} value - The boolean value to determine whether the permission point is enabled or disabled.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
80
|
+
* const permission = workbook.getPermission();
|
|
81
|
+
* const unitId = workbook.getId();
|
|
82
|
+
* permission.setWorkbookPermissionPoint(unitId, permission.permissionPointsDefinition.WorkbookEditablePermission, false)
|
|
83
|
+
* ```
|
|
65
84
|
*/
|
|
66
85
|
setWorkbookPermissionPoint(unitId: string, FPointClass: WorkbookPermissionPointConstructor, value: boolean): void;
|
|
67
86
|
/**
|
|
68
87
|
* This function is used to set whether the workbook can be edited
|
|
69
88
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
70
89
|
* @param {boolean} value - A value that controls whether the workbook can be edited
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
94
|
+
* const permission = workbook.getPermission();
|
|
95
|
+
* const unitId = workbook.getId();
|
|
96
|
+
* permission.setWorkbookEditPermission(unitId, false);
|
|
97
|
+
* ```
|
|
71
98
|
*/
|
|
72
99
|
setWorkbookEditPermission(unitId: string, value: boolean): void;
|
|
73
100
|
/**
|
|
74
101
|
* This function is used to add a base permission for a worksheet.
|
|
102
|
+
* Note that after adding, only the background mask of the permission module will be rendered. If you want to modify the function permissions,
|
|
103
|
+
* you need to modify the permission points with the permissionId returned by this function.
|
|
75
104
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
76
105
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
77
106
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission is successfully added. If the operation fails or no result is returned, it resolves to `undefined`.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
111
|
+
* const permission = workbook.getPermission();
|
|
112
|
+
* const unitId = workbook.getId();
|
|
113
|
+
* const worksheet = workbook.getActiveSheet();
|
|
114
|
+
* const subUnitId = worksheet.getSheetId();
|
|
115
|
+
* // Note that there will be no permission changes after this step is completed. It only returns an ID for subsequent permission changes.
|
|
116
|
+
* // For details, please see the example of the **`setWorksheetPermissionPoint`** API.
|
|
117
|
+
* const permissionId = await permission.addWorksheetBasePermission(unitId, subUnitId)
|
|
118
|
+
* // Can still edit and read it.
|
|
119
|
+
* console.log('debugger', permissionId)
|
|
120
|
+
* ```
|
|
78
121
|
*/
|
|
79
122
|
addWorksheetBasePermission(unitId: string, subUnitId: string): Promise<string | undefined>;
|
|
80
123
|
/**
|
|
81
124
|
* Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
|
|
82
125
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
83
126
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
131
|
+
* const permission = workbook.getPermission();
|
|
132
|
+
* const unitId = workbook.getId();
|
|
133
|
+
* const worksheet = workbook.getActiveSheet();
|
|
134
|
+
* const subUnitId = worksheet.getSheetId();
|
|
135
|
+
* permission.removeWorksheetPermission(unitId, subUnitId);
|
|
136
|
+
* ```
|
|
84
137
|
*/
|
|
85
138
|
removeWorksheetPermission(unitId: string, subUnitId: string): void;
|
|
86
139
|
/**
|
|
@@ -92,16 +145,46 @@ export declare class FPermission extends FBase {
|
|
|
92
145
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
93
146
|
* @param {boolean} value - The new permission value to be set for the worksheet.
|
|
94
147
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission point is successfully set or created. If no permission is set, it resolves to `undefined`.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
152
|
+
* const permission = workbook.getPermission();
|
|
153
|
+
* const unitId = workbook.getId();
|
|
154
|
+
* const worksheet = workbook.getActiveSheet();
|
|
155
|
+
* const subUnitId = worksheet.getSheetId();
|
|
156
|
+
* const permissionId = await permission.addWorksheetBasePermission(unitId, subUnitId)
|
|
157
|
+
* // After this line of code , the worksheet will no longer be editable
|
|
158
|
+
* permission.setWorksheetPermissionPoint(unitId, subUnitId, permission.permissionPointsDefinition.WorksheetEditPermission, false);
|
|
95
159
|
*/
|
|
96
160
|
setWorksheetPermissionPoint(unitId: string, subUnitId: string, FPointClass: WorkSheetPermissionPointConstructor, value: boolean): Promise<string | undefined>;
|
|
97
161
|
/**
|
|
98
162
|
* Adds a range protection to the worksheet.
|
|
163
|
+
* Note that after adding, only the background mask of the permission module will be rendered. If you want to modify the function permissions,
|
|
164
|
+
* you need to modify the permission points with the permissionId returned by this function.
|
|
99
165
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
100
166
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
101
|
-
* @param {
|
|
167
|
+
* @param {FRange[]} ranges - The ranges to be protected.
|
|
102
168
|
* @returns {Promise<{ permissionId: string, ruleId: string } | undefined>} - Returns an object containing the `permissionId` and `ruleId` if the range protection is successfully added. If the operation fails or no result is returned, it resolves to `undefined`. permissionId is used to stitch permission point ID,ruleId is used to store permission rules
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
*const workbook = univerAPI.getActiveWorkbook();
|
|
173
|
+
* const permission = workbook.getPermission();
|
|
174
|
+
* const unitId = workbook.getId();
|
|
175
|
+
* const worksheet = workbook.getActiveSheet();
|
|
176
|
+
* const subUnitId = worksheet.getSheetId();
|
|
177
|
+
* const range = worksheet.getRange(0,0,2,2);
|
|
178
|
+
* const ranges = [];
|
|
179
|
+
* ranges.push(range);
|
|
180
|
+
* // Note that there will be no permission changes after this step is completed. It only returns an ID for subsequent permission changes.
|
|
181
|
+
* // For details, please see the example of the **`setRangeProtectionPermissionPoint`** API.
|
|
182
|
+
* const res = await permission.addRangeBaseProtection(unitId, subUnitId, ranges);
|
|
183
|
+
* const {permissionId, ruleId} = res;
|
|
184
|
+
* console.log('debugger', permissionId, ruleId);
|
|
185
|
+
* ```
|
|
103
186
|
*/
|
|
104
|
-
addRangeBaseProtection(unitId: string, subUnitId: string, ranges:
|
|
187
|
+
addRangeBaseProtection(unitId: string, subUnitId: string, ranges: FRange[]): Promise<{
|
|
105
188
|
permissionId: string;
|
|
106
189
|
ruleId: string;
|
|
107
190
|
} | undefined>;
|
|
@@ -110,6 +193,21 @@ export declare class FPermission extends FBase {
|
|
|
110
193
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
111
194
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
112
195
|
* @param {string[]} ruleIds - The rule IDs of the range protection to be removed.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
200
|
+
* const permission = workbook.getPermission();
|
|
201
|
+
* const unitId = workbook.getId();
|
|
202
|
+
* const worksheet = workbook.getActiveSheet();
|
|
203
|
+
* const subUnitId = worksheet.getSheetId();
|
|
204
|
+
* const range = worksheet.getRange(0,0,2,2);
|
|
205
|
+
* const ranges = [];
|
|
206
|
+
* ranges.push(range);
|
|
207
|
+
* const res = await permission.addRangeBaseProtection(unitId, subUnitId, ranges);
|
|
208
|
+
* const ruleId = res.ruleId;
|
|
209
|
+
* permission.removeRangeProtection(unitId, subUnitId, [ruleId]);
|
|
210
|
+
* ```
|
|
113
211
|
*/
|
|
114
212
|
removeRangeProtection(unitId: string, subUnitId: string, ruleIds: string[]): void;
|
|
115
213
|
/**
|
|
@@ -120,6 +218,24 @@ export declare class FPermission extends FBase {
|
|
|
120
218
|
* @param {RangePermissionPointConstructor} FPointClass - The constructor for the range permission point class.
|
|
121
219
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
122
220
|
* @param {boolean} value - The new permission value to be set for the range (e.g., true for allowing access, false for restricting access).
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
225
|
+
* const permission = workbook.getPermission();
|
|
226
|
+
* const unitId = workbook.getId();
|
|
227
|
+
* const worksheet = workbook.getActiveSheet();
|
|
228
|
+
* const subUnitId = worksheet.getSheetId();
|
|
229
|
+
* const range = worksheet.getRange(0, 0, 2, 2);
|
|
230
|
+
* const ranges = [];
|
|
231
|
+
* ranges.push(range);
|
|
232
|
+
* // Note that there will be no permission changes after this step is completed. It only returns an ID for subsequent permission changes.
|
|
233
|
+
* // For details, please see the example of the **`setRangeProtectionPermissionPoint`** API.
|
|
234
|
+
* const res = await permission.addRangeBaseProtection(unitId, subUnitId, ranges);
|
|
235
|
+
* const {permissionId, ruleId} = res;
|
|
236
|
+
* // After passing the following line of code, the range set above will become uneditable
|
|
237
|
+
* permission.setRangeProtectionPermissionPoint(unitId,subUnitId,permissionId, permission.permissionPointsDefinition.RangeProtectionPermissionEditPoint, false);
|
|
238
|
+
* ```
|
|
123
239
|
*/
|
|
124
240
|
setRangeProtectionPermissionPoint(unitId: string, subUnitId: string, permissionId: string, FPointClass: RangePermissionPointConstructor, value: boolean): void;
|
|
125
241
|
/**
|
|
@@ -132,6 +248,22 @@ export declare class FPermission extends FBase {
|
|
|
132
248
|
* @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
|
|
133
249
|
* @param {string} ruleId - The ruleId of the range protection rule that is being updated.
|
|
134
250
|
* @param {IRange[]} ranges - The array of new ranges to be set for the range protection rule.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
255
|
+
* const permission = workbook.getPermission();
|
|
256
|
+
* const unitId = workbook.getId();
|
|
257
|
+
* const worksheet = workbook.getActiveSheet();
|
|
258
|
+
* const subUnitId = worksheet.getSheetId();
|
|
259
|
+
* const range = worksheet.getRange(0, 0, 2, 2);
|
|
260
|
+
* const ranges = [];
|
|
261
|
+
* ranges.push(range);
|
|
262
|
+
* const res = await permission.addRangeBaseProtection(unitId, subUnitId, ranges);
|
|
263
|
+
* const {permissionId, ruleId} = res;
|
|
264
|
+
* const newRange = worksheet.getRange(3, 3, 2, 2);
|
|
265
|
+
* permission.setRangeProtectionRanges(unitId, subUnitId, ruleId, [newRange]);
|
|
266
|
+
* ```
|
|
135
267
|
*/
|
|
136
|
-
setRangeProtectionRanges(unitId: string, subUnitId: string, ruleId: string, ranges:
|
|
268
|
+
setRangeProtectionRanges(unitId: string, subUnitId: string, ruleId: string, ranges: FRange[]): void;
|
|
137
269
|
}
|