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 menu components and implement QuickInsertMenu (#6695)
白熱87e22087a83b
diff --git a/packages/core/package.json b/packages/core/package.jsonindex f830bcd23e..478156e9c8 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -78,11 +78,11 @@"@univerjs/themes": "workspace:*","@wendellhu/redi": "1.1.1","async-lock": "^1.4.1",- "dayjs": "^1.11.19",+ "dayjs": "^1.11.20","fast-diff": "1.3.0","kdbush": "^4.0.2","lodash-es": "^4.17.23",- "nanoid": "5.1.6",+ "nanoid": "5.1.7","numfmt": "^3.2.3","ot-json1": "^1.0.2","rbush": "^4.0.1"diff --git a/packages/design/package.json b/packages/design/package.jsonindex 392d5dedb5..5dca02a773 100644--- a/packages/design/package.json+++ b/packages/design/package.json@@ -79,9 +79,7 @@"@univerjs/icons": "^1.1.1","class-variance-authority": "^0.7.1","clsx": "^2.1.1",- "dayjs": "^1.11.19",- "rc-dropdown": "^4.2.1",- "rc-menu": "^9.16.0",+ "dayjs": "^1.11.20","react-transition-group": "^4.4.5","sonner": "^2.0.7","tailwind-merge": "2.6.0"diff --git a/packages/design/src/components/menu/__tests__/index.spec.tsx b/packages/design/src/components/menu/__tests__/index.spec.tsxdeleted file mode 100644index 2abf99f1c0..0000000000--- a/packages/design/src/components/menu/__tests__/index.spec.tsx+++ /dev/null@@ -1,133 +0,0 @@-/**- * 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 { cleanup, fireEvent, render, screen } from '@testing-library/react';-import { afterEach, describe, expect, it, vi } from 'vitest';-import { ConfigProvider } from '../../config-provider/ConfigProvider';-import { Menu, MenuItem, TinyMenuGroup } from '../Menu';-import '@testing-library/jest-dom/vitest';--const { menuPropsSpy } = vi.hoisted(() => ({- menuPropsSpy: vi.fn(),-}));--vi.mock('rc-menu', () => ({- default: (props: any) => {- menuPropsSpy(props);- return (- <div data-testid="rc-menu" data-prefix={props.prefixCls} className={props.className}>- {props.children}- </div>- );- },- MenuItem: (props: any) => <div data-testid="rc-menu-item">{props.children}</div>,- MenuItemGroup: (props: any) => <div data-testid="rc-menu-group">{props.children}</div>,- SubMenu: (props: any) => <div data-testid="rc-sub-menu">{props.children}</div>,-}));--vi.mock('../../tooltip/Tooltip', () => ({- Tooltip: (props: any) => (- <div data-testid="mock-tooltip" data-title={props.title}>- {props.children}- </div>- ),-}));--afterEach(() => {- cleanup();- menuPropsSpy.mockClear();-});--describe('Menu', () => {- it('should render rc-menu with mount container', () => {- const mountContainer = document.createElement('div');-- render(- <ConfigProvider mountContainer={mountContainer}>- <Menu className="inner-class" wrapperClass="wrapper-class">- <MenuItem key="menu-item">Menu Item</MenuItem>- </Menu>- </ConfigProvider>- );-- const rcMenu = screen.getByTestId('rc-menu');- expect(rcMenu).toHaveClass('wrapper-class');- expect(rcMenu).toHaveAttribute('data-prefix');- expect(rcMenu.getAttribute('data-prefix')).toContain('univer-menu');-- const props = menuPropsSpy.mock.calls.at(-1)?.[0];- expect(props.getPopupContainer()).toBe(mountContainer);- });-- it('should render nothing without mount container', () => {- render(- <ConfigProvider mountContainer={null}>- <Menu className="inner-class" wrapperClass="wrapper-class" />- </ConfigProvider>- );-- expect(screen.queryByTestId('rc-menu')).not.toBeInTheDocument();- });-- it('should render tiny menu group and support click/tooltip', () => {- const onClickA = vi.fn();- const onClickB = vi.fn();-- function IconA(props: { className?: string }) {- return <span className={props.className}>IconA</span>;- }-- function IconB(props: { className?: string }) {- return <span className={props.className}>IconB</span>;- }-- const { container } = render(- <TinyMenuGroup- items={[- {- key: 'a',- className: 'custom-a',- Icon: IconA,- active: true,- tooltip: 'tip-a',- onClick: onClickA,- },- {- key: 'b',- className: 'custom-b',- Icon: IconB,- onClick: onClickB,- },- ]}- />- );-- expect(screen.getByTestId('mock-tooltip')).toHaveAttribute('data-title', 'tip-a');-- const iconA = screen.getByText('IconA');- const iconAWrapper = iconA.parentElement as HTMLElement;- expect(iconAWrapper.className).toContain('univer-bg-gray-50');-- fireEvent.click(iconAWrapper);- expect(onClickA).toHaveBeenCalledTimes(1);-- const iconB = screen.getByText('IconB');- fireEvent.click(iconB.parentElement as HTMLElement);- expect(onClickB).toHaveBeenCalledTimes(1);-- expect(container.querySelectorAll('.custom-a, .custom-b').length).toBe(2);- });-});diff --git a/packages/design/src/components/menu/index.css b/packages/design/src/components/menu/index.cssdeleted file mode 100644index b2f221a75d..0000000000--- a/packages/design/src/components/menu/index.css+++ /dev/null@@ -1,340 +0,0 @@-.univer-menu {- @apply univer-max-w-fit;- @apply univer-m-0 univer-py-1 univer-px-2 univer-text-sm univer-list-none univer-rounded-md univer-box-border univer-shadow-md univer-border-solid univer-border univer-border-gray-200 univer-min-w-52 univer-w-fit univer-bg-white;-}-.univer-dark .univer-menu {- @apply univer-bg-gray-700 univer-border-gray-600;-}--.univer-menu-vertical {- display: grid;-}--.univer-menu-hidden,-.univer-menu-submenu-hidden {- display: none;-}--.univer-menu-item-group {- @apply univer-py-1;-}--.univer-menu-item-group:not(:last-child) {- border-bottom: 1px solid #e3e5ea;-}-.univer-dark .univer-menu-item-group:not(:last-child) {- @apply univer-border-b-gray-600;-}--.univer-menu-item-group-list {- display: grid;- margin: 0;- padding: 0;- @apply univer-gap-1;-}--.univer-menu-item-group-title {- font-weight: 600;- line-height: 1.5em;- padding: 4px;- padding-top: 6px;- @apply univer-text-gray-600 univer-text-xs univer-px-2;-}-.univer-dark .univer-menu-item-group-title {- @apply univer-text-white;-}--.univer-menu-item-group-title:empty {- display: none;-}--.univer-menu-item-active,-.univer-menu-submenu-active {- @apply univer-bg-gray-50 univer-rounded-md;-}-.univer-dark .univer-menu-item-active,-.univer-dark .univer-menu-submenu-active {- @apply univer-bg-gray-600;-}--.univer-menu-item-selected {- transform: translateZ(0);- @apply univer-bg-gray-50 univer-rounded-md;-}-.univer-dark .univer-menu-item-selected {- @apply univer-bg-gray-600;-}--.univer-menu-submenu-selected {- @apply univer-bg-gray-50 univer-rounded-md;-}-.univer-dark .univer-menu-submenu-selected {- @apply univer-bg-gray-600;-}--.univer-menu > li.univer-menu-submenu {- padding: 0;-}--.univer-menu-horizontal-sub,-.univer-menu-vertical-sub,-.univer-menu-vertical-left-sub,-.univer-menu-vertical-right-sub {- min-width: 160px;- margin-top: 0;-}--.univer-menu-item {- display: flex;- align-items: center;- min-height: 32px;- line-height: 1.5em;- @apply univer-rounded-md univer-text-sm univer-text-gray-900 univer-px-2 univer-gap-3;-}-.univer-dark .univer-menu-item {- @apply univer-text-white;-}--.univer-menu-item:hover {- @apply univer-bg-gray-50;-}-.univer-dark .univer-menu-item:hover {- @apply univer-bg-gray-600;-}--.univer-menu-item .icon {- @apply univer-text-gray-600;-}-.univer-dark .univer-menu-item .icon {- @apply univer-text-white;-}--.univer-menu-item,-.univer-menu-submenu {- cursor: pointer;- position: relative;- box-sizing: border-box;- margin: 0;- white-space: nowrap;- list-style: none;-}--.univer-menu-item.univer-menu-item-disabled,-.univer-menu-submenu.univer-menu-submenu-disabled {- cursor: not-allowed;- @apply !univer-text-gray-400;-}--.univer-menu-submenu-popup {- position: absolute;- z-index: 1070;-}--.univer-menu-submenu-popup .submenu-title-wrapper {- @apply univer-pr-5;-}--.univer-menu-submenu-title {- display: flex;- align-items: center;- justify-content: space-between;- height: 100%;- min-height: 32px;- line-height: 1.5em;- @apply univer-text-gray-900 univer-text-sm univer-px-2;-}-.univer-dark .univer-menu-submenu-title {- @apply univer-text-white;-}--.univer-menu-submenu-title-more-icon,-.univer-menu-item-more-icon {- @apply univer-text-gray-400 univer-text-sm univer-ml-2;-}--.univer-menu-horizontal {- overflow: hidden;- white-space: nowrap;- border: none;- border-bottom: 1px solid transparent;- box-shadow: none;- @apply univer-border-b-gray-200;-}-.univer-dark .univer-menu-horizontal {- @apply univer-border-b-gray-600;-}--.univer-menu-horizontal > .univer-menu-item,-.univer-menu-horizontal > .univer-menu-submenu > .univer-menu-submenu-title {- padding: 15px 20px;-}--.univer-menu-horizontal > .univer-menu-submenu,-.univer-menu-horizontal > .univer-menu-item {- display: inline-block;- vertical-align: bottom;- border-bottom: 2px solid transparent;-}--.univer-menu-vertical,-.univer-menu-vertical-left,-.univer-menu-vertical-right,-.univer-menu-inline {- width: 100%;-}--.univer-menu-vertical > .univer-menu-item,-.univer-menu-vertical > .univer-menu-submenu > .univer-menu-submenu-title,-.univer-menu-vertical-left > .univer-menu-item,-.univer-menu-vertical-left > .univer-menu-submenu > .univer-menu-submenu-title,-.univer-menu-vertical-right > .univer-menu-item,-.univer-menu-vertical-right > .univer-menu-submenu > .univer-menu-submenu-title,-.univer-menu-inline > .univer-menu-item,-.univer-menu-inline > .univer-menu-submenu > .univer-menu-submenu-title {- display: flex;- align-items: center;- justify-content: space-between;- box-sizing: border-box;- width: 100%;- min-height: 28px;- @apply univer-p-1;-}--.univer-menu-vertical .univer-menu-submenu-arrow,-.univer-menu-vertical-left .univer-menu-submenu-arrow,-.univer-menu-vertical-right .univer-menu-submenu-arrow,-.univer-menu-inline .univer-menu-submenu-arrow {- position: absolute;- right: 16px;- display: inline-block;- font-size: inherit;- line-height: 1.5em;- text-align: center;- text-transform: none;- text-rendering: auto;- vertical-align: baseline;-}--.univer-menu-sub-inline {- padding: 0;- border: none;- border-radius: 0;- box-shadow: none;-}--.univer-menu-sub-inline > .univer-menu-item,-.univer-menu-sub-inline > .univer-menu-submenu > .univer-menu-submenu-title {- padding-top: 8px;- padding-right: 0;- padding-bottom: 8px;-}--.univer-menu-open-slide-up-enter,-.univer-menu-open-slide-up-appear {- opacity: 0;- animation-play-state: paused;- animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1);- transform-origin: 0 0;- animation-duration: 0.3s;- animation-fill-mode: both;-}--.univer-menu-open-slide-up-leave {- opacity: 1;- animation-play-state: paused;- animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);- transform-origin: 0 0;- animation-duration: 0.3s;- animation-fill-mode: both;-}--.univer-menu-open-slide-up-enter.univer-menu-open-slide-up-enter-active,-.univer-menu-open-slide-up-appear.univer-menu-open-slide-up-appear-active {- animation-name: menu-open-slide-up-in;- animation-play-state: running;-}--.univer-menu-open-slide-up-leave.univer-menu-open-slide-up-leave-active {- animation-name: menu-open-slide-up-out;- animation-play-state: running;-}--@keyframes menu-open-slide-up-in {- 0% {- transform-origin: 0% 0%;- transform: scaleY(0);- opacity: 0;- }-- 100% {- transform-origin: 0% 0%;- transform: scaleY(1);- opacity: 1;- }-}--@keyframes menu-open-slide-up-out {- 0% {- transform-origin: 0% 0%;- transform: scaleY(1);- opacity: 1;- }-- 100% {- transform-origin: 0% 0%;- transform: scaleY(0);- opacity: 0;- }-}--.univer-menu-open-zoom-enter,-.univer-menu-open-zoom-appear {- opacity: 0;- animation-play-state: paused;- animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1);- transform-origin: 0 0;- animation-duration: 0.3s;- animation-fill-mode: both;-}--.univer-menu-open-zoom-leave {- animation-play-state: paused;- animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);- transform-origin: 0 0;- animation-duration: 0.3s;- animation-fill-mode: both;-}--.univer-menu-open-zoom-enter.univer-menu-open-zoom-enter-active,-.univer-menu-open-zoom-appear.univer-menu-open-zoom-appear-active {- animation-name: menu-open-zoom-in;- animation-play-state: running;-}--.univer-menu-open-zoom-leave.univer-menu-open-zoom-leave-active {- animation-name: menu-open-zoom-out;- animation-play-state: running;-}--@keyframes menu-open-zoom-in {- 0% {- transform: scale(0, 0);- opacity: 0;- }-- 100% {- transform: scale(1, 1);- opacity: 1;- }-}--@keyframes menu-open-zoom-out {- 0% {- transform: scale(1, 1);- }-- 100% {- transform: scale(0, 0);- opacity: 0;- }-}diff --git a/packages/design/src/components/menu/menu.stories.tsx b/packages/design/src/components/menu/menu.stories.tsxdeleted file mode 100644index 0403fe73d4..0000000000--- a/packages/design/src/components/menu/menu.stories.tsx+++ /dev/null@@ -1,145 +0,0 @@-/**- * 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 { CopyIcon, CutIcon, DeleteIcon } from '@univerjs/icons';-import { Menu, MenuItem, MenuItemGroup, SubMenu, TinyMenuGroup } from './Menu';--export default {- title: 'Components / Menu',- component: Menu,- parameters: {- layout: 'centered',- },- tags: ['autodocs'],-};--export const Default = () => {- return (- <Menu>- <TinyMenuGroup- items={[- {- onClick: () => {},- className: '',- Icon: CopyIcon,- key: 'copy',- },- {- onClick: () => {},- className: '',- Icon: CutIcon,- key: 'cut',- },- {- onClick: () => {},- className: '',- Icon: DeleteIcon,- key: 'delete',- },- {- onClick: () => {},- className: '',- Icon: CopyIcon,- key: 'copy1',- },- {- onClick: () => {},- className: '',- Icon: CutIcon,- key: 'cut1',- },- {- onClick: () => {},- className: '',- Icon: DeleteIcon,- key: 'delete1',- },- {- onClick: () => {},- className: '',- Icon: CopyIcon,- key: 'copy2',- },- {- onClick: () => {},- className: '',- Icon: CutIcon,- key: 'cut2',- },- {- onClick: () => {},- className: '',- Icon: DeleteIcon,- key: 'delete2',- },- ]}- />- <MenuItemGroup>- <MenuItem>- <CopyIcon />- Item 1- </MenuItem>- <MenuItem>- <CutIcon />- Item 2- </MenuItem>- <MenuItem>- <DeleteIcon />- Item 3- </MenuItem>- </MenuItemGroup>- <MenuItemGroup title="Group 1">- <MenuItem>- <CopyIcon />- Item 4- </MenuItem>- <MenuItem>- <CutIcon />- Item 5- </MenuItem>- </MenuItemGroup>- <MenuItemGroup>- <SubMenu- title={(- <div>- <CopyIcon />- SubMenu- </div>- )}- >- <MenuItemGroup>- <MenuItem>- <CopyIcon />- Item 6- </MenuItem>- </MenuItemGroup>- </SubMenu>- <SubMenu title="SubMenu2">- <MenuItemGroup>- <MenuItem>- <CopyIcon />- Item 7- </MenuItem>- <MenuItem>- <CutIcon />- Item 8- </MenuItem>- </MenuItemGroup>- </SubMenu>- </MenuItemGroup>- </Menu>- );-};diff --git a/packages/design/src/index.ts b/packages/design/src/index.tsindex 20a342b98a..04ae604a8f 100644--- a/packages/design/src/index.ts+++ b/packages/design/src/index.ts@@ -41,7 +41,6 @@ export { HoverCard, type IHoverCardProps } from './components/hover-card/HoverCaexport { type IInputNumberProps, InputNumber } from './components/input-number/InputNumber';export { type IInputProps, Input } from './components/input/Input';export { type IKBDProps, KBD } from './components/kbd/Kbd';-export { Menu, MenuItem, MenuItemGroup, type MenuRef, SubMenu, TinyMenuGroup } from './components/menu';export { type IMessageProps, message, Messager, MessageType, removeMessage } from './components/message/Message';export { type IPagerProps, Pager } from './components/pager/Pager';export { type IPopupProps, Popup } from './components/popup';diff --git a/packages/docs-quick-insert-ui/src/views/QuickInsertMenu.tsx b/packages/docs-quick-insert-ui/src/views/QuickInsertMenu.tsxnew file mode 100644index 0000000000..c2c9d8d627--- /dev/null+++ b/packages/docs-quick-insert-ui/src/views/QuickInsertMenu.tsx@@ -0,0 +1,168 @@+/**+ * 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 { ComponentManager } from '@univerjs/ui';+import type { MutableRefObject } from 'react';+import type { DocPopupMenu, IDocPopupMenuItem } from '../services/doc-quick-insert-popup.service';+import { borderBottomClassName, borderClassName, clsx, scrollbarClassName, Tooltip } from '@univerjs/design';+import { useEffect, useMemo, useRef } from 'react';++interface IQuickInsertMenuProps {+ menus: DocPopupMenu[];+ focusedMenuIndex: number;+ focusedMenuRef: MutableRefObject<IDocPopupMenuItem | null>;+ menuNodeMapRef: MutableRefObject<Map<string, HTMLElement>>;+ componentManager: ComponentManager;+ onFocusedMenuIndexChange: (index: number) => void;+ onSelect: (menu: IDocPopupMenuItem) => void;+}++function isMenuGroup(menu: DocPopupMenu): menu is DocPopupMenu & { children: IDocPopupMenuItem[] } {+ return 'children' in menu;+}++function flattenMenuItems(menus: DocPopupMenu[]): IDocPopupMenuItem[] {+ return menus.flatMap((menu) => {+ if (isMenuGroup(menu)) {+ return flattenMenuItems(menu.children);+ }++ return menu;+ });+}++export function getQuickInsertMenuLeafCount(menus: DocPopupMenu[]) {+ return flattenMenuItems(menus).length;+}++export function QuickInsertMenu(props: IQuickInsertMenuProps) {+ const {+ menus,+ focusedMenuIndex,+ focusedMenuRef,+ menuNodeMapRef,+ componentManager,+ onFocusedMenuIndexChange,+ onSelect,+ } = props;++ const flatMenus = useMemo(() => flattenMenuItems(menus), [menus]);++ useEffect(() => {+ const focusedMenu = Number.isNaN(focusedMenuIndex)+ ? null+ : flatMenus[focusedMenuIndex] ?? null;++ focusedMenuRef.current = focusedMenu;++ if (!focusedMenu) {+ return;+ }++ menuNodeMapRef.current.get(focusedMenu.id)?.scrollIntoView({+ block: 'nearest',+ });+ }, [flatMenus, focusedMenuIndex, focusedMenuRef, menuNodeMapRef]);++ const itemIndexRef = useRef(0);+ itemIndexRef.current = 0;++ function renderMenus(currentMenus: DocPopupMenu[]) {+ return currentMenus.map((menu, index) => {+ const iconKey = menu.icon;+ const Icon = iconKey ? componentManager.get(iconKey) : null;++ if (isMenuGroup(menu)) {+ return (+ <div+ key={menu.id}+ className={clsx('univer-grid univer-gap-1 univer-py-1', index !== currentMenus.length - 1 && borderBottomClassName)}+ >+ <div+ className={`+ univer-box-border univer-inline-flex univer-items-center univer-gap-2 univer-px-2+ univer-text-xs univer-font-semibold univer-text-gray-600+ dark:!univer-text-gray-300+ `}+ >+ {Icon && <span className="univer-inline-flex univer-text-base"><Icon /></span>}+ <span>{menu.title}</span>+ </div>+ <div className="univer-grid univer-gap-1">+ {renderMenus(menu.children)}+ </div>+ </div>+ );+ }++ const currentMenuIndex = itemIndexRef.current;+ const isFocused = focusedMenuIndex === currentMenuIndex;+ itemIndexRef.current += 1;++ return (+ <div+ key={menu.id}+ ref={(node) => {+ if (node) {+ menuNodeMapRef.current.set(menu.id, node);+ return;+ }++ menuNodeMapRef.current.delete(menu.id);+ }}+ role="button"+ tabIndex={-1}+ className={clsx(`+ univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer+ univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none+ univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-900+ univer-outline-none+ hover:univer-bg-gray-50+ dark:!univer-text-white+ dark:hover:!univer-bg-gray-600+ `, {+ 'hover:univer-bg-transparent': !isFocused,+ 'univer-bg-gray-50 dark:!univer-bg-gray-600': isFocused,+ })}+ onMouseEnter={() => onFocusedMenuIndexChange(currentMenuIndex)}+ onMouseLeave={() => onFocusedMenuIndexChange(Number.NaN)}+ onClick={() => onSelect(menu)}+ >+ <div className="univer-inline-flex univer-w-full univer-items-center univer-gap-2">+ {Icon && <span className="univer-inline-flex univer-text-base"><Icon /></span>}+ <Tooltip showIfEllipsis title={menu.title} placement="right">+ <span className="univer-truncate">{menu.title}</span>+ </Tooltip>+ </div>+ </div>+ );+ });+ }++ return (+ <div+ className={clsx(`+ univer-box-border univer-grid univer-max-h-[360px] univer-gap-1 univer-overflow-y-auto+ univer-overflow-x-hidden univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2+ univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md+ dark:!univer-bg-gray-700 dark:!univer-text-white+ `, borderClassName, scrollbarClassName)}+ onWheel={(event) => event.stopPropagation()}+ >+ {renderMenus(menus)}+ </div>+ );+}diff --git a/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsx b/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsxindex 431407c94b..4a2a8916fc 100644--- a/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsx+++ b/packages/docs-quick-insert-ui/src/views/QuickInsertPopup.tsx@@ -16,11 +16,11 @@import type { DocPopupMenu, IDocPopupMenuItem } from '../services/doc-quick-insert-popup.service';import { CommandType, Direction, DisposableCollection, generateRandomId, ICommandService, LocaleService, toDisposable } from '@univerjs/core';-import { clsx, Menu, MenuItem, MenuItemGroup, scrollbarClassName, Tooltip } from '@univerjs/design';import { ComponentManager, IShortcutService, KeyCode, useDependency, useObservable } from '@univerjs/ui';import { useEffect, useMemo, useRef, useState } from 'react';import { CloseQuickInsertPopupOperation } from '../commands/operations/quick-insert-popup.operation';import { DocQuickInsertPopupService } from '../services/doc-quick-insert-popup.service';+import { getQuickInsertMenuLeafCount, QuickInsertMenu } from './QuickInsertMenu';import { QuickInsertPlaceholder } from './QuickInsertPlaceholder';function filterMenusByKeyword(menus: DocPopupMenu[], keyword: string) {@@ -76,9 +76,6 @@ export const QuickInsertPopup = () => {const [focusedMenuIndex, setFocusedMenuIndex] = useState(0);const focusedMenuRef = useRef<IDocPopupMenuItem | null>(null);- const menuIndexAccumulator = useRef(0);- menuIndexAccumulator.current = 0;-const filterKeyword = useObservable(docQuickInsertPopupService.filterKeyword$, '');const currentPopup = useObservable(docQuickInsertPopupService.editPopup$);const menus = useObservable<DocPopupMenu[]>(currentPopup?.popup.menus$, []);@@ -90,6 +87,12 @@ export const QuickInsertPopup = () => {const [filteredMenus, setFilteredMenus] = useState<DocPopupMenu[]>(() => {return filterMenusByKeyword(translatedMenus, filterKeyword.toLowerCase());});+ const filteredMenuCount = useMemo(() => getQuickInsertMenuLeafCount(filteredMenus), [filteredMenus]);+ const filteredMenuCountRef = useRef(filteredMenuCount);++ useEffect(() => {+ filteredMenuCountRef.current = filteredMenuCount;+ }, [filteredMenuCount]);useEffect(() => {const id = requestIdleCallback(() => {@@ -140,9 +143,13 @@ export const QuickInsertPopup = () => {type: CommandType.OPERATION,handler: () => {setFocusedMenuIndex((index) => {+ if (filteredMenuCountRef.current <= 0) {+ return 0;+ }+const nextIndex = (index - 1);- return nextIndex >= 0 ? nextIndex : menuIndexAccumulator.current - 1;+ return nextIndex >= 0 ? nextIndex : filteredMenuCountRef.current - 1;});},};@@ -151,9 +158,13 @@ export const QuickInsertPopup = () => {type: CommandType.OPERATION,handler: () => {setFocusedMenuIndex((index) => {+ if (filteredMenuCountRef.current <= 0) {+ return 0;+ }+const nextIndex = (index + 1);- return nextIndex <= (menuIndexAccumulator.current - 1) ? nextIndex : 0;+ return nextIndex <= (filteredMenuCountRef.current - 1) ? nextIndex : 0;});},};@@ -192,7 +203,7 @@ export const QuickInsertPopup = () => {return () => {disposableCollection.dispose();};- }, []);+ }, [commandService, id, shortcutService]);useEffect(() => {setFocusedMenuIndex(0);@@ -206,75 +217,6 @@ export const QuickInsertPopup = () => {};}, []);- function renderMenus(menus: DocPopupMenu[]) {- return menus.map((menu) => {- const iconKey = (menu as IDocPopupMenuItem).icon;- const Icon = iconKey ? componentManager.get(iconKey) : null;-- if ('children' in menu) {- return (- <MenuItemGroup- key={menu.id}- title={(- <div- className={`- univer-mb-2 univer-flex univer-items-center univer-text-xs univer-text-gray-400- `}- >- {Icon && <span className="univer-mr-2 univer-inline-flex univer-text-base"><Icon /></span>}- <span>{menu.title}</span>- </div>- )}- >- {renderMenus(menu.children!)}- </MenuItemGroup>- );- }-- const currentMenuIndex = menuIndexAccumulator.current;- const isFocused = focusedMenuIndex === currentMenuIndex;- if (isFocused) {- focusedMenuRef.current = menu as IDocPopupMenuItem;- const node = menuNodeMapRef.current.get(menu.id);- node?.scrollIntoView({- block: 'nearest',- });- }-- menuIndexAccumulator.current++;-- return (- <MenuItem- // @ts-expect-error- ref={(node) => {- if (node) {- menuNodeMapRef.current.set(menu.id, node);- }- }}- onMouseEnter={() => setFocusedMenuIndex(currentMenuIndex)}- onMouseLeave={() => setFocusedMenuIndex(Number.NaN)}- key={menu.id}- className={clsx('univer-w-[calc(220px-var(--padding-base)*2)] univer-text-sm', {- 'hover:univer-bg-transparent': !isFocused,- 'univer-bg-gray-100 dark:!univer-bg-gray-500': isFocused,- })}- onClick={() => {- handleMenuSelect(menu as IDocPopupMenuItem);- }}- >- <div- className="univer-flex univer-w-full univer-items-center univer-px-1"- >- {Icon && <span className="univer-mr-2 univer-inline-flex univer-text-base"><Icon /></span>}- <Tooltip showIfEllipsis title={menu.title} placement="right">- <span className="univer-truncate">{menu.title}</span>- </Tooltip>- </div>- </MenuItem>- );- });- }-const hasMenus = filteredMenus.length > 0;const Placeholder = currentPopup?.popup.Placeholder || componentManager.get(QuickInsertPlaceholder.componentKey);@@ -283,13 +225,15 @@ export const QuickInsertPopup = () => {<div className="univer-mt-2">{hasMenus? (- <Menu- wrapperClass={clsx(`- univer-max-h-[360px] univer-w-[220px] univer-overflow-y-auto univer-overflow-x-hidden- `, scrollbarClassName)}- >- {renderMenus(filteredMenus)}- </Menu>+ <QuickInsertMenu+ menus={filteredMenus}+ focusedMenuIndex={focusedMenuIndex}+ focusedMenuRef={focusedMenuRef}+ menuNodeMapRef={menuNodeMapRef}+ componentManager={componentManager}+ onFocusedMenuIndexChange={setFocusedMenuIndex}+ onSelect={handleMenuSelect}+ />): Placeholder && <Placeholder />}</div>diff --git a/packages/docs-ui/src/components/paragraph-menu/index.tsx b/packages/docs-ui/src/components/paragraph-menu/index.tsxindex f28cb9050a..79801454ca 100644--- a/packages/docs-ui/src/components/paragraph-menu/index.tsx+++ b/packages/docs-ui/src/components/paragraph-menu/index.tsx@@ -20,7 +20,7 @@ import { ICommandService, IUniverInstanceService, NamedStyleType, UniverInstanceimport { borderClassName, clsx } from '@univerjs/design';import { IRenderManagerService } from '@univerjs/engine-render';import { DownIcon } from '@univerjs/icons';-import { ContextMenuPosition, DesktopMenu, ILayoutService, RectPopup, useDependency, useObservable } from '@univerjs/ui';+import { ContextMenuPanel, ContextMenuPosition, ILayoutService, RectPopup, useDependency, useObservable } from '@univerjs/ui';import { useMemo, useRef, useState } from 'react';import { BehaviorSubject } from 'rxjs';import { HEADING_ICON_MAP } from '../../menu/paragraph-menu';@@ -123,8 +123,8 @@ export const ParagraphMenu = ({ popup }: { popup: IPopup }) => {isMouseOver.current = false;}}>- <DesktopMenu- style={{ width: 212 }}+ <ContextMenuPanel+ className="univer-w-[212px]"menuType={ContextMenuPosition.PARAGRAPH}onOptionSelect={(params) => {const { label: id, commandId, value } = params;diff --git a/packages/design/src/components/menu/Menu.tsx b/packages/ui/src/components/menu/desktop/DesignTinyMenuGroup.tsxsimilarity index 62%rename from packages/design/src/components/menu/Menu.tsxrename to packages/ui/src/components/menu/desktop/DesignTinyMenuGroup.tsxindex 35cd114064..001d588b8d 100644--- a/packages/design/src/components/menu/Menu.tsx+++ b/packages/ui/src/components/menu/desktop/DesignTinyMenuGroup.tsx@@ -14,44 +14,8 @@* limitations under the License.*/-import type { MenuItemGroupProps, MenuItemProps, MenuProps, MenuRef, SubMenuProps } from 'rc-menu';import type { ComponentType } from 'react';-import RcMenu, { MenuItem as RcMenuItem, MenuItemGroup as RcMenuItemGroup, SubMenu as RcSubMenu } from 'rc-menu';-import { forwardRef, useContext } from 'react';-import { clsx } from '../../helper/clsx';-import { ConfigContext } from '../config-provider/ConfigProvider';-import { Tooltip } from '../tooltip/Tooltip';-import './index.css';--/** @deprecated */-export const Menu = forwardRef<MenuRef, MenuProps & { wrapperClass?: string }>((props, ref) => {- const { mountContainer } = useContext(ConfigContext);- const { wrapperClass, ...rest } = props;- return mountContainer && (- <RcMenu- ref={ref}- prefixCls={clsx('univer-menu', props.className)}- getPopupContainer={() => mountContainer}- {...rest}- className={wrapperClass}- />- );-});--/** @deprecated */-export function MenuItem(props: MenuItemProps) {- return <RcMenuItem {...props} />;-}--/** @deprecated */-export function SubMenu(props: SubMenuProps) {- return <RcSubMenu {...props} />;-}--/** @deprecated */-export function MenuItemGroup(props: MenuItemGroupProps) {- return <RcMenuItemGroup {...props} />;-}+import { clsx, Tooltip } from '@univerjs/design';export interface ITinyMenuItem {onClick: () => void;@@ -66,7 +30,7 @@ export interface ITinyMenuGroupProps {items: ITinyMenuItem[];}-export function TinyMenuGroup({ items }: ITinyMenuGroupProps) {+export function DesignTinyMenuGroup({ items }: ITinyMenuGroupProps) {return (<divclassName="univer-menu-item-group univer-flex univer-flex-wrap univer-gap-2.5 univer-p-1 univer-px-0"@@ -99,9 +63,7 @@ export function TinyMenuGroup({ items }: ITinyMenuGroupProps) {{ele}</Tooltip>)- : (- ele- );+ : ele;})}</div>);diff --git a/packages/ui/src/components/menu/desktop/Menu.tsx b/packages/ui/src/components/menu/desktop/Menu.tsxdeleted file mode 100644index 453e31e8dc..0000000000--- a/packages/ui/src/components/menu/desktop/Menu.tsx+++ /dev/null@@ -1,362 +0,0 @@-/**- * 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 { MenuRef } from '@univerjs/design';-import type {- IDisplayMenuItem,- IMenuButtonItem,- IMenuItem,- IMenuSelectorItem,- IValueOption,- MenuItemDefaultValueType,-} from '../../../services/menu/menu';-import { isRealNum, LocaleService } from '@univerjs/core';-import {- clsx,- Menu as DesignMenu,- MenuItem as DesignMenuItem,- MenuItemGroup as DesignMenuItemGroup,- SubMenu as DesignSubMenu,-} from '@univerjs/design';-import { CheckMarkIcon, MoreIcon } from '@univerjs/icons';-import { useEffect, useMemo, useState } from 'react';-import { combineLatest, isObservable, of } from 'rxjs';-import { ILayoutService } from '../../../services/layout/layout.service';-import { MenuItemType } from '../../../services/menu/menu';-import { IMenuManagerService } from '../../../services/menu/menu-manager.service';-import { ContextMenuGroup } from '../../../services/menu/types';-import { useDependency, useObservable } from '../../../utils/di';-import { CustomLabel } from '../../custom-label/CustomLabel';-import { useScrollYOverContainer } from '../../hooks/layout';-import { UITinyMenuGroup } from './TinyMenuGroup';--const contentClassName = 'univer-inline-flex univer-gap-2 univer-items-center';-const moreIconClassName = 'univer-size-3.5 univer-text-gray-900 dark:!univer-text-white';--/** @deprecated */-export interface IBaseMenuProps {- parentKey?: string | number;- menuType?: string;-- value?: string | number;- options?: IValueOption[];- /**- * The menu will show scroll on it over viewport height- * Recommend that you use this prop when displaying menu overlays in Dropdown- */- overViewport?: 'scroll';- onOptionSelect?: (option: IValueOption) => void;- style?: React.CSSProperties;-}--/** @deprecated */-function MenuWrapper(props: IBaseMenuProps) {- const { menuType, onOptionSelect } = props;- const localeService = useDependency(LocaleService);- const menuManagerService = useDependency(IMenuManagerService);-- const menuItems = useMemo(() => menuType ? menuManagerService.getMenuByPositionKey(menuType) : [], [menuType, menuManagerService]);-- const [hiddenStates, setHiddenStates] = useState<Record<string, boolean>>({});- const filteredMenuItems = useMemo(() => {- return menuItems.filter((item) => {- if (!item.children) return item;-- const itemKey = item.key?.toString() || '';- return !hiddenStates[itemKey];- });- }, [menuItems, hiddenStates]);-- useEffect(() => {- const subscriptions = menuItems.map((item) => {- if (!item.children) return null;-- const hiddenObservables = item.children.map((subItem) => subItem.item?.hidden$ ?? of(false));-- return combineLatest(hiddenObservables).subscribe((hiddenValues) => {- const isAllHidden = hiddenValues.every((hidden) => hidden === true);- setHiddenStates((prev) => ({- ...prev,- [item.key]: isAllHidden,- }));- });- });-- return () => {- subscriptions.forEach((sub) => sub?.unsubscribe());- setHiddenStates({});- };- }, [menuItems]);-- if (!menuType) {- return null;- };-- return filteredMenuItems && filteredMenuItems.map((item) => item.item- ? (- <MenuItem- key={item.key}- menuItem={item.item}- onClick={(object: Partial<IValueOption>) => {- onOptionSelect?.({ value: '', label: item.key, ...object });- }}- />- )- : item.children?.length- ? item.key === ContextMenuGroup.QUICK- ? <UITinyMenuGroup key={item.key} item={item} onOptionSelect={onOptionSelect} />- : (- <DesignMenuItemGroup key={item.key} eventKey={item.key} title={item.title ? localeService.t(item.title) : undefined}>- {item.children.map((child) => (- child.item && (- <MenuItem- key={child.key}- menuItem={child.item}- onClick={(object: Partial<IValueOption>) => {- onOptionSelect?.({ value: '', label: child.key, ...object });- }}- />- )- ))}- </DesignMenuItemGroup>- )- : null);-}--/** @deprecated */-function MenuOptionsWrapper(props: IBaseMenuProps) {- const { options, value, onOptionSelect, parentKey } = props;-- return options?.map((option: IValueOption, index: number) => {- const key = `${parentKey}-${option.label ?? option.id}-${index}`;-- const onChange = (v: string | number) => {- onOptionSelect?.({ value: v, label: option?.label, commandId: option?.commandId });- };-- const handleClick = () => {- if (typeof option.value === 'undefined') return;-- onOptionSelect?.({- ...option,- });- };-- const _className = clsx({- 'univer-bg-none': typeof option.label !== 'string' && !option.label?.hoverable,- });-- return (- <DesignMenuItem disabled={option.disabled} key={key} eventKey={key} className={_className} onClick={handleClick}>- <span- className={clsx(contentClassName, {- 'univer-relative univer-pl-5': !(- typeof option.label !== 'string' && !option.label?.hoverable- ),- })}- >- {typeof value !== 'undefined' && String(value) === String(option.value) && (- <span className="univer-absolute univer-left-0 univer-inline-flex univer-items-center">- <CheckMarkIcon className="univer-text-primary-600" />- </span>- )}- <CustomLabel- value$={option.value$}- value={option.value}- label={option.label}- icon={option.icon}- onChange={onChange}- />- </span>- </DesignMenuItem>- );- }) ?? null;-}--/** @deprecated */-export const Menu = (props: IBaseMenuProps) => {- const { overViewport, style, ...restProps } = props;- const [menuEl, setMenuEl] = useState<HTMLDListElement>();- const layoutService = useDependency(ILayoutService);-- useScrollYOverContainer(overViewport === 'scroll' ? menuEl : null, layoutService.rootContainerElement);-- function handleSetMenuEl(ref: MenuRef | null) {- if (ref) {- setMenuEl(ref.list);- }- }- return (- <DesignMenu- style={style}- ref={handleSetMenuEl}- selectable={false}- >- <MenuOptionsWrapper {...restProps} />- <MenuWrapper {...restProps} />- </DesignMenu>- );-};--/** @deprecated */-interface IMenuItemProps {- menuItem: IDisplayMenuItem<IMenuItem>;- onClick: (object: Partial<IValueOption>) => void;-}--/** @deprecated */-function MenuItem({ menuItem, onClick }: IMenuItemProps) {- const menuManagerService = useDependency(IMenuManagerService);- const disabled = useObservable<boolean>(menuItem.disabled$, false);- const activated = useObservable<boolean>(menuItem.activated$, false);- const hidden = useObservable(menuItem.hidden$, false);- const value = useObservable<MenuItemDefaultValueType>(menuItem.value$);- const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;- const selectionsFromObservable = useObservable(isObservable(item.selections) ? item.selections : undefined);- const [inputValue, setInputValue] = useState(value);-- useEffect(() => {- setInputValue(value);- }, [value]);-- if (hidden) {- return null;- }- /**- * user input change value from CustomLabel- * @param v- */- const onChange = (v: string | number) => {- const newValue = isRealNum(v) && typeof v === 'string' ? Number.parseInt(v) : v;- setInputValue(newValue);- };-- const renderButtonType = () => {- const item = menuItem as IDisplayMenuItem<IMenuButtonItem>;- const { title, label } = item;-- return (- <DesignMenuItem- key={item.id}- eventKey={item.id}- disabled={disabled}- className={clsx({- 'univer-bg-gray-200': activated,- })}- onClick={() => {- onClick({ commandId: item.commandId, value: inputValue, id: item.id });- }}- >- <span className={contentClassName}>- <CustomLabel- value={value}- title={title}- label={label}- icon={item.icon}- onChange={onChange}- />- </span>- </DesignMenuItem>- );- };-- const renderSelectorType = () => {- const selections = selectionsFromObservable ?? (item.selections as IValueOption[] | undefined) ?? [];-- if (selections.length > 0) {- return (- <DesignSubMenu- key={item.id}- eventKey={item.id}- popupOffset={[18, 0]}- title={(- <span className={contentClassName}>- <CustomLabel- title={item.title}- value={inputValue}- onChange={onChange}- icon={item.icon}- label={item.label}- />- {item.shortcut && ` (${item.shortcut})`}- </span>- )}- expandIcon={<MoreIcon className={moreIconClassName} />}- >- <DesignMenuItemGroup>- {selections.length > 0 && (- <MenuOptionsWrapper- parentKey={item.id}- menuType={item.id}- options={selections}- onOptionSelect={(v) => {- onClick({ value: v.value, id: item.id, commandId: v.commandId });- }}- />- )}- </DesignMenuItemGroup>- </DesignSubMenu>- );- }-- return (- <DesignMenuItem key={item.id} eventKey={item.id}>- <span className={contentClassName}>- <CustomLabel- title={item.title}- value={inputValue}- icon={item.icon}- label={item.label}- onChange={onChange}- />- {item.shortcut && ` (${item.shortcut})`}- </span>- </DesignMenuItem>- );- };-- const subMenuItems = menuItem.id ? menuManagerService.getMenuByPositionKey(menuItem.id) : [];-- const renderSubItemsType = () => {- const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;-- return (- <DesignSubMenu- key={item.id}- eventKey={item.id}- popupOffset={[18, 0]}- title={(- <span className={contentClassName}>- <CustomLabel title={item.title} icon={item.icon} label={item.label} onChange={onChange} />- </span>- )}- expandIcon={<MoreIcon className={moreIconClassName} />}- >- <DesignMenuItemGroup>- {subMenuItems.length && <MenuWrapper menuType={item.id} parentKey={item.id} onOptionSelect={onClick} />}- </DesignMenuItemGroup>- </DesignSubMenu>- );- };-- return (- <>- {menuItem.type === MenuItemType.SELECTOR && renderSelectorType()}- {menuItem.type === MenuItemType.SUBITEMS && renderSubItemsType()}- {menuItem.type === MenuItemType.BUTTON && renderButtonType()}- </>- );-}diff --git a/packages/ui/src/components/menu/desktop/TinyMenuGroup.tsx b/packages/ui/src/components/menu/desktop/TinyMenuGroup.tsxindex de52826b16..488a567563 100644--- a/packages/ui/src/components/menu/desktop/TinyMenuGroup.tsx+++ b/packages/ui/src/components/menu/desktop/TinyMenuGroup.tsx@@ -17,11 +17,12 @@import type { IDisplayMenuItem, IMenuItem, IValueOption } from '../../../services/menu/menu';import type { IMenuSchema } from '../../../services/menu/menu-manager.service';import { convertObservableToBehaviorSubject, LocaleService } from '@univerjs/core';-import { clsx, TinyMenuGroup as DesignTinyMenuGroup } from '@univerjs/design';+import { clsx } from '@univerjs/design';import { useEffect, useState } from 'react';import { combineLatest, of } from 'rxjs';import { ComponentManager } from '../../../common';import { useDependency, useObservable } from '../../../utils/di';+import { DesignTinyMenuGroup } from './DesignTinyMenuGroup';interface IUIQuickMenuGroupProps {item: IMenuSchema;diff --git a/packages/ui/src/components/menu/mobile/MobileMenu.tsx b/packages/ui/src/components/menu/mobile/MobileMenu.tsxindex bdf0591644..9ec6850b82 100644--- a/packages/ui/src/components/menu/mobile/MobileMenu.tsx+++ b/packages/ui/src/components/menu/mobile/MobileMenu.tsx@@ -16,7 +16,7 @@import type { IDisplayMenuItem, IMenuButtonItem, IMenuItem, IMenuSelectorItem, IValueOption, MenuItemDefaultValueType } from '../../../services/menu/menu';import type { IMenuSchema } from '../../../services/menu/menu-manager.service';-import type { IBaseMenuProps } from '../desktop/Menu';+import type { IBaseMenuProps } from '../types';import { LocaleService } from '@univerjs/core';import { borderBottomClassName, clsx } from '@univerjs/design';import { CheckMarkIcon, MoreIcon, MoreLeftIcon } from '@univerjs/icons';diff --git a/packages/design/src/components/menu/index.ts b/packages/ui/src/components/menu/types.tssimilarity index 55%rename from packages/design/src/components/menu/index.tsrename to packages/ui/src/components/menu/types.tsindex fa27493651..1efb472ce3 100644--- a/packages/design/src/components/menu/index.ts+++ b/packages/ui/src/components/menu/types.ts@@ -14,5 +14,19 @@* limitations under the License.*/-export { Menu, MenuItem, MenuItemGroup, SubMenu, TinyMenuGroup } from './Menu';-export type { MenuRef } from 'rc-menu';+import type { IValueOption } from '../../services/menu/menu';++export interface IBaseMenuProps {+ parentKey?: string | number;+ menuType?: string;++ value?: string | number;+ options?: IValueOption[];+ /**+ * The menu will show scroll on it over viewport height+ * Recommend that you use this prop when displaying menu overlays in Dropdown+ */+ overViewport?: 'scroll';+ onOptionSelect?: (option: IValueOption) => void;+ style?: React.CSSProperties;+}diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex 422eeb7f47..820c84d342 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -29,8 +29,6 @@ export { FontSize } from './components/font-size/FontSize';export { FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HEADING_LIST } from './components/font-size/interface';export * from './components/hooks';export { t } from './components/hooks/locale';-export { Menu as UIMenu } from './components/menu/desktop/Menu';-export { Menu as DesktopMenu } from './components/menu/desktop/Menu';export { type INotificationOptions } from './components/notification/Notification';export { ProgressBar } from './components/progress-bar/ProgressBar';export { type IUniverUIConfig, UI_PLUGIN_CONFIG_KEY } from './config/config';@@ -130,6 +128,7 @@ export type { IConfirmChildrenProps } from './views/components/confirm-part/inteexport { type IConfirmPartMethodOptions } from './views/components/confirm-part/interface';export { AnchoredContextMenu, type IContextMenuAnchorRect } from './views/components/context-menu/AnchoredContextMenu';export { DesktopContextMenu as ContextMenu } from './views/components/context-menu/ContextMenu';+export { ContextMenuPanel } from './views/components/context-menu/ContextMenuPanel';export { MobileContextMenu } from './views/components/context-menu/MobileContextMenu';export { type IDialogPartMethodOptions } from './views/components/dialog-part/interface';export { FloatDomSingle } from './views/components/dom/FloatDom';diff --git a/packages/ui/src/views/components/context-menu/ContextMenuPanel.tsx b/packages/ui/src/views/components/context-menu/ContextMenuPanel.tsxindex b85092641f..8f8f8557a2 100644--- a/packages/ui/src/views/components/context-menu/ContextMenuPanel.tsx+++ b/packages/ui/src/views/components/context-menu/ContextMenuPanel.tsx@@ -40,6 +40,7 @@ import { useDependency, useObservable } from '../../../utils/di';interface IContextMenuPanelProps {menuType: string;menuSessionVersion?: number;+ className?: string;onOptionSelect?: (option: IValueOption) => void;}@@ -65,7 +66,7 @@ const submenuVisualGap = 20;export const CONTEXT_MENU_SUBMENU_PORTAL_ATTR = 'data-u-context-menu-submenu';export function ContextMenuPanel(props: IContextMenuPanelProps) {- const { menuType, menuSessionVersion = 0, onOptionSelect } = props;+ const { menuType, menuSessionVersion = 0, className, onOptionSelect } = props;const menuManagerService = useDependency(IMenuManagerService);const layoutService = useDependency(ILayoutService);const [menuElement, setMenuElement] = useState<HTMLDivElement | null>(null);@@ -136,7 +137,8 @@ export function ContextMenuPanel(props: IContextMenuPanelProps) {dark:!univer-bg-gray-700 dark:!univer-text-white`,borderClassName,- scrollbarClassName+ scrollbarClassName,+ className)}style={{maxHeight: maxMenuHeight,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 79fcf9eebc..17b6c61275 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -780,8 +780,8 @@ importers:specifier: ^1.4.1version: 1.4.1dayjs:- specifier: ^1.11.19- version: 1.11.19+ specifier: ^1.11.20+ version: 1.11.20fast-diff:specifier: 1.3.0version: 1.3.0@@ -792,8 +792,8 @@ importers:specifier: ^4.17.23version: 4.17.23nanoid:- specifier: 5.1.6- version: 5.1.6+ specifier: 5.1.7+ version: 5.1.7numfmt:specifier: ^3.2.3version: 3.2.3@@ -881,14 +881,8 @@ importers:specifier: ^2.1.1version: 2.1.1dayjs:- specifier: ^1.11.19- version: 1.11.19- rc-dropdown:- specifier: ^4.2.1- rc-menu:- specifier: ^9.16.0+ specifier: ^1.11.20+ version: 1.11.20react-transition-group:specifier: ^4.4.5@@ -4999,20 +4993,6 @@ packages:'@radix-ui/[email protected]':resolution: {integrity: sha512-HPwpGIzkl28mWyZqG52jiqDJ12waP11Pa1lGoiyUkIEuMLBP0oeK/C89esbXrxsky5we7dfd8U58nm0SgAWpVw==}- '@rc-component/[email protected]':- resolution: {integrity: sha512-6f813C0IsasTZms08kfA8kPAGxbbkYToa8ALaiDIGGECU4i9hj8Plgbx0sNJDrey3EtHO30hmdaxtT0138xZcg==}- engines: {node: '>=8.x'}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-- '@rc-component/[email protected]':- resolution: {integrity: sha512-/9zuTnWwhQ3S3WT1T8BubuFTT46kvnXgaERR9f4BTKyn61/wpf/BvbImzYBubzJibU707FxwbKszLlHjcLiv1Q==}- engines: {node: '>=8.x'}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-'@react-dnd/[email protected]':resolution: {integrity: sha512-WLyfoHvxhs0V9U+GTsGilGgf2QsPl6ZZ44fnv0/b8T3nQyvzxidxsg/ZltbWssbsRDlYW8UKSQMTGotuTotZ6A==}@@ -6731,8 +6711,8 @@ packages:resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==}engines: {node: '>= 0.4'}- resolution: {integrity: sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==}+ resolution: {integrity: sha512-YbwwqR/uYpeoP4pu043q+LTDLFBLApUP6VxRihdfNTqu4ubqMlGDLd6ErXhEgsyvY0K6nCs7nggYumAN+9uEuQ==}resolution: {integrity: sha512-rBMW+F2TXryBwB54Q0d8drNEI+TfoS9JpNTAoVpukbWEhjXQq4rySFYLaqXMFXwdv61Zb2OHtj5bviSoimqxRQ==}@@ -8785,8 +8765,8 @@ packages:engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}hasBin: true- resolution: {integrity: sha512-c7+7RQ+dMB5dPwwCp4ee1/iV/q2P6aK1mTZcfr1BTuVlyW9hJYiMPybJCcnBlQtuSmTIWNeazm/zqNoZSSElBg==}+ resolution: {integrity: sha512-ua3NDgISf6jdwezAheMOk4mbE1LXjm1DfMUDMuJf4AqxLFK3ccGpgWizwa5YV7Yz9EpXwEaWoRXSb/BnV0t5dQ==}engines: {node: ^18 || >=20}hasBin: true@@ -9496,42 +9476,6 @@ packages:resolution: {integrity: sha512-IP0UpfeWQujYC8Jg162rMNc01Rf0gWMMAb2Uxus/Q0qOFw4lCcq6ZnQEZwUoJqWyUGJ9th7JjwI4yIWo+uvoAQ==}- resolution: {integrity: sha512-YDAlXsPv3I1n42dv1JpdM7wJ+gSUBfeyPK59ZpBD9jQhK9jVuxpjj3NmWQHOBceA1zEPVX84T2wbdb2SD0UjmA==}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-- resolution: {integrity: sha512-ghHx6/6Dvp+fw8CJhDUHFHDJ84hJE3BXNCzSgLdmNiFErWSOaZNsihDAsKq9ByTALo/xkNIwtDFGIl6r+RPXBg==}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-- resolution: {integrity: sha512-w+XTUrfh7ArbYEd2582uDrEhmBHwK1ZENJiSJVb7uRxdE7qJSYjbO2eksRXmndqyKqKoYPc9ClpPh5242mV1vA==}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-- resolution: {integrity: sha512-3MoPQQPV1uKyOMVNd6SZfONi+f3st0r8PksexIdBTeIYbMX0Jr+k7pHEDvsXtR4BpCv90/Pv2MovVNhktKrwvw==}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-- resolution: {integrity: sha512-YZLjUbyIWox8E9i9C3Tm7ia+W7euPItNWSPX5sCcQTYbnwDb5uNpnLHQCG1f22oZWUhLw4Mv2tFmeWe68CDQRQ==}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-- resolution: {integrity: sha512-resueRJzmHG9Q6rI/DfK6Kdv9/Lfls05vzMs1Sk3M2P+3cJa+MakaZyWY8IPfehVuhPJFKrIY1IK4GqbiaiY5w==}- peerDependencies:- react: 19.2.4- react-dom: 19.2.4-resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==}@@ -9601,9 +9545,6 @@ packages:resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}- resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==}-resolution: {integrity: sha512-Ivuj6AxRDlo/H8OiEDU1mdgivxuKbwGOa5Ub6Yf+bHcu0JWioT7ttlpCWF63/gKrJBlRMB6fW9/eNOXINg9+Gg==}peerDependencies:@@ -9745,9 +9686,6 @@ packages:resolution: {integrity: sha512-yE7KUfFvaBFzGPs5H3Ops1RevfUEsDc5Iz65rOwWg4lE8HJSYtle77uul3+573457oHvBKuHYDl/xqUkKpEEdw==}engines: {node: '>=18'}- resolution: {integrity: sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==}-resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}engines: {node: '>=4'}@@ -12893,25 +12831,6 @@ snapshots:'@radix-ui/[email protected]': {}- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])-- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])-'@react-dnd/[email protected]': {}'@react-dnd/[email protected]': {}@@ -14700,7 +14619,7 @@ snapshots:es-errors: 1.3.0is-data-view: 1.0.2- [email protected]: {}+ [email protected]: {}dependencies:@@ -17159,7 +17078,7 @@ snapshots:- [email protected]: {}+ [email protected]: {}@@ -17948,59 +17867,6 @@ snapshots:dependencies:quickselect: 3.0.0- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])-- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])-- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])-- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])-- dependencies:- '@babel/runtime': 7.27.1- classnames: 2.5.1- react: 19.2.4- react-dom: 19.2.4([email protected])- resize-observer-polyfill: 1.5.1-- dependencies:- '@babel/runtime': 7.27.1- react: 19.2.4- react-dom: 19.2.4([email protected])- react-is: 18.3.1-dependencies:defu: 6.1.4@@ -18099,8 +17965,6 @@ snapshots:- [email protected]: {}-[email protected](@types/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))([email protected]):dependencies:classnames: 2.5.1@@ -18290,8 +18154,6 @@ snapshots:- [email protected]: {}-