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
build(base-ui): slotManager
tonytonychopper123cc7554c17004
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsxindex fcdfb41ad2..bd924d5cb6 100644--- a/examples/univer-sheet-ts/src/main.tsx+++ b/examples/univer-sheet-ts/src/main.tsx@@ -6,6 +6,7 @@ import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/common-plugin-data';import { OperationPlugin } from '@univerjs/sheets-plugin-operation';import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';import { OverGridImagePlugin } from '@univerjs/sheets-plugin-image';+import { FindPlugin } from '@univerjs/sheets-plugin-find';const uiDefaultConfigDemo = {container: 'universheet',@@ -66,7 +67,7 @@ univer.install();// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(universheet);-// FindPlugin.create().installTo(universheet);+FindPlugin.create().installTo(universheet);universheet.installPlugin(new OperationPlugin());universheet.installPlugin(new ImportXlsxPlugin());universheet.installPlugin(new OverGridImagePlugin());diff --git a/packages/base-ui/src/Common/AppContext.tsx b/packages/base-ui/src/Common/AppContext.tsxindex 6683a328e9..729c0476a5 100644--- a/packages/base-ui/src/Common/AppContext.tsx+++ b/packages/base-ui/src/Common/AppContext.tsx@@ -4,10 +4,14 @@import { ContextBase } from '@univerjs/core';import { createContext } from 'preact';import { LocaleType } from '../Enum';+import { ComponentManager } from './ComponentManager';+import { ZIndexManager } from './ZIndexManager';export type AppContextValues = {context: ContextBase;locale: LocaleType;+ componentManager: ComponentManager;+ zIndexManager: ZIndexManager;};const AppContext = createContext<Partial<AppContextValues>>({});diff --git a/packages/base-ui/src/Common/ComponentManager.ts b/packages/base-ui/src/Common/ComponentManager.tsindex 563a10aef8..2c2ca9eba9 100644--- a/packages/base-ui/src/Common/ComponentManager.ts+++ b/packages/base-ui/src/Common/ComponentManager.ts@@ -1,3 +1,4 @@+import { IKeyValue } from '@univerjs/core';import {BorderDashDot,BorderDashDotDot,@@ -48,11 +49,17 @@ import {VerticalBorderIcon,} from '../Components/Icon';+export interface CustomComponent {+ name: string;+ props?: IKeyValue;+}+export type ComponentList = Map<string, Function>;+export class ComponentManager {- private _componentList: Map<string, any> = new Map();+ private _componentList: ComponentList = new Map();constructor() {- const iconList = {+ const iconList: Record<string, Function> = {ForwardIcon,BackIcon,BoldIcon,diff --git a/packages/base-ui/src/Common/SlotManager.ts b/packages/base-ui/src/Common/SlotManager.tsnew file mode 100644index 0000000000..652ef7ca5e--- /dev/null+++ b/packages/base-ui/src/Common/SlotManager.ts@@ -0,0 +1,61 @@+import { Nullable } from '@univerjs/core';+import { Slot } from '../Components/Slot/Slot';+import { CustomComponent } from './ComponentManager';++export type SlotComponent = {+ name: string;+ component: CustomComponent;+};++export type SlotGroupProps = Map<string, Map<string, SlotComponent>>;+export type SlotList = Map<string, Slot>;++export class SlotManager {+ private _slotGroup: SlotGroupProps = new Map();++ private _slotList: SlotList = new Map();++ getComponent = (ref: Slot) => {+ this._slotList.set(ref.props.name, ref);+ const slot = this._slotGroup.get(ref.props.name);+ if (!slot) return;+ ref.setSlotAll(slot);+ };++ setSlotComponent(slotName: string, component: SlotComponent, cb?: () => {}) {+ const slot = this._slotGroup.get(slotName);+ if (!slot) {+ const map = new Map([[component.name, component]]);+ this._slotGroup.set(slotName, map);+ } else {+ slot.set(component.name, component);+ }++ const item = this._slotList.get(slotName);+ item?.setSlot(component, cb);+ }++ removeSlotComponent(slotName: string, name: string) {+ const slot = this._slotList.get(slotName);+ if (!slot) return;+ const SlotComponent = this._slotGroup.get(slotName);+ if (!SlotComponent) return;+ const component = SlotComponent.get(name);+ if (!component) return;+ slot.removeSlot(component);+ }++ getSlot(slotName: string): Nullable<Slot> {+ const slot = this._slotList.get(slotName);+ if (slot) return slot;+ }++ removeSlot(name: string) {+ this._slotGroup.delete(name);+ const slot = this._slotList.get(name);+ if (slot) {+ slot.setSlotAll(new Map());+ this._slotList.delete(name);+ }+ }+}diff --git a/packages/base-ui/src/Common/ZIndexManager.ts b/packages/base-ui/src/Common/ZIndexManager.tsnew file mode 100644index 0000000000..da8f6dee68--- /dev/null+++ b/packages/base-ui/src/Common/ZIndexManager.ts@@ -0,0 +1,25 @@+export class ZIndexManager {+ private _list: Map<string, string> = new Map();++ setIndex(name: string, value: string) {+ this._list.set(name, value);+ }++ getIndex(name: string) {+ return this._list.get(name);+ }++ removeIndex(name: string) {+ this._list.delete(name);+ }++ getMaxIndex() {+ let max = -9999999;+ this._list.forEach((item) => {+ if (+item > max) {+ max = +item;+ }+ });+ return max;+ }+}diff --git a/packages/base-ui/src/Common/index.ts b/packages/base-ui/src/Common/index.tsindex a5606229f1..50902947e3 100644--- a/packages/base-ui/src/Common/index.ts+++ b/packages/base-ui/src/Common/index.ts@@ -3,3 +3,5 @@ export * from './KeyboardManager';export * from './DragManager';export * from './ComponentManager';export * from './RegisterManager';+export * from './SlotManager';+export * from './ZIndexManager';diff --git a/packages/base-ui/src/Components/Dropdown/Dropdown.tsx b/packages/base-ui/src/Components/Dropdown/Dropdown.tsxindex b591587ffd..1e5ca026f6 100644--- a/packages/base-ui/src/Components/Dropdown/Dropdown.tsx+++ b/packages/base-ui/src/Components/Dropdown/Dropdown.tsx@@ -1,6 +1,6 @@import { Icon } from '..';import { JSXComponent } from '../../BaseComponent';-import { Component, createRef } from '../../Framework';+import { PureComponent, createRef } from '../../Framework';import { BaseDropdownProps, DropdownComponent } from '../../Interfaces';import { Menu } from '../Menu';import { Tooltip } from '../Tooltip';@@ -10,7 +10,7 @@ interface IState {menuStyle: JSX.CSSProperties;}-export class Dropdown extends Component<BaseDropdownProps, IState> {+export class Dropdown extends PureComponent<BaseDropdownProps, IState> {MenuRef = createRef<Menu>();DropRef = createRef<HTMLDivElement>();diff --git a/packages/base-ui/src/Components/Item/Item.tsx b/packages/base-ui/src/Components/Item/Item.tsxindex b79e483eb0..3cdde9ccd3 100644--- a/packages/base-ui/src/Components/Item/Item.tsx+++ b/packages/base-ui/src/Components/Item/Item.tsx@@ -22,8 +22,8 @@ export class Item extends Component<BaseItemProps> {) : ('')}- <span className={styles.selectItemContent}>{label}</span>- {suffix ? <span className={styles.selectItemSuffix}>{suffix}</span> : ''}+ <span className={styles.selectItemContent}>{this.getLabel(label)}</span>+ {suffix ? <span className={styles.selectItemSuffix}>{this.getLabel(suffix)}</span> : ''}</div>);}diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsxindex d6018bc7b0..454398978d 100644--- a/packages/base-ui/src/Components/Menu/Menu.tsx+++ b/packages/base-ui/src/Components/Menu/Menu.tsx@@ -117,7 +117,7 @@ export class Menu extends Component<BaseMenuProps, BaseMenuState> {this.mouseLeave(e, index);}}>- {item.label}+ {this.getLabel(item.label)}{item.children ? (<Menuref={(ele: Menu) => (this._refs[index] = ele)}diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsxindex 5dc2feb266..1fe12e99f6 100644--- a/packages/base-ui/src/Components/Select/Select.tsx+++ b/packages/base-ui/src/Components/Select/Select.tsx@@ -1,6 +1,6 @@-import { PureComponent } from 'preact/compat';import { Icon } from '..';-import { ComponentChildren, createRef, RefObject } from '../../Framework';+import { CustomComponent } from '../../Common';+import { ComponentChildren, createRef, RefObject, PureComponent } from '../../Framework';import { BaseMenuItem } from '../../Interfaces';import { Dropdown } from '../Dropdown';import { Input } from '../Input';@@ -21,17 +21,12 @@ enum DisplayTypes {SUFFIX,}-interface CustomComponent {- name: string;- props?: Record<string, any>;-}-export interface BaseSelectChildrenProps extends BaseItemProps {onPressEnter?: (...arg: any) => void;children?: BaseSelectChildrenProps[];unSelectable?: boolean; //选中后不生效事件- customLabel?: CustomComponent;- customSuffix?: CustomComponent;+ label?: CustomComponent | ComponentChildren | string;+ suffix?: CustomComponent | ComponentChildren | string;name?: string;}@@ -47,8 +42,7 @@ export interface BaseSelectProps {hideSelectedIcon?: boolean;className?: string;name?: string;- customLabel?: CustomComponent;- customSuffix?: CustomComponent;+ suffix?: any;tooltip?: string;}@@ -277,7 +271,7 @@ export class Select extends PureComponent<BaseSelectProps, IState> {return (<div className={`${styles.selectSingle} ${className}`}><Dropdown onMainClick={onMainClick} tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <div>{content}</div>+ <div>{this.getLabel(content)}</div></Dropdown></div>);@@ -310,7 +304,7 @@ export class Select extends PureComponent<BaseSelectProps, IState> {return (<div className={`${styles.selectDouble} ${className}`}><Dropdown onClick={onClick} tooltip={tooltip} menu={{ menu, onClick: this.onClick }} icon={<Icon.NextIcon />}>- <div className={styles.selectLabel}>{content}</div>+ <div className={styles.selectLabel}>{this.getLabel(content)}</div></Dropdown></div>);@@ -323,7 +317,7 @@ export class Select extends PureComponent<BaseSelectProps, IState> {return (<div className={`${styles.selectDouble} ${className}`}><Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <div className={styles.selectLabel}>{label}</div>+ <div className={styles.selectLabel}>{this.getLabel(label)}</div></Dropdown></div>);@@ -332,11 +326,10 @@ export class Select extends PureComponent<BaseSelectProps, IState> {getDoubleFix = () => {const { label, className = '', tooltip, onClick } = this.props;const { menu } = this.state;-return (<div className={`${styles.selectDouble} ${className}`}><Dropdown tooltip={tooltip} onClick={onClick} menu={{ menu, onClick: this.onClick }} icon={<Icon.NextIcon />}>- <div className={styles.selectLabel}>{label}</div>+ <div className={styles.selectLabel}>{this.getLabel(label)}</div></Dropdown></div>);diff --git a/packages/base-ui/src/Components/SiderModal/SiderModal.tsx b/packages/base-ui/src/Components/SiderModal/SiderModal.tsxindex aa6bff43f8..7d8925efa5 100644--- a/packages/base-ui/src/Components/SiderModal/SiderModal.tsx+++ b/packages/base-ui/src/Components/SiderModal/SiderModal.tsx@@ -1,25 +1,47 @@import { Component } from '../../Framework';-import { JSXComponent } from '../../BaseComponent';-import { BaseSiderModalProps, SiderModalComponent } from '../../Interfaces';+import { BaseSiderModalProps } from '../../Interfaces';import { Icon } from '../index';import Style from './index.module.less';-class SiderModal extends Component<BaseSiderModalProps> {+type IState = {+ zIndex: number;+ show: boolean;+};++class SiderModal extends Component<BaseSiderModalProps, IState> {initialize(props: BaseSiderModalProps) {- this.state = {};+ this.state = {+ zIndex: props.zIndex ?? 0,+ show: props.show ?? true,+ };}close() {- this._context.getPluginManager().getPluginByName<any>('spreadsheet')!.showSiderByName(this.props.pluginName, false);- if (this.props.closeSide) {- this.props.closeSide();- }+ this.setState({+ show: false,+ });+ }++ handleClick() {+ const zIndex = this.context.zIndexManager.getMaxIndex() + 1;+ this.setState({+ zIndex,+ });+ }++ componentWillReceiveProps(props: BaseSiderModalProps): void {+ this.setState({+ show: props.show ?? true,+ });}render(props: BaseSiderModalProps) {const { className = '', style } = props;- return (- <div className={`${Style.siderModal} ${className}`} style={{ ...style }}>+ const { zIndex, show } = this.state;+ this.context.zIndexManager.setIndex(props.name, zIndex);++ return show ? (+ <div className={`${Style.siderModal} ${className}`} style={{ ...style, zIndex }} onClick={() => this.handleClick()}><div className={Style.siderModalHeader}><h3 className={Style.siderModalTitle}>{this.props.title}</h3><span className={Style.siderModalClose} onClick={() => this.close()}>@@ -31,13 +53,7 @@ class SiderModal extends Component<BaseSiderModalProps> {</div><div className={Style.siderModalFooter}>{this.props.footer}</div></div>- );- }-}--export class UniverSiderModal implements SiderModalComponent {- render(): JSXComponent<BaseSiderModalProps> {- return SiderModal;+ ) : null;}}diff --git a/packages/base-ui/src/Components/SiderModal/index.module.less b/packages/base-ui/src/Components/SiderModal/index.module.lessindex d792839167..ea26117c1f 100644--- a/packages/base-ui/src/Components/SiderModal/index.module.less+++ b/packages/base-ui/src/Components/SiderModal/index.module.less@@ -3,6 +3,7 @@height: 100%;border-left: 1px solid;background-color: var(--bg);+ position: fixed;.sider-modal-header {overflow: hidden;@@ -51,4 +52,4 @@width: 100%;height: 50px;}-}+}\ No newline at end of filediff --git a/packages/base-ui/src/Components/Slot/Slot.tsx b/packages/base-ui/src/Components/Slot/Slot.tsxindex e71ec74dc0..33af23e1d8 100644--- a/packages/base-ui/src/Components/Slot/Slot.tsx+++ b/packages/base-ui/src/Components/Slot/Slot.tsx@@ -1,16 +1,21 @@import { BaseComponentProps } from '../../BaseComponent';+import { SlotComponent } from '../../Common/SlotManager';import { Component } from '../../Framework';interface IState {- slotGroup: any[];+ slotGroup: Map<string, SlotComponent>;}-export class Slot extends Component<BaseComponentProps, IState> {- refs: any[] = [];+interface IProps extends BaseComponentProps {+ name: string;+}++export class Slot extends Component<IProps, IState> {+ private _refs: any[] = [];initialize() {this.state = {- slotGroup: [],+ slotGroup: new Map(),};}@@ -18,26 +23,58 @@ export class Slot extends Component<BaseComponentProps, IState> {this.props.getComponent?.(this);}- setSlotGroup(group: any[]) {- const slotGroup = group.map((item, index) => {- const Modal = plugin?.getRegisterComponent(item);- if (Modal) {- return <Modal ref={(ele: any) => (this.refs[index] = ele)} />;+ setSlot(component: SlotComponent, cb?: () => void) {+ const { slotGroup } = this.state;+ slotGroup.set(component.name, component);++ this.setState(+ {+ slotGroup,+ },+ () => {+ cb?.();}- return null;+ );+ }++ setSlotAll(slots: Map<string, SlotComponent>) {+ const { slotGroup } = this.state;+ slots.forEach((item) => {+ slotGroup.set(item.name, item);});this.setState({- modalGroup,+ slotGroup,});}- getModalGroup() {- return this.refs;+ removeSlot(component: SlotComponent) {+ const { slotGroup } = this.state;+ const slot = slotGroup.get(component.name);+ if (!slot) return;+ slotGroup.delete(component.name);+ this.setState({+ slotGroup,+ });+ }++ getSlots() {+ return this._refs;+ }++ renderSlot() {+ const { slotGroup } = this.state;+ const arr: JSX.Element[] = [];+ slotGroup.forEach((item, index) => {+ const Label = this.context.componentManager.get(item.component.name);+ if (Label) {+ arr.push(<Label ref={(ref: any) => (this._refs[index as any] = ref)} {...item.component.props}></Label>);+ }+ });+ return arr;}render() {- const { modalGroup } = this.state;- return <>{modalGroup.map((item) => item)}</>;+ return <>{this.renderSlot()}</>;}}diff --git a/packages/base-ui/src/Components/Tooltip/Tooltip.tsx b/packages/base-ui/src/Components/Tooltip/Tooltip.tsxindex 1caf9cb2d0..a4cd25c9c7 100644--- a/packages/base-ui/src/Components/Tooltip/Tooltip.tsx+++ b/packages/base-ui/src/Components/Tooltip/Tooltip.tsx@@ -96,7 +96,7 @@ export class Tooltip extends Component<BaseTooltipProps, TooltipState> {display: `${this.state.show ? 'block' : 'none'}`,}}>- {this.props.title}+ {this.getLabel(this.props.title)}<span className={style.tooltipTriangle}></span></span>) : null}diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.tsindex 2117427990..a55c57197f 100644--- a/packages/base-ui/src/Components/index.ts+++ b/packages/base-ui/src/Components/index.ts@@ -30,6 +30,8 @@ export * from './Select';export * from './CellRange';+export * from './Slot/Slot';+export {Avatar,Button,diff --git a/packages/base-ui/src/Framework/Preact.ts b/packages/base-ui/src/Framework/Preact.tsxsimilarity index 53%rename from packages/base-ui/src/Framework/Preact.tsrename to packages/base-ui/src/Framework/Preact.tsxindex 89ea23d2cf..847567ccab 100644--- a/packages/base-ui/src/Framework/Preact.ts+++ b/packages/base-ui/src/Framework/Preact.tsx@@ -1,8 +1,22 @@import { Context } from '@univerjs/core/src/Basics/Context';-import { cloneElement, Component as PreactComponent, ComponentChildren, ComponentClass, createRef, JSX, RefObject, render, VNode, PreactContext, Ref, toChildArray } from 'preact';+import {+ cloneElement,+ Component as PreactComponent,+ ComponentChildren,+ ComponentClass,+ createRef,+ JSX,+ RefObject,+ render,+ VNode,+ PreactContext,+ Ref,+ toChildArray,+ isValidElement,+} from 'preact';import { ForwardFn, forwardRef, PureComponent as PreactPureComponent } from 'preact/compat';import { useRef, useState, useEffect } from 'preact/hooks';-import { AppContext, AppContextValues } from '../Common';+import { AppContext, AppContextValues, CustomComponent } from '../Common';/*** Wrap the framework for easy switching of the underlying framework@@ -24,6 +38,22 @@ abstract class Component<P = {}, S = {}> extends PreactComponent<P, S> {return this.getContext().getLocale().get(name);}+ getLabel(label: string | CustomComponent | ComponentChildren) {+ if (typeof label === 'string') {+ return this.getLocale(label);+ }+ if (isValidElement(label)) {+ return label;+ }+ const Label = this.context.componentManager.get((label as CustomComponent).name);+ if (Label) {+ const props = (label as CustomComponent).props ?? {};+ return <Label {...props}></Label>;+ }++ return null;+ }+protected initialize(props?: P): void {//}@@ -32,8 +62,6 @@ abstract class Component<P = {}, S = {}> extends PreactComponent<P, S> {abstract class PureComponent<P = {}, S = {}> extends PreactPureComponent<P, S> {static contextType: PreactContext<Partial<AppContextValues>> = AppContext;- protected _context: Context;-constructor(props?: P) {super(props);this.initialize(props);@@ -47,6 +75,22 @@ abstract class PureComponent<P = {}, S = {}> extends PreactPureComponent<P, S> {return this.getContext().getLocale().get(name);}+ getLabel(label: string | CustomComponent | ComponentChildren) {+ if (typeof label === 'string') {+ return this.getLocale(label);+ }+ if (isValidElement(label)) {+ return label;+ }+ const Label = this.context.componentManager.get((label as CustomComponent).name);+ if (Label) {+ const props = (label as CustomComponent).props ?? {};+ return <Label {...props}></Label>;+ }++ return null;+ }+protected initialize(props?: P): void {//}diff --git a/packages/base-ui/src/Interfaces/SiderModal.ts b/packages/base-ui/src/Interfaces/SiderModal.tsindex e8b9fbf46e..8f377839dd 100644--- a/packages/base-ui/src/Interfaces/SiderModal.ts+++ b/packages/base-ui/src/Interfaces/SiderModal.ts@@ -2,14 +2,15 @@ import { BaseComponent, JSXComponent } from '../BaseComponent';import { ComponentChildren, RefObject } from '../Framework';export interface BaseSiderModalProps {+ name: string;title: string | any;- closeSide?: Function;+ show?: boolean;children?: ComponentChildren;footer?: ComponentChildren;- pluginName: string;ref?: RefObject<HTMLElement>;className?: string;- style: JSX.CSSProperties;+ zIndex?: number;+ style?: JSX.CSSProperties;}export interface SiderModalComponent extends BaseComponent<BaseSiderModalProps> {diff --git a/packages/sheets-plugin-find/src/Controller/FindController.ts b/packages/sheets-plugin-find/src/Controller/FindController.tsindex 5a5a687d40..7d6ea367e1 100644--- a/packages/sheets-plugin-find/src/Controller/FindController.ts+++ b/packages/sheets-plugin-find/src/Controller/FindController.ts@@ -14,7 +14,7 @@ export class FindController {name: FIND_PLUGIN_NAME,toolbarType: 1,tooltip: 'find.findLabel',- customLabel: {+ label: {name: 'SearchIcon',},show: true,diff --git a/packages/sheets-plugin-find/src/Controller/FindModalController.ts b/packages/sheets-plugin-find/src/Controller/FindModalController.tsindex c5b454a275..6b87adcecb 100644--- a/packages/sheets-plugin-find/src/Controller/FindModalController.ts+++ b/packages/sheets-plugin-find/src/Controller/FindModalController.ts@@ -1,6 +1,5 @@import { Nullable } from '@univerjs/core';import { SheetUIPlugin, SHEET_UI_PLUGIN_NAME } from '@univerjs/ui-plugin-sheets';-import { FIND_PLUGIN_NAME } from '../Const/PLUGIN_NAME';import { TextFinder } from '../Domain';import { FindPlugin } from '../FindPlugin';import { FindModal } from '../View/UI/FindModal';@@ -80,16 +79,21 @@ export class FindModalController {private _initialize() {const sheetUIPlugin = this._plugin.getContext().getUniver().getGlobalContext().getPluginManager().getRequirePluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME);- sheetUIPlugin.addSlot(FIND_PLUGIN_NAME + FindModal.name, {- component: FindModal,- props: {- getComponent: this.getComponent.bind(this),- findNext: this.findNext.bind(this),- findPrevious: this.findPrevious.bind(this),- replaceText: this.replaceText.bind(this),- replaceAll: this.replaceAll.bind(this),- matchCase: this.matchCase.bind(this),- matchEntireCell: this.matchEntireCell.bind(this),+ const componentManager = sheetUIPlugin.getComponentManager();+ componentManager.register(FindModal.name, FindModal);+ sheetUIPlugin.setSlot('main', {+ name: SHEET_UI_PLUGIN_NAME + FindModal.name,+ component: {+ name: FindModal.name,+ props: {+ getComponent: this.getComponent.bind(this),+ findNext: this.findNext.bind(this),+ findPrevious: this.findPrevious.bind(this),+ replaceText: this.replaceText.bind(this),+ replaceAll: this.replaceAll.bind(this),+ matchCase: this.matchCase.bind(this),+ matchEntireCell: this.matchEntireCell.bind(this),+ },},});}diff --git a/packages/sheets-plugin-image/src/Controller/OverGridImageController.ts b/packages/sheets-plugin-image/src/Controller/OverGridImageController.tsindex 68d142b538..9385037cab 100644--- a/packages/sheets-plugin-image/src/Controller/OverGridImageController.ts+++ b/packages/sheets-plugin-image/src/Controller/OverGridImageController.ts@@ -22,7 +22,7 @@ export class OverGridImageController {toolbarType: 1,tooltip: '导入图片',show: true,- labelLocale: '图片',+ label: '图片',onClick: () => {FileSelected.chooseImage().then((img) => {});},diff --git a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.tsindex 5499c43207..62a236440d 100644--- a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts+++ b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts@@ -24,7 +24,7 @@ export class ImportXlsxController {toolbarType: 1,tooltip: 'importXlsx.tooltip',show: true,- labelLocale: 'importXlsx.import',+ label: 'importXlsx.import',onClick: () => {this.upload();},diff --git a/packages/sheets-plugin-operation/src/Domain/Copy.ts b/packages/sheets-plugin-operation/src/Domain/Copy.tsindex 260273946e..b26b0b24e5 100644--- a/packages/sheets-plugin-operation/src/Domain/Copy.ts+++ b/packages/sheets-plugin-operation/src/Domain/Copy.ts@@ -1,9 +1,8 @@import { SheetContext, PLUGIN_NAMES, Tools, handleJsonToDom, handleStyleToString, ObjectArray, IColumnData, IRowData } from '@univerjs/core';import { SheetPlugin, SelectionModel, SelectionControl } from '@univerjs/base-sheets';-import { RightMenuProps, SheetUIPlugin, SHEET_UI_PLUGIN_NAME, RightMenuItem } from '@univerjs/ui-plugin-sheets';+import { RightMenuProps, RightMenuItem } from '@univerjs/ui-plugin-sheets';import { Clipboard } from '@univerjs/base-ui';// import { ClipboardInput } from '../UI/ClipboardInput';-import { OPERATION_PLUGIN } from '../Const';export abstract class Copy {private _context: SheetContext;@@ -23,27 +22,6 @@ export abstract class Copy {copy(e: Event) {e.preventDefault();}-- private _initRegisterComponent(component: any[]) {- // const SheetPlugin = this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;-- const mainSlotController = this._context- .getUniver()- .getGlobalContext()- .getPluginManager()- .getRequirePluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)- .getAppUIController()- .getSheetContainerController()- .getMainSlotController();-- for (let i = 0; i < component.length; i++) {- // SheetPlugin.registerComponent(OPERATION_PLUGIN + component[i].name, component[i]);-- mainSlotController.addSlot(OPERATION_PLUGIN + component[i].name, {- component: component[i],- });- }- }}export class UniverCopy extends Copy {diff --git a/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-docs/src/Controller/ToolbarUIController.tsindex a4055d19bb..b8cd72f893 100644--- a/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts@@ -12,13 +12,11 @@ import styles from '../View/Toolbar/index.module.less';export interface BaseToolbarSelectChildrenProps extends BaseSelectChildrenProps {suffixLocale?: string;children?: BaseToolbarSelectChildrenProps[];- labelLocale?: string;}export interface BaseToolbarSelectProps extends BaseSelectProps {suffixLocale?: string;children?: BaseToolbarSelectChildrenProps[];- labelLocale?: string;}enum ToolbarType {diff --git a/packages/ui-plugin-sheets/src/Controller/AppUIController.ts b/packages/ui-plugin-sheets/src/Controller/AppUIController.tsindex e29e690c9c..ba3b58951a 100644--- a/packages/ui-plugin-sheets/src/Controller/AppUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/AppUIController.ts@@ -18,6 +18,8 @@ export class AppUIController {UI.create({context: this._plugin.getGlobalContext(),locale: this._plugin.getGlobalContext().getLocale().getCurrentLocale(),+ componentManager: this._plugin.getComponentManager(),+ zIndexManager: this._plugin.getZIndexManager(),changeLocale: this.changeLocale,UIConfig,container: this._plugin.getConfig().container,diff --git a/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.tsindex a46edd7ab4..8f9d987b03 100644--- a/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts@@ -3,7 +3,6 @@ import { SheetUIPlugin } from '../SheetUIPlugin';import { InfoBar } from '../View/InfoBar';type IProps = {- locale?: string;label?: string;onBlur?: (e: FocusEvent) => void;};@@ -36,12 +35,6 @@ export class InfoBarUIController {};resetInfoList(list: BaseInfoBarProps) {- const locale = this._plugin.getGlobalContext().getLocale();- for (let k in list) {- if (list[k].locale) {- list[k].label = locale.get(list[k].locale);- }- }this._infoBar.setInfoList(list);}@@ -56,16 +49,16 @@ export class InfoBarUIController {this._infoBarModel = new InfoBarModel(name);this._infoList = {back: {- locale: 'info.return',+ label: 'info.return',},rename: {- locale: 'info.tips',+ label: 'info.tips',},update: {- locale: 'info.detailUpdate',+ label: 'info.detailUpdate',},save: {- locale: 'info.detailSave',+ label: 'info.detailSave',},sheet: {label: name,diff --git a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.tsindex d0aeb8e16b..866647a65b 100644--- a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts@@ -1,36 +1,32 @@import { IMouseEvent, IPointerEvent } from '@univerjs/base-render';import { SheetPlugin } from '@univerjs/base-sheets';-import { BaseMenuItem, BaseSelectChildrenProps } from '@univerjs/base-ui';+import { BaseMenuItem, BaseSelectChildrenProps, ComponentChildren } from '@univerjs/base-ui';import { PLUGIN_NAMES, Tools, UIObserver } from '@univerjs/core';import { SheetUIPlugin } from '..';import { DefaultRightMenuConfig, SheetRightMenuConfig } from '../Basics';import { RightMenu, RightMenuInput, RightMenuItem } from '../View';import styles from '../View/RightMenu/index.module.less';-export interface CustomLabelOptions extends BaseSelectChildrenProps {- locale?: string;-}interface CustomLabelProps {- prefix?: string;- suffix?: string;- prefixLocale?: string[] | string;- suffixLocale?: string[] | string;- options?: CustomLabelOptions[];+ prefix?: string[] | string;+ suffix?: string[] | string;+ options?: BaseSelectChildrenProps[];label?: string;children?: CustomLabelProps[];onKeyUp?: (e: Event) => void;}+export interface CustomLabel{+ name: string;+ props?: CustomLabelProps;+}+export interface RightMenuProps extends BaseMenuItem {- customLabel?: {- name: string;- props?: CustomLabelProps;- };+ label?: string | CustomLabel | ComponentChildren;children?: RightMenuProps[];suffix?: string;border?: boolean;- locale?: string;}export class RightMenuUIController {@@ -63,7 +59,7 @@ export class RightMenuUIController {show: this._config.InsertColumn,},{- customLabel: {+ label: {name: RightMenuInput.name,props: {prefix: 'rightClick.toTopAdd',@@ -73,7 +69,7 @@ export class RightMenuUIController {show: this._config.AddRowTop,},{- customLabel: {+ label: {name: RightMenuInput.name,props: {prefix: 'rightClick.toBottomAdd',@@ -83,7 +79,7 @@ export class RightMenuUIController {show: this._config.AddRowBottom,},{- customLabel: {+ label: {name: RightMenuInput.name,props: {prefix: 'rightClick.toLeftAdd',@@ -93,7 +89,7 @@ export class RightMenuUIController {show: this._config.AddColumnLeft,},{- customLabel: {+ label: {name: RightMenuInput.name,props: {prefix: 'rightClick.toRightAdd',@@ -121,7 +117,7 @@ export class RightMenuUIController {show: this._config.ShowRow,},{- customLabel: {+ label: {name: RightMenuInput.name,props: {prefix: 'rightClick.rowHeight',@@ -142,7 +138,7 @@ export class RightMenuUIController {show: this._config.ShowColumn,},{- customLabel: {+ label: {name: RightMenuInput.name,props: {prefix: 'rightClick.columnWidth',@@ -155,7 +151,7 @@ export class RightMenuUIController {},{show: this._config.DeleteCell,- customLabel: {+ label: {name: RightMenuItem.name,props: {label: 'rightClick.deleteCell',@@ -183,106 +179,106 @@ export class RightMenuUIController {},// {// show: this._config.hideMatrix,- // customLabel: {+ // label: {// name: RightMenuItem.name,// props: {- // locale: 'rightClick.matrix',+ // label: 'rightClick.matrix',// },// },// children: [// {- // customLabel: {+ // label: {// name: RightMenuButton.name,// props: {- // locale: 'rightClick.flip',+ // label: 'rightClick.flip',// children: [// {- // locale: 'rightClick.upAndDown',+ // label: 'rightClick.upAndDown',// },// {- // locale: 'rightClick.leftAndRight',+ // label: 'rightClick.leftAndRight',// },// ],// },// },// },// {- // customLabel: {+ // label: {// name: RightMenuButton.name,// props: {- // locale: 'rightClick.flip',+ // label: 'rightClick.flip',// children: [// {- // locale: 'rightClick.clockwise',+ // label: 'rightClick.clockwise',// },// {- // locale: 'rightClick.counterclockwise',+ // label: 'rightClick.counterclockwise',// },// ],// },// },// },// {- // locale: ['rightClick.transpose'],+ // label: ['rightClick.transpose'],// },// {- // customLabel: {+ // label: {// name: RightMenuSelect.name,// props: {- // locale: 'rightClick.matrixCalculation',+ // label: 'rightClick.matrixCalculation',// options: [// {- // locale: 'rightClick.plus',+ // label: 'rightClick.plus',// },// {- // locale: 'rightClick.minus',+ // label: 'rightClick.minus',// },// {- // locale: 'rightClick.multiply',+ // label: 'rightClick.multiply',// },// {- // locale: 'rightClick.divided',+ // label: 'rightClick.divided',// },// {- // locale: 'rightClick.power',+ // label: 'rightClick.power',// },// {- // locale: 'rightClick.root',+ // label: 'rightClick.root',// },// {- // locale: 'rightClick.log',+ // label: 'rightClick.log',// },// ],// },// },// },// {- // customLabel: {+ // label: {// name: RightMenuButton.name,// props: {- // locale: 'rightClick.delete0',+ // label: 'rightClick.delete0',// children: [// {- // locale: 'rightClick.byRow',+ // label: 'rightClick.byRow',// },// {- // locale: 'rightClick.byCol',+ // label: 'rightClick.byCol',// },// ],// },// },// },// {- // customLabel: {+ // label: {// name: RightMenuButton.name,// props: {- // locale: 'rightClick.removeDuplicate',+ // label: 'rightClick.removeDuplicate',// children: [// {- // locale: 'rightClick.byRow',+ // label: 'rightClick.byRow',// },// {- // locale: 'rightClick.byCol',+ // label: 'rightClick.byCol',// },// ],// },diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.tsindex bbd02cb204..8c6d95d94e 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts@@ -1,4 +1,4 @@-import { BaseMenuItem, BaseUlProps, ColorPicker } from '@univerjs/base-ui';+import { BaseMenuItem, BaseUlProps, ColorPicker, CustomComponent } from '@univerjs/base-ui';import {Nullable,Plugin,@@ -19,14 +19,8 @@ import { SheetBar } from '../View/SheetBar';import styles from '../View/SheetBar/index.module.less';import { SheetBarMenuItem } from '../View/SheetBar/SheetBarMenu';-interface CustomComponent {- name: string;- props?: Record<string, any>;-}-interface SheetUl extends BaseMenuItem {- locale?: string;- customLabel?: CustomComponent;+ label?: CustomComponent | string;children?: SheetUl[];}@@ -56,30 +50,30 @@ export class SheetBarUIController {this._plugin = plugin;this._sheetUl = [{- locale: 'sheetConfig.delete',+ label: 'sheetConfig.delete',onClick: () => {that.setUIObserve('onUIChangeObservable', { name: 'deleteSheet', value: this._dataId });},},{- locale: 'sheetConfig.copy',+ label: 'sheetConfig.copy',onClick: () => {that.setUIObserve('onUIChangeObservable', { name: 'copySheet' });},},{- locale: 'sheetConfig.rename',+ label: 'sheetConfig.rename',onClick: () => {this._sheetBar.reNameSheet(this._dataId);},},{- locale: 'sheetConfig.changeColor',+ label: 'sheetConfig.changeColor',border: true,className: styles.selectColorPickerParent,children: [{- customLabel: {+ label: {name: this._plugin.getPluginName() + ColorPicker.name,props: {onClick: (color: string) => {@@ -98,13 +92,13 @@ export class SheetBarUIController {],},{- locale: 'sheetConfig.hide',+ label: 'sheetConfig.hide',onClick: () => {that.setUIObserve('onUIChangeObservable', { name: 'hideSheet', value: this._dataId });},},{- locale: 'sheetConfig.unhide',+ label: 'sheetConfig.unhide',onClick: () => {this._sheetBar.ref.current.showMenu(true);that.setUIObserve('onUIChangeObservable', { name: 'unHideSheet', value: this._dataId });@@ -161,49 +155,6 @@ export class SheetBarUIController {this._refreshComponent();};- resetLabel(label: string[] | string) {- const locale = this._plugin.getGlobalContext().getLocale();-- 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;- }-- findLocale(obj: any) {- for (let k in obj) {- if (k === 'locale') {- obj.label = this.resetLabel(obj[k]);- } else if (k.endsWith('Locale')) {- const index = k.indexOf('Locale');- obj[k.slice(0, index)] = this.resetLabel(obj[k]);- } else if (!obj[k].$$typeof) {- if (Object.prototype.toString.call(obj[k]) === '[object Object]') {- this.findLocale(obj[k]);- } else if (Object.prototype.toString.call(obj[k]) === '[object Array]') {- obj[k] = this.resetSheetUl(obj[k]);- }- }- }-- return obj;- }-setUIObserve<T>(type: string, msg: UIObserver<T>) {this._plugin.getContext().getObserverManager().requiredObserver<UIObserver<T>>(type, 'core').notifyObservers(msg);}@@ -224,18 +175,6 @@ export class SheetBarUIController {return this._menuList;}- resetSheetUl(sheetUl: SheetUl[]) {- for (let i = 0; i < sheetUl.length; i++) {- let item = sheetUl[i];- item = this.findLocale(item);-- if (item.children) {- item.children = this.resetSheetUl(item.children);- }- }- return sheetUl;- }-selectSheet() {}deleteSheet() {}@@ -363,7 +302,6 @@ export class SheetBarUIController {}protected _refreshComponent(): void {- this._sheetUl = this.resetSheetUl(this._sheetUl);this._refreshSheetData();this._refreshSheetBarUI();}diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.tsindex d6a9752245..1b36dc5c80 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts@@ -1,6 +1,6 @@-import { DragManager, getRefElement, Prompt } from '@univerjs/base-ui';+import { DragManager, getRefElement, Prompt, SlotManager, ZIndexManager } from '@univerjs/base-ui';import { LocaleType } from '@univerjs/core';-import { ISheetUIPluginConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';+import { ISheetUIPluginConfig } from '../Basics';import { SheetUIPlugin } from '../SheetUIPlugin';import { SheetContainer } from '../View';import { CellEditorUIController } from './CellEditorUIController';@@ -21,6 +21,10 @@ export class SheetContainerUIController {private _slotController: SlotController;+ private _slotManager: SlotManager;++ private _zIndexManager: ZIndexManager;+private _cellEditorUIController: CellEditorUIController;private _formulaBarUIController: FormulaBarUIController;@@ -45,6 +49,7 @@ export class SheetContainerUIController {this._initialize();this._slotController = new SlotController();+ this._slotManager = new SlotManager();this._toolbarController = new ToolbarUIController(this._plugin, this._config.layout?.toolbarConfig);this._cellEditorUIController = new CellEditorUIController(this._plugin);this._formulaBarUIController = new FormulaBarUIController(this._plugin);@@ -53,8 +58,15 @@ export class SheetContainerUIController {this._countBarController = new CountBarUIController(this._plugin);this._sheetBarController = new SheetBarUIController(this._plugin);// 插入prompt组件- this._slotController.addSlot(SHEET_UI_PLUGIN_NAME + Prompt.name, {- component: Prompt,+ // this._slotController.addSlot(SHEET_UI_PLUGIN_NAME + Prompt.name, {+ // component: Prompt,+ // });+ this._plugin.getComponentManager().register(Prompt.name, Prompt);+ this._slotManager.setSlotComponent('main', {+ name: Prompt.name,+ component: {+ name: Prompt.name,+ },});}@@ -94,7 +106,8 @@ export class SheetContainerUIController {changeSheetName: this._sheetBarController.changeSheetName,},slot: {- getComponent: this._slotController.getComponent,+ // getComponent: this._slotController.getComponent,+ getComponent: this._slotManager.getComponent,},},};@@ -144,6 +157,10 @@ export class SheetContainerUIController {return this._slotController;}+ getSlotManager() {+ return this._slotManager;+ }+getToolbarController() {return this._toolbarController;}diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsindex 17874186ae..982391291d 100644--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts@@ -1,5 +1,5 @@import { BorderInfo, SheetPlugin } from '@univerjs/base-sheets';-import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';+import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren, CustomComponent } from '@univerjs/base-ui';import {BorderType,CommandManager,@@ -16,6 +16,7 @@ import {Range,FontWeight,FontItalic,+ ITextRotation,} from '@univerjs/core';import { SheetUIPlugin } from '..';import { DefaultToolbarConfig, SheetToolbarConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';@@ -34,17 +35,8 @@ import {import styles from '../View/Toolbar/index.module.less';-// 继承基础下拉属性,添加国际化-export interface BaseToolbarSelectChildrenProps extends BaseSelectChildrenProps {- suffixLocale?: string;- children?: BaseToolbarSelectChildrenProps[];- labelLocale?: string;-}-export interface BaseToolbarSelectProps extends BaseSelectProps {- suffixLocale?: string;- children?: BaseToolbarSelectChildrenProps[];- labelLocale?: string;+ children?: BaseSelectChildrenProps[];}enum ToolbarType {@@ -103,7 +95,7 @@ export class ToolbarUIController {toolbarType: 1,tooltip: 'toolbar.undo',name: 'undo',- customLabel: {+ label: {name: 'ForwardIcon',},show: this._config.undo,@@ -115,7 +107,7 @@ export class ToolbarUIController {{toolbarType: 1,tooltip: 'toolbar.redo',- customLabel: {+ label: {name: 'BackIcon',},name: 'redo',@@ -161,7 +153,7 @@ export class ToolbarUIController {{toolbarType: 1,tooltip: 'toolbar.bold',- customLabel: {+ label: {name: 'BoldIcon',},unActive: false,@@ -175,7 +167,7 @@ export class ToolbarUIController {{toolbarType: 1,tooltip: 'toolbar.italic',- customLabel: {+ label: {name: 'ItalicIcon',},unActive: false,@@ -189,7 +181,7 @@ export class ToolbarUIController {{toolbarType: 1,tooltip: 'toolbar.strikethrough',- customLabel: {+ label: {name: 'DeleteLineIcon',},unActive: false,@@ -206,7 +198,7 @@ export class ToolbarUIController {{toolbarType: 1,tooltip: 'toolbar.underline',- customLabel: {+ label: {name: 'UnderLineIcon',},unActive: false,@@ -223,14 +215,14 @@ export class ToolbarUIController {{type: 5,tooltip: 'toolbar.textColor.main',- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + ColorSelect.name,props: {getComponent: (ref: ColorSelect) => {this._colorSelect1 = ref;},color: '#000',- customLabel: {+ label: {name: 'TextColorIcon',},},@@ -238,20 +230,19 @@ export class ToolbarUIController {onClick: () => {this.hideTooltip();const textColor = this._toolList.find((item) => item.name === 'textColor');- if (!textColor) return;- if (!textColor.customLabel) return;- if (!textColor.customLabel.props) return;- textColor.customLabel.props.color = this._textColor;+ if (!textColor || !textColor.label) return;+ if (!((textColor.label as CustomComponent).props?.color)) return;+ (textColor.label as CustomComponent).props!.color = this._textColor;this.changeColor(this._textColor);},hideSelectedIcon: true,className: styles.selectColorPickerParent,children: [{- labelLocale: 'toolbar.resetColor',+ label: 'toolbar.resetColor',},{- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + ColorPicker.name,props: {onClick: (color: string, e: MouseEvent) => {@@ -269,14 +260,14 @@ export class ToolbarUIController {{type: 5,tooltip: 'toolbar.fillColor.main',- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + ColorSelect.name,props: {getComponent: (ref: ColorSelect) => {this._colorSelect2 = ref;},color: '#fff',- customLabel: {+ label: {name: 'FillColorIcon',},},@@ -284,20 +275,19 @@ export class ToolbarUIController {onClick: () => {this.hideTooltip();const fillColor = this._toolList.find((item) => item.name === 'fillColor');- if (!fillColor) return;- if (!fillColor.customLabel) return;- if (!fillColor.customLabel.props) return;- fillColor.customLabel.props.color = this._background;+ if (!fillColor || !fillColor.label) return;+ if (!((fillColor.label as CustomComponent).props?.color)) return;+ (fillColor.label as CustomComponent).props!.color = this._background;this.setBackground(this._background);},hideSelectedIcon: true,className: styles.selectColorPickerParent,children: [{- labelLocale: 'toolbar.resetColor',+ label: 'toolbar.resetColor',},{- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + ColorPicker.name,props: {onClick: (color: string, e: MouseEvent) => {@@ -330,7 +320,7 @@ export class ToolbarUIController {...BORDER_LINE_CHILDREN,{name: 'borderColor',- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + LineColor.name,props: {color: '#000',@@ -342,7 +332,7 @@ export class ToolbarUIController {className: styles.selectColorPickerParent,children: [{- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + ColorPicker.name,props: {onClick: (color: string, e: MouseEvent) => {@@ -350,10 +340,9 @@ export class ToolbarUIController {this._borderInfo.color = color;const borderItem = this._toolList.find((item) => item.name === 'border');const lineColor = borderItem?.children?.find((item) => item.name === 'borderColor');- if (!lineColor) return;- if (!lineColor.customLabel) return;- if (!lineColor.customLabel.props) return;- lineColor.customLabel.props.color = color;+ if (!lineColor || !lineColor.label) return;+ if (!((lineColor.label as CustomComponent).props?.color)) return;+ (lineColor.label as CustomComponent).props!.color = color;},},},@@ -365,7 +354,7 @@ export class ToolbarUIController {],},{- customLabel: {+ label: {name: SHEET_UI_PLUGIN_NAME + LineBold.name,props: {img: 0,@@ -375,7 +364,12 @@ export class ToolbarUIController {},onClick: (...arg) => {arg[0].stopPropagation();- this._lineBold.setImg(BORDER_SIZE_CHILDREN[arg[2]].customLabel?.name);+ const label = BORDER_SIZE_CHILDREN[arg[2]].label+ if(typeof label === 'string'){+ this._lineBold.setImg(label);+ }else{+ this._lineBold.setImg(label.name);+ }this._borderInfo.style = arg[1];},className: styles.selectLineBoldParent,@@ -387,7 +381,7 @@ export class ToolbarUIController {{type: 5,tooltip: 'toolbar.mergeCell.main',- customLabel: {+ label: {name: 'MergeIcon',},show: this._config.mergeCell,@@ -647,7 +641,7 @@ export class ToolbarUIController {const underline = range.getUnderline();const horizontalAlign = range.getHorizontalAlignment() ?? HorizontalAlign.LEFT;const verticalAlign = range.getVerticalAlignment() ?? VerticalAlign.BOTTOM;- const rotation = range.getTextRotation();+ const rotation = range.getTextRotation() as ITextRotation;const warp = range.getWrapStrategy() ?? WrapStrategy.CLIP;const bold = this._toolList.find((item) => item.name === 'bold');@@ -691,13 +685,13 @@ export class ToolbarUIController {fontItalicItem.active = !!fontItalic;}// if (textColor) {- // const label = textColor.customLabel+ // const label = textColor.label// if (label && label.props) {// label.props.color = fontColor// }// }// if (fillColor) {- // const label = fillColor.customLabel+ // const label = fillColor.label// if (label && label.props) {// label.props.color = background// }diff --git a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts b/packages/ui-plugin-sheets/src/SheetUIPlugin.tsindex 76496084ec..95a35d4110 100644--- a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts+++ b/packages/ui-plugin-sheets/src/SheetUIPlugin.ts@@ -1,5 +1,5 @@-import { Plugin, Tools, PLUGIN_NAMES, Context, Univer, IKeyValue, LocaleType } from '@univerjs/core';-import { ComponentManager, getRefElement, RegisterManager, KeyboardManager } from '@univerjs/base-ui';+import { Plugin, Tools, PLUGIN_NAMES, Context, Univer } from '@univerjs/core';+import { ComponentManager, getRefElement, RegisterManager, KeyboardManager, SlotComponent, ZIndexManager } from '@univerjs/base-ui';import { RenderEngine } from '@univerjs/base-render';import { DefaultSheetUIConfig, installObserver, ISheetUIPluginConfig, SheetUIPluginObserve, SHEET_UI_PLUGIN_NAME } from './Basics';import { AppUIController } from './Controller/AppUIController';@@ -17,6 +17,8 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {private _config: ISheetUIPluginConfig;+ private _zIndexManager: ZIndexManager;+private _componentManager: ComponentManager;constructor(config?: ISheetUIPluginConfig) {@@ -54,6 +56,7 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {// }this._componentManager = new ComponentManager();+ this._zIndexManager = new ZIndexManager();this._keyboardManager = new KeyboardManager(this);this._registerManager = new RegisterManager(this);this._appUIController = new AppUIController(this);@@ -63,25 +66,25 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {});}- loadLocale(locale: LocaleType, module: IKeyValue) {- // import(`./Locale/${locale}`).then((module) => {- // Do something with the module.- const localObject: IKeyValue = {};- localObject[locale] = module.default;+ // loadLocale(locale: LocaleType, module: IKeyValue) {+ // // import(`./Locale/${locale}`).then((module) => {+ // // Do something with the module.+ // const localObject: IKeyValue = {};+ // localObject[locale] = module.default;- console.log('localObject===', locale, localObject);+ // console.log('localObject===', locale, localObject);- this.getLocale().load(localObject);+ // this.getLocale().load(localObject);- this._componentManager = new ComponentManager();- this._keyboardManager = new KeyboardManager(this);- this._registerManager = new RegisterManager(this);- this._appUIController = new AppUIController(this);- // AppUIController initializes the DOM as an asynchronous rendering process, and must wait for the UI rendering to complete before starting to render the canvas- this.UIDidMount(() => {- this.initRender();- });- }+ // this._componentManager = new ComponentManager();+ // this._keyboardManager = new KeyboardManager(this);+ // this._registerManager = new RegisterManager(this);+ // this._appUIController = new AppUIController(this);+ // // AppUIController initializes the DOM as an asynchronous rendering process, and must wait for the UI rendering to complete before starting to render the canvas+ // this.UIDidMount(() => {+ // this.initRender();+ // });+ // }getConfig() {return this._config;@@ -120,6 +123,10 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {return this._componentManager;}+ getZIndexManager() {+ return this._zIndexManager;+ }+/*** usage this._clipboardExtensionManager.handle(data);* @returns@@ -157,6 +164,10 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {this._appUIController.getSheetContainerController().UIDidMount(cb);}+ setSlot(slotName: string, component: SlotComponent, cb?: () => {}) {+ this._appUIController.getSheetContainerController().getSlotManager().setSlotComponent(slotName, component, cb);+ }+addSlot(name: string, slot: SlotComponentProps, cb?: () => void) {this._appUIController.getSheetContainerController().getMainSlotController().addSlot(name, slot, cb);}diff --git a/packages/ui-plugin-sheets/src/View/App.tsx b/packages/ui-plugin-sheets/src/View/App.tsxindex c4c0bd6e54..e646799c0a 100644--- a/packages/ui-plugin-sheets/src/View/App.tsx+++ b/packages/ui-plugin-sheets/src/View/App.tsx@@ -1,10 +1,12 @@-import { AppContext, BaseComponentProps, Component } from '@univerjs/base-ui';+import { AppContext, BaseComponentProps, Component, ComponentManager, ZIndexManager } from '@univerjs/base-ui';import { LocaleType } from '@univerjs/core';import { BaseSheetContainerProps, SheetContainer } from './SheetContainer';export interface BaseUIProps extends BaseComponentProps {locale: LocaleType;UIConfig: BaseSheetContainerProps;+ componentManager: ComponentManager;+ zIndexManager: ZIndexManager;changeLocale: (locale: string) => void;}@@ -29,7 +31,7 @@ export class App extends Component<BaseUIProps, IState> {}render() {- const { context, UIConfig } = this.props;+ const { context, UIConfig, componentManager, zIndexManager } = this.props;const { locale } = this.state;return (@@ -37,6 +39,8 @@ export class App extends Component<BaseUIProps, IState> {value={{context,locale,+ componentManager,+ zIndexManager,}}><divdiff --git a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsxindex 6bca2a8166..c401164161 100644--- a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx@@ -1,14 +1,8 @@-import { BaseComponentProps, Component, ComponentChildren } from '@univerjs/base-ui';-import { SheetUIPlugin } from '../../..';-import { SHEET_UI_PLUGIN_NAME } from '../../../Basics';+import { BaseComponentProps, Component, ComponentChildren, CustomComponent } from '@univerjs/base-ui';import styles from './index.module.less';interface IProps extends BaseComponentProps {- customLabel?: {- name: string;- props: any;- };- label?: ComponentChildren;+ label?: ComponentChildren | CustomComponent;id: string;color: string;}@@ -19,17 +13,8 @@ interface IState {}export class ColorSelect extends Component<IProps, IState> {+componentDidMount(): void {- const componentManager = this.getContext().getPluginManager().getPluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)?.getComponentManager();- let label = this.props.label;- if (this.props.customLabel) {- const Label = componentManager?.get(this.props.customLabel.name);- label = <Label {...this.props.customLabel.props}></Label>;- }- this.setState({- label,- color: this.props.color,- });this.props.getComponent?.(this);}@@ -46,9 +31,10 @@ export class ColorSelect extends Component<IProps, IState> {}render() {+ const {label} = this.propsreturn (<div className={styles.colorSelect}>- <div>{this.state.label}</div>+ <div>{this.getLabel(label)}</div><div className={styles.colorSelectLine} style={{ background: this.state.color }}></div></div>);diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsxindex 9d22f176df..9547fddf68 100644--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx@@ -38,9 +38,10 @@ export class LineBold extends Component<IProps, IState> {if (!img) return null;const span = document.querySelector('.base-sheets-line-bold') as HTMLDivElement;const props = { width: span.offsetWidth };- const componentManager = this.getContext().getPluginManager().getPluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)?.getComponentManager();- const Img = componentManager?.get(img);- return <Img {...(props as any)} />;+ const Img = this.context.componentManager.get(img);+ if(Img){+ return <Img {...(props as any)} />;+ }}render() {@@ -49,7 +50,7 @@ export class LineBold extends Component<IProps, IState> {return (<div style={{ paddingBottom: '3px', width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><span className={'base-sheets-line-bold'} style={{ position: 'relative' }}>- {this.getLocale(label)}+ {this.getLabel(label)}<div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '14px' }}>{img.length ? this.getImg(img) : ''}</div></span><Icon.RightIcon />diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsxindex 6d5ac26047..009a7874b8 100644--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx@@ -38,7 +38,7 @@ export class LineColor extends Component<IProps, IState> {return (<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>- <span style={{ display: 'inline-block', borderBottom: `3px solid ${color}` }}>{this.getLocale(label)}</span>+ <span style={{ display: 'inline-block', borderBottom: `3px solid ${color}` }}>{this.getLabel(label)}</span><Icon.RightIcon /></div>);diff --git a/packages/ui-plugin-sheets/src/View/Common/test.tsx b/packages/ui-plugin-sheets/src/View/Common/test.tsxnew file mode 100644index 0000000000..d0042659d6--- /dev/null+++ b/packages/ui-plugin-sheets/src/View/Common/test.tsx@@ -0,0 +1,15 @@+import { Component, SiderModal } from '@univerjs/base-ui';++type IProps = {};++type IState = {};++export class Test extends Component<IProps, IState> {+ render() {+ return (+ <SiderModal zIndex={92} name="test" title={'test'} style={{ width: '30%', background: 'red' }}>+ Hello+ </SiderModal>+ );+ }+}diff --git a/packages/ui-plugin-sheets/src/View/Common/test1.tsx b/packages/ui-plugin-sheets/src/View/Common/test1.tsxnew file mode 100644index 0000000000..d784220a24--- /dev/null+++ b/packages/ui-plugin-sheets/src/View/Common/test1.tsx@@ -0,0 +1,15 @@+import { Component, SiderModal } from '@univerjs/base-ui';++type IProps = {};++type IState = {};++export class Test1 extends Component<IProps, IState> {+ render() {+ return (+ <SiderModal zIndex={91} name="test1" title={'test1'} style={{ width: '70%', background: '#abcdef' }}>+ Hello 1+ </SiderModal>+ );+ }+}diff --git a/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsxindex d2ce4d4dd4..bd84f63a9b 100644--- a/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsx+++ b/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsx@@ -49,8 +49,8 @@ export class InfoBar extends Component<IProps, IState> {<Input bordered={false} value={sheet.label} onBlur={renameSheet} /></Tooltip></div>- <div className={styles.infoDetailUpdate}>{update.label}</div>- <div className={styles.infoDetailSave}>{save.label}</div>+ <div className={styles.infoDetailUpdate}>{this.getLabel(update.label)}</div>+ <div className={styles.infoDetailSave}>{this.getLabel(save.label)}</div></Container>);}diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsxindex 4d53fac0a2..42e4a0625e 100644--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsx+++ b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsx@@ -1,8 +1,6 @@import { IMouseEvent } from '@univerjs/base-render';-import { BaseRightMenuProps, Component, createRef, Menu } from '@univerjs/base-ui';-import { SheetUIPlugin } from '../..';-import { SHEET_UI_PLUGIN_NAME } from '../../Basics';-import { RightMenuProps } from '../../Controller';+import { BaseRightMenuProps, Component, createRef, Menu } from '@univerjs/base-ui';+import { RightMenuProps } from '../../Controller';import Style from './index.module.less';interface IState {@@ -10,7 +8,6 @@ interface IState {srcElement: any;eventType: string | null;children: RightMenuProps[];- replace: RightMenuProps[];}export class RightMenu extends Component<BaseRightMenuProps, IState> {@@ -24,39 +21,12 @@ export class RightMenu extends Component<BaseRightMenuProps, IState> {srcElement: null,eventType: null,children: [],- replace: [],};}- // 转换成渲染需要的数据- resetMenuList(children: RightMenuProps[], replace: RightMenuProps[]) {- const componentManager = this.getContext().getPluginManager().getPluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)?.getComponentManager();-- for (let i = 0; i < children.length; i++) {- const item = children[i];- if (item.customLabel) {- const Label = componentManager?.get(item.customLabel.name);-- const props = item.customLabel.props ?? {};- if (Label) {- item.label = <Label {...props} />;- }- } else if (typeof item.label === 'string') {- item.label = this.getLocale(replace[i].label as string);- }-- if (item.children) {- item.children = this.resetMenuList(item.children, replace[i].children!);- }- }-- return children;- }-setMenuList(children: RightMenuProps[]) {this.setState({children,- replace: JSON.parse(JSON.stringify(children)),});}@@ -158,7 +128,7 @@ export class RightMenu extends Component<BaseRightMenuProps, IState> {e.preventDefault();}}>- <Menu ref={this.ulRef} menu={this.resetMenuList(this.state.children, this.state.replace)} onClick={this.handleClick}></Menu>+ <Menu ref={this.ulRef} menu={this.state.children} onClick={this.handleClick}></Menu></div>));diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsxindex 13caab51df..827cf31b6c 100644--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx+++ b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx@@ -20,9 +20,9 @@ export class RightMenuInput extends Component<IProps> {const { prefix, suffix } = this.props;return (<div>- {this.getLocale(prefix)}+ {this.getLabel(prefix)}<Input onPressEnter={this.handleKeyUp.bind(this)} type="number" placeholder="1" onClick={this.handleClick}></Input>- {this.getLocale(suffix)}+ {this.getLabel(suffix)}</div>);}diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuItem.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuItem.tsxindex 675a7848bd..09b9071f81 100644--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuItem.tsx+++ b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuItem.tsx@@ -11,7 +11,7 @@ export class RightMenuItem extends Component<IProps> {return (<div className={styles.rightMenuItem}>- {this.getLocale(label)}+ {this.getLabel(label)}<Icon.Format.RightIcon /></div>);diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsxindex dc64915748..7e673e4875 100644--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx@@ -37,8 +37,6 @@ export class SheetBar extends Component<BaseSheetBarProps, SheetState> {startClientX: number;- private _localeObserver: Nullable<Observer<Workbook>>;-private _renderKey: number = 1;initialize(props: BaseSheetBarProps) {@@ -49,40 +47,8 @@ export class SheetBar extends Component<BaseSheetBarProps, SheetState> {};}- resetLabel(list: any) {- const componentManager = this.getContext().getPluginManager().getPluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)?.getComponentManager();-- for (let i = 0; i < list.length; i++) {- const item = list[i];-- // 优先寻找自定义组件- if (item.customLabel) {- const Label = componentManager?.get(item.customLabel.name);- if (Label) {- const props = item.customLabel.props ?? {};- item.label = <Label {...props} />;- }- }-- if (item.children) {- item.children = this.resetLabel(item.children);- }- }- return list;- }-// setstatesetValue = (value: any, fn?: () => void) => {- let { sheetList, menuList, sheetUl } = value;- if (sheetList) {- sheetList = this.resetLabel(sheetList);- }- if (menuList) {- menuList = this.resetLabel(menuList);- }- if (sheetUl) {- sheetUl = this.resetLabel(sheetUl);- }this.setState((prevState) => ({ ...value }), fn);};@@ -221,7 +187,7 @@ export class SheetBar extends Component<BaseSheetBarProps, SheetState> {<div className={`${styles.slideTabDivider}`}></div><div className={`${styles.slideTabTitle}`}><span className={`${styles.slideTabSpan}`} style={{ padding: '2px 5px 2px 5px' }}>- {item.label}+ {this.getLabel(item.label)}</span></div><div className={`${styles.slideTabIcon}`} data-slide-skip="true" style={{ lineHeight: 1 }} data-id={item.sheetId} onClick={this.contextMenu}>diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsxindex 28fad95ca8..d29d7180c8 100644--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu.tsx@@ -59,7 +59,7 @@ export class SheetBarMenu extends Component<SheetBarMenuProps, IState> {<span className={styles.sheetBarMenuIcon}><EffIcon item={item}></EffIcon></span>- <span className={styles.sheetBarMenuTitle}>{item.label}</span>+ <span className={styles.sheetBarMenuTitle}>{this.getLabel(item.label ?? '')}</span></li>))}</ul>diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsxindex ca592fb74c..23c9ed0e6c 100644--- a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx@@ -1,4 +1,4 @@-import { BaseComponentProps, Component, Container, Content, createRef, Footer, Header, Layout, Sider } from '@univerjs/base-ui';+import { BaseComponentProps, Component, Container, Content, createRef, Footer, Header, Layout, Sider, Slot } from '@univerjs/base-ui';import defaultSkin from '@univerjs/base-ui/Basics/CSS/Skin/default.module.less';import { Tools } from '@univerjs/core';import cssVars from 'css-vars-ponyfill';@@ -10,7 +10,6 @@ import { SheetBar } from '../SheetBar';import { FormulaBar } from '../FormulaBar';import { RichText } from '../RichText';import { ISheetUIPluginConfig } from '../../Basics';-import { Slot } from '../Slot/Slot';import { Toolbar } from '../Toolbar';export interface BaseSheetContainerProps extends BaseComponentProps {@@ -107,7 +106,7 @@ export class SheetContainer extends Component<BaseSheetContainerProps> {const id = typeof container === 'string' ? container : container.id;// get all skins- const skins = {+ const skins: Record<string, CSSModuleClasses> = {default: defaultSkin,};@@ -220,7 +219,7 @@ export class SheetContainer extends Component<BaseSheetContainerProps> {{/* innerLeft */}</Sider><Content className={config.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>- <Slot {...methods.slot}></Slot>+ {/* <Slot {...methods.slot}></Slot> */}{!!config.contentSplit && (<Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}><div className={style.hoverCursor} onMouseDown={this.handleSplitBarMouseDown}></div>@@ -232,6 +231,7 @@ export class SheetContainer extends Component<BaseSheetContainerProps> {</Container>{/* <Prompt show={true} title="123" content="235" /> */}{/* extend main content */}+ <Slot name="main" {...methods.slot}></Slot></Content><Siderdiff --git a/packages/ui-plugin-sheets/src/View/Toolbar/Const.ts b/packages/ui-plugin-sheets/src/View/Toolbar/Const.tsindex c2db56e735..db573b0f9d 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 = [{- labelLocale: 'fontFamily.TimesNewRoman',+ label: 'fontFamily.TimesNewRoman',style: { 'font-family': 'Times New Roman' },value: 'Times New Roman',selected: true,},{- labelLocale: 'fontFamily.Arial',+ label: 'fontFamily.Arial',style: { 'font-family': 'Arial' },value: 'Arial',},{- labelLocale: 'fontFamily.Tahoma',+ label: 'fontFamily.Tahoma',style: { 'font-family': 'Tahoma' },value: 'Tahoma',},{- labelLocale: 'fontFamily.Verdana',+ label: 'fontFamily.Verdana',style: { 'font-family': 'Verdana' },value: 'Verdana',},{- labelLocale: 'fontFamily.MicrosoftAccorblack',+ label: 'fontFamily.MicrosoftAccorblack',style: { 'font-family': '微软雅黑' },value: '微软雅黑',},{- labelLocale: 'fontFamily.SimSun',+ label: 'fontFamily.SimSun',style: { 'font-family': '宋体' },value: '宋体',},{- labelLocale: 'fontFamily.SimHei',+ label: 'fontFamily.SimHei',style: { 'font-family': '黑体' },value: '黑体',},{- labelLocale: 'fontFamily.Kaiti',+ label: 'fontFamily.Kaiti',style: { 'font-family': '楷体' },value: '楷体',},{- labelLocale: 'fontFamily.FangSong',+ label: 'fontFamily.FangSong',style: { 'font-family': '仿宋' },value: '仿宋',},{- labelLocale: 'fontFamily.NSimSun',+ label: 'fontFamily.NSimSun',style: { 'font-family': '新宋体' },value: '新宋体',},{- labelLocale: 'fontFamily.STXinwei',+ label: 'fontFamily.STXinwei',style: { 'font-family': '华文新魏' },value: '华文新魏',},{- labelLocale: 'fontFamily.STXingkai',+ label: 'fontFamily.STXingkai',style: { 'font-family': '华文行楷' },value: '华文行楷',},{- labelLocale: 'fontFamily.STLiti',+ label: 'fontFamily.STLiti',style: { 'font-family': '华文隶书' },value: '华文隶书',},{- labelLocale: 'fontFamily.HanaleiFill',+ label: 'fontFamily.HanaleiFill',style: { 'font-family': 'HanaleiFill' },value: 'HanaleiFill',},{- labelLocale: 'fontFamily.Anton',+ label: 'fontFamily.Anton',style: { 'font-family': 'Anton' },value: 'Anton',},{- labelLocale: 'fontFamily.Pacifico',+ label: 'fontFamily.Pacifico',style: { 'font-family': 'Pacifico' },value: 'Pacifico',},@@ -150,73 +150,73 @@ export const FONT_FAMILY_CHILDREN = [export const BORDER_LINE_CHILDREN = [{- labelLocale: 'borderLine.borderTop',- customSuffix: {+ label: 'borderLine.borderTop',+ suffix: {name: 'TopBorderIcon',},value: 'top',},{- labelLocale: 'borderLine.borderBottom',- customSuffix: {+ label: 'borderLine.borderBottom',+ suffix: {name: 'BottomBorderIcon',},value: 'bottom',},{- labelLocale: 'borderLine.borderLeft',- customSuffix: {+ label: 'borderLine.borderLeft',+ suffix: {name: 'LeftBorderIcon',},value: 'left',},{- labelLocale: 'borderLine.borderRight',- customSuffix: {+ label: 'borderLine.borderRight',+ suffix: {name: 'RightBorderIcon',},value: 'right',border: true,},{- labelLocale: 'borderLine.borderNone',- customSuffix: {+ label: 'borderLine.borderNone',+ suffix: {name: 'NoneBorderIcon',},value: 'none',},{- labelLocale: 'borderLine.borderAll',- customSuffix: {+ label: 'borderLine.borderAll',+ suffix: {name: 'FullBorderIcon',},value: 'all',selected: true,},{- labelLocale: 'borderLine.borderOutside',- customSuffix: {+ label: 'borderLine.borderOutside',+ suffix: {name: 'OuterBorderIcon',},value: 'outside',},{- labelLocale: 'borderLine.borderInside',- customSuffix: {+ label: 'borderLine.borderInside',+ suffix: {name: 'InnerBorderIcon',},value: 'inside',},{- labelLocale: 'borderLine.borderHorizontal',- customSuffix: {+ label: 'borderLine.borderHorizontal',+ suffix: {name: 'StripingBorderIcon',},value: 'horizontal',},{- labelLocale: 'borderLine.borderVertical',- customSuffix: {+ label: 'borderLine.borderVertical',+ suffix: {name: 'VerticalBorderIcon',},value: 'vertical',@@ -225,71 +225,71 @@ export const BORDER_LINE_CHILDREN = [export const BORDER_SIZE_CHILDREN = [{- labelLocale: 'borderLine.borderNone',+ label: 'borderLine.borderNone',value: BorderStyleTypes.NONE,},{- customLabel: {+ label: {name: 'BorderThin',},value: BorderStyleTypes.THIN,},{- customLabel: {+ label: {name: 'BorderHair',},value: BorderStyleTypes.HAIR,},{- customLabel: {+ label: {name: 'BorderDotted',},value: BorderStyleTypes.DOTTED,},{- customLabel: {+ label: {name: 'BorderDashed',},value: BorderStyleTypes.DASHED,},{- customLabel: {+ label: {name: 'BorderDashDot',},value: BorderStyleTypes.DOTTED,},{- customLabel: {+ label: {name: 'BorderDashDotDot',},value: BorderStyleTypes.DASH_DOT_DOT,},{- customLabel: {+ label: {name: 'BorderMedium',},value: BorderStyleTypes.MEDIUM,},{- customLabel: {+ label: {name: 'BorderMediumDashed',},value: BorderStyleTypes.MEDIUM_DASHED,},{- customLabel: {+ label: {name: 'BorderMediumDashDot',},value: BorderStyleTypes.MEDIUM_DASH_DOT,},{- customLabel: {+ label: {name: 'BorderMediumDashDotDot',},value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,},{- customLabel: {+ label: {name: 'BorderThick',},value: BorderStyleTypes.THICK,@@ -298,42 +298,42 @@ export const BORDER_SIZE_CHILDREN = [export const MERGE_CHILDREN = [{- labelLocale: 'merge.all',+ label: 'merge.all',value: 'all',},{- labelLocale: 'merge.vertical',+ label: 'merge.vertical',value: 'vertical',},{- labelLocale: 'merge.horizontal',+ label: 'merge.horizontal',value: 'horizontal',},{- labelLocale: 'merge.cancel',+ label: 'merge.cancel',value: 'cancel',},];export const HORIZONTAL_ALIGN_CHILDREN = [{- labelLocale: 'align.left',- customSuffix: {+ label: 'align.left',+ suffix: {name: 'LeftAlignIcon',},value: 1,},{- labelLocale: 'align.center',+ label: 'align.center',selected: true,- customSuffix: {+ suffix: {name: 'CenterAlignIcon',},value: 2,},{- labelLocale: 'align.right',- customSuffix: {+ label: 'align.right',+ suffix: {name: 'RightAlignIcon',},value: 3,@@ -342,22 +342,22 @@ export const HORIZONTAL_ALIGN_CHILDREN = [export const VERTICAL_ALIGN_CHILDREN = [{- labelLocale: 'align.top',- customSuffix: {+ label: 'align.top',+ suffix: {name: 'TopVerticalIcon',},value: 1,},{- labelLocale: 'align.middle',- customSuffix: {+ label: 'align.middle',+ suffix: {name: 'CenterVerticalIcon',},value: 2,},{- labelLocale: 'align.bottom',- customSuffix: {+ label: 'align.bottom',+ suffix: {name: 'BottomVerticalIcon',},value: 3,@@ -366,22 +366,22 @@ export const VERTICAL_ALIGN_CHILDREN = [export const TEXT_WRAP_CHILDREN = [{- labelLocale: 'textWrap.overflow',- customSuffix: {+ label: 'textWrap.overflow',+ suffix: {name: 'OverflowIcon',},value: 1,},{- labelLocale: 'textWrap.wrap',- customSuffix: {+ label: 'textWrap.wrap',+ suffix: {name: 'BrIcon',},value: 3,},{- labelLocale: 'textWrap.clip',- customSuffix: {+ label: 'textWrap.clip',+ suffix: {name: 'CutIcon',},value: 2,@@ -390,43 +390,43 @@ export const TEXT_WRAP_CHILDREN = [export const TEXT_ROTATE_CHILDREN = [{- labelLocale: 'textRotate.none',- customSuffix: {+ label: 'textRotate.none',+ suffix: {name: 'TextRotateIcon',},value: 0,},{- labelLocale: 'textRotate.angleUp',- customSuffix: {+ label: 'textRotate.angleUp',+ suffix: {name: 'TextRotateAngleUpIcon',},value: -45,},{- labelLocale: 'textRotate.angleDown',- customSuffix: {+ label: 'textRotate.angleDown',+ suffix: {name: 'TextRotateAngleDownIcon',},value: 45,},{- labelLocale: 'textRotate.vertical',- customSuffix: {+ label: 'textRotate.vertical',+ suffix: {name: 'TextRotateVerticalIcon',},value: 'v',},{- labelLocale: 'textRotate.rotationUp',- customSuffix: {+ label: 'textRotate.rotationUp',+ suffix: {name: 'TextRotateRotationUpIcon',},value: -90,},{- labelLocale: 'textRotate.rotationDown',- customSuffix: {+ label: 'textRotate.rotationDown',+ suffix: {name: 'TextRotateRotationDownIcon',},value: 90,diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsxindex aacc52a51f..256535aa9d 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, findLocale, PreactContext, Select, Tooltip } from '@univerjs/base-ui';+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, PreactContext, Select, Tooltip } from '@univerjs/base-ui';import { SheetUIPlugin } from '../..';import { SHEET_UI_PLUGIN_NAME } from '../../Basics';import { IToolbarItemProps } from '../../Controller';@@ -143,35 +143,6 @@ export class Toolbar extends Component<IProps, IState> {}};- 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 = findLocale<IToolbarItemProps>(toolList[i], this.getLocale.bind(this));- // 优先寻找自定义组件- if (item.customLabel) {- const Label = componentManager?.get(item.customLabel.name);- if (Label) {- const props = item.customLabel.props ?? {};- item.label = <Label {...props} />;- }- }-- if (item.customSuffix) {- const Suffix = componentManager?.get(item.customSuffix.name);- if (Suffix) {- const props = item.customSuffix.props ?? {};- item.suffix = <Suffix {...props} />;- }- }-- if (item.children) {- item.children = this.resetLabel(item.children);- }- }- return toolList;- };-setToolbar = (toolList: any[]) => {// toolList = this.resetLabel(toolList);@@ -211,14 +182,13 @@ export class Toolbar extends Component<IProps, IState> {// 渲染domgetToolbarList(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'}>+ <Tooltip title={item.tooltip} placement={'bottom'}><Button unActive={item.unActive} className={styles.textButton} type="text" active={item.active} onClick={item.onClick}>- {item.label}+ {this.getLabel(item.label)}</Button></Tooltip>);@@ -227,12 +197,11 @@ export class Toolbar extends Component<IProps, IState> {if (item.show) {return (<Select- tooltip={this.getLocale(item.tooltip)}+ tooltip={item.tooltip}type={item.type}display={item.display}children={item.children}- customLabel={item.customLabel}- customSuffix={item.customSuffix}+ suffix={item.suffix}label={item.label}onClick={item.onClick}onPressEnter={item.onPressEnter}@@ -257,7 +226,7 @@ export class Toolbar extends Component<IProps, IState> {{this.getToolbarList(defaultToolList)}<div ref={this.moreBtnRef} className={styles.moreButton} style={{ visibility: moreToolList.length ? 'visible' : 'hidden' }}>- <Tooltip title={this.getLocale('toolbar.toolMoreTip')} placement={'bottom'}>+ <Tooltip title={'toolbar.toolMoreTip'} placement={'bottom'}><Button type="text" onClick={this.showMore}><div style={{ fontSize: '14px' }}>{this.getLocale('toolbar.toolMore')}</div></Button>