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
fix: fix icon types
wzhudev5ca2a3771caa
diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsxindex 8fc3a60e78..51946adf41 100644--- a/packages/base-ui/src/Components/Select/Select.tsx+++ b/packages/base-ui/src/Components/Select/Select.tsx@@ -12,7 +12,8 @@ import { Icon } from '../..'; // FIXME: strange import// TODO: these type definitions should be moved out of components to menu serviceexport enum SelectTypes {- SINGLE, // 普通下拉+ SINGLE,+ /** dropdown with input */INPUT,COLOR,DOUBLE,@@ -224,11 +225,18 @@ export class Select extends PureComponent<BaseSelectProps, IState> {}}+ updateData() {+ if (this.props.type === SelectTypes.INPUT) {+ this.setState({ content: this.props.label });+ }+ }+override componentDidMount() {this.initData();}override componentWillReceiveProps(nextProps: BaseSelectProps) {+ this.updateData();// this.props = Object.assign(this.props, nextProps);// this.initData();}@@ -303,7 +311,12 @@ export class Select extends PureComponent<BaseSelectProps, IState> {return (<div className={`${styles.selectInput} ${className}`}><Dropdown onMainClick={onMainClick} ref={ref} tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <Input onPressEnter={(e) => this.handlePressEnter(e, ref)} onBlur={this.onPressEnter} type="number" value={content as string} />+ <Input+ onPressEnter={(e) => this.handlePressEnter(e, ref)}+ onBlur={this.onPressEnter}+ type="number"+ value={`${this.props.label as number}` ?? (content as string)}+ /></Dropdown></div>);diff --git a/packages/base-ui/src/Interfaces/Tooltip.ts b/packages/base-ui/src/Interfaces/Tooltip.tsindex 4ba8d529b8..49029302e0 100644--- a/packages/base-ui/src/Interfaces/Tooltip.ts+++ b/packages/base-ui/src/Interfaces/Tooltip.ts@@ -3,7 +3,9 @@ import { BaseComponent, BaseComponentProps, JSXComponent } from '../BaseComponenexport interface BaseTooltipProps extends BaseComponentProps {[index: number]: string;+title?: string;+ shortcut?: string;children: ComponentChildren;placement?: string;color?: string;diff --git a/packages/base-ui/src/services/menu/menu.service.ts b/packages/base-ui/src/services/menu/menu.service.tsindex 5ecbb9aff4..85b95e273b 100644--- a/packages/base-ui/src/services/menu/menu.service.ts+++ b/packages/base-ui/src/services/menu/menu.service.ts@@ -13,6 +13,9 @@ export type OneOrMany<T> = T | T[];export const enum MenuPosition {TOOLBAR,CONTEXT_MENU,+ TAB_CONTEXT_MENU,+ ROW_HEADER_CONTEXT_MENU,+ COL_HEADER_CONTEXT_MENU,}export const enum MenuItemType {diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsindex 82f6175eb7..fa57f81ca8 100644--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts@@ -6,7 +6,21 @@ import { ComponentChildren } from 'preact';import { SheetToolbarConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';-import { WrapTextMenuItemFactory } from './menu';+import {+ BackgroundColorSelectorMenuItemFactory,+ BoldMenuItemFactory,+ CellBorderSelectorMenuItemFactory,+ TextColorSelectorMenuItemFactory,+ FontFamilySelectorMenuItemFactory,+ FontSizeSelectorMenuItemFactory,+ ItalicMenuItemFactory,+ RedoMenuItemFactory,+ StrikeThroughMenuItemFactory,+ TextRotateMenuItemFactory,+ UnderlineMenuItemFactory,+ UndoMenuItemFactory,+ WrapTextMenuItemFactory,+} from './menu';export interface BaseToolbarSelectProps extends BaseSelectProps {children?: BaseSelectChildrenProps[];@@ -102,19 +116,19 @@ 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,- // FontColorSelectorMenuItemFactory,- // BackgroundColorSelectorMenuItemFactory,- // CellBorderSelectorMenuItemFactory,+ UndoMenuItemFactory,+ RedoMenuItemFactory,+ FontFamilySelectorMenuItemFactory,+ FontSizeSelectorMenuItemFactory,+ BoldMenuItemFactory,+ ItalicMenuItemFactory,+ UnderlineMenuItemFactory,+ StrikeThroughMenuItemFactory,+ TextColorSelectorMenuItemFactory,+ BackgroundColorSelectorMenuItemFactory,+ CellBorderSelectorMenuItemFactory,WrapTextMenuItemFactory,- // TextRotateMenuItemFactory,+ TextRotateMenuItemFactory,].forEach((factory) => {this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));});diff --git a/packages/ui-plugin-sheets/src/Controller/menu.ts b/packages/ui-plugin-sheets/src/Controller/menu.tsindex c9b7b533e9..0324f9bf7d 100644--- a/packages/ui-plugin-sheets/src/Controller/menu.ts+++ b/packages/ui-plugin-sheets/src/Controller/menu.ts@@ -333,10 +333,11 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec};}-export function FontColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {+export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {return {id: SetTextColorCommand.id,title: 'textColor',+ tooltip: 'toolbar.textColor.main',type: MenuItemType.SELECTOR,selectType: SelectTypes.DOUBLEFIX,menu: [MenuPosition.TOOLBAR],@@ -410,7 +411,7 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSeldisplay: DisplayTypes.SUFFIX,menu: [MenuPosition.TOOLBAR],type: MenuItemType.SELECTOR,- selectType: SelectTypes.DOUBLEFIX,+ selectType: SelectTypes.DOUBLE,selections: [...BORDER_LINE_CHILDREN,{@@ -549,17 +550,14 @@ export function WrapTextMenuItemFactory(accessor: IAccessor): IMenuSelectorItemreturn {id: SetTextWrapCommand.id,title: 'textWrapMode',- label: {- name: 'textWrapMode',- props: undefined,- },tooltip: 'toolbar.textWrapMode.main',type: MenuItemType.SELECTOR,- selectType: SelectTypes.SINGLE,+ selectType: SelectTypes.DOUBLE,menu: [MenuPosition.TOOLBAR],selections: TEXT_WRAP_CHILDREN,+ display: DisplayTypes.SUFFIX,value$: new Observable((subscriber) => {- const dispose = commandService.onCommandExecuted((c) => {+ const disposable = commandService.onCommandExecuted((c) => {const id = c.id;if (id !== SetRangeStyleMutation.id && id !== SetSelectionsOperation.id) {return;@@ -571,7 +569,7 @@ export function WrapTextMenuItemFactory(accessor: IAccessor): IMenuSelectorItemsubscriber.next(ws);});- return () => dispose.dispose();+ return () => disposable.dispose();}),};}@@ -586,8 +584,9 @@ export function TextRotateMenuItemFactory(accessor: IAccessor): IMenuSelectorIteid: SetTextRotationCommand.id,title: 'textRotateMode',tooltip: 'toolbar.textRotateMode.main',+ display: DisplayTypes.SUFFIX,type: MenuItemType.SELECTOR,- selectType: SelectTypes.SINGLE,+ selectType: SelectTypes.DOUBLE,menu: [MenuPosition.TOOLBAR],value$: new Observable<number>((subscriber) => {commandService.onCommandExecuted((c) => {diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsx b/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsxindex 707806c4ee..5e2eaa34d1 100644--- a/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsx+++ b/packages/ui-plugin-sheets/src/View/Toolbar/ToolbarItem.tsx@@ -42,7 +42,8 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbar});if (this.props.type === MenuItemType.SELECTOR) {- this.currentValueSubscription = (this.props as IDisplayMenuItem<IMenuSelectorItem>).value$?.subscribe((value) => {+ const props = this.props as IDisplayMenuItem<IMenuSelectorItem>;+ this.currentValueSubscription = props.value$?.subscribe((value) => {this.setState({ value });});}@@ -71,15 +72,15 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbarconst props = this.props as IDisplayMenuItem<IMenuSelectorItem>;return (- <Tooltip title={props.title + (props.shortcut ? ` (${props.shortcut})` : '')} placement="bottom">+ <Tooltip title={props.tooltip + (props.shortcut ? ` (${props.shortcut})` : '')} placement="bottom"><SelectclassName={props.className}- tooltip={props.tooltip}label={value ?? props.label}display={props.display}type={props.selectType!}children={props.selections!}onClick={(value) => commandService.executeCommand(props.id, { value })}+ onPressEnter={(value) => commandService.executeCommand(props.id, { value })}></Select></Tooltip>);