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.

feat(facade): change data-validation facade api into sync (#3736)

zhangwcbae4c9582be
diff --git a/packages/facade/src/apis/sheets/f-range.ts b/packages/facade/src/apis/sheets/f-range.ts
index 1477dd91d6..e1439533de 100644
--- a/packages/facade/src/apis/sheets/f-range.ts
+++ b/packages/facade/src/apis/sheets/f-range.ts
@@ -668,9 +668,9 @@ export class FRange {
* @param rule data validation rule, build by `FUniver.newDataValidation`
* @returns current range
*/
- async setDataValidation(rule: Nullable<FDataValidation>): Promise<this> {
+ setDataValidation(rule: Nullable<FDataValidation>): this {
if (!rule) {
- this._commandService.executeCommand(ClearRangeDataValidationCommand.id, {
+ this._commandService.syncExecuteCommand(ClearRangeDataValidationCommand.id, {
unitId: this._workbook.getUnitId(),
subUnitId: this._worksheet.getSheetId(),
ranges: [this._range],
@@ -687,7 +687,7 @@ export class FRange {
},
};
- await this._commandService.executeCommand(AddSheetDataValidationCommand.id, params);
+ this._commandService.syncExecuteCommand(AddSheetDataValidationCommand.id, params);
return this;
}
diff --git a/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts b/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts
index a50cedfeb4..c88dcbd6fe 100644
--- a/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts
+++ b/packages/sheets-data-validation-ui/src/commands/commands/data-validation-ui.command.ts
@@ -24,7 +24,7 @@ import { OpenValidationPanelOperation } from '../operations/data-validation.oper
export const AddSheetDataValidationAndOpenCommand: ICommand = {
type: CommandType.COMMAND,
id: 'data-validation.command.addRuleAndOpen',
- async handler(accessor) {
+ handler(accessor) {
const univerInstanceService = accessor.get(IUniverInstanceService);
const target = getSheetCommandTarget(univerInstanceService);
if (!target) return false;
@@ -41,10 +41,10 @@ export const AddSheetDataValidationAndOpenCommand: ICommand = {
subUnitId,
};
- const res = await commandService.executeCommand(AddSheetDataValidationCommand.id, addParams);
+ const res = commandService.syncExecuteCommand(AddSheetDataValidationCommand.id, addParams);
if (res) {
- commandService.executeCommand(OpenValidationPanelOperation.id, {
+ commandService.syncExecuteCommand(OpenValidationPanelOperation.id, {
ruleId: rule.uid,
isAdd: true,
});
diff --git a/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts b/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts
index 066d0e06f9..ee75622ae3 100644
--- a/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts
+++ b/packages/sheets-data-validation/src/commands/commands/data-validation.command.ts
@@ -18,7 +18,7 @@ import type { CellValue, IAccessor, ICellData, ICommand, IDataValidationRuleBase
import type { DataValidationChangeSource, IAddDataValidationMutationParams, IRemoveDataValidationMutationParams, IUpdateDataValidationMutationParams } from '@univerjs/data-validation';
import type { ISetRangeValuesMutationParams, ISheetCommandSharedParams } from '@univerjs/sheets';
import type { RangeMutation } from '../../models/rule-matrix';
-import { CommandType, DataValidationType, ICommandService, IUndoRedoService, IUniverInstanceService, ObjectMatrix, Range, sequenceExecute, sequenceExecuteAsync, Tools } from '@univerjs/core';
+import { CommandType, DataValidationType, ICommandService, IUndoRedoService, IUniverInstanceService, ObjectMatrix, Range, sequenceExecute, Tools } from '@univerjs/core';
import { AddDataValidationMutation, DataValidatorRegistryService, getRuleOptions, getRuleSetting, RemoveDataValidationMutation, UpdateDataValidationMutation, UpdateRuleType } from '@univerjs/data-validation';
import { getSheetCommandTarget, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '@univerjs/sheets';
import { SheetDataValidationModel } from '../../models/sheet-data-validation-model';
@@ -202,7 +202,7 @@ export function getDataValidationDiffMutations(
export const UpdateSheetDataValidationRangeCommand: ICommand<IUpdateSheetDataValidationRangeCommandParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.updateDataValidationRuleRange',
- async handler(accessor, params) {
+ handler(accessor, params) {
if (!params) {
return false;
}
@@ -225,7 +225,7 @@ export const UpdateSheetDataValidationRangeCommand: ICommand<IUpdateSheetDataVal
redoMutations,
unitID: unitId,
});
- await sequenceExecuteAsync(redoMutations, commandService);
+ sequenceExecute(redoMutations, commandService);
return true;
},
};
@@ -239,7 +239,7 @@ export interface IAddSheetDataValidationCommandParams {
export const AddSheetDataValidationCommand: ICommand<IAddSheetDataValidationCommandParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.addDataValidation',
- async handler(accessor, params) {
+ handler(accessor, params) {
if (!params) {
return false;
}
@@ -280,7 +280,7 @@ export const AddSheetDataValidationCommand: ICommand<IAddSheetDataValidationComm
undoMutations,
});
- await sequenceExecuteAsync(redoMutations, commandService);
+ sequenceExecute(redoMutations, commandService);
return true;
},
};