Skip to content

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.

chore: adjust the way to get FPermission (#4281)

ybzkyc3d9e0b061c8
diff --git a/packages/sheets/src/facade/f-univer.ts b/packages/sheets/src/facade/f-univer.ts
index 9e9e9e5b30..2e5ac111be 100644
--- a/packages/sheets/src/facade/f-univer.ts
+++ b/packages/sheets/src/facade/f-univer.ts
@@ -42,7 +42,8 @@ export interface IFUniverSheetsMixin {
getUniverSheet(id: string): FWorkbook | null;
/**
* Get the PermissionInstance.
- *
+ * @deprecated This function is deprecated and will be removed in version 0.6.0.
+ * Please use the function with the same name on the `FWorkbook` instance instead.
* @returns {FPermission} - The PermissionInstance.
*/
getPermission(): FPermission;
diff --git a/packages/sheets/src/facade/f-workbook.ts b/packages/sheets/src/facade/f-workbook.ts
index ceee1d8923..30e7dab3b3 100644
--- a/packages/sheets/src/facade/f-workbook.ts
+++ b/packages/sheets/src/facade/f-workbook.ts
@@ -18,6 +18,7 @@ import type { CommandListener, ICommandInfo, IDisposable, IRange, IWorkbookData,
import type { ISetSelectionsOperationParams, ISheetCommandSharedParams } from '@univerjs/sheets';
import { FBase, ICommandService, ILogService, Inject, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService, LocaleService, mergeWorksheetSnapshotWithDefault, RedoCommand, toDisposable, UndoCommand, UniverInstanceType } from '@univerjs/core';
import { CopySheetCommand, getPrimaryForRange, InsertSheetCommand, RemoveSheetCommand, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetOrderCommand, SheetsSelectionsService, WorkbookEditablePermission } from '@univerjs/sheets';
+import { FPermission } from './f-permission';
import { FRange } from './f-range';
import { FWorksheet } from './f-worksheet';
@@ -615,4 +616,13 @@ export class FWorkbook extends FBase {
const sheet = this.getActiveSheet();
return this.moveSheet(sheet, index);
}
+
+ /**
+ * Get the PermissionInstance.
+ *
+ * @returns {FPermission} - The PermissionInstance.
+ */
+ getPermission() {
+ return this._injector.createInstance(FPermission);
+ }
}