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
WIP
wzhudev0e658309fb18
diff --git a/packages/base-sheets/src/Commands/Commands/set-style.command.ts b/packages/base-sheets/src/Commands/Commands/set-style.command.tsindex b6dad539f2..b1d1552c95 100644--- a/packages/base-sheets/src/Commands/Commands/set-style.command.ts+++ b/packages/base-sheets/src/Commands/Commands/set-style.command.ts@@ -251,7 +251,7 @@ export const SetFontSizeCommand: ICommand<ISetFontSizeCommandParams> = {};export interface ISetColorCommandParams {- value: IColorStyle;+ value: string;}export const SetTextColorCommand: ICommand<ISetColorCommandParams> = {@@ -266,7 +266,9 @@ export const SetTextColorCommand: ICommand<ISetColorCommandParams> = {const setStyleParams: ISetStyleParams<IColorStyle> = {style: {type: 'cl',- value: params.value,+ value: {+ rgb: params.value,+ },},};@@ -304,7 +306,27 @@ export const SetBackgroundColorCommand: ICommand<ISetColorCommandParams> = {const setStyleParams: ISetStyleParams<IColorStyle> = {style: {type: 'bg',- value: params.value,+ value: {+ rgb: params.value,+ },+ },+ };++ return commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ },+};++export const ResetBackgroundColorCommand: ICommand = {+ type: CommandType.COMMAND,+ id: 'sheet.command.reset-background-color',+ handler: async (accessor) => {+ const commandService = accessor.get(ICommandService);+ const setStyleParams: ISetStyleParams<IColorStyle> = {+ style: {+ type: 'bg',+ value: {+ rgb: undefined,+ },},};@@ -313,7 +335,7 @@ export const SetBackgroundColorCommand: ICommand<ISetColorCommandParams> = {};export interface ISetCellBorderCommandParams {- border: IBorderData;+ value: IBorderData;}export const SetCellBorderCommand: ICommand<ISetCellBorderCommandParams> = {@@ -328,7 +350,44 @@ export const SetCellBorderCommand: ICommand<ISetCellBorderCommandParams> = {const setStyleParams: ISetStyleParams<IBorderData> = {style: {type: 'bd',- value: params.border,+ value: params.value,+ },+ };++ return commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ },+};++export interface ISetCellBorderColorCommandParams {+ value: string;+}++export const SetCellBorderColorCommand: ICommand<ISetCellBorderColorCommandParams> = {+ type: CommandType.COMMAND,+ id: 'sheet.command.set-cell-border-color',+ handler: async (accessor, params) => {+ if (!params) {+ return false;+ }++ const commandService = accessor.get(ICommandService);++ const currentCell = accessor.get(ISelectionManager).getCurrentCell();+ if (!currentCell) {+ return false;+ }++ const currentBorder = currentCell.getBorder();+ const newBorder = Tools.deepMerge(currentBorder, {+ color: {+ rgb: params.value,+ },+ });++ const setStyleParams: ISetStyleParams<IBorderData> = {+ style: {+ type: 'bd',+ value: newBorder,},};diff --git a/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts b/packages/base-sheets/src/Controller/BasicWorksheet.controller.tsindex 84a5f43b2e..b221dbd4c1 100644--- a/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts+++ b/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts@@ -9,6 +9,7 @@ import { SetWorksheetActivateCommand } from '../Commands/Commands/set-worksheet-import { SetWorksheetActivateMutation } from '../Commands/Mutations/set-worksheet-activate.mutation';import {ISetStyleParams,+ ResetBackgroundColorCommand,ResetTextColorCommand,SetBackgroundColorCommand,SetCellBorderCommand,@@ -106,6 +107,7 @@ export class BasicWorksheetController extends Disposable implements IDisposableSetTextWrapCommand,SetTextRotationCommand,ResetTextColorCommand,+ ResetBackgroundColorCommand,].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));}diff --git a/packages/base-sheets/src/index.ts b/packages/base-sheets/src/index.tsindex 219358cb02..da94a823f6 100644--- a/packages/base-sheets/src/index.ts+++ b/packages/base-sheets/src/index.ts@@ -33,6 +33,8 @@ export {SetTextWrapCommand,SetVerticalTextAlignCommand,ResetTextColorCommand,+ ResetBackgroundColorCommand,+ SetCellBorderColorCommand,} from './Commands/Commands/set-style.command';export { InsertSheetCommand } from './Commands/Commands/insert-sheet.command';export { ClearSelectionContentCommand } from './Commands/Commands/clear-selection-content.command';diff --git a/packages/base-ui/src/Components/ColorPicker/ColorPicker.tsx b/packages/base-ui/src/Components/ColorPicker/ColorPicker.tsxindex 1571ef6ceb..08123052ff 100644--- a/packages/base-ui/src/Components/ColorPicker/ColorPicker.tsx+++ b/packages/base-ui/src/Components/ColorPicker/ColorPicker.tsx@@ -1,5 +1,6 @@-import { Component, createRef } from 'preact';+import { Component, JSX, createRef } from 'preact';import { BaseColorPickerProps, ColorPickerComponent, JSXComponent } from '../..';+import { ICustomComponentProps } from '../../services/menu/menu';import { Button, Tooltip } from '../index';import { ColorPickerPanel } from './ColorPickerPanel';import { CustomLabel } from '../CustomLabel';@@ -27,7 +28,7 @@ interface IState {root: Element | null;}-class ColorPicker extends Component<BaseColorPickerProps, IState> {+class ColorPicker extends Component<BaseColorPickerProps & ICustomComponentProps<string>, IState> {ulRef = createRef();constructor(props: BaseColorPickerProps) {@@ -66,8 +67,8 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {* @eventProperty*/onClick = (color: string, e: MouseEvent) => {- this.props.onClick && this.props.onClick(color, e);- // this.hideSelect();+ this.props.onClick?.(color, e);+ this.props.onValueChange?.(color);};/**@@ -134,7 +135,7 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {});};- componentDidMount() {+ override componentDidMount() {this.props.getComponent?.(this);}@@ -161,8 +162,7 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {className={styles.pickerSwatchBtn}style={{ background: item }}onClick={(e: MouseEvent) => {- // this.hideSelect();- this.props.onClick && this.props.onClick(item, e);+ this.onClick(item, e);}}/></Tooltip>diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsxindex 887d73663c..c5cd2ab887 100644--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx+++ b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx@@ -6,7 +6,7 @@ import { IBaseCustomLabelProps } from '../../Interfaces';import { DisplayTypes } from '../Select';import styles from './CustomLabel.module.less';-import { IMenuSelectorItem } from '../../services/menu/menu.service';+import { IMenuSelectorItem } from '../../services/menu/menu';function getLocale(context: Partial<AppContextValues>, name: string) {return context.localeService?.t(name);@@ -38,6 +38,11 @@ export function NeoCustomLabel<T>(props: Pick<IMenuSelectorItem<unknown>, 'icon'// TODO: implement display input}+ // if the render type is icon, then render value to icon+ if (display === DisplayTypes.ICON) {+ return <>{value}</>;+ }+return <>{value}</>;}diff --git a/packages/base-ui/src/Components/Dropdown/Dropdown.tsx b/packages/base-ui/src/Components/Dropdown/Dropdown.tsxindex 23c7f26e3f..234f3175a8 100644--- a/packages/base-ui/src/Components/Dropdown/Dropdown.tsx+++ b/packages/base-ui/src/Components/Dropdown/Dropdown.tsx@@ -91,13 +91,18 @@ export class Dropdown extends PureComponent<BaseDropdownProps, IState> {)}{content}<Menu+ menuId={menu.menuId}options={menu.options}+ display={menu.display}onClick={menu.onClick}ref={this.MenuRef}menu={menu.menu}- menuItems={menu.menuItems}className={menu.className}style={{ ...menu.style, ...menuStyle }}+ onOptionSelect={(v) => {+ menu.onOptionSelect?.(v);+ this.hideMenu();+ }}></Menu></div>);diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsxindex 4f688e07cf..84dd4988a6 100644--- a/packages/base-ui/src/Components/Menu/Menu.tsx+++ b/packages/base-ui/src/Components/Menu/Menu.tsx@@ -1,15 +1,23 @@import { Component, ComponentChild, createRef } from 'preact';import { Subscription } from 'rxjs';import { ICommandService } from '@univerjs/core';-import { BaseMenuProps, BaseMenuState, BaseMenuItem, BaseMenuStyle } from '../../Interfaces';+import { BaseMenuProps, BaseMenuItem, BaseMenuStyle } from '../../Interfaces';import { joinClassNames } from '../../Utils';-import { CustomLabel } from '../CustomLabel';+import { CustomLabel, NeoCustomLabel } from '../CustomLabel';import styles from './index.module.less';-import { IDisplayMenuItem } from '../../services/menu/menu.service';+import { IDisplayMenuItem, IMenuService } from '../../services/menu/menu.service';import { AppContext } from '../../Common/AppContext';-import { IMenuItem } from '../../services/menu/menu';+import { ICustomComponentOption, IMenuItem, IValueOption, isValueOptions } from '../../services/menu/menu';++export interface IBaseMenuState {+ show: boolean;+ posStyle: BaseMenuStyle;+ menuItems: Array<IDisplayMenuItem<IMenuItem>>;+}++export class Menu extends Component<BaseMenuProps, IBaseMenuState> {+ static override contextType = AppContext;-export class Menu extends Component<BaseMenuProps, BaseMenuState> {private _MenuRef = createRef<HTMLUListElement>();private _refs: Menu[] = [];@@ -19,6 +27,16 @@ export class Menu extends Component<BaseMenuProps, BaseMenuState> {this.initialize();}+ override componentDidMount(): void {+ this.getSubMenus();+ }++ override componentWillReceiveProps(nextProps: Readonly<BaseMenuProps>): void {+ if (this.props.menuId !== nextProps.menuId) {+ this.getSubMenus();+ }+ }+getMenuRef = () => this._MenuRef;handleClick = (e: MouseEvent, item: BaseMenuItem, index: number) => {@@ -93,9 +111,11 @@ export class Menu extends Component<BaseMenuProps, BaseMenuState> {}};+ // eslint-disable-next-line max-lines-per-functionrender() {- const { className = '', style = '', menu, menuItems, deep = 0, options } = this.props;- const { show, posStyle } = this.state;+ const { context, props, state } = this;+ const { className = '', style = '', menu, deep = 0, options, display } = props;+ const { show, posStyle, menuItems } = state;return (<ul className={joinClassNames(styles.colsMenu, className)} style={{ ...style, ...posStyle, display: show ? 'block' : 'none' }} ref={this._MenuRef}>@@ -136,7 +156,38 @@ export class Menu extends Component<BaseMenuProps, BaseMenuState> {</>);})}- {/* render custom components */}+ {options?.map((option: IValueOption | ICustomComponentOption, index: number) => {+ // render value option+ const isValueOption = isValueOptions(option);+ if (isValueOption) {+ return (+ <li+ className={joinClassNames(styles.colsMenuitem, option.disabled ? styles.colsMenuitemDisabled : '')}+ onClick={() => {+ if (option.value) {+ this.props.onOptionSelect!(option);+ }+ // TODO: handle if options is a custom component+ }}+ >+ <NeoCustomLabel value={option.value} display={display} title={option.label} />+ </li>+ );+ }++ // custom component option+ const CustomComponent = context.componentManager?.get(option.id);+ return (+ <li>+ <CustomComponent+ onValueChange={(v: string | number) => {+ this.props.onOptionSelect!({ value: v, label: option.id });+ this.showMenu(false);+ }}+ />+ </li>+ );+ })}{/* render submenus */}{menuItems?.map((item, index) => (<MenuItem menuItem={item} index={index} onClick={() => this.showMenu(false)} />@@ -149,8 +200,19 @@ export class Menu extends Component<BaseMenuProps, BaseMenuState> {this.state = {show: false,posStyle: {},+ menuItems: [],};}++ private getSubMenus() {+ const { menuId } = this.props;+ if (menuId) {+ const menuService: IMenuService = this.context.injector.get(IMenuService);+ this.setState({+ menuItems: menuService.getSubMenuItems(menuId),+ });+ }+ }}export interface IMenuItemProps {diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsxindex 09e32e3aad..7591774de5 100644--- a/packages/base-ui/src/Components/Select/Select.tsx+++ b/packages/base-ui/src/Components/Select/Select.tsx@@ -7,8 +7,7 @@ import { Input } from '../Input';import { BaseItemProps, Item } from '../Item/Item';import { CustomLabel, NeoCustomLabel } from '../CustomLabel';import styles from './index.module.less';-import { Icon, IDisplayMenuItem, IMenuItem, IMenuService } from '../..'; // FIXME: strange import-import { IValueOption } from '../../services/menu/menu.service';+import { Icon, IDisplayMenuItem, IMenuItem, IValueOption } from '../..'; // FIXME: strange import// TODO: these type definitions should be moved out of components to menu service@@ -67,7 +66,7 @@ export interface BaseSelectProps {value?: string | number;icon?: string;id?: string;- options?: IValueOption;+ options?: IValueOption[];title?: string;}@@ -265,15 +264,10 @@ export class Select extends PureComponent<BaseSelectProps, IState> {override componentDidMount() {this.initData();- this.getSubMenus();}override componentWillReceiveProps(nextProps: BaseSelectProps) {this.updateData();-- if (this.props.id !== nextProps.id && nextProps.id) {- this.getSubMenus();- }}resetMenu(children: BaseSelectChildrenProps[], hideSelectedIcon?: boolean) {@@ -404,18 +398,22 @@ export class Select extends PureComponent<BaseSelectProps, IState> {};renderNeo = () => {- const { tooltip, onClick, display, value, icon, title, id, options } = this.props;+ const { tooltip, onClick, display, value, icon, title, id, options, type } = this.props;const { menuItems } = this.state;const onClickInner = (...args: unknown[]) => {onClick?.(args[1] as number | string);};+ const onOptionSelect = (option: IValueOption) => {+ onClick?.(option.value);+ };+return (<div className={`${styles.selectDouble}`}>{/* TODO@wzhudev: we should compose options and builtin component here. They may have different onClick callback. */}{/* TODO@wzhudev: should pass in a value to set the menu's selected status. */}- <Dropdown tooltip={tooltip} onClick={onClick} menu={{ parentId: id, options, onClick: onClickInner, menuItems }} icon={<Icon.NextIcon />}>+ <Dropdown tooltip={tooltip} onClick={onClick} menu={{ menuId: id, options, onClick: onClickInner, onOptionSelect, display }} icon={<Icon.NextIcon />}>{/* TODO@wzhudev: change menu props of Dropdown. Dropdown shouldn't know how to create a menu. */}<div className={styles.selectLabel}><NeoCustomLabel icon={icon} display={display} title={title!} value={value} onChange={(v) => onClick?.(v)} />@@ -430,14 +428,4 @@ export class Select extends PureComponent<BaseSelectProps, IState> {return <div className={styles.selectComponent}>{this.getType(type)}</div>;}-- private getSubMenus() {- const { id } = this.props;- if (id) {- const menuService: IMenuService = this.context.injector.get(IMenuService);- this.setState({- menuItems: menuService.getSubMenuItems(id),- });- }- }}diff --git a/packages/base-ui/src/Interfaces/CustomLabel.ts b/packages/base-ui/src/Interfaces/CustomLabel.tsindex 411f6d7199..e2952cb07c 100644--- a/packages/base-ui/src/Interfaces/CustomLabel.ts+++ b/packages/base-ui/src/Interfaces/CustomLabel.ts@@ -26,4 +26,4 @@ export interface IBaseCustomLabelProps {export interface CustomLabelComponent extends BaseComponent<IBaseCustomLabelProps> {render(): JSXComponent<IBaseCustomLabelProps>;-}\ No newline at end of file+}diff --git a/packages/base-ui/src/Interfaces/Menu.ts b/packages/base-ui/src/Interfaces/Menu.tsindex 9639fe9ae7..b4a283e958 100644--- a/packages/base-ui/src/Interfaces/Menu.ts+++ b/packages/base-ui/src/Interfaces/Menu.ts@@ -1,6 +1,7 @@import { ComponentChildren, JSX } from 'preact';import { BaseComponent, JSXComponent } from '../BaseComponent';-import { IDisplayMenuItem, IValueOption } from '../services/menu/menu.service';+import { ICustomComponentOption, IValueOption } from '../services/menu/menu';+import { DisplayTypes } from '../Components/Select/Select';export interface BaseMenuItem {className?: string;@@ -15,29 +16,31 @@ export interface BaseMenuItem {}export interface BaseMenuProps {+ /** @deprecated */onClick?: (...arg: any) => void;+ /** @deprecated */className?: string;+ /** @deprecated */style?: JSX.CSSProperties;+ /** @deprecated */parent?: any;+ /** @deprecated */dom?: HTMLElement;+ /** @deprecated */ref?: any;+ /** @deprecated */deep?: number;/** @deprecated this is legacy menu mechanism. Do not use it. Use `menuItems` instead. */menu?: BaseMenuItem[]; // TODO: should be renamed to `items`// NOTE: options above are legacy. They are going to be removed after we complete refactoring.+ display?: DisplayTypes;menuId?: string;- // eslint-disable-next-line @typescript-eslint/no-explicit-any- menuItems?: Array<IDisplayMenuItem<any>>;- options?: IValueOption[];+ options?: Array<IValueOption | ICustomComponentOption>;+ onOptionSelect?: (option: IValueOption) => void;}-export type BaseMenuState = {- show: boolean;- posStyle: BaseMenuStyle;-};-export type BaseMenuStyle = {left?: string;right?: string;diff --git a/packages/base-ui/src/index.ts b/packages/base-ui/src/index.tsindex 9826d8c8cc..10e9836668 100644--- a/packages/base-ui/src/index.ts+++ b/packages/base-ui/src/index.ts@@ -8,7 +8,18 @@ export * from './Components';export * from './BaseComponent';export * from './UIPlugin';-export { MenuItemType, MenuPosition, ICustomComponentOption, IMenuButtonItem, IMenuItem, IMenuSelectorItem, IValueOption } from './services/menu/menu';+export {+ ICustomComponentProps,+ ICustomComponentOption,+ IMenuButtonItem,+ IMenuItem,+ IMenuSelectorItem,+ IValueOption,+ MenuItemType,+ MenuPosition,+ isCustomComponentOption,+ isValueOptions,+} from './services/menu/menu';export { IMenuService, DesktopMenuService, IDisplayMenuItem } from './services/menu/menu.service';export { KeyCode, MetaKeys } from './services/shortcut/keycode';export { IShortcutService, IShortcutItem, DesktopShortcutService } from './services/shortcut/shortcut.service';diff --git a/packages/base-ui/src/services/menu/menu.ts b/packages/base-ui/src/services/menu/menu.tsindex 94d019972d..40019de590 100644--- a/packages/base-ui/src/services/menu/menu.ts+++ b/packages/base-ui/src/services/menu/menu.ts@@ -20,6 +20,7 @@ export const enum MenuItemType {BUTTON,/** Menu item with submenus. Submenus could be other IMenuItem or an ID of a registered component. */SELECTOR,+ DROPDOWN,}interface IMenuItemBase {@@ -63,12 +64,25 @@ export interface IValueOption {disabled?: boolean;}+export function isValueOptions(v: IValueOption | ICustomComponentOption): v is IValueOption {+ return typeof (v as IValueOption).value !== 'undefined';+}+export interface ICustomComponentOption {id: string;}+export interface ICustomComponentProps<T> {+ value: T;+ onValueChange: (v: T) => void;+}++export function isCustomComponentOption(v: IValueOption | ICustomComponentOption): v is ICustomComponentOption {+ return typeof (v as ICustomComponentOption).id !== 'undefined';+}+export interface IMenuSelectorItem<V> extends IMenuItemBase {- type: MenuItemType.SELECTOR;+ type: MenuItemType.SELECTOR | MenuItemType.DROPDOWN;/** Determines how the label of the selector should display. */display?: DisplayTypes;diff --git a/packages/core/src/Types/Interfaces/IStyleData.ts b/packages/core/src/Types/Interfaces/IStyleData.tsindex c28c9069c0..7705682692 100644--- a/packages/core/src/Types/Interfaces/IStyleData.ts+++ b/packages/core/src/Types/Interfaces/IStyleData.ts@@ -1,13 +1,5 @@import { BorderStyleTypes } from '../Enum/BorderStyleTypes';-import {- BooleanNumber,- HorizontalAlign,- TextDecoration,- TextDirection,- BaselineOffset,- VerticalAlign,- WrapStrategy,-} from '../Enum/TextStyle';+import { BooleanNumber, HorizontalAlign, TextDecoration, TextDirection, BaselineOffset, VerticalAlign, WrapStrategy } from '../Enum/TextStyle';import { ThemeColorType } from '../Enum/ThemeColorType';import { Nullable } from '../../Shared/Types';diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsindex f3b064779d..39ec89a6bd 100644--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts@@ -6,18 +6,7 @@ import { ComponentChildren } from 'preact';import { SheetToolbarConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';-import {- BoldMenuItemFactory,- FontFamilySelectorMenuItemFactory,- FontSizeSelectorMenuItemFactory,- ItalicMenuItemFactory,- RedoMenuItemFactory,- ResetTextColorMenuItemFactory,- StrikeThroughMenuItemFactory,- TextColorSelectorMenuItemFactory,- UnderlineMenuItemFactory,- UndoMenuItemFactory,-} from './menu';+import { CellBorderSelectorMenuItemFactory, SetBorderColorMenuItemFactory } from './menu';export interface BaseToolbarSelectProps extends BaseSelectProps {children?: BaseSelectChildrenProps[];@@ -113,18 +102,20 @@ export class ToolbarUIController extends Disposable {// TODO: @wzhudev: now we register menu items that only display in the toolbar here. In fact we should register all commands and menu items and shortcuts// in a single controller. I will do that layer.[- UndoMenuItemFactory,- RedoMenuItemFactory,- FontFamilySelectorMenuItemFactory,- FontSizeSelectorMenuItemFactory,- BoldMenuItemFactory,- ItalicMenuItemFactory,- UnderlineMenuItemFactory,- StrikeThroughMenuItemFactory,- TextColorSelectorMenuItemFactory,- ResetTextColorMenuItemFactory,+ // UndoMenuItemFactory,+ // RedoMenuItemFactory,+ // FontFamilySelectorMenuItemFactory,+ // FontSizeSelectorMenuItemFactory,+ // BoldMenuItemFactory,+ // ItalicMenuItemFactory,+ // UnderlineMenuItemFactory,+ // StrikeThroughMenuItemFactory,+ // TextColorSelectorMenuItemFactory,+ // ResetTextColorMenuItemFactory,// BackgroundColorSelectorMenuItemFactory,- // CellBorderSelectorMenuItemFactory,+ // ResetBackgroundColorMenuItemFactory,+ CellBorderSelectorMenuItemFactory,+ SetBorderColorMenuItemFactory,// HorizontalAlignMenuItemFactory,// VerticalAlignMenuItemFactory,// WrapTextMenuItemFactory,diff --git a/packages/ui-plugin-sheets/src/Controller/menu.ts b/packages/ui-plugin-sheets/src/Controller/menu.tsindex fdc515bba7..3be0d63b11 100644--- a/packages/ui-plugin-sheets/src/Controller/menu.ts+++ b/packages/ui-plugin-sheets/src/Controller/menu.ts@@ -24,6 +24,8 @@ import {SetHorizontalTextAlignCommand,SetVerticalTextAlignCommand,ResetTextColorCommand,+ ResetBackgroundColorCommand,+ SetCellBorderColorCommand,} from '@univerjs/base-sheets';import { ColorPicker, DisplayTypes, IMenuButtonItem, IMenuItem, IMenuSelectorItem, MenuItemType, MenuPosition, SelectTypes } from '@univerjs/base-ui';import { FontItalic, FontWeight, IBorderData, ICommandService, IPermissionService, IUndoRedoService, RedoCommand, UndoCommand } from '@univerjs/core';@@ -392,9 +394,6 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSeledisplay: DisplayTypes.COLOR,className: styles.selectColorPickerParent,selections: [- {- id: 'toolbar.resetColor',- },{id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,},@@ -417,6 +416,16 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele};}+export function ResetBackgroundColorMenuItemFactory(accessor: IAccessor): IMenuButtonItem {+ return {+ id: ResetBackgroundColorCommand.id,+ type: MenuItemType.BUTTON,+ title: 'toolbar.resetColor',+ positions: [MenuPosition.TOOLBAR],+ parentId: SetBackgroundColorCommand.id,+ };+}+export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {const commandService = accessor.get(ICommandService);const selectionManager = accessor.get(ISelectionManager);@@ -432,9 +441,6 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMeicon: 'FillColorIcon',className: styles.selectColorPickerParent,selections: [- {- id: 'toolbar.resetColor',- },{id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,},@@ -457,7 +463,24 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMe};}-export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<IBorderData | undefined> {+export function SetBorderColorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<IBorderData | undefined> {+ return {+ id: SetCellBorderColorCommand.id,+ title: 'border',+ positions: [MenuPosition.TOOLBAR],+ parentId: SetCellBorderCommand.id,+ display: DisplayTypes.COLOR,+ selectType: SelectTypes.NEO,+ type: MenuItemType.SELECTOR,+ selections: [+ {+ id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,+ },+ ],+ };+}++export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {const permissionService = accessor.get(IPermissionService);const commandService = accessor.get(ICommandService);const selectionManager = accessor.get(ISelectionManager);@@ -465,36 +488,12 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSelreturn {id: SetCellBorderCommand.id,title: 'border',- display: DisplayTypes.SUFFIX,+ display: DisplayTypes.ICON,positions: [MenuPosition.TOOLBAR],- type: MenuItemType.SELECTOR,- selectType: SelectTypes.DOUBLE,+ type: MenuItemType.DROPDOWN,+ selectType: SelectTypes.NEO,selections: [...BORDER_LINE_CHILDREN,- // TODO: change to border color menu item here- // {- // name: 'borderColor',- // label: {- // name: SHEET_UI_PLUGIN_NAME + LineColor.name,- // props: {- // color: '#000',- // label: 'borderLine.borderColor',- // },- // },- // className: styles.selectColorPickerParent,- // children: [- // {- // label: {- // name: SHEET_UI_PLUGIN_NAME + ColorPicker.name,- // props: {},- // },- // className: styles.selectColorPicker,- // onClick: (...arg) => {- // arg[0].stopPropagation();- // },- // },- // ],- // },// TODO: add a set line bold menu item here// {// label: {@@ -509,20 +508,8 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSel// children: BORDER_SIZE_CHILDREN,// },],- value$: new Observable<IBorderData | undefined>((subscriber) => {- const disposable = commandService.onCommandExecuted((c) => {- const id = c.id;- if (id !== SetRangeStyleMutation.id && id !== SetSelectionsOperation.id) {- return;- }-- const range = selectionManager.getCurrentCell();- const borderData = range?.getBorder();-- subscriber.next(borderData);- });-- return disposable.dispose;+ value$: new Observable<string>((subscriber) => {+ subscriber.next('border');}),};}@@ -593,7 +580,7 @@ export function WrapTextMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<}// FIXME: set rotation would cause a bug-export function TextRotateMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {+export function TextRotateMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<number> {const permissionService = accessor.get(IPermissionService);const commandService = accessor.get(ICommandService);const selectionManager = accessor.get(ISelectionManager);@@ -705,7 +692,8 @@ export function DeleteRangeMenuItemFactory(accessor: IAccessor): IMenuItem {id: `${DeleteRangeCommand.id}.parent`,positions: [MenuPosition.CONTEXT_MENU],title: 'rightClick.deleteCell',- submenus: [DeleteRangeCommand.id, `${DeleteRangeCommand.id}up`],+ type: MenuItemType.BUTTON,+ // submenus: [DeleteRangeCommand.id, `${DeleteRangeCommand.id}up`],};}export function DeleteRangeMoveLeftMenuItemFactory(accessor: IAccessor): IMenuItem {diff --git a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsxindex b997b2ce34..1f2028b2dd 100644--- a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx@@ -42,4 +42,4 @@ export class ColorSelect extends Component<IProps, IState> {</div>);}-}\ No newline at end of file+}diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/Const.ts b/packages/ui-plugin-sheets/src/View/Toolbar/Const.tsindex db573b0f9d..1e6b62a0d3 100644--- a/packages/ui-plugin-sheets/src/View/Toolbar/Const.ts+++ b/packages/ui-plugin-sheets/src/View/Toolbar/Const.ts@@ -151,6 +151,7 @@ export const FONT_FAMILY_CHILDREN = [export const BORDER_LINE_CHILDREN = [{label: 'borderLine.borderTop',+ icon: 'TopBorderIcon',suffix: {name: 'TopBorderIcon',},diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsx b/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsxindex fc8d9d8d10..b7e4a8f888 100644--- a/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsx+++ b/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsx@@ -1,7 +1,7 @@import { ComponentChild, Component } from 'preact';import { Subscription } from 'rxjs';-import { AppContext, Button, Tooltip, CustomLabel, IDisplayMenuItem, MenuItemType, Select, IMenuSelectorItem, IMenuItem, IMenuButtonItem } from '@univerjs/base-ui';+import { AppContext, Button, Tooltip, CustomLabel, IDisplayMenuItem, MenuItemType, Select, IMenuSelectorItem, IMenuItem, IMenuButtonItem, IValueOption } from '@univerjs/base-ui';import { ICommandService } from '@univerjs/core';import styles from './index.module.less';@@ -62,6 +62,7 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbarrender(): ComponentChild {switch (this.props.type) {+ case MenuItemType.DROPDOWN:case MenuItemType.SELECTOR:return this.renderSelectorType();default:@@ -84,6 +85,7 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbartitle={title}children={selections!}className={className}+ options={selections as IValueOption[]}display={display}icon={icon}value={value}