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(sheets-ui): add abort editing

Evan889740f7e60b
diff --git a/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts b/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts
index 93d69bf51a..52557d40f3 100644
--- a/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts
+++ b/packages/sheets-ui/src/commands/operations/cell-edit.operation.ts
@@ -53,12 +53,11 @@ export const SetCellEditVisibleWithF2Operation: IOperation<IEditorBridgeServiceV
if (!workbook) {
return false;
}
- commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
+
+ return commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, {
...params,
unitId: workbook.getUnitId(),
});
-
- return true;
},
};
diff --git a/packages/sheets-ui/src/facade/f-workbook.ts b/packages/sheets-ui/src/facade/f-workbook.ts
index e45e9dca5c..5f39ef13b7 100644
--- a/packages/sheets-ui/src/facade/f-workbook.ts
+++ b/packages/sheets-ui/src/facade/f-workbook.ts
@@ -156,6 +156,18 @@ export interface IFWorkbookSheetsUIMixin {
*/
endEditingAsync(save?: boolean): Promise<boolean>;
+ /**
+ * @async
+ * End the editing process of the current active cell
+ * @returns {Promise<boolean>} Whether the editing process is ended successfully
+ * @example
+ * ```ts
+ * const fWorkbook = univerAPI.getActiveWorkbook();
+ * await fWorkbook.endEditingAsync(false);
+ * ```
+ */
+ abortEditingAsync(): Promise<boolean>;
+
/**
* Get scroll state of specified sheet.
* @param {string} sheetId - sheet id
@@ -353,6 +365,10 @@ export class FWorkbookSheetsUIMixin extends FWorkbook implements IFWorkbookSheet
return this.endEditing(save);
}
+ override abortEditingAsync(): Promise<boolean> {
+ return this.endEditingAsync(false);
+ }
+
/**
* Get scroll state of specified sheet.
* @param {string} sheetId - sheet id