Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat: support grouping for menu (#324)

白熱a376b4b05d87
diff --git a/examples/univer-sheet-ts/src/locales.ts b/examples/univer-sheet-ts/src/locales.ts
index 7f4731baa7..c4f3e26363 100644
--- a/examples/univer-sheet-ts/src/locales.ts
+++ b/examples/univer-sheet-ts/src/locales.ts
@@ -1,5 +1,6 @@
import { zh as DocPluginZh } from '@univerjs/base-docs';
import { zh as SheetPluginZh } from '@univerjs/base-sheets';
+import { zh as BaseUiZh } from '@univerjs/base-ui';
import { zh as SheetDebuggerPluginZh } from '@univerjs/sheets-plugin-debugger';
import { zh as FindPluginZh } from '@univerjs/sheets-plugin-find';
import { zh as ImportXlsxPluginZh } from '@univerjs/sheets-plugin-import-xlsx';
@@ -17,5 +18,6 @@ export const locales = {
...DocUIPluginZh,
...SheetUIPluginZh,
...SheetDebuggerPluginZh,
+ ...BaseUiZh,
},
};
diff --git a/packages/base-ui/src/Common/ComponentManager.ts b/packages/base-ui/src/Common/ComponentManager.ts
index 7f65e0fe84..98a4f28f4a 100644
--- a/packages/base-ui/src/Common/ComponentManager.ts
+++ b/packages/base-ui/src/Common/ComponentManager.ts
@@ -1,4 +1,5 @@
import { IKeyValue } from '@univerjs/core';
+import { Copy24, PasteSpecial24 } from '@univerjs/icons';
import {
BorderDashDot,
@@ -52,7 +53,6 @@ import {
UnderLineIcon,
VerticalBorderIcon,
} from '../Components/Icon';
-import { Item } from '../Components/Item/Item';
export interface ICustomComponent {
name: string;
@@ -114,14 +114,14 @@ export class ComponentManager {
BorderMediumDashDotDot,
BorderThick,
FxIcon,
+
+ Copy24,
+ PasteSpecial24,
};
for (const k in iconList) {
this.register(k, iconList[k]);
}
-
- // Register common components
- this.register('Item', Item);
}
register(name: string, component: any) {
diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less b/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less
index b670bdc6c8..a445746e3e 100644
--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less
+++ b/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less
@@ -1,6 +1,7 @@
.color-select {
position: relative;
display: flex;
+ align-items: center;
.color-select-line {
position: absolute;
@@ -18,4 +19,12 @@
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
-}
\ No newline at end of file
+}
+
+.neo-custom-label {
+ &-item {
+ display: flex;
+ align-items: center;
+ gap: var(--margin-xs);
+ }
+}
diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
index 5093dd4fa9..dae6204fa5 100644
--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
+++ b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
@@ -1,9 +1,11 @@
-import { isValidElement, JSX, useContext } from 'react';
+import { LocaleService } from '@univerjs/core';
+import { Selectedo24 } from '@univerjs/icons';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+import React, { isValidElement, JSX } from 'react';
-import { AppContext, AppContextValues, ICustomComponent } from '../../Common';
+import { ComponentManager, ICustomComponent } from '../../Common';
import { IMenuSelectorItem } from '../../services/menu/menu';
import { Input } from '../Input';
-import { Item } from '../Item/Item';
import { DisplayTypes } from '../Select';
import styles from './CustomLabel.module.less';
@@ -17,10 +19,6 @@ export interface IBaseCustomLabelProps {
title?: string;
}
-function getLocale(context: Partial<AppContextValues>, name: string) {
- return context.localeService?.t(name) || name;
-}
-
export interface INeoCustomLabelProps {
value?: string | number | undefined;
selected?: boolean;
@@ -44,19 +42,24 @@ export function NeoCustomLabel(
props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'display' | 'title' | 'max' | 'min'> &
INeoCustomLabelProps
): JSX.Element | null {
- const context = useContext(AppContext);
const { display, value, title, icon, label, onChange, selected, onFocus, max, min } = props;
+ const localeService = useDependency(LocaleService);
+ const componentManager = useDependency(ComponentManager);
+
+ function getLocale(name: string) {
+ return localeService.t(name) ?? name;
+ }
if (display === DisplayTypes.COLOR) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- return <ColorSelect value={value as any} title={getLocale(context, title) as string} icon={icon} />;
+ return <ColorSelect value={value as any} title={getLocale(title) as string} icon={icon} />;
}
if (display === DisplayTypes.FONT) {
// According to the value, translate toolbar font
return (
<div className={styles.fontSelect} style={{ fontFamily: value as string }}>
- {getLocale(context, `fontFamily.${(`${value}` || '').replace(/\s/g, '')}`)}
+ {getLocale(`fontFamily.${(`${value}` || '').replace(/\s/g, '')}`)}
</div>
);
}
@@ -72,7 +75,7 @@ export function NeoCustomLabel(
style={{
width: '32px',
height: '24px',
- padding: '2px',
+ padding: '0',
textAlign: 'center',
background: 'transparent',
}}
@@ -84,7 +87,7 @@ export function NeoCustomLabel(
if (display === DisplayTypes.ICON && icon) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- const IconComponent = context.componentManager?.get(icon) as any;
+ const IconComponent = componentManager.get(icon) as any;
if (IconComponent) {
return <IconComponent {...props} />;
}
@@ -94,35 +97,41 @@ export function NeoCustomLabel(
const labelName = typeof label === 'string' ? label : (label as ICustomComponent).name;
const customProps = (label as ICustomComponent).props ?? {};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- const LabelComponent = context.componentManager?.get(labelName) as any;
+ const LabelComponent = componentManager.get(labelName) as any;
if (LabelComponent) {
return <LabelComponent {...customProps} {...props} />;
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- const LabelComponent = icon ? (context.componentManager?.get(icon) as any) : null;
+ const LabelComponent = icon ? (componentManager.get(icon) as any) : null;
// Process Font Family drop-down list font
return (
- <Item
- selected={selected}
- label={title}
- value={value}
- suffix={LabelComponent ? <LabelComponent /> : null}
- disabled={false}
+ <div
+ className={styles.neoCustomLabelItem}
style={{ fontFamily: title.indexOf('fontFamily.') === 0 ? `${value}` : 'inherit' }}
- ></Item>
+ >
+ {selected && (
+ <span className={styles.selectItemSelected}>
+ <Selectedo24 style={{ color: 'rgb(var(--success-color))' }} />
+ </span>
+ )}
+ {LabelComponent && <LabelComponent />}
+ <span className={styles.selectItemContent}>{getLocale(title)}</span>
+ </div>
);
}
/** @deprecated */
export function CustomLabel(props: IBaseCustomLabelProps): JSX.Element | null {
- const context = useContext(AppContext);
const { label, display, onChange } = props;
+ const localeService = useDependency(LocaleService);
+ const componentManager = useDependency(ComponentManager);
+
function getLocale(name: string) {
- return context.localeService?.t(name) ?? name;
+ return localeService.t(name) ?? name;
}
// the new way to render toolbar item type to replace Label prop
@@ -140,7 +149,7 @@ export function CustomLabel(props: IBaseCustomLabelProps): JSX.Element | null {
// other types of components and icon
if (label) {
- const Label = context.componentManager?.get((label as ICustomComponent).name) as any;
+ const Label = componentManager.get((label as ICustomComponent).name) as any;
if (Label) {
const props = (label as ICustomComponent).props ?? {};
return <Label onChange={onChange} {...props} />;
@@ -157,22 +166,23 @@ export interface IColorSelectProps {
value: string;
}
-// export class ColorSelect extends Component<IColorSelectProps> {
-// render() {
-// const { value, icon, title } = this.props;
-// return (
-// <div className={styles.colorSelect}>
-// <div>{icon ? <CustomLabel label={{ name: icon }} /> : title}</div>
-// <div className={styles.colorSelectLine} style={{ background: value }}></div>
-// </div>
-// );
-// }
-// }
export function ColorSelect({ value, icon, title }: IColorSelectProps) {
- return (
- <div className={styles.colorSelect}>
- {icon ? <CustomLabel label={{ name: icon, props: { color: value } }} /> : title}
- {/* <div className={styles.colorSelectLine} style={{ background: value }}></div> */}
- </div>
- );
+ const componentManager = useDependency(ComponentManager);
+ const localeService = useDependency(LocaleService);
+
+ function renderIconComponent() {
+ if (icon) {
+ const IconComponent = componentManager.get(icon) as any;
+
+ if (IconComponent) {
+ // TODO: @jikkai fix the colorChannel1
+ // return <IconComponent extend={{ colorChannel1: value }} />;
+ return <IconComponent />;
+ }
+ }
+
+ return localeService.t(title) ?? title;
+ }
+
+ return <div className={styles.colorSelect}>{renderIconComponent()}</div>;
}
diff --git a/packages/base-ui/src/Components/Dropdown/Dropdown.tsx b/packages/base-ui/src/Components/Dropdown/Dropdown.tsx
deleted file mode 100644
index 9a18ce6424..0000000000
--- a/packages/base-ui/src/Components/Dropdown/Dropdown.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import { IKeyValue } from '@univerjs/core';
-import React, { useEffect, useRef, useState } from 'react';
-
-import { Icon } from '..';
-import { Menu } from '../Menu';
-import { BaseMenuProps } from '../Menu/Menu';
-import styles from './index.module.less';
-
-export interface BaseDropdownProps {
- children: React.ReactNode;
- /** @deprecated dropdown shouldn't know what is inside */
- menu: BaseMenuProps;
- placement?: 'Left' | 'Right' | 'Top' | 'Bottom';
- showArrow?: boolean;
- icon?: React.ReactNode;
- onClick?: () => void;
- onMainClick?: () => void; //非功能按钮事件
- tooltip?: string;
- content?: React.ReactNode;
-}
-
-/** @deprecated */
-export const Dropdown = (props: BaseDropdownProps) => {
- const DropRef = useRef<HTMLDivElement>(null);
- const IconRef = useRef<HTMLDivElement>(null);
- const [menuStyle, setMenuStyle] = useState<Record<string, string | number>>({});
- const [menuShow, setMenuShow] = useState(false);
-
- const handleClick = () => {
- props.onClick?.();
- props.onMainClick?.();
- const { icon } = props;
- if (!icon) {
- showMenu();
- }
- };
-
- const showMenu = () => {
- setMenuShow(true);
- window.addEventListener('click', hideMenuClick, true);
- };
-
- const hideMenu = () => {
- setMenuShow(false);
- window.removeEventListener('click', hideMenuClick, true);
- };
-
- const hideMenuClick = (e: MouseEvent) => {
- if (!(DropRef as IKeyValue).current || !(DropRef as IKeyValue).current?.contains(e.target as Node)) {
- hideMenu();
- }
- };
-
- useEffect(() => {
- const { placement } = props;
- const style: Record<string, string | number> = { position: 'absolute' };
- if (!placement || placement === 'Bottom') {
- style.left = 0;
- style.top = '100%';
- } else if (placement === 'Top') {
- style.left = 0;
- style.top = '-100%';
- } else if (placement === 'Left') {
- style.left = '-100%';
- style.top = 0;
- } else {
- style.left = '100%';
- style.top = 0;
- }
- setMenuStyle(style);
- }, [props.placement]);
-
- return (
- <>
- <div className={styles.dropdown} ref={DropRef}>
- <div className={styles.dropContent} onClick={handleClick}>
- {props.children}
- {props.showArrow ? <Icon.Format.NextIcon /> : ''}
- </div>
- {props.icon && (
- <div ref={IconRef} className={styles.dropIcon} onClick={showMenu}>
- {props.icon}
- </div>
- )}
- {props.content}
- <div>
- <Menu
- menuId={props.menu.menuId}
- options={props.menu.options}
- display={props.menu.display}
- onClick={props.menu.onClick}
- value={props.menu.value}
- menu={props.menu.menu}
- className={props.menu.className}
- style={{ ...props.menu.style, ...menuStyle }}
- onClose={props.menu.onClose}
- onOptionSelect={(v) => {
- props.menu.onOptionSelect?.(v);
- // There is no need to hide the menu after selecting the border color or style.
- !v.show && hideMenu();
- }}
- show={menuShow}
- />
- </div>
- </div>
- </>
- );
-};
diff --git a/packages/base-ui/src/Components/Dropdown/index.ts b/packages/base-ui/src/Components/Dropdown/index.ts
index acc4379511..4a55c78783 100644
--- a/packages/base-ui/src/Components/Dropdown/index.ts
+++ b/packages/base-ui/src/Components/Dropdown/index.ts
@@ -1,2 +1 @@
-export * from './Dropdown';
export * from './Dropdown2';
diff --git a/packages/base-ui/src/Components/Icon/AddIcon.tsx b/packages/base-ui/src/Components/Icon/AddIcon.tsx
index 88079c3eb7..2724f847b3 100644
--- a/packages/base-ui/src/Components/Icon/AddIcon.tsx
+++ b/packages/base-ui/src/Components/Icon/AddIcon.tsx
@@ -1,41 +1,43 @@
-import { BaseComponentProps } from '../../BaseComponent';
-import { joinClassNames } from '../../Utils';
-import styles from './Style/index.module.less';
-
-export interface BaseIconProps extends BaseComponentProps {
- spin?: boolean;
- rotate?: number;
- style?: React.CSSProperties;
- className?: string;
- children?: React.ReactNode;
- name?: string;
- width?: string;
- height?: string;
- color?: string;
-}
-export const Icon = (props: BaseIconProps) => {
- const { spin, rotate, children, name, style, className } = props;
-
- let svgStyle;
- if (style) {
- svgStyle = style;
- svgStyle.transform = rotate ? `rotate(${rotate}deg)` : '';
- } else {
- svgStyle = rotate ? { transform: `rotate(${rotate}deg)` } : {};
- }
-
- const classes = joinClassNames(
- styles.icon,
- {
- [`${styles.icon}-${name}`]: name,
- [`${styles.icon}-spin`]: spin || name === 'loading',
- },
- className
- );
-
- return (
- <span role="img" className={classes} style={{ ...svgStyle }}>
- {children}
- </span>
- );
-};
+import { IExtendProps } from '@univerjs/icons';
+
+import { joinClassNames } from '../../Utils';
+import styles from './Style/index.module.less';
+
+export interface BaseIconProps {
+ spin?: boolean;
+ rotate?: number;
+ style?: React.CSSProperties;
+ className?: string;
+ children?: React.ReactNode;
+ name?: string;
+ width?: string;
+ height?: string;
+ color?: string;
+ extend?: IExtendProps;
+}
+export const Icon = (props: BaseIconProps) => {
+ const { spin, rotate, children, name, style, className } = props;
+
+ let svgStyle;
+ if (style) {
+ svgStyle = style;
+ svgStyle.transform = rotate ? `rotate(${rotate}deg)` : '';
+ } else {
+ svgStyle = rotate ? { transform: `rotate(${rotate}deg)` } : {};
+ }
+
+ const classes = joinClassNames(
+ styles.icon,
+ {
+ [`${styles.icon}-${name}`]: name,
+ [`${styles.icon}-spin`]: spin || name === 'loading',
+ },
+ className
+ );
+
+ return (
+ <span role="img" className={classes} style={{ ...svgStyle }}>
+ {children}
+ </span>
+ );
+};
diff --git a/packages/base-ui/src/Components/Icon/Font/index.tsx b/packages/base-ui/src/Components/Icon/Font/index.tsx
index 4f9a11cdca..c68e4a9d31 100644
--- a/packages/base-ui/src/Components/Icon/Font/index.tsx
+++ b/packages/base-ui/src/Components/Icon/Font/index.tsx
@@ -8,7 +8,9 @@ export const ItalicIcon = (props: BaseIconProps) => <TextItalic24 />;
export const DeleteLineIcon = (props: BaseIconProps) => <Strikethrough24 style={props.style} />;
export const UnderLineIcon = (props: BaseIconProps) => <Underline24 />;
-export const TextColorIcon = (props: BaseIconProps) => <TextColor24 style={{ color: props.color }} />;
+export const TextColorIcon = (props: BaseIconProps) => (
+ <TextColor24 style={{ color: props.color }} extend={props.extend} />
+);
export default {
BoldIcon,
diff --git a/packages/base-ui/src/Components/InputNumber/InputNumber.tsx b/packages/base-ui/src/Components/InputNumber/InputNumber.tsx
index bf82bf43e1..4dfec47e89 100644
--- a/packages/base-ui/src/Components/InputNumber/InputNumber.tsx
+++ b/packages/base-ui/src/Components/InputNumber/InputNumber.tsx
@@ -1,19 +1,15 @@
import { DropdownPromptSmall8 } from '@univerjs/icons';
import React, { useRef, useState } from 'react';
-import { BaseComponentProps } from '../../BaseComponent';
import { joinClassNames } from '../../Utils/util';
import styles from './Style/index.module.less';
-export interface BaseInputNumberProps extends BaseComponentProps {
+export interface BaseInputNumberProps {
/**
* Input's class name
*/
className?: string;
- /** Semantic DOM style */
- style?: React.CSSProperties;
-
/**
* The input content value
*/
@@ -77,7 +73,6 @@ export const InputNumber: React.FC<BaseInputNumberProps> = ({
disabled = false,
bordered = true,
className = '',
- style = {},
}) => {
const [inputValue, setInputValue] = useState(value);
const ref = useRef<HTMLInputElement>(null);
@@ -141,7 +136,7 @@ export const InputNumber: React.FC<BaseInputNumberProps> = ({
});
return (
- <div className={`${styles.inputNumber} ${className}`} style={style}>
+ <div className={`${styles.inputNumber} ${className}`}>
<div className={styles.inputWrap}>
<input
ref={ref}
diff --git a/packages/base-ui/src/Components/InputNumber/Style/index.module.less b/packages/base-ui/src/Components/InputNumber/Style/index.module.less
index 11afb3b01b..f08c879505 100644
--- a/packages/base-ui/src/Components/InputNumber/Style/index.module.less
+++ b/packages/base-ui/src/Components/InputNumber/Style/index.module.less
@@ -10,8 +10,8 @@
position: relative;
display: flex;
align-items: center;
- width: 60px;
- height: 26px;
+ width: 32px;
+ box-sizing: border-box;
&:hover {
.input-buttons {
@@ -22,11 +22,9 @@
background-color: var(--bg-color-secondary);
border: 2px solid var(--primary-color);
border-radius: var(--border-radius-base);
-
+
// Center
text-align: center;
- padding-right: 21px;
- padding: 0 26px 0 4px;
}
}
@@ -69,7 +67,7 @@
&:hover{
background-color: fade(@primary-color,10%);
border-radius: 0px var(--border-radius-base) 0px 0px;
-
+
}
}
diff --git a/packages/base-ui/src/Components/Item/Item.stories.tsx b/packages/base-ui/src/Components/Item/Item.stories.tsx
deleted file mode 100644
index e0d51401c7..0000000000
--- a/packages/base-ui/src/Components/Item/Item.stories.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import type { Meta } from '@storybook/react';
-
-import { Item } from './Item';
-
-const meta: Meta<typeof Item> = {
- title: 'Components / Item',
- component: Item,
- parameters: {
- layout: 'centered',
- },
- tags: ['autodocs'],
- args: {
- selected: true,
- border: true,
- },
-};
-
-export default meta;
-
-export const Playground = {
- args: {},
-};
diff --git a/packages/base-ui/src/Components/Item/Item.tsx b/packages/base-ui/src/Components/Item/Item.tsx
deleted file mode 100644
index 8b18c04a16..0000000000
--- a/packages/base-ui/src/Components/Item/Item.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import React from 'react';
-
-import { Icon } from '..';
-import { CustomLabel } from '../CustomLabel';
-import styles from './index.module.less';
-
-export interface BaseMenuItem {
- className?: string;
- style?: React.CSSProperties;
- label?: React.ReactNode;
- value?: any;
- children?: BaseMenuItem[];
- show?: boolean;
- disabled?: boolean;
- onClick?: (...arg: any) => void;
- border?: boolean;
-}
-export interface BaseItemProps extends BaseMenuItem {
- selected?: boolean;
- suffix?: React.ReactNode;
- border?: boolean;
-}
-// // TODO@wzhudev: move this component to another proper position. Now used by NeoCustomLabel component.
-// /**
-// * This render as a label of MenuItem.
-// */
-// export class Item extends Component<BaseItemProps> {
-// render() {
-// const { selected, label, suffix, disabled } = this.props;
-// return (
-// <div className={joinClassNames(styles.selectItem, disabled ? styles.selectDisabledItem : '')}>
-// {selected && (
-// <span className={styles.selectItemSelected}>
-// <Icon.CorrectIcon />
-// </span>
-// )}
-// <span className={styles.selectItemContent}>
-// <CustomLabel label={label} />
-// </span>
-// {suffix && (
-// <span className={styles.selectItemSuffix}>
-// <CustomLabel label={suffix} />
-// </span>
-// )}
-// </div>
-// );
-// }
-// }
-
-export function Item({ selected, label, suffix, disabled, className, style, onClick }: BaseItemProps) {
- return (
- <div
- className={`${styles.selectItem} ${disabled ? styles.selectDisabledItem : ''} ${className || ''}`}
- style={style}
- onClick={onClick}
- >
- {selected && (
- <span className={styles.selectItemSelected}>
- <Icon.CorrectIcon />
- </span>
- )}
- <span className={styles.selectItemContent}>
- <CustomLabel label={label} />
- </span>
- {suffix && (
- <span className={styles.selectItemSuffix}>
- <CustomLabel label={suffix} />
- </span>
- )}
- </div>
- );
-}
diff --git a/packages/base-ui/src/Components/Item/index.module.less b/packages/base-ui/src/Components/Item/index.module.less
deleted file mode 100644
index c3364e8962..0000000000
--- a/packages/base-ui/src/Components/Item/index.module.less
+++ /dev/null
@@ -1,32 +0,0 @@
-.select-item {
- display: flex;
- align-items: center;
- position: relative;
- justify-content: space-between;
-
- .select-item-selected {
- display: flex;
- align-items: center;
- position: absolute;
- left: 5px;
- top: 50%;
- transform: translateY(-50%) scale(1.5);
- }
-
- .select-item-content {
- display: block;
- }
-
- .select-item-suffix {
- margin-left: 10px;
-
- span[role='img'] {
- font-size: 24px;
- }
- }
-}
-
-.select-disabled-item {
- pointer-events: none;
- color: var(--gray-15);
-}
diff --git a/packages/base-ui/src/Components/Item/index.ts b/packages/base-ui/src/Components/Item/index.ts
deleted file mode 100644
index c924835a04..0000000000
--- a/packages/base-ui/src/Components/Item/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Item';
diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsx
index e13a089642..db80b8cb01 100644
--- a/packages/base-ui/src/Components/Menu/Menu.tsx
+++ b/packages/base-ui/src/Components/Menu/Menu.tsx
@@ -18,8 +18,7 @@ import { IMenuService } from '../../services/menu/menu.service';
import { joinClassNames } from '../../Utils';
import { NeoCustomLabel } from '../CustomLabel/CustomLabel';
import { useObservable } from '../hooks/observable';
-import { BaseMenuItem } from '../Item/Item';
-import { DisplayTypes } from '../Select/Select';
+import { BaseMenuItem, DisplayTypes } from '../Select/Select';
import styles from './index.module.less';
/** @deprecated */
diff --git a/packages/base-ui/src/Components/Menu/Menu2.tsx b/packages/base-ui/src/Components/Menu/Menu2.tsx
index f286dd2dc0..70a400ce4e 100644
--- a/packages/base-ui/src/Components/Menu/Menu2.tsx
+++ b/packages/base-ui/src/Components/Menu/Menu2.tsx
@@ -25,7 +25,7 @@ import { DisplayTypes } from '../Select/Select';
import styles from './index.module.less';
export interface IBaseMenuProps {
- menuType?: string;
+ menuType?: string | string[];
// used for selector
display?: DisplayTypes;
@@ -40,9 +40,31 @@ function Menu2Wrapper(props: IBaseMenuProps) {
const { menuType, onOptionSelect } = props;
const menuService = useDependency(IMenuService);
- const menuItems = menuType ? menuService.getMenuItems(menuType) : [];
+ if (!menuType) return;
- return menuItems?.map((item: IDisplayMenuItem<IMenuItem>) => (
+ if (Array.isArray(menuType)) {
+ const menuTypes = menuType.map((type) => menuService.getMenuItems(type));
+
+ return (
+ <>
+ {menuTypes.map((menuItems) =>
+ menuItems.map((item: IDisplayMenuItem<IMenuItem>) => (
+ <Menu2Item
+ key={item.id}
+ menuItem={item}
+ onClick={(object: Partial<IValueOption>) => {
+ onOptionSelect?.({ value: '', label: item.id, ...object });
+ }}
+ />
+ ))
+ )}
+ </>
+ );
+ }
+
+ const menuItems = menuService.getMenuItems(menuType);
+
+ return menuItems.map((item: IDisplayMenuItem<IMenuItem>) => (
<Menu2Item
key={item.id}
menuItem={item}
@@ -164,6 +186,7 @@ export function Menu2Item({ menuItem, onClick }: IMenu2ItemProps) {
value={inputValue}
title={title}
label={label}
+ icon={item.icon}
onChange={onChange}
onValueChange={() => {
// Right-click the menu for the title bar, and the Enter key triggers after entering the row height
@@ -225,6 +248,7 @@ export function Menu2Item({ menuItem, onClick }: IMenu2ItemProps) {
</SubMenu>
);
}
+
return (
<MenuItem
key={item.id}
@@ -268,7 +292,7 @@ export function Menu2Item({ menuItem, onClick }: IMenu2ItemProps) {
}
expandIcon={<More12 style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />}
>
- {menuItems.length > 0 && <Menu2Wrapper menuType={item.id} onOptionSelect={onClick} />}
+ {menuItems.length && <Menu2Wrapper menuType={item.id} onOptionSelect={onClick} />}
</SubMenu>
);
};
diff --git a/packages/base-ui/src/Components/Menu/index.module.less b/packages/base-ui/src/Components/Menu/index.module.less
index 85f422018c..547ff51392 100644
--- a/packages/base-ui/src/Components/Menu/index.module.less
+++ b/packages/base-ui/src/Components/Menu/index.module.less
@@ -12,6 +12,11 @@
box-sizing: border-box;
outline: none;
+ &-vertical {
+ display: grid;
+ gap: var(--margin-xxs);
+ }
+
&-hidden,
&-submenu-hidden {
display: none;
@@ -154,7 +159,7 @@
& > .menu2-item,
& > .menu2-submenu > .menu2-submenu-title {
width: 100%;
- padding: var(--padding-sm);
+ padding: var(--padding-xs) var(--padding-sm);
box-sizing: border-box;
display: flex;
justify-content: space-between;
diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsx
index 50897ac0c7..06db346280 100644
--- a/packages/base-ui/src/Components/Select/Select.tsx
+++ b/packages/base-ui/src/Components/Select/Select.tsx
@@ -5,12 +5,28 @@ import { ICustomComponent } from '../../Common';
import { IValueOption } from '../../services/menu/menu';
import { NeoCustomLabel } from '../CustomLabel';
import { Dropdown2 } from '../Dropdown';
-import { BaseItemProps } from '../Item/Item';
import { Menu2 } from '../Menu/Menu2';
import styles from './index.module.less';
// TODO: these type definitions should be moved out of components to menu service
+export interface BaseMenuItem {
+ className?: string;
+ style?: React.CSSProperties;
+ label?: React.ReactNode;
+ value?: any;
+ children?: BaseMenuItem[];
+ show?: boolean;
+ disabled?: boolean;
+ onClick?: (...arg: any) => void;
+ border?: boolean;
+}
+export interface BaseItemProps extends BaseMenuItem {
+ selected?: boolean;
+ suffix?: React.ReactNode;
+ border?: boolean;
+}
+
export enum DisplayTypes {
LABEL,
diff --git a/packages/base-ui/src/Components/Select/index.module.less b/packages/base-ui/src/Components/Select/index.module.less
index a599a30e7f..e82fca6ddf 100644
--- a/packages/base-ui/src/Components/Select/index.module.less
+++ b/packages/base-ui/src/Components/Select/index.module.less
@@ -1,76 +1,29 @@
-@import '../../Basics/CSS//Skin/default.module.less';
+@select-component-height: 28px;
.select-component {
position: relative;
+ height: @select-component-height;
+ padding: 0 var(--padding-xs);
+ border-radius: var(--border-radius-base);
display: flex;
align-items: center;
- border-radius: var(--border-radius-base);
- // margin: 0 3px;
- // height: 26px;
+ cursor: pointer;
&:hover {
- background-color: var(--grey-100);
+ background-color: rgb(var(--grey-100));
+ border-radius: var(--border-radius-base);
}
.select-button {
- padding: 0px 5px;
- span[role='img'] {
- font-size: 24px;
- }
}
.select-single {
text-overflow: ellipsis;
white-space: nowrap;
-
- &:hover {
- background: @bg-color-hover;
- }
- }
-
- .select-input {
- display: flex;
- align-items: center;
-
- &:hover {
- background: @bg-color-hover;
- }
-
- input {
- width: 38px;
- height: 20px;
- background: transparent;
- border: 1px solid transparent;
-
- &::-webkit-outer-spin-button,
- &::-webkit-inner-spin-button {
- -webkit-appearance: none;
- }
-
- &[type='number'] {
- -moz-appearance: textfield;
- }
-
- &:hover {
- border: 1px solid transparent;
- }
-
- &:focus {
- background: #fff;
- border: 1px solid var(--primary-color-hover);
- }
- }
}
.select-double {
- // &:hover {
- // background: @bg-color-hover;
- // }
-
- .dropdown {
- // padding-right: 0;
- }
.drop-content {
position: relative;
@@ -85,53 +38,20 @@
transform: translate(-50%, 0);
}
}
-
- .drop-icon {
- // border-left: 1px solid transparent;
- height: 26px;
- padding: 0 2px;
-
- &:hover{
- background-color: var(--grey-300);
- border-radius: 0 var(--border-radius-base) var(--border-radius-base) 0;
- }
- }
}
.select-label {
display: flex;
align-items: center;
- height: 26px;
- font-size: 18px;//icon size
- padding: 0 4px;
- span[role='img'] {
- font-size: 24px;
- }
-
- &:hover{
- background-color: var(--grey-300);
- border-radius: @border-radius-base;
- }
+ font-size: var(--font-size-xxl);
+ gap: var(--margin-xxs);
}
-
- button {
- .button();
- border-color: transparent;
- height: auto;
- }
-}
-
-.button() {
- padding: 0px;
- box-sizing: border-box;
}
.select-drop-icon {
height: 100%;
- // margin-left: 5px;
- // border-left: 1px solid @gray-14;
display: flex;
align-items: center;
- color: var(--grey-400);
+ color: rgb(var(--grey-400));
font-size: 10px;
}
diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.ts
index d8503db2eb..576bdd5b6a 100644
--- a/packages/base-ui/src/Components/index.ts
+++ b/packages/base-ui/src/Components/index.ts
@@ -13,7 +13,6 @@ export * from './CustomLabel';
export * from './Dropdown';
export * from './Input';
export * from './InputNumber';
-export * from './Item/Item';
export * from './Layout';
export * from './Menu';
export * from './Modal';
diff --git a/packages/base-ui/src/Locale/en.ts b/packages/base-ui/src/Locale/en.ts
new file mode 100644
index 0000000000..28b1ef6aab
--- /dev/null
+++ b/packages/base-ui/src/Locale/en.ts
@@ -0,0 +1,10 @@
+export default {
+ uiToolbar: {
+ start: 'Start',
+ insert: 'Insert',
+ formulas: 'Formulas',
+ data: 'Data',
+ view: 'View',
+ others: 'Others',
+ },
+};
diff --git a/packages/base-ui/src/Locale/index.ts b/packages/base-ui/src/Locale/index.ts
new file mode 100644
index 0000000000..42a991e0fe
--- /dev/null
+++ b/packages/base-ui/src/Locale/index.ts
@@ -0,0 +1,4 @@
+import en from './en';
+import zh from './zh';
+
+export { en, zh };
diff --git a/packages/base-ui/src/Locale/zh.ts b/packages/base-ui/src/Locale/zh.ts
new file mode 100644
index 0000000000..65871b15e0
--- /dev/null
+++ b/packages/base-ui/src/Locale/zh.ts
@@ -0,0 +1,10 @@
+export default {
+ uiToolbar: {
+ start: '开始',
+ insert: '插入',
+ formulas: '公式',
+ data: '数据',
+ view: '视图',
+ others: '其他',
+ },
+};
diff --git a/packages/base-ui/src/base-ui-plugin.ts b/packages/base-ui/src/base-ui-plugin.ts
index 4b42f53008..4c0a3f852c 100644
--- a/packages/base-ui/src/base-ui-plugin.ts
+++ b/packages/base-ui/src/base-ui-plugin.ts
@@ -1,4 +1,4 @@
-import { ILocalStorageService, Plugin, PLUGIN_NAMES, PluginType } from '@univerjs/core';
+import { ILocalStorageService, LocaleService, Plugin, PLUGIN_NAMES, PluginType } from '@univerjs/core';
import { Dependency, Inject, Injector } from '@wendellhu/redi';
import { ComponentManager } from './Common/ComponentManager';
@@ -6,6 +6,7 @@ import { ZIndexManager } from './Common/ZIndexManager';
import { SharedController } from './controllers/shared-shortcut.controller';
import { IUIController, IWorkbenchOptions } from './controllers/ui/ui.controller';
import { DesktopUIController } from './controllers/ui/ui-desktop.controller';
+import { en } from './Locale';
import { BrowserClipboardService, IClipboardInterfaceService } from './services/clipboard/clipboard-interface.service';
import { DesktopContextMenuService, IContextMenuService } from './services/contextmenu/contextmenu.service';
import { DesktopFocusService, IFocusService } from './services/focus/focus.service';
@@ -32,11 +33,16 @@ export class UIPlugin extends Plugin {
constructor(
config: Partial<IUIPluginConfig> = {},
- @Inject(Injector) protected readonly _injector: Injector
+ @Inject(Injector) protected readonly _injector: Injector,
+ @Inject(LocaleService) private readonly _localeService: LocaleService
) {
super(PLUGIN_NAMES.BASE_UI);
this._config = Object.assign(DEFAULT_SLIDE_PLUGIN_DATA, config);
+
+ this._localeService.getLocale().load({
+ en,
+ });
}
override onStarting(_injector: Injector): void {
diff --git a/packages/base-ui/src/index.ts b/packages/base-ui/src/index.ts
index 12ffc1b36b..c2042ae8c3 100644
--- a/packages/base-ui/src/index.ts
+++ b/packages/base-ui/src/index.ts
@@ -8,6 +8,7 @@ export { IUIController } from './controllers/ui/ui.controller';
export { type IDesktopUIController } from './controllers/ui/ui-desktop.controller';
export * from './Enum';
export * from './Helpers';
+export * from './Locale';
export { CopyCommand, CutCommand, PasteCommand } from './services/clipboard/clipboard.command';
export { CopyShortcutItem, CutShortcutItem, PasteShortcutItem } from './services/clipboard/clipboard.shortcut';
export {
@@ -32,6 +33,7 @@ export {
isCustomComponentOption,
isValueOptions,
type IValueOption,
+ MenuGroup,
MenuItemType,
MenuPosition,
} from './services/menu/menu';
diff --git a/packages/base-ui/src/services/menu/menu.service.ts b/packages/base-ui/src/services/menu/menu.service.ts
index 3afb6bbed3..0e59d5ea5d 100644
--- a/packages/base-ui/src/services/menu/menu.service.ts
+++ b/packages/base-ui/src/services/menu/menu.service.ts
@@ -2,36 +2,9 @@ import { Disposable, toDisposable } from '@univerjs/core';
import { createIdentifier, IDisposable } from '@wendellhu/redi';
import { debounceTime, Observable, Subject } from 'rxjs';
-// TODO@wzhudev: this props should be moved to menu.service.ts to break cycle import
-import { BaseSelectChildrenProps } from '../../Components/Select/Select';
import { IShortcutService } from '../shortcut/shortcut.service';
import { IDisplayMenuItem, IMenuItem, MenuPosition } from './menu';
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export interface IMenuItemState {
- id: string;
-
- disabled?: boolean;
- hidden?: boolean;
- checked?: boolean;
-}
-
-// TODO@Dushusir remove CustomLabelProps and CustomLabel in rightMenuUIController after migrate new UI system
-
-interface CustomLabelProps {
- prefix?: string[] | string;
- suffix?: string[] | string;
- options?: BaseSelectChildrenProps[];
- label?: string;
- children?: CustomLabelProps[];
- onKeyUp?: (e: Event) => void;
-}
-
-export interface CustomLabel {
- name: string;
- props?: CustomLabelProps;
-}
-
export const IMenuService = createIdentifier<IMenuService>('univer.menu-service');
export interface IMenuService {
@@ -111,10 +84,26 @@ export class DesktopMenuService extends Disposable implements IMenuService {
getMenuItems(positions: MenuPosition | string): Array<IDisplayMenuItem<IMenuItem>> {
// TODO: @wzhudev: compose shortcut to returned menu items.
if (this._menuByPositions.has(positions)) {
- const menuItems = [...this._menuByPositions.get(positions)!.values()].map((menu) =>
- this.getDisplayMenuItems(menu[1])
- );
- return menuItems;
+ const menuItems = this._menuByPositions.get(positions);
+
+ if (menuItems) {
+ // const _this = this;
+ // const result = menuItems.map(function walk([id, item]) {
+ // const menuItem = _this.getDisplayMenuItems(item);
+ //
+ // const subMenu = _this._menuByPositions.get(id);
+ // if (subMenu) {
+ // menuItem.children = subMenu.map(walk);
+ // return menuItem;
+ // }
+ //
+ // return menuItem;
+ // });
+ //
+ // console.log(result);
+
+ return [...menuItems.values()].map((menu) => this.getDisplayMenuItems(menu[1]));
+ }
}
return [] as Array<IDisplayMenuItem<IMenuItem>>;
diff --git a/packages/base-ui/src/services/menu/menu.ts b/packages/base-ui/src/services/menu/menu.ts
index de06883ef6..75df9e7184 100644
--- a/packages/base-ui/src/services/menu/menu.ts
+++ b/packages/base-ui/src/services/menu/menu.ts
@@ -7,10 +7,20 @@ export type OneOrMany<T> = T | T[];
export const enum MenuPosition {
VOID = 'void',
- TOOLBAR = 'toolbar',
+ TOOLBAR_START = 'uiToolbar.start',
+ TOOLBAR_INSERT = 'uiToolbar.insert',
+ TOOLBAR_FORMULAS = 'uiToolbar.formulas',
+ TOOLBAR_DATA = 'uiToolbar.data',
+ TOOLBAR_VIEW = 'uiToolbar.view',
+ TOOLBAR_OTHERS = 'uiToolbar.others',
CONTEXT_MENU = 'contextMenu',
}
+export const enum MenuGroup {
+ TOOLBAR_HISTORY,
+ TOOLBAR_OTHERS,
+}
+
export const enum MenuItemType {
/** Button style menu item. */
BUTTON,
@@ -29,6 +39,9 @@ interface IMenuItemBase<V> {
icon?: string;
tooltip?: string;
+ /** The group that the item belongs to. */
+ group?: MenuGroup;
+
/** In what menu should the item display. */
positions: OneOrMany<MenuPosition | string>;
@@ -71,10 +84,6 @@ export interface IMenuButtonItem<V = undefined> extends IMenuItemBase<V> {
activated$?: Observable<boolean>;
}
-export function isMenuButtonItem(v: IMenuItem): v is IMenuButtonItem {
- return v.type === MenuItemType.BUTTON;
-}
-
export interface IValueOption {
value: string | number;
label:
diff --git a/packages/base-ui/src/views/app.tsx b/packages/base-ui/src/views/app.tsx
index 37415e3ef5..dff00ddb6f 100644
--- a/packages/base-ui/src/views/app.tsx
+++ b/packages/base-ui/src/views/app.tsx
@@ -48,7 +48,7 @@ export function App(props: IUniverAppProps) {
const [locale, setLocale] = useState<LocaleType>(localeService.getLocale().getCurrentLocale());
useEffect(() => {
- const listeners = [
+ const subscriptions = [
localeService.getLocale().locale$.subscribe((locale) => {
locale && setLocale(locale);
}),
@@ -59,7 +59,7 @@ export function App(props: IUniverAppProps) {
return () => {
// batch unsubscribe
- listeners.forEach((listener) => listener.unsubscribe());
+ subscriptions.forEach((subscription) => subscription.unsubscribe());
};
}, []);
diff --git a/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx b/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx
index 1470c4dc21..bae7db3a75 100644
--- a/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx
+++ b/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx
@@ -1,7 +1,7 @@
import { IMouseEvent } from '@univerjs/base-render';
import { DisposableCollection, ICommandService } from '@univerjs/core';
-import { RediContext, useDependency } from '@wendellhu/redi/react-bindings';
-import React, { useContext, useEffect, useState } from 'react';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+import React, { useEffect, useState } from 'react';
import { Dropdown2 } from '../../../Components/Dropdown/Dropdown2';
import { Menu2 } from '../../../Components/Menu/Menu2';
@@ -17,9 +17,8 @@ export function ContextMenu(props: IProps) {
const [visible, setVisible] = useState(false);
const [menuType, setMenuType] = useState('');
- const context = useContext(RediContext);
-
const contextMenuService = useDependency(IContextMenuService);
+ const commandService = useDependency(ICommandService);
useEffect(() => {
const _disposables = new DisposableCollection();
@@ -61,10 +60,9 @@ export function ContextMenu(props: IProps) {
alignPoint
overlay={
<Menu2
- menuType={menuType}
+ menuType={[menuType]}
onOptionSelect={(params) => {
const { label: commandId, value } = params;
- const commandService = context.injector?.get(ICommandService);
commandService && commandService.executeCommand(commandId as string, { value });
setVisible(false);
}}
diff --git a/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx b/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx
index 9045ca3854..685f30af16 100644
--- a/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx
+++ b/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx
@@ -64,7 +64,6 @@ export function ToolbarButton(props: IBaseToolbarButtonProps) {
const _className = joinClassNames(
styles.toolbarBtn,
- `${styles.toolbarBtn}-text`,
{
[`${styles.toolbarBtn}-text-active`]: active,
},
diff --git a/packages/base-ui/src/views/components/DocBars/Button/index.module.less b/packages/base-ui/src/views/components/DocBars/Button/index.module.less
index 393a562523..fec661c9a6 100644
--- a/packages/base-ui/src/views/components/DocBars/Button/index.module.less
+++ b/packages/base-ui/src/views/components/DocBars/Button/index.module.less
@@ -1,55 +1,32 @@
-@import '../../../../Components/Button/Style/mixin.less';
+@toolbar-btn-size: 28px;
.toolbar-btn {
- line-height: @line-height-base;
- .btn();
- .btn-default();
+ width: @toolbar-btn-size;
+ height: @toolbar-btn-size;
+ padding: 0;
+ font-size: var(--font-size-xxl);
+ background-color: transparent;
+ border: none;
+ border-radius: var(--border-radius-base);
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ outline: none;
+ cursor: pointer;
- >span {
- display: inline-block;
+ &:not([disabled]):hover {
+ color: rgb(var(--text-color));
+ background-color: rgb(var(--grey-100));
+ border-color: transparent;
}
-
- &-text {
- .button-color(rgb(var(--text-color)), transparent, transparent);
- box-shadow: none;
-
- &:hover {
- color: rgb(var(--text-color));
- background-color: rgb(var(--grey-100));
- border-color: transparent;
- }
-
- // &:active {
- // color: var(--text-color);
- // background: #eee;
- // border-color: transparent;
- // }
- .button-disabled(var(--disabled-color); transparent; transparent);
- &-active {
- color: rgb(var(--text-color));
- background-color: rgb(var(--grey-100));
- border-color: transparent;
- }
- height: 26px;
+ &[disabled] {
+ cursor: not-allowed;
}
- &::before {
- position: absolute;
- top: -1px;
- right: -1px;
- bottom: -1px;
- left: -1px;
- z-index: 1;
- display: none;
- background: @bg-color-secondary;
- border-radius: inherit;
- opacity: 0.35;
- transition: opacity 0.2s;
- content: '';
- pointer-events: none;
- }
-
- &:active>span {
- position: relative;
+ &-active {
+ color: rgb(var(--text-color));
+ background-color: rgb(var(--grey-100));
+ border-color: transparent;
}
}
+
diff --git a/packages/base-ui/src/views/components/DocBars/DocBars.tsx b/packages/base-ui/src/views/components/DocBars/DocBars.tsx
index 15cf044324..ad1bbcc1d2 100644
--- a/packages/base-ui/src/views/components/DocBars/DocBars.tsx
+++ b/packages/base-ui/src/views/components/DocBars/DocBars.tsx
@@ -1,33 +1,94 @@
+import { LocaleService } from '@univerjs/core';
import { useDependency } from '@wendellhu/redi/react-bindings';
-import { useEffect, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
-import { IDisplayMenuItem, IMenuItem, MenuPosition } from '../../../services/menu/menu';
+import { IDisplayMenuItem, IMenuItem, MenuGroup, MenuPosition } from '../../../services/menu/menu';
import { IMenuService } from '../../../services/menu/menu.service';
+import { joinClassNames } from '../../../Utils';
import styles from './index.module.less';
import { ToolbarItem } from './ToolbarItem';
+interface IMenuGroup {
+ name: string;
+ menuItems: Array<IDisplayMenuItem<IMenuItem>>;
+}
+
export function DocBars() {
const menuService = useDependency(IMenuService);
+ const localeService = useDependency(LocaleService);
- const [menuItems, setMenuItems] = useState<Array<IDisplayMenuItem<IMenuItem>>>([]);
+ const [menuGroups, setMenuGroups] = useState<IMenuGroup[]>([]);
+ const [activeMenuGroup, setActiveMenuGroup] = useState<IMenuGroup | null>(null);
useEffect(() => {
- const update = () => {
- setMenuItems(menuService.getMenuItems(MenuPosition.TOOLBAR));
- };
+ const listener = menuService.menuChanged$.subscribe(() => {
+ const menuGroups = [
+ MenuPosition.TOOLBAR_START,
+ MenuPosition.TOOLBAR_INSERT,
+ MenuPosition.TOOLBAR_FORMULAS,
+ MenuPosition.TOOLBAR_DATA,
+ MenuPosition.TOOLBAR_VIEW,
+ MenuPosition.TOOLBAR_OTHERS,
+ ]
+ .map((position) => ({
+ name: position,
+ menuItems: menuService.getMenuItems(position),
+ }))
+ .filter((group) => group.menuItems.length);
- // TODO: dispose
- menuService.menuChanged$.subscribe(() => update());
- update();
+ setMenuGroups(menuGroups);
+
+ if (activeMenuGroup === null) {
+ setActiveMenuGroup(menuGroups[0]);
+ }
+ });
+
+ return () => {
+ listener.unsubscribe();
+ };
}, []);
+ const toolbarGroups = useMemo(() => {
+ if (!activeMenuGroup?.menuItems) return [];
+
+ return activeMenuGroup.menuItems.reduce(
+ (acc, item) => {
+ const key = item.group ?? MenuGroup.TOOLBAR_OTHERS;
+ if (!acc[key]) {
+ acc[key] = [];
+ }
+
+ acc[key].push(item);
+ return acc;
+ },
+ {} as Record<MenuGroup, Array<IDisplayMenuItem<IMenuItem>>>
+ );
+ }, [activeMenuGroup]);
+
return (
<section className={styles.docBars}>
- <div className={styles.menubar}>{/* TODO: Start */}</div>
+ <div className={styles.menubar}>
+ {menuGroups.map((group, index) => (
+ <a
+ key={index}
+ className={joinClassNames(styles.menubarItem, {
+ [styles.menubarItemActive]: group.name === activeMenuGroup?.name,
+ })}
+ onClick={() => setActiveMenuGroup(group)}
+ >
+ {localeService.t(group.name) ?? ''}
+ </a>
+ ))}
+ </div>
+
<div className={styles.toolbar}>
<div className={styles.toolbarContainer}>
- {menuItems.map((item) => (
- <ToolbarItem key={item.id} {...item} />
+ {Object.entries(toolbarGroups).map(([key, item], index) => (
+ <div className={styles.toolbarGroup}>
+ {item.map((subItem) => (
+ <ToolbarItem key={subItem.id} {...subItem} />
+ ))}
+ </div>
))}
</div>
</div>
diff --git a/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx b/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx
index 4bce9b9064..82b82aa83a 100644
--- a/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx
+++ b/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx
@@ -1,14 +1,13 @@
-import { ICommandService } from '@univerjs/core';
-import { Component } from 'react';
+import { ICommandService, LocaleService } from '@univerjs/core';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+import { useEffect, useState } from 'react';
import { Subscription } from 'rxjs';
-import { AppContext } from '../../../Common/AppContext';
-import { CustomLabel } from '../../../Components/CustomLabel/CustomLabel';
+import { ComponentManager } from '../../../Common';
import { Select } from '../../../Components/Select/Select';
import { Tooltip } from '../../../Components/Tooltip/Tooltip';
import {
IDisplayMenuItem,
- IMenuButtonItem,
IMenuItem,
IMenuSelectorItem,
IValueOption,
@@ -17,81 +16,60 @@ import {
import { ToolbarButton } from './Button/ToolbarButton';
import styles from './index.module.less';
-export interface IToolbarItemStatus {
- disabled: boolean;
- activated: boolean;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- value: any;
-}
-
-/** The component to render toolbar item. */
-export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbarItemStatus> {
- static override contextType = AppContext;
-
- declare context: React.ContextType<typeof AppContext>;
-
- private disabledSubscription: Subscription | undefined;
-
- private activatedSubscription: Subscription | undefined;
-
- private currentValueSubscription: Subscription | undefined;
+export function ToolbarItem(props: IDisplayMenuItem<IMenuItem>) {
+ const localeService = useDependency(LocaleService);
+ const commandService = useDependency(ICommandService);
+ const componentManager = useDependency(ComponentManager);
- constructor(props: IDisplayMenuItem<IMenuItem>) {
- super(props);
-
- this.state = {
- disabled: false,
- activated: false,
- value: undefined,
- };
- }
-
- override componentDidMount() {
- this.disabledSubscription = this.props.disabled$?.subscribe((disabled) => {
- this.setState({ disabled });
- });
-
- if (this.props.type === MenuItemType.BUTTON) {
- const props = this.props as IDisplayMenuItem<IMenuButtonItem>;
- this.activatedSubscription = props.activated$?.subscribe((activated) => {
- this.setState({ activated });
- });
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const [value, setValue] = useState<any>();
+ const [disabled, setDisabled] = useState(false);
+ const [activated, setActivated] = useState(false);
+
+ useEffect(() => {
+ const subscriptions: Subscription[] = [];
+
+ props.disabled$ &&
+ subscriptions.push(
+ props.disabled$.subscribe((disabled) => {
+ setDisabled(disabled);
+ })
+ );
+
+ if (props.type === MenuItemType.BUTTON) {
+ props.activated$ &&
+ subscriptions.push(
+ props.activated$.subscribe((activated) => {
+ setActivated(activated);
+ })
+ );
}
- if (this.props.type === MenuItemType.SELECTOR) {
- const props = this.props as IDisplayMenuItem<IMenuSelectorItem>;
- this.currentValueSubscription = props.value$?.subscribe((value) => {
- this.setState({ value });
- });
+ if (props.type === MenuItemType.SELECTOR) {
+ props.value$ &&
+ subscriptions.push(
+ props.value$.subscribe((value) => {
+ setValue(value);
+ })
+ );
}
- }
- override UNSAFE_componentWillMount() {
- this.disabledSubscription?.unsubscribe();
- this.activatedSubscription?.unsubscribe();
- this.currentValueSubscription?.unsubscribe();
- }
+ return () => {
+ subscriptions.forEach((subscription) => {
+ subscription.unsubscribe();
+ });
+ };
+ }, []);
- override render() {
- switch (this.props.type) {
- case MenuItemType.SUBITEMS:
- case MenuItemType.SELECTOR:
- return this.renderSelectorType();
- default:
- return this.renderButtonType();
- }
- }
+ const { tooltip, shortcut, icon, title, label, display, id, min, max, onClose } = props;
- private renderSelectorType() {
- const { context, state } = this;
- const commandService: ICommandService = context.injector.get(ICommandService);
- const { disabled, value } = state;
+ const tooltipTitle = localeService?.t(tooltip) + (shortcut ? ` (${shortcut})` : '');
- const props = this.props as IDisplayMenuItem<IMenuSelectorItem>;
- const { icon, title, label, display, selections, id, onClose, max, min } = props;
+ function renderSelectorType() {
+ const { selections } = props as IDisplayMenuItem<IMenuSelectorItem>;
return (
- <Tooltip title={this.getTooltip()} placement="bottom">
+ <Tooltip title={tooltipTitle} placement="bottom">
<Select
id={id}
title={title}
@@ -106,6 +84,7 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbar
onClick={(value) => {
// commandService.executeCommand(id, { value })
// 子元素commandId会被现在的id覆盖,暂时这么写以区分
+ // TODO: @jikkai should be refactored
let commandId = id;
if (value instanceof Object && value.id) {
commandId = value.id;
@@ -117,35 +96,41 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbar
commandService.executeCommand(commandId, value);
}}
onClose={onClose}
- ></Select>
+ />
</Tooltip>
);
}
- private renderButtonType() {
- const { props, context, state } = this;
- const { disabled, activated } = state;
- const { icon, title } = props;
- const commandService: ICommandService = context.injector.get(ICommandService);
+ function renderButtonType() {
+ function renderIconOrLabel() {
+ if (icon) {
+ const IconComponent = componentManager.get(icon) as React.ComponentType;
+
+ if (IconComponent) return <IconComponent />;
+ }
+ return title;
+ }
return (
- <Tooltip title={this.getTooltip()} placement="bottom">
+ <Tooltip title={tooltipTitle} placement="bottom">
<ToolbarButton
+ className={styles.toolbarItemTextButton}
active={activated}
- className={styles.textButton}
disabled={disabled}
onClick={() => commandService.executeCommand(props.id)}
onDoubleClick={() => props.subId && commandService.executeCommand(props.subId)}
>
- <CustomLabel label={icon ? { name: icon } : title} />
+ {renderIconOrLabel()}
</ToolbarButton>
</Tooltip>
);
}
- private getTooltip(): string {
- return (
- this.context.localeService?.t(this.props.tooltip) + (this.props.shortcut ? ` (${this.props.shortcut})` : '')
- );
+ switch (props.type) {
+ case MenuItemType.SUBITEMS:
+ case MenuItemType.SELECTOR:
+ return renderSelectorType();
+ default:
+ return renderButtonType();
}
}
diff --git a/packages/base-ui/src/views/components/DocBars/index.module.less b/packages/base-ui/src/views/components/DocBars/index.module.less
index d0d66eeaad..19a84a5cb0 100644
--- a/packages/base-ui/src/views/components/DocBars/index.module.less
+++ b/packages/base-ui/src/views/components/DocBars/index.module.less
@@ -1,17 +1,38 @@
-@import '../../../Basics/CSS/Skin/default.module.less';
-
.doc-bars {
box-sizing: border-box;
.menubar {
height: 40px;
- border-bottom: 1px solid @border-color;
+ border-bottom: 1px solid rgb(var(--border-color));
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: var(--margin-xs);
+
+ &-item {
+ padding: var(--padding-xs) var(--padding-sm);
+ font-size: var(--font-size-sm);
+ font-weight: 400;
+ border-radius: var(--border-radius-base);
+ display: block;
+ cursor: pointer;
+ transition: all 0.1s ease-in-out;
+
+ &:hover:not(&-active) {
+ background: rgb(var(--grey-300));
+ }
+
+ &-active {
+ color: rgb(var(--color-white));
+ background: rgb(var(--primary-color));
+ }
+ }
}
.toolbar {
position: relative;
height: 40px;
- padding: 0 @padding-xl;
+ padding: 0 var(--padding-xl);
color: rgb(var(--text-color));
font-size: var(--font-size);
@@ -25,124 +46,25 @@
height: 100%;
display: flex;
align-items: center;
+ justify-content: center;
border-bottom: 1px solid rgb(var(--border-color));
-
- > div {
- height: 26px;
- display: inline-block;
- vertical-align: middle;
- margin: 0 1px;
- cursor: pointer;
-
- &.select-button:hover {
- background-color: #efefef;
- }
- }
-
- }
-
- .single-button {
- &.more-hide {
- display: none;
- }
-
- &.more-show {
- display: block;
- }
- }
-
- .cols-menu {
- overflow-y: auto;
- }
-
- .select-label-string {
- .drop-content {
- > div {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- width: 90px;
- }
- }
- }
-
- .select-double-string {
- .drop-content {
- > div {
- width: 24px;
- }
- }
+ gap: var(--margin-xs);
}
- .select-color-picker-parent {
- .select-item-content {
- width: 100%;
- }
-
- .select-color-picker {
- cursor: default;
-
- &:hover {
- background: var(--bg);
- }
-
- .select-item {
- padding: 0;
- }
-
- .color-picker-outer {
- box-shadow: none;
- }
- }
- }
-
- .select-line-bold-parent {
- .select-item-content {
- width: 100%;
- }
- }
-
- .select-single {
- // height: 26px;
- // line-height: 26px;
- }
-
- .select-input {
- // height: 26px;
- // line-height: 26px;
- }
-
- .select-double {
- // height: 26px;
- // line-height: 26px;
- }
-
- button {
- padding: 0 4px; // FIXME Set the BIUS buttons, the target is 26 * 26, padding 4px, but only 27.6 * 26 can be obtained
+ &-group {
display: flex;
align-items: center;
- // height: 26px;
- font-size: 18px;
- border-radius: var(--border-radius-base);
- }
- span[role='img'].univericon-nextIcon {
- font-size: 12px;
- }
-
- .text-button {
- span[role='img'] {
- font-size: 24px;
- }
-
- button {
- padding: 0 5px;
+ &:not(:last-child) {
+ &::after {
+ content: '';
+ width: 1px;
+ height: 20px;
+ margin-left: var(--margin-xs);
+ background-color: rgb(var(--border-color));
+ display: block;
+ }
}
}
}
-
- .button() {
- padding: 0px;
- line-height: 1;
- }
}
diff --git a/packages/core/src/services/locale/locale.service.ts b/packages/core/src/services/locale/locale.service.ts
index cc0417df46..19653ca16f 100644
--- a/packages/core/src/services/locale/locale.service.ts
+++ b/packages/core/src/services/locale/locale.service.ts
@@ -49,7 +49,7 @@ export class LocaleService extends Disposable {
}
t(key?: string): Nullable<string | number> {
- return this.get(key);
+ return this.get(key) ?? key;
}
setLocale(locale: LocaleType): void {
diff --git a/packages/sheets-plugin-debugger/src/controllers/menu.ts b/packages/sheets-plugin-debugger/src/controllers/menu.ts
index f36dc380c5..2b0e6c9490 100644
--- a/packages/sheets-plugin-debugger/src/controllers/menu.ts
+++ b/packages/sheets-plugin-debugger/src/controllers/menu.ts
@@ -20,7 +20,7 @@ export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
tooltip: 'debugger.locale.tooltip',
display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'English',
@@ -42,7 +42,7 @@ export function ThemeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
tooltip: 'debugger.theme.tooltip',
display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'green',
@@ -63,7 +63,7 @@ export function UIComponentMenuItemFactory(accessor: IAccessor): IMenuSelectorIt
tooltip: 'debugger.uiComponent.tooltip',
display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
{
label: 'Notification Success',
diff --git a/packages/sheets-plugin-find/src/Controller/menu.ts b/packages/sheets-plugin-find/src/Controller/menu.ts
index 2fddd00ce9..ccc45f13b0 100644
--- a/packages/sheets-plugin-find/src/Controller/menu.ts
+++ b/packages/sheets-plugin-find/src/Controller/menu.ts
@@ -10,7 +10,7 @@ export function FindMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'SearchIcon',
title: 'find.findLabel',
tooltip: 'find.findLabel',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
// TODO@Dushusir disabled$ status
};
}
diff --git a/packages/sheets-plugin-image/src/Controller/menu.ts b/packages/sheets-plugin-image/src/Controller/menu.ts
index ea1ccc4874..a7b2f5e05f 100644
--- a/packages/sheets-plugin-image/src/Controller/menu.ts
+++ b/packages/sheets-plugin-image/src/Controller/menu.ts
@@ -10,7 +10,7 @@ export function ImportImageMenuItemFactory(accessor: IAccessor): IMenuButtonItem
icon: 'ImageIcon',
title: 'Image', // FIXME use translation
tooltip: 'Import Image', // FIXME use translation
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
// TODO@Dushusir disabled$ status
};
}
diff --git a/packages/sheets-plugin-import-xlsx/src/Controller/menu.ts b/packages/sheets-plugin-import-xlsx/src/Controller/menu.ts
index 0b3a205f4e..a81738e040 100644
--- a/packages/sheets-plugin-import-xlsx/src/Controller/menu.ts
+++ b/packages/sheets-plugin-import-xlsx/src/Controller/menu.ts
@@ -9,7 +9,7 @@ export function ImportMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
type: MenuItemType.BUTTON,
title: 'importXlsx.import',
tooltip: 'importXlsx.tooltip',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
// TODO@Dushusir disabled$ status
};
}
diff --git a/packages/sheets-plugin-numfmt/src/Controller/menu.ts b/packages/sheets-plugin-numfmt/src/Controller/menu.ts
index c1c9f91e06..c6239b7d01 100644
--- a/packages/sheets-plugin-numfmt/src/Controller/menu.ts
+++ b/packages/sheets-plugin-numfmt/src/Controller/menu.ts
@@ -18,7 +18,7 @@ export function NumfmtRangeDataMenuItemFactory(accessor: IAccessor): IMenuSelect
type: MenuItemType.SELECTOR,
display: DisplayTypes.CUSTOM,
// display: DisplayTypes.FONT,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
selections: DEFAULT_DATA,
// disabled$: new Observable((subscriber) => {
// let editable = false;
diff --git a/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts
index fa1aacf716..58ebd1e7a3 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts
@@ -134,7 +134,7 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSel
icon: 'FullBorderIcon',
tooltip: 'toolbar.border.main',
display: DisplayTypes.ICON,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
type: MenuItemType.SUBITEMS,
selections: [...BORDER_LINE_CHILDREN],
onClose: () => {
diff --git a/packages/ui-plugin-sheets/src/controller/menu/menu.ts b/packages/ui-plugin-sheets/src/controller/menu/menu.ts
index 0d3004c22f..6dad6e6220 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/menu.ts
@@ -55,6 +55,7 @@ import {
DisplayTypes,
IMenuButtonItem,
IMenuSelectorItem,
+ MenuGroup,
MenuItemType,
MenuPosition,
PasteCommand,
@@ -102,11 +103,12 @@ export function UndoMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: UndoCommand.id,
+ group: MenuGroup.TOOLBAR_HISTORY,
type: MenuItemType.BUTTON,
icon: 'ForwardIcon',
title: 'Undo',
tooltip: 'toolbar.undo',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
disabled$: undoRedoService.undoRedoStatus$.pipe(map((v) => v.undos <= 0)),
};
}
@@ -116,11 +118,12 @@ export function RedoMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
return {
id: RedoCommand.id,
+ group: MenuGroup.TOOLBAR_HISTORY,
type: MenuItemType.BUTTON,
icon: 'BackIcon',
title: 'Redo',
tooltip: 'toolbar.redo',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
disabled$: undoRedoService.undoRedoStatus$.pipe(map((v) => v.redos <= 0)),
};
}
@@ -134,7 +137,7 @@ export function FormatPainterMenuItemFactory(accessor: IAccessor): IMenuButtonIt
icon: 'FormatPainterIcon',
title: 'Format Painter',
tooltip: 'toolbar.formatPainter',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
activated$: new Observable<boolean>((subscriber) => {
let active = false;
@@ -164,7 +167,7 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'BoldIcon',
title: 'Set bold',
tooltip: 'toolbar.bold',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable<boolean>((subscriber) => {
let editable = false;
@@ -220,7 +223,7 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'ItalicIcon',
title: 'Set italic',
tooltip: 'toolbar.italic',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable<boolean>((subscriber) => {
let editable = false;
function update() {
@@ -278,7 +281,7 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'UnderLineIcon',
title: 'Set underline',
tooltip: 'toolbar.underline',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable<boolean>((subscriber) => {
let editable = false;
function update() {
@@ -336,7 +339,7 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonIt
icon: 'DeleteLineIcon',
title: 'Set strike through',
tooltip: 'toolbar.strikethrough',
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
disabled$: new Observable<boolean>((subscriber) => {
let editable = false;
function update() {
@@ -542,7 +545,7 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSel
tooltip: 'toolbar.font',
type: MenuItemType.SELECTOR,
display: DisplayTypes.FONT,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
selections: FONT_FAMILY_CHILDREN,
disabled$: new Observable((subscriber) => {
let editable = false;
@@ -605,7 +608,7 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
display: DisplayTypes.INPUT,
min: 1,
max: 400,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
selections: FONT_SIZE_CHILDREN,
disabled$: new Observable<boolean>((subscriber) => {
let editable = false;
@@ -672,7 +675,7 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele
icon: 'TextColorIcon',
tooltip: 'toolbar.textColor.main',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
display: DisplayTypes.COLOR,
selections: [
{
@@ -711,7 +714,7 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMe
tooltip: 'toolbar.fillColor.main',
title: 'TextColorIcon',
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
display: DisplayTypes.COLOR,
icon: 'FillColorIcon',
selections: [
@@ -759,7 +762,7 @@ export function HorizontalAlignMenuItemFactory(accessor: IAccessor): IMenuSelect
id: SetHorizontalTextAlignCommand.id,
title: 'horizontalAlignMode',
icon: HORIZONTAL_ALIGN_CHILDREN[0].icon,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
tooltip: 'toolbar.horizontalAlignMode.main',
display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
@@ -817,7 +820,7 @@ export function VerticalAlignMenuItemFactory(accessor: IAccessor): IMenuSelector
tooltip: 'toolbar.verticalAlignMode.main',
display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
selections: VERTICAL_ALIGN_CHILDREN,
value$: new Observable<VerticalAlign>((subscriber) => {
const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
@@ -871,7 +874,7 @@ export function WrapTextMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<
tooltip: 'toolbar.textWrapMode.main',
icon: TEXT_WRAP_CHILDREN[0].icon,
type: MenuItemType.SELECTOR,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
selections: TEXT_WRAP_CHILDREN,
display: DisplayTypes.ICON,
value$: new Observable((subscriber) => {
@@ -943,7 +946,7 @@ export function TextRotateMenuItemFactory(accessor: IAccessor): IMenuSelectorIte
display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
selections: TEXT_ROTATE_CHILDREN,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
value$: new Observable<number | string>((subscriber) => {
const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
const id = c.id;
@@ -977,6 +980,7 @@ export function CopyMenuItemFactory(): IMenuButtonItem {
id: CopyCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.copy',
+ icon: 'Copy24',
positions: [
MenuPosition.CONTEXT_MENU,
SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
@@ -1003,6 +1007,7 @@ export function PasteMenuItemFactory(): IMenuButtonItem {
id: PasteCommand.id,
type: MenuItemType.BUTTON,
title: 'rightClick.paste',
+ icon: 'PasteSpecial24',
positions: [
MenuPosition.CONTEXT_MENU,
SheetMenuPosition.COL_HEADER_CONTEXT_MENU,
diff --git a/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts
index a96e25b4ef..f083d090d5 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts
@@ -19,7 +19,7 @@ export function CellMergeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem
icon: 'MergeIcon',
tooltip: 'toolbar.mergeCell.main',
display: DisplayTypes.ICON,
- positions: [MenuPosition.TOOLBAR],
+ positions: [MenuPosition.TOOLBAR_START],
type: MenuItemType.SUBITEMS,
// selections: [...MERGE_CHILDREN],
};