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: clear format failed when not change selections (#2338)
Ran Luo07a4e0fc669c
diff --git a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/start-edit.controller.tsindex 07e20ac1f0..b21f6c4ff4 100644--- a/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/start-edit.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICommandInfo, IDocumentBody, IDocumentData, IPosition, Nullable } from '@univerjs/core';+import type { ICommandInfo, IDocumentBody, IPosition, Nullable } from '@univerjs/core';import {DEFAULT_EMPTY_DOCUMENT_VALUE,Disposable,@@ -60,6 +60,7 @@ import { IEditorService, KeyCode, SetEditorResizeOperation } from '@univerjs/ui'import { Inject } from '@wendellhu/redi';import { filter } from 'rxjs';+import { ClearSelectionFormatCommand } from '@univerjs/sheets';import { getEditorObject } from '../../basics/editor/get-editor-object';import { SetCellEditVisibleOperation } from '../../commands/operations/cell-edit.operation';import { ICellEditorManagerService } from '../../services/editor/cell-editor-manager.service';@@ -520,7 +521,7 @@ export class StartEditController extends Disposable {eventType === DeviceInputEventType.Keyboard ||(eventType === DeviceInputEventType.Dblclick && isInArrayFormulaRange)) {- const snapshot = Tools.deepClone(documentDataModel.getSnapshot()) as IDocumentData;+ const snapshot = Tools.deepClone(documentDataModel.getSnapshot());const documentViewModel = this._docViewModelManagerService.getViewModel(editorUnitId);if (documentViewModel == null) {@@ -677,6 +678,15 @@ export class StartEditController extends Disposable {}}));++ this.disposeWithMe(+ // Use fix https://github.com/dream-num/univer/issues/1231.+ this._commandService.onCommandExecuted((command: ICommandInfo) => {+ if (command.id === ClearSelectionFormatCommand.id) {+ this._editorBridgeService.refreshEditCellState();+ }+ })+ );}private _setOpenForCurrent(unitId: Nullable<string>, sheetId: Nullable<string>) {diff --git a/packages/sheets/src/commands/commands/clear-selection-format.command.ts b/packages/sheets/src/commands/commands/clear-selection-format.command.tsindex 799b6e524c..8e7d092b1e 100644--- a/packages/sheets/src/commands/commands/clear-selection-format.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-format.command.ts@@ -36,7 +36,9 @@ import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mu*/export const ClearSelectionFormatCommand: ICommand = {id: 'sheet.command.clear-selection-format',+type: CommandType.COMMAND,+handler: async (accessor: IAccessor) => {const univerInstanceService = accessor.get(IUniverInstanceService);const commandService = accessor.get(ICommandService);diff --git a/packages/sheets/src/commands/commands/set-range-values.command.ts b/packages/sheets/src/commands/commands/set-range-values.command.tsindex fbdf6893a1..5fbcf088cc 100644--- a/packages/sheets/src/commands/commands/set-range-values.command.ts+++ b/packages/sheets/src/commands/commands/set-range-values.command.ts@@ -52,6 +52,7 @@ export interface ISetRangeValuesCommandParams extends Partial<ISheetCommandShareexport const SetRangeValuesCommand: ICommand = {id: 'sheet.command.set-range-values',type: CommandType.COMMAND,+ // eslint-disable-next-line max-lines-per-functionhandler: (accessor: IAccessor, params: ISetRangeValuesCommandParams) => {const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);diff --git a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/sheets/src/commands/mutations/set-range-values.mutation.tsindex 4cf70ba7f4..6fb80ddc0e 100644--- a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts@@ -155,6 +155,7 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, botype: CommandType.MUTATION,+ // eslint-disable-next-line max-lines-per-functionhandler: (accessor, params) => {const { cellValue, subUnitId, unitId } = params;const univerInstanceService = accessor.get(IUniverInstanceService);@@ -172,6 +173,7 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, boconst styles = workbook.getStyles();const newValues = new ObjectMatrix(cellValue);+ // eslint-disable-next-line complexitynewValues.forValue((row, col, newVal) => {// clear allif (!newVal) {