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 some commands that did not pass the ranges to the permissionCheckWithRanges method (#6125)
wpxp1234566840b39f0a81
diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.tsindex 8732d796c0..c4cbdfcd2a 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.permission.controller.ts@@ -36,11 +36,12 @@ export class ConditionalFormattingPermissionController extends Disposable {this.disposeWithMe(this._commandService.beforeCommandExecuted((command: ICommandInfo) => {if (command.id === AddCfCommand.id) {+ const { unitId, subUnitId, rule: { ranges } } = command.params as IAddCfCommandParams;const permission = this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes: [WorkbookEditablePermission],rangeTypes: [RangeProtectionPermissionEditPoint],worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission],- }, (command.params as IAddCfCommandParams).rule.ranges);+ }, ranges, unitId, subUnitId);if (!permission) {this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t('permission.dialog.setStyleErr'));}diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.tsindex 847d29cd44..a0f31f0421 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-permission.controller.ts@@ -15,7 +15,7 @@*/import type { ICommandInfo } from '@univerjs/core';-import type { IUpdateSheetDataValidationRangeCommandParams } from '@univerjs/sheets-data-validation';+import type { IAddSheetDataValidationCommandParams, IUpdateSheetDataValidationRangeCommandParams } from '@univerjs/sheets-data-validation';import { Disposable, ICommandService, Inject, LocaleService } from '@univerjs/core';import { RangeProtectionPermissionEditPoint, SheetPermissionCheckController, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission } from '@univerjs/sheets';import { AddSheetDataValidationCommand, UpdateSheetDataValidationRangeCommand } from '@univerjs/sheets-data-validation';@@ -34,21 +34,23 @@ export class DataValidationPermissionController extends Disposable {this.disposeWithMe(this._commandService.beforeCommandExecuted((command: ICommandInfo) => {if (command.id === AddSheetDataValidationCommand.id) {+ const { unitId, subUnitId, rule: { ranges } } = command.params as IAddSheetDataValidationCommandParams;const permission = this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes: [WorkbookEditablePermission],rangeTypes: [RangeProtectionPermissionEditPoint],worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission],- });+ }, ranges, unitId, subUnitId);if (!permission) {this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t('permission.dialog.setStyleErr'));}}if (command.id === UpdateSheetDataValidationRangeCommand.id) {+ const { unitId, subUnitId, ranges } = command.params as IUpdateSheetDataValidationRangeCommandParams;const permission = this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes: [WorkbookEditablePermission],rangeTypes: [RangeProtectionPermissionEditPoint],worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission],- }, (command.params as IUpdateSheetDataValidationRangeCommandParams).ranges);+ }, ranges, unitId, subUnitId);if (!permission) {this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t('permission.dialog.setStyleErr'));}diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.tsindex a026d9a8bb..24d17aff6c 100644--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-permission.controller.ts@@ -62,7 +62,7 @@ export class SheetsFilterPermissionController extends Disposable {permission = this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes: [RangeProtectionPermissionViewPoint],worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission],- }, [filterRange]);+ }, [filterRange], unitId, subUnitId);} else {const range = this._sheetsSelectionService.getCurrentLastSelection()?.range;if (range) {@@ -96,7 +96,7 @@ export class SheetsFilterPermissionController extends Disposable {const permission = this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes: [RangeProtectionPermissionViewPoint],worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission],- }, [colRange]);+ }, [colRange], unitId, subUnitId);if (!permission) {this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t('permission.dialog.filterErr'));}diff --git a/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/popup.controller.tsindex 67c4d08e11..b1e07e1e9c 100644--- a/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/popup.controller.ts@@ -80,13 +80,13 @@ export class SheetsHyperLinkPopupController extends Disposable {workbookTypes: [WorkbookViewPermission],worksheetTypes: [WorksheetViewPermission],rangeTypes: [RangeProtectionPermissionViewPoint],- }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]);+ }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }], unitId, subUnitId);let editPermission = this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes: [WorkbookEditablePermission],worksheetTypes: [WorksheetEditPermission, WorksheetInsertHyperlinkPermission],rangeTypes: [RangeProtectionPermissionEditPoint],- }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }]);+ }, [{ startRow: currentRow, startColumn: currentCol, endRow: currentRow, endColumn: currentCol }], unitId, subUnitId);// Check if the cell is a hyperlink formula, if it is, we don't allow editingconst cell = worksheet.getCellRaw(currentRow, currentCol);diff --git a/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-hover.controller.ts b/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-hover.controller.tsindex f3802c345d..73e4f6d1cf 100644--- a/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-hover.controller.ts+++ b/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-hover.controller.ts@@ -47,7 +47,7 @@ export class SheetsThreadCommentHoverController extends Disposable {workbookTypes: [WorkbookCommentPermission],worksheetTypes: [WorksheetViewPermission],rangeTypes: [RangeProtectionPermissionViewPoint],- }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]);+ }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }], unitId, subUnitId);if (!commentPermission) {return;}diff --git a/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-popup.controller.ts b/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-popup.controller.tsindex 2e082307e7..23731d322b 100644--- a/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-popup.controller.ts+++ b/packages/sheets-thread-comment-ui/src/controllers/sheets-thread-comment-popup.controller.ts@@ -175,7 +175,7 @@ export class SheetsThreadCommentPopupController extends Disposable {workbookTypes: [WorkbookCommentPermission],worksheetTypes: [WorksheetViewPermission],rangeTypes: [RangeProtectionPermissionViewPoint],- }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }]);+ }, [{ startRow: row, startColumn: col, endRow: row, endColumn: col }], unitId, subUnitId);if (!commentPermission) {return;diff --git a/packages/sheets/src/commands/commands/clear-selection-content.command.ts b/packages/sheets/src/commands/commands/clear-selection-content.command.tsindex 048266f28a..ce82bd5ec5 100644--- a/packages/sheets/src/commands/commands/clear-selection-content.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-content.command.ts@@ -30,7 +30,7 @@ import { SheetsSelectionsService } from '../../services/selections/selection.serimport { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';-interface IClearSelectionContentCommandParams {+export interface IClearSelectionContentCommandParams {unitId?: string;subUnitId?: string;ranges?: IRange[];diff --git a/packages/sheets/src/controllers/permission/sheet-permission-check.controller.ts b/packages/sheets/src/controllers/permission/sheet-permission-check.controller.tsindex a417ca11e3..077e459316 100644--- a/packages/sheets/src/controllers/permission/sheet-permission-check.controller.ts+++ b/packages/sheets/src/controllers/permission/sheet-permission-check.controller.ts@@ -15,6 +15,7 @@*/import type { ICellData, ICellDataForSheetInterceptor, ICommandInfo, IObjectMatrixPrimitiveType, IPermissionTypes, IRange, Nullable, Workbook, WorkbookPermissionPointConstructor, Worksheet } from '@univerjs/core';+import type { IClearSelectionContentCommandParams } from '../../commands/commands/clear-selection-content.command';import type { IMoveRangeCommandParams } from '../../commands/commands/move-range.command';import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../../commands/commands/move-rows-cols.command';import type { ISetSpecificColsVisibleCommandParams } from '../../commands/commands/set-col-visible.command';@@ -100,11 +101,16 @@ export class SheetPermissionCheckController extends Disposable {break;case ClearSelectionContentCommand.id:- permission = this.permissionCheckWithRanges({- workbookTypes: [WorkbookEditablePermission],- rangeTypes: [RangeProtectionPermissionEditPoint],- worksheetTypes: [WorksheetSetCellValuePermission, WorksheetEditPermission],- });+ permission = this.permissionCheckWithRanges(+ {+ workbookTypes: [WorkbookEditablePermission],+ rangeTypes: [RangeProtectionPermissionEditPoint],+ worksheetTypes: [WorksheetSetCellValuePermission, WorksheetEditPermission],+ },+ (params as IClearSelectionContentCommandParams).ranges,+ (params as IClearSelectionContentCommandParams).unitId,+ (params as IClearSelectionContentCommandParams).subUnitId+ );errorMsg = this._localeService.t('permission.dialog.editErr');break;case DeltaColumnWidthCommand.id:@@ -160,19 +166,29 @@ export class SheetPermissionCheckController extends Disposable {break;case SetSpecificColsVisibleCommand.id:- permission = this.permissionCheckWithRanges({- workbookTypes: [WorkbookEditablePermission],- rangeTypes: [RangeProtectionPermissionEditPoint],- worksheetTypes: [WorksheetEditPermission, WorksheetSetColumnStylePermission],- }, (params as ISetSpecificColsVisibleCommandParams).ranges);+ permission = this.permissionCheckWithRanges(+ {+ workbookTypes: [WorkbookEditablePermission],+ rangeTypes: [RangeProtectionPermissionEditPoint],+ worksheetTypes: [WorksheetEditPermission, WorksheetSetColumnStylePermission],+ },+ (params as ISetSpecificColsVisibleCommandParams).ranges,+ (params as ISetSpecificColsVisibleCommandParams).unitId,+ (params as ISetSpecificColsVisibleCommandParams).subUnitId+ );errorMsg = this._localeService.t('permission.dialog.setRowColStyleErr');break;case SetSpecificRowsVisibleCommand.id:- permission = this.permissionCheckWithRanges({- workbookTypes: [WorkbookEditablePermission],- rangeTypes: [RangeProtectionPermissionEditPoint],- worksheetTypes: [WorksheetEditPermission, WorksheetSetRowStylePermission],- }, (params as ISetSpecificRowsVisibleCommandParams).ranges);+ permission = this.permissionCheckWithRanges(+ {+ workbookTypes: [WorkbookEditablePermission],+ rangeTypes: [RangeProtectionPermissionEditPoint],+ worksheetTypes: [WorksheetEditPermission, WorksheetSetRowStylePermission],+ },+ (params as ISetSpecificRowsVisibleCommandParams).ranges,+ (params as ISetSpecificRowsVisibleCommandParams).unitId,+ (params as ISetSpecificRowsVisibleCommandParams).subUnitId+ );errorMsg = this._localeService.t('permission.dialog.setRowColStyleErr');break;case SetSelectedColsVisibleCommand.id:diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex 294e91161f..2cc406611b 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -67,7 +67,7 @@ export { AddWorksheetProtectionCommand } from './commands/commands/add-worksheetexport { SetWorksheetRangeThemeStyleCommand } from './commands/commands/add-worksheet-range-theme.command';export { AppendRowCommand, type IAppendRowCommandParams } from './commands/commands/append-row.command';export { ClearSelectionAllCommand } from './commands/commands/clear-selection-all.command';-export { ClearSelectionContentCommand } from './commands/commands/clear-selection-content.command';+export { ClearSelectionContentCommand, type IClearSelectionContentCommandParams } from './commands/commands/clear-selection-content.command';export { ClearSelectionFormatCommand } from './commands/commands/clear-selection-format.command';export { CopySheetCommand } from './commands/commands/copy-worksheet.command';export type { ICopySheetCommandParams } from './commands/commands/copy-worksheet.command';