@univerjs/sheets 0.20.1 → 0.21.0-insiders.20260422-d7fcb4d
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 +8373 -1
- package/lib/cjs/index.js +21516 -2
- package/lib/cjs/locale/ca-ES.js +17 -1
- package/lib/cjs/locale/en-US.js +32 -1
- package/lib/cjs/locale/es-ES.js +17 -1
- package/lib/cjs/locale/fa-IR.js +17 -1
- package/lib/cjs/locale/fr-FR.js +17 -1
- package/lib/cjs/locale/ja-JP.js +17 -1
- package/lib/cjs/locale/ko-KR.js +17 -1
- package/lib/cjs/locale/ru-RU.js +17 -1
- package/lib/cjs/locale/sk-SK.js +17 -1
- package/lib/cjs/locale/vi-VN.js +17 -1
- package/lib/cjs/locale/zh-CN.js +17 -1
- package/lib/cjs/locale/zh-TW.js +17 -1
- package/lib/es/facade.js +8335 -1
- package/lib/es/index.js +20994 -2
- package/lib/es/locale/ca-ES.js +16 -1
- package/lib/es/locale/en-US.js +31 -1
- package/lib/es/locale/es-ES.js +16 -1
- package/lib/es/locale/fa-IR.js +16 -1
- package/lib/es/locale/fr-FR.js +16 -1
- package/lib/es/locale/ja-JP.js +16 -1
- package/lib/es/locale/ko-KR.js +16 -1
- package/lib/es/locale/ru-RU.js +16 -1
- package/lib/es/locale/sk-SK.js +16 -1
- package/lib/es/locale/vi-VN.js +16 -1
- package/lib/es/locale/zh-CN.js +16 -1
- package/lib/es/locale/zh-TW.js +16 -1
- package/lib/facade.js +8335 -1
- package/lib/index.js +20994 -2
- package/lib/locale/ca-ES.js +16 -1
- package/lib/locale/en-US.js +31 -1
- package/lib/locale/es-ES.js +16 -1
- package/lib/locale/fa-IR.js +16 -1
- package/lib/locale/fr-FR.js +16 -1
- package/lib/locale/ja-JP.js +16 -1
- package/lib/locale/ko-KR.js +16 -1
- package/lib/locale/ru-RU.js +16 -1
- package/lib/locale/sk-SK.js +16 -1
- package/lib/locale/vi-VN.js +16 -1
- package/lib/locale/zh-CN.js +16 -1
- package/lib/locale/zh-TW.js +16 -1
- package/lib/types/basics/defined-name-utils.d.ts +28 -0
- package/lib/types/commands/commands/remove-row-col.command.d.ts +2 -1
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +11 -12
- package/lib/types/facade/f-defined-name.d.ts +30 -30
- package/lib/types/facade/f-univer.d.ts +0 -24
- package/lib/types/facade/f-workbook.d.ts +38 -39
- package/lib/types/facade/index.d.ts +2 -2
- package/lib/types/facade/permission/f-range-permission.d.ts +31 -228
- package/lib/types/facade/permission/f-range-protection-rule.d.ts +157 -46
- package/lib/types/facade/permission/f-workbook-permission.d.ts +51 -129
- package/lib/types/facade/permission/f-worksheet-permission.d.ts +111 -199
- package/lib/types/facade/permission/permission-types.d.ts +20 -125
- package/lib/types/facade/permission/util.d.ts +40 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/permission/range-permission/util.d.ts +2 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +9 -9
- package/LICENSE +0 -176
- package/lib/types/facade/f-permission.d.ts +0 -426
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { FRange } from '../f-range';
|
|
17
|
-
import type { IRangeProtectionOptions } from './permission-types';
|
|
18
|
-
import { ICommandService, Injector } from '@univerjs/core';
|
|
17
|
+
import type { IRangeProtectionOptions, RangePermissionSnapshot } from './permission-types';
|
|
18
|
+
import { IAuthzIoService, ICommandService, Injector, IPermissionService } from '@univerjs/core';
|
|
19
19
|
import { RangeProtectionRuleModel } from '@univerjs/sheets';
|
|
20
|
+
import { RangePermissionPoint } from './permission-types';
|
|
20
21
|
/**
|
|
21
22
|
* Implementation class for range protection rules
|
|
22
23
|
* Encapsulates operations on a single protection rule
|
|
@@ -31,46 +32,25 @@ export declare class FRangeProtectionRule {
|
|
|
31
32
|
private readonly _ranges;
|
|
32
33
|
private readonly _options;
|
|
33
34
|
private readonly _injector;
|
|
35
|
+
private readonly _permissionService;
|
|
36
|
+
private readonly _authzIoService;
|
|
34
37
|
private readonly _commandService;
|
|
35
38
|
private readonly _rangeProtectionRuleModel;
|
|
36
|
-
constructor(_unitId: string, _subUnitId: string, _ruleId: string, _permissionId: string, _ranges: FRange[], _options: IRangeProtectionOptions, _injector: Injector, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel);
|
|
39
|
+
constructor(_unitId: string, _subUnitId: string, _ruleId: string, _permissionId: string, _ranges: FRange[], _options: IRangeProtectionOptions, _injector: Injector, _permissionService: IPermissionService, _authzIoService: IAuthzIoService, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel);
|
|
37
40
|
/**
|
|
38
41
|
* Get the rule ID.
|
|
39
|
-
* @returns {string} The unique identifier of this protection rule.
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
|
|
43
|
-
* const permission = worksheet?.getWorksheetPermission();
|
|
44
|
-
* const rules = await permission?.listRangeProtectionRules();
|
|
45
|
-
* const ruleId = rules?.[0]?.id;
|
|
46
|
-
* console.log(ruleId);
|
|
47
|
-
* ```
|
|
48
42
|
*/
|
|
49
43
|
get id(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Get the permission ID associated with this rule.
|
|
46
|
+
*/
|
|
47
|
+
get permissionId(): string;
|
|
50
48
|
/**
|
|
51
49
|
* Get the protected ranges.
|
|
52
|
-
* @returns {FRange[]} Array of protected ranges.
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
|
|
56
|
-
* const permission = worksheet?.getWorksheetPermission();
|
|
57
|
-
* const rules = await permission?.listRangeProtectionRules();
|
|
58
|
-
* const ranges = rules?.[0]?.ranges;
|
|
59
|
-
* console.log(ranges);
|
|
60
|
-
* ```
|
|
61
50
|
*/
|
|
62
51
|
get ranges(): FRange[];
|
|
63
52
|
/**
|
|
64
53
|
* Get the protection options.
|
|
65
|
-
* @returns {IRangeProtectionOptions} Copy of the protection options.
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
|
|
69
|
-
* const permission = worksheet?.getWorksheetPermission();
|
|
70
|
-
* const rules = await permission?.listRangeProtectionRules();
|
|
71
|
-
* const options = rules?.[0]?.options;
|
|
72
|
-
* console.log(options);
|
|
73
|
-
* ```
|
|
74
54
|
*/
|
|
75
55
|
get options(): IRangeProtectionOptions;
|
|
76
56
|
/**
|
|
@@ -79,31 +59,162 @@ export declare class FRangeProtectionRule {
|
|
|
79
59
|
* @returns {Promise<void>} A promise that resolves when the ranges are updated.
|
|
80
60
|
* @example
|
|
81
61
|
* ```ts
|
|
82
|
-
* const
|
|
83
|
-
* const
|
|
84
|
-
* const rules = await
|
|
85
|
-
*
|
|
86
|
-
*
|
|
62
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
63
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
64
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
65
|
+
* // Update the ranges to A1:C3 for the first rule
|
|
66
|
+
* if (rules.length > 0) {
|
|
67
|
+
* const rule = rules[0];
|
|
68
|
+
* const result = await rule.updateRanges([fWorksheet.getRange('A1:C3')]);
|
|
69
|
+
* console.log(result);
|
|
70
|
+
* }
|
|
87
71
|
* ```
|
|
88
72
|
*/
|
|
89
|
-
updateRanges(ranges: FRange[]): Promise<
|
|
73
|
+
updateRanges(ranges: FRange[]): Promise<boolean>;
|
|
90
74
|
/**
|
|
91
75
|
* Delete the current protection rule.
|
|
92
76
|
* @returns {Promise<void>} A promise that resolves when the rule is removed.
|
|
93
77
|
* @example
|
|
94
78
|
* ```ts
|
|
95
|
-
* const
|
|
96
|
-
* const
|
|
97
|
-
* const rules = await
|
|
98
|
-
*
|
|
99
|
-
*
|
|
79
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
80
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
81
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
82
|
+
* // Remove the first protection rule
|
|
83
|
+
* if (rules.length > 0) {
|
|
84
|
+
* const rule = rules[0];
|
|
85
|
+
* const result = await rule.remove();
|
|
86
|
+
* console.log(result);
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
remove(): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Set a specific permission point for the range rule (low-level API).
|
|
93
|
+
*
|
|
94
|
+
* **Important:** This method only updates the permission point value for an existing protection rule.
|
|
95
|
+
* It does NOT create permission checks that will block actual editing operations.
|
|
96
|
+
* You must call `protect()` first to create a protection rule before using this method.
|
|
97
|
+
*
|
|
98
|
+
* This method is useful for:
|
|
99
|
+
* - Fine-tuning permissions after creating a protection rule with `protect()`
|
|
100
|
+
* - Dynamically adjusting permissions based on runtime conditions
|
|
101
|
+
* - Advanced permission management scenarios
|
|
102
|
+
*
|
|
103
|
+
* @param {RangePermissionPoint} point The permission point to set.
|
|
104
|
+
* @param {boolean} value The value to set (true = allowed, false = denied).
|
|
105
|
+
* @returns {Promise<void>} A promise that resolves when the point is set.
|
|
106
|
+
* @throws {Error} If no protection rule exists for this range.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
111
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
112
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
113
|
+
* // First, create a protection rule
|
|
114
|
+
* const rule = await fRange.getRangePermission().protect({ name: 'My Range', allowEdit: true });
|
|
115
|
+
* // Then you can dynamically update permission points
|
|
116
|
+
* await rule.setPoint(univerAPI.Enum.RangePermissionPoint.Edit, false); // Now disable edit
|
|
117
|
+
* await rule.setPoint(univerAPI.Enum.RangePermissionPoint.View, true); // Ensure view is enabled
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
setPoint(point: RangePermissionPoint, value: boolean): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Get the value of a specific permission point.
|
|
123
|
+
* @param {RangePermissionPoint} point The range permission point to query.
|
|
124
|
+
* @returns {boolean} true if allowed, false if denied.
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
128
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
129
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
130
|
+
* // Check if the first rule allows editing
|
|
131
|
+
* if (rules.length > 0) {
|
|
132
|
+
* const rule = rules[0];
|
|
133
|
+
* const canEdit = rule.getPoint(univerAPI.Enum.RangePermissionPoint.Edit);
|
|
134
|
+
* console.log(canEdit);
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
getPoint(point: RangePermissionPoint): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Check if the current user can edit this range.
|
|
141
|
+
* @returns {boolean} true if editable, false otherwise.
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
145
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
146
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
147
|
+
* // Check if the first rule allows editing
|
|
148
|
+
* const rule = rules[0];
|
|
149
|
+
* if (rule?.canEdit()) {
|
|
150
|
+
* console.log(`You can edit this range ${rule.ranges.map(r => r.getA1Notation()).join(', ')}`);
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
canEdit(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Check if the current user can view this range.
|
|
157
|
+
* @returns {boolean} true if viewable, false otherwise.
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
161
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
162
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
163
|
+
* // Check if the first rule allows viewing
|
|
164
|
+
* const rule = rules[0];
|
|
165
|
+
* if (rule?.canView()) {
|
|
166
|
+
* console.log(`You can view this range ${rule.ranges.map(r => r.getA1Notation()).join(', ')}`);
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
canView(): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Check if the current user can manage collaborators for this range.
|
|
173
|
+
* @returns {boolean} true if can manage collaborators, false otherwise.
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
177
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
178
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
179
|
+
* // Check if the first rule allows managing collaborators
|
|
180
|
+
* const rule = rules[0];
|
|
181
|
+
* if (rule?.canManageCollaborator()) {
|
|
182
|
+
* console.log(`You can manage collaborators for this range ${rule.ranges.map(r => r.getA1Notation()).join(', ')}`);
|
|
183
|
+
* }
|
|
100
184
|
* ```
|
|
101
185
|
*/
|
|
102
|
-
|
|
186
|
+
canManageCollaborator(): boolean;
|
|
103
187
|
/**
|
|
104
|
-
* Check if
|
|
105
|
-
* @returns true if
|
|
106
|
-
* @
|
|
188
|
+
* Check if the current user can delete this protection rule.
|
|
189
|
+
* @returns {boolean} true if can delete rule, false otherwise.
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
193
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
194
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
195
|
+
* // Check if the first rule allows deleting the rule
|
|
196
|
+
* const rule = rules[0];
|
|
197
|
+
* if (rule?.canDelete()) {
|
|
198
|
+
* console.log(`You can delete this protection rule for this range ${rule.ranges.map(r => r.getA1Notation()).join(', ')}`);
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
canDelete(): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Get the current permission snapshot.
|
|
205
|
+
* @returns {RangePermissionSnapshot} Snapshot of all permission points.
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
209
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
210
|
+
* const rules = await fWorksheet.getWorksheetPermission().listRangeProtectionRules();
|
|
211
|
+
* // Get the permission snapshot of the first rule
|
|
212
|
+
* if (rules.length > 0) {
|
|
213
|
+
* const rule = rules[0];
|
|
214
|
+
* const snapshot = rule.getSnapshot();
|
|
215
|
+
* console.log(snapshot);
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
107
218
|
*/
|
|
108
|
-
|
|
219
|
+
getSnapshot(): RangePermissionSnapshot;
|
|
109
220
|
}
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
17
|
-
import type { Observable } from 'rxjs';
|
|
18
|
-
import type { ICollaborator, IWorkbookPermission, UnsubscribeFn, WorkbookMode, WorkbookPermissionSnapshot } from './permission-types';
|
|
16
|
+
import type { ICollaborator, ICollaboratorUser, WorkbookMode, WorkbookPermissionSnapshot } from './permission-types';
|
|
19
17
|
import { IAuthzIoService, Injector, IPermissionService } from '@univerjs/core';
|
|
18
|
+
import { FBase } from '@univerjs/core/facade';
|
|
20
19
|
import { UnitRole, WorkbookPermissionPoint } from './permission-types';
|
|
21
20
|
/**
|
|
22
21
|
* Implementation class for WorkbookPermission
|
|
@@ -24,68 +23,20 @@ import { UnitRole, WorkbookPermissionPoint } from './permission-types';
|
|
|
24
23
|
*
|
|
25
24
|
* @hideconstructor
|
|
26
25
|
*/
|
|
27
|
-
export declare class FWorkbookPermission
|
|
26
|
+
export declare class FWorkbookPermission extends FBase {
|
|
28
27
|
private readonly _unitId;
|
|
29
28
|
private readonly _injector;
|
|
30
|
-
|
|
29
|
+
protected readonly _permissionService: IPermissionService;
|
|
31
30
|
private readonly _authzIoService;
|
|
32
|
-
private readonly _permissionSubject;
|
|
33
|
-
private readonly _collaboratorChangeSubject;
|
|
34
|
-
/**
|
|
35
|
-
* Observable stream of permission snapshot changes (BehaviorSubject)
|
|
36
|
-
* Emits immediately on subscription with current state, then on any permission point change
|
|
37
|
-
*/
|
|
38
|
-
readonly permission$: Observable<WorkbookPermissionSnapshot>;
|
|
39
|
-
/**
|
|
40
|
-
* Observable stream of individual permission point changes
|
|
41
|
-
* Emits when a specific permission point value changes
|
|
42
|
-
*/
|
|
43
|
-
readonly pointChange$: Observable<{
|
|
44
|
-
point: WorkbookPermissionPoint;
|
|
45
|
-
value: boolean;
|
|
46
|
-
oldValue: boolean;
|
|
47
|
-
}>;
|
|
48
|
-
/**
|
|
49
|
-
* Observable stream of collaborator changes
|
|
50
|
-
* Emits when collaborators are added, updated, or removed
|
|
51
|
-
*/
|
|
52
|
-
readonly collaboratorChange$: Observable<{
|
|
53
|
-
type: 'add' | 'update' | 'delete';
|
|
54
|
-
collaborator: ICollaborator;
|
|
55
|
-
}>;
|
|
56
|
-
private _subscriptions;
|
|
57
|
-
private readonly _fPermission;
|
|
58
31
|
constructor(_unitId: string, _injector: Injector, _permissionService: IPermissionService, _authzIoService: IAuthzIoService);
|
|
59
|
-
/**
|
|
60
|
-
* Create permission snapshot stream from IPermissionService
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private _createPermissionStream;
|
|
64
|
-
/**
|
|
65
|
-
* Create point change stream from IPermissionService
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
private _createPointChangeStream;
|
|
69
|
-
/**
|
|
70
|
-
* Extract WorkbookPermissionPoint type from permission point ID
|
|
71
|
-
* @private
|
|
72
|
-
*/
|
|
73
|
-
private _extractWorkbookPointType;
|
|
74
|
-
/**
|
|
75
|
-
* Build permission snapshot
|
|
76
|
-
*/
|
|
77
|
-
private _buildSnapshot;
|
|
78
|
-
/**
|
|
79
|
-
* Listen to permission point changes
|
|
80
32
|
/**
|
|
81
33
|
* Set permission mode for the workbook.
|
|
82
34
|
* @param {WorkbookMode} mode The permission mode to set ('owner' | 'editor' | 'viewer' | 'commenter').
|
|
83
35
|
* @returns {Promise<void>} A promise that resolves when the mode is set.
|
|
84
36
|
* @example
|
|
85
37
|
* ```ts
|
|
86
|
-
* const
|
|
87
|
-
*
|
|
88
|
-
* await permission?.setMode('editor');
|
|
38
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
39
|
+
* await fWorkbook.getWorkbookPermission().setMode('editor');
|
|
89
40
|
* ```
|
|
90
41
|
*/
|
|
91
42
|
setMode(mode: WorkbookMode): Promise<void>;
|
|
@@ -94,19 +45,13 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
94
45
|
* @private
|
|
95
46
|
*/
|
|
96
47
|
private _getModePermissions;
|
|
97
|
-
/**
|
|
98
|
-
* Batch set multiple permission points efficiently
|
|
99
|
-
* @private
|
|
100
|
-
*/
|
|
101
|
-
private _batchSetPermissionPoints;
|
|
102
48
|
/**
|
|
103
49
|
* Set the workbook to read-only mode (viewer mode).
|
|
104
50
|
* @returns {Promise<void>} A promise that resolves when the mode is set.
|
|
105
51
|
* @example
|
|
106
52
|
* ```ts
|
|
107
|
-
* const
|
|
108
|
-
*
|
|
109
|
-
* await permission?.setReadOnly();
|
|
53
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
54
|
+
* await fWorkbook.getWorkbookPermission().setReadOnly();
|
|
110
55
|
* ```
|
|
111
56
|
*/
|
|
112
57
|
setReadOnly(): Promise<void>;
|
|
@@ -115,25 +60,11 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
115
60
|
* @returns {Promise<void>} A promise that resolves when the mode is set.
|
|
116
61
|
* @example
|
|
117
62
|
* ```ts
|
|
118
|
-
* const
|
|
119
|
-
*
|
|
120
|
-
* await permission?.setEditable();
|
|
63
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
64
|
+
* await fWorkbook.getWorkbookPermission().setEditable();
|
|
121
65
|
* ```
|
|
122
66
|
*/
|
|
123
67
|
setEditable(): Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Check if the workbook is editable.
|
|
126
|
-
* @returns {boolean} true if the workbook can be edited, false otherwise.
|
|
127
|
-
* @example
|
|
128
|
-
* ```ts
|
|
129
|
-
* const workbook = univerAPI.getActiveWorkbook();
|
|
130
|
-
* const permission = workbook?.getWorkbookPermission();
|
|
131
|
-
* if (permission?.canEdit()) {
|
|
132
|
-
* console.log('Workbook is editable');
|
|
133
|
-
* }
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
canEdit(): boolean;
|
|
137
68
|
/**
|
|
138
69
|
* Set a specific permission point.
|
|
139
70
|
* @param {WorkbookPermissionPoint} point The permission point to set.
|
|
@@ -141,21 +72,33 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
141
72
|
* @returns {Promise<void>} A promise that resolves when the point is set.
|
|
142
73
|
* @example
|
|
143
74
|
* ```ts
|
|
144
|
-
* const
|
|
145
|
-
* const permission =
|
|
146
|
-
* await permission
|
|
75
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
76
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
77
|
+
* await permission.setPoint(univerAPI.Enum.WorkbookPermissionPoint.Print, false);
|
|
147
78
|
* ```
|
|
148
79
|
*/
|
|
149
80
|
setPoint(point: WorkbookPermissionPoint, value: boolean): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Check if the workbook is editable.
|
|
83
|
+
* @returns {boolean} true if the workbook can be edited, false otherwise.
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
87
|
+
* if (fWorkbook.getWorkbookPermission().canEdit()) {
|
|
88
|
+
* console.log('Workbook is editable');
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
canEdit(): boolean;
|
|
150
93
|
/**
|
|
151
94
|
* Get the value of a specific permission point.
|
|
152
95
|
* @param {WorkbookPermissionPoint} point The permission point to query.
|
|
153
96
|
* @returns {boolean} true if allowed, false if denied.
|
|
154
97
|
* @example
|
|
155
98
|
* ```ts
|
|
156
|
-
* const
|
|
157
|
-
* const permission =
|
|
158
|
-
* const canPrint = permission
|
|
99
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
100
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
101
|
+
* const canPrint = permission.getPoint(univerAPI.Enum.WorkbookPermissionPoint.Print);
|
|
159
102
|
* console.log(canPrint);
|
|
160
103
|
* ```
|
|
161
104
|
*/
|
|
@@ -165,9 +108,8 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
165
108
|
* @returns {WorkbookPermissionSnapshot} An object containing all permission point values.
|
|
166
109
|
* @example
|
|
167
110
|
* ```ts
|
|
168
|
-
* const
|
|
169
|
-
* const
|
|
170
|
-
* const snapshot = permission?.getSnapshot();
|
|
111
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
112
|
+
* const snapshot = fWorkbook.getWorkbookPermission().getSnapshot();
|
|
171
113
|
* console.log(snapshot);
|
|
172
114
|
* ```
|
|
173
115
|
*/
|
|
@@ -178,9 +120,9 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
178
120
|
* @returns {Promise<void>} A promise that resolves when the collaborators are set.
|
|
179
121
|
* @example
|
|
180
122
|
* ```ts
|
|
181
|
-
* const
|
|
182
|
-
* const permission =
|
|
183
|
-
* await permission
|
|
123
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
124
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
125
|
+
* await permission.setCollaborators([
|
|
184
126
|
* {
|
|
185
127
|
* user: { userID: 'user1', name: 'John Doe', avatar: 'https://...' },
|
|
186
128
|
* role: univerAPI.Enum.UnitRole.Editor
|
|
@@ -193,7 +135,7 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
193
135
|
* ```
|
|
194
136
|
*/
|
|
195
137
|
setCollaborators(collaborators: Array<{
|
|
196
|
-
user:
|
|
138
|
+
user: ICollaboratorUser;
|
|
197
139
|
role: UnitRole;
|
|
198
140
|
}>): Promise<void>;
|
|
199
141
|
/**
|
|
@@ -203,15 +145,15 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
203
145
|
* @returns {Promise<void>} A promise that resolves when the collaborator is added.
|
|
204
146
|
* @example
|
|
205
147
|
* ```ts
|
|
206
|
-
* const
|
|
207
|
-
* const permission =
|
|
208
|
-
* await permission
|
|
148
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
149
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
150
|
+
* await permission.addCollaborator(
|
|
209
151
|
* { userID: 'user1', name: 'John Doe', avatar: 'https://...' },
|
|
210
152
|
* univerAPI.Enum.UnitRole.Editor
|
|
211
153
|
* );
|
|
212
154
|
* ```
|
|
213
155
|
*/
|
|
214
|
-
addCollaborator(user:
|
|
156
|
+
addCollaborator(user: ICollaboratorUser, role: UnitRole): Promise<void>;
|
|
215
157
|
/**
|
|
216
158
|
* Update an existing collaborator's role and information.
|
|
217
159
|
* @param {IUser} user The updated user information (userID, name, avatar).
|
|
@@ -219,24 +161,24 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
219
161
|
* @returns {Promise<void>} A promise that resolves when the collaborator is updated.
|
|
220
162
|
* @example
|
|
221
163
|
* ```ts
|
|
222
|
-
* const
|
|
223
|
-
* const permission =
|
|
224
|
-
* await permission
|
|
164
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
165
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
166
|
+
* await permission.updateCollaborator(
|
|
225
167
|
* { userID: 'user1', name: 'John Doe Updated', avatar: 'https://...' },
|
|
226
168
|
* univerAPI.Enum.UnitRole.Reader
|
|
227
169
|
* );
|
|
228
170
|
* ```
|
|
229
171
|
*/
|
|
230
|
-
updateCollaborator(user:
|
|
172
|
+
updateCollaborator(user: ICollaboratorUser, role: UnitRole): Promise<void>;
|
|
231
173
|
/**
|
|
232
174
|
* Remove a collaborator from the workbook.
|
|
233
175
|
* @param {string} userId The user ID to remove.
|
|
234
176
|
* @returns {Promise<void>} A promise that resolves when the collaborator is removed.
|
|
235
177
|
* @example
|
|
236
178
|
* ```ts
|
|
237
|
-
* const
|
|
238
|
-
* const permission =
|
|
239
|
-
* await permission
|
|
179
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
180
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
181
|
+
* await permission.removeCollaborator('user1');
|
|
240
182
|
* ```
|
|
241
183
|
*/
|
|
242
184
|
removeCollaborator(userId: string): Promise<void>;
|
|
@@ -246,9 +188,9 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
246
188
|
* @returns {Promise<void>} A promise that resolves when the collaborators are removed.
|
|
247
189
|
* @example
|
|
248
190
|
* ```ts
|
|
249
|
-
* const
|
|
250
|
-
* const permission =
|
|
251
|
-
* await permission
|
|
191
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
192
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
193
|
+
* await permission.removeCollaborators(['user1', 'user2']);
|
|
252
194
|
* ```
|
|
253
195
|
*/
|
|
254
196
|
removeCollaborators(userIds: string[]): Promise<void>;
|
|
@@ -257,31 +199,11 @@ export declare class FWorkbookPermission implements IWorkbookPermission {
|
|
|
257
199
|
* @returns {Promise<ICollaborator[]>} Array of collaborators with their roles.
|
|
258
200
|
* @example
|
|
259
201
|
* ```ts
|
|
260
|
-
* const
|
|
261
|
-
* const permission =
|
|
262
|
-
* const collaborators = await permission
|
|
202
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
203
|
+
* const permission = fWorkbook.getWorkbookPermission();
|
|
204
|
+
* const collaborators = await permission.listCollaborators();
|
|
263
205
|
* console.log(collaborators);
|
|
264
206
|
* ```
|
|
265
207
|
*/
|
|
266
208
|
listCollaborators(): Promise<ICollaborator[]>;
|
|
267
|
-
/**
|
|
268
|
-
* Subscribe to permission changes (simplified interface for users not familiar with RxJS).
|
|
269
|
-
* @param {Function} listener Callback function to be called when permissions change.
|
|
270
|
-
* @returns {UnsubscribeFn} Unsubscribe function.
|
|
271
|
-
* @example
|
|
272
|
-
* ```ts
|
|
273
|
-
* const workbook = univerAPI.getActiveWorkbook();
|
|
274
|
-
* const permission = workbook?.getWorkbookPermission();
|
|
275
|
-
* const unsubscribe = permission?.subscribe((snapshot) => {
|
|
276
|
-
* console.log('Permission changed:', snapshot);
|
|
277
|
-
* });
|
|
278
|
-
* // Later, to stop listening:
|
|
279
|
-
* unsubscribe?.();
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
subscribe(listener: (snapshot: WorkbookPermissionSnapshot) => void): UnsubscribeFn;
|
|
283
|
-
/**
|
|
284
|
-
* Clean up resources
|
|
285
|
-
*/
|
|
286
|
-
dispose(): void;
|
|
287
209
|
}
|