fix(editor): fix the issue where content being edited in a cell would be reset (#6495)

This commit is contained in:
wpxp123456
2026-01-21 14:12:32 +08:00
committed by GitHub
parent 00fe317c0b
commit dc5cf3cf1e
@@ -17,14 +17,13 @@
import type { ICommandInfo, IDisposable, IExecutionOptions, ISelectionCell, Nullable, Workbook } from '@univerjs/core';
import type { IEditorInputConfig } from '@univerjs/docs-ui';
import type { IRender, IRenderContext, IRenderModule } from '@univerjs/engine-render';
import type { ISelectionWithStyle, ISetRangeValuesMutationParams } from '@univerjs/sheets';
import type { ISelectionWithStyle } from '@univerjs/sheets';
import type { ICurrentEditCellParam, IEditorBridgeServiceVisibleParam } from '../../services/editor-bridge.service';
import { DisposableCollection, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHEET, ICommandService, IContextService, Inject, IUniverInstanceService, RxDisposable, toDisposable, UniverInstanceType } from '@univerjs/core';
import { DocSelectionRenderService } from '@univerjs/docs-ui';
import { DeviceInputEventType, IRenderManagerService } from '@univerjs/engine-render';
import {
ClearSelectionFormatCommand,
SetRangeValuesMutation,
SetWorksheetActiveOperation,
SheetsSelectionsService,
} from '@univerjs/sheets';
@@ -206,18 +205,18 @@ export class EditorBridgeRenderController extends RxDisposable implements IRende
this._editorBridgeService.refreshEditCellState();
}
if (command.id === SetRangeValuesMutation.id) {
const params = command.params as ISetRangeValuesMutationParams;
const { cellValue, unitId, subUnitId } = params;
if (!cellValue) return;
const editCell = this._editorBridgeService.getEditLocation();
if (editCell) {
const { unitId: editingUnitId, sheetId: editingSheetId, row, column } = editCell;
if (unitId === editingUnitId && subUnitId === editingSheetId && cellValue && cellValue[row] && Object.prototype.hasOwnProperty.call(cellValue[row], column)) {
this._editorBridgeService.refreshEditCellState();
}
}
}
// if (command.id === SetRangeValuesMutation.id) {
// const params = command.params as ISetRangeValuesMutationParams;
// const { cellValue, unitId, subUnitId } = params;
// if (!cellValue) return;
// const editCell = this._editorBridgeService.getEditLocation();
// if (editCell) {
// const { unitId: editingUnitId, sheetId: editingSheetId, row, column } = editCell;
// if (unitId === editingUnitId && subUnitId === editingSheetId && cellValue && cellValue[row] && Object.prototype.hasOwnProperty.call(cellValue[row], column)) {
// this._editorBridgeService.refreshEditCellState();
// }
// }
// }
}));
d.add(this._commandService.beforeCommandExecuted((command: ICommandInfo, options?: IExecutionOptions) => {