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.

fix(numfmt): #853 the cell number format is not consistent with the toolbar display (#949)

Gpound.liu9be3dae0be52
diff --git a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts
index 7e139baf3a..97b384dac5 100644
--- a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts
+++ b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts
@@ -437,12 +437,13 @@ export class NumfmtController extends Disposable implements INumfmtController {
}
private _commandExecutedListener() {
+ const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id];
this.disposeWithMe(
toDisposable(
merge(
new Observable<string>((subscribe) => {
const disposable = this._commandService.onCommandExecuted((command) => {
- if (SetNumfmtMutation.id === command.id) {
+ if (commandList.includes(command.id)) {
const params = command.params as ISetNumfmtMutationParams;
subscribe.next(params.unitId);
}
diff --git a/packages/sheets-numfmt/src/menu/menu.ts b/packages/sheets-numfmt/src/menu/menu.ts
index 284ab2d204..022660f5d0 100644
--- a/packages/sheets-numfmt/src/menu/menu.ts
+++ b/packages/sheets-numfmt/src/menu/menu.ts
@@ -16,7 +16,7 @@
import { ICommandService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';
import { AddDigitsSingle, MoreDownSingle, ReduceDigitsSingle, RmbSingle } from '@univerjs/icons';
-import { INumfmtService, SelectionManagerService, SetNumfmtMutation } from '@univerjs/sheets';
+import { INumfmtService, RemoveNumfmtMutation, SelectionManagerService, SetNumfmtMutation } from '@univerjs/sheets';
import type { ComponentManager, IMenuSelectorItem } from '@univerjs/ui';
import { getMenuHiddenObservable, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
import type { IAccessor } from '@wendellhu/redi';
@@ -96,8 +96,9 @@ export const FactoryOtherMenuItem = (componentManager: ComponentManager) => {
merge(
selectionManagerService.selectionMoveEnd$,
new Observable<null>((commandSubscribe) => {
+ const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id];
const disposable = commandService.onCommandExecuted((commandInfo) => {
- if (commandInfo.id === SetNumfmtMutation.id) {
+ if (commandList.includes(commandInfo.id)) {
commandSubscribe.next(null);
}
});