@univerjs/sheets 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/lib/cjs/facade.js +8352 -1
  2. package/lib/cjs/index.js +21494 -2
  3. package/lib/cjs/locale/ca-ES.js +17 -1
  4. package/lib/cjs/locale/en-US.js +32 -1
  5. package/lib/cjs/locale/es-ES.js +17 -1
  6. package/lib/cjs/locale/fa-IR.js +17 -1
  7. package/lib/cjs/locale/fr-FR.js +17 -1
  8. package/lib/cjs/locale/ja-JP.js +17 -1
  9. package/lib/cjs/locale/ko-KR.js +17 -1
  10. package/lib/cjs/locale/ru-RU.js +17 -1
  11. package/lib/cjs/locale/sk-SK.js +17 -1
  12. package/lib/cjs/locale/vi-VN.js +17 -1
  13. package/lib/cjs/locale/zh-CN.js +17 -1
  14. package/lib/cjs/locale/zh-TW.js +17 -1
  15. package/lib/es/facade.js +8314 -1
  16. package/lib/es/index.js +20973 -2
  17. package/lib/es/locale/ca-ES.js +16 -1
  18. package/lib/es/locale/en-US.js +31 -1
  19. package/lib/es/locale/es-ES.js +16 -1
  20. package/lib/es/locale/fa-IR.js +16 -1
  21. package/lib/es/locale/fr-FR.js +16 -1
  22. package/lib/es/locale/ja-JP.js +16 -1
  23. package/lib/es/locale/ko-KR.js +16 -1
  24. package/lib/es/locale/ru-RU.js +16 -1
  25. package/lib/es/locale/sk-SK.js +16 -1
  26. package/lib/es/locale/vi-VN.js +16 -1
  27. package/lib/es/locale/zh-CN.js +16 -1
  28. package/lib/es/locale/zh-TW.js +16 -1
  29. package/lib/facade.js +8314 -1
  30. package/lib/index.js +20973 -2
  31. package/lib/locale/ca-ES.js +16 -1
  32. package/lib/locale/en-US.js +31 -1
  33. package/lib/locale/es-ES.js +16 -1
  34. package/lib/locale/fa-IR.js +16 -1
  35. package/lib/locale/fr-FR.js +16 -1
  36. package/lib/locale/ja-JP.js +16 -1
  37. package/lib/locale/ko-KR.js +16 -1
  38. package/lib/locale/ru-RU.js +16 -1
  39. package/lib/locale/sk-SK.js +16 -1
  40. package/lib/locale/vi-VN.js +16 -1
  41. package/lib/locale/zh-CN.js +16 -1
  42. package/lib/locale/zh-TW.js +16 -1
  43. package/lib/types/commands/commands/remove-row-col.command.d.ts +2 -1
  44. package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +11 -12
  45. package/lib/types/facade/f-univer.d.ts +0 -7
  46. package/lib/types/facade/f-workbook.d.ts +0 -13
  47. package/lib/types/facade/index.d.ts +2 -2
  48. package/lib/types/facade/permission/f-range-permission.d.ts +31 -228
  49. package/lib/types/facade/permission/f-range-protection-rule.d.ts +157 -46
  50. package/lib/types/facade/permission/f-workbook-permission.d.ts +51 -129
  51. package/lib/types/facade/permission/f-worksheet-permission.d.ts +111 -199
  52. package/lib/types/facade/permission/permission-types.d.ts +20 -125
  53. package/lib/types/facade/permission/util.d.ts +40 -0
  54. package/lib/types/services/permission/range-permission/util.d.ts +2 -1
  55. package/lib/umd/facade.js +1 -1
  56. package/lib/umd/index.js +2 -2
  57. package/package.json +9 -9
  58. package/lib/types/facade/f-permission.d.ts +0 -426
@@ -13,199 +13,54 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Observable } from 'rxjs';
17
16
  import type { FRange } from '../f-range';
18
17
  import type { FWorksheet } from '../f-worksheet';
19
- import type { IRangeProtectionOptions, RangePermissionSnapshot } from './permission-types';
20
- import { IAuthzIoService, ICommandService, Injector, IPermissionService } from '@univerjs/core';
18
+ import type { IRangeProtectionOptions } from './permission-types';
19
+ import { IAuthzIoService, ICommandService, Injector } from '@univerjs/core';
20
+ import { FBase } from '@univerjs/core/facade';
21
21
  import { RangeProtectionRuleModel } from '@univerjs/sheets';
22
22
  import { FRangeProtectionRule } from './f-range-protection-rule';
23
- import { RangePermissionPoint } from './permission-types';
24
23
  /**
25
24
  * Implementation class for RangePermission
26
25
  * Manages range-level permissions
27
26
  *
28
27
  * @hideconstructor
29
28
  */
30
- export declare class FRangePermission {
29
+ export declare class FRangePermission extends FBase {
31
30
  private readonly _unitId;
32
31
  private readonly _subUnitId;
33
32
  private readonly _range;
34
33
  private readonly _worksheet;
35
34
  private readonly _injector;
36
- private readonly _permissionService;
37
35
  private readonly _authzIoService;
38
36
  private readonly _commandService;
39
37
  private readonly _rangeProtectionRuleModel;
40
- private readonly _permissionSubject;
41
- private readonly _subscriptions;
42
- private readonly _fPermission;
43
- /**
44
- * Observable stream of permission snapshot changes
45
- * @returns Observable that emits when permission snapshot changes
46
- */
47
- readonly permission$: Observable<RangePermissionSnapshot>;
48
- /**
49
- * Observable stream of protection state changes
50
- * @returns Observable that emits when protection state changes
51
- */
52
- readonly protectionChange$: Observable<{
53
- type: 'protected';
54
- rule: FRangeProtectionRule;
55
- } | {
56
- type: 'unprotected';
57
- ruleId: string;
58
- }>;
59
- constructor(_unitId: string, _subUnitId: string, _range: FRange, _worksheet: FWorksheet, _injector: Injector, _permissionService: IPermissionService, _authzIoService: IAuthzIoService, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel);
60
- /**
61
- * Create permission snapshot stream from IPermissionService
62
- * @private
63
- */
64
- private _createPermissionStream;
65
- /**
66
- * Create protection change stream from RangeProtectionRuleModel
67
- * @private
68
- */
69
- private _createProtectionChangeStream;
70
- /**
71
- * Check if a protection rule matches this range
72
- */
73
- private _rangeMatches;
74
- /**
75
- * Create a Facade rule from internal rule
76
- */
77
- private _createFacadeRule;
78
- /**
79
- * Get the value of a specific permission point.
80
- * @param {RangePermissionPoint} point The permission point to query.
81
- * @returns {boolean} true if allowed, false if denied.
82
- * @example
83
- * ```ts
84
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
85
- * const permission = range?.getRangePermission();
86
- * const canEdit = permission?.getPoint(univerAPI.Enum.RangePermissionPoint.Edit);
87
- * console.log(canEdit);
88
- * ```
89
- */
90
- getPoint(point: RangePermissionPoint): boolean;
91
- /**
92
- * Get the current permission snapshot.
93
- * @returns {RangePermissionSnapshot} Snapshot of all permission points.
94
- * @example
95
- * ```ts
96
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
97
- * const permission = range?.getRangePermission();
98
- * const snapshot = permission?.getSnapshot();
99
- * console.log(snapshot);
100
- * ```
101
- */
102
- getSnapshot(): RangePermissionSnapshot;
38
+ constructor(_unitId: string, _subUnitId: string, _range: FRange, _worksheet: FWorksheet, _injector: Injector, _authzIoService: IAuthzIoService, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel);
103
39
  /**
104
40
  * Check if the current range is protected.
105
- * @returns {boolean} true if protected, false otherwise.
41
+ * @returns {boolean} True if the range is protected, false otherwise.
106
42
  * @example
107
43
  * ```ts
108
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
109
- * const permission = range?.getRangePermission();
110
- * const isProtected = permission?.isProtected();
44
+ * const fWorkbook = univerAPI.getActiveWorkbook();
45
+ * const fWorksheet = fWorkbook.getActiveSheet();
46
+ * const fRange = fWorksheet.getRange('A1:B2');
47
+ * // Check if the A1:B2 range is protected
48
+ * const isProtected = fRange.getRangePermission().isProtected();
111
49
  * console.log(isProtected);
112
50
  * ```
113
51
  */
114
52
  isProtected(): boolean;
115
- /**
116
- * Check if the current user can edit this range.
117
- * @returns {boolean} true if editable, false otherwise.
118
- * @example
119
- * ```ts
120
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
121
- * const permission = range?.getRangePermission();
122
- * if (permission?.canEdit()) {
123
- * console.log('You can edit this range');
124
- * }
125
- * ```
126
- */
127
- canEdit(): boolean;
128
- /**
129
- * Check if the current user can view this range.
130
- * @returns {boolean} true if viewable, false otherwise.
131
- * @example
132
- * ```ts
133
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
134
- * const permission = range?.getRangePermission();
135
- * if (permission?.canView()) {
136
- * console.log('You can view this range');
137
- * }
138
- * ```
139
- */
140
- canView(): boolean;
141
- /**
142
- * Check if the current user can manage collaborators for this range.
143
- * @returns {boolean} true if can manage collaborators, false otherwise.
144
- * @example
145
- * ```ts
146
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
147
- * const permission = range?.getRangePermission();
148
- * if (permission?.canManageCollaborator()) {
149
- * console.log('You can manage collaborators for this range');
150
- * }
151
- * ```
152
- */
153
- canManageCollaborator(): boolean;
154
- /**
155
- * Check if the current user can delete this protection rule.
156
- * @returns {boolean} true if can delete rule, false otherwise.
157
- * @example
158
- * ```ts
159
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
160
- * const permission = range?.getRangePermission();
161
- * if (permission?.canDelete()) {
162
- * console.log('You can delete this protection rule');
163
- * }
164
- * ```
165
- */
166
- canDelete(): boolean;
167
- /**
168
- * Set a specific permission point for the range (low-level API).
169
- *
170
- * **Important:** This method only updates the permission point value for an existing protection rule.
171
- * It does NOT create permission checks that will block actual editing operations.
172
- * You must call `protect()` first to create a protection rule before using this method.
173
- *
174
- * This method is useful for:
175
- * - Fine-tuning permissions after creating a protection rule with `protect()`
176
- * - Dynamically adjusting permissions based on runtime conditions
177
- * - Advanced permission management scenarios
178
- *
179
- * @param {RangePermissionPoint} point The permission point to set.
180
- * @param {boolean} value The value to set (true = allowed, false = denied).
181
- * @returns {Promise<void>} A promise that resolves when the point is set.
182
- * @throws {Error} If no protection rule exists for this range.
183
- *
184
- * @example
185
- * ```ts
186
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
187
- * const permission = range?.getRangePermission();
188
- *
189
- * // First, create a protection rule
190
- * await permission?.protect({ name: 'My Range', allowEdit: true });
191
- *
192
- * // Then you can dynamically update permission points
193
- * await permission?.setPoint(univerAPI.Enum.RangePermissionPoint.Edit, false); // Now disable edit
194
- * await permission?.setPoint(univerAPI.Enum.RangePermissionPoint.View, true); // Ensure view is enabled
195
- * ```
196
- */
197
- setPoint(point: RangePermissionPoint, value: boolean): Promise<void>;
198
53
  /**
199
54
  * Protect the current range.
200
55
  * @param {IRangeProtectionOptions} options Protection options.
201
56
  * @returns {Promise<FRangeProtectionRule>} The created protection rule.
202
57
  * @example
203
58
  * ```ts
204
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
205
- * const permission = range?.getRangePermission();
206
- * const rule = await permission?.protect({
59
+ * const fWorkbook = univerAPI.getActiveWorkbook();
60
+ * const fWorksheet = fWorkbook.getActiveSheet();
61
+ * const fRange = fWorksheet.getRange('A1:B2');
62
+ * const rule = await fRange.getRangePermission().protect({
207
63
  * name: 'My protected range',
208
- * allowEdit: true,
209
64
  * allowedUsers: ['user1', 'user2'],
210
65
  * allowViewByOthers: false,
211
66
  * });
@@ -214,83 +69,31 @@ export declare class FRangePermission {
214
69
  */
215
70
  protect(options?: IRangeProtectionOptions): Promise<FRangeProtectionRule>;
216
71
  /**
217
- * Determine view state from options
218
- * @private
219
- */
220
- private _determineViewState;
221
- /**
222
- * Determine edit state from options
223
- * @private
224
- */
225
- private _determineEditState;
226
- /**
227
- * Set permission points based on options (for local runtime control)
228
- * @private
229
- */
230
- private _setPermissionPoints;
231
- /**
232
- * Set a single permission point
233
- * @private
234
- */
235
- private _setPermissionPoint;
236
- /**
237
- * Unprotect the current range.
238
- * @returns {Promise<void>} A promise that resolves when the range is unprotected.
72
+ * Cancel all protection rules that intersect with the current range.
73
+ * @returns {Promise<boolean>} True if all rules were successfully removed, false otherwise.
239
74
  * @example
240
75
  * ```ts
241
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
242
- * const permission = range?.getRangePermission();
243
- * await permission?.unprotect();
76
+ * const fWorkbook = univerAPI.getActiveWorkbook();
77
+ * const fWorksheet = fWorkbook.getActiveSheet();
78
+ * const fRange = fWorksheet.getRange('A1:B2');
79
+ * const result = await fRange.getRangePermission().unprotect();
80
+ * console.log(result);
244
81
  * ```
245
82
  */
246
- unprotect(): Promise<void>;
83
+ unprotect(): Promise<boolean>;
247
84
  /**
248
- * List all protection rules.
85
+ * List all protection rules that intersect with the current range.
249
86
  * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
250
87
  * @example
251
88
  * ```ts
252
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
253
- * const permission = range?.getRangePermission();
254
- * const rules = await permission?.listRules();
89
+ * const fWorkbook = univerAPI.getActiveWorkbook();
90
+ * const fWorksheet = fWorkbook.getActiveSheet();
91
+ * const fRange = fWorksheet.getRange('A1:B2');
92
+ * const rules = await fRange.getRangePermission().listRules();
255
93
  * console.log(rules);
256
94
  * ```
257
95
  */
258
- listRules(): Promise<FRangeProtectionRule[]>;
259
- /**
260
- * Subscribe to permission changes (simplified interface).
261
- * @param {Function} listener Callback function to be called when permissions change.
262
- * @returns {Function} Unsubscribe function.
263
- * @example
264
- * ```ts
265
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
266
- * const permission = range?.getRangePermission();
267
- * const unsubscribe = permission?.subscribe((snapshot) => {
268
- * console.log('Permission changed:', snapshot);
269
- * });
270
- * // Later, to stop listening:
271
- * unsubscribe?.();
272
- * ```
273
- */
274
- subscribe(listener: (snapshot: RangePermissionSnapshot) => void): (() => void);
275
- /**
276
- * Get the protection rule for the current range
277
- */
278
- private _getProtectionRule;
279
- /**
280
- * Build Facade objects for all protection rules
281
- */
282
- private _buildProtectionRules;
283
- /**
284
- * Build Facade objects for all protection rules (async version with collaborator data)
285
- * @private
286
- */
287
- private _buildProtectionRulesAsync;
288
- /**
289
- * Build permission snapshot
290
- */
291
- private _buildSnapshot;
292
- /**
293
- * Clean up resources
294
- */
295
- dispose(): void;
96
+ listRules(options?: {
97
+ ignoreCollaborators?: boolean;
98
+ }): Promise<FRangeProtectionRule[]>;
296
99
  }
@@ -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
@@ -32,45 +33,24 @@ export declare class FRangeProtectionRule {
32
33
  private readonly _options;
33
34
  private readonly _injector;
34
35
  private readonly _commandService;
36
+ private readonly _permissionService;
37
+ private readonly _authzIoService;
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, _commandService: ICommandService, _permissionService: IPermissionService, _authzIoService: IAuthzIoService, _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 worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
83
- * const permission = worksheet?.getWorksheetPermission();
84
- * const rules = await permission?.listRangeProtectionRules();
85
- * const rule = rules?.[0];
86
- * await rule?.updateRanges([worksheet.getRange('A1:C3')]);
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<void>;
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 worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
96
- * const permission = worksheet?.getWorksheetPermission();
97
- * const rules = await permission?.listRangeProtectionRules();
98
- * const rule = rules?.[0];
99
- * await rule?.remove();
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
- remove(): Promise<void>;
186
+ canManageCollaborator(): boolean;
103
187
  /**
104
- * Check if two ranges intersect
105
- * @returns true if ranges intersect, false otherwise
106
- * @private
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
- private _rangesIntersect;
219
+ getSnapshot(): RangePermissionSnapshot;
109
220
  }