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(ui): add mobile ribbon (#6677)
白熱c25feda5bd48
diff --git a/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.tsindex 8cf8fb21eb..5843b7eef4 100644--- a/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts+++ b/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts@@ -346,7 +346,9 @@ export class SheetUIMobileController extends Disposable {const uiController = this._uiPartsService;const injector = this._injector;- this.disposeWithMe(uiController.registerComponent(BuiltInUIPart.HEADER, () => connectInjector(MobileSheetBar, injector)));+ // Use the same FormulaBar implementation as desktop for now.+ // this.disposeWithMe(uiController.registerComponent(BuiltInUIPart.HEADER, () => connectInjector(RenderSheetHeader, injector)));+ this.disposeWithMe(uiController.registerComponent(BuiltInUIPart.FOOTER, () => connectInjector(MobileSheetBar, injector)));this.disposeWithMe(uiController.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(RenderSheetContent, injector)));}diff --git a/packages/ui/src/components/menu/mobile/MobileMenu.tsx b/packages/ui/src/components/menu/mobile/MobileMenu.tsxindex 000d78f924..bdf0591644 100644--- a/packages/ui/src/components/menu/mobile/MobileMenu.tsx+++ b/packages/ui/src/components/menu/mobile/MobileMenu.tsx@@ -43,8 +43,12 @@ type MobileMenuView =currentValue: MenuItemDefaultValueType;};-export function MobileMenu(props: IBaseMenuProps) {- const { menuType, onOptionSelect } = props;+interface IMobileMenuProps extends IBaseMenuProps {+ schemas?: IMenuSchema[];+}++export function MobileMenu(props: IMobileMenuProps) {+ const { menuType, onOptionSelect, schemas: providedSchemas } = props;const menuManagerService = useDependency(IMenuManagerService);const [viewStack, setViewStack] = useState<MobileMenuView[]>([]);@@ -57,20 +61,24 @@ export function MobileMenu(props: IBaseMenuProps) {const menuSchemaVersion = useObservable(menuSchemaVersion$, 0);const menuSchemas = useMemo(() => {+ if (providedSchemas) {+ return providedSchemas;+ }+if (!menuType) {return [];}return menuManagerService.getMenuByPositionKey(menuType);- }, [menuManagerService, menuSchemaVersion, menuType]);+ }, [providedSchemas, menuManagerService, menuSchemaVersion, menuType]);useEffect(() => {setViewStack([]);- }, [menuType]);+ }, [menuType, providedSchemas]);const currentView = viewStack[viewStack.length - 1] ?? null;- if (!menuType) {+ if (!menuType && !providedSchemas) {return null;}@@ -142,7 +150,7 @@ export function MobileMenu(props: IBaseMenuProps) {function MobileSchemaList(props: {schemas: IMenuSchema[];- menuType: string;+ menuType?: string;onExecute?: IBaseMenuProps['onOptionSelect'];onOpenView: (view: MobileMenuView) => void;}) {@@ -217,7 +225,7 @@ function MobileSchemaList(props: {function MobileSchemaRow(props: {schema: IMenuSchema;- menuType: string;+ menuType?: string;onExecute?: IBaseMenuProps['onOptionSelect'];onOpenView: (view: MobileMenuView) => void;bordered: boolean;@@ -350,7 +358,7 @@ function MobileSelectionOptionRow(props: {function useMobileSchemaInteraction(props: {schema: IMenuSchema;- menuType: string;+ menuType?: string;onOpenView: (view: MobileMenuView) => void;}) {const { schema, menuType, onOpenView } = props;@@ -434,6 +442,7 @@ function useMobileSchemaInteraction(props: {value,id: buttonItem.id,label: schema.key,+ params: buttonItem.params,});};diff --git a/packages/ui/src/controllers/ui/__tests__/ui-desktop-mobile.controller.spec.tsx b/packages/ui/src/controllers/ui/__tests__/ui-desktop-mobile.controller.spec.tsxindex d55a29d8d6..e47f3a1b1f 100644--- a/packages/ui/src/controllers/ui/__tests__/ui-desktop-mobile.controller.spec.tsx+++ b/packages/ui/src/controllers/ui/__tests__/ui-desktop-mobile.controller.spec.tsx@@ -201,9 +201,16 @@ describe('MobileUIController', () => {vi.mocked(unmount).mockClear();const deps = createCommonDeps();+ const menuManagerService = {+ mergeMenu: vi.fn(),+ };const uiPartsService = {registerComponent: vi.fn(() => ({ dispose: vi.fn() })),};+ const componentManager = {+ register: vi.fn(() => ({ dispose: vi.fn() })),+ dispose: vi.fn(),+ };const controller = new MobileUIController({ container: 'missing-mobile' } as any,@@ -212,16 +219,21 @@ describe('MobileUIController', () => {deps.renderManagerService as any,deps.layoutService as any,deps.instanceService as any,- uiPartsService as any+ menuManagerService as any,+ uiPartsService as any,+ componentManager as any);vi.advanceTimersByTime(3300);- expect(uiPartsService.registerComponent).toHaveBeenCalledTimes(2);+ expect(menuManagerService.mergeMenu).toHaveBeenCalledTimes(1);+ expect(uiPartsService.registerComponent).toHaveBeenCalledTimes(3);+ expect(componentManager.register).toHaveBeenCalledTimes(6);expect(render).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({ id: 'missing-mobile' }));controller.dispose();expect(unmount).toHaveBeenCalled();+ expect(componentManager.dispose).toHaveBeenCalledTimes(1);});it('should support existing id, html container and default container', () => {@@ -235,9 +247,16 @@ describe('MobileUIController', () => {document.body.appendChild(existing);const htmlContainer = document.createElement('section');+ const menuManagerService = {+ mergeMenu: vi.fn(),+ };const uiPartsService = {registerComponent: vi.fn(() => ({ dispose: vi.fn() })),};+ const componentManager = {+ register: vi.fn(() => ({ dispose: vi.fn() })),+ dispose: vi.fn(),+ };const byExistingId = new MobileUIController({ container: 'mobile-existing' } as any,@@ -246,7 +265,9 @@ describe('MobileUIController', () => {deps.renderManagerService as any,deps.layoutService as any,deps.instanceService as any,- uiPartsService as any+ menuManagerService as any,+ uiPartsService as any,+ componentManager as any);const byElement = new MobileUIController(@@ -256,7 +277,9 @@ describe('MobileUIController', () => {deps.renderManagerService as any,deps.layoutService as any,deps.instanceService as any,- uiPartsService as any+ menuManagerService as any,+ uiPartsService as any,+ componentManager as any);const byDefault = new MobileUIController(@@ -266,7 +289,9 @@ describe('MobileUIController', () => {deps.renderManagerService as any,deps.layoutService as any,deps.instanceService as any,- uiPartsService as any+ menuManagerService as any,+ uiPartsService as any,+ componentManager as any);vi.advanceTimersByTime(3300);diff --git a/packages/ui/src/controllers/ui/ui-mobile.controller.tsx b/packages/ui/src/controllers/ui/ui-mobile.controller.tsxindex d626d8e68c..4a97f5f0a4 100644--- a/packages/ui/src/controllers/ui/ui-mobile.controller.tsx+++ b/packages/ui/src/controllers/ui/ui-mobile.controller.tsx@@ -15,16 +15,29 @@*/import type { IDisposable } from '@univerjs/core';+import type { ComponentType } from 'react';import type { IUniverUIConfig } from '../../config/config';+import type { IUniverWorkbenchProps } from '../../views/workbench/Workbench';import type { IUIController, IWorkbenchOptions } from './ui.controller';import { Inject, Injector, IUniverInstanceService, LifecycleService, toDisposable } from '@univerjs/core';-import { render as createRoot, unmount } from '@univerjs/design';+import { ColorPicker, render as createRoot, unmount } from '@univerjs/design';import { IRenderManagerService } from '@univerjs/engine-render';+import { ComponentManager } from '../../common';+import { HEADING_ITEM_COMPONENT, HeadingItem } from '../../components';+import { COLOR_PICKER_COMPONENT } from '../../components/color-picker/interface';+import { COMMON_LABEL_COMPONENT, CommonLabel } from '../../components/common-label';+import { FontFamily, FontFamilyItem } from '../../components/font-family';+import { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from '../../components/font-family/interface';+import { FontSize } from '../../components/font-size/FontSize';+import { FONT_SIZE_COMPONENT } from '../../components/font-size/interface';+import { menuSchema } from '../../menu/schema';import { ILayoutService } from '../../services/layout/layout.service';+import { IMenuManagerService } from '../../services/menu/menu-manager.service';import { BuiltInUIPart, IUIPartsService } from '../../services/parts/parts.service';import { connectInjector } from '../../utils/di';import { FloatDom } from '../../views/components/dom/FloatDom';import { CanvasPopup } from '../../views/components/popup/CanvasPopup';+import { MobileRibbon } from '../../views/components/ribbon/MobileRibbon';import { MobileWorkbench } from '../../views/mobile-workbench/MobileWorkbench';import { SingleUnitUIController } from './ui-shared.controller';@@ -36,21 +49,46 @@ export class MobileUIController extends SingleUnitUIController implements IUICon@IRenderManagerService renderManagerService: IRenderManagerService,@ILayoutService layoutService: ILayoutService,@IUniverInstanceService instanceService: IUniverInstanceService,- @IUIPartsService uiPartsService: IUIPartsService+ @IMenuManagerService menuManagerService: IMenuManagerService,+ @IUIPartsService uiPartsService: IUIPartsService,+ @Inject(ComponentManager) private readonly _componentManager: ComponentManager) {super(injector, instanceService, layoutService, lifecycleService, renderManagerService);+ menuManagerService.mergeMenu(menuSchema);this._initBuiltinComponents(uiPartsService);+ this._registerComponents();this._bootstrapWorkbench();}+ override dispose(): void {+ super.dispose();+ this._componentManager.dispose();+ }+override bootstrap(callback: (contentElement: HTMLElement, containerElement: HTMLElement) => void): IDisposable {return bootstrap(this._injector, this._config, callback);}+ private _registerComponents() {+ ([+ [COMMON_LABEL_COMPONENT, CommonLabel],+ [HEADING_ITEM_COMPONENT, HeadingItem],+ [FONT_FAMILY_COMPONENT, FontFamily],+ [FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem],+ [FONT_SIZE_COMPONENT, FontSize],+ [COLOR_PICKER_COMPONENT, ColorPicker],+ ] as const).forEach(([key, comp]) => {+ this.disposeWithMe(+ this._componentManager.register(key, comp)+ );+ });+ }+private _initBuiltinComponents(uiPartsService: IUIPartsService) {this.disposeWithMe(uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(CanvasPopup, this._injector)));this.disposeWithMe(uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(FloatDom, this._injector)));+ this.disposeWithMe(uiPartsService.registerComponent(BuiltInUIPart.TOOLBAR, () => connectInjector(MobileRibbon, this._injector)));}}@@ -75,7 +113,7 @@ function bootstrap(mountContainer = createContainer('univer');}- const ConnectedApp = connectInjector(MobileWorkbench, injector);+ const ConnectedApp = connectInjector(MobileWorkbench, injector) as ComponentType<IUniverWorkbenchProps>;const onRendered = (canvasElement: HTMLElement) => callback(canvasElement, mountContainer);function render() {diff --git a/packages/ui/src/mobile-plugin.ts b/packages/ui/src/mobile-plugin.tsindex 8f87316962..9f708c064c 100644--- a/packages/ui/src/mobile-plugin.ts+++ b/packages/ui/src/mobile-plugin.ts@@ -34,6 +34,7 @@ import { ContextMenuService, IContextMenuService } from './services/contextmenu/import { DesktopDialogService } from './services/dialog/desktop-dialog.service';import { IDialogService } from './services/dialog/dialog.service';import { CanvasFloatDomService } from './services/dom/canvas-dom-layer.service';+import { FontService, IFontService } from './services/font.service';import { DesktopGalleryService } from './services/gallery/desktop-gallery.service';import { IGalleryService } from './services/gallery/gallery.service';import { DesktopGlobalZoneService } from './services/global-zone/desktop-global-zone.service';@@ -50,6 +51,7 @@ import { INotificationService } from './services/notification/notification.serviimport { IUIPartsService, UIPartsService } from './services/parts/parts.service';import { IPlatformService, PlatformService } from './services/platform/platform.service';import { CanvasPopupService, ICanvasPopupService } from './services/popup/canvas-popup.service';+import { DesktopRibbonService, IRibbonService } from './services/ribbon/ribbon.service';import { ShortcutPanelService } from './services/shortcut/shortcut-panel.service';import { IShortcutService, ShortcutService } from './services/shortcut/shortcut.service';import { DesktopSidebarService } from './services/sidebar/desktop-sidebar.service';@@ -103,6 +105,7 @@ export class UniverMobileUIPlugin extends Plugin {[ShortcutPanelService],[IUIPartsService, { useClass: UIPartsService }],[ILayoutService, { useClass: DesktopLayoutService }],+ [IRibbonService, { useClass: DesktopRibbonService }],[IShortcutService, { useClass: ShortcutService }],[IPlatformService, { useClass: PlatformService }],[IMenuManagerService, { useClass: MenuManagerService }],@@ -121,6 +124,7 @@ export class UniverMobileUIPlugin extends Plugin {[IBeforeCloseService, { useClass: DesktopBeforeCloseService }],[ILocalFileService, { useClass: DesktopLocalFileService }],[ICanvasPopupService, { useClass: CanvasPopupService }],+ [IFontService, { useClass: FontService }],[CanvasFloatDomService],[diff --git a/packages/ui/src/services/menu/menu.ts b/packages/ui/src/services/menu/menu.tsindex 2853f123a7..4a25bcd079 100644--- a/packages/ui/src/services/menu/menu.ts+++ b/packages/ui/src/services/menu/menu.ts@@ -76,6 +76,7 @@ export interface IValueOption<T = undefined> {id?: string;value?: string | number;value$?: Observable<T>;+ params?: any;slot?: boolean;label?:| stringdiff --git a/packages/ui/src/views/components/context-menu/MobileContextMenu.tsx b/packages/ui/src/views/components/context-menu/MobileContextMenu.tsxindex 6a30ee2163..d1e7c77402 100644--- a/packages/ui/src/views/components/context-menu/MobileContextMenu.tsx+++ b/packages/ui/src/views/components/context-menu/MobileContextMenu.tsx@@ -144,9 +144,16 @@ export function MobileContextMenu() {<MobileMenumenuType={menuType}onOptionSelect={(params) => {- const { label: id, value, commandId } = params;+ const commandId = params.commandId ?? params.id ?? params.label as string | undefined;+ const fallbackParams = typeof params.params === 'function' ? params.params() : params.params;+ const commandParams = typeof params.value === 'undefined' ? fallbackParams : { value: params.value };++ if (!commandId) {+ return;+ }+layoutService.focus();- commandService.executeCommand(commandId ?? id as string, { value });+ commandService.executeCommand(commandId, commandParams);handleClose();}}/>diff --git a/packages/ui/src/views/components/ribbon/MobileRibbon.tsx b/packages/ui/src/views/components/ribbon/MobileRibbon.tsxnew file mode 100644index 0000000000..2f82a64849--- /dev/null+++ b/packages/ui/src/views/components/ribbon/MobileRibbon.tsx@@ -0,0 +1,353 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { ComponentType } from 'react';+import { LocaleService } from '@univerjs/core';+import { borderBottomClassName, borderClassName, borderRightClassName, clsx } from '@univerjs/design';+import { MoreIcon, MoreLeftIcon, MoreRightIcon } from '@univerjs/icons';+import { useEffect, useMemo, useRef, useState } from 'react';+import { RibbonPosition } from '../../../services/menu/types';+import { IRibbonService } from '../../../services/ribbon/ribbon.service';+import { useDependency, useObservable } from '../../../utils/di';+import { ComponentContainer } from '../ComponentContainer';+import { ToolbarItem } from './ToolbarItem';++interface IMobileRibbonProps {+ headerMenuComponents?: Set<ComponentType>;+ headerMenu?: boolean;+}++const toolbarScrollOffset = 168;+const resetButtonClassName = `+univer-m-0 univer-flex univer-appearance-none univer-items-center univer-justify-center+univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outline-none+`;+const nestedControlResetClassName = `+[&_button]:!univer-m-0 [&_button]:!univer-appearance-none [&_button]:!univer-border-0+[&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-leading-none+[&_button]:!univer-outline-none+[&_input]:!univer-m-0 [&_input]:!univer-appearance-none [&_input]:!univer-border-0+[&_input]:!univer-bg-transparent [&_input]:!univer-p-0 [&_input]:!univer-leading-none+[&_input]:!univer-outline-none+`;++export function MobileRibbon(props: IMobileRibbonProps) {+ const { headerMenuComponents, headerMenu = true } = props;++ const localeService = useDependency(LocaleService);+ const ribbonService = useDependency(IRibbonService);++ const ribbon = useObservable(ribbonService.ribbon$, []);+ const activatedTab = useObservable(ribbonService.activatedTab$, RibbonPosition.START);++ const activeIndex = useMemo(() => {+ const index = ribbon.findIndex((group) => group.key === activatedTab);+ return index === -1 ? 0 : index;+ }, [activatedTab, ribbon]);++ const activeGroup = ribbon[activeIndex];+ const activeGroups = activeGroup?.children ?? [];+ const hasHeaderMenu = !!(headerMenu && headerMenuComponents && headerMenuComponents.size > 0);++ const toolbarScrollRef = useRef<HTMLDivElement>(null);+ const [canScrollLeft, setCanScrollLeft] = useState(false);+ const [canScrollRight, setCanScrollRight] = useState(false);++ useEffect(() => {+ if (!activeGroup && ribbon.length > 0) {+ ribbonService.setActivatedTab(ribbon[0].key);+ }+ }, [activeGroup, ribbon, ribbonService]);++ useEffect(() => {+ const container = toolbarScrollRef.current;++ if (!container) {+ return;+ }++ const updateScrollState = () => {+ const { scrollLeft, clientWidth, scrollWidth } = container;+ setCanScrollLeft(scrollLeft > 4);+ setCanScrollRight(scrollLeft + clientWidth < scrollWidth - 4);+ };++ updateScrollState();++ const resizeObserver = new ResizeObserver(updateScrollState);+ resizeObserver.observe(container);+ container.addEventListener('scroll', updateScrollState, { passive: true });++ return () => {+ resizeObserver.disconnect();+ container.removeEventListener('scroll', updateScrollState);+ };+ }, [activeGroup]);++ if (ribbon.length === 0 && !hasHeaderMenu) {+ return null;+ }++ function selectTab(index: number) {+ const nextGroup = ribbon[index];++ if (!nextGroup) {+ return;+ }++ ribbonService.setActivatedTab(nextGroup.key);+ }++ function scrollToolbar(direction: 'left' | 'right') {+ const container = toolbarScrollRef.current;++ if (!container) {+ return;+ }++ container.scrollBy({+ left: direction === 'left' ? -toolbarScrollOffset : toolbarScrollOffset,+ behavior: 'smooth',+ });+ }++ return (+ <div+ data-u-comp="mobile-ribbon"+ className={clsx(`+ univer-flex univer-flex-col univer-gap-1.5 univer-bg-gray-50 univer-px-3 univer-py-1.5 univer-text-sm+ dark:!univer-bg-gray-900+ `, borderBottomClassName)}+ >+ <div+ className="+ univer-grid univer-grid-cols-[28px_minmax(0,1fr)_auto] univer-items-center univer-gap-1.5+ univer-px-0.5 univer-py-0.5+ "+ >+ <div className="univer-flex univer-items-center">+ <button+ type="button"+ className={clsx(resetButtonClassName, `+ univer-size-7 univer-rounded-md univer-text-gray-500 univer-transition-colors+ hover:univer-bg-gray-100+ active:univer-bg-gray-200+ dark:!univer-text-gray-300+ dark:hover:!univer-bg-gray-700+ dark:active:!univer-bg-gray-600+ `, {+ 'univer-opacity-40': activeIndex === 0,+ })}+ disabled={activeIndex === 0}+ aria-label="Previous"+ onClick={() => selectTab(activeIndex - 1)}+ >+ <MoreIcon className="univer-rotate-180 univer-text-sm" />+ </button>+ </div>++ <div className="univer-flex univer-min-w-0 univer-items-center univer-justify-center univer-gap-2.5">+ {ribbon.map((group, index) => {+ const active = index === activeIndex;++ return (+ <button+ key={group.key}+ type="button"+ role="tab"+ aria-selected={active}+ className={clsx(`+ ${resetButtonClassName}+ univer-relative univer-shrink-0 univer-px-1 univer-py-1 univer-text-sm+ univer-font-semibold univer-transition-colors+ `, active+ ? `+ univer-text-primary-600+ dark:!univer-text-primary-400+ `+ : `+ univer-text-gray-700+ dark:!univer-text-gray-200+ `)}+ onClick={() => selectTab(index)}+ >+ {localeService.t(group.key)}+ {active && (+ <span+ className="+ univer-absolute univer-bottom-0 univer-left-1/2 univer-h-0.5 univer-w-8+ -univer-translate-x-1/2 univer-rounded-full univer-bg-primary-600+ dark:!univer-bg-primary-400+ "+ />+ )}+ </button>+ );+ })}+ </div>++ <div className="univer-flex univer-items-center univer-gap-1">+ <button+ type="button"+ className={clsx(`+ ${resetButtonClassName}+ univer-size-7 univer-rounded-md univer-text-gray-500 univer-transition-colors+ hover:univer-bg-gray-100+ active:univer-bg-gray-200+ dark:!univer-text-gray-300+ dark:hover:!univer-bg-gray-700+ dark:active:!univer-bg-gray-600+ `, {+ 'univer-opacity-40': activeIndex >= ribbon.length - 1,+ })}+ disabled={activeIndex >= ribbon.length - 1}+ aria-label="Next"+ onClick={() => selectTab(activeIndex + 1)}+ >+ <MoreIcon className="univer-text-sm" />+ </button>++ {hasHeaderMenu && (+ <div+ className="+ univer-flex univer-items-center univer-gap-1+ [&>*]:univer-m-0 [&>*]:univer-inline-flex [&>*]:univer-min-h-7 [&>*]:univer-min-w-7+ [&>*]:univer-appearance-none [&>*]:univer-items-center [&>*]:univer-justify-center+ [&>*]:univer-rounded-md [&>*]:univer-border-0 [&>*]:univer-px-1.5+ [&>*]:univer-leading-none [&>*]:univer-outline-none+ "+ >+ <ComponentContainer components={headerMenuComponents!} />+ </div>+ )}+ </div>+ </div>++ <div+ className={clsx(`+ univer-grid univer-grid-cols-[22px_minmax(0,1fr)_22px] univer-items-center univer-gap-1.5+ univer-rounded-xl univer-bg-white univer-px-2 univer-py-1+ dark:!univer-bg-gray-800+ `, borderClassName)}+ >+ <button+ type="button"+ className={clsx(`+ ${resetButtonClassName}+ univer-h-8 univer-w-5 univer-text-gray-500 univer-transition-colors+ dark:!univer-text-gray-300+ `, {+ 'univer-opacity-30': !canScrollLeft,+ })}+ disabled={!canScrollLeft}+ aria-label="Previous"+ onClick={() => scrollToolbar('left')}+ >+ <MoreLeftIcon className="univer-text-sm" />+ </button>++ <div+ ref={toolbarScrollRef}+ data-u-comp="mobile-ribbon-toolbar"+ className={`+ univer-flex univer-min-w-0 univer-items-center univer-gap-1.5 univer-overflow-x-auto+ univer-scroll-smooth univer-px-0.5+ [&::-webkit-scrollbar]:univer-hidden+ `}+ >+ {activeGroups.map((groupItem, groupIndex) => {+ const groupItems = groupItem.children?.filter((child) => !!child.item) ?? [];++ if (!groupItems.length) {+ return null;+ }++ return (+ <div+ key={groupItem.key}+ className={clsx(`+ univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5+ rtl:univer-pl-1.5 rtl:univer-pr-0+ `, {+ [borderRightClassName]: groupIndex !== activeGroups.length - 1,+ })}+ >+ {groupItems.map((child) => (+ child.item && (+ <div+ key={child.key}+ className={clsx(`+ [&_button]:!univer-font-inherit+ univer-flex univer-h-8 univer-shrink-0 univer-items-center+ univer-rounded-md+ [&_*]:univer-box-border+ [&_.univer-custom-label]:univer-text-sm+ [&_.univer-custom-label]:univer-leading-none+ [&_.univer-toolbar-button-selector-main]:!univer-h-8+ [&_.univer-toolbar-button-selector-main]:!univer-rounded-none+ [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md+ [&_.univer-toolbar-button-selector-main]:!univer-px-1.5+ [&_.univer-toolbar-button-selector-root]:!univer-h-8+ [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden+ [&_.univer-toolbar-button-selector-root]:!univer-rounded-md+ [&_.univer-toolbar-button-selector-root]:!univer-pr-0+ [&_.univer-toolbar-button-selector-trigger]:!univer-static+ [&_.univer-toolbar-button-selector-trigger]:!univer-h-8+ [&_.univer-toolbar-button-selector-trigger]:!univer-w-6+ [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none+ [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md+ [&_.univer-toolbar-selector-root]:!univer-h-8+ [&_.univer-toolbar-selector-root]:!univer-gap-1+ [&_.univer-toolbar-selector-root]:!univer-rounded-md+ [&_.univer-toolbar-selector-root]:!univer-px-1.5+ [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5+ [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full+ [&_.univer-tooltip]:univer-items-center+ [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8+ [&_[data-u-command]]:!univer-rounded-md+ [&_[data-u-command]]:!univer-px-1.5+ [&_button]:!univer-h-8 [&_button]:!univer-min-w-8+ [&_button]:!univer-rounded-md [&_button]:!univer-px-1.5+ `, nestedControlResetClassName)}+ >+ <ToolbarItem {...child.item} />+ </div>+ )+ ))}+ </div>+ );+ })}+ </div>++ <button+ type="button"+ className={clsx(`+ ${resetButtonClassName}+ univer-h-8 univer-w-5 univer-text-gray-500 univer-transition-colors+ dark:!univer-text-gray-300+ `, {+ 'univer-opacity-30': !canScrollRight,+ })}+ disabled={!canScrollRight}+ aria-label="Next"+ onClick={() => scrollToolbar('right')}+ >+ <MoreRightIcon className="univer-text-sm" />+ </button>+ </div>+ </div>+ );+}diff --git a/packages/ui/src/views/components/ribbon/ToolbarButton.tsx b/packages/ui/src/views/components/ribbon/ToolbarButton.tsxindex 8739982b5a..e569169f54 100644--- a/packages/ui/src/views/components/ribbon/ToolbarButton.tsx+++ b/packages/ui/src/views/components/ribbon/ToolbarButton.tsx@@ -95,7 +95,7 @@ export function ToolbarButton(props: IBaseToolbarButtonProps) {return (<buttontype="button"- className={clsx(toolbarButtonClassName, {+ className={clsx(toolbarButtonClassName, className, {'univer-px-2': noIcon,'!univer-bg-gray-200 dark:!univer-bg-gray-500': active,})}diff --git a/packages/ui/src/views/components/ribbon/ToolbarItem.tsx b/packages/ui/src/views/components/ribbon/ToolbarItem.tsxindex f497fbc5a4..d84ebe641e 100644--- a/packages/ui/src/views/components/ribbon/ToolbarItem.tsx+++ b/packages/ui/src/views/components/ribbon/ToolbarItem.tsx@@ -108,9 +108,9 @@ export const ToolbarItem = forwardRef<ITooltipWrapperRef, IDisplayMenuItem<IMenudata-u-command={id}data-disabled={disabled}className={clsx(`- univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6- univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm- univer-transition-colors+ univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative+ univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5+ univer-text-sm univer-transition-colorshover:univer-bg-gray-100dark:hover:!univer-bg-gray-700`, {@@ -120,8 +120,8 @@ export const ToolbarItem = forwardRef<ITooltipWrapperRef, IDisplayMenuItem<IMenu><divclassName={clsx(`- univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l- univer-px-1 univer-transition-colors+ univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full+ univer-items-center univer-rounded-l univer-px-1 univer-transition-colorshover:univer-bg-gray-200dark:hover:!univer-bg-gray-600`, {@@ -149,9 +149,9 @@ export const ToolbarItem = forwardRef<ITooltipWrapperRef, IDisplayMenuItem<IMenu><divclassName={clsx(`- univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6- univer-w-5 univer-items-center univer-justify-center univer-rounded-r- univer-transition-colors+ univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0+ univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center+ univer-justify-center univer-rounded-r univer-transition-colorshover:univer-bg-gray-200dark:hover:!univer-bg-gray-600`, {@@ -179,9 +179,9 @@ export const ToolbarItem = forwardRef<ITooltipWrapperRef, IDisplayMenuItem<IMenu<divdata-u-command={id}className={clsx(`- univer-animate-in univer-fade-in univer-relative univer-flex univer-h-6 univer-cursor-pointer- univer-items-center univer-gap-2 univer-whitespace-nowrap univer-rounded univer-px-1- univer-transition-colors+ univer-toolbar-selector-root univer-animate-in univer-fade-in univer-relative univer-flex+ univer-h-6 univer-cursor-pointer univer-items-center univer-gap-2 univer-whitespace-nowrap+ univer-rounded univer-px-1 univer-transition-colorshover:univer-bg-gray-100dark:hover:!univer-bg-gray-700`, {@@ -199,7 +199,9 @@ export const ToolbarItem = forwardRef<ITooltipWrapperRef, IDisplayMenuItem<IMenuonChange={handleSelectionsValueChange}/><div- className={clsx('univer-flex univer-h-full univer-items-center', {+ className={clsx(`+ univer-toolbar-selector-trigger univer-flex univer-h-full univer-items-center+ `, {'univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600': disabled,})}>diff --git a/packages/ui/src/views/mobile-workbench/MobileWorkbench.tsx b/packages/ui/src/views/mobile-workbench/MobileWorkbench.tsxindex b6922f9237..a24c85af82 100644--- a/packages/ui/src/views/mobile-workbench/MobileWorkbench.tsx+++ b/packages/ui/src/views/mobile-workbench/MobileWorkbench.tsx@@ -36,7 +36,10 @@ export interface IUniverAppProps extends IWorkbenchOptions {export function MobileWorkbench(props: IUniverAppProps) {const {header = true,+ toolbar = true,footer = true,+ headerMenu = true,+ ribbonType = 'classic',contextMenu = true,mountContainer,onRendered,@@ -50,9 +53,11 @@ export function MobileWorkbench(props: IUniverAppProps) {const footerComponents = useComponentsOfPart(BuiltInUIPart.FOOTER);const headerComponents = useComponentsOfPart(BuiltInUIPart.HEADER);+ const headerMenuComponents = useComponentsOfPart(BuiltInUIPart.HEADER_MENU);const contentComponents = useComponentsOfPart(BuiltInUIPart.CONTENT);const leftSidebarComponents = useComponentsOfPart(BuiltInUIPart.LEFT_SIDEBAR);const globalComponents = useComponentsOfPart(BuiltInUIPart.GLOBAL);+ const toolbarComponents = useComponentsOfPart(BuiltInUIPart.TOOLBAR);const [darkMode, setDarkMode] = useState<boolean>(false);useEffect(() => {@@ -121,10 +126,24 @@ export function MobileWorkbench(props: IUniverAppProps) {})}tabIndex={-1}onBlur={(e) => e.stopPropagation()}+ onContextMenu={(e) => e.preventDefault()}>{/* header */}- {header && (- <header className="univer-relative univer-z-10 univer-w-full" />+ {header && toolbar && (+ <header+ data-u-comp="headerbar"+ className="univer-relative univer-z-10 univer-w-full univer-overflow-hidden"+ >+ <ComponentContainer+ key="toolbar"+ components={toolbarComponents}+ sharedProps={{+ ribbonType,+ headerMenuComponents,+ headerMenu,+ }}+ />+ </header>)}{/* content */}