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
refactor: change add protection params (#2427)
ybzkye8afcfd77175
diff --git a/packages/sheets-ui/src/commands/commands/range-protection.command.ts b/packages/sheets-ui/src/commands/commands/range-protection.command.tsindex 219f328e5f..fdedc56921 100644--- a/packages/sheets-ui/src/commands/commands/range-protection.command.ts+++ b/packages/sheets-ui/src/commands/commands/range-protection.command.ts@@ -358,7 +358,7 @@ export const SetProtectionCommand: ICommand<ISetProtectionParams> = {if (oldRule) {if (oldRule.unitType === UnitObject.Worksheet) {redoMutations.push({ id: DeleteWorksheetProtectionMutation.id, params: { unitId, subUnitId } });- undoMutations.push({ id: AddWorksheetProtectionMutation.id, params: { unitId, rule: oldRule } });+ undoMutations.push({ id: AddWorksheetProtectionMutation.id, params: { unitId, rule: oldRule, subUnitId: oldRule.subUnitId } });} else if (oldRule.unitType === UnitObject.SelectRange) {redoMutations.push({ id: DeleteRangeProtectionMutation.id, params: { unitId, subUnitId, ruleIds: [(oldRule as IRangeProtectionRule).id] } });undoMutations.push({ id: AddRangeProtectionMutation.id, params: { unitId, subUnitId, rules: [oldRule] } });@@ -366,7 +366,7 @@ export const SetProtectionCommand: ICommand<ISetProtectionParams> = {}if (rule.unitType === UnitObject.Worksheet) {- redoMutations.push({ id: AddWorksheetProtectionMutation.id, params: { unitId, rule } });+ redoMutations.push({ id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId: rule.subUnitId } });undoMutations.unshift({ id: DeleteWorksheetProtectionMutation.id, params: { unitId, subUnitId } });} else if (rule.unitType === UnitObject.SelectRange) {(rule as IRangeProtectionRule).id = rangeProtectionRuleModel.createRuleId(unitId, subUnitId);diff --git a/packages/sheets-ui/src/commands/commands/worksheet-protection.command.ts b/packages/sheets-ui/src/commands/commands/worksheet-protection.command.tsindex 5d68abe9f2..74918555da 100644--- a/packages/sheets-ui/src/commands/commands/worksheet-protection.command.ts+++ b/packages/sheets-ui/src/commands/commands/worksheet-protection.command.ts@@ -54,10 +54,11 @@ export const AddWorksheetProtectionCommand: ICommand<IAddWorksheetProtectionParaconst result = await commandService.executeCommand(AddWorksheetProtectionMutation.id, {unitId,rule,+ subUnitId: rule.subUnitId,});if (result) {- const redoMutations = [{ id: AddWorksheetProtectionMutation.id, params: { unitId, rule } }];+ const redoMutations = [{ id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId: rule.subUnitId } }];const undoMutations = [{ id: DeleteWorksheetProtectionMutation.id, params: { unitId, subUnitId } }];undoRedoService.pushUndoRedo({unitID: unitId,@@ -87,7 +88,7 @@ export const DeleteWorksheetProtectionCommand: ICommand<IDeleteWorksheetProtecti});const redoMutations = [{ id: DeleteWorksheetProtectionMutation.id, params: { unitId, subUnitId } }];- const undoMutations = [{ id: AddWorksheetProtectionMutation.id, params: { unitId, rule } }];+ const undoMutations = [{ id: AddWorksheetProtectionMutation.id, params: { unitId, rule, subUnitId: rule.subUnitId } }];undoRedoService.pushUndoRedo({unitID: unitId,redoMutations,diff --git a/packages/sheets/src/commands/mutations/add-worksheet-protection.mutation.ts b/packages/sheets/src/commands/mutations/add-worksheet-protection.mutation.tsindex 420633b335..c1d2286f4d 100644--- a/packages/sheets/src/commands/mutations/add-worksheet-protection.mutation.ts+++ b/packages/sheets/src/commands/mutations/add-worksheet-protection.mutation.ts@@ -21,6 +21,7 @@ import type { IWorksheetProtectionRule } from '../../services/permission/type';export interface IAddWorksheetProtectionParams {unitId: string;+ subUnitId: string;rule: IWorksheetProtectionRule;}diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex dd214fd139..97027720cd 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -375,3 +375,5 @@ export {export { RangeProtectionPermissionEditPoint } from './services/permission/permission-point/range/edit';export { RangeProtectionPermissionViewPoint } from './services/permission/permission-point/range/view';++export type { IAddWorksheetProtectionParams } from './commands/mutations/add-worksheet-protection.mutation';