@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
|
@@ -21,8 +21,7 @@ import { ICommandService, ILogService, Injector, IPermissionService, IResourceLo
|
|
|
21
21
|
import { FBaseInitialable } from '@univerjs/core/facade';
|
|
22
22
|
import { IDefinedNamesService } from '@univerjs/engine-formula';
|
|
23
23
|
import { RangeThemeStyle, SheetsSelectionsService } from '@univerjs/sheets';
|
|
24
|
-
import { FDefinedName } from './f-defined-name';
|
|
25
|
-
import { FPermission } from './f-permission';
|
|
24
|
+
import { FDefinedName, FDefinedNameBuilder } from './f-defined-name';
|
|
26
25
|
import { FRange } from './f-range';
|
|
27
26
|
import { FWorksheet } from './f-worksheet';
|
|
28
27
|
import { FWorkbookPermission } from './permission/f-workbook-permission';
|
|
@@ -514,18 +513,6 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
514
513
|
* ```
|
|
515
514
|
*/
|
|
516
515
|
moveActiveSheet(index: number): FWorkbook;
|
|
517
|
-
/**
|
|
518
|
-
* Get the PermissionInstance.
|
|
519
|
-
* @returns {FPermission} - The PermissionInstance.
|
|
520
|
-
* @deprecated Use `getWorkbookPermission()` instead for the new permission API
|
|
521
|
-
* @example
|
|
522
|
-
* ```ts
|
|
523
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
524
|
-
* const permission = fWorkbook.getPermission();
|
|
525
|
-
* console.log(permission);
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
getPermission(): FPermission;
|
|
529
516
|
/**
|
|
530
517
|
* Get the WorkbookPermission instance for managing workbook-level permissions.
|
|
531
518
|
* This is the new permission API that provides a more intuitive and type-safe interface.
|
|
@@ -562,10 +549,6 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
562
549
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
563
550
|
* const definedName = fWorkbook.getDefinedName('MyDefinedName');
|
|
564
551
|
* console.log(definedName?.getFormulaOrRefString());
|
|
565
|
-
*
|
|
566
|
-
* if (definedName) {
|
|
567
|
-
* definedName.setName('NewDefinedName');
|
|
568
|
-
* }
|
|
569
552
|
* ```
|
|
570
553
|
*/
|
|
571
554
|
getDefinedName(name: string): FDefinedName | null;
|
|
@@ -582,30 +565,21 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
582
565
|
*/
|
|
583
566
|
getDefinedNames(): FDefinedName[];
|
|
584
567
|
/**
|
|
585
|
-
*
|
|
586
|
-
* @
|
|
587
|
-
* @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
|
|
588
|
-
* @returns {FWorkbook} The current FWorkbook instance
|
|
589
|
-
* @example
|
|
590
|
-
* ```ts
|
|
591
|
-
* // The code below inserts a defined name
|
|
592
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
593
|
-
* fWorkbook.insertDefinedName('MyDefinedName', 'Sheet1!$A$1');
|
|
594
|
-
* ```
|
|
595
|
-
*/
|
|
596
|
-
insertDefinedName(name: string, formulaOrRefString: string): FWorkbook;
|
|
597
|
-
/**
|
|
598
|
-
* Delete the defined name with the given name.
|
|
599
|
-
* @param {string} name The name of the defined name to delete
|
|
600
|
-
* @returns {boolean} true if the defined name was deleted, false otherwise
|
|
568
|
+
* Create a new defined name builder.
|
|
569
|
+
* @returns {FDefinedNameBuilder} - The defined name builder.
|
|
601
570
|
* @example
|
|
602
571
|
* ```ts
|
|
603
|
-
* // The code below deletes the defined name with the given name
|
|
604
572
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
605
|
-
* fWorkbook.
|
|
573
|
+
* const definedNameParam = fWorkbook.newDefinedNameBuilder()
|
|
574
|
+
* .setRef('Sheet1!$A$1')
|
|
575
|
+
* .setName('MyDefinedName')
|
|
576
|
+
* .setComment('This is a comment');
|
|
577
|
+
* .build();
|
|
578
|
+
* console.log(definedNameParam);
|
|
579
|
+
* fWorkbook.insertDefinedNameBuilder(definedNameParam);
|
|
606
580
|
* ```
|
|
607
581
|
*/
|
|
608
|
-
|
|
582
|
+
newDefinedNameBuilder(): FDefinedNameBuilder;
|
|
609
583
|
/**
|
|
610
584
|
* Insert a defined name by builder param.
|
|
611
585
|
* @param {ISetDefinedNameMutationParam} param The param to insert the defined name
|
|
@@ -614,12 +588,12 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
614
588
|
* ```ts
|
|
615
589
|
* // The code below inserts a defined name by builder param
|
|
616
590
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
617
|
-
* const
|
|
591
|
+
* const definedNameParam = fWorkbook.newDefinedNameBuilder()
|
|
618
592
|
* .setRef('Sheet1!$A$1')
|
|
619
593
|
* .setName('MyDefinedName')
|
|
620
594
|
* .setComment('This is a comment')
|
|
621
595
|
* .build();
|
|
622
|
-
* fWorkbook.insertDefinedNameBuilder(
|
|
596
|
+
* fWorkbook.insertDefinedNameBuilder(definedNameParam);
|
|
623
597
|
* ```
|
|
624
598
|
*/
|
|
625
599
|
insertDefinedNameBuilder(param: ISetDefinedNameMutationParam): void;
|
|
@@ -645,6 +619,31 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
645
619
|
* ```
|
|
646
620
|
*/
|
|
647
621
|
updateDefinedNameBuilder(param: ISetDefinedNameMutationParam): void;
|
|
622
|
+
/**
|
|
623
|
+
* Insert a defined name.
|
|
624
|
+
* @param {string} name The name of the defined name to insert
|
|
625
|
+
* @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
|
|
626
|
+
* @returns {FWorkbook} The current FWorkbook instance
|
|
627
|
+
* @example
|
|
628
|
+
* ```ts
|
|
629
|
+
* // The code below inserts a defined name
|
|
630
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
631
|
+
* fWorkbook.insertDefinedName('MyDefinedName', 'Sheet1!$A$1');
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
634
|
+
insertDefinedName(name: string, formulaOrRefString: string): FWorkbook;
|
|
635
|
+
/**
|
|
636
|
+
* Delete the defined name with the given name.
|
|
637
|
+
* @param {string} name The name of the defined name to delete
|
|
638
|
+
* @returns {boolean} true if the defined name was deleted, false otherwise
|
|
639
|
+
* @example
|
|
640
|
+
* ```ts
|
|
641
|
+
* // The code below deletes the defined name with the given name
|
|
642
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
643
|
+
* fWorkbook.deleteDefinedName('MyDefinedName');
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
646
|
+
deleteDefinedName(name: string): boolean;
|
|
648
647
|
/**
|
|
649
648
|
* Gets the registered range themes.
|
|
650
649
|
* @returns {string[]} The name list of registered range themes.
|
|
@@ -17,10 +17,10 @@ import './f-univer';
|
|
|
17
17
|
import './f-enum';
|
|
18
18
|
export * from './f-enum';
|
|
19
19
|
export * from './f-event';
|
|
20
|
-
export { FPermission } from './f-permission';
|
|
21
20
|
export { FRange } from './f-range';
|
|
22
21
|
export { FSelection } from './f-selection';
|
|
23
22
|
export { FSheetHooks } from './f-sheet-hooks';
|
|
24
23
|
export { FWorkbook } from './f-workbook';
|
|
25
|
-
export type * from './f-univer';
|
|
26
24
|
export { FWorksheet } from './f-worksheet';
|
|
25
|
+
export { FWorkbookPermission } from './permission/f-workbook-permission';
|
|
26
|
+
export type * from './f-univer';
|
|
@@ -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
|
|
20
|
-
import { IAuthzIoService, ICommandService, Injector
|
|
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
|
-
|
|
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}
|
|
41
|
+
* @returns {boolean} True if the range is protected, false otherwise.
|
|
106
42
|
* @example
|
|
107
43
|
* ```ts
|
|
108
|
-
* const
|
|
109
|
-
* const
|
|
110
|
-
* const
|
|
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
|
|
205
|
-
* const
|
|
206
|
-
* const
|
|
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
|
-
*
|
|
218
|
-
* @
|
|
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
|
|
242
|
-
* const
|
|
243
|
-
*
|
|
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<
|
|
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
|
|
253
|
-
* const
|
|
254
|
-
* const
|
|
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(
|
|
259
|
-
|
|
260
|
-
|
|
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
|
}
|