@univerjs/sheets 0.11.0 → 0.12.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/cjs/locale/ja-JP.js +1 -0
- package/lib/es/facade.js +5551 -3674
- package/lib/es/index.js +3854 -3852
- package/lib/es/locale/ja-JP.js +17 -0
- package/lib/facade.js +5551 -3674
- package/lib/index.js +3854 -3852
- package/lib/locale/ja-JP.js +17 -0
- package/lib/types/commands/commands/clear-selection-content.command.d.ts +6 -1
- package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +0 -13
- package/lib/types/facade/f-permission.d.ts +41 -2
- package/lib/types/facade/f-range.d.ts +30 -0
- package/lib/types/facade/f-workbook.d.ts +28 -0
- package/lib/types/facade/f-worksheet.d.ts +31 -0
- package/lib/types/facade/permission/f-range-permission.d.ts +270 -0
- package/lib/types/facade/permission/f-range-protection-rule.d.ts +108 -0
- package/lib/types/facade/permission/f-workbook-permission.d.ts +270 -0
- package/lib/types/facade/permission/f-worksheet-permission.d.ts +335 -0
- package/lib/types/facade/permission/index.d.ts +21 -0
- package/lib/types/facade/permission/permission-point-map.d.ts +14 -0
- package/lib/types/facade/permission/permission-types.d.ts +483 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/ja-JP.d.ts +3 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +3 -3
- package/lib/umd/locale/ja-JP.js +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { IUser } from '@univerjs/protocol';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { FRange } from '../f-range';
|
|
4
|
+
/**
|
|
5
|
+
* ========================
|
|
6
|
+
* Basic Types / Enums
|
|
7
|
+
* ========================
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* User role in a unit (Workbook)
|
|
11
|
+
*/
|
|
12
|
+
export declare enum UnitRole {
|
|
13
|
+
Reader = 0,
|
|
14
|
+
Editor = 1,
|
|
15
|
+
Owner = 2
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* User reference information
|
|
19
|
+
*/
|
|
20
|
+
export interface IUserRef {
|
|
21
|
+
/** User ID (defined by host system) */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Display name */
|
|
24
|
+
displayName?: string;
|
|
25
|
+
/** Email address */
|
|
26
|
+
email?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Collaborator information
|
|
30
|
+
*/
|
|
31
|
+
export interface ICollaborator {
|
|
32
|
+
/** User information */
|
|
33
|
+
user: IUserRef;
|
|
34
|
+
/** Role */
|
|
35
|
+
role: UnitRole;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Workbook-level permission point enumeration
|
|
39
|
+
*/
|
|
40
|
+
export declare enum WorkbookPermissionPoint {
|
|
41
|
+
/** Edit permission */
|
|
42
|
+
Edit = "WorkbookEdit",
|
|
43
|
+
/** View permission */
|
|
44
|
+
View = "WorkbookView",
|
|
45
|
+
/** Print permission */
|
|
46
|
+
Print = "WorkbookPrint",
|
|
47
|
+
/** Export permission */
|
|
48
|
+
Export = "WorkbookExport",
|
|
49
|
+
/** Share permission */
|
|
50
|
+
Share = "WorkbookShare",
|
|
51
|
+
/** Copy content permission */
|
|
52
|
+
CopyContent = "WorkbookCopy",
|
|
53
|
+
/** Duplicate file permission */
|
|
54
|
+
DuplicateFile = "WorkbookDuplicate",
|
|
55
|
+
/** Comment permission */
|
|
56
|
+
Comment = "WorkbookComment",
|
|
57
|
+
/** Manage collaborators permission */
|
|
58
|
+
ManageCollaborator = "WorkbookManageCollaborator",
|
|
59
|
+
/** Create sheet permission */
|
|
60
|
+
CreateSheet = "WorkbookCreateSheet",
|
|
61
|
+
/** Delete sheet permission */
|
|
62
|
+
DeleteSheet = "WorkbookDeleteSheet",
|
|
63
|
+
/** Rename sheet permission */
|
|
64
|
+
RenameSheet = "WorkbookRenameSheet",
|
|
65
|
+
/** Move sheet permission */
|
|
66
|
+
MoveSheet = "WorkbookMoveSheet",
|
|
67
|
+
/** Hide sheet permission */
|
|
68
|
+
HideSheet = "WorkbookHideSheet",
|
|
69
|
+
/** View history permission */
|
|
70
|
+
ViewHistory = "WorkbookViewHistory",
|
|
71
|
+
/** Manage history permission */
|
|
72
|
+
ManageHistory = "WorkbookHistory",
|
|
73
|
+
/** Recover history permission */
|
|
74
|
+
RecoverHistory = "WorkbookRecoverHistory",
|
|
75
|
+
/** Create protection permission */
|
|
76
|
+
CreateProtection = "WorkbookCreateProtect",
|
|
77
|
+
/** Insert row permission */
|
|
78
|
+
InsertRow = "WorkbookInsertRow",
|
|
79
|
+
/** Insert column permission */
|
|
80
|
+
InsertColumn = "WorkbookInsertColumn",
|
|
81
|
+
/** Delete row permission */
|
|
82
|
+
DeleteRow = "WorkbookDeleteRow",
|
|
83
|
+
/** Delete column permission */
|
|
84
|
+
DeleteColumn = "WorkbookDeleteColumn",
|
|
85
|
+
/** Copy sheet permission */
|
|
86
|
+
CopySheet = "WorkbookCopySheet"
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Worksheet-level permission point enumeration
|
|
90
|
+
*/
|
|
91
|
+
export declare enum WorksheetPermissionPoint {
|
|
92
|
+
/** Edit permission */
|
|
93
|
+
Edit = "WorksheetEdit",
|
|
94
|
+
/** View permission */
|
|
95
|
+
View = "WorksheetView",
|
|
96
|
+
/** Copy permission */
|
|
97
|
+
Copy = "WorksheetCopy",
|
|
98
|
+
/** Set cell value permission */
|
|
99
|
+
SetCellValue = "WorksheetSetCellValue",
|
|
100
|
+
/** Set cell style permission */
|
|
101
|
+
SetCellStyle = "WorksheetSetCellStyle",
|
|
102
|
+
/** Set row style permission */
|
|
103
|
+
SetRowStyle = "WorksheetSetRowStyle",
|
|
104
|
+
/** Set column style permission */
|
|
105
|
+
SetColumnStyle = "WorksheetSetColumnStyle",
|
|
106
|
+
/** Insert row permission */
|
|
107
|
+
InsertRow = "WorksheetInsertRow",
|
|
108
|
+
/** Insert column permission */
|
|
109
|
+
InsertColumn = "WorksheetInsertColumn",
|
|
110
|
+
/** Delete row permission */
|
|
111
|
+
DeleteRow = "WorksheetDeleteRow",
|
|
112
|
+
/** Delete column permission */
|
|
113
|
+
DeleteColumn = "WorksheetDeleteColumn",
|
|
114
|
+
/** Sort permission */
|
|
115
|
+
Sort = "WorksheetSort",
|
|
116
|
+
/** Filter permission */
|
|
117
|
+
Filter = "WorksheetFilter",
|
|
118
|
+
/** Pivot table permission */
|
|
119
|
+
PivotTable = "WorksheetPivotTable",
|
|
120
|
+
/** Insert hyperlink permission */
|
|
121
|
+
InsertHyperlink = "WorksheetInsertHyperlink",
|
|
122
|
+
/** Edit extra object permission */
|
|
123
|
+
EditExtraObject = "WorksheetEditExtraObject",
|
|
124
|
+
/** Manage collaborators permission */
|
|
125
|
+
ManageCollaborator = "WorksheetManageCollaborator",
|
|
126
|
+
/** Delete protection permission */
|
|
127
|
+
DeleteProtection = "WorksheetDeleteProtection",
|
|
128
|
+
/** Select protected cells permission */
|
|
129
|
+
SelectProtectedCells = "WorksheetSelectProtectedCells",
|
|
130
|
+
/** Select unprotected cells permission */
|
|
131
|
+
SelectUnProtectedCells = "WorksheetSelectUnProtectedCells"
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Range-level permission point enumeration
|
|
135
|
+
*/
|
|
136
|
+
export declare enum RangePermissionPoint {
|
|
137
|
+
/** Edit permission */
|
|
138
|
+
Edit = "RangeEdit",
|
|
139
|
+
/** View permission */
|
|
140
|
+
View = "RangeView",
|
|
141
|
+
ManageCollaborator = "RangeManageCollaborator",
|
|
142
|
+
Delete = "RangeDeleteProtection"
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Workbook permission mode
|
|
146
|
+
*/
|
|
147
|
+
export type WorkbookMode = 'owner' | 'editor' | 'viewer' | 'commenter';
|
|
148
|
+
/**
|
|
149
|
+
* Worksheet permission mode
|
|
150
|
+
*/
|
|
151
|
+
export type WorksheetMode = 'editable' | 'readOnly' | 'filterOnly';
|
|
152
|
+
/**
|
|
153
|
+
* Workbook permission snapshot (state of all permission points)
|
|
154
|
+
*/
|
|
155
|
+
export type WorkbookPermissionSnapshot = Record<WorkbookPermissionPoint, boolean>;
|
|
156
|
+
/**
|
|
157
|
+
* Worksheet permission snapshot (state of all permission points)
|
|
158
|
+
*/
|
|
159
|
+
export type WorksheetPermissionSnapshot = Record<WorksheetPermissionPoint, boolean>;
|
|
160
|
+
/**
|
|
161
|
+
* Range permission snapshot (state of all permission points)
|
|
162
|
+
*/
|
|
163
|
+
export type RangePermissionSnapshot = Record<RangePermissionPoint, boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* Unsubscribe function type
|
|
166
|
+
*/
|
|
167
|
+
export type UnsubscribeFn = () => void;
|
|
168
|
+
/**
|
|
169
|
+
* ========================
|
|
170
|
+
* Range Protection Configuration and Rules
|
|
171
|
+
* ========================
|
|
172
|
+
*/
|
|
173
|
+
/**
|
|
174
|
+
* Range protection options configuration
|
|
175
|
+
*/
|
|
176
|
+
export interface IRangeProtectionOptions {
|
|
177
|
+
/** Whether to allow current user to edit (default false = protected, not editable) */
|
|
178
|
+
allowEdit?: boolean;
|
|
179
|
+
/** Whitelist of users allowed to edit; empty means determined by role or global policy */
|
|
180
|
+
allowedUsers?: string[];
|
|
181
|
+
allowViewByOthers?: boolean;
|
|
182
|
+
/** Rule name for UI display and management */
|
|
183
|
+
name?: string;
|
|
184
|
+
/** Custom metadata (logs, tags, etc.) */
|
|
185
|
+
metadata?: Record<string, unknown>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Range protection rule Facade
|
|
189
|
+
* Encapsulates internal permissionId / ruleId
|
|
190
|
+
*/
|
|
191
|
+
export interface IRangeProtectionRule {
|
|
192
|
+
/** Internal rule id, for debugging/logging, generally not directly used by callers */
|
|
193
|
+
readonly id: string;
|
|
194
|
+
/** List of ranges covered by this rule */
|
|
195
|
+
readonly ranges: FRange[];
|
|
196
|
+
/** Current rule configuration */
|
|
197
|
+
readonly options: IRangeProtectionOptions;
|
|
198
|
+
/** Update protected ranges */
|
|
199
|
+
updateRanges(ranges: FRange[]): Promise<void>;
|
|
200
|
+
/** Partially update configuration */
|
|
201
|
+
updateOptions(options: Partial<IRangeProtectionOptions>): Promise<void>;
|
|
202
|
+
/** Delete current protection rule */
|
|
203
|
+
remove(): Promise<void>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Cell permission debug rule information
|
|
207
|
+
*/
|
|
208
|
+
export interface ICellPermissionDebugRuleInfo {
|
|
209
|
+
ruleId: string;
|
|
210
|
+
/** Range reference string list, e.g., ['A1:B10', 'D1:D5'] */
|
|
211
|
+
rangeRefs: string[];
|
|
212
|
+
options: IRangeProtectionOptions;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Cell permission debug information
|
|
216
|
+
*/
|
|
217
|
+
export interface ICellPermissionDebugInfo {
|
|
218
|
+
row: number;
|
|
219
|
+
col: number;
|
|
220
|
+
/** List of protection rules that apply */
|
|
221
|
+
hitRules: ICellPermissionDebugRuleInfo[];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* ========================
|
|
225
|
+
* Facade: WorkbookPermission
|
|
226
|
+
* ========================
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* Workbook-level permission Facade interface
|
|
230
|
+
*/
|
|
231
|
+
export interface IWorkbookPermission {
|
|
232
|
+
/**
|
|
233
|
+
* High-level mode setting: By Owner / Editor / Viewer / Commenter semantics
|
|
234
|
+
* Internally automatically combines multiple WorkbookPermissionPoints
|
|
235
|
+
*/
|
|
236
|
+
setMode(mode: WorkbookMode): Promise<void>;
|
|
237
|
+
/** Shortcut: Set workbook to read-only (equivalent to setMode('viewer')) */
|
|
238
|
+
setReadOnly(): Promise<void>;
|
|
239
|
+
/** Shortcut: Set workbook to editable (equivalent to setMode('editor') or owner subset) */
|
|
240
|
+
setEditable(): Promise<void>;
|
|
241
|
+
/** Whether current user can edit this workbook (calculated from combined permissions) */
|
|
242
|
+
canEdit(): boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Collaborator management (wraps IAuthzIoService)
|
|
245
|
+
*/
|
|
246
|
+
/** Batch set collaborators (replace mode, overwrites existing collaborator list) */
|
|
247
|
+
setCollaborators(collaborators: Array<{
|
|
248
|
+
user: IUser;
|
|
249
|
+
role: UnitRole;
|
|
250
|
+
}>): Promise<void>;
|
|
251
|
+
/** Add a single collaborator */
|
|
252
|
+
addCollaborator(user: IUser, role: UnitRole): Promise<void>;
|
|
253
|
+
/** Update collaborator role and information */
|
|
254
|
+
updateCollaborator(user: IUser, role: UnitRole): Promise<void>;
|
|
255
|
+
/** Remove collaborator */
|
|
256
|
+
removeCollaborator(userId: string): Promise<void>;
|
|
257
|
+
/** Batch remove collaborators */
|
|
258
|
+
removeCollaborators(userIds: string[]): Promise<void>;
|
|
259
|
+
/** List all collaborators */
|
|
260
|
+
listCollaborators(): Promise<ICollaborator[]>;
|
|
261
|
+
/**
|
|
262
|
+
* Low-level point operations: Directly set boolean value of a WorkbookPermissionPoint
|
|
263
|
+
*/
|
|
264
|
+
setPoint(point: WorkbookPermissionPoint, value: boolean): Promise<void>;
|
|
265
|
+
/** Read current value of a point (synchronous, reads from local state) */
|
|
266
|
+
getPoint(point: WorkbookPermissionPoint): boolean;
|
|
267
|
+
/** Get snapshot of all current points */
|
|
268
|
+
getSnapshot(): WorkbookPermissionSnapshot;
|
|
269
|
+
/**
|
|
270
|
+
* ========================
|
|
271
|
+
* RxJS Observable Reactive Interface
|
|
272
|
+
* ========================
|
|
273
|
+
*/
|
|
274
|
+
/**
|
|
275
|
+
* Permission snapshot change stream (BehaviorSubject, immediately provides current state on subscription)
|
|
276
|
+
* Triggers when any permission point changes
|
|
277
|
+
*/
|
|
278
|
+
readonly permission$: Observable<WorkbookPermissionSnapshot>;
|
|
279
|
+
/**
|
|
280
|
+
* Single permission point change stream
|
|
281
|
+
* For scenarios that only care about specific permission point changes
|
|
282
|
+
*/
|
|
283
|
+
readonly pointChange$: Observable<{
|
|
284
|
+
point: WorkbookPermissionPoint;
|
|
285
|
+
value: boolean;
|
|
286
|
+
oldValue: boolean;
|
|
287
|
+
}>;
|
|
288
|
+
/**
|
|
289
|
+
* Collaborator change stream
|
|
290
|
+
*/
|
|
291
|
+
readonly collaboratorChange$: Observable<{
|
|
292
|
+
type: 'add' | 'update' | 'delete';
|
|
293
|
+
collaborator: ICollaborator;
|
|
294
|
+
}>;
|
|
295
|
+
/**
|
|
296
|
+
* Compatibility method: Simplified subscription (for users unfamiliar with RxJS)
|
|
297
|
+
* Internally implemented based on permission$ Observable
|
|
298
|
+
*/
|
|
299
|
+
subscribe(listener: (snapshot: WorkbookPermissionSnapshot) => void): UnsubscribeFn;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* ========================
|
|
303
|
+
* Facade: WorksheetPermission
|
|
304
|
+
* ========================
|
|
305
|
+
*/
|
|
306
|
+
/**
|
|
307
|
+
* Worksheet permission configuration
|
|
308
|
+
*/
|
|
309
|
+
export interface IWorksheetPermissionConfig {
|
|
310
|
+
/** One-time mode setting */
|
|
311
|
+
mode?: WorksheetMode;
|
|
312
|
+
/** Point-level configuration patch */
|
|
313
|
+
points?: Partial<Record<WorksheetPermissionPoint, boolean>>;
|
|
314
|
+
/** Batch range protection configuration (optional, for simplified scenarios) */
|
|
315
|
+
rangeProtections?: Array<{
|
|
316
|
+
rangeRefs: string[];
|
|
317
|
+
options?: IRangeProtectionOptions;
|
|
318
|
+
}>;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Worksheet-level permission Facade interface
|
|
322
|
+
*/
|
|
323
|
+
export interface IWorksheetPermission {
|
|
324
|
+
/**
|
|
325
|
+
* Set worksheet overall mode:
|
|
326
|
+
* - 'readOnly' → Lock write-related points
|
|
327
|
+
* - 'filterOnly' → Only enable Filter/Sort, close other write-related points
|
|
328
|
+
* - 'commentOnly' → Close write, keep comment
|
|
329
|
+
* - 'editable' → Most write-related points enabled
|
|
330
|
+
*/
|
|
331
|
+
setMode(mode: WorksheetMode): Promise<void>;
|
|
332
|
+
/** Shortcut: Read-only */
|
|
333
|
+
setReadOnly(): Promise<void>;
|
|
334
|
+
/** Shortcut: Editable */
|
|
335
|
+
setEditable(): Promise<void>;
|
|
336
|
+
/** Whether current user can "overall" edit this sheet (not considering local range protection) */
|
|
337
|
+
canEdit(): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Cell-level high-level check (combines sheet-level & range-level rules)
|
|
340
|
+
*/
|
|
341
|
+
canEditCell(row: number, col: number): boolean;
|
|
342
|
+
canViewCell(row: number, col: number): boolean;
|
|
343
|
+
/**
|
|
344
|
+
* Debug use: View protection rule information for a specific cell
|
|
345
|
+
*/
|
|
346
|
+
debugCellPermission(row: number, col: number): ICellPermissionDebugInfo | null;
|
|
347
|
+
/**
|
|
348
|
+
* Point operations (low-level)
|
|
349
|
+
*/
|
|
350
|
+
setPoint(point: WorksheetPermissionPoint, value: boolean): Promise<void>;
|
|
351
|
+
getPoint(point: WorksheetPermissionPoint): boolean;
|
|
352
|
+
getSnapshot(): WorksheetPermissionSnapshot;
|
|
353
|
+
/**
|
|
354
|
+
* Batch apply permission configuration (for "configuration-driven" scenarios)
|
|
355
|
+
* Internally uses Command to ensure undo/redo
|
|
356
|
+
*/
|
|
357
|
+
applyConfig(config: IWorksheetPermissionConfig): Promise<void>;
|
|
358
|
+
/**
|
|
359
|
+
* Range protection management
|
|
360
|
+
*/
|
|
361
|
+
/** Batch create multiple range protection rules (one-time operation, better performance) */
|
|
362
|
+
protectRanges(configs: Array<{
|
|
363
|
+
ranges: FRange[];
|
|
364
|
+
options?: IRangeProtectionOptions;
|
|
365
|
+
}>): Promise<IRangeProtectionRule[]>;
|
|
366
|
+
/** Batch delete multiple protection rules */
|
|
367
|
+
unprotectRules(ruleIds: string[]): Promise<void>;
|
|
368
|
+
/**
|
|
369
|
+
* List all range protection rules on current sheet
|
|
370
|
+
*/
|
|
371
|
+
listRangeProtectionRules(): Promise<IRangeProtectionRule[]>;
|
|
372
|
+
/**
|
|
373
|
+
* ========================
|
|
374
|
+
* RxJS Observable Reactive Interface
|
|
375
|
+
* ========================
|
|
376
|
+
*/
|
|
377
|
+
/**
|
|
378
|
+
* Permission snapshot change stream (BehaviorSubject, immediately provides current state on subscription)
|
|
379
|
+
* Triggers when any permission point changes
|
|
380
|
+
*/
|
|
381
|
+
readonly permission$: Observable<WorksheetPermissionSnapshot>;
|
|
382
|
+
/**
|
|
383
|
+
* Single permission point change stream
|
|
384
|
+
* For scenarios that only care about specific permission point changes
|
|
385
|
+
*/
|
|
386
|
+
readonly pointChange$: Observable<{
|
|
387
|
+
point: WorksheetPermissionPoint;
|
|
388
|
+
value: boolean;
|
|
389
|
+
oldValue: boolean;
|
|
390
|
+
}>;
|
|
391
|
+
/**
|
|
392
|
+
* Range protection rule change stream (add, delete, update)
|
|
393
|
+
*/
|
|
394
|
+
readonly rangeProtectionChange$: Observable<{
|
|
395
|
+
type: 'add' | 'update' | 'delete';
|
|
396
|
+
rules: IRangeProtectionRule[];
|
|
397
|
+
}>;
|
|
398
|
+
/**
|
|
399
|
+
* Current all range protection rules list stream (BehaviorSubject)
|
|
400
|
+
* Immediately provides current rule list on subscription, auto-updates when rules change
|
|
401
|
+
*/
|
|
402
|
+
readonly rangeProtectionRules$: Observable<IRangeProtectionRule[]>;
|
|
403
|
+
/**
|
|
404
|
+
* Compatibility method: Simplified subscription (for users unfamiliar with RxJS)
|
|
405
|
+
* Internally implemented based on permission$ Observable
|
|
406
|
+
*/
|
|
407
|
+
subscribe(listener: (snapshot: WorksheetPermissionSnapshot) => void): UnsubscribeFn;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* ========================
|
|
411
|
+
* Facade: RangePermission
|
|
412
|
+
* ========================
|
|
413
|
+
*/
|
|
414
|
+
/**
|
|
415
|
+
* Range-level permission Facade interface
|
|
416
|
+
*/
|
|
417
|
+
export interface IRangePermission {
|
|
418
|
+
/**
|
|
419
|
+
* Create protection rule on current range
|
|
420
|
+
* - Default options.allowEdit = false → Treated as "locked"
|
|
421
|
+
*/
|
|
422
|
+
protect(options?: IRangeProtectionOptions): Promise<IRangeProtectionRule>;
|
|
423
|
+
/**
|
|
424
|
+
* Remove all protection rules covered by current range
|
|
425
|
+
* (Internally can calculate range → ruleId mapping)
|
|
426
|
+
*/
|
|
427
|
+
unprotect(): Promise<void>;
|
|
428
|
+
/**
|
|
429
|
+
* Whether current range is in protected state (for current user)
|
|
430
|
+
*/
|
|
431
|
+
isProtected(): boolean;
|
|
432
|
+
/** Whether current user can edit this range (combines Worksheet / Workbook / Range levels) */
|
|
433
|
+
canEdit(): boolean;
|
|
434
|
+
/** Whether current user can view this range */
|
|
435
|
+
canView(): boolean;
|
|
436
|
+
/**
|
|
437
|
+
* Range-level point reading (generally for debugging / advanced scenarios)
|
|
438
|
+
* Usually only need Edit/View two points
|
|
439
|
+
*/
|
|
440
|
+
getPoint(point: RangePermissionPoint): boolean;
|
|
441
|
+
getSnapshot(): RangePermissionSnapshot;
|
|
442
|
+
/**
|
|
443
|
+
* Set a specific permission point for the range (low-level API for local runtime control)
|
|
444
|
+
* @param {RangePermissionPoint} point The permission point to set
|
|
445
|
+
* @param {boolean} value The value to set (true = allowed, false = denied)
|
|
446
|
+
* @returns {Promise<void>} A promise that resolves when the point is set
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
|
|
450
|
+
* const permission = range?.getRangePermission();
|
|
451
|
+
* await permission?.setPoint(RangePermissionPoint.Edit, false); // Disable edit for current user
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
setPoint(point: RangePermissionPoint, value: boolean): Promise<void>;
|
|
455
|
+
/**
|
|
456
|
+
* Get snapshot of all protection rules in current worksheet (can also proxy worksheet interface)
|
|
457
|
+
*/
|
|
458
|
+
listRules(): Promise<IRangeProtectionRule[]>;
|
|
459
|
+
/**
|
|
460
|
+
* ========================
|
|
461
|
+
* RxJS Observable Reactive Interface
|
|
462
|
+
* ========================
|
|
463
|
+
*/
|
|
464
|
+
/**
|
|
465
|
+
* Permission snapshot change stream (BehaviorSubject, immediately provides current state on subscription)
|
|
466
|
+
*/
|
|
467
|
+
readonly permission$: Observable<RangePermissionSnapshot>;
|
|
468
|
+
/**
|
|
469
|
+
* Protection state change stream
|
|
470
|
+
*/
|
|
471
|
+
readonly protectionChange$: Observable<{
|
|
472
|
+
type: 'protected';
|
|
473
|
+
rule: IRangeProtectionRule;
|
|
474
|
+
} | {
|
|
475
|
+
type: 'unprotected';
|
|
476
|
+
ruleId: string;
|
|
477
|
+
}>;
|
|
478
|
+
/**
|
|
479
|
+
* Compatibility method: Simplified subscription (for users unfamiliar with RxJS)
|
|
480
|
+
* Internally implemented based on permission$ Observable
|
|
481
|
+
*/
|
|
482
|
+
subscribe(listener: (snapshot: RangePermissionSnapshot) => void): UnsubscribeFn;
|
|
483
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { AddWorksheetProtectionCommand } from './commands/commands/add-worksheet
|
|
|
29
29
|
export { SetWorksheetRangeThemeStyleCommand } from './commands/commands/add-worksheet-range-theme.command';
|
|
30
30
|
export { AppendRowCommand, type IAppendRowCommandParams } from './commands/commands/append-row.command';
|
|
31
31
|
export { ClearSelectionAllCommand } from './commands/commands/clear-selection-all.command';
|
|
32
|
-
export { ClearSelectionContentCommand } from './commands/commands/clear-selection-content.command';
|
|
32
|
+
export { ClearSelectionContentCommand, type IClearSelectionContentCommandParams } from './commands/commands/clear-selection-content.command';
|
|
33
33
|
export { ClearSelectionFormatCommand } from './commands/commands/clear-selection-format.command';
|
|
34
34
|
export { CopySheetCommand } from './commands/commands/copy-worksheet.command';
|
|
35
35
|
export type { ICopySheetCommandParams } from './commands/commands/copy-worksheet.command';
|