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
feat(sheet): fix toolbar set tab color & delete sheetbarui controller (#178)
YuHong2b8a62e07dc3
diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsxindex 1b75d54481..f3463eaa1a 100644--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx@@ -396,11 +396,11 @@ export class SheetBar extends Component<BaseSheetBarProps, SheetState> {show={showMenu}style={menuStyle}onOptionSelect={(params) => {- const { label: commandId } = params;+ const { label: commandId, value } = params;const commandService: ICommandService = (this.context as IKeyValue).injector.get(ICommandService);- commandService.executeCommand(commandId as string);+ commandService.executeCommand(commandId as string, { value });}}/>diff --git a/packages/ui-plugin-sheets/src/controller/SheetBarUIController.ts b/packages/ui-plugin-sheets/src/controller/SheetBarUIController.tsdeleted file mode 100644index 0f3cc84326..0000000000--- a/packages/ui-plugin-sheets/src/controller/SheetBarUIController.ts+++ /dev/null@@ -1,89 +0,0 @@-import { BaseComponentProps, ColorPicker, ComponentManager, IMenuItemFactory, IMenuService } from '@univerjs/base-ui';-import { BooleanNumber, Disposable, ICommandService, LifecycleStages, Nullable, OnLifecycle } from '@univerjs/core';-import { Inject, Injector } from '@wendellhu/redi';--import { SHEET_UI_PLUGIN_NAME } from '../Basics/Const';-import { RenameSheetCommand } from '../commands/commands/rename.command';-import { ShowMenuListCommand } from '../commands/commands/unhide.command';-import { SheetBar } from '../View/SheetBar';-import {- ChangeColorSheetMenuItemFactory,- CopySheetMenuItemFactory,- DeleteSheetMenuItemFactory,- HideSheetMenuItemFactory,- RenameSheetMenuItemFactory,- UnHideSheetMenuItemFactory,-} from './menu/menu';--export interface BaseUlProps extends BaseComponentProps {- label?: string | JSX.Element | string[];- /**- * 是否显示 选中图标- */- selected?: boolean;- /**- * 是否显示 隐藏图标- */- hidden?: BooleanNumber;- icon?: JSX.Element | string | null | undefined;- border?: boolean;- children?: BaseUlProps[];- onClick?: (...arg: any[]) => void;- onKeyUp?: (...any: any[]) => void;- onMouseDown?: (...any: any[]) => void;- style?: React.CSSProperties;- showSelect?: (e: MouseEvent) => void;- getParent?: any;- show?: boolean;- className?: string;- selectType?: string;- name?: string;- ref?: any;- locale?: Array<string | object> | string;- /**- * 是否隐藏当前item- */- hideLi?: boolean;-}-export interface SheetUlProps extends BaseUlProps {- index: string;- color?: Nullable<string>;- sheetId: string;-}--@OnLifecycle(LifecycleStages.Ready, SheetBarUIController)-export class SheetBarUIController extends Disposable {- protected _sheetBar: SheetBar;-- constructor(- @Inject(Injector) private readonly _injector: Injector,- @Inject(ComponentManager) private readonly _componentManager: ComponentManager,- @ICommandService private readonly _commandService: ICommandService,- @IMenuService private readonly _menuService: IMenuService- ) {- super();-- this._initializeContextMenu();-- this._componentManager.register(SHEET_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);-- [ShowMenuListCommand, RenameSheetCommand].forEach((command) =>- this.disposeWithMe(this._commandService.registerCommand(command))- );- }-- private _initializeContextMenu() {- (- [- DeleteSheetMenuItemFactory,- CopySheetMenuItemFactory,- RenameSheetMenuItemFactory,- ChangeColorSheetMenuItemFactory,- HideSheetMenuItemFactory,- UnHideSheetMenuItemFactory,- ] as IMenuItemFactory[]- ).forEach((factory) => {- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));- });- }-}diff --git a/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts b/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.tsindex 0b9fe30bd6..557a11905b 100644--- a/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts+++ b/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts@@ -10,6 +10,7 @@ import {SetUnderlineCommand,} from '@univerjs/base-sheets';import {+ ColorPicker,ComponentManager,IDesktopUIController,IMenuItemFactory,@@ -21,6 +22,9 @@ import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univimport { Inject, Injector } from '@wendellhu/redi';import { connectInjector } from '@wendellhu/redi/react-bindings';+import { SHEET_UI_PLUGIN_NAME } from '../Basics';+import { RenameSheetCommand } from '../commands/commands/rename.command';+import { ShowMenuListCommand } from '../commands/commands/unhide.command';import { QuitCellEditorCommand } from '../services/cell-editor/cell-editor.command';import { RightMenuInput } from '../View/RightMenu/RightMenuInput';import { RightMenuItem } from '../View/RightMenu/RightMenuItem';@@ -29,14 +33,18 @@ import { CellBorderSelectorMenuItemFactory } from './menu/border.menu';import {BackgroundColorSelectorMenuItemFactory,BoldMenuItemFactory,+ ChangeColorSheetMenuItemFactory,ClearSelectionMenuItemFactory,CONTEXT_MENU_INPUT_LABEL,CopyMenuItemFactory,+ CopySheetMenuItemFactory,DeleteRangeMenuItemFactory,DeleteRangeMoveLeftMenuItemFactory,DeleteRangeMoveUpMenuItemFactory,+ DeleteSheetMenuItemFactory,FontFamilySelectorMenuItemFactory,FontSizeSelectorMenuItemFactory,+ HideSheetMenuItemFactory,HorizontalAlignMenuItemFactory,InsertColMenuItemFactory,InsertRowMenuItemFactory,@@ -45,6 +53,7 @@ import {RedoMenuItemFactory,RemoveColMenuItemFactory,RemoveRowMenuItemFactory,+ RenameSheetMenuItemFactory,ResetBackgroundColorMenuItemFactory,ResetTextColorMenuItemFactory,SetBorderColorMenuItemFactory,@@ -56,6 +65,7 @@ import {TextRotateMenuItemFactory,UnderlineMenuItemFactory,UndoMenuItemFactory,+ UnHideSheetMenuItemFactory,VerticalAlignMenuItemFactory,WrapTextMenuItemFactory,} from './menu/menu';@@ -66,7 +76,6 @@ import {CellMergeMenuItemFactory,CellMergeVerticalMenuItemFactory,} from './menu/merge.menu';-import { SheetBarUIController } from './SheetBarUIController';import { QuitCellEditorShortcutItem } from './shortcuts/editor.shortcut';import {ExpandSelectionDownShortcutItem,@@ -98,8 +107,6 @@ import { ClearSelectionValueShortcutItem } from './shortcuts/value.shortcut';@OnLifecycle(LifecycleStages.Ready, SheetUIController)export class SheetUIController extends Disposable {- private _sheetBarUIController: SheetBarUIController;-constructor(@Inject(Injector) private readonly _injector: Injector,@Inject(ComponentManager) private readonly _componentManager: ComponentManager,@@ -110,9 +117,6 @@ export class SheetUIController extends Disposable {) {super();- this._sheetBarUIController = this._injector.createInstance(SheetBarUIController);- this._injector.add([SheetBarUIController, { useFactory: () => this._sheetBarUIController }]);-this._initialize();this._initUI();}@@ -124,6 +128,7 @@ export class SheetUIController extends Disposable {// FIXME: no dispose logiccomponentManager.register(CONTEXT_MENU_INPUT_LABEL, RightMenuInput);componentManager.register(RightMenuItem.name, RightMenuItem);+ componentManager.register(SHEET_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);// init commands[@@ -138,6 +143,9 @@ export class SheetUIController extends Disposable {SetFontSizeCommand,QuitCellEditorCommand,++ ShowMenuListCommand,+ RenameSheetCommand,].forEach((c) => {this.disposeWithMe(this._commandService.registerCommand(c));});@@ -185,6 +193,14 @@ export class SheetUIController extends Disposable {VerticalAlignMenuItemFactory,WrapTextMenuItemFactory,TextRotateMenuItemFactory,++ // sheetbar+ DeleteSheetMenuItemFactory,+ CopySheetMenuItemFactory,+ RenameSheetMenuItemFactory,+ ChangeColorSheetMenuItemFactory,+ HideSheetMenuItemFactory,+ UnHideSheetMenuItemFactory,] as IMenuItemFactory[]).forEach((factory) => {this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));