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
refactor(ui): remove unused Divider component and apply separator class to toolbar items (#4975)
白熱233c38815ebe
diff --git a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.pngindex fa2f4f3097..4c2d05b9cf 100644Binary files a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png and b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/default-doc-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.pngindex dba2a509c8..a699532ebe 100644Binary files a/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-switching-render-unit.spec.ts-snapshots/switching-render-unit-ci-chromium-linux.png differdiff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.pngindex f688156613..44277e660b 100644Binary files a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png and b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts-snapshots/default-sheet-fullpage-ci-chromium-linux.png differdiff --git a/packages/ui/src/controllers/shortcut-display/menu.ts b/packages/ui/src/controllers/shortcut-display/menu.tsindex d7905f9e39..7220a211b5 100644--- a/packages/ui/src/controllers/shortcut-display/menu.ts+++ b/packages/ui/src/controllers/shortcut-display/menu.ts@@ -14,12 +14,11 @@* limitations under the License.*/-import { UniverInstanceType } from '@univerjs/core';import type { IAccessor } from '@univerjs/core';-+import type { IMenuButtonItem } from '../../services/menu/menu';+import { UniverInstanceType } from '@univerjs/core';import { ToggleShortcutPanelOperation } from '../../commands/operations/toggle-shortcut-panel.operation';import { getMenuHiddenObservable } from '../../common/menu-hidden-observable';-import type { IMenuButtonItem } from '../../services/menu/menu';import { MenuItemType } from '../../services/menu/menu';export function ShortcutPanelMenuItemFactory(accessor: IAccessor): IMenuButtonItem {diff --git a/packages/ui/src/services/menu/menu.ts b/packages/ui/src/services/menu/menu.tsindex da202b1635..ea04e43325 100644--- a/packages/ui/src/services/menu/menu.ts+++ b/packages/ui/src/services/menu/menu.ts@@ -129,10 +129,10 @@ export type IDisplayMenuItem<T extends IMenuItem> = T & {shortcut?: string;};-export type MenuItemConfig<T extends MenuItemDefaultValueType = MenuItemDefaultValueType> = Partial<Omit<IMenuItem, 'id' | 'subId' | 'value$' | 'hidden$' | 'disabled$' | 'activated$' | 'icon$'> & {+export type MenuItemConfig = Partial<Omit<IMenuItem, 'id' | 'subId' | 'value$' | 'hidden$' | 'disabled$' | 'activated$' | 'icon$'> & {hidden?: boolean;disabled?: boolean;activated?: boolean;}>;-export type MenuConfig<T extends MenuItemDefaultValueType = MenuItemDefaultValueType> = Record<string, MenuItemConfig<T>>;-export type IMenuItemFactory = (accessor: IAccessor, menuConfig?: MenuConfig<MenuItemDefaultValueType>) => IMenuItem;+export type MenuConfig = Record<string, MenuItemConfig>;+export type IMenuItemFactory = (accessor: IAccessor, menuConfig?: MenuConfig) => IMenuItem;diff --git a/packages/ui/src/views/components/ribbon/Ribbon.tsx b/packages/ui/src/views/components/ribbon/Ribbon.tsxindex 2a35650223..645c141bbe 100644--- a/packages/ui/src/views/components/ribbon/Ribbon.tsx+++ b/packages/ui/src/views/components/ribbon/Ribbon.tsx@@ -17,7 +17,7 @@import type { ComponentType } from 'react';import type { IMenuSchema } from '../../../services/menu/menu-manager.service';import { LocaleService } from '@univerjs/core';-import { clsx, Separator } from '@univerjs/design';+import { clsx } from '@univerjs/design';import { MoreFunctionSingle } from '@univerjs/icons';import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';import { IMenuManagerService } from '../../../services/menu/menu-manager.service';@@ -33,10 +33,6 @@ interface IRibbonProps {headerMenu?: boolean;}-function Divider() {- return <Separator className="!univer-h-5" orientation="vertical" />;-}-export function Ribbon(props: IRibbonProps) {const { headerMenuComponents, headerMenu = true } = props;@@ -51,6 +47,12 @@ export function Ribbon(props: IRibbonProps) {const [changingActiveTab, setChangingActiveTab] = useState(false);const [collapsedIds, setCollapsedIds] = useState<string[]>([]);+ const separatorClassName = `[&>*:last-child:after]:univer-absolute [&>*:last-child:after]:-univer-right-2+ [&>*:last-child:after]:univer-top-1/2 [&>*:last-child:after]:univer-h-5 [&>*:last-child:after]:univer-translate-x-[3px]+ [&>*:last-child:after]:univer-w-px [&>*:last-child:after]:-univer-translate-y-1/2+ [&>*:last-child:after]:univer-bg-gray-200 [&>*:last-child:after]:univer-content-['']+ [&>*:last-child]:univer-relative`;+const handleSelectTab = useCallback((group: IMenuSchema) => {toolbarItemRefs.current = {};setChangingActiveTab(true);@@ -148,7 +150,7 @@ export function Ribbon(props: IRibbonProps) {const fakeToolbarContent = useMemo(() => (activeGroup.allGroups.map((groupItem) => (<Fragment key={groupItem.key}>- <div className="univer-flex univer-flex-nowrap univer-gap-2 univer-px-2">+ <div className={clsx('univer-flex univer-flex-nowrap univer-gap-2 univer-px-2', separatorClassName)}>{groupItem.children?.map((child) => (child.item && (<ToolbarItem@@ -166,7 +168,6 @@ export function Ribbon(props: IRibbonProps) {)))}</div>- <Divider /></Fragment>))), [activeGroup.allGroups]);@@ -234,9 +235,9 @@ export function Ribbon(props: IRibbonProps) {'univer-duration-300 univer-animate-in univer-fade-in': changingActiveTab,})}>- {activeGroup.visibleGroups.map((groupItem, index) => (groupItem.children?.length || groupItem.item) && (+ {activeGroup.visibleGroups.map((groupItem) => (groupItem.children?.length || groupItem.item) && (<Fragment key={groupItem.key}>- <div className="univer-flex univer-flex-nowrap univer-gap-2 univer-px-2">+ <div className={clsx('univer-flex univer-flex-nowrap univer-gap-2 univer-px-2', separatorClassName)}>{groupItem.children? groupItem.children?.map((child) => (child.item && <ToolbarItem key={child.key} {...child.item} />@@ -245,14 +246,12 @@ export function Ribbon(props: IRibbonProps) {groupItem.item && <ToolbarItem key={groupItem.key} {...groupItem.item} />)}</div>- {index < activeGroup.visibleGroups.length - 1 && activeGroup.visibleGroups.some((groupItem) => groupItem.children?.length || !!groupItem.item) && <Divider />}</Fragment>))}{/* overflow menu items */}{collapsedIds.length > 0 && (<>- <Divider /><TooltipWrapper title={localeService.t('ribbon.more')} placement="bottom"><DropdownWrapperalign="end"