/** * Copyright 2023-present DreamNum Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { FRange } from '../f-range'; import type { FWorksheet } from '../f-worksheet'; import type { IRangeProtectionOptions } from './permission-types'; import { IAuthzIoService, ICommandService, Injector } from '@univerjs/core'; import { FBase } from '@univerjs/core/facade'; import { RangeProtectionRuleModel } from '@univerjs/sheets'; import { FRangeProtectionRule } from './f-range-protection-rule'; /** * Implementation class for RangePermission * Manages range-level permissions * * @hideconstructor */ export declare class FRangePermission extends FBase { private readonly _unitId; private readonly _subUnitId; private readonly _range; private readonly _worksheet; private readonly _injector; private readonly _authzIoService; private readonly _commandService; private readonly _rangeProtectionRuleModel; constructor(_unitId: string, _subUnitId: string, _range: FRange, _worksheet: FWorksheet, _injector: Injector, _authzIoService: IAuthzIoService, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel); /** * Check if the current range is protected. * @returns {boolean} True if the range is protected, false otherwise. * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * const fRange = fWorksheet.getRange('A1:B2'); * // Check if the A1:B2 range is protected * const isProtected = fRange.getRangePermission().isProtected(); * console.log(isProtected); * ``` */ isProtected(): boolean; /** * Protect the current range. * @param {IRangeProtectionOptions} options Protection options. * @returns {Promise} The created protection rule. * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * const fRange = fWorksheet.getRange('A1:B2'); * const rule = await fRange.getRangePermission().protect({ * name: 'My protected range', * allowedUsers: ['user1', 'user2'], * allowViewByOthers: false, * }); * console.log(rule); * ``` */ protect(options?: IRangeProtectionOptions): Promise; /** * Cancel all protection rules that intersect with the current range. * @returns {Promise} True if all rules were successfully removed, false otherwise. * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * const fRange = fWorksheet.getRange('A1:B2'); * const result = await fRange.getRangePermission().unprotect(); * console.log(result); * ``` */ unprotect(): Promise; /** * List all protection rules that intersect with the current range. * @returns {Promise} Array of protection rules. * @example * ```ts * const fWorkbook = univerAPI.getActiveWorkbook(); * const fWorksheet = fWorkbook.getActiveSheet(); * const fRange = fWorksheet.getRange('A1:B2'); * const rules = await fRange.getRangePermission().listRules(); * console.log(rules); * ``` */ listRules(options?: { ignoreCollaborators?: boolean; }): Promise; }