Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
chore: add sheet permission facade api (#2604)
ybzky9ca077f462ea
diff --git a/packages/facade/src/apis/sheets/f-workbook.ts b/packages/facade/src/apis/sheets/f-workbook.tsindex 06d2f25ed5..0a435a1cd4 100644--- a/packages/facade/src/apis/sheets/f-workbook.ts+++ b/packages/facade/src/apis/sheets/f-workbook.ts@@ -17,6 +17,7 @@import type { CommandListener, ICommandInfo, IRange, IWorkbookData, Workbook } from '@univerjs/core';import {ICommandService,+ IPermissionService,IResourceLoaderService,IUniverInstanceService,mergeWorksheetSnapshotWithDefault,@@ -28,7 +29,7 @@ import {import type {ISheetCommandSharedParams,} from '@univerjs/sheets';-import { InsertSheetCommand, RemoveSheetCommand, SelectionManagerService, SetWorksheetActiveOperation } from '@univerjs/sheets';+import { InsertSheetCommand, RemoveSheetCommand, SelectionManagerService, SetWorksheetActiveOperation, WorkbookEditablePermission } from '@univerjs/sheets';import type { IDisposable } from '@wendellhu/redi';import { Inject, Injector } from '@wendellhu/redi';@@ -43,7 +44,8 @@ export class FWorkbook {@Inject(IResourceLoaderService) private readonly _resourceLoaderService: IResourceLoaderService,@Inject(SelectionManagerService) private readonly _selectionManagerService: SelectionManagerService,@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,- @ICommandService private readonly _commandService: ICommandService+ @ICommandService private readonly _commandService: ICommandService,+ @IPermissionService private readonly _permissionService: IPermissionService) {this.id = this._workbook.getUnitId();@@ -260,5 +262,18 @@ export class FWorkbook {);}+ /**+ * Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.+ * @param {boolean} value editable value want to set+ */+ setEditable(value: boolean): void {+ const instance = new WorkbookEditablePermission(this._workbook.getUnitId());+ const editPermissionPoint = this._permissionService.getPermissionPoint(instance.id);+ if (!editPermissionPoint) {+ this._permissionService.addPermissionPoint(instance);+ }+ this._permissionService.updatePermissionPoint(instance.id, value);+ }+// #region callbacks}