Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: add `BorderPanel` & adjust the styling of `ColorPicker` (#445)
白熱daa57e9844ee
diff --git a/package.json b/package.jsonindex 420ba2e8ea..fed398ba3c 100644--- a/package.json+++ b/package.json@@ -73,6 +73,9 @@"lint-staged": {"**/*.{js,ts,tsx}": ["eslint --fix"+ ],+ "**/*.less": [+ "stylelint --fix"]}}diff --git a/packages/base-sheets/src/commands/commands/set-border-command.ts b/packages/base-sheets/src/commands/commands/set-border-command.tsindex a9badbaea5..1826e151df 100644--- a/packages/base-sheets/src/commands/commands/set-border-command.ts+++ b/packages/base-sheets/src/commands/commands/set-border-command.ts@@ -34,6 +34,26 @@ function forEach(range: IRange, action: (row: number, column: number) => void):}}+export interface ISetBorderBasicCommand {+ value: {+ id: string;+ value: string;+ };+}+export const SetBorderBasicCommand: ICommand<ISetBorderBasicCommand> = {+ id: 'sheet.command.set-border-basic',+ type: CommandType.COMMAND,+ handler: async (accessor: IAccessor, params: ISetBorderBasicCommand) => {+ const { value, id } = params.value;++ if (!value || !id) return false;++ const commandService = accessor.get(ICommandService);++ return commandService.executeCommand(id, { value });+ },+};+export interface ISetBorderPositionCommandParams {value: BorderType;}diff --git a/packages/base-sheets/src/controllers/basic-worksheet.controller.ts b/packages/base-sheets/src/controllers/basic-worksheet.controller.tsindex ed1bd9fe1c..26ca46a9a1 100644--- a/packages/base-sheets/src/controllers/basic-worksheet.controller.ts+++ b/packages/base-sheets/src/controllers/basic-worksheet.controller.ts@@ -30,6 +30,7 @@ import { RemoveColCommand, RemoveRowCommand } from '../commands/commands/remove-import { RemoveSheetCommand } from '../commands/commands/remove-sheet.command';import { RemoveWorksheetMergeCommand } from '../commands/commands/remove-worksheet-merge.command';import {+ SetBorderBasicCommand,SetBorderColorCommand,SetBorderCommand,SetBorderPositionCommand,@@ -158,6 +159,7 @@ export class BasicWorksheetController extends Disposable implements IDisposableResetBackgroundColorCommand,ResetTextColorCommand,SetBackgroundColorCommand,+ SetBorderBasicCommand,SetBorderColorCommand,SetBorderCommand,SetBorderPositionCommand,diff --git a/packages/base-sheets/src/index.ts b/packages/base-sheets/src/index.tsindex 056623c1f6..9d70ae768a 100644--- a/packages/base-sheets/src/index.ts+++ b/packages/base-sheets/src/index.ts@@ -69,6 +69,7 @@ export type {ISetBorderStyleCommandParams,} from './commands/commands/set-border-command';export {+ SetBorderBasicCommand,SetBorderColorCommand,SetBorderCommand,SetBorderPositionCommand,diff --git a/packages/base-ui/package.json b/packages/base-ui/package.jsonindex 1590e766c4..b305d22d42 100644--- a/packages/base-ui/package.json+++ b/packages/base-ui/package.json@@ -46,11 +46,10 @@"build:doc": "storybook build"},"dependencies": {- "@rc-component/trigger": "^1.18.1","@univerjs/base-render": "workspace:*","@univerjs/core": "workspace:*","@univerjs/design": "workspace:*",- "@univerjs/icons": "^0.1.7",+ "@univerjs/icons": "^0.1.8","@wendellhu/redi": "^0.12.11","clsx": "^2.0.0","localforage": "^1.10.0",diff --git a/packages/base-ui/src/components/custom-label/CustomLabel.tsx b/packages/base-ui/src/components/custom-label/CustomLabel.tsxindex 363309b279..8ef07c1c1f 100644--- a/packages/base-ui/src/components/custom-label/CustomLabel.tsx+++ b/packages/base-ui/src/components/custom-label/CustomLabel.tsx@@ -43,7 +43,12 @@ export function CustomLabel(props: ICustomLabelProps): JSX.Element | null {const labelName = isStringLabel ? label : label?.name;const CustomComponent = componentManager.get(labelName);- CustomComponent && nodes.push(<CustomComponent key={index++} {...customProps} />);++ if (CustomComponent) {+ nodes.push(<CustomComponent key={index++} {...customProps} />);+ } else {+ nodes.push(<span key={index++}>{localeService.t(labelName)}</span>);+ }}if (title) {nodes.push(<span key={index++}>{localeService.t(title)}</span>);diff --git a/packages/base-ui/src/components/menu/Menu.tsx b/packages/base-ui/src/components/menu/Menu.tsxindex c3fef42880..0542de7817 100644--- a/packages/base-ui/src/components/menu/Menu.tsx+++ b/packages/base-ui/src/components/menu/Menu.tsx@@ -8,17 +8,14 @@ import {import { MoreSingle } from '@univerjs/icons';import { useDependency } from '@wendellhu/redi/react-bindings';import clsx from 'clsx';-import React, { useState } from 'react';+import { useState } from 'react';import { isObservable, of } from 'rxjs';-import { ComponentManager } from '../../Common';import {- ICustomComponentOption,IDisplayMenuItem,IMenuButtonItem,IMenuItem,IMenuSelectorItem,- isValueOptions,IValueOption,MenuGroup,MenuItemDefaultValueType,@@ -36,7 +33,7 @@ export interface IBaseMenuProps {menuType?: string | string[];value?: string | number;- options?: Array<IValueOption | ICustomComponentOption>;+ options?: IValueOption[];onOptionSelect?: (option: IValueOption) => void;}@@ -103,48 +100,36 @@ function MenuWrapper(props: IBaseMenuProps) {function MenuOptionsWrapper(props: IBaseMenuProps) {const { options, value, onOptionSelect, parentKey } = props;- const componentManager = useDependency(ComponentManager);+ return options?.map((option: IValueOption, index: number) => {+ const key = `${parentKey}-${option.label ?? option.id}-${index}`;- return options?.map((option: IValueOption | ICustomComponentOption, index: number) => {- const isValueOption = isValueOptions(option);- const key = `${parentKey}-${isValueOption ? option.label : option.id}-${index}`;+ const onChange = (v: string | number) => {+ onOptionSelect?.({ value: v, label: option?.label });+ };- if (isValueOption) {- return (- <DesignMenuItem- key={key}- eventKey={key}- onClick={() => {- onOptionSelect?.({- ...option,- });- }}- >- <span className={styles.menuItemContent}>- <CustomLabel- selected={String(value) === String(option.value)} // use √ for select- value={String(option.value)}- label={option.label}- title={typeof option.label === 'string' ? option.label : ''}- icon={option.icon}- />- </span>- </DesignMenuItem>- );- }+ const handleClick = () => {+ if (typeof option.value === 'undefined') return;++ onOptionSelect?.({+ ...option,+ });+ };- const CustomComponent = componentManager.get(option.id) as React.ComponentType<any>;+ const _className = clsx({+ [styles.menuItemNoHover]: typeof option.label !== 'string' && !option.label?.hoverable,+ });return (- <DesignMenuItem key={key} eventKey={key} className={clsx(styles.menuItemCustom)}>- <CustomComponent- onValueChange={(v: string | number) => {- onOptionSelect?.({- value: v,- label: option.id,- });- }}- />+ <DesignMenuItem key={key} eventKey={key} className={_className} onClick={handleClick}>+ <span className={styles.menuItemContent}>+ <CustomLabel+ selected={typeof value !== 'undefined' && value === option.value}+ value={option.value}+ label={option.label}+ icon={option.icon}+ onChange={onChange}+ />+ </span></DesignMenuItem>);});@@ -189,13 +174,13 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {<DesignMenuItemkey={item.id}eventKey={item.id}- // disabled={disabled} // FIXME disabled is not working+ disabled={disabled}onClick={() => {onClick({ value: inputValue, id: item.id }); // merge cell}}><span className={styles.menuItemContent}>- <CustomLabel value={inputValue} title={title} label={label} icon={item.icon} onChange={onChange} />+ <CustomLabel value={value} title={title} label={label} icon={item.icon} onChange={onChange} /></span></DesignMenuItem>);@@ -204,13 +189,9 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {const renderSelectorType = () => {const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;- let selections: Array<IValueOption | ICustomComponentOption>;+ let selections: IValueOption[];if (isObservable(item.selections)) {- selections = useObservable<Array<IValueOption | ICustomComponentOption>>(- item.selections || of([]),- [],- true- );+ selections = useObservable<IValueOption[]>(item.selections || of([]), [], true);} else {selections = item.selections || [];}@@ -241,7 +222,7 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {menuType={item.id}options={selections}onOptionSelect={(v) => {- onClick({ value: v.value, id: item.id }); // border style don't trigger hide menu, set show true+ onClick({ value: v.value, id: item.id });}}/>)}@@ -255,9 +236,9 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {<CustomLabeltitle={item.title}value={inputValue}- onChange={onChange}icon={item.icon}label={item.label}+ onChange={onChange}/>{item.shortcut && ` (${item.shortcut})`}</span>@@ -267,6 +248,7 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {const renderSubItemsType = () => {const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;+ console.log(item);return (<DesignSubMenu@@ -275,7 +257,7 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {popupOffset={[18, 0]}title={<span className={styles.menuItemContent}>- <CustomLabel title={item.title} value={item.title} icon={item.icon} label={item.label} />+ <CustomLabel title={item.title} icon={item.icon} label={item.label} onChange={onChange} /></span>}expandIcon={<MoreSingle className={styles.menuItemMoreIcon} />}diff --git a/packages/base-ui/src/components/menu/index.module.less b/packages/base-ui/src/components/menu/index.module.lessindex 71fe109e36..95bb540cc6 100644--- a/packages/base-ui/src/components/menu/index.module.less+++ b/packages/base-ui/src/components/menu/index.module.less@@ -1,6 +1,6 @@.menu {&-item {- &-custom {+ &-no-hover {background: none;}diff --git a/packages/base-ui/src/index.ts b/packages/base-ui/src/index.tsindex 6be8275c28..4cf8f0998c 100644--- a/packages/base-ui/src/index.ts+++ b/packages/base-ui/src/index.ts@@ -26,15 +26,12 @@ export {export { DesktopDialogService } from './services/dialog/desktop-dialog.service';export { IDialogService } from './services/dialog/dialog.service';export {- type ICustomComponentOption,type ICustomComponentProps,type IDisplayMenuItem,type IMenuButtonItem,type IMenuItem,type IMenuItemFactory,type IMenuSelectorItem,- isCustomComponentOption,- isValueOptions,type IValueOption,MenuGroup,MenuItemType,diff --git a/packages/base-ui/src/services/menu/menu.ts b/packages/base-ui/src/services/menu/menu.tsindex b90d656eae..b2f20b7827 100644--- a/packages/base-ui/src/services/menu/menu.ts+++ b/packages/base-ui/src/services/menu/menu.ts@@ -62,8 +62,9 @@ interface IMenuItemBase<V> {| string| {name: string;- props?: Record<string, string | number>;- };+ hoverable?: boolean;+ props?: Record<string, string | number | Array<{ [x: string | number]: string }>>;+ }; // custom component, send to CustomLabel label propertyhidden$?: Observable<boolean>;disabled$?: Observable<boolean>;@@ -78,12 +79,13 @@ export interface IMenuButtonItem<V = undefined> extends IMenuItemBase<V> {}export interface IValueOption {- value: string | number;- label:+ value?: string | number;+ label?:| string| {name: string;- props?: Record<string, string | number>;+ hoverable?: boolean;+ props?: Record<string, string | number | Array<{ [x: string | number]: string }>>;}; // custom component, send to CustomLabel label propertyicon?: string;tooltip?: string;@@ -92,24 +94,11 @@ export interface IValueOption {id?: string; // command id}-export function isValueOptions(v: IValueOption | ICustomComponentOption): v is IValueOption {- return typeof (v as IValueOption).value !== 'undefined';-}--export interface ICustomComponentOption {- id: string;- disabled?: boolean;-}-export interface ICustomComponentProps<T> {value: T;onChange: (v: T) => void;}-export function isCustomComponentOption(v: IValueOption | ICustomComponentOption): v is ICustomComponentOption {- return typeof (v as ICustomComponentOption).id !== 'undefined';-}-export interface IMenuSelectorItem<V = MenuItemDefaultValueType> extends IMenuItemBase<V> {type: MenuItemType.SELECTOR | MenuItemType.SUBITEMS;@@ -118,9 +107,7 @@ export interface IMenuSelectorItem<V = MenuItemDefaultValueType> extends IMenuIt// 一个是一个特殊组件,比如 color picker,选中后直接使用其 value 触发 command// 一个是其他 menu 的 id,直接渲染成其他的 menu/** Options or IDs of registered components. */- selections?:- | Array<IValueOption | ICustomComponentOption>- | Observable<Array<IValueOption | ICustomComponentOption>>;+ selections?: IValueOption[] | Observable<IValueOption[]>;}export function isMenuSelectorItem<T extends MenuItemDefaultValueType>(v: IMenuItem): v is IMenuSelectorItem<T> {diff --git a/packages/base-ui/src/views/components/doc-bars/index.module.less b/packages/base-ui/src/views/components/doc-bars/index.module.lessindex 4845e10ec1..48823aa433 100644--- a/packages/base-ui/src/views/components/doc-bars/index.module.less+++ b/packages/base-ui/src/views/components/doc-bars/index.module.less@@ -93,10 +93,10 @@height: @toolbar-btn-size;padding: 0 var(--padding-xs);- border-radius: var(--border-radius-base);-font-size: var(--font-size-xl);+ border-radius: var(--border-radius-base);+&:hover {background-color: rgb(var(--grey-100));border-radius: var(--border-radius-base);diff --git a/packages/design/package.json b/packages/design/package.jsonindex 2055d007af..b65014f053 100644--- a/packages/design/package.json+++ b/packages/design/package.json@@ -47,7 +47,7 @@"dependencies": {"@rc-component/color-picker": "^1.4.1","@rc-component/trigger": "^1.18.1",- "@univerjs/icons": "^0.1.7",+ "@univerjs/icons": "^0.1.8","clsx": "^2.0.0","rc-dialog": "^9.3.4","rc-dropdown": "^4.1.0",diff --git a/packages/design/src/components/avatar/__tests__/index.spec.tsx b/packages/design/src/components/avatar/__tests__/index.spec.tsxindex aac0ceeddc..ddb10c0e8d 100644--- a/packages/design/src/components/avatar/__tests__/index.spec.tsx+++ b/packages/design/src/components/avatar/__tests__/index.spec.tsx@@ -14,4 +14,10 @@ describe('Avatar', () => {const childrenElement = getByText('Test');expect(childrenElement).not.toBeNull();});++ test('renders the image', () => {+ const { container } = render(<Avatar src="test.png" />);++ expect(container.querySelector('img')).not.toBeNull();+ });});diff --git a/packages/design/src/components/checkbox-group/__tests__/index.spec.tsx b/packages/design/src/components/checkbox-group/__tests__/index.spec.tsxindex eda1a2e44b..f37c1b245c 100644--- a/packages/design/src/components/checkbox-group/__tests__/index.spec.tsx+++ b/packages/design/src/components/checkbox-group/__tests__/index.spec.tsx@@ -1,4 +1,5 @@-import { fireEvent, render, screen } from '@testing-library/react';+import { fireEvent, render } from '@testing-library/react';+import { useState } from 'react';import { describe, expect, test } from 'vitest';import { Checkbox } from '../../checkbox/Checkbox';@@ -21,8 +22,30 @@ describe('CheckboxGroup', () => {test('click Checkbox', async () => {render(group);- fireEvent.click(screen.getByText('1'));+ let result = ['0'];+ function Demo() {+ const [active, setActive] = useState(result);- expect(active).toEqual(['0', '1']);+ return (+ <CheckboxGroup+ value={active}+ onChange={(value) => {+ setActive(value as string[]);+ result = value as string[];+ }}+ >+ <Checkbox value="0">x</Checkbox>+ <Checkbox value="1">y</Checkbox>+ </CheckboxGroup>+ );+ }++ const { getByText } = render(<Demo />);++ fireEvent.click(getByText('y'));+ fireEvent.click(getByText('y'));+ fireEvent.click(getByText('y'));++ expect(result).toEqual(['0', '1']);});});diff --git a/packages/design/src/components/color-picker/ColorPicker.tsx b/packages/design/src/components/color-picker/ColorPicker.tsxindex 412037aa78..9d840b257b 100644--- a/packages/design/src/components/color-picker/ColorPicker.tsx+++ b/packages/design/src/components/color-picker/ColorPicker.tsx@@ -1,7 +1,5 @@import RcColorPicker, { Color, ColorBlock } from '@rc-component/color-picker';-import { useContext, useState } from 'react';-import { ConfigContext } from '../config-provider/ConfigProvider';import styles from './index.module.less';import { colorPresets } from './presets';@@ -10,20 +8,11 @@ export interface IColorPickerProps {onClick?: (color: string, e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;- onValueChange?: (value: string) => void;-}--enum ColorPickerMode {- PRESET,- CUSTOM,+ onChange?: (value: string) => void;}export function ColorPicker(props: IColorPickerProps) {- const { onValueChange } = props;-- const [mode, setMode] = useState<ColorPickerMode>(ColorPickerMode.PRESET);-- const { locale } = useContext(ConfigContext);+ const { onChange } = props;function handleStopPropagation(e: React.MouseEvent) {e.stopPropagation();@@ -32,41 +21,26 @@ export function ColorPicker(props: IColorPickerProps) {function handleChange(color: Color | string) {const value = (typeof color === 'string' ? color : color.toHexString()) ?? '';- onValueChange && onValueChange(value);- }-- function handleToggleMode(e: React.MouseEvent) {- e.stopPropagation();- setMode(mode === ColorPickerMode.PRESET ? ColorPickerMode.CUSTOM : ColorPickerMode.PRESET);+ onChange?.(value);}return (<section>- {mode === ColorPickerMode.PRESET && (- <div>- <div className={styles.colorPickerColorBlocks}>- {colorPresets.map((color) => (- <ColorBlock- key={color}- prefixCls={styles.colorPicker}- color={color}- onClick={() => handleChange(color)}- />- ))}- </div>- <a className={styles.colorPickerCustomBtn} onClick={handleToggleMode}>- {locale.design.ColorPicker.custom}- </a>+ <div>+ <div className={styles.colorPickerColorBlocks}>+ {colorPresets.map((color) => (+ <ColorBlock+ key={color}+ prefixCls={styles.colorPicker}+ color={color}+ onClick={() => handleChange(color)}+ />+ ))}</div>- )}- {mode === ColorPickerMode.CUSTOM && (- <section onClick={handleStopPropagation}>- <RcColorPicker prefixCls={styles.colorPicker} disabledAlpha onChangeComplete={handleChange} />- <a className={styles.colorPickerCancelBtn} onClick={handleToggleMode}>- {locale.design.ColorPicker.cancel}- </a>- </section>- )}+ </div>+ <section onClick={handleStopPropagation}>+ <RcColorPicker prefixCls={styles.colorPicker} disabledAlpha onChangeComplete={handleChange} />+ </section></section>);}diff --git a/packages/design/src/components/color-picker/index.module.less b/packages/design/src/components/color-picker/index.module.lessindex 0470c893b6..a64a40b316 100644--- a/packages/design/src/components/color-picker/index.module.less+++ b/packages/design/src/components/color-picker/index.module.less@@ -10,7 +10,7 @@display: block;width: max-content;- min-width: 272px;+ min-width: 232px;visibility: visible;@@ -22,9 +22,9 @@display: flex;flex-direction: column;- width: 272px;+ width: 232px;- background-color: #fff;+ background-color: rgb(var(--white-color));border-radius: @outer-border-radius;&-disabled {@@ -37,7 +37,7 @@.color-picker-palette {overflow: hidden;- min-height: 160px;+ min-height: 100px;border-radius: @inner-border-radius;& > .color-picker-gradient {@@ -53,6 +53,8 @@}&-handler {+ transform: translateY(-1px);+box-sizing: border-box;width: @default-handler-size;height: @default-handler-size;@@ -74,24 +76,14 @@}}- &-custom-btn {- cursor: pointer;- font-size: var(--font-size-base);- color: rgb(var(--text-color));- }-- &-cancel-btn {- cursor: pointer;- font-size: var(--font-size-base);- color: rgb(var(--text-color));- }&-color-blocks {display: grid;grid-template-columns: repeat(10, 1fr);grid-template-rows: repeat(9, 1fr);- gap: var(--margin-xs);+ gap: var(--margin-xxs);+ width: 232px;margin-bottom: var(--margin-xs);}@@ -102,8 +94,8 @@overflow: hidden;- width: 20px;- height: 20px;+ width: 18px;+ height: 18px;border-radius: @inner-border-radius;@@ -119,7 +111,8 @@&-slider-container {display: flex;- margin-bottom: var(--margin-xs);+ flex-direction: row-reverse;+ gap: var(--margin-sm);.color-picker-slider-group {flex: 1;diff --git a/packages/design/src/components/config-provider/ColorPicker.stories.tsx b/packages/design/src/components/config-provider/ConfigProvider.stories.tsxsimilarity index 78%rename from packages/design/src/components/config-provider/ColorPicker.stories.tsxrename to packages/design/src/components/config-provider/ConfigProvider.stories.tsxindex 23afe4dbb0..176699d04a 100644--- a/packages/design/src/components/config-provider/ColorPicker.stories.tsx+++ b/packages/design/src/components/config-provider/ConfigProvider.stories.tsx@@ -3,7 +3,7 @@ import { useState } from 'react';import { enUS, type ILocale, zhCN } from '../../locale';import { Button } from '../button/Button';-import { ColorPicker } from '../color-picker/ColorPicker';+import { Confirm } from '../confirm/Confirm';import { ConfigProvider } from './ConfigProvider';const meta: Meta<typeof ConfigProvider> = {@@ -19,10 +19,12 @@ export default meta;export const Playground = {render() {+ const [visible, setVisible] = useState(false);const [locale, setLocale] = useState(enUS);function handleChangeLocale(locale: ILocale) {setLocale(locale);+ setVisible(true);}return (@@ -30,7 +32,9 @@ export const Playground = {<Button onClick={() => handleChangeLocale(enUS)}>enUS</Button><Button onClick={() => handleChangeLocale(zhCN)}>zhCN</Button><ConfigProvider locale={locale} mountContainer={document.body}>- <ColorPicker />+ <Confirm visible={visible} onClose={() => setVisible(false)}>+ xx+ </Confirm></ConfigProvider></>);diff --git a/packages/design/src/components/config-provider/ConfigProvider.tsx b/packages/design/src/components/config-provider/ConfigProvider.tsxindex 99d6a3fdc4..f89d9164d2 100644--- a/packages/design/src/components/config-provider/ConfigProvider.tsx+++ b/packages/design/src/components/config-provider/ConfigProvider.tsx@@ -14,7 +14,7 @@ export const ConfigContext = createContext<Omit<IConfigProviderProps, 'children'});export function ConfigProvider(props: IConfigProviderProps) {- const { children, locale = {}, mountContainer } = props;+ const { children, locale, mountContainer } = props;// set default locale to enUSlet _locale: ILocale;diff --git a/packages/design/src/components/config-provider/__tests__/index.spec.tsx b/packages/design/src/components/config-provider/__tests__/index.spec.tsxnew file mode 100644index 0000000000..0af161a1da--- /dev/null+++ b/packages/design/src/components/config-provider/__tests__/index.spec.tsx@@ -0,0 +1,83 @@+import { render } from '@testing-library/react';+import { useContext } from 'react';+import { describe, expect, test } from 'vitest';++import { enUS, ILocale, zhCN } from '../../../locale';+import { ConfigContext, ConfigProvider } from '../ConfigProvider';++describe('ConfigProvider', () => {+ test('should render correctly', () => {+ let _mountContainer: HTMLElement | null = null;+ let _locale: ILocale | null = null;++ function Empty() {+ const { locale, mountContainer } = useContext(ConfigContext);++ _locale = locale;+ _mountContainer = mountContainer;++ return <></>;+ }++ const root = render(+ <ConfigProvider locale={zhCN} mountContainer={document.body}>+ <Empty />+ </ConfigProvider>+ );++ expect(_locale).equals(zhCN);+ expect(_mountContainer).equals(document.body);++ root.unmount();+ });++ test('should render correctly when mountContainer is not document.body', () => {+ const mountContainer = document.createElement('div');+ document.body.appendChild(mountContainer);++ let _mountContainer: HTMLElement | null = null;++ function Empty() {+ const { mountContainer } = useContext(ConfigContext);++ _mountContainer = mountContainer;++ return <></>;+ }++ const root = render(+ <ConfigProvider locale={zhCN} mountContainer={mountContainer}>+ <Empty />+ </ConfigProvider>+ );++ expect(_mountContainer).equals(mountContainer);++ root.unmount();+ });++ test('should render correctly when locale is invalid', () => {+ const mountContainer = document.createElement('div');+ document.body.appendChild(mountContainer);++ let _locale: ILocale | null = null;++ function Empty() {+ const { locale } = useContext(ConfigContext);++ _locale = locale;++ return <></>;+ }++ const root = render(+ <ConfigProvider locale={{} as any} mountContainer={mountContainer}>+ <Empty />+ </ConfigProvider>+ );++ expect(_locale).equals(enUS);++ root.unmount();+ });+});diff --git a/packages/design/src/components/layout/Layout.stories.tsx b/packages/design/src/components/layout/Layout.stories.tsxdeleted file mode 100644index 8013214798..0000000000--- a/packages/design/src/components/layout/Layout.stories.tsx+++ /dev/null@@ -1,31 +0,0 @@-import type { Meta } from '@storybook/react';--import { Content, Footer, Header, Layout, Sider } from './Layout';--const meta: Meta<typeof Layout> = {- title: 'Components / Layout',- component: Layout,- parameters: {- layout: 'centered',- },- tags: ['autodocs'],-};--export default meta;--export const SiderLayout = {- title: 'Sider',- args: {- style: { width: '640px', height: '320px' },- children: (- <>- <Sider style={{ color: '#fff', background: '#001529' }}>aside</Sider>- <Content style={{ padding: '24px', background: '#f5f5f5', display: 'flex', flexDirection: 'column' }}>- <Header style={{ color: '#fff', background: '#001529' }}>header</Header>- <Content style={{ background: '#fff' }}>content</Content>- <Footer style={{ color: '#fff', background: '#001529' }}>footer</Footer>- </Content>- </>- ),- },-};diff --git a/packages/design/src/components/layout/Layout.tsx b/packages/design/src/components/layout/Layout.tsxdeleted file mode 100644index f9ec53e87c..0000000000--- a/packages/design/src/components/layout/Layout.tsx+++ /dev/null@@ -1,132 +0,0 @@-import clsx from 'clsx';-import { useEffect, useRef, useState } from 'react';--import styles from './index.module.less';--function getFirstChild(obj: HTMLElement) {- const objChild = [];- const objs = obj.getElementsByTagName('*');-- for (let i = 0, j = objs.length; i < j; ++i) {- if (objs[i].nodeType !== Node.ELEMENT_NODE) {- continue;- }- const node = objs[i].parentNode;- if (node && node.nodeType === 1) {- if (node === obj) {- objChild[objChild.length] = objs[i];- }- } else if (node && node.parentNode === obj) {- objChild[objChild.length] = objs[i];- }- }-- return objChild;-}--export interface ILayoutProps {- children?: React.ReactNode;-- /** Semantic DOM class */- className?: string;-- /** Semantic DOM style */- style?: React.CSSProperties;-}--/**- * Layout Component- */-export function Layout({ children, style, className }: ILayoutProps) {- const [isAside, setIsAside] = useState(false);- const ref = useRef<HTMLTableSectionElement>(null);-- // If the first child element contains the `aside` component, the layout needs to be changed to horizontal arrangement- useEffect(() => {- if (ref.current) {- const children = getFirstChild(ref.current);- const childrens = children instanceof Array ? children : [children];-- for (const ele of childrens) {- if (ele.tagName === 'ASIDE') {- setIsAside(true);- break;- }- }- }- }, []);-- const _className = clsx(- styles.layoutWrapper,- {- [styles.layoutWrapperHasSider]: isAside,- },- className- );-- return (- <section ref={ref} className={_className} style={style}>- {children}- </section>- );-}--/**- * Header Component- */-export const Header = (props: ILayoutProps) => {- const { children, className, style } = props;-- const _className = clsx(styles.headerWrapper, className);-- return (- <header className={_className} style={style}>- {children}- </header>- );-};--/**- * Footer Component- */-export function Footer(props: ILayoutProps) {- const { children, className, style } = props;-- const _className = clsx(styles.footerWrapper, className);-- return (- <footer className={_className} style={style}>- {children}- </footer>- );-}--/**- * Content Component- */-export function Content(props: ILayoutProps) {- const { children, className, style } = props;-- const _className = clsx(styles.contentWrapper, className);-- return (- <main className={_className} style={style}>- {children}- </main>- );-}--/**- * Sider Component- */-export function Sider(props: ILayoutProps) {- const { children, className, style } = props;-- const _className = clsx(styles.siderWrapper, className);-- return (- <aside className={_className} style={style}>- {children}- </aside>- );-}diff --git a/packages/design/src/components/layout/__tests__/index.spec.tsx b/packages/design/src/components/layout/__tests__/index.spec.tsxdeleted file mode 100644index 1a7e3414c0..0000000000--- a/packages/design/src/components/layout/__tests__/index.spec.tsx+++ /dev/null@@ -1,12 +0,0 @@-import { render } from '@testing-library/react';-import { describe, expect, test } from 'vitest';--import { Layout } from '../Layout';--describe('Layout', () => {- test('should display initial Layout', () => {- const { container } = render(<Layout>layout content Text</Layout>);-- expect(container.textContent).toMatch('layout content Text');- });-});diff --git a/packages/design/src/components/layout/index.module.less b/packages/design/src/components/layout/index.module.lessdeleted file mode 100644index 47bbd295f2..0000000000--- a/packages/design/src/components/layout/index.module.less+++ /dev/null@@ -1,32 +0,0 @@-.layout-wrapper {- overflow: hidden;- display: flex;- flex: auto;- flex-direction: column;-- height: 100%;- min-height: 0;-- &&-has-sider {- flex-direction: row;- }-}--.header-wrapper {- user-select: none;- flex: 0 0 auto;-}--.footer-wrapper {- flex: 0 0 auto;-}--.content-wrapper {- flex: auto;- min-height: 0;-}--.sider-wrapper {- flex-direction: row;- width: 200px;-}diff --git a/packages/design/src/components/layout/index.ts b/packages/design/src/components/layout/index.tsdeleted file mode 100644index fa362a0972..0000000000--- a/packages/design/src/components/layout/index.ts+++ /dev/null@@ -1 +0,0 @@-export { Content, Footer, Header, type ILayoutProps, Layout, Sider } from './Layout';diff --git a/packages/design/src/components/menu/index.module.less b/packages/design/src/components/menu/index.module.lessindex ee39dff8ca..5b64595e5a 100644--- a/packages/design/src/components/menu/index.module.less+++ b/packages/design/src/components/menu/index.module.less@@ -14,7 +14,7 @@&-vertical {display: grid;- gap: var(--margin-xxs);+ gap: var(--margin-xs);}&-hidden,@@ -25,7 +25,7 @@&-item {&-group {&:not(:last-child) {- padding-bottom: var(--padding-xs);+ padding-bottom: var(--padding-sm);border-bottom: 1px solid rgb(var(--border-color));}}diff --git a/packages/design/src/components/slider/Slider.tsx b/packages/design/src/components/slider/Slider.tsxindex 826479811e..b322899112 100644--- a/packages/design/src/components/slider/Slider.tsx+++ b/packages/design/src/components/slider/Slider.tsx@@ -9,11 +9,6 @@ import { Dropdown } from '../dropdown/Dropdown';import { Tooltip } from '../tooltip/Tooltip';import styles from './index.module.less';-/**- * TODO:- * 2. Localization '恢复至 100%'- */-export interface ISliderProps {/** The value of slider. When range is false, use number, otherwise, use [number, number] */value: number;@@ -128,14 +123,14 @@ export function Slider(props: ISliderProps) {</Button><div className={styles.sliderRail}>- <div ref={sliderInnerRailRef} className={styles.sliderInnerRail}>+ <div ref={sliderInnerRailRef} role="track" className={styles.sliderInnerRail}><Tooltip title={`${locale.design.Slider.resetTo} ${resetPoint}%`}>- <a className={styles.sliderResetPoint} onClick={handleReset} />+ <a className={styles.sliderResetPoint} role="reset button" onClick={handleReset} /></Tooltip><divclassName={styles.sliderHandle}- role="slider"+ role="handle"style={{left: `${offset}%`,}}diff --git a/packages/design/src/components/slider/__test__/index.spec.tsx b/packages/design/src/components/slider/__test__/index.spec.tsxindex bd39006628..4cb5aeaada 100644--- a/packages/design/src/components/slider/__test__/index.spec.tsx+++ b/packages/design/src/components/slider/__test__/index.spec.tsx@@ -1,4 +1,5 @@-import { render } from '@testing-library/react';+import { fireEvent, render, screen } from '@testing-library/react';+import { useState } from 'react';import { describe, expect, test } from 'vitest';import { Slider } from '../Slider';@@ -8,4 +9,65 @@ describe('Slider', () => {const { container } = render(<Slider min={0} max={100} value={90} />);expect(container);});++ test('renders correctly with resetPoint', () => {+ let value = 90;++ function handleChange(point: number) {+ value = point;+ }++ const { container } = render(<Slider value={value} resetPoint={30} onChange={handleChange} />);++ fireEvent.click(container.querySelector('[role=reset button]')!);++ expect(value).toBe(30);+ });++ test('renders correctly with steps', () => {+ let result = 10;+ function Demo() {+ const [value, setValue] = useState(result);++ function handleChange(point: number) {+ setValue(point);+ result = point;+ }++ return <Slider max={20} value={value} onChange={handleChange} />;+ }++ const { container } = render(<Demo />);++ const [prev, next] = container.querySelectorAll('button');++ fireEvent.click(prev);+ fireEvent.click(prev);+ fireEvent.click(next);+ fireEvent.click(next);+ fireEvent.click(next);++ expect(result).toBe(20);+ });++ test('renders correctly with shortcuts', () => {+ let result = 10;+ function Demo() {+ const [value, setValue] = useState(result);++ function handleChange(point: number) {+ setValue(point);+ result = point;+ }++ return <Slider value={value} shortcuts={[10, 50]} onChange={handleChange} />;+ }++ const { container } = render(<Demo />);++ fireEvent.click(screen.getByText('10%'));+ fireEvent.click(screen.getByText('50%'));++ expect(result).toBe(50);+ });});diff --git a/packages/design/src/index.ts b/packages/design/src/index.tsindex 0cc89751e4..de4004433f 100644--- a/packages/design/src/index.ts+++ b/packages/design/src/index.ts@@ -10,7 +10,6 @@ export { Dialog, type IDialogProps } from './components/dialog';export { Dropdown, type IDropdownProps } from './components/dropdown';export { type IInputProps, Input } from './components/input';export { type IInputNumberProps, InputNumber } from './components/input-number';-export { Content, Footer, Header, type ILayoutProps, Layout, Sider } from './components/layout';export { Menu, MenuItem, MenuItemGroup, SubMenu } from './components/menu';export { type IMessageMethodOptions, type IMessageProps, Message, MessageType } from './components/message';export { type IRadioProps, Radio } from './components/radio';diff --git a/packages/design/src/locale/en-US.ts b/packages/design/src/locale/en-US.tsindex 3c8d13d58d..02dd0ba181 100644--- a/packages/design/src/locale/en-US.ts+++ b/packages/design/src/locale/en-US.ts@@ -2,10 +2,6 @@ import { ILocale } from './interface';const locale: ILocale = {design: {- ColorPicker: {- custom: 'CUSTOM',- cancel: 'CANCEL',- },Confirm: {cancel: 'cancel',confirm: 'ok',diff --git a/packages/design/src/locale/interface.ts b/packages/design/src/locale/interface.tsindex 2d9083d43f..1b2cbb8d51 100644--- a/packages/design/src/locale/interface.ts+++ b/packages/design/src/locale/interface.ts@@ -1,6 +1,5 @@export interface ILocale {design: {- ColorPicker: Record<string, any>;Confirm: Record<string, any>;Slider: Record<string, any>;};diff --git a/packages/design/src/locale/zh-CN.ts b/packages/design/src/locale/zh-CN.tsindex 1c74e1394f..fb7dcf0f02 100644--- a/packages/design/src/locale/zh-CN.ts+++ b/packages/design/src/locale/zh-CN.ts@@ -2,10 +2,6 @@ import { ILocale } from './interface';const locale: ILocale = {design: {- ColorPicker: {- custom: '自定义',- cancel: '取消',- },Confirm: {cancel: '取消',confirm: '确定',diff --git a/packages/design/vitest.config copy.ts b/packages/design/vitest.config copy.tsdeleted file mode 100644index 3c74cf802f..0000000000--- a/packages/design/vitest.config copy.ts+++ /dev/null@@ -1,9 +0,0 @@-import { defineConfig } from 'vitest/config';--export default defineConfig({- test: {- coverage: {- provider: 'istanbul',- },- },-});diff --git a/packages/sheets-plugin-formula/package.json b/packages/sheets-plugin-formula/package.jsonindex 5e4aa15364..8bf03437d4 100644--- a/packages/sheets-plugin-formula/package.json+++ b/packages/sheets-plugin-formula/package.json@@ -27,7 +27,7 @@"@univerjs/base-ui": "workspace:*","@univerjs/core": "workspace:*","@univerjs/design": "workspace:*",- "@univerjs/icons": "^0.1.7",+ "@univerjs/icons": "^0.1.8","@univerjs/ui-plugin-sheets": "workspace:*","@wendellhu/redi": "^0.12.11","react": "^18.2.0",diff --git a/packages/ui-plugin-docs/src/views/doc-container/DocContainer.tsx b/packages/ui-plugin-docs/src/views/doc-container/DocContainer.tsxindex cb84df9673..04f424cd1e 100644--- a/packages/ui-plugin-docs/src/views/doc-container/DocContainer.tsx+++ b/packages/ui-plugin-docs/src/views/doc-container/DocContainer.tsx@@ -1,5 +1,4 @@import { BaseComponentProps } from '@univerjs/base-ui';-import { Container, Content, Footer, Layout, Sider } from '@univerjs/design';import { Component, createRef } from 'react';import { IDocUIPluginConfig } from '../../basics';@@ -152,19 +151,19 @@ export class DocContainer extends Component<BaseDocContainerProps> {const config = layout?.docContainerConfig!;// Set Provider for entire Containerreturn (- <Container className={style.layoutContainer}>- <Layout>- <Sider style={{ display: config.outerLeft ? 'block' : 'none' }}></Sider>- <Layout className={style.mainContent} style={{ position: 'relative' }}>- <Layout>- <Sider+ <section className={style.layoutContainer}>+ <div>+ <aside style={{ display: config.outerLeft ? 'block' : 'none' }}></aside>+ <div className={style.mainContent} style={{ position: 'relative' }}>+ <div>+ <asidestyle={{display: config.innerLeft ? 'block' : 'none',}}>{/* innerLeft */}- </Sider>- <Content+ </aside>+ <divclassName={config.contentSplit === 'vertical'? style.contentContainerVertical@@ -172,44 +171,44 @@ export class DocContainer extends Component<BaseDocContainerProps> {}>{!!config.contentSplit && (- <Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>+ <div ref={this.splitLeftRef} className={style.contentInnerLeftContainer}><divclassName={style.hoverCursor}onMouseDown={this.handleSplitBarMouseDown}></div>- </Container>+ </div>)}- <Container+ <divonContextMenu={(e) => e.preventDefault()}ref={this.contentRef}className={style.contentInnerRightContainer}- ></Container>+ ></div>{/* extend main content */}- </Content>+ </div>- <Sider+ <asidestyle={{display: config.innerRight ? 'block' : 'none',}}>{/* innerRight */}{/* <SideGroup></SideGroup> */}- </Sider>- </Layout>- <Footer+ </aside>+ </div>+ <footerstyle={{display: config.footer ? 'block' : 'none',}}- ></Footer>- </Layout>- <Sider+ ></footer>+ </div>+ <asidestyle={{display: config.outerRight ? 'block' : 'none',}}className={style.outerRightContainer}- ></Sider>- </Layout>- </Container>+ ></aside>+ </div>+ </section>);}}diff --git a/packages/ui-plugin-sheets/package.json b/packages/ui-plugin-sheets/package.jsonindex b5dff3a61c..dd89e5c867 100644--- a/packages/ui-plugin-sheets/package.json+++ b/packages/ui-plugin-sheets/package.json@@ -53,7 +53,7 @@"@univerjs/base-ui": "workspace:*","@univerjs/core": "workspace:*","@univerjs/design": "workspace:*",- "@univerjs/icons": "^0.1.7",+ "@univerjs/icons": "^0.1.8","@wendellhu/redi": "^0.12.11","react": "^18.2.0","react-dom": "^18.2.0",diff --git a/packages/ui-plugin-sheets/src/components/border-line/index.ts b/packages/ui-plugin-sheets/src/components/border-line/index.tsdeleted file mode 100644index 7334ed0eb7..0000000000--- a/packages/ui-plugin-sheets/src/components/border-line/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { BorderLine } from './BorderLine';-export { BORDER_LINE_COMPONENT } from './interface';diff --git a/packages/ui-plugin-sheets/src/components/border-line/interface.ts b/packages/ui-plugin-sheets/src/components/border-line/interface.tsdeleted file mode 100644index 302088291c..0000000000--- a/packages/ui-plugin-sheets/src/components/border-line/interface.ts+++ /dev/null@@ -1,10 +0,0 @@-import { ICustomComponentProps } from '@univerjs/base-ui';-import { BorderStyleTypes } from '@univerjs/core';--import { COMPONENT_PREFIX } from '../const';--export const BORDER_LINE_COMPONENT = `${COMPONENT_PREFIX}_BORDER_LINE_COMPONENT`;--export interface IBorderLineProps extends ICustomComponentProps<string> {- type: BorderStyleTypes;-}diff --git a/packages/ui-plugin-sheets/src/components/border-panel/BorderPanel.tsx b/packages/ui-plugin-sheets/src/components/border-panel/BorderPanel.tsxnew file mode 100644index 0000000000..27fc722f0f--- /dev/null+++ b/packages/ui-plugin-sheets/src/components/border-panel/BorderPanel.tsx@@ -0,0 +1,203 @@+import { ComponentManager } from '@univerjs/base-ui';+import { BorderStyleTypes } from '@univerjs/core';+import { ColorPicker, Dropdown, Menu, MenuItem } from '@univerjs/design';+import { MoreDownSingle, PaintBucket } from '@univerjs/icons';+import { useDependency } from '@wendellhu/redi/react-bindings';++import { BorderLine } from './border-line/BorderLine';+import styles from './index.module.less';+import { BorderPanelType, IBorderPanelProps } from './interface';++const BORDER_LINE_CHILDREN = [+ {+ label: 'borderLine.borderTop',+ icon: 'UpBorderSingle',+ value: 'top',+ },+ {+ label: 'borderLine.borderBottom',+ icon: 'DownBorderSingle',+ value: 'bottom',+ },+ {+ label: 'borderLine.borderLeft',+ icon: 'LeftBorderSingle',+ value: 'left',+ },+ {+ label: 'borderLine.borderRight',+ icon: 'RightBorderSingle',+ value: 'right',+ },+ {+ label: 'borderLine.borderNone',+ icon: 'NoBorderSingle',+ value: 'none',+ },+ {+ label: 'borderLine.borderAll',+ icon: 'AllBorderSingle',+ value: 'all',+ },+ {+ label: 'borderLine.borderOutside',+ icon: 'OuterBorderSingle',+ value: 'outside',+ },+ {+ label: 'borderLine.borderInside',+ icon: 'InnerBorderSingle',+ value: 'inside',+ },+ {+ label: 'borderLine.borderHorizontal',+ icon: 'InnerBorderSingle',+ value: 'horizontal',+ },+ {+ label: 'borderLine.borderVertical',+ icon: 'InnerBorderSingle',+ value: 'vertical',+ },+];++const BORDER_SIZE_CHILDREN = [+ {+ label: BorderStyleTypes.THIN,+ value: BorderStyleTypes.THIN,+ },+ {+ label: BorderStyleTypes.HAIR,+ value: BorderStyleTypes.HAIR,+ },+ {+ label: BorderStyleTypes.DOTTED,+ value: BorderStyleTypes.DOTTED,+ },+ {+ label: BorderStyleTypes.DASHED,+ value: BorderStyleTypes.DASHED,+ },+ {+ label: BorderStyleTypes.DASH_DOT,+ value: BorderStyleTypes.DASH_DOT,+ },+ {+ label: BorderStyleTypes.DASH_DOT_DOT,+ value: BorderStyleTypes.DASH_DOT_DOT,+ },+ {+ label: BorderStyleTypes.MEDIUM,+ value: BorderStyleTypes.MEDIUM,+ },+ {+ label: BorderStyleTypes.MEDIUM_DASHED,+ value: BorderStyleTypes.MEDIUM_DASHED,+ },+ {+ label: BorderStyleTypes.MEDIUM_DASH_DOT,+ value: BorderStyleTypes.MEDIUM_DASH_DOT,+ },+ {+ label: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,+ value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,+ },+ {+ label: BorderStyleTypes.THICK,+ value: BorderStyleTypes.THICK,+ },+];++export function BorderPanel(props: IBorderPanelProps) {+ const componentManager = useDependency(ComponentManager);+ const { panelType, onChange } = props;++ function handleClick(item: { value: string | number }, type: BorderPanelType) {+ const { id } = panelType.find((item) => item.type === type) ?? {};++ if (id) {+ onChange?.({+ id,+ value: item.value,+ });+ }+ }++ function renderIcon(icon: string) {+ const Icon = componentManager.get(icon);++ return Icon && <Icon extend={{ colorChannel1: 'rgb(var(--primary-color))' }} />;+ }++ function stopPropagation(e: React.MouseEvent) {+ e.stopPropagation();+ }++ return (+ <section className={styles.uiPluginSheetsBorderPanel}>+ <div className={styles.uiPluginSheetsBorderPanelPosition}>+ {BORDER_LINE_CHILDREN.map((item) => (+ <div+ key={item.value}+ className={styles.uiPluginSheetsBorderPanelPositionItem}+ onClick={() => handleClick(item, BorderPanelType.POSITION)}+ >+ {renderIcon(item.icon)}+ </div>+ ))}+ </div>++ <div className={styles.uiPluginSheetsBorderPanelStyles}>+ <div>+ <Dropdown+ align={{+ offset: [0, 18],+ }}+ overlay={+ <section className={styles.uiPluginSheetsBorderPanelBoard} onClick={stopPropagation}>+ <ColorPicker onChange={(value) => handleClick({ value }, BorderPanelType.COLOR)} />+ </section>+ }+ >+ <a className={styles.uiPluginSheetsBorderPanelButton} onClick={stopPropagation}>+ <PaintBucket extend={{ colorChannel1: 'rgb(var(--primary-color))' }} />+ <span className={styles.uiPluginSheetsBorderPanelMoreIcon}>+ <MoreDownSingle />+ </span>+ </a>+ </Dropdown>+ </div>++ <div>+ <Dropdown+ align={{+ offset: [0, 18],+ }}+ overlay={+ <section onClick={stopPropagation}>+ <Menu>+ {BORDER_SIZE_CHILDREN.map((item) => (+ <MenuItem+ key={item.value}+ eventKey={item.value.toString()}+ onClick={() => handleClick({ value: item.value }, BorderPanelType.STYLE)}+ >+ <BorderLine type={item.value} />+ </MenuItem>+ ))}+ </Menu>+ </section>+ }+ >+ <a className={styles.uiPluginSheetsBorderPanelButton} onClick={stopPropagation}>+ <BorderLine type={BorderStyleTypes.THIN} />+ <span className={styles.uiPluginSheetsBorderPanelMoreIcon}>+ <MoreDownSingle />+ </span>+ </a>+ </Dropdown>+ </div>+ </div>+ </section>+ );+}diff --git a/packages/ui-plugin-sheets/src/components/border-line/BorderLine.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/BorderLine.tsxsimilarity index 96%rename from packages/ui-plugin-sheets/src/components/border-line/BorderLine.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/BorderLine.tsxindex facb3ac131..f6ec7115f9 100644--- a/packages/ui-plugin-sheets/src/components/border-line/BorderLine.tsx+++ b/packages/ui-plugin-sheets/src/components/border-panel/border-line/BorderLine.tsx@@ -10,7 +10,10 @@ import { BorderMediumDashDotDot } from './icons/BorderMediumDashDotDot';import { BorderMediumDashed } from './icons/BorderMediumDashed';import { BorderThick } from './icons/BorderThick';import { BorderThin } from './icons/BorderThin';-import { IBorderLineProps } from './interface';++interface IBorderLineProps {+ type: BorderStyleTypes;+}export function BorderLine(props: IBorderLineProps) {const { type = BorderStyleTypes.THIN } = props;diff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDot.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDashDot.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDot.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDashDot.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDotDot.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDashDotDot.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDotDot.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDashDotDot.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashed.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDashed.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashed.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDashed.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDotted.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDotted.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderDotted.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderDotted.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderHair.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderHair.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderHair.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderHair.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMedium.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMedium.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderMedium.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMedium.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDot.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMediumDashDot.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDot.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMediumDashDot.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDotDot.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMediumDashDotDot.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDotDot.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMediumDashDotDot.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashed.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMediumDashed.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashed.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderMediumDashed.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderThick.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderThick.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderThick.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderThick.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-line/icons/BorderThin.tsx b/packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderThin.tsxsimilarity index 100%rename from packages/ui-plugin-sheets/src/components/border-line/icons/BorderThin.tsxrename to packages/ui-plugin-sheets/src/components/border-panel/border-line/icons/BorderThin.tsxdiff --git a/packages/ui-plugin-sheets/src/components/border-panel/index.module.less b/packages/ui-plugin-sheets/src/components/border-panel/index.module.lessnew file mode 100644index 0000000000..f05372af49--- /dev/null+++ b/packages/ui-plugin-sheets/src/components/border-panel/index.module.less@@ -0,0 +1,77 @@+.ui-plugin-sheets-border-panel {+ display: grid;+ gap: var(--margin-sm);++ &-position {+ display: grid;+ grid-template-columns: repeat(5, 1fr);+ gap: var(--margin-xxs);++ box-sizing: border-box;+ padding-bottom: var(--padding-base);++ border-bottom: 1px solid rgb(var(--border-color));++ &-item {+ display: flex;+ align-items: center;+ justify-content: center;++ width: 24px;+ height: 24px;++ font-size: var(--font-size-lg);++ border-radius: var(--border-radius-base);++ &:hover {+ background-color: rgb(var(--bg-color-hover));+ }+ }+ }++ &-styles {+ display: flex;+ gap: var(--margin-xs);+ align-items: center;+ justify-content: space-around;+ }++ &-board {+ box-sizing: border-box;+ padding: var(--padding-base);++ background-color: rgb(var(--bg-color-secondary));+ border: 1px solid rgb(var(--border-color));+ border-radius: var(--border-radius-lg);+ box-shadow: var(--box-shadow-base);+ }++ &-button {+ cursor: pointer;++ position: relative;++ display: flex;+ gap: var(--margin-xs);+ align-items: center;++ height: 24px;+ padding: 0 var(--padding-xs);++ font-size: var(--font-size-lg);++ border-radius: var(--border-radius-base);++ transition: all 0.15s;++ &:hover {+ background-color: rgb(var(--bg-color-hover));+ }+ }++ &-more-icon {+ font-size: 10px;+ color: rgb(var(--grey-400));+ }+}diff --git a/packages/ui-plugin-sheets/src/components/border-panel/index.ts b/packages/ui-plugin-sheets/src/components/border-panel/index.tsnew file mode 100644index 0000000000..e69de29bb2diff --git a/packages/ui-plugin-sheets/src/components/border-panel/interface.ts b/packages/ui-plugin-sheets/src/components/border-panel/interface.tsnew file mode 100644index 0000000000..9838e8cc1f--- /dev/null+++ b/packages/ui-plugin-sheets/src/components/border-panel/interface.ts@@ -0,0 +1,18 @@+import { ICustomComponentProps } from '@univerjs/base-ui';++import { COMPONENT_PREFIX } from '../const';++export const BORDER_PANEL_COMPONENT = `${COMPONENT_PREFIX}_BORDER_PANEL_COMPONENT`;++export interface IBorderPanelProps extends ICustomComponentProps<{ id: string; value: string | number }> {+ panelType: Array<{+ type: BorderPanelType;+ id: string;+ }>;+}++export enum BorderPanelType {+ POSITION = 'position',+ STYLE = 'style',+ COLOR = 'color',+}diff --git a/packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsx b/packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsxindex 51b81a81d6..5ba12285e1 100644--- a/packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsx+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsx@@ -7,7 +7,7 @@ import styles from './index.module.less';import { IMenuItemInputProps } from './interface';export const MenuItemInput = (props: IMenuItemInputProps) => {- const { prefix, suffix, value, onChange, onValueChange } = props;+ const { prefix, suffix, value, onChange } = props;const localeService = useDependency(LocaleService);@@ -31,8 +31,13 @@ export const MenuItemInput = (props: IMenuItemInputProps) => {return (<div className={styles.uiPluginSheetsContextMenuInput}>{localeService.t(prefix)}- <span onClick={(e) => e.stopPropagation()}>- <InputNumber value={Number(inputValue)} onKeyDown={handleKeyDown} onChange={handleChange} />+ <span className={styles.uiPluginSheetsContextMenuInputContainer} onClick={(e) => e.stopPropagation()}>+ <InputNumber+ value={Number(inputValue)}+ precision={0}+ onKeyDown={handleKeyDown}+ onChange={handleChange}+ /></span>{localeService.t(suffix)}</div>diff --git a/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.less b/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.lessindex 1579bfabd6..f542f223e7 100644--- a/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.less+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.less@@ -2,4 +2,8 @@display: flex;gap: var(--margin-sm);align-items: center;++ &-container {+ width: 72px;+ }}diff --git a/packages/ui-plugin-sheets/src/components/menu-item-input/interface.ts b/packages/ui-plugin-sheets/src/components/menu-item-input/interface.tsindex d9886b8322..7021a4d247 100644--- a/packages/ui-plugin-sheets/src/components/menu-item-input/interface.ts+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/interface.ts@@ -7,9 +7,4 @@ export const MENU_ITEM_INPUT_COMPONENT = `${COMPONENT_PREFIX}_MENU_ITEM_INPUT_COexport interface IMenuItemInputProps extends ICustomComponentProps<string> {prefix: string;suffix: string;-- /**- * After ENTER, execute Command, close the right-click menu- */- onValueChange?: (value: string) => void;}diff --git a/packages/ui-plugin-sheets/src/controllers/menu/border.menu.ts b/packages/ui-plugin-sheets/src/controllers/menu/border.menu.tsindex cb2f9c44d3..fa1c6e032f 100644--- a/packages/ui-plugin-sheets/src/controllers/menu/border.menu.ts+++ b/packages/ui-plugin-sheets/src/controllers/menu/border.menu.ts@@ -1,173 +1,15 @@import {BorderStyleManagerService,+ SetBorderBasicCommand,SetBorderColorCommand,SetBorderPositionCommand,SetBorderStyleCommand,} from '@univerjs/base-sheets';import { IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/base-ui';-import { BorderStyleTypes, ICommandService } from '@univerjs/core';+import { ICommandService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { map } from 'rxjs/operators';-import { BORDER_LINE_COMPONENT } from '../../components/border-line';-import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';--export const LINE_BOLD_LABEL = 'CONTEXT_MENU_INPUT';--export const BORDER_LINE_CHILDREN = [- {- label: 'borderLine.borderTop',- icon: 'UpBorderSingle',- value: 'top',- },- {- label: 'borderLine.borderBottom',- icon: 'DownBorderSingle',- value: 'bottom',- },- {- label: 'borderLine.borderLeft',- icon: 'LeftBorderSingle',- value: 'left',- },- {- label: 'borderLine.borderRight',- icon: 'RightBorderSingle',- value: 'right',- },- {- label: 'borderLine.borderNone',- icon: 'NoBorderSingle',- value: 'none',- },- {- label: 'borderLine.borderAll',- icon: 'AllBorderSingle',- value: 'all',- },- {- label: 'borderLine.borderOutside',- icon: 'OuterBorderSingle',- value: 'outside',- },- {- label: 'borderLine.borderInside',- icon: 'InnerBorderSingle',- value: 'inside',- },- {- label: 'borderLine.borderHorizontal',- icon: 'InnerBorderSingle',- value: 'horizontal',- },- {- label: 'borderLine.borderVertical',- icon: 'InnerBorderSingle',- value: 'vertical',- },-];--export const BORDER_SIZE_CHILDREN = [- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.THIN,- },- },- value: BorderStyleTypes.THIN,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.HAIR,- },- },- value: BorderStyleTypes.HAIR,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.DOTTED,- },- },- value: BorderStyleTypes.DOTTED,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.DASHED,- },- },- value: BorderStyleTypes.DASHED,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.DOTTED,- },- },- value: BorderStyleTypes.DOTTED,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.DASH_DOT_DOT,- },- },- value: BorderStyleTypes.DASH_DOT_DOT,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.MEDIUM,- },- },- value: BorderStyleTypes.MEDIUM,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.MEDIUM_DASHED,- },- },- value: BorderStyleTypes.MEDIUM_DASHED,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.MEDIUM_DASH_DOT,- },- },- value: BorderStyleTypes.MEDIUM_DASH_DOT,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,- },- },- value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,- },- {- label: {- name: BORDER_LINE_COMPONENT,- props: {- type: BorderStyleTypes.THICK,- },- },- value: BorderStyleTypes.THICK,- },-];+import { BORDER_PANEL_COMPONENT, BorderPanelType } from '../../components/border-panel/interface';export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {// const permissionService = accessor.get(IPermissionService);@@ -175,40 +17,63 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSelconst borderStyleManagerService = accessor.get(BorderStyleManagerService);return {- id: SetBorderPositionCommand.id,+ id: SetBorderBasicCommand.id,icon: 'AllBorderSingle',group: MenuGroup.TOOLBAR_FORMAT,tooltip: 'toolbar.border.main',positions: [MenuPosition.TOOLBAR_START],type: MenuItemType.SUBITEMS,- selections: [...BORDER_LINE_CHILDREN],- };-}--export function SetBorderColorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {- const borderStyleManagerService = accessor.get(BorderStyleManagerService);- return {- id: SetBorderColorCommand.id,- title: 'borderLine.borderColor',- positions: SetBorderPositionCommand.id,- type: MenuItemType.SELECTOR,selections: [{- id: COLOR_PICKER_COMPONENT,+ label: {+ name: BORDER_PANEL_COMPONENT,+ hoverable: false,+ props: {+ panelType: [+ {+ type: BorderPanelType.POSITION,+ id: SetBorderPositionCommand.id,+ },+ {+ type: BorderPanelType.STYLE,+ id: SetBorderStyleCommand.id,+ },+ {+ type: BorderPanelType.COLOR,+ id: SetBorderColorCommand.id,+ },+ ],+ },+ },},],- value$: borderStyleManagerService.borderInfo$.pipe(map((info) => info.color)),};}-export function SetBorderStyleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<BorderStyleTypes> {- const borderStyleManagerService = accessor.get(BorderStyleManagerService);- return {- id: SetBorderStyleCommand.id,- title: 'borderLine.borderType',- positions: SetBorderPositionCommand.id,- type: MenuItemType.SELECTOR,- selections: [...BORDER_SIZE_CHILDREN],- value$: borderStyleManagerService.borderInfo$.pipe(map((info) => info.style)),- };-}+// export function SetBorderColorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {+// const borderStyleManagerService = accessor.get(BorderStyleManagerService);+// return {+// id: SetBorderColorCommand.id,+// title: 'borderLine.borderColor',+// positions: SetBorderPositionCommand.id,+// type: MenuItemType.SELECTOR,+// selections: [+// {+// label: COLOR_PICKER_COMPONENT,+// },+// ],+// value$: borderStyleManagerService.borderInfo$.pipe(map((info) => info.color)),+// };+// }++// export function SetBorderStyleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<BorderStyleTypes> {+// const borderStyleManagerService = accessor.get(BorderStyleManagerService);+// return {+// id: SetBorderStyleCommand.id,+// title: 'borderLine.borderType',+// positions: SetBorderPositionCommand.id,+// type: MenuItemType.SELECTOR,+// selections: [...BORDER_SIZE_CHILDREN],+// value$: borderStyleManagerService.borderInfo$.pipe(map((info) => info.style)),+// };+// }diff --git a/packages/ui-plugin-sheets/src/controllers/menu/clear.menu.ts b/packages/ui-plugin-sheets/src/controllers/menu/clear.menu.tsnew file mode 100644index 0000000000..ae7cc8acc6--- /dev/null+++ b/packages/ui-plugin-sheets/src/controllers/menu/clear.menu.ts@@ -0,0 +1,49 @@+import {+ ClearSelectionAllCommand,+ ClearSelectionContentCommand,+ ClearSelectionFormatCommand,+} from '@univerjs/base-sheets';+import { IMenuButtonItem, IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/base-ui';++import { SheetMenuPosition } from './menu';++const CLEAR_SELECTION_MENU_ID = 'sheet.menu.clear-selection';+export function ClearSelectionMenuItemFactory(): IMenuSelectorItem<string> {+ return {+ id: CLEAR_SELECTION_MENU_ID,+ group: MenuGroup.CONTEXT_MENU_FORMAT,+ type: MenuItemType.SUBITEMS,+ icon: 'ClearFormat',+ title: 'rightClick.clearSelection',+ positions: [+ MenuPosition.CONTEXT_MENU,+ SheetMenuPosition.COL_HEADER_CONTEXT_MENU,+ SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,+ ],+ };+}++export function ClearSelectionContentMenuItemFactory(): IMenuButtonItem {+ return {+ id: ClearSelectionContentCommand.id,+ type: MenuItemType.BUTTON,+ title: 'rightClick.clearContent',+ positions: [CLEAR_SELECTION_MENU_ID],+ };+}+export function ClearSelectionFormatMenuItemFactory(): IMenuButtonItem {+ return {+ id: ClearSelectionFormatCommand.id,+ type: MenuItemType.BUTTON,+ title: 'rightClick.clearFormat',+ positions: [CLEAR_SELECTION_MENU_ID],+ };+}+export function ClearSelectionAllMenuItemFactory(): IMenuButtonItem {+ return {+ id: ClearSelectionAllCommand.id,+ type: MenuItemType.BUTTON,+ title: 'rightClick.clearAll',+ positions: [CLEAR_SELECTION_MENU_ID],+ };+}diff --git a/packages/ui-plugin-sheets/src/controllers/menu/delete.menu.ts b/packages/ui-plugin-sheets/src/controllers/menu/delete.menu.tsnew file mode 100644index 0000000000..4cafa3c6fa--- /dev/null+++ b/packages/ui-plugin-sheets/src/controllers/menu/delete.menu.ts@@ -0,0 +1,61 @@+import {+ DeleteRangeMoveLeftCommand,+ DeleteRangeMoveUpCommand,+ RemoveColCommand,+ RemoveRowCommand,+} from '@univerjs/base-sheets';+import { IMenuButtonItem, IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/base-ui';++import { SheetMenuPosition } from './menu';++const DELETE_RANGE_MENU_ID = 'sheet.menu.delete';+export function DeleteRangeMenuItemFactory(): IMenuSelectorItem<string> {+ return {+ id: DELETE_RANGE_MENU_ID,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.SUBITEMS,+ title: 'rightClick.delete',+ icon: 'ClearFormat',+ positions: [MenuPosition.CONTEXT_MENU],+ };+}++export function RemoveColMenuItemFactory(): IMenuButtonItem {+ return {+ id: RemoveColCommand.id,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.BUTTON,+ positions: [DELETE_RANGE_MENU_ID, SheetMenuPosition.COL_HEADER_CONTEXT_MENU],+ title: 'rightClick.deleteSelectedColumn',+ };+}++export function RemoveRowMenuItemFactory(): IMenuButtonItem {+ return {+ id: RemoveRowCommand.id,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.BUTTON,+ positions: [DELETE_RANGE_MENU_ID, SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],+ title: 'rightClick.deleteSelectedRow',+ };+}++export function DeleteRangeMoveLeftMenuItemFactory(): IMenuButtonItem {+ return {+ id: DeleteRangeMoveLeftCommand.id,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.BUTTON,+ title: 'rightClick.moveLeft',+ positions: [DELETE_RANGE_MENU_ID],+ };+}++export function DeleteRangeMoveUpMenuItemFactory(): IMenuButtonItem {+ return {+ id: DeleteRangeMoveUpCommand.id,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.BUTTON,+ title: 'rightClick.moveUp',+ positions: [DELETE_RANGE_MENU_ID],+ };+}diff --git a/packages/ui-plugin-sheets/src/controllers/menu/insert.menu.ts b/packages/ui-plugin-sheets/src/controllers/menu/insert.menu.tsnew file mode 100644index 0000000000..69883252e7--- /dev/null+++ b/packages/ui-plugin-sheets/src/controllers/menu/insert.menu.ts@@ -0,0 +1,127 @@+import {+ InsertColAfterCommand,+ InsertColBeforeCommand,+ InsertRangeMoveDownCommand,+ InsertRangeMoveRightCommand,+ InsertRowAfterCommand,+ InsertRowBeforeCommand,+ SelectionManagerService,+} from '@univerjs/base-sheets';+import { IMenuButtonItem, IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/base-ui';+import { IAccessor } from '@wendellhu/redi';+import { Observable } from 'rxjs';++import { SheetMenuPosition } from './menu';++const COL_INSERT_MENU_ID = 'sheet.menu.col-insert';+export function ColInsertMenuItemFactory(): IMenuSelectorItem<string> {+ return {+ id: COL_INSERT_MENU_ID,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.SUBITEMS,+ title: 'rightClick.insert',+ icon: 'ClearFormat',+ positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],+ };+}+const ROW_INSERT_MENU_ID = 'sheet.menu.row-insert';+export function RowInsertMenuItemFactory(): IMenuSelectorItem<string> {+ return {+ id: ROW_INSERT_MENU_ID,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.SUBITEMS,+ title: 'rightClick.insert',+ icon: 'ClearFormat',+ positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],+ };+}+const CELL_INSERT_MENU_ID = 'sheet.menu.cell-insert';+export function CellInsertMenuItemFactory(): IMenuSelectorItem<string> {+ return {+ id: CELL_INSERT_MENU_ID,+ group: MenuGroup.CONTEXT_MENU_LAYOUT,+ type: MenuItemType.SUBITEMS,+ title: 'rightClick.insert',+ icon: 'ClearFormat',+ positions: [MenuPosition.CONTEXT_MENU],+ };+}++export function InsertRowBeforeMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ const selectionManager = accessor.get(SelectionManagerService);++ return {+ id: InsertRowBeforeCommand.id,+ type: MenuItemType.BUTTON,+ title: 'rightClick.insertRowBefore',+ positions: [ROW_INSERT_MENU_ID, CELL_INSERT_MENU_ID],+ hidden$: new Observable((observer) => {+ // if there are multi selections this item should be hidden+ const selections = selectionManager.getSelections();+ observer.next(selections?.length !== 1);+ }),+ };+}++export function InsertRowAfterMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ const selectionManager = accessor.get(SelectionManagerService);+ return {+ id: InsertRowAfterCommand.id,+ type: MenuItemType.BUTTON,+ positions: [ROW_INSERT_MENU_ID],+ title: 'rightClick.insertRow',+ hidden$: new Observable((observer) => {+ // if there are multi selections this item should be hidden+ const selections = selectionManager.getSelections();+ observer.next(selections?.length !== 1);+ }),+ };+}++export function InsertColBeforeMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ const selectionManager = accessor.get(SelectionManagerService);+ return {+ id: InsertColBeforeCommand.id,+ type: MenuItemType.BUTTON,+ positions: [COL_INSERT_MENU_ID, CELL_INSERT_MENU_ID],+ title: 'rightClick.insertColumnBefore',+ hidden$: new Observable((observer) => {+ // if there are multi selections this item should be hidden+ const selections = selectionManager.getSelections();+ observer.next(selections?.length !== 1);+ }),+ };+}++export function InsertColAfterMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ const selectionManager = accessor.get(SelectionManagerService);+ return {+ id: InsertColAfterCommand.id,+ type: MenuItemType.BUTTON,+ positions: [COL_INSERT_MENU_ID],+ title: 'rightClick.insertColumn',+ hidden$: new Observable((observer) => {+ // if there are multi selections this item should be hidden+ const selections = selectionManager.getSelections();+ observer.next(selections?.length !== 1);+ }),+ };+}++export function InsertRangeMoveRightMenuItemFactory(): IMenuButtonItem {+ return {+ id: InsertRangeMoveRightCommand.id,+ type: MenuItemType.BUTTON,+ title: 'rightClick.moveRight',+ positions: [CELL_INSERT_MENU_ID],+ };+}++export function InsertRangeMoveDownMenuItemFactory(): IMenuButtonItem {+ return {+ id: InsertRangeMoveDownCommand.id,+ type: MenuItemType.BUTTON,+ title: 'rightClick.moveDown',+ positions: [CELL_INSERT_MENU_ID],+ };+}diff --git a/packages/ui-plugin-sheets/src/controllers/menu/menu.ts b/packages/ui-plugin-sheets/src/controllers/menu/menu.tsindex e42c447dfb..8e99fdb40a 100644--- a/packages/ui-plugin-sheets/src/controllers/menu/menu.ts+++ b/packages/ui-plugin-sheets/src/controllers/menu/menu.ts@@ -1,19 +1,4 @@import {- ClearSelectionAllCommand,- ClearSelectionContentCommand,- ClearSelectionFormatCommand,- CopySheetCommand,- DeleteRangeMoveLeftCommand,- DeleteRangeMoveUpCommand,- InsertColAfterCommand,- InsertColBeforeCommand,- InsertRangeMoveDownCommand,- InsertRangeMoveRightCommand,- InsertRowAfterCommand,- InsertRowBeforeCommand,- RemoveColCommand,- RemoveRowCommand,- RemoveSheetCommand,ResetBackgroundColorCommand,ResetTextColorCommand,SelectionManagerService,@@ -31,13 +16,10 @@ import {SetSelectedColsVisibleCommand,SetSelectedRowsVisibleCommand,SetSelectionsOperation,- SetTabColorCommand,SetTextRotationCommand,SetTextWrapCommand,SetVerticalTextAlignCommand,- SetWorksheetHideCommand,SetWorksheetRowIsAutoHeightCommand,- SetWorksheetShowCommand,SheetPermissionService,} from '@univerjs/base-sheets';import {@@ -72,21 +54,17 @@ import {SetRangeTextColorCommand,SetRangeUnderlineCommand,} from '../../commands/commands/inline-format.command';-import { RenameSheetOperation } from '../../commands/commands/rename.command';import {SetInfiniteFormatPainterCommand,SetOnceFormatPainterCommand,} from '../../commands/commands/set-format-painter.command';import { SetSelectionFrozenCommand } from '../../commands/commands/set-frozen.command';-import { ShowMenuListCommand } from '../../commands/commands/unhide.command';import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';import { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from '../../components/font-family';import { FONT_SIZE_COMPONENT } from '../../components/font-size';import { MENU_ITEM_INPUT_COMPONENT } from '../../components/menu-item-input';import { FormatPainterStatus, IFormatPainterService } from '../../services/format-painter/format-painter.service';-export { SetBorderColorMenuItemFactory, SetBorderStyleMenuItemFactory } from './border.menu';-export enum SheetMenuPosition {ROW_HEADER_CONTEXT_MENU = 'rowHeaderContextMenu',COL_HEADER_CONTEXT_MENU = 'colHeaderContextMenu',@@ -377,55 +355,55 @@ export const FONT_SIZE_CHILDREN = [export const FONT_FAMILY_CHILDREN = [{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'Times New Roman',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'Arial',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'Tahoma',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'Verdana',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'Microsoft YaHei',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'SimSun',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'SimHei',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'Kaiti',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'FangSong',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'NSimSun',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'STXinwei',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'STXingkai',},{- label: { name: FONT_FAMILY_ITEM_COMPONENT },+ label: FONT_FAMILY_ITEM_COMPONENT,value: 'STLiti',},// The following 3 fonts do not work, temporarily delete@@ -555,6 +533,7 @@ export function ResetTextColorMenuItemFactory(): IMenuButtonItem {id: ResetTextColorCommand.id,type: MenuItemType.BUTTON,title: 'toolbar.resetColor',+ icon: 'NoColor',positions: SetRangeTextColorCommand.id,};}@@ -571,7 +550,10 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelepositions: [MenuPosition.TOOLBAR_START],selections: [{- id: COLOR_PICKER_COMPONENT,+ label: {+ name: COLOR_PICKER_COMPONENT,+ hoverable: false,+ },},],value$: new Observable<string>((subscriber) => {@@ -610,7 +592,10 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMeicon: 'PaintBucket',selections: [{- id: COLOR_PICKER_COMPONENT,+ label: {+ name: COLOR_PICKER_COMPONENT,+ hoverable: false,+ },},],value$: new Observable<string>((subscriber) => {@@ -906,213 +891,6 @@ export function PasteMenuItemFactory(): IMenuButtonItem {};}-// #endregion-const CLEAR_SELECTION_MENU_ID = 'sheet.menu.clear-selection';-export function ClearSelectionMenuItemFactory(): IMenuSelectorItem<string> {- return {- id: CLEAR_SELECTION_MENU_ID,- group: MenuGroup.CONTEXT_MENU_FORMAT,- type: MenuItemType.SUBITEMS,- icon: 'ClearFormat',- title: 'rightClick.clearSelection',- positions: [- MenuPosition.CONTEXT_MENU,- SheetMenuPosition.COL_HEADER_CONTEXT_MENU,- SheetMenuPosition.ROW_HEADER_CONTEXT_MENU,- ],- };-}--export function ClearSelectionContentMenuItemFactory(): IMenuButtonItem {- return {- id: ClearSelectionContentCommand.id,- type: MenuItemType.BUTTON,- title: 'rightClick.clearContent',- positions: [CLEAR_SELECTION_MENU_ID],- };-}-export function ClearSelectionFormatMenuItemFactory(): IMenuButtonItem {- return {- id: ClearSelectionFormatCommand.id,- type: MenuItemType.BUTTON,- title: 'rightClick.clearFormat',- positions: [CLEAR_SELECTION_MENU_ID],- };-}-export function ClearSelectionAllMenuItemFactory(): IMenuButtonItem {- return {- id: ClearSelectionAllCommand.id,- type: MenuItemType.BUTTON,- title: 'rightClick.clearAll',- positions: [CLEAR_SELECTION_MENU_ID],- };-}--const COL_INSERT_MENU_ID = 'sheet.menu.col-insert';-export function ColInsertMenuItemFactory(): IMenuSelectorItem<string> {- return {- id: COL_INSERT_MENU_ID,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.SUBITEMS,- title: 'rightClick.insert',- icon: 'ClearFormat',- positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],- };-}-const ROW_INSERT_MENU_ID = 'sheet.menu.row-insert';-export function RowInsertMenuItemFactory(): IMenuSelectorItem<string> {- return {- id: ROW_INSERT_MENU_ID,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.SUBITEMS,- title: 'rightClick.insert',- icon: 'ClearFormat',- positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],- };-}-const CELL_INSERT_MENU_ID = 'sheet.menu.cell-insert';-export function CellInsertMenuItemFactory(): IMenuSelectorItem<string> {- return {- id: CELL_INSERT_MENU_ID,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.SUBITEMS,- title: 'rightClick.insert',- icon: 'ClearFormat',- positions: [MenuPosition.CONTEXT_MENU],- };-}--export function InsertRowBeforeMenuItemFactory(accessor: IAccessor): IMenuButtonItem {- const selectionManager = accessor.get(SelectionManagerService);-- return {- id: InsertRowBeforeCommand.id,- type: MenuItemType.BUTTON,- title: 'rightClick.insertRowBefore',- positions: [ROW_INSERT_MENU_ID, CELL_INSERT_MENU_ID],- hidden$: new Observable((observer) => {- // if there are multi selections this item should be hidden- const selections = selectionManager.getSelections();- observer.next(selections?.length !== 1);- }),- };-}--export function InsertRowAfterMenuItemFactory(accessor: IAccessor): IMenuButtonItem {- const selectionManager = accessor.get(SelectionManagerService);- return {- id: InsertRowAfterCommand.id,- type: MenuItemType.BUTTON,- positions: [ROW_INSERT_MENU_ID],- title: 'rightClick.insertRow',- hidden$: new Observable((observer) => {- // if there are multi selections this item should be hidden- const selections = selectionManager.getSelections();- observer.next(selections?.length !== 1);- }),- };-}--export function InsertColBeforeMenuItemFactory(accessor: IAccessor): IMenuButtonItem {- const selectionManager = accessor.get(SelectionManagerService);- return {- id: InsertColBeforeCommand.id,- type: MenuItemType.BUTTON,- positions: [COL_INSERT_MENU_ID, CELL_INSERT_MENU_ID],- title: 'rightClick.insertColumnBefore',- hidden$: new Observable((observer) => {- // if there are multi selections this item should be hidden- const selections = selectionManager.getSelections();- observer.next(selections?.length !== 1);- }),- };-}--export function InsertColAfterMenuItemFactory(accessor: IAccessor): IMenuButtonItem {- const selectionManager = accessor.get(SelectionManagerService);- return {- id: InsertColAfterCommand.id,- type: MenuItemType.BUTTON,- positions: [COL_INSERT_MENU_ID],- title: 'rightClick.insertColumn',- hidden$: new Observable((observer) => {- // if there are multi selections this item should be hidden- const selections = selectionManager.getSelections();- observer.next(selections?.length !== 1);- }),- };-}--export function InsertRangeMoveRightMenuItemFactory(): IMenuButtonItem {- return {- id: InsertRangeMoveRightCommand.id,- type: MenuItemType.BUTTON,- title: 'rightClick.moveRight',- positions: [CELL_INSERT_MENU_ID],- };-}--export function InsertRangeMoveDownMenuItemFactory(): IMenuButtonItem {- return {- id: InsertRangeMoveDownCommand.id,- type: MenuItemType.BUTTON,- title: 'rightClick.moveDown',- positions: [CELL_INSERT_MENU_ID],- };-}--const DELETE_RANGE_MENU_ID = 'sheet.menu.delete';-export function DeleteRangeMenuItemFactory(): IMenuSelectorItem<string> {- return {- id: DELETE_RANGE_MENU_ID,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.SUBITEMS,- title: 'rightClick.delete',- icon: 'ClearFormat',- positions: [MenuPosition.CONTEXT_MENU],- };-}--export function RemoveColMenuItemFactory(): IMenuButtonItem {- return {- id: RemoveColCommand.id,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.BUTTON,- positions: [DELETE_RANGE_MENU_ID, SheetMenuPosition.COL_HEADER_CONTEXT_MENU],- title: 'rightClick.deleteSelectedColumn',- };-}--export function RemoveRowMenuItemFactory(): IMenuButtonItem {- return {- id: RemoveRowCommand.id,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.BUTTON,- positions: [DELETE_RANGE_MENU_ID, SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],- title: 'rightClick.deleteSelectedRow',- };-}--export function DeleteRangeMoveLeftMenuItemFactory(): IMenuButtonItem {- return {- id: DeleteRangeMoveLeftCommand.id,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.BUTTON,- title: 'rightClick.moveLeft',- positions: [DELETE_RANGE_MENU_ID],- };-}--export function DeleteRangeMoveUpMenuItemFactory(): IMenuButtonItem {- return {- id: DeleteRangeMoveUpCommand.id,- group: MenuGroup.CONTEXT_MENU_LAYOUT,- type: MenuItemType.BUTTON,- title: 'rightClick.moveUp',- positions: [DELETE_RANGE_MENU_ID],- };-}-export function FitContentMenuItemFactory(): IMenuButtonItem {return {id: SetWorksheetRowIsAutoHeightCommand.id,@@ -1335,105 +1113,3 @@ export function SetColWidthMenuItemFactory(accessor: IAccessor): IMenuButtonItem}),};}--// right menu in main sheet bar-export function DeleteSheetMenuItemFactory(): IMenuButtonItem {- return {- id: RemoveSheetCommand.id,- type: MenuItemType.BUTTON,- positions: [SheetMenuPosition.SHEET_BAR],- title: 'sheetConfig.delete',- };-}--export function CopySheetMenuItemFactory(): IMenuButtonItem {- return {- id: CopySheetCommand.id,- type: MenuItemType.BUTTON,- positions: [SheetMenuPosition.SHEET_BAR],- title: 'sheetConfig.copy',- };-}--export function RenameSheetMenuItemFactory(): IMenuButtonItem {- return {- id: RenameSheetOperation.id,- type: MenuItemType.BUTTON,- positions: [SheetMenuPosition.SHEET_BAR],- title: 'sheetConfig.rename',- };-}--export function ChangeColorSheetMenuItemFactory(): IMenuSelectorItem<string> {- return {- id: SetTabColorCommand.id,- title: 'sheetConfig.changeColor',- positions: [SheetMenuPosition.SHEET_BAR],- type: MenuItemType.SELECTOR,- selections: [- {- id: COLOR_PICKER_COMPONENT,- },- ],- };-}--export function HideSheetMenuItemFactory(): IMenuButtonItem {- return {- id: SetWorksheetHideCommand.id,- type: MenuItemType.BUTTON,- positions: [SheetMenuPosition.SHEET_BAR],- title: 'sheetConfig.hide',- };-}--export function UnHideSheetMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<any> {- const univerInstanceService = accessor.get(IUniverInstanceService);- const commandService = accessor.get(ICommandService);- const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const hiddenList = workbook.getHiddenWorksheets().map((s) => ({- label: workbook.getSheetBySheetId(s)?.getName() || '',- value: s,- }));-- return {- id: SetWorksheetShowCommand.id,- type: MenuItemType.SELECTOR,- positions: [SheetMenuPosition.SHEET_BAR],- title: 'sheetConfig.unhide',- disabled$: new Observable((subscriber) => {- const disposable = commandService.onCommandExecuted((c) => {- if (c.id !== SetWorksheetHideCommand.id && c.id !== SetWorksheetShowCommand.id) {- return;- }- const newList = workbook.getHiddenWorksheets();- subscriber.next(newList.length === 0);- });- subscriber.next(hiddenList.length === 0);- return disposable.dispose;- }),- selections: new Observable((subscriber) => {- const disposable = commandService.onCommandExecuted((c) => {- if (c.id !== SetWorksheetHideCommand.id && c.id !== SetWorksheetShowCommand.id) {- return;- }- const newList = workbook.getHiddenWorksheets().map((s) => ({- label: workbook.getSheetBySheetId(s)?.getName() || '',- value: s,- }));- subscriber.next(newList);- });- subscriber.next(hiddenList);- return disposable.dispose;- }),- };-}--export function ShowMenuItemFactory(): IMenuButtonItem {- return {- id: ShowMenuListCommand.id,- type: MenuItemType.BUTTON,- positions: [SheetMenuPosition.SHEET_BAR],- title: 'sheetConfig.unhide',- };-}diff --git a/packages/ui-plugin-sheets/src/controllers/menu/sheet.menu.ts b/packages/ui-plugin-sheets/src/controllers/menu/sheet.menu.tsnew file mode 100644index 0000000000..1e846efb19--- /dev/null+++ b/packages/ui-plugin-sheets/src/controllers/menu/sheet.menu.ts@@ -0,0 +1,120 @@+import {+ CopySheetCommand,+ RemoveSheetCommand,+ SetTabColorCommand,+ SetWorksheetHideCommand,+ SetWorksheetShowCommand,+} from '@univerjs/base-sheets';+import { IMenuButtonItem, IMenuSelectorItem, MenuItemType } from '@univerjs/base-ui';+import { ICommandService, IUniverInstanceService } from '@univerjs/core';+import { IAccessor } from '@wendellhu/redi';+import { Observable } from 'rxjs';++import { RenameSheetOperation } from '../../commands/commands/rename.command';+import { ShowMenuListCommand } from '../../commands/commands/unhide.command';+import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';+import { SheetMenuPosition } from './menu';++export function DeleteSheetMenuItemFactory(): IMenuButtonItem {+ return {+ id: RemoveSheetCommand.id,+ type: MenuItemType.BUTTON,+ positions: [SheetMenuPosition.SHEET_BAR],+ title: 'sheetConfig.delete',+ };+}++export function CopySheetMenuItemFactory(): IMenuButtonItem {+ return {+ id: CopySheetCommand.id,+ type: MenuItemType.BUTTON,+ positions: [SheetMenuPosition.SHEET_BAR],+ title: 'sheetConfig.copy',+ };+}++export function RenameSheetMenuItemFactory(): IMenuButtonItem {+ return {+ id: RenameSheetOperation.id,+ type: MenuItemType.BUTTON,+ positions: [SheetMenuPosition.SHEET_BAR],+ title: 'sheetConfig.rename',+ };+}++export function ChangeColorSheetMenuItemFactory(): IMenuSelectorItem<string> {+ return {+ id: SetTabColorCommand.id,+ title: 'sheetConfig.changeColor',+ positions: [SheetMenuPosition.SHEET_BAR],+ type: MenuItemType.SELECTOR,+ selections: [+ {+ label: {+ name: COLOR_PICKER_COMPONENT,+ hoverable: false,+ },+ },+ ],+ };+}++export function HideSheetMenuItemFactory(): IMenuButtonItem {+ return {+ id: SetWorksheetHideCommand.id,+ type: MenuItemType.BUTTON,+ positions: [SheetMenuPosition.SHEET_BAR],+ title: 'sheetConfig.hide',+ };+}++export function UnHideSheetMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<any> {+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const commandService = accessor.get(ICommandService);+ const workbook = univerInstanceService.getCurrentUniverSheetInstance();+ const hiddenList = workbook.getHiddenWorksheets().map((s) => ({+ label: workbook.getSheetBySheetId(s)?.getName() || '',+ value: s,+ }));++ return {+ id: SetWorksheetShowCommand.id,+ type: MenuItemType.SELECTOR,+ positions: [SheetMenuPosition.SHEET_BAR],+ title: 'sheetConfig.unhide',+ disabled$: new Observable((subscriber) => {+ const disposable = commandService.onCommandExecuted((c) => {+ if (c.id !== SetWorksheetHideCommand.id && c.id !== SetWorksheetShowCommand.id) {+ return;+ }+ const newList = workbook.getHiddenWorksheets();+ subscriber.next(newList.length === 0);+ });+ subscriber.next(hiddenList.length === 0);+ return disposable.dispose;+ }),+ selections: new Observable((subscriber) => {+ const disposable = commandService.onCommandExecuted((c) => {+ if (c.id !== SetWorksheetHideCommand.id && c.id !== SetWorksheetShowCommand.id) {+ return;+ }+ const newList = workbook.getHiddenWorksheets().map((s) => ({+ label: workbook.getSheetBySheetId(s)?.getName() || '',+ value: s,+ }));+ subscriber.next(newList);+ });+ subscriber.next(hiddenList);+ return disposable.dispose;+ }),+ };+}++export function ShowMenuItemFactory(): IMenuButtonItem {+ return {+ id: ShowMenuListCommand.id,+ type: MenuItemType.BUTTON,+ positions: [SheetMenuPosition.SHEET_BAR],+ title: 'sheetConfig.unhide',+ };+}diff --git a/packages/ui-plugin-sheets/src/controllers/sheet-ui.controller.ts b/packages/ui-plugin-sheets/src/controllers/sheet-ui.controller.tsindex 95ed8b4510..568b0e5a39 100644--- a/packages/ui-plugin-sheets/src/controllers/sheet-ui.controller.ts+++ b/packages/ui-plugin-sheets/src/controllers/sheet-ui.controller.ts@@ -54,7 +54,8 @@ import { SetScrollOperation } from '../commands/operations/scroll.operation';import { SetCopySelectionsOperation } from '../commands/operations/selection.operation';import { SetFormatPainterOperation } from '../commands/operations/set-format-painter.operation';import { SetZoomRatioOperation } from '../commands/operations/set-zoom-ratio.operation';-import { BORDER_LINE_COMPONENT, BorderLine } from '../components/border-line';+import { BorderPanel } from '../components/border-panel/BorderPanel';+import { BORDER_PANEL_COMPONENT } from '../components/border-panel/interface';import { COLOR_PICKER_COMPONENT, ColorPicker } from '../components/color-picker';import {FONT_FAMILY_COMPONENT,@@ -67,21 +68,33 @@ import { MENU_ITEM_INPUT_COMPONENT, MenuItemInput } from '../components/menu-iteimport { RenderSheetContent, RenderSheetFooter, RenderSheetHeader } from '../views/sheet-container/SheetContainer';import { CellBorderSelectorMenuItemFactory } from './menu/border.menu';import {- BackgroundColorSelectorMenuItemFactory,- BoldMenuItemFactory,- CellInsertMenuItemFactory,- ChangeColorSheetMenuItemFactory,ClearSelectionAllMenuItemFactory,ClearSelectionContentMenuItemFactory,ClearSelectionFormatMenuItemFactory,ClearSelectionMenuItemFactory,- ColInsertMenuItemFactory,- CopyMenuItemFactory,- CopySheetMenuItemFactory,+} from './menu/clear.menu';+import {DeleteRangeMenuItemFactory,DeleteRangeMoveLeftMenuItemFactory,DeleteRangeMoveUpMenuItemFactory,- DeleteSheetMenuItemFactory,+ RemoveColMenuItemFactory,+ RemoveRowMenuItemFactory,+} from './menu/delete.menu';+import {+ CellInsertMenuItemFactory,+ ColInsertMenuItemFactory,+ InsertColAfterMenuItemFactory,+ InsertColBeforeMenuItemFactory,+ InsertRangeMoveDownMenuItemFactory,+ InsertRangeMoveRightMenuItemFactory,+ InsertRowAfterMenuItemFactory,+ InsertRowBeforeMenuItemFactory,+ RowInsertMenuItemFactory,+} from './menu/insert.menu';+import {+ BackgroundColorSelectorMenuItemFactory,+ BoldMenuItemFactory,+ CopyMenuItemFactory,FitContentMenuItemFactory,FontFamilySelectorMenuItemFactory,FontSizeSelectorMenuItemFactory,@@ -89,28 +102,14 @@ import {FrozenMenuItemFactory,HideColMenuItemFactory,HideRowMenuItemFactory,- HideSheetMenuItemFactory,HorizontalAlignMenuItemFactory,- InsertColAfterMenuItemFactory,- InsertColBeforeMenuItemFactory,- InsertRangeMoveDownMenuItemFactory,- InsertRangeMoveRightMenuItemFactory,- InsertRowAfterMenuItemFactory,- InsertRowBeforeMenuItemFactory,ItalicMenuItemFactory,PasteMenuItemFactory,- RemoveColMenuItemFactory,- RemoveRowMenuItemFactory,- RenameSheetMenuItemFactory,ResetBackgroundColorMenuItemFactory,ResetTextColorMenuItemFactory,- RowInsertMenuItemFactory,- SetBorderColorMenuItemFactory,- SetBorderStyleMenuItemFactory,SetColWidthMenuItemFactory,SetRowHeightMenuItemFactory,ShowColMenuItemFactory,- ShowMenuItemFactory,ShowRowMenuItemFactory,StrikeThroughMenuItemFactory,TextColorSelectorMenuItemFactory,@@ -126,6 +125,14 @@ import {CellMergeMenuItemFactory,CellMergeVerticalMenuItemFactory,} from './menu/merge.menu';+import {+ ChangeColorSheetMenuItemFactory,+ CopySheetMenuItemFactory,+ DeleteSheetMenuItemFactory,+ HideSheetMenuItemFactory,+ RenameSheetMenuItemFactory,+ ShowMenuItemFactory,+} from './menu/sheet.menu';import {EditorBreakLineShortcut,EditorCursorEnterShortcut,@@ -190,7 +197,7 @@ export class SheetUIController extends Disposable {// FIXME: no dispose logiccomponentManager.register(MENU_ITEM_INPUT_COMPONENT, MenuItemInput);- componentManager.register(BORDER_LINE_COMPONENT, BorderLine);+ componentManager.register(BORDER_PANEL_COMPONENT, BorderPanel);componentManager.register(COLOR_PICKER_COMPONENT, ColorPicker);componentManager.register(FONT_FAMILY_COMPONENT, FontFamily);componentManager.register(FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem);@@ -281,11 +288,9 @@ export class SheetUIController extends Disposable {FontSizeSelectorMenuItemFactory,ResetTextColorMenuItemFactory,TextColorSelectorMenuItemFactory,- BackgroundColorSelectorMenuItemFactory,ResetBackgroundColorMenuItemFactory,+ BackgroundColorSelectorMenuItemFactory,CellBorderSelectorMenuItemFactory,- SetBorderColorMenuItemFactory,- SetBorderStyleMenuItemFactory,CellMergeMenuItemFactory,CellMergeAllMenuItemFactory,CellMergeVerticalMenuItemFactory,diff --git a/packages/ui-plugin-sheets/src/views/EditorContainer/editorContainer-zh.md b/packages/ui-plugin-sheets/src/views/EditorContainer/editorContainer-zh.mddeleted file mode 100644index 3be73d0226..0000000000--- a/packages/ui-plugin-sheets/src/views/EditorContainer/editorContainer-zh.md+++ /dev/null@@ -1,11 +0,0 @@-----category: Components-type: 通用-title: EditorContainer-subtitle: 文本编辑器-cover: ''------## 介绍--编辑器浮层,可录入公式,富文本diff --git a/packages/ui-plugin-slides/src/views/slide-container/SlideContainer.tsx b/packages/ui-plugin-slides/src/views/slide-container/SlideContainer.tsxindex 9533c5d588..aef4efdb8f 100644--- a/packages/ui-plugin-slides/src/views/slide-container/SlideContainer.tsx+++ b/packages/ui-plugin-slides/src/views/slide-container/SlideContainer.tsx@@ -1,5 +1,4 @@import { BaseComponentProps } from '@univerjs/base-ui';-import { Container, Content, Footer, Header, Layout, Sider } from '@univerjs/design';import { Component, createRef } from 'react';import { ISlideUIPluginConfig } from '../../basics';@@ -155,24 +154,24 @@ export class SlideContainer extends Component<BaseSlideContainerProps> {const config = layout?.slideContainerConfig!;// Set Provider for entire Containerreturn (- <Container className={style.layoutContainer}>- <Layout>- <Sider style={{ display: config.outerLeft ? 'block' : 'none' }}></Sider>- <Layout className={style.mainContent} style={{ position: 'relative' }}>- <Header style={{ display: config.header ? 'block' : 'none' }}>+ <section className={style.layoutContainer}>+ <div>+ <aside style={{ display: config.outerLeft ? 'block' : 'none' }}></aside>+ <div className={style.mainContent} style={{ position: 'relative' }}>+ <header style={{ display: config.header ? 'block' : 'none' }}>{config.infoBar && <InfoBar {...methods.infoBar}></InfoBar>}{config.toolbar && <Toolbar {...methods.toolbar}></Toolbar>}- </Header>- <Layout>- <Sider+ </header>+ <div>+ <asidestyle={{width: '300px',display: config.innerLeft ? 'block' : 'none',}}><SlideBar {...methods.slideBar}></SlideBar>- </Sider>- <Content+ </aside>+ <divclassName={config.contentSplit === 'vertical'? style.contentContainerVertical@@ -180,48 +179,48 @@ export class SlideContainer extends Component<BaseSlideContainerProps> {}>{!!config.contentSplit && (- <Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>+ <div ref={this.splitLeftRef} className={style.contentInnerLeftContainer}><divclassName={style.hoverCursor}onMouseDown={this.handleSplitBarMouseDown}></div>- </Container>+ </div>)}- <Container+ <divonContextMenu={(e: React.MouseEvent) => e.preventDefault()}ref={this.contentRef}className={style.contentInnerRightContainer}>{/* {config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>} */}- </Container>+ </div>{/* extend main content */}- </Content>+ </div>- <Sider+ <asidestyle={{display: config.innerRight ? 'block' : 'none',}}>{/* innerRight */}{/* <SideGroup></SideGroup> */}- </Sider>- </Layout>- <Footer+ </aside>+ </div>+ <footerstyle={{display: config.footer ? 'block' : 'none',}}>{/* {config.countBar && <CountBar {...methods.countBar}></CountBar>} */}- </Footer>- </Layout>- <Sider+ </footer>+ </div>+ <asidestyle={{display: config.outerRight ? 'block' : 'none',}}className={style.outerRightContainer}- ></Sider>- </Layout>- </Container>+ ></aside>+ </div>+ </section>);}}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a50eed0c12..34dc273c0f 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -557,9 +557,6 @@ importers:packages/base-ui:dependencies:- '@rc-component/trigger':- specifier: ^1.18.1- version: 1.18.1([email protected])([email protected])'@univerjs/base-render':specifier: workspace:*version: link:../base-render@@ -570,8 +567,8 @@ importers:specifier: workspace:*version: link:../design'@univerjs/icons':- specifier: ^0.1.7- version: 0.1.7([email protected])([email protected])+ specifier: ^0.1.8+ version: 0.1.8([email protected])([email protected])'@wendellhu/redi':specifier: ^0.12.11version: 0.12.11@@ -772,8 +769,8 @@ importers:specifier: ^1.18.1version: 1.18.1([email protected])([email protected])'@univerjs/icons':- specifier: ^0.1.7- version: 0.1.7([email protected])([email protected])+ specifier: ^0.1.8+ version: 0.1.8([email protected])([email protected])clsx:specifier: ^2.0.0version: 2.0.0@@ -979,8 +976,8 @@ importers:specifier: workspace:*version: link:../design'@univerjs/icons':- specifier: ^0.1.7- version: 0.1.7([email protected])([email protected])+ specifier: ^0.1.8+ version: 0.1.8([email protected])([email protected])'@univerjs/ui-plugin-sheets':specifier: workspace:*version: link:../ui-plugin-sheets@@ -1208,8 +1205,8 @@ importers:specifier: workspace:*version: link:../design'@univerjs/icons':- specifier: ^0.1.7- version: 0.1.7([email protected])([email protected])+ specifier: ^0.1.8+ version: 0.1.8([email protected])([email protected])'@wendellhu/redi':specifier: ^0.12.11version: 0.12.11@@ -5799,8 +5796,8 @@ packages:resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}dev: true- resolution: {integrity: sha512-jFzcqluGXPrNmbQ0GaB/aXrDtis+bV5igyWcYvx8/3ZIuwddQ0MVy//O4DulhV42Tc5XJMdRKeN41+iBHLiYXQ==}+ resolution: {integrity: sha512-E4wxcg/rHsdqzTlvQyRLSuBE/lH1cPFr/xOCRZk4/nlxnnmnt7iN/4fAIrHRqgCJOarAmFV8D6okv1POBEurIA==}peerDependencies:react: '*'react-dom: '*'