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
fix: fix dv custom cell permission (#3559)
ybzkyd1964fc8c473
diff --git a/packages/sheets-ui/src/controllers/cell-custom-render.controller.ts b/packages/sheets-ui/src/controllers/cell-custom-render.controller.tsindex c7d4150799..f801aaf93d 100644--- a/packages/sheets-ui/src/controllers/cell-custom-render.controller.ts+++ b/packages/sheets-ui/src/controllers/cell-custom-render.controller.ts@@ -14,10 +14,12 @@* limitations under the License.*/-import { Disposable, DisposableCollection, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, sortRules } from '@univerjs/core';+import { Disposable, DisposableCollection, Inject, IPermissionService, IUniverInstanceService, LifecycleStages, OnLifecycle, sortRules } from '@univerjs/core';import { IRenderManagerService, Vector2 } from '@univerjs/engine-render';-import type { ICellCustomRender, ICellRenderContext, Nullable, UniverInstanceService, Workbook } from '@univerjs/core';+import { UnitAction, WorkbookEditablePermission, WorksheetEditPermission } from '@univerjs/sheets';+import type { ICellCustomRender, ICellDataForSheetInterceptor, ICellRenderContext, Nullable, UniverInstanceService, Workbook } from '@univerjs/core';import type { IMouseEvent, IPointerEvent, IRenderContext, IRenderModule, RenderManagerService, Spreadsheet } from '@univerjs/engine-render';+import type { ICellPermission } from '@univerjs/sheets';import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';import type { ISheetSkeletonManagerParam } from '../services/sheet-skeleton-manager.service';@@ -32,7 +34,8 @@ export class CellCustomRenderController extends Disposable implements IRenderModprivate readonly _context: IRenderContext<Workbook>,@Inject(SheetSkeletonManagerService) private readonly _sheetSkeletonManagerService: SheetSkeletonManagerService,@IRenderManagerService private readonly _renderManagerService: RenderManagerService,- @IUniverInstanceService private readonly _univerInstanceService: UniverInstanceService+ @IUniverInstanceService private readonly _univerInstanceService: UniverInstanceService,+ @IPermissionService private readonly _permissionService: IPermissionService) {super();this._initEventBinding();@@ -143,6 +146,20 @@ export class CellCustomRenderController extends Disposable implements IRenderModconst activeRenderInfo = getActiveRender(evt);if (activeRenderInfo) {const [activeRender, cellContext] = activeRenderInfo;+ const { row, col, worksheet, unitId, subUnitId } = cellContext;+ const sheetEditable = this._permissionService.composePermission(+ [new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]+ )?.every((permission) => permission.value);++ if (!sheetEditable) {+ return false;+ }++ const permission = (worksheet.getCell(row, col) as (ICellDataForSheetInterceptor & { selectionProtection: ICellPermission[] }))?.selectionProtection?.[0];+ if (permission?.[UnitAction.Edit] === false) {+ return false;+ }+activeRender.onPointerDown?.(cellContext, evt);}});diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex f34d4eb887..1cc872c823 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -142,7 +142,7 @@ export {WorksheetSortPermission,WorksheetViewPermission,} from './services/permission/permission-point';-export { UnitObject } from '@univerjs/protocol';+export { UnitAction, UnitObject } from '@univerjs/protocol';export { checkRangesEditablePermission } from './services/permission/util';// range-protection