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
xiugai
tonytonychopper123a1f965c610fc
diff --git a/packages/base-sheets/src/Controller/ToolBarController.ts b/packages/base-sheets/src/Controller/ToolBarController.tsindex a871467715..4882ec8439 100644--- a/packages/base-sheets/src/Controller/ToolBarController.ts+++ b/packages/base-sheets/src/Controller/ToolBarController.ts@@ -1,4 +1,4 @@-import { Range, HorizontalAlign, VerticalAlign, WrapStrategy, BorderType, UIObserver } from '@univerjs/core';+import { HorizontalAlign, VerticalAlign, WrapStrategy, BorderType, UIObserver } from '@univerjs/core';import { SheetPlugin } from '../SheetPlugin';import { SelectionControl } from './Selection/SelectionController';@@ -17,71 +17,6 @@ export interface BorderInfo {export class ToolbarController {private _plugin: SheetPlugin;- private _changeToolbarState(range: Range): void {- const workbook = this._plugin.getContext().getWorkBook();- const worksheet = workbook.getActiveSheet();- if (worksheet) {- const cellMatrix = worksheet.getCellMatrix();- const strikeThrough = range.getStrikeThrough();- const fontSize = range.getFontSize();- const fontWeight = range.getFontWeight();- const fontName = range.getFontFamily();- const fontItalic = range.getFontStyle();- const underline = range.getUnderline();- const horizontalAlign = range.getHorizontalAlignment();- const verticalAlign = range.getVerticalAlignment();- const rotation = range.getTextRotation();-- // const textRotateModeItem = this._toolList.find((item) => item.name === 'textRotateMode');- // const fontSizeItem = this._toolList.find((item) => item.name === 'fontSize');- // const fontNameItem = this._toolList.find((item) => item.name === 'font');- // const fontBoldItem = this._toolList.find((item) => item.name === 'bold');- // const fontItalicItem = this._toolList.find((item) => item.name === 'italic');- // const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');- // const underlineItem = this._toolList.find((item) => item.name === 'underline');- // const horizontalAlignModeItem = this._toolList.find((item) => item.name === 'horizontalAlignMode');- // const verticalAlignModeItem = this._toolList.find((item) => item.name === 'verticalAlignMode');-- // if (strikethroughItem) {- // strikethroughItem.active = !!(strikeThrough && strikeThrough.s);- // }- // if (fontNameItem) {- // fontNameItem.children?.forEach((item) => {- // item.selected = fontName === item.value;- // });- // }- // if (fontSizeItem) {- // fontSizeItem.children?.forEach((item) => {- // item.selected = fontSize === item.value;- // });- // }- // if (fontBoldItem) {- // fontBoldItem.active = !!fontWeight;- // }- // if (fontItalicItem) {- // fontItalicItem.active = !!fontItalic;- // }- // if (underlineItem) {- // underlineItem.active = !!(underline && underline.s);- // }- // if (horizontalAlignModeItem) {- // horizontalAlignModeItem.children?.forEach((item) => {- // item.selected = horizontalAlign === item.value;- // });- // }- // if (textRotateModeItem) {- // textRotateModeItem.children?.forEach((item) => {- // item.selected = rotation === item.value;- // });- // }- // if (verticalAlignModeItem) {- // verticalAlignModeItem.children?.forEach((item) => {- // item.selected = verticalAlign === item.value;- // });- // }- }- }-constructor(plugin: SheetPlugin) {this._plugin = plugin;@@ -195,40 +130,6 @@ export class ToolbarController {// this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.add((value: string) => {// this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('bg', value);// });- // // Monitor selection changes, update toolbar button status and values TODO: 根据不同的焦点对象,接受- // this._plugin.getObserver('onChangeSelectionObserver')?.add((selectionControl: SelectionControl) => {- // // const currentCell = selectionControl.model.currentCell;- // //- // // if (currentCell) {- // // let currentRangeData;- // //- // // if (currentCell.isMerged) {- // // const mergeInfo = currentCell.mergeInfo;- // //- // // currentRangeData = {- // // startRow: mergeInfo.startRow,- // // endRow: mergeInfo.endRow,- // // startColumn: mergeInfo.startColumn,- // // endColumn: mergeInfo.endColumn,- // // };- // // } else {- // // const { row, column } = currentCell;- // // currentRangeData = {- // // startRow: row,- // // endRow: row,- // // startColumn: column,- // // endColumn: column,- // // };- // // }- // //- // // const cellData = this._plugin.getWorkbook().getActiveSheet().getRange(currentRangeData).getObjectValue({ isIncludeStyle: true });- // // }- // const manager = this._plugin.getSelectionManager();- // const range = manager?.getCurrentCell();- // if (range) {- // this._changeToolbarState(range);- // }- // });}setRedo() {diff --git a/packages/base-ui/src/Components/Button/Button.tsx b/packages/base-ui/src/Components/Button/Button.tsxindex 5727d8e2c0..bacaab3765 100644--- a/packages/base-ui/src/Components/Button/Button.tsx+++ b/packages/base-ui/src/Components/Button/Button.tsx@@ -1,4 +1,5 @@-import { BaseButtonProps, ButtonComponent, JSXComponent } from '../../BaseComponent';+import { BaseButtonProps } from '../../BaseComponent';+import { Component } from '../../Framework';import { joinClassNames } from '../../Utils';import { LoadingIcon } from '../Icon';import styles from './Style/index.module.less';@@ -28,62 +29,86 @@ import styles from './Style/index.module.less';// isActive?: true;// }-const Button = (props: BaseButtonProps) => {- const { type, shape, size, htmlType = 'button', danger = false, disabled, block = false, loading = false, active = false, onClick, children, className = '', style } = props;+interface IState {+ isActive: boolean;+}++class Button extends Component<BaseButtonProps, IState> {+ constructor(props: BaseButtonProps) {+ super();+ this.state = {+ isActive: props.active ?? false,+ };+ }++ getSizeCls() {+ const { size } = this.props;+ let sizeCls = '';+ switch (size) {+ case 'large':+ sizeCls = 'lg';+ break;+ case 'small':+ sizeCls = 'sm';+ break;+ default:+ break;+ }+ return sizeCls;+ }++ getClass() {+ const { isActive } = this.state;+ const { type, shape, danger, block, loading, size, className } = this.props;+ return joinClassNames(+ styles.btn,+ {+ [`${styles.btn}-${type}`]: type,+ [`${styles.btn}-${shape}`]: shape,+ [`${styles.btn}-${this.getSizeCls()}`]: size,+ [`${styles.btn}-danger`]: !!danger,+ [`${styles.btn}-block`]: block,+ [`${styles.btn}-loading`]: loading,+ [`${styles.btn}-active`]: isActive,+ },+ className+ );+ }++ handleClick = (e: MouseEvent) => {+ const { disabled, onClick } = this.props;- const handleClick = (e: MouseEvent) => {if (disabled) {e.preventDefault();return;}- if (onClick) {- onClick(e);- }- };- let sizeCls = '';- switch (size) {- case 'large':- sizeCls = 'lg';- break;- case 'small':- sizeCls = 'sm';- break;- default:- break;- }- const classes = joinClassNames(- styles.btn,- {- [`${styles.btn}-${type}`]: type,- [`${styles.btn}-${shape}`]: shape,- [`${styles.btn}-${sizeCls}`]: size,- [`${styles.btn}-danger`]: !!danger,- [`${styles.btn}-block`]: block,- [`${styles.btn}-loading`]: loading,- },- className- );+ this.setState(+ {+ isActive: !this.state.isActive,+ },+ () => {+ if (onClick) {+ onClick.call(null, this.state.isActive);+ }+ }+ );+ };- let customStyle = style;- // set active status- if (active) {- customStyle = Object.assign((style as object) || {}, { background: '#eee' });+ componentWillReceiveProps(props: BaseButtonProps) {+ this.setState({+ isActive: props.active,+ });}- const buttonNode = (- <button type={htmlType} onClick={handleClick} className={classes} disabled={disabled} style={{ ...customStyle }}>- {loading ? <LoadingIcon /> : ''}- {children}- </button>- );-- return buttonNode;-};--export class UniverButton implements ButtonComponent {- render(): JSXComponent<BaseButtonProps> {- return Button;+ render() {+ const { htmlType, disabled, style, loading, children } = this.props;+ return (+ <button type={htmlType} onClick={this.handleClick} className={this.getClass()} disabled={disabled} style={style}>+ {loading ? <LoadingIcon /> : ''}+ {children}+ </button>+ );}}diff --git a/packages/base-ui/src/Components/Button/Style/index.module.css b/packages/base-ui/src/Components/Button/Style/index.module.cssnew file mode 100644index 0000000000..2185fa3cda--- /dev/null+++ b/packages/base-ui/src/Components/Button/Style/index.module.css@@ -0,0 +1,196 @@+/*+1. 所有的变量加到这里,复用+2. 组件要用的话,在这定义好,导入组件使用+3. 需要作为皮肤变量的,导入到所有皮肤中导出使用+*/+.btn {+ line-height: 1.5715;+ position: relative;+ display: inline-block;+ font-weight: 400;+ white-space: nowrap;+ text-align: center;+ background-image: none;+ padding: 0 10px;+ border: 1px solid transparent;+ cursor: pointer;+ user-select: none;+ height: 30px;+ border-radius: 1px;+ font-size: 14px;+ color: var(--text-color);+ background: var(--bg);+ border-color: var(--border-color-base);+}+.btn,+.btn:active {+ outline: 0;+}+.btn[disabled] {+ cursor: not-allowed;+}+.btn[disabled] > * {+ pointer-events: none;+}+.btn-lg {+ height: 40px;+ border-radius: 2px;+ font-size: 16px;+}+.btn-sm {+ height: 24px;+ border-radius: 2px;+ font-size: 12px;+}+.btn:hover,+.btn:active {+ color: #0188fb;+ background: var(--bg);+ border-color: #0188fb;+}+.btn[disabled],+.btn[disabled]:hover,+.btn[disabled]:active {+ color: var(--disabled-color);+ background: var(--disabled-bg);+ border-color: var(--border-color-base);+ text-shadow: none;+ box-shadow: none;+}+.btn > span {+ display: inline-block;+}+.btn-primary {+ color: var(--bg);+ background: #0188fb;+ border-color: #0188fb;+}+.btn-primary:hover {+ color: var(--bg);+ background: rgba(1, 136, 251, 0.7);+ border-color: rgba(1, 136, 251, 0.7);+}+.btn-primary:active {+ color: var(--bg);+ background: rgba(1, 136, 251, 0.5);+ border-color: rgba(1, 136, 251, 0.5);+}+.btn-primary[disabled],+.btn-primary[disabled]:hover,+.btn-primary[disabled]:active {+ color: var(--disabled-color);+ background: var(--disabled-bg);+ border-color: var(--border-color-base);+ text-shadow: none;+ box-shadow: none;+}+.btn-danger {+ color: var(--bg);+ background: #f5222d;+ border-color: #f5222d;+}+.btn-danger:hover {+ color: var(--bg);+ background: rgba(245, 34, 45, 0.7);+ border-color: rgba(245, 34, 45, 0.7);+}+.btn-danger:active {+ color: var(--bg);+ background: rgba(245, 34, 45, 0.5);+ border-color: rgba(245, 34, 45, 0.5);+}+.btn-danger[disabled],+.btn-danger[disabled]:hover,+.btn-danger[disabled]:active {+ color: var(--disabled-color);+ background: var(--disabled-bg);+ border-color: var(--border-color-base);+ text-shadow: none;+ box-shadow: none;+}+.btn-text {+ color: var(--text-color);+ background: transparent;+ border-color: transparent;+ box-shadow: none;+}+.btn-text:hover {+ color: var(--text-color);+ background: #eee;+ border-color: transparent;+}+.btn-text:active {+ color: var(--text-color);+ background: #eee;+ border-color: transparent;+}+.btn-text[disabled],+.btn-text[disabled]:hover,+.btn-text[disabled]:active {+ color: var(--disabled-color);+ background: transparent;+ border-color: transparent;+ text-shadow: none;+ box-shadow: none;+}+.btn-active {+ color: var(--text-color);+ background: var(--bg-hover);+ border-color: var(--border-color-base);+ text-shadow: none;+ box-shadow: none;+}+.btn-round {+ height: 30px;+ border-radius: 30px;+ font-size: 14px;+}+.btn-round.btn-lg {+ height: 40px;+ border-radius: 40px;+ font-size: 16px;+}+.btn-round.btn-sm {+ height: 24px;+ border-radius: 24px;+ font-size: 12px;+}+.btn-circle {+ min-width: 30px;+ padding-right: 0;+ padding-left: 0;+ text-align: center;+ border-radius: 50%;+}+.btn-circle.btn-lg {+ min-width: 40px;+ border-radius: 50%;+}+.btn-circle.btn-sm {+ min-width: 24px;+ border-radius: 50%;+}+.btn-block {+ width: 100%;+}+.btn-loading {+ position: relative;+}+.btn::before {+ position: absolute;+ top: -1px;+ right: -1px;+ bottom: -1px;+ left: -1px;+ z-index: 1;+ display: none;+ background: var(--bg);+ border-radius: inherit;+ opacity: 0.35;+ transition: opacity 0.2s;+ content: '';+ pointer-events: none;+}+.btn:active > span {+ position: relative;+}diff --git a/packages/base-ui/src/Components/Button/Style/index.module.less b/packages/base-ui/src/Components/Button/Style/index.module.lessindex d533f18145..dc53895f8a 100644--- a/packages/base-ui/src/Components/Button/Style/index.module.less+++ b/packages/base-ui/src/Components/Button/Style/index.module.less@@ -21,6 +21,14 @@.btn-text();}+ &-active {+ color: var(--text-color);+ background: var(--bg-hover);+ border-color: var(--border-color-base);+ text-shadow: none;+ box-shadow: none;+ }+&-round {.btn-round();}@@ -53,7 +61,6 @@pointer-events: none;}- &:focus>span,&:active>span {position: relative;}diff --git a/packages/base-ui/src/Components/Button/Style/mixin.css b/packages/base-ui/src/Components/Button/Style/mixin.cssnew file mode 100644index 0000000000..4ed4a7474e--- /dev/null+++ b/packages/base-ui/src/Components/Button/Style/mixin.css@@ -0,0 +1,5 @@+/*+1. 所有的变量加到这里,复用+2. 组件要用的话,在这定义好,导入组件使用+3. 需要作为皮肤变量的,导入到所有皮肤中导出使用+*/diff --git a/packages/base-ui/src/Components/Button/Style/mixin.less b/packages/base-ui/src/Components/Button/Style/mixin.lessindex 5812ca7721..883aefbe45 100644--- a/packages/base-ui/src/Components/Button/Style/mixin.less+++ b/packages/base-ui/src/Components/Button/Style/mixin.less@@ -20,8 +20,7 @@&,&:hover,- &:active,- &:focus {+ &:active {.button-color(@color; @background; @border);text-shadow: none;box-shadow: none;@@ -32,8 +31,7 @@.btn-primary(@color: var(--bg); @background: @primary-color) {.button-color(@color; @background; @background);- &:hover,- &:focus {+ &:hover {.button-color(@color, fade(@background, 70%), fade(@background, 70%))}@@ -48,7 +46,6 @@.button-color(@color; @background; @board);&:hover,- &:focus,&:active {.button-color(@primary-color, @background, @primary-color);}@@ -60,8 +57,7 @@.button-color(var(--text-color), transparent, transparent);box-shadow: none;- &:hover,- &:focus {+ &:hover {color: var(--text-color);background: #eee;border-color: transparent;@@ -90,8 +86,7 @@.button-size(30px; 15px; @font-size-base; @border-width-base);&,- &:active,- &:focus {+ &:active {outline: 0;}@@ -119,8 +114,7 @@.btn-danger-default() {.button-color(@error-color, @bg, @error-color);- &:hover,- &:focus {+ &:hover {.button-color(fade(@error-color, 70%); @bg; fade(@error-color, 70%))}diff --git a/packages/base-ui/src/Components/Container/Container.tsx b/packages/base-ui/src/Components/Container/Container.tsxindex 3d7873eae1..9448c9d0d3 100644--- a/packages/base-ui/src/Components/Container/Container.tsx+++ b/packages/base-ui/src/Components/Container/Container.tsx@@ -5,13 +5,14 @@ type IProps = {style?: {};className?: string;onClick?: (e: MouseEvent) => void;+ onContextMenu?: (e: MouseEvent) => void;};export const Container = forwardRef((props: IProps, ref: Ref<HTMLDivElement>) => {- const { children, style, className, onClick } = props;+ const { children, style, className, onClick, onContextMenu } = props;return (- <div ref={ref} style={style} className={className} onClick={onClick}>+ <div onContextMenu={onContextMenu} ref={ref} style={style} className={className} onClick={onClick}>{children}</div>);diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsxindex 72741810dd..369ad926ec 100644--- a/packages/base-ui/src/Components/Menu/Menu.tsx+++ b/packages/base-ui/src/Components/Menu/Menu.tsx@@ -1,6 +1,5 @@import { Component, createRef } from '../../Framework';-import { JSXComponent } from '../../BaseComponent';-import { BaseMenuProps, BaseMenuState, BaseMenuItem, BaseMenuStyle, MenuComponent } from '../../Interfaces';+import { BaseMenuProps, BaseMenuState, BaseMenuItem, BaseMenuStyle } from '../../Interfaces';import { joinClassNames } from '../../Utils';import styles from './index.module.less';@@ -144,9 +143,3 @@ export class Menu extends Component<BaseMenuProps, BaseMenuState> {);}}--export class UniverMenu implements MenuComponent {- render(): JSXComponent<BaseMenuProps> {- return Menu;- }-}diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsxindex 3ae3ce1e05..d4984e231a 100644--- a/packages/base-ui/src/Components/Select/Select.tsx+++ b/packages/base-ui/src/Components/Select/Select.tsx@@ -1,7 +1,6 @@import { Icon } from '..';import { ComponentChildren, Component } from '../../Framework';import { BaseMenuItem } from '../../Interfaces';-import { Button } from '../Button';import { Dropdown } from '../Dropdown';import { Input } from '../Input';import { BaseItemProps, Item } from '../Item/Item';@@ -275,11 +274,9 @@ export class Select extends Component<BaseSelectProps, IState> {return (<div className={`${styles.selectSingle} ${className}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <div>{content}</div>- </Dropdown>- </Button>+ <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>+ <div>{content}</div>+ </Dropdown></div>);};@@ -291,11 +288,9 @@ export class Select extends Component<BaseSelectProps, IState> {return (<div className={`${styles.selectInput} ${className}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <Input onKeyUp={this.onKeyUp} type="number" value={content as string} />- </Dropdown>- </Button>+ <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>+ <Input onKeyUp={this.onKeyUp} type="number" value={content as string} />+ </Dropdown></div>);};@@ -306,11 +301,9 @@ export class Select extends Component<BaseSelectProps, IState> {return (<div className={`${styles.selectDouble} ${className}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} icon={<Icon.NextIcon />}>- <div className={styles.selectLabel}>{content}</div>- </Dropdown>- </Button>+ <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} icon={<Icon.NextIcon />}>+ <div className={styles.selectLabel}>{content}</div>+ </Dropdown></div>);};@@ -321,11 +314,9 @@ export class Select extends Component<BaseSelectProps, IState> {return (<div className={`${styles.selectDouble} ${className}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <div className={styles.selectLabel}>{label}</div>- </Dropdown>- </Button>+ <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>+ <div className={styles.selectLabel}>{label}</div>+ </Dropdown></div>);};@@ -336,11 +327,9 @@ export class Select extends Component<BaseSelectProps, IState> {return (<div className={`${styles.selectDouble} ${className}`}>- <Button type="text">- <Dropdown tooltip={tooltip} onClick={this.onClick} menu={{ menu, onClick: this.onClick }} icon={<Icon.NextIcon />}>- <div className={styles.selectLabel}>{label}</div>- </Dropdown>- </Button>+ <Dropdown tooltip={tooltip} onClick={this.onClick} menu={{ menu, onClick: this.onClick }} icon={<Icon.NextIcon />}>+ <div className={styles.selectLabel}>{label}</div>+ </Dropdown></div>);};diff --git a/packages/base-ui/src/Components/Select/index.module.css b/packages/base-ui/src/Components/Select/index.module.cssindex 7892d7c6fa..a19d45450a 100644--- a/packages/base-ui/src/Components/Select/index.module.css+++ b/packages/base-ui/src/Components/Select/index.module.css@@ -16,6 +16,16 @@text-overflow: ellipsis;white-space: nowrap;}+.select-component .select-single:hover {+ background: var(--bg-hover);+}+.select-component .select-input {+ display: flex;+ align-items: center;+}+.select-component .select-input:hover {+ background: var(--bg-hover);+}.select-component .select-input input {width: 38px;height: 20px;@@ -36,15 +46,8 @@background: #fff;border: 1px solid var(--primary-color-hover);}-.select-component .select-color .cols-menu {- padding: 0;- border: none;-}-.select-component .select-color .cols-menu .cols-menuitem {- padding: 0;-}-.select-component .select-color .cols-menu .select-item {- padding: 0;+.select-component .select-double:hover {+ background: var(--bg-hover);}.select-component .select-double .dropdown {height: 24px;diff --git a/packages/base-ui/src/Components/Select/index.module.less b/packages/base-ui/src/Components/Select/index.module.lessindex ae29cab082..fc336d594d 100644--- a/packages/base-ui/src/Components/Select/index.module.less+++ b/packages/base-ui/src/Components/Select/index.module.less@@ -18,9 +18,20 @@.select-single {text-overflow: ellipsis;white-space: nowrap;++ &:hover {+ background: var(--bg-hover);+ }}.select-input {+ display: flex;+ align-items: center;++ &:hover {+ background: var(--bg-hover);+ }+input {width: 38px;height: 20px;@@ -47,22 +58,11 @@}}- .select-color {- .cols-menu {- padding: 0;- border: none;-- .cols-menuitem {- padding: 0;- }-- .select-item {- padding: 0;- }+ .select-double {+ &:hover {+ background: var(--bg-hover);}- }- .select-double {.dropdown {height: 24px;padding-right: 0;diff --git a/packages/base-ui/src/Components/TextButton/TextButton.tsx b/packages/base-ui/src/Components/TextButton/TextButton.tsxdeleted file mode 100644index 642b57b8ce..0000000000--- a/packages/base-ui/src/Components/TextButton/TextButton.tsx+++ /dev/null@@ -1,54 +0,0 @@-import { ComponentChildren, Component } from '../../Framework';-import { BaseComponentRender } from '../../BaseComponent';-import styles from './index.module.less';-import { Button } from '../Button';--export interface BaseTextButtonProps {- active?: boolean;- label?: ComponentChildren;- onClick?: (...arg: any) => void;-}--interface IState {- active?: boolean;-}--export class TextButton extends Component<BaseTextButtonProps, IState> {- private _render: BaseComponentRender;-- initialize() {- this.state = {- active: this.props.active,- };- }-- handleClick = () => {- const active = !this.state.active;- this.props.onClick?.(active);-- this.setState({- active,- });- };-- componentWillReceiveProps(nextProps: Readonly<BaseTextButtonProps>, nextContext: any) {- if (nextProps.active !== this.props.active) {- this.setState({- active: nextProps.active,- });- }- }-- render() {- const { label } = this.props;- const { active } = this.state;-- return (- <div className={styles.textButton}>- <Button type="text" active={active} onClick={this.handleClick}>- {label}- </Button>- </div>- );- }-}diff --git a/packages/base-ui/src/Components/TextButton/index.module.css b/packages/base-ui/src/Components/TextButton/index.module.cssdeleted file mode 100644index 4fb4faa3e5..0000000000--- a/packages/base-ui/src/Components/TextButton/index.module.css+++ /dev/null@@ -1,6 +0,0 @@-.text-button span[role="img"] {- font-size: 24px;-}-.text-button button {- padding: 0 5px;-}diff --git a/packages/base-ui/src/Components/TextButton/index.module.less b/packages/base-ui/src/Components/TextButton/index.module.lessdeleted file mode 100644index 305b85ad5c..0000000000--- a/packages/base-ui/src/Components/TextButton/index.module.less+++ /dev/null@@ -1,9 +0,0 @@-.text-button {- span[role="img"] {- font-size: 24px;- }-- button {- padding: 0 5px;- }-}\ No newline at end of filediff --git a/packages/base-ui/src/Components/TextButton/index.ts b/packages/base-ui/src/Components/TextButton/index.tsdeleted file mode 100644index 2bf7c86106..0000000000--- a/packages/base-ui/src/Components/TextButton/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './TextButton';diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.tsindex eff122c95c..7540cf3a4f 100644--- a/packages/base-ui/src/Components/index.ts+++ b/packages/base-ui/src/Components/index.ts@@ -26,10 +26,8 @@ import { Slider } from './Slider';import { Tab, TabPane } from './Tabs';import { Tooltip } from './Tooltip';import { Ul } from './Ul';-import { TextButton } from './TextButton/TextButton';export * from './Select';-export * from './TextButton';export {Avatar,@@ -64,5 +62,4 @@ export {SiderModal,ResizeDialog,Dropdown,- TextButton,};diff --git a/packages/base-ui/src/Utils/util.ts b/packages/base-ui/src/Utils/util.tsindex 4d4d035da6..dcb6d5889e 100644--- a/packages/base-ui/src/Utils/util.ts+++ b/packages/base-ui/src/Utils/util.ts@@ -1,4 +1,3 @@-import { Locale } from '../Basics/Shared/Locale';import { Component, RefObject } from '../Framework';/**@@ -13,11 +12,11 @@ export function isElement(element: any) {export const isDOM =typeof HTMLElement === 'object'? function (obj: any) {- return obj instanceof HTMLElement;- }+ return obj instanceof HTMLElement;+ }: function (obj: any) {- return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';- };+ return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string';+ };/*** DOM selector@@ -242,57 +241,67 @@ export function setLastCaretPosition(dom: HTMLElement) {/*** 翻译数据中的国际化*/-function resetLabel(label: string[] | string, locale: Locale) {- let str = '';-- if (label instanceof Array) {- label.forEach((item) => {- if (item.includes('.')) {- str += locale.get(item);- } else {- str += item;- }- });- } else {- if (label.includes('.')) {- str = locale.get(label);- } else {- str += label;- }- }-- return str;-}--function findLocale(obj: any, locale: Locale) {+// function resetLabel(label: string[] | string, locale: Locale) {+// let str = '';++// if (label instanceof Array) {+// label.forEach((item) => {+// if (item.includes('.')) {+// str += locale.get(item);+// } else {+// str += item;+// }+// });+// } else {+// if (label.includes('.')) {+// str = locale.get(label);+// } else {+// str += label;+// }+// }++// return str;+// }++export function findLocale<T>(obj: T, fn: Function) {for (let k in obj) {- if (k === 'locale') {- obj.label = resetLabel(obj[k], locale);- } else if (k.endsWith('Locale')) {+ if (k.endsWith('Locale') && typeof obj[k] === 'string') {const index = k.indexOf('Locale');- obj[k.slice(0, index)] = resetLabel(obj[k], locale);- } else if (obj[k] && !obj[k].$$typeof) {- if (Object.prototype.toString.call(obj[k]) === '[object Object]') {- findLocale(obj[k], locale);- } else if (Object.prototype.toString.call(obj[k]) === '[object Array]') {- resetDataLabel(obj[k], locale);- }+ obj[k.slice(0, index)] = fn(obj[k]);}}-return obj;}-export function resetDataLabel(data: any[], locale: Locale) {- for (let i = 0; i < data.length; i++) {- let item = data[i];-- item = findLocale(item, locale);-- if (item.children) {- item.children = resetDataLabel(item.children, locale);- }- }-- return data;-}+// function findLocale(obj: any, locale: Locale) {+// for (let k in obj) {+// if (k === 'locale') {+// obj.label = resetLabel(obj[k], locale);+// } else if (k.endsWith('Locale')) {+// const index = k.indexOf('Locale');+// obj[k.slice(0, index)] = resetLabel(obj[k], locale);+// } else if (obj[k] && !obj[k].$$typeof) {+// if (Object.prototype.toString.call(obj[k]) === '[object Object]') {+// findLocale(obj[k], locale);+// } else if (Object.prototype.toString.call(obj[k]) === '[object Array]') {+// resetDataLabel(obj[k], locale);+// }+// }+// }++// return obj;+// }++// export function resetDataLabel(data: any[], locale: Locale) {+// for (let i = 0; i < data.length; i++) {+// let item = data[i];++// item = findLocale(item, locale);++// if (item.children) {+// item.children = resetDataLabel(item.children, locale);+// }+// }++// return data;+// }diff --git a/packages/sheets-plugin-formula/src/Controller/FormulaController.tsx b/packages/sheets-plugin-formula/src/Controller/FormulaController.tsxindex d5a2e33888..94e168ff1c 100644--- a/packages/sheets-plugin-formula/src/Controller/FormulaController.tsx+++ b/packages/sheets-plugin-formula/src/Controller/FormulaController.tsx@@ -111,7 +111,9 @@ export class FormulaController {.getAppUIController().getSheetContainerController().getMainSlotController()- .addSlot(FORMULA_PLUGIN_NAME + FormulaLabel.name, FormulaLabel);+ .addSlot(FORMULA_PLUGIN_NAME + FormulaLabel.name, {+ component: FormulaLabel,+ });}getDataModel() {diff --git a/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.ts b/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.tsindex 472e30b295..0e30e10fa7 100644--- a/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.ts+++ b/packages/sheets-plugin-formula/src/Controller/FormulaPromptController.ts@@ -40,26 +40,27 @@ export class FormulaPromptController {.getAppUIController().getSheetContainerController().getMainSlotController()- .addSlot(FORMULA_PLUGIN_NAME + SearchFunction.name, SearchFunction, () => {- const searchFunction = this._sheetUIPlugin- .getAppUIController()- .getSheetContainerController()- .getMainSlotController()- .getSlot(FORMULA_PLUGIN_NAME + SearchFunction.name);- this._searchFunction = searchFunction;- });+ .addSlot(+ FORMULA_PLUGIN_NAME + SearchFunction.name,+ {+ component: SearchFunction,+ },+ () => {+ const searchFunction = this._sheetUIPlugin+ .getAppUIController()+ .getSheetContainerController()+ .getMainSlotController()+ .getSlot(FORMULA_PLUGIN_NAME + SearchFunction.name);+ console.info('searchFunction====', searchFunction);+ }+ );this._sheetUIPlugin.getAppUIController().getSheetContainerController().getMainSlotController()- .addSlot(FORMULA_PLUGIN_NAME + HelpFunction.name, HelpFunction, () => {- const helpFunction = this._sheetUIPlugin- .getAppUIController()- .getSheetContainerController()- .getMainSlotController()- .getSlot(FORMULA_PLUGIN_NAME + HelpFunction.name);- this._helpFunction = helpFunction;+ .addSlot(FORMULA_PLUGIN_NAME + HelpFunction.name, {+ component: HelpFunction,});}diff --git a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.tsindex b45ad491d9..4d0c78f791 100644--- a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts@@ -1,6 +1,6 @@import { IMouseEvent, IPointerEvent } from '@univerjs/base-render';import { SheetPlugin } from '@univerjs/base-sheets';-import { BaseMenuItem, BaseSelectChildrenProps, resetDataLabel } from '@univerjs/base-ui';+import { BaseMenuItem, BaseSelectChildrenProps } from '@univerjs/base-ui';import { PLUGIN_NAMES, Tools, UIObserver } from '@univerjs/core';import { SheetUIPlugin } from '..';import { DefaultRightMenuConfig, SheetRightMenuConfig } from '../Basics';@@ -300,6 +300,7 @@ export class RightMenuUIController {this._sheetPlugin.getMainComponent().onPointerDownObserver.add((evt: IPointerEvent | IMouseEvent) => {if (evt.button === 2) {+ evt.preventDefault()this._rightMenu.handleContextMenu(evt);}});@@ -313,9 +314,7 @@ export class RightMenuUIController {// 刷新setMenuList() {- const locale = this._plugin.getContext().getLocale();- const menuList = resetDataLabel(this._menuList, locale);- this._rightMenu?.setMenuList(menuList);+ this._rightMenu?.setMenuList(this._menuList);}setUIObserve<T>(msg: UIObserver<T>) {diff --git a/packages/ui-plugin-sheets/src/Controller/SlotController.ts b/packages/ui-plugin-sheets/src/Controller/SlotController.tsindex 2f16b09681..083c3a20fe 100644--- a/packages/ui-plugin-sheets/src/Controller/SlotController.ts+++ b/packages/ui-plugin-sheets/src/Controller/SlotController.ts@@ -1,6 +1,12 @@+import { IKeyValue } from "@univerjs/core";import { Slot } from "../View";-export type SlotGroupProps = Map<string, any>;+export type SlotComponentProps = {+ component: Function,+ props?: IKeyValue+}++export type SlotGroupProps = Map<string, SlotComponentProps>export class SlotController {private _slotGroup: SlotGroupProps = new Map();@@ -11,9 +17,12 @@ export class SlotController {this._slot = ref}- addSlot(name: string, component: any, cb?: () => void) {+ addSlot<O, T = null>(name: string, slot: SlotComponentProps, cb?: () => void) {if (this._slotGroup.get(name)) return- this._slotGroup.set(name, component)+ this._slotGroup.set(name, {+ component: slot.component,+ props: slot.props ?? {}+ })this.setSlot(cb)}diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsindex 5c38beec74..81346be1c5 100644--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts@@ -1,6 +1,6 @@-import { BorderInfo } from '@univerjs/base-sheets';-import { BaseSelectChildrenProps, BaseSelectProps, BaseTextButtonProps, ColorPicker } from '@univerjs/base-ui';-import { BorderType, DEFAULT_STYLES, HorizontalAlign, IKeyValue, Tools, UIObserver, VerticalAlign, WrapStrategy } from '@univerjs/core';+import { BorderInfo, SelectionControl, SheetPlugin } from '@univerjs/base-sheets';+import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';+import { BorderType, DEFAULT_STYLES, FontItalic, FontStyleType, FontWeight, HorizontalAlign, IKeyValue, PLUGIN_NAMES, Range, Tools, UIObserver, VerticalAlign, WrapStrategy } from '@univerjs/core';import { SheetUIPlugin } from '..';import { DefaultToolbarConfig, SheetToolbarConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';@@ -23,17 +23,21 @@ enum ToolbarType {BUTTON,}-export interface IToolbarItemProps extends BaseToolbarSelectProps, BaseTextButtonProps {+export interface IToolbarItemProps extends BaseToolbarSelectProps {+ active?: boolean;show?: boolean; //是否显示按钮toolbarType?: ToolbarType;tooltip?: string; //tooltip文字border?: boolean;+ suffix?: ComponentChildren;}export class ToolbarUIController {private _plugin: SheetUIPlugin;+ private _sheetPlugin: SheetPlugin;+private _toolbar: Toolbar;private _toolList: IToolbarItemProps[];@@ -57,6 +61,8 @@ export class ToolbarUIController {constructor(plugin: SheetUIPlugin, config?: SheetToolbarConfig) {this._plugin = plugin;+ this._sheetPlugin = plugin.getContext().getUniver().getCurrentUniverSheetInstance().context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;+this._config = Tools.deepMerge({}, DefaultToolbarConfig, config);this._toolList = [@@ -164,6 +170,7 @@ export class ToolbarUIController {getComponent: (ref: ColorSelect) => {this._colorSelect1 = ref},+ color: '#000',customLabel: {name: 'TextColorIcon',},@@ -176,7 +183,6 @@ export class ToolbarUIController {customLabel: {name: SHEET_UI_PLUGIN_NAME + ColorPicker.name,props: {-onClick: (color: string, e: MouseEvent) => {this._colorSelect1.setColor(color);this.setFontColor(color)@@ -198,6 +204,7 @@ export class ToolbarUIController {getComponent: (ref: ColorSelect) => {this._colorSelect2 = ref},+ color: '#fff',customLabel: {name: 'FillColorIcon',},@@ -353,6 +360,105 @@ export class ToolbarUIController {this._plugin.getComponentManager().register(SHEET_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker)this._plugin.getComponentManager().register(SHEET_UI_PLUGIN_NAME + LineColor.name, LineColor)this._plugin.getComponentManager().register(SHEET_UI_PLUGIN_NAME + LineBold.name, LineBold)++ this._sheetPlugin.getObserver('onChangeSelectionObserver')?.add((selectionControl: SelectionControl) => {+ const manager = this._sheetPlugin.getSelectionManager();+ const range = manager?.getCurrentCell();+ if (range) {+ this._changeToolbarState(range);+ }+ });+ }++ private _changeToolbarState(range: Range): void {+ const workbook = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook();+ const worksheet = workbook.getActiveSheet();+ if (worksheet) {+ const isBold = range.getFontWeight();+ const IsItalic = range.getFontStyle()+ const strikeThrough = range.getStrikeThrough();+ const fontSize = range.getFontSize();+ const fontWeight = range.getFontWeight();+ const fontName = range.getFontFamily();+ const fontItalic = range.getFontStyle();+ const fontColor = range.getFontColor();+ const background = range.getBackground();+ const underline = range.getUnderline();+ const horizontalAlign = range.getHorizontalAlignment();+ const verticalAlign = range.getVerticalAlignment();+ const rotation = range.getTextRotation();++ const bold = this._toolList.find((item) => item.name === 'bold')+ const italic = this._toolList.find((item) => item.name === 'italic')+ const textRotateModeItem = this._toolList.find((item) => item.name === 'textRotateMode');+ const fontSizeItem = this._toolList.find((item) => item.name === 'fontSize');+ const fontNameItem = this._toolList.find((item) => item.name === 'font');+ const fontBoldItem = this._toolList.find((item) => item.name === 'bold');+ const fontItalicItem = this._toolList.find((item) => item.name === 'italic');+ const textColor = this._toolList.find((item) => item.name === 'textColor')+ const fillColor = this._toolList.find((item) => item.name === 'fillColor')+ const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');+ const underlineItem = this._toolList.find((item) => item.name === 'underline');+ const horizontalAlignModeItem = this._toolList.find((item) => item.name === 'horizontalAlignMode');+ const verticalAlignModeItem = this._toolList.find((item) => item.name === 'verticalAlignMode');++ if (bold) {+ bold.active = isBold === FontWeight.BOLD+ }++ if (italic) {+ italic.active = IsItalic === FontItalic.ITALIC+ }++ if (strikethroughItem) {+ strikethroughItem.active = !!(strikeThrough && strikeThrough.s);+ }+ if (fontNameItem) {+ fontNameItem.children?.forEach((item) => {+ item.selected = fontName === item.value;+ });+ }+ if (fontSizeItem) {+ fontSizeItem.label = fontSize.toString()+ }+ if (fontBoldItem) {+ fontBoldItem.active = !!fontWeight;+ }+ if (fontItalicItem) {+ fontItalicItem.active = !!fontItalic;+ }+ if (textColor) {+ const label = textColor.customLabel+ if (label && label.props) {+ label.props.color = fontColor+ }+ }+ if (fillColor) {+ const label = fillColor.customLabel+ if (label && label.props) {+ label.props.color = background+ }+ }+ if (underlineItem) {+ underlineItem.active = !!(underline && underline.s);+ }+ if (horizontalAlignModeItem) {+ horizontalAlignModeItem.children?.forEach((item) => {+ item.selected = horizontalAlign === item.value;+ });+ }+ if (textRotateModeItem) {+ textRotateModeItem.children?.forEach((item) => {+ item.selected = rotation === item.value;+ });+ }+ if (verticalAlignModeItem) {+ verticalAlignModeItem.children?.forEach((item) => {+ item.selected = verticalAlign === item.value;+ });+ }+ this.setToolbar();+ }}// 获取Toolbar组件diff --git a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsxindex 8cd59ac68d..40a353d3c9 100644--- a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx@@ -11,6 +11,7 @@ interface IProps extends BaseComponentProps {};label?: ComponentChildren;id: string;+ color: string;}interface IState {@@ -28,11 +29,17 @@ export class ColorSelect extends Component<IProps, IState> {}this.setState({label,- color: '#000',+ color: this.props.color,});this.props.getComponent?.(this);}+ componentWillReceiveProps(props: IProps) {+ this.setState({+ color: props.color,+ });+ }+setColor(color: string) {this.setState({color,diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsxindex d972c32bd1..4b9a8e82b5 100644--- a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx@@ -220,18 +220,19 @@ export class SheetContainer extends Component<BaseSheetContainerProps> {{/* innerLeft */}</Sider><Content className={config.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>- {/* extend main content */}<Slot {...methods.slot}></Slot>{!!config.contentSplit && (<Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}><div className={style.hoverCursor} onMouseDown={this.handleSplitBarMouseDown}></div></Container>)}- <Container ref={this.contentRef} className={style.contentInnerRightContainer}>+ <Container onContextMenu={(e) => e.preventDefault()} ref={this.contentRef} className={style.contentInnerRightContainer}>{config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>}{<RichText {...methods.cellEditor}></RichText>}</Container>+ {/* extend main content */}</Content>+<Siderstyle={{display: config.innerRight ? 'block' : 'none',diff --git a/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx b/packages/ui-plugin-sheets/src/View/Slot/Slot.tsxindex ce96957842..f2fbbd5bba 100644--- a/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx+++ b/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx@@ -1,7 +1,8 @@import { BaseComponentProps, Component } from '@univerjs/base-ui';+import { SlotGroupProps } from '../../Controller/SlotController';interface IState {- slotGroup: Map<string, any>;+ slotGroup: SlotGroupProps;}interface IProps extends BaseComponentProps {@@ -11,8 +12,6 @@ interface IProps extends BaseComponentProps {export class Slot extends Component<IProps, IState> {refMap = new Map();- refs: any[] = [];-initialize() {this.state = {slotGroup: new Map(),@@ -23,7 +22,7 @@ export class Slot extends Component<IProps, IState> {this.props.getComponent?.(this);}- setSlotGroup(group: Map<string, any>, cb?: () => void) {+ setSlotGroup(group: SlotGroupProps, cb?: () => void) {this.setState({slotGroup: group,@@ -36,11 +35,20 @@ export class Slot extends Component<IProps, IState> {return this.refMap;}- getRender(slotGroup: Map<string, any>) {+ getRender(slotGroup: SlotGroupProps) {const group: JSX.Element[] = [];slotGroup.forEach((v, k) => {- const Slot = slotGroup.get(k);- Slot && group.push(<Slot ref={(ele: any) => this.refMap.set(k, ele)}></Slot>);+ const Slot = slotGroup.get(k)?.component;+ const props = slotGroup.get(k)?.props;+ if (!Slot) return;+ group.push(+ <Slot+ ref={(ele: Slot) => {+ this.refMap.set(k, ele);+ }}+ {...props}+ ></Slot>+ );});return group;}diff --git a/packages/ui-plugin-sheets/src/View/ToolBar/Const.ts b/packages/ui-plugin-sheets/src/View/ToolBar/Const.tsindex c3472d2a31..39a8bab1df 100644--- a/packages/ui-plugin-sheets/src/View/ToolBar/Const.ts+++ b/packages/ui-plugin-sheets/src/View/ToolBar/Const.ts@@ -66,83 +66,83 @@ export const FONT_SIZE_CHILDREN = [export const FONT_FAMILY_CHILDREN = [{- label: 'fontFamily.TimesNewRoman',+ labelLocale: 'fontFamily.TimesNewRoman',style: { 'font-family': 'Times New Roman' },value: 'Times New Roman',selected: true,},{- label: 'fontFamily.Arial',+ labelLocale: 'fontFamily.Arial',style: { 'font-family': 'Arial' },value: 'Arial',},{- label: 'fontFamily.Tahoma',+ labelLocale: 'fontFamily.Tahoma',style: { 'font-family': 'Tahoma' },value: 'Tahoma',},{- label: 'fontFamily.Verdana',+ labelLocale: 'fontFamily.Verdana',style: { 'font-family': 'Verdana' },value: 'Verdana',},{- label: 'fontFamily.MicrosoftAccorblack',+ labelLocale: 'fontFamily.MicrosoftAccorblack',style: { 'font-family': '微软雅黑' },value: '微软雅黑',},{- label: 'fontFamily.SimSun',+ labelLocale: 'fontFamily.SimSun',style: { 'font-family': '宋体' },value: '宋体',},{- label: 'fontFamily.SimHei',+ labelLocale: 'fontFamily.SimHei',style: { 'font-family': '黑体' },value: '黑体',},{- label: 'fontFamily.Kaiti',+ labelLocale: 'fontFamily.Kaiti',style: { 'font-family': '楷体' },value: '楷体',},{- label: 'fontFamily.FangSong',+ labelLocale: 'fontFamily.FangSong',style: { 'font-family': '仿宋' },value: '仿宋',},{- label: 'fontFamily.NSimSun',+ labelLocale: 'fontFamily.NSimSun',style: { 'font-family': '新宋体' },value: '新宋体',},{- label: 'fontFamily.STXinwei',+ labelLocale: 'fontFamily.STXinwei',style: { 'font-family': '华文新魏' },value: '华文新魏',},{- label: 'fontFamily.STXingkai',+ labelLocale: 'fontFamily.STXingkai',style: { 'font-family': '华文行楷' },value: '华文行楷',},{- label: 'fontFamily.STLiti',+ labelLocale: 'fontFamily.STLiti',style: { 'font-family': '华文隶书' },value: '华文隶书',},{- label: 'fontFamily.HanaleiFill',+ labelLocale: 'fontFamily.HanaleiFill',style: { 'font-family': 'HanaleiFill' },value: 'HanaleiFill',},{- label: 'fontFamily.Anton',+ labelLocale: 'fontFamily.Anton',style: { 'font-family': 'Anton' },value: 'Anton',},{- label: 'fontFamily.Pacifico',+ labelLocale: 'fontFamily.Pacifico',style: { 'font-family': 'Pacifico' },value: 'Pacifico',},@@ -150,28 +150,28 @@ export const FONT_FAMILY_CHILDREN = [export const BORDER_LINE_CHILDREN = [{- label: 'borderLine.borderTop',+ labelLocale: 'borderLine.borderTop',customSuffix: {name: 'TopBorderIcon',},value: 'top',},{- label: 'borderLine.borderBottom',+ labelLocale: 'borderLine.borderBottom',customSuffix: {name: 'BottomBorderIcon',},value: 'bottom',},{- label: 'borderLine.borderLeft',+ labelLocale: 'borderLine.borderLeft',customSuffix: {name: 'LeftBorderIcon',},value: 'left',},{- label: 'borderLine.borderRight',+ labelLocale: 'borderLine.borderRight',customSuffix: {name: 'RightBorderIcon',},@@ -179,14 +179,14 @@ export const BORDER_LINE_CHILDREN = [border: true,},{- label: 'borderLine.borderNone',+ labelLocale: 'borderLine.borderNone',customSuffix: {name: 'NoneBorderIcon',},value: 'none',},{- label: 'borderLine.borderAll',+ labelLocale: 'borderLine.borderAll',customSuffix: {name: 'FullBorderIcon',},@@ -194,28 +194,28 @@ export const BORDER_LINE_CHILDREN = [selected: true,},{- label: 'borderLine.borderOutside',+ labelLocale: 'borderLine.borderOutside',customSuffix: {name: 'OuterBorderIcon',},value: 'outside',},{- label: 'borderLine.borderInside',+ labelLocale: 'borderLine.borderInside',customSuffix: {name: 'InnerBorderIcon',},value: 'inside',},{- label: 'borderLine.borderHorizontal',+ labelLocale: 'borderLine.borderHorizontal',customSuffix: {name: 'StripingBorderIcon',},value: 'horizontal',},{- label: 'borderLine.borderVertical',+ labelLocale: 'borderLine.borderVertical',customSuffix: {name: 'VerticalBorderIcon',},@@ -225,7 +225,7 @@ export const BORDER_LINE_CHILDREN = [export const BORDER_SIZE_CHILDREN = [{- label: 'borderLine.borderNone',+ labelLocale: 'borderLine.borderNone',value: BorderStyleTypes.NONE,},{@@ -298,33 +298,33 @@ export const BORDER_SIZE_CHILDREN = [export const MERGE_CHILDREN = [{- label: 'merge.all',+ labelLocale: 'merge.all',value: 'all',},{- label: 'merge.vertical',+ labelLocale: 'merge.vertical',value: 'vertical',},{- label: 'merge.horizontal',+ labelLocale: 'merge.horizontal',value: 'horizontal',},{- label: 'merge.cancel',+ labelLocale: 'merge.cancel',value: 'cancel',},];export const HORIZONTAL_ALIGN_CHILDREN = [{- label: 'align.left',+ labelLocale: 'align.left',customSuffix: {name: 'LeftAlignIcon',},value: 1,},{- label: 'align.center',+ labelLocale: 'align.center',selected: true,customSuffix: {name: 'CenterAlignIcon',@@ -332,7 +332,7 @@ export const HORIZONTAL_ALIGN_CHILDREN = [value: 2,},{- label: 'align.right',+ labelLocale: 'align.right',customSuffix: {name: 'RightAlignIcon',},@@ -342,21 +342,21 @@ export const HORIZONTAL_ALIGN_CHILDREN = [export const VERTICAL_ALIGN_CHILDREN = [{- label: 'align.top',+ labelLocale: 'align.top',customSuffix: {name: 'TopVerticalIcon',},value: 1,},{- label: 'align.middle',+ labelLocale: 'align.middle',customSuffix: {name: 'CenterVerticalIcon',},value: 2,},{- label: 'align.bottom',+ labelLocale: 'align.bottom',customSuffix: {name: 'BottomVerticalIcon',},@@ -366,21 +366,21 @@ export const VERTICAL_ALIGN_CHILDREN = [export const TEXT_WRAP_CHILDREN = [{- label: 'textWrap.overflow',+ labelLocale: 'textWrap.overflow',customSuffix: {name: 'OverflowIcon',},value: 1,},{- label: 'textWrap.wrap',+ labelLocale: 'textWrap.wrap',customSuffix: {name: 'BrIcon',},value: 3,},{- label: 'textWrap.clip',+ labelLocale: 'textWrap.clip',customSuffix: {name: 'CutIcon',},@@ -390,42 +390,42 @@ export const TEXT_WRAP_CHILDREN = [export const TEXT_ROTATE_CHILDREN = [{- label: 'textRotate.none',+ labelLocale: 'textRotate.none',customSuffix: {name: 'TextRotateIcon',},value: 0,},{- label: 'textRotate.angleUp',+ labelLocale: 'textRotate.angleUp',customSuffix: {name: 'TextRotateAngleUpIcon',},value: -45,},{- label: 'textRotate.angleDown',+ labelLocale: 'textRotate.angleDown',customSuffix: {name: 'TextRotateAngleDownIcon',},value: 45,},{- label: 'textRotate.vertical',+ labelLocale: 'textRotate.vertical',customSuffix: {name: 'TextRotateVerticalIcon',},value: 'v',},{- label: 'textRotate.rotationUp',+ labelLocale: 'textRotate.rotationUp',customSuffix: {name: 'TextRotateRotationUpIcon',},value: -90,},{- label: 'textRotate.rotationDown',+ labelLocale: 'textRotate.rotationDown',customSuffix: {name: 'TextRotateRotationDownIcon',},diff --git a/packages/ui-plugin-sheets/src/View/ToolBar/ToolBar.tsx b/packages/ui-plugin-sheets/src/View/ToolBar/ToolBar.tsxindex 60c1d3c935..9427e79870 100644--- a/packages/ui-plugin-sheets/src/View/ToolBar/ToolBar.tsx+++ b/packages/ui-plugin-sheets/src/View/ToolBar/ToolBar.tsx@@ -1,4 +1,4 @@-import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, PreactContext, Select, TextButton, Tooltip } from '@univerjs/base-ui';+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, findLocale, PreactContext, Select, Tooltip } from '@univerjs/base-ui';import { SheetUIPlugin } from '../..';import { SHEET_UI_PLUGIN_NAME } from '../../Basics';import { IToolbarItemProps } from '../../Controller';@@ -15,9 +15,6 @@ interface IState {defaultToolList: IToolbarItemProps[];showMore: boolean;toolbarListWidths: number[];- replace: IToolbarItemProps[];- defaultReplaceList: IToolbarItemProps[];- moreReplaceList: IToolbarItemProps[];}export class Toolbar extends Component<IProps, IState> {@@ -41,9 +38,6 @@ export class Toolbar extends Component<IProps, IState> {defaultToolList: [],moreToolList: [],toolbarListWidths: [],- replace: [],- defaultReplaceList: [],- moreReplaceList: [],};}@@ -101,8 +95,6 @@ export class Toolbar extends Component<IProps, IState> {{defaultToolList: this.state.toolList.slice(0, index),moreToolList: index ? this.state.toolList.slice(index) : [],- defaultReplaceList: this.state.replace.slice(0, index),- moreReplaceList: index ? this.state.replace.slice(index) : [],},() => {this.resetUl();@@ -140,8 +132,6 @@ export class Toolbar extends Component<IProps, IState> {{defaultToolList: this.state.defaultToolList.concat(this.state.moreToolList.slice(0, last ? moreIndex + 1 : moreIndex)),moreToolList: last ? [] : this.state.moreToolList.slice(moreIndex),- defaultReplaceList: this.state.replace.concat(this.state.moreReplaceList.slice(0, last ? moreIndex + 1 : moreIndex)),- moreReplaceList: last ? [] : this.state.moreReplaceList.slice(moreIndex),},() => {this.resetUl();@@ -153,12 +143,11 @@ export class Toolbar extends Component<IProps, IState> {}};- resetLabel = (toolList: any[], replace: IToolbarItemProps[]) => {+ resetLabel = (toolList: IToolbarItemProps[]) => {const componentManager = this.getContext().getPluginManager().getPluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)?.getComponentManager();for (let i = 0; i < toolList.length; i++) {- const item = toolList[i];-+ const item = findLocale<IToolbarItemProps>(toolList[i], this.getLocale.bind(this));// 优先寻找自定义组件if (item.customLabel) {const Label = componentManager?.get(item.customLabel.name);@@ -166,8 +155,6 @@ export class Toolbar extends Component<IProps, IState> {const props = item.customLabel.props ?? {};item.label = <Label {...props} />;}- } else {- item.label = this.getLocale(replace[i].label as string);}if (item.customSuffix) {@@ -179,7 +166,7 @@ export class Toolbar extends Component<IProps, IState> {}if (item.children) {- item.children = this.resetLabel(item.children, replace[i].children ?? []);+ item.children = this.resetLabel(item.children);}}return toolList;@@ -192,8 +179,6 @@ export class Toolbar extends Component<IProps, IState> {{toolList,defaultToolList: toolList,- replace: JSON.parse(JSON.stringify(toolList)),- defaultReplaceList: JSON.parse(JSON.stringify(toolList)),},() => {this.setToolbarListWidth();@@ -225,14 +210,16 @@ export class Toolbar extends Component<IProps, IState> {}// 渲染dom- getToolbarList(list: IToolbarItemProps[], replace: IToolbarItemProps[]) {- list = this.resetLabel(list, replace);+ getToolbarList(list: IToolbarItemProps[]) {+ list = this.resetLabel(list);return list.map((item) => {if (item.toolbarType) {if (item.show) {return (<Tooltip title={this.getLocale(item.tooltip)} placement={'bottom'}>- <TextButton active={item.active} label={item.label} onClick={item.onClick}></TextButton>+ <Button className={styles.textButton} type="text" active={item.active} onClick={item.onClick}>+ {item.label}+ </Button></Tooltip>);}@@ -261,12 +248,12 @@ export class Toolbar extends Component<IProps, IState> {}render() {- const { defaultToolList, moreToolList, showMore, defaultReplaceList, moreReplaceList } = this.state;+ const { defaultToolList, moreToolList, showMore } = this.state;return (<Container style={{ position: 'relative' }}><div className={`${styles.toolbarWarp} ${styles.toolbar}`} ref={this.toolbarRef}>- {this.getToolbarList(defaultToolList, defaultReplaceList)}+ {this.getToolbarList(defaultToolList)}<div ref={this.moreBtnRef} className={styles.moreButton} style={{ visibility: moreToolList.length ? 'visible' : 'hidden' }}><Tooltip title={this.getLocale('toolbar.toolMoreTip')} placement={'bottom'}>@@ -279,7 +266,7 @@ export class Toolbar extends Component<IProps, IState> {{moreToolList.length ? (<div style={{ visibility: showMore ? 'visible' : 'hidden' }} className={`${styles.moreTool} ${styles.toolbar}`} ref={this.moreToolRef}>- {this.getToolbarList(moreToolList, moreReplaceList)}+ {this.getToolbarList(moreToolList)}</div>) : (''diff --git a/packages/ui-plugin-sheets/src/View/ToolBar/index.module.css b/packages/ui-plugin-sheets/src/View/ToolBar/index.module.cssindex 8245552da9..1379b5148c 100644--- a/packages/ui-plugin-sheets/src/View/ToolBar/index.module.css+++ b/packages/ui-plugin-sheets/src/View/ToolBar/index.module.css@@ -62,6 +62,18 @@.toolbar .select-line-bold-parent .select-item-content {width: 100%;}+.toolbar .select-single {+ height: 26px;+ line-height: 26px;+}+.toolbar .select-input {+ height: 26px;+ line-height: 26px;+}+.toolbar .select-double {+ height: 26px;+ line-height: 26px;+}.toolbar button {padding: 0;height: 26px;@@ -69,6 +81,12 @@.toolbar span[role='img'].univericon-nextIcon {font-size: 12px;}+.toolbar .text-button span[role="img"] {+ font-size: 24px;+}+.toolbar .text-button button {+ padding: 0 5px;+}.more-button {position: absolute;right: 15px;diff --git a/packages/ui-plugin-sheets/src/View/ToolBar/index.module.less b/packages/ui-plugin-sheets/src/View/ToolBar/index.module.lessindex 9a11e2623e..648d0fef8b 100644--- a/packages/ui-plugin-sheets/src/View/ToolBar/index.module.less+++ b/packages/ui-plugin-sheets/src/View/ToolBar/index.module.less@@ -89,6 +89,21 @@}}+ .select-single {+ height: 26px;+ line-height: 26px;+ }++ .select-input {+ height: 26px;+ line-height: 26px;+ }++ .select-double {+ height: 26px;+ line-height: 26px;+ }+button {padding: 0;height: 26px;@@ -97,6 +112,17 @@span[role='img'].univericon-nextIcon {font-size: 12px;}++ .text-button {+ span[role="img"] {+ font-size: 24px;+ }++ button {+ padding: 0 5px;+ }+ }+}.more-button {@@ -129,7 +155,6 @@button {.button();- // font-size: 24px;}}