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: no need to modify sheet cell data when cell editor has been input nothing (#619)
Ran Luof4c6533ced3f
diff --git a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/end-edit.controller.tsindex c2714a1227..6f98a929ec 100644--- a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts@@ -154,6 +154,13 @@ export class EndEditController extends Disposable {this._moveCursor(keycode);+ // If neither the formula bar editor nor the cell editor has been edited,+ // it is considered that the content has not changed and returns directly.+ const editorIsDirty = this._editorBridgeService.getEditorDirty();+ if (editorIsDirty === false) {+ return;+ }+const workbook = this._currentUniverService.getUniverSheetInstance(unitId);const worksheet = workbook?.getSheetBySheetId(sheetId);diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.tsindex ae1da4f8d3..e6f70e3432 100644--- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts@@ -567,6 +567,8 @@ export class StartEditController extends Disposable {return;}+ this._editorBridgeService.changeEditorDirty(true);+const skeleton = this._docSkeletonManagerService.getSkeletonByUnitId(unitId)?.skeleton;if (skeleton == null) {diff --git a/packages/sheets-ui/src/services/editor-bridge.service.ts b/packages/sheets-ui/src/services/editor-bridge.service.tsindex f57430d947..172dcfba75 100644--- a/packages/sheets-ui/src/services/editor-bridge.service.ts+++ b/packages/sheets-ui/src/services/editor-bridge.service.ts@@ -40,6 +40,8 @@ export interface IEditorBridgeService {setState(param: IEditorBridgeServiceParam): void;getState(): Readonly<Nullable<IEditorBridgeServiceParam>>;changeVisible(param: IEditorBridgeServiceVisibleParam): void;+ changeEditorDirty(dirtyStatus: boolean): void;+ getEditorDirty(): boolean;isVisible(): IEditorBridgeServiceVisibleParam;enableForceKeepVisible(): void;disableForceKeepVisible(): void;@@ -52,6 +54,8 @@ export class EditorBridgeService extends Disposable implements IEditorBridgeServprivate _isForceKeepVisible: boolean = false;+ private _editorIsDirty: boolean = false;+private _visible: IEditorBridgeServiceVisibleParam = {visible: false,eventType: DeviceInputEventType.Dblclick,@@ -115,6 +119,11 @@ export class EditorBridgeService extends Disposable implements IEditorBridgeServchangeVisible(param: IEditorBridgeServiceVisibleParam) {this._visible = param;+ // Reset the dirty status when the editor is visible.+ if (param.visible) {+ this._editorIsDirty = false;+ }+this._visible$.next(this._visible);this._afterVisible$.next(this._visible);}@@ -134,6 +143,14 @@ export class EditorBridgeService extends Disposable implements IEditorBridgeServisForceKeepVisible(): boolean {return this._isForceKeepVisible;}++ changeEditorDirty(dirtyStatus: boolean) {+ this._editorIsDirty = dirtyStatus;+ }++ getEditorDirty() {+ return this._editorIsDirty;+ }}export const IEditorBridgeService = createIdentifier<EditorBridgeService>('univer.sheet-editor-bridge.service');