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.

chore: add ISetWorksheetActivateCommandParams (#6971)

wpxp12345628d7e9a55611
diff --git a/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts b/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts
index 13d56f69a4..2daeabf7f3 100644
--- a/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts
+++ b/packages/sheets-ui/src/controllers/defined-name/defined-name.controller.ts
@@ -15,7 +15,7 @@
*/
import type { Workbook } from '@univerjs/core';
-import type { ISelectionWithStyle } from '@univerjs/sheets';
+import type { ISelectionWithStyle, ISetWorksheetActivateCommandParams } from '@univerjs/sheets';
import { Disposable, ICommandService, Inject, IUniverInstanceService, ThemeService, UniverInstanceType } from '@univerjs/core';
import { deserializeRangeWithSheet, IDefinedNamesService, isReferenceStrings, operatorToken } from '@univerjs/engine-formula';
import { getPrimaryForRange, ScrollToCellOperation, SetWorksheetActivateCommand, SheetsSelectionsService } from '@univerjs/sheets';
@@ -114,7 +114,7 @@ export class SheetsDefinedNameController extends Disposable {
const worksheetCache = workbook.getSheetBySheetName(unitRange.sheetName);
if (worksheetCache && worksheet.getSheetId() !== worksheetCache.getSheetId()) {
worksheet = worksheetCache;
- await this._cmdSrv.executeCommand(SetWorksheetActivateCommand.id, {
+ await this._cmdSrv.executeCommand<ISetWorksheetActivateCommandParams>(SetWorksheetActivateCommand.id, {
subUnitId: worksheet.getSheetId(),
unitId,
});
diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
index 496bd181f0..120a1b2e3d 100644
--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
@@ -31,7 +31,7 @@ import type {
Workbook,
} from '@univerjs/core';
import type { IRichTextEditingMutationParams } from '@univerjs/docs';
-import type { ISetRangeValuesCommandParams, MutationsAffectRange } from '@univerjs/sheets';
+import type { ISetRangeValuesCommandParams, ISetWorksheetActivateCommandParams, MutationsAffectRange } from '@univerjs/sheets';
import type { IUniverSheetsUIConfig } from '../../config/config';
import type { IEditorBridgeServiceVisibleParam } from '../../services/editor-bridge.service';
import {
@@ -557,7 +557,7 @@ export class EditingRenderController extends Disposable {
*/
if (workbookId === unitId && sheetId !== worksheetId) {
// SetWorksheetActivateCommand handler uses Promise
- await this._commandService.executeCommand(SetWorksheetActivateCommand.id, {
+ await this._commandService.executeCommand<ISetWorksheetActivateCommandParams>(SetWorksheetActivateCommand.id, {
subUnitId: sheetId,
unitId,
});
diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx
index a6b2db0940..d22c452093 100644
--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx
+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx
@@ -16,6 +16,10 @@
import type { ICommandInfo, Workbook } from '@univerjs/core';
import type { IDropdownMenuProps } from '@univerjs/design';
+import type {
+ ISetWorksheetActivateCommandParams,
+ ISetWorksheetShowCommandParams,
+} from '@univerjs/sheets';
import type { ReactNode } from 'react';
import { BooleanNumber, DisposableCollection, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { clsx, DropdownMenu } from '@univerjs/design';
@@ -33,7 +37,6 @@ import {
} from '@univerjs/sheets';
import { useDependency, useObservable } from '@univerjs/ui';
import { useCallback, useEffect, useMemo, useState } from 'react';
-
import { ISheetBarService } from '../../../services/sheet-bar/sheet-bar.service';
import { SheetBarButton } from '../sheet-bar-button/SheetBarButton';
@@ -60,13 +63,12 @@ export function SheetBarMenu() {
if (!sheetId || !workbook) return;
if (item.hidden) {
- commandService.executeCommand(SetWorksheetShowCommand.id, {
+ commandService.executeCommand<ISetWorksheetShowCommandParams>(SetWorksheetShowCommand.id, {
unitId: workbook.getUnitId(),
subUnitId: sheetId,
- value: sheetId,
});
} else if (!item.selected) {
- commandService.executeCommand(SetWorksheetActivateCommand.id, {
+ commandService.executeCommand<ISetWorksheetActivateCommandParams>(SetWorksheetActivateCommand.id, {
unitId: workbook.getUnitId(),
subUnitId: sheetId,
});