Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix:(numfmtplugin/ui)
tonytonychopper1230f9b6364ec51
diff --git a/packages/base-component/src/BaseComponent.ts b/packages/base-component/src/BaseComponent.tsindex 0a94d69a82..67483dbbbf 100644--- a/packages/base-component/src/BaseComponent.ts+++ b/packages/base-component/src/BaseComponent.ts@@ -1,9 +1,6 @@import { BasePlugin } from '@univer/core';-import { ISelectButtonType } from './Enum/ISelectButton';-import { ISlotElementType } from './Enum/ISlotElement';-import { ComponentClass, ForwardFn, RefObject } from './Framework';-import { IMainProps } from './IData';-import { BaseIconProps, Description } from './Components';+import { ComponentClass, ForwardFn } from './Framework';+import { Description } from './Components';// TODO Button const enum@@ -55,117 +52,6 @@ export interface BaseCellRangeModalProps extends BaseComponentProps {placeholderProps?: string;valueProps?: string;}-export interface BaseDemoProps extends BaseComponentProps {- onClick?: (e: MouseEvent) => void;-}-export interface IToolBarItemProps extends BaseComponentProps {- /**- * locale info- */- locale?: string;- /**- * icon locale info- */- iconName?: string;- /**- * show info- */- label?: string | JSX.Element;- /**- * value- */- value?: string | number;-- /**- * is selected- */- selected?: boolean;- /**- * icon- */- icon?: JSX.Element | string | null | undefined;-- /**- * icon props for the icon represented by the string- */- iconProps?: BaseIconProps;-- /**- * type of item- */- type?: ISlotElementType;-- /**- * tooltip info- */- tooltip?: string;-- /**- *- */- tooltipRight?: string;-- /**- * top split line- */- border?: boolean;-- /**- * is show- */- show?: boolean;-- /**- * child item- */- children?: IToolBarItemProps[];-- /**- * click event listener- */- onClick?: (...arg: any[]) => void;-- /**- * key up event listener- */- onKeyUp?: (...arg: any[]) => void;-- /**- * trigger update label- */- triggerUpdate?: (func: Function) => void;-- /**- * style- */- style?: Record<string, string>;-- /**- * apply to input box- */- needChange?: boolean;-- /**- * type of select element- */- selectType?: ISelectButtonType;-- // TODO: what is meaning- slot?: {- header?: IMainProps;- footer?: IMainProps;- };-}--export interface BaseToolBarProps extends BaseComponentProps {- style?: JSX.CSSProperties;- toolList: IToolBarItemProps[];- forwardRefs?: RefObject<HTMLElement>;- func?: {- addButton: Function;- };-}-// component classexport interface ButtonComponent extends BaseComponent<BaseButtonProps> {render(): JSXComponent<BaseButtonProps>;@@ -173,16 +59,6 @@ export interface ButtonComponent extends BaseComponent<BaseButtonProps> {export interface CellRangeModalComponent extends BaseComponent<BaseCellRangeModalProps> {render(): JSXComponent<BaseCellRangeModalProps>;}-export interface DemoComponent extends BaseComponent<BaseDemoProps> {- render(): JSXComponent<BaseDemoProps>;-}--// export interface SheetContainerComponent extends BaseComponent<BaseSheetContainerProps> {-// render(): JSXComponent<BaseSheetContainerProps>;-// }-export interface ToolBarComponent extends BaseComponent<BaseToolBarProps> {- render(): JSXComponent<BaseToolBarProps>;-}// component typeexport type PropsFrom<T> = T extends BaseComponent<infer Props> ? Props : void;diff --git a/packages/base-component/src/Components/Description.ts b/packages/base-component/src/Components/Description.tsindex 7e4d8592d1..36499091f1 100644--- a/packages/base-component/src/Components/Description.ts+++ b/packages/base-component/src/Components/Description.ts@@ -3,7 +3,7 @@ import { AvatarComponent } from './Avatar';import { CheckboxComponent, CheckboxGroupComponent } from './Checkbox';import { ColorPickerCircleButtonComponent } from './ColorPickerCircleButton';import { SiderModalComponent } from './SiderModal';-import { ButtonComponent, CellRangeModalComponent, DemoComponent } from '../BaseComponent';+import { ButtonComponent, CellRangeModalComponent } from '../BaseComponent';import { IconComponent } from './Icon';import { InputComponent } from './Input';import { TabComponent, TabPaneComponent } from './Tab';@@ -35,7 +35,6 @@ export interface Description {Footer: FooterComponent;Content: ContentComponent;Sider: SiderComponent;- Demo: DemoComponent;Checkbox: CheckboxComponent;CheckboxGroup: CheckboxGroupComponent;ColorPicker: ColorPickerComponent;diff --git a/packages/base-formula-engine/src/FormulaEnginePlugin.tsx b/packages/base-formula-engine/src/FormulaEnginePlugin.tsxindex 34f1b40934..c5bec85572 100644--- a/packages/base-formula-engine/src/FormulaEnginePlugin.tsx+++ b/packages/base-formula-engine/src/FormulaEnginePlugin.tsx@@ -1,6 +1,5 @@import { Context, Plugin, PLUGIN_NAMES } from '@univer/core';-import { IToolBarItemProps, ISlotElement } from '@univer/base-component';import { IOCContainer } from '@univer/core';import { LexerTreeMaker } from './Analysis/Lexer';import { FormulaEnginePluginObserver } from './Basics/Observer';diff --git a/packages/base-sheets/package.json b/packages/base-sheets/package.jsonindex be640a6afa..7ec1d9ea96 100644--- a/packages/base-sheets/package.json+++ b/packages/base-sheets/package.json@@ -52,6 +52,7 @@"@univer/common-plugin-data": "workspace:^0.0.1","@univer/core": "workspace:^0.0.1","@univer/sheets-plugin-clipboard": "workspace:^0.0.1",+ "@univer/sheets-plugin-find": "workspace:^0.0.1","@univer/sheets-plugin-formula": "workspace:^0.0.1","@univer/sheets-plugin-numfmt": "workspace:^0.0.1","@univer/style-universheet": "workspace:^0.0.1",diff --git a/packages/base-sheets/src/Basics/Observer.ts b/packages/base-sheets/src/Basics/Observer.tsindex c6ebfb36fe..21e6d3a8ca 100644--- a/packages/base-sheets/src/Basics/Observer.ts+++ b/packages/base-sheets/src/Basics/Observer.ts@@ -4,7 +4,7 @@ import { SelectionControl } from '../Controller/Selection/SelectionController';import { SheetContainer } from '../View/UI/SheetContainer';import { ToolBar } from '../View/UI/ToolBar/ToolBar';import { LineColor } from '../View/UI/Common/Line/LineColor';-import { ToolBar1 } from '../View/UI/ToolBar/ToolBar1';+import { ModalGroup } from '../View/UI/ModalGroup/ModalGroup';interface ISelectionControlFillConfig {}@@ -37,7 +37,8 @@ export type SpreadsheetPluginObserve = {onChangeCurrentSheetObserver: Observable<string>;onToolBarDidMountObservable: Observable<ToolBar>;- onToolBar1DidMountObservable: Observable<ToolBar1>;++ onModalGroupDidMountObservable: Observable<ModalGroup>;onLineColorDidMountObservable: Observable<LineColor>;@@ -72,6 +73,7 @@ export function uninstall(plugin: Plugin) {plugin.deleteObserve('onChangeSelectionObserver');plugin.deleteObserve('onToolBarDidMountObservable');+ plugin.deleteObserve('onModalGroupDidMountObservable');plugin.deleteObserve('onChangeCurrentSheetObserver');plugin.deleteObserve('onSheetContainerDidMountObservable');@@ -106,7 +108,8 @@ export function install(plugin: Plugin) {plugin.pushToObserve('onChangeCurrentSheetObserver');plugin.pushToObserve('onToolBarDidMountObservable');- plugin.pushToObserve('onToolBar1DidMountObservable');+ plugin.pushToObserve('onModalGroupDidMountObservable');+plugin.pushToObserve('onLineColorDidMountObservable');plugin.pushToObserve('onSheetBarDidMountObservable');plugin.pushToObserve('onCountBarDidMountObservable');diff --git a/packages/base-sheets/src/Controller/CellEditorController.ts b/packages/base-sheets/src/Controller/CellEditorController.tsindex 25e547ebd7..fe0a6a2c4f 100644--- a/packages/base-sheets/src/Controller/CellEditorController.ts+++ b/packages/base-sheets/src/Controller/CellEditorController.ts@@ -1,4 +1,4 @@-import { $$, getRefElement, handleDomToJson, handleJsonToDom, IMainProps, ISlotElement, handleStyleToString, handleStringToStyle } from '@univer/base-component';+import { getRefElement, handleDomToJson, handleJsonToDom, IMainProps, ISlotElement, handleStyleToString, handleStringToStyle, $$ } from '@univer/base-component';import { Direction, IDocumentData, IRangeData, IStyleData, Nullable, ICellData, Tools, isKeyPrintable } from '@univer/core';import { DeviceType, IKeyboardEvent, IMouseEvent, IPointerEvent } from '@univer/base-render';import { RichText } from '@univer/style-universheet';diff --git a/packages/base-sheets/src/Controller/ModalGroupController.ts b/packages/base-sheets/src/Controller/ModalGroupController.tsnew file mode 100644index 0000000000..847104d4bf--- /dev/null+++ b/packages/base-sheets/src/Controller/ModalGroupController.ts@@ -0,0 +1,37 @@+import { SpreadsheetPlugin } from '../SpreadsheetPlugin';+import { ModalGroup } from '../View/UI/ModalGroup/ModalGroup';++export type ModalGroupProps = string[];++export class ModalGroupController {+ private _ModalGroup: ModalGroupProps;++ private _ModalGroupComponent: ModalGroup;++ private _plugin: SpreadsheetPlugin;++ constructor(plugin: SpreadsheetPlugin) {+ this._plugin = plugin;++ this._ModalGroup = [];++ this.init();+ }++ init() {+ this._plugin.getObserver('onModalGroupDidMountObservable')?.add((component) => {+ //初始化视图+ this._ModalGroupComponent = component;+ });+ }++ addModal(name: string, component: any) {+ const index = this._ModalGroup.findIndex((item) => item === name);+ if (index < 0) {+ this._plugin.registerComponent(name, component);+ this._ModalGroup.push(name);++ this._ModalGroupComponent.setModalGroup(this._ModalGroup);+ }+ }+}diff --git a/packages/base-sheets/src/Controller/ToolBarController.ts b/packages/base-sheets/src/Controller/ToolBarController.tsindex 2417aedd17..780dbdd25a 100644--- a/packages/base-sheets/src/Controller/ToolBarController.ts+++ b/packages/base-sheets/src/Controller/ToolBarController.ts@@ -1,22 +1,30 @@-import { BaseComponentRender, BaseComponentSheet, ISelectButton, IToolBarItemProps } from '@univer/base-component';-import { Tools, BorderType, BorderStyleTypes, ICellData, IStyleData, HorizontalAlign, VerticalAlign, WrapStrategy, DEFAULT_STYLES } from '@univer/core';+import { BaseComponentRender, BaseComponentSheet } from '@univer/base-component';+import { Tools, BorderType, BorderStyleTypes, HorizontalAlign, VerticalAlign, WrapStrategy, DEFAULT_STYLES } from '@univer/core';+import { ColorPicker } from '@univer/style-universheet';import { SpreadsheetPlugin } from '../SpreadsheetPlugin';import { defaultLayout, ILayout } from '../View/UI/SheetContainer';++import { SelectionControl } from './Selection/SelectionController';import {BORDER_LINE_CHILDREN,FONT_FAMILY_CHILDREN,FONT_SIZE_CHILDREN,HORIZONTAL_ALIGN_CHILDREN,MERGE_CHILDREN,- MORE_FORMATS_CHILDREN,TEXT_ROTATE_CHILDREN,TEXT_WRAP_CHILDREN,VERTICAL_ALIGN_CHILDREN,} from '../View/UI/ToolBar/Const';-import { ToolBarModel } from '../Model/ToolBarModel';-import { ToolBar } from '../View/UI/ToolBar/ToolBar';-import { SelectionControl } from './Selection/SelectionController';-import { SelectionModel } from '../Model/SelectionModel';+import styles from '../View/UI/ToolBar/index.module.less';+import { LineColor } from '../View/UI/Common/Line/LineColor';+import { SelectionModel } from '../Model';+import { IToolBarItemProps, ToolBarModel } from '../Model/ToolBarModel';+import { ToolBar } from '../View/UI/ToolBar';++interface BorderInfo {+ color: string;+ width: string;+}/***@@ -28,363 +36,287 @@ export class ToolBarController {private _toolBarComponent: ToolBar;+ private _toolList: IToolBarItemProps[];++ private _lineColor: LineColor;+Render: BaseComponentRender;- // all functions need trigger to update tool bar status- triggerUpdateMap: Map<string, Function> = new Map();+ private _borderInfo: BorderInfo; //存储边框信息constructor(plugin: SpreadsheetPlugin) {this._plugin = plugin;- const component = this._plugin.context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();+ const pluginName = this._plugin.getPluginName();++ this.initRegisterComponent();const config =this._plugin.config.layout === 'auto'? Tools.deepClone(defaultLayout.toolBarConfig): Tools.deepMerge(defaultLayout.toolBarConfig, (this._plugin.config.layout as ILayout).toolBarConfig);- const toolList: IToolBarItemProps[] = [+ this._borderInfo = {+ color: '#000',+ width: '1',+ };++ this._toolList = [{- locale: 'undo',- type: 'single',- icon: 'ForwardIcon',+ toolbarType: 1,+ tooltipLocale: 'toolbar.undo',+ customLabel: {+ name: 'ForwardIcon',+ },show: config.undoRedo,onClick: () => {this.setUndo();},},{- locale: 'redo',- type: 'single',- icon: 'BackIcon',+ toolbarType: 1,+ tooltipLocale: 'toolbar.redo',+ customLabel: {+ name: 'BackIcon',+ },show: config.undoRedo,onClick: () => {this.setRedo();},},- {- locale: 'paintFormat',- type: 'single',- icon: 'FormatIcon',- show: config.paintFormat,- },- {- locale: 'currencyFormat',- type: 'single',- icon: 'MoneyIcon',- show: config.currencyFormat,- },- {- locale: 'percentageFormat',- type: 'single',- icon: 'PercentIcon',- show: config.percentageFormat,- },- {- locale: 'numberDecrease',- type: 'single',- icon: 'ReduceNumIcon',- show: config.numberDecrease,- },- {- locale: 'numberIncrease',- type: 'single',- icon: 'AddNumIcon',- show: config.numberIncrease,- },- {- locale: 'moreFormats',- type: 'select',- icon: 'NextIcon',- needChange: true,- show: config.moreFormats,- // onClick: this.handleClickMoreFormats,- border: true,- children: [- ...MORE_FORMATS_CHILDREN,- {- locale: 'defaultFmt.CustomFormats.text',- border: true,- selected: false,- icon: 'RightIcon',- children: [- {- locale: 'format.moreCurrency',- onClick: (e: string) => {- // this.showFormatModal(e, 'format.titleCurrency');- },- },- {- locale: 'format.moreDateTime',- onClick: (e: string) => {- // this.showFormatModal(e, 'format.titleDateTime');- },- },- {- locale: 'format.moreNumber',- onClick: (e: string) => {- // this.showFormatModal(e, 'format.titleNumber');- },- },- ],- },- ],- },++ // {+ // toolbarType: 1,+ // tooltipLocale: 'paintFormat',+ // label: 'FormatIcon',+ // show: config.paintFormat,+ // },+ // {+ // toolbarType: 1,+ // tooltipLocale: 'currencyFormat',+ // label: 'MoneyIcon',+ // show: config.currencyFormat,+ // },+ // {+ // toolbarType: 1,+ // tooltipLocale: 'percentageFormat',+ // label: 'PercentIcon',+ // show: config.percentageFormat,+ // },+ // {+ // toolbarType: 1,+ // tooltipLocale: 'numberDecrease',+ // label: 'ReduceNumIcon',+ // show: config.numberDecrease,+ // },+ // {+ // toolbarType: 1,+ // tooltipLocale: 'numberIncrease',+ // label: 'AddNumIcon',+ // show: config.numberIncrease,+ // },{- locale: 'font',- type: 'select',- icon: 'NextIcon',+ type: 0,+ tooltipLocale: 'font',+ selectClassName: styles.selectLabelString,show: config.font,- needChange: true,border: true,onClick: (fontFamily: string) => {this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.notifyObservers(fontFamily);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('font', cb);- },children: FONT_FAMILY_CHILDREN,},-{- type: 'select',- locale: 'fontSize',+ type: 1,+ tooltipLocale: 'fontSize',label: String(DEFAULT_STYLES.fs),show: config.fontSize,- selectType: ISelectButton.INPUT_NUMBER,- needChange: true,- border: false,- onKeyUp: (fontSize: number) => {- this._plugin.getObserver('onAfterChangeFontSizeObservable')?.notifyObservers(fontSize);- },onClick: (fontSize: number) => {this._plugin.getObserver('onAfterChangeFontSizeObservable')?.notifyObservers(fontSize);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('fontSize', cb);+ onKeyUp: (fontSize: number) => {+ this._plugin.getObserver('onAfterChangeFontSizeObservable')?.notifyObservers(fontSize);},- icon: 'NextIcon',children: FONT_SIZE_CHILDREN,},-{- locale: 'bold',- type: 'single',- icon: 'BoldIcon',+ toolbarType: 1,+ tooltipLocale: 'bold',+ customLabel: {+ name: 'BoldIcon',+ },show: config.bold,- selected: false,onClick: (isBold: boolean) => {this._plugin.getObserver('onAfterChangeFontWeightObservable')?.notifyObservers(isBold);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('bold', cb);- },},-{- locale: 'italic',- type: 'single',- icon: 'ItalicIcon',+ toolbarType: 1,+ tooltipLocale: 'italic',+ customLabel: {+ name: 'ItalicIcon',+ },show: config.italic,- selected: false,onClick: (isItalic: boolean) => {this._plugin.getObserver('onAfterChangeFontItalicObservable')?.notifyObservers(isItalic);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('italic', cb);- },},{- locale: 'strikethrough',- type: 'single',- icon: 'DeleteLineIcon',+ toolbarType: 1,+ tooltipLocale: 'strikethrough',+ customLabel: {+ name: 'DeleteLineIcon',+ },show: config.strikethrough,- selected: false,onClick: (isStrikethrough: boolean) => {this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.notifyObservers(isStrikethrough);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('strikethrough', cb);- },},{- locale: 'underline',- type: 'single',- icon: 'UnderLineIcon',+ toolbarType: 1,+ tooltipLocale: 'underline',+ customLabel: {+ name: 'UnderLineIcon',+ },show: config.underline,- selected: false,onClick: (isItalic: boolean) => {this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.notifyObservers(isItalic);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('underline', cb);- },},{- locale: 'textColor',- type: 'select',- label: 'TextColorIcon',- icon: 'NextIcon',- selectType: ISelectButton.COLOR,+ type: 2,+ tooltipLocale: 'textColor',+ customLabel: {+ name: 'TextColorIcon',+ },show: config.textColor,- slot: {},onClick: (color: string) => {this._plugin.getObserver('onAfterChangeFontColorObservable')?.notifyObservers(color);},},{- locale: 'fillColor',- type: 'select',- label: 'FillColorIcon',- icon: 'NextIcon',- selectType: ISelectButton.COLOR,+ type: 2,+ tooltipLocale: 'fillColor',+ customLabel: {+ name: 'FillColorIcon',+ },show: config.fillColor,- slot: {},onClick: (color: string) => {this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.notifyObservers(color);},},-{- locale: 'borderLine',- type: 'select',- label: 'FullBorderIcon',- icon: 'NextIcon',+ type: 3,+ display: 1,show: config.border,- needChange: true,- selectType: ISelectButton.DOUBLE,- onClick: (type, color, style) => {- this.setBorder(type, color, style);+ onClick: (type) => {+ // console.dir(type);+ // console.dir(this._borderInfo);},- children: BORDER_LINE_CHILDREN,+ children: [+ ...BORDER_LINE_CHILDREN,+ {+ customLabel: {+ name: pluginName + LineColor.name,+ },+ unSelectable: true,+ className: styles.selectColorPickerParent,+ children: [+ {+ customLabel: {+ name: pluginName + ColorPicker.name,+ props: { onClick: (color: string, e: MouseEvent) => this.handleLineColor(color, e) },+ },+ className: styles.selectColorPicker,+ onClick: this.handleLineColor,+ },+ ],+ },+ // {+ // locale: 'borderLine.borderSize',+ // suffix: 'RightIcon',+ // value: 1,+ // unSelectable: true,+ // children: [+ // { locale: 'borderLine.borderNone', value: 0 },+ // { label: 'BorderThin', value: 1 },+ // { label: 'BorderHair', value: 2 },+ // { label: 'BorderDotted', value: 3 },+ // { label: 'BorderDashed', value: 4 },+ // { label: 'BorderDashDot', value: 5 },+ // { label: 'BorderDashDotDot', value: 6 },+ // { label: 'BorderMedium', value: 7 },+ // { label: 'BorderMediumDashed', value: 8 },+ // { label: 'BorderMediumDashDot', value: 9 },+ // { label: 'BorderMediumDashDotDot', value: 10 },+ // { label: 'BorderThick', value: 12 },+ // ],+ // },+ ],},-{- locale: 'mergeCell',- type: 'select',- label: 'MergeIcon',- icon: 'NextIcon',+ type: 5,+ tooltipLocale: 'mergeCell',+ customLabel: {+ name: 'MergeIcon',+ },show: config.mergeCell,- selectType: ISelectButton.DOUBLE,onClick: (value: string) => {this.setMerge(value);},children: MERGE_CHILDREN,},-{- locale: 'horizontalAlignMode',- type: 'select',- label: 'LeftAlignIcon',- icon: 'NextIcon',+ type: 3,+ tooltipLocale: 'horizontalAlignMode',+ display: 1,show: config.horizontalAlignMode,- selectType: ISelectButton.DOUBLE,- needChange: true,onClick: (value: HorizontalAlign) => {this.setHorizontalAlignment(value);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('horizontalAlign', cb);- },children: HORIZONTAL_ALIGN_CHILDREN,},{- locale: 'verticalAlignMode',- type: 'select',- label: 'BottomVerticalIcon',- icon: 'NextIcon',+ type: 3,+ tooltipLocale: 'verticalAlignMode',+ display: 1,show: config.verticalAlignMode,- selectType: ISelectButton.DOUBLE,- needChange: true,onClick: (value: VerticalAlign) => {this.setVerticalAlignment(value);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('verticalAlign', cb);- },children: VERTICAL_ALIGN_CHILDREN,},{- locale: 'textWrapMode',- type: 'select',- label: 'CutIcon',- icon: 'NextIcon',+ type: 3,+ tooltipLocale: 'textWrapMode',+ display: 1,show: config.textWrapMode,- selectType: ISelectButton.DOUBLE,- needChange: true,onClick: (value: WrapStrategy) => {this.setWrapStrategy(value);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('textWrap', cb);- },children: TEXT_WRAP_CHILDREN,},{- locale: 'textRotateMode',- type: 'select',- label: 'TextRotateIcon',- icon: 'NextIcon',+ type: 3,+ tooltipLocale: 'textRotateMode',+ display: 1,show: config.textRotateMode,- selectType: ISelectButton.DOUBLE,- needChange: true,onClick: (value: number | string) => {this.setTextRotation(value);},- triggerUpdate: (cb: Function) => {- this.triggerUpdateMap.set('textRotate', cb);- },children: TEXT_ROTATE_CHILDREN,},-- // {- // locale: 'print',- // type: 'select',- // label: 'PrintIcon',- // show: true,- // icon: 'NextIcon',- // children: [- // {- // locale: 'print.menuItemPrint',- // icon: 'PrintIcon',- // },- // {- // locale: 'print.menuItemAreas',- // icon: 'PrintAreaIcon',- // border: true,- // },- // {- // locale: 'print.menuItemRows',- // icon: 'PrintTitleIcon',- // },- // {- // locale: 'print.menuItemColumns',- // icon: 'PrintTitleIcon',- // },- // ],- // },];this._toolBarModel = new ToolBarModel();this._toolBarModel.config = config;- this._toolBarModel.toolList = toolList;+ this._toolBarModel.toolList = this._toolList;- this._initialize();+ this.init();}- private _initialize() {- // this._plugin.sheetContainerConfig.toolList = [];- // this._plugin.sheetContainerConfig.toolList = this._toolBarModel.toolList;-- // this._plugin.context- // .getObserverManager()- // .getObserver<SheetContainer>('onSheetContainerDidMountObservable', 'workbook')- // ?.add((component) => {- // this._sheetContainer = component;- // this._sheetContainer.setToolBar(this._toolBarModel.toolList);- // });+ init() {this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.add((value: string) => {if (!this._plugin.getCellEditorControl().isEditMode) {this.setFontFamily(value);@@ -443,27 +375,23 @@ export class ToolBarController {});this._plugin.getObserver('onToolBarDidMountObservable')?.add((component) => {+ //初始化视图this._toolBarComponent = component;+ this.resetToolBarList();+ });- this._toolBarComponent.setToolBar(this._toolBarModel.toolList);-- // this._toolBarComponent.setState((prevState) => ({- // defaultToolList: prevState.toolList,- // index: prevState.toolList.length,- // }));+ this._plugin.getObserver('onLineColorDidMountObservable')?.add((component) => {+ //初始化视图+ this._lineColor = component;});this._plugin.context.getObserverManager().getObserver('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- // this._sheetContainer.setToolBar(this._toolBarModel.toolList);- });+ ?.add(() => {});// Monitor selection changes, update toolbar button status and values TODO: 根据不同的焦点对象,接受this._plugin.getObserver('onChangeSelectionObserver')?.add((selectionControl: SelectionControl) => {- // console.log('this._plugin.getSelectionManager().getActiveRangeList()?.getRangeList()', this._plugin.getSelectionManager().getActiveRangeList()?.getRangeList());-const currentCell = selectionControl.model.currentCell;if (currentCell) {@@ -489,59 +417,123 @@ export class ToolBarController {}const cellData = this._plugin.getWorkbook().getActiveSheet().getRange(currentRangeData).getObjectValue({ isIncludeStyle: true });- this.triggerAllUpdate(cellData);}});}+ initRegisterComponent() {+ const component = this._plugin.context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ const pluginName = this._plugin.getPluginName();+ this.Render = component.getComponentRender();+ const registerIcon = {+ ForwardIcon: this.Render.renderFunction('ForwardIcon'),+ BackIcon: this.Render.renderFunction('BackIcon'),+ BoldIcon: this.Render.renderFunction('BoldIcon'),+ ItalicIcon: this.Render.renderFunction('ItalicIcon'),+ DeleteLineIcon: this.Render.renderFunction('DeleteLineIcon'),+ UnderLineIcon: this.Render.renderFunction('UnderLineIcon'),+ TextColorIcon: this.Render.renderFunction('TextColorIcon'),+ FillColorIcon: this.Render.renderFunction('FillColorIcon'),+ MergeIcon: this.Render.renderFunction('MergeIcon'),+ TopBorderIcon: this.Render.renderFunction('TopBorderIcon'),+ BottomBorderIcon: this.Render.renderFunction('BottomBorderIcon'),+ LeftBorderIcon: this.Render.renderFunction('LeftBorderIcon'),+ RightBorderIcon: this.Render.renderFunction('RightBorderIcon'),+ NoneBorderIcon: this.Render.renderFunction('NoneBorderIcon'),+ FullBorderIcon: this.Render.renderFunction('FullBorderIcon'),+ OuterBorderIcon: this.Render.renderFunction('OuterBorderIcon'),+ InnerBorderIcon: this.Render.renderFunction('InnerBorderIcon'),+ StripingBorderIcon: this.Render.renderFunction('StripingBorderIcon'),+ VerticalBorderIcon: this.Render.renderFunction('VerticalBorderIcon'),+ LeftAlignIcon: this.Render.renderFunction('LeftAlignIcon'),+ CenterAlignIcon: this.Render.renderFunction('CenterAlignIcon'),+ RightAlignIcon: this.Render.renderFunction('RightAlignIcon'),+ TopVerticalIcon: this.Render.renderFunction('TopVerticalIcon'),+ CenterVerticalIcon: this.Render.renderFunction('CenterVerticalIcon'),+ BottomVerticalIcon: this.Render.renderFunction('BottomVerticalIcon'),+ OverflowIcon: this.Render.renderFunction('OverflowIcon'),+ BrIcon: this.Render.renderFunction('BrIcon'),+ CutIcon: this.Render.renderFunction('CutIcon'),+ TextRotateIcon: this.Render.renderFunction('TextRotateIcon'),+ TextRotateAngleUpIcon: this.Render.renderFunction('TextRotateAngleUpIcon'),+ TextRotateAngleDownIcon: this.Render.renderFunction('TextRotateAngleDownIcon'),+ TextRotateVerticalIcon: this.Render.renderFunction('TextRotateVerticalIcon'),+ TextRotateRotationUpIcon: this.Render.renderFunction('TextRotateRotationUpIcon'),+ TextRotateRotationDownIcon: this.Render.renderFunction('TextRotateRotationDownIcon'),+ };++ // 注册自定义组件+ this._plugin.registerComponent(pluginName + LineColor.name, LineColor);+ this._plugin.registerComponent(pluginName + ColorPicker.name, ColorPicker);+ for (let k in registerIcon) {+ this._plugin.registerComponent(k, registerIcon[k]);+ }+ }++ resetLocale(toolList: any[]) {+ const locale = this._plugin.context.getLocale();++ for (let i = 0; i < toolList.length; i++) {+ const item = toolList[i];+ if (item.tooltipLocale) {+ item.tooltip = locale.get(item.tooltipLocale);+ }+ if (item.locale) {+ item.label = locale.get(item.locale);+ }+ if (item.suffixLocale) {+ item.suffix = locale.get(item.suffixLocale);+ }+ if (item.children) {+ item.children = this.resetLocale(item.children);+ }+ }+ return toolList;+ }++ resetToolBarList() {+ const toolList = this.resetLocale(this._toolList);+ this._toolBarComponent.setToolBar(toolList);+ }+setRedo() {this._plugin.getContext().getCommandManager().redo();- // // this._plugin.getMainComponent().makeDirty(true);}setUndo() {this._plugin.getContext().getCommandManager().undo();- // // this._plugin.getMainComponent().makeDirty(true);}setFontColor(value: string) {this._plugin.getSelectionManager().getActiveRangeList()?.setFontColor(value);- // this._plugin.getMainComponent().makeDirty(true);}setBackground(value: string) {this._plugin.getSelectionManager().getActiveRangeList()?.setBackground(value);- // this._plugin.getMainComponent().makeDirty(true);}setFontSize(value: number) {this._plugin.getSelectionManager().getActiveRangeList()?.setFontSize(value);- // this._plugin.getMainComponent().makeDirty(true);}setFontFamily(value: string) {this._plugin.getSelectionManager().getActiveRangeList()?.setFontFamily(value);- // this._plugin.getMainComponent().makeDirty(true);}setFontWeight(value: boolean) {this._plugin.getSelectionManager().getActiveRangeList()?.setFontWeight(value);- // this._plugin.getMainComponent().makeDirty(true);}setFontStyle(value: boolean) {this._plugin.getSelectionManager().getActiveRangeList()?.setFontStyle(value);- // this._plugin.getMainComponent().makeDirty(true);}setStrikeThrough(value: boolean) {this._plugin.getSelectionManager().getActiveRangeList()?.setStrikeThrough(value);- // this._plugin.getMainComponent().makeDirty(true);}setUnderline(value: boolean) {this._plugin.getSelectionManager().getActiveRangeList()?.setUnderline(value);- // this._plugin.getMainComponent().makeDirty(true);}setMerge(value: string) {@@ -569,28 +561,24 @@ export class ToolBarController {}// update data- // this._plugin.getCanvasView().updateToSheet(this._plugin.getContext().getWorkBook().getActiveSheet()!);+ this._plugin.getCanvasView().updateToSheet(this._plugin.getContext().getWorkBook().getActiveSheet()!);// update render// this._plugin.getMainComponent().makeDirty(true);}setHorizontalAlignment(value: HorizontalAlign) {this._plugin.getSelectionManager().getActiveRangeList()?.setHorizontalAlignment(value);- // this._plugin.getMainComponent().makeDirty(true);}setVerticalAlignment(value: VerticalAlign) {this._plugin.getSelectionManager().getActiveRangeList()?.setVerticalAlignment(value);- // this._plugin.getMainComponent().makeDirty(true);}setWrapStrategy(value: WrapStrategy) {this._plugin.getSelectionManager().getActiveRangeList()?.setWrapStrategy(value);- // this._plugin.getMainComponent().makeDirty(true);}setTextRotation(value: number | string) {- // verticalif (value === 'v') {this._plugin.getSelectionManager().getActiveRangeList()?.setVerticalText(1);} else {@@ -599,8 +587,6 @@ export class ToolBarController {.getActiveRangeList()?.setTextRotation(value as number);}-- // this._plugin.getMainComponent().makeDirty(true);}setBorder(type: BorderType, color: string, style: BorderStyleTypes) {@@ -619,72 +605,21 @@ export class ToolBarController {this._plugin.getContext().getWorkBook().getActiveSheet().getRange(range).setBorderByType(type, color, style);});- // update data- // this._plugin.getCanvasView().updateToSheet(this._plugin.getContext().getWorkBook().getActiveSheet()!);- // update render- // this._plugin.getMainComponent().makeDirty(true);+ this._plugin.getCanvasView().updateToSheet(this._plugin.getContext().getWorkBook().getActiveSheet()!);}}- triggerAllUpdate(cellData: ICellData) {- if (!cellData) {- cellData = {- s: {},- };- }- const style = (cellData.s as IStyleData) || {};-- for (const [key, triggerUpdate] of this.triggerUpdateMap) {- let f;- switch (key) {- case 'font':- f = style.ff || DEFAULT_STYLES.ff;- triggerUpdate(f);- break;-- case 'fontSize':- f = style.fs || DEFAULT_STYLES.fs;- triggerUpdate(f);- break;-- case 'bold':- triggerUpdate(!!style.bl);- break;-- case 'italic':- triggerUpdate(!!style.it);- break;-- case 'strikethrough':- triggerUpdate(!!style.st?.s);- break;-- case 'underline':- triggerUpdate(!!style.ul?.s);- break;-- case 'horizontalAlign':- triggerUpdate(style?.ht || DEFAULT_STYLES.ht);- break;-- case 'verticalAlign':- triggerUpdate(style?.vt || DEFAULT_STYLES.vt);- break;-- case 'textWrap':- triggerUpdate(style?.tb || DEFAULT_STYLES.tb);- break;-- case 'textRotate':- if (!style.tr) {- style.tr = DEFAULT_STYLES.tr;- }- triggerUpdate(style.tr?.v ? 'v' : style.tr?.a);- break;-- default:- break;- }- }+ // 改变边框线颜色+ handleLineColor(color: string, e: MouseEvent) {+ e.stopPropagation();+ this._lineColor.setColor(color);+ this._borderInfo.color = color;+ }++ addToolButton(config: IToolBarItemProps) {+ const index = this._toolList.findIndex((item) => item.name === config.name);+ if (index > -1) return;+ this._toolList.push(config);+ this.resetToolBarList();}}diff --git a/packages/base-sheets/src/Controller/ToolBarController1.ts b/packages/base-sheets/src/Controller/ToolBarController1.tsdeleted file mode 100644index 21471c9ab2..0000000000--- a/packages/base-sheets/src/Controller/ToolBarController1.ts+++ /dev/null@@ -1,624 +0,0 @@-import { BaseComponentRender, BaseComponentSheet } from '@univer/base-component';-import { Tools, BorderType, BorderStyleTypes, HorizontalAlign, VerticalAlign, WrapStrategy, DEFAULT_STYLES } from '@univer/core';-import { ColorPicker } from '@univer/style-universheet';-import { SpreadsheetPlugin } from '../SpreadsheetPlugin';-import { defaultLayout, ILayout } from '../View/UI/SheetContainer';--import { SelectionControl } from './Selection/SelectionController';-import { ToolBar1 } from '../View/UI/ToolBar/ToolBar1';-import {- BORDER_LINE_CHILDREN,- FONT_FAMILY_CHILDREN,- FONT_SIZE_CHILDREN,- HORIZONTAL_ALIGN_CHILDREN,- MERGE_CHILDREN,- TEXT_ROTATE_CHILDREN,- TEXT_WRAP_CHILDREN,- VERTICAL_ALIGN_CHILDREN,-} from '../View/UI/ToolBar/Const';-import styles from '../View/UI/ToolBar/index.module.less';-import { LineColor } from '../View/UI/Common/Line/LineColor';-import { SelectionModel } from '../Model';-import { IToolBarItemProps, ToolBarModel1 } from '../Model/ToolBarModal1';--interface BorderInfo {- color: string;- width: string;-}--/**- *- */-export class ToolBarController1 {- private _toolBarModel: ToolBarModel1;-- private _plugin: SpreadsheetPlugin;-- private _toolBarComponent: ToolBar1;-- private _toolList: IToolBarItemProps[];-- private _lineColor: LineColor;-- Render: BaseComponentRender;-- private _borderInfo: BorderInfo; //存储边框信息-- constructor(plugin: SpreadsheetPlugin) {- this._plugin = plugin;-- this.initRegisterComponent();-- const config =- this._plugin.config.layout === 'auto'- ? Tools.deepClone(defaultLayout.toolBarConfig)- : Tools.deepMerge(defaultLayout.toolBarConfig, (this._plugin.config.layout as ILayout).toolBarConfig);-- this._borderInfo = {- color: '#000',- width: '1',- };-- this._toolList = [- {- toolbarType: 1,- tooltipLocale: 'toolbar.undo',- label: 'ForwardIcon',- show: config.undoRedo,- onClick: () => {- this.setUndo();- },- },- {- toolbarType: 1,- tooltipLocale: 'toolbar.redo',- label: 'BackIcon',- show: config.undoRedo,- onClick: () => {- this.setRedo();- },- },-- // {- // toolbarType: 1,- // tooltipLocale: 'paintFormat',- // label: 'FormatIcon',- // show: config.paintFormat,- // },- // {- // toolbarType: 1,- // tooltipLocale: 'currencyFormat',- // label: 'MoneyIcon',- // show: config.currencyFormat,- // },- // {- // toolbarType: 1,- // tooltipLocale: 'percentageFormat',- // label: 'PercentIcon',- // show: config.percentageFormat,- // },- // {- // toolbarType: 1,- // tooltipLocale: 'numberDecrease',- // label: 'ReduceNumIcon',- // show: config.numberDecrease,- // },- // {- // toolbarType: 1,- // tooltipLocale: 'numberIncrease',- // label: 'AddNumIcon',- // show: config.numberIncrease,- // },- // {- // type: 0,- // tooltipLocale: 'moreFormats',- // show: config.moreFormats,- // border: true,- // children: [- // ...MORE_FORMATS_CHILDREN,- // {- // locale: 'defaultFmt.CustomFormats.text',- // suffix: 'RightIcon',- // children: [- // {- // locale: 'format.moreCurrency',- // onClick: (e: string) => {},- // },- // {- // locale: 'format.moreDateTime',- // onClick: (e: string) => {},- // },- // {- // locale: 'format.moreNumber',- // onClick: (e: string) => {},- // },- // ],- // },- // ],- // },-- {- type: 0,- tooltipLocale: 'font',- selectClassName: styles.selectLabelString,- show: config.font,- border: true,- onClick: (fontFamily: string) => {- this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.notifyObservers(fontFamily);- },- children: FONT_FAMILY_CHILDREN,- },- {- type: 1,- tooltipLocale: 'fontSize',- label: String(DEFAULT_STYLES.fs),- show: config.fontSize,- onClick: (fontSize: number) => {- this._plugin.getObserver('onAfterChangeFontSizeObservable')?.notifyObservers(fontSize);- },- onKeyUp: (fontSize: number) => {- this._plugin.getObserver('onAfterChangeFontSizeObservable')?.notifyObservers(fontSize);- },- children: FONT_SIZE_CHILDREN,- },- {- toolbarType: 1,- tooltipLocale: 'bold',- label: 'BoldIcon',- show: config.bold,- onClick: (isBold: boolean) => {- this._plugin.getObserver('onAfterChangeFontWeightObservable')?.notifyObservers(isBold);- },- },- {- toolbarType: 1,- tooltipLocale: 'italic',- label: 'ItalicIcon',- show: config.italic,- onClick: (isItalic: boolean) => {- this._plugin.getObserver('onAfterChangeFontItalicObservable')?.notifyObservers(isItalic);- },- },- {- toolbarType: 1,- tooltipLocale: 'strikethrough',- label: 'DeleteLineIcon',- show: config.strikethrough,- onClick: (isStrikethrough: boolean) => {- this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.notifyObservers(isStrikethrough);- },- },- {- toolbarType: 1,- tooltipLocale: 'underline',- label: 'UnderLineIcon',- show: config.underline,- onClick: (isItalic: boolean) => {- this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.notifyObservers(isItalic);- },- },- {- type: 2,- tooltipLocale: 'textColor',- label: 'TextColorIcon',- show: config.textColor,- onClick: (color: string) => {- this._plugin.getObserver('onAfterChangeFontColorObservable')?.notifyObservers(color);- },- },- {- type: 2,- tooltipLocale: 'fillColor',- label: 'FillColorIcon',- show: config.fillColor,- onClick: (color: string) => {- this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.notifyObservers(color);- },- },- {- type: 3,- display: 1,- show: config.border,- onClick: (type) => {- // console.dir(type);- // console.dir(this._borderInfo);- },- children: [- ...BORDER_LINE_CHILDREN,- {- label: 'LineColor',- unSelectable: true,- className: styles.selectColorPickerParent,- children: [- {- label: 'LineColorPicker',- className: styles.selectColorPicker,- onClick: this.handleLineColor,- },- ],- },- // {- // locale: 'borderLine.borderSize',- // suffix: 'RightIcon',- // value: 1,- // unSelectable: true,- // children: [- // { locale: 'borderLine.borderNone', value: 0 },- // { label: 'BorderThin', value: 1 },- // { label: 'BorderHair', value: 2 },- // { label: 'BorderDotted', value: 3 },- // { label: 'BorderDashed', value: 4 },- // { label: 'BorderDashDot', value: 5 },- // { label: 'BorderDashDotDot', value: 6 },- // { label: 'BorderMedium', value: 7 },- // { label: 'BorderMediumDashed', value: 8 },- // { label: 'BorderMediumDashDot', value: 9 },- // { label: 'BorderMediumDashDotDot', value: 10 },- // { label: 'BorderThick', value: 12 },- // ],- // },- ],- },- {- type: 5,- tooltipLocale: 'mergeCell',- label: 'MergeIcon',- show: config.mergeCell,- onClick: (value: string) => {- this.setMerge(value);- },- children: MERGE_CHILDREN,- },- {- type: 3,- tooltipLocale: 'horizontalAlignMode',- display: 1,- show: config.horizontalAlignMode,- onClick: (value: HorizontalAlign) => {- this.setHorizontalAlignment(value);- },- children: HORIZONTAL_ALIGN_CHILDREN,- },- {- type: 3,- tooltipLocale: 'verticalAlignMode',- display: 1,- show: config.verticalAlignMode,- onClick: (value: VerticalAlign) => {- this.setVerticalAlignment(value);- },- children: VERTICAL_ALIGN_CHILDREN,- },- {- type: 3,- tooltipLocale: 'textWrapMode',- display: 1,- show: config.textWrapMode,- onClick: (value: WrapStrategy) => {- this.setWrapStrategy(value);- },- children: TEXT_WRAP_CHILDREN,- },- {- type: 3,- tooltipLocale: 'textRotateMode',- display: 1,- show: config.textRotateMode,- onClick: (value: number | string) => {- this.setTextRotation(value);- },- children: TEXT_ROTATE_CHILDREN,- },- ];-- this._toolBarModel = new ToolBarModel1();- this._toolBarModel.config = config;- this._toolBarModel.toolList = this._toolList;-- this.init();- }-- init() {- this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.add((value: string) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setFontFamily(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('ff', value);- }- });- this._plugin.getObserver('onAfterChangeFontSizeObservable')?.add((value: number) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setFontSize(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('fs', value);- }- });- this._plugin.getObserver('onAfterChangeFontWeightObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setFontWeight(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('bl', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontItalicObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setFontStyle(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('it', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setStrikeThrough(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('cl', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setUnderline(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('un', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontColorObservable')?.add((value: string) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setFontColor(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('fc', value);- }- });- this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.add((value: string) => {- if (!this._plugin.getCellEditorControl().isEditMode) {- this.setBackground(value);- } else {- this._plugin.getCellEditorControl().richText.cellTextStyle.updateFormat('bg', value);- }- });-- this._plugin.getObserver('onToolBar1DidMountObservable')?.add((component) => {- //初始化视图- this._toolBarComponent = component;- this.resetToolBarList();- });-- this._plugin.getObserver('onLineColorDidMountObservable')?.add((component) => {- //初始化视图- this._lineColor = component;- });-- this._plugin.context- .getObserverManager()- .getObserver('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {});-- // 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 });- }- });- }-- initRegisterComponent() {- const component = this._plugin.context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();- const registerIcon = {- ForwardIcon: this.Render.renderFunction('ForwardIcon'),- BackIcon: this.Render.renderFunction('BackIcon'),- BoldIcon: this.Render.renderFunction('BoldIcon'),- ItalicIcon: this.Render.renderFunction('ItalicIcon'),- DeleteLineIcon: this.Render.renderFunction('DeleteLineIcon'),- UnderLineIcon: this.Render.renderFunction('UnderLineIcon'),- TextColorIcon: this.Render.renderFunction('TextColorIcon'),- FillColorIcon: this.Render.renderFunction('FillColorIcon'),- MergeIcon: this.Render.renderFunction('MergeIcon'),- TopBorderIcon: this.Render.renderFunction('TopBorderIcon'),- BottomBorderIcon: this.Render.renderFunction('BottomBorderIcon'),- LeftBorderIcon: this.Render.renderFunction('LeftBorderIcon'),- RightBorderIcon: this.Render.renderFunction('RightBorderIcon'),- NoneBorderIcon: this.Render.renderFunction('NoneBorderIcon'),- FullBorderIcon: this.Render.renderFunction('FullBorderIcon'),- OuterBorderIcon: this.Render.renderFunction('OuterBorderIcon'),- InnerBorderIcon: this.Render.renderFunction('InnerBorderIcon'),- StripingBorderIcon: this.Render.renderFunction('StripingBorderIcon'),- VerticalBorderIcon: this.Render.renderFunction('VerticalBorderIcon'),- LeftAlignIcon: this.Render.renderFunction('LeftAlignIcon'),- CenterAlignIcon: this.Render.renderFunction('CenterAlignIcon'),- RightAlignIcon: this.Render.renderFunction('RightAlignIcon'),- TopVerticalIcon: this.Render.renderFunction('TopVerticalIcon'),- CenterVerticalIcon: this.Render.renderFunction('CenterVerticalIcon'),- BottomVerticalIcon: this.Render.renderFunction('BottomVerticalIcon'),- OverflowIcon: this.Render.renderFunction('OverflowIcon'),- BrIcon: this.Render.renderFunction('BrIcon'),- CutIcon: this.Render.renderFunction('CutIcon'),- TextRotateIcon: this.Render.renderFunction('TextRotateIcon'),- TextRotateAngleUpIcon: this.Render.renderFunction('TextRotateAngleUpIcon'),- TextRotateAngleDownIcon: this.Render.renderFunction('TextRotateAngleDownIcon'),- TextRotateVerticalIcon: this.Render.renderFunction('TextRotateVerticalIcon'),- TextRotateRotationUpIcon: this.Render.renderFunction('TextRotateRotationUpIcon'),- TextRotateRotationDownIcon: this.Render.renderFunction('TextRotateRotationDownIcon'),- };- // 注册自定义组件- this._plugin.registerComponent('LineColor', LineColor);- this._plugin.registerComponent('LineColorPicker', ColorPicker, { onClick: (color: string, e: MouseEvent) => this.handleLineColor(color, e) });- for (let k in registerIcon) {- this._plugin.registerComponent(k, registerIcon[k]);- }- }-- resetLocale(toolList: any[]) {- const locale = this._plugin.context.getLocale();-- for (let i = 0; i < toolList.length; i++) {- const item = toolList[i];- if (item.tooltipLocale) {- item.tooltip = locale.get(item.tooltipLocale);- }- if (item.locale) {- item.label = locale.get(item.locale);- }- if (item.suffixLocale) {- item.suffix = locale.get(item.suffixLocale);- }- if (item.children) {- item.children = this.resetLocale(item.children);- }- }- return toolList;- }-- resetToolBarList() {- const toolList = this.resetLocale(this._toolList);- this._toolBarComponent.setToolBar(toolList);- }-- setRedo() {- this._plugin.getContext().getCommandManager().redo();- }-- setUndo() {- this._plugin.getContext().getCommandManager().undo();- }-- setFontColor(value: string) {- this._plugin.getSelectionManager().getActiveRangeList()?.setFontColor(value);- }-- setBackground(value: string) {- this._plugin.getSelectionManager().getActiveRangeList()?.setBackground(value);- }-- setFontSize(value: number) {- this._plugin.getSelectionManager().getActiveRangeList()?.setFontSize(value);- }-- setFontFamily(value: string) {- this._plugin.getSelectionManager().getActiveRangeList()?.setFontFamily(value);- }-- setFontWeight(value: boolean) {- this._plugin.getSelectionManager().getActiveRangeList()?.setFontWeight(value);- }-- setFontStyle(value: boolean) {- this._plugin.getSelectionManager().getActiveRangeList()?.setFontStyle(value);- }-- setStrikeThrough(value: boolean) {- this._plugin.getSelectionManager().getActiveRangeList()?.setStrikeThrough(value);- }-- setUnderline(value: boolean) {- this._plugin.getSelectionManager().getActiveRangeList()?.setUnderline(value);- }-- setMerge(value: string) {- const currentRange = this._plugin.getSelectionManager().getActiveRange();-- switch (value) {- case 'all':- currentRange?.merge();- break;-- case 'vertical':- currentRange?.mergeVertically();- break;-- case 'horizontal':- currentRange?.mergeAcross();- break;-- case 'cancel':- currentRange?.breakApart();- break;-- default:- break;- }-- // update data- this._plugin.getCanvasView().updateToSheet(this._plugin.getContext().getWorkBook().getActiveSheet()!);- // update render- // this._plugin.getMainComponent().makeDirty(true);- }-- setHorizontalAlignment(value: HorizontalAlign) {- this._plugin.getSelectionManager().getActiveRangeList()?.setHorizontalAlignment(value);- }-- setVerticalAlignment(value: VerticalAlign) {- this._plugin.getSelectionManager().getActiveRangeList()?.setVerticalAlignment(value);- }-- setWrapStrategy(value: WrapStrategy) {- this._plugin.getSelectionManager().getActiveRangeList()?.setWrapStrategy(value);- }-- setTextRotation(value: number | string) {- if (value === 'v') {- this._plugin.getSelectionManager().getActiveRangeList()?.setVerticalText(1);- } else {- this._plugin- .getSelectionManager()- .getActiveRangeList()- ?.setTextRotation(value as number);- }- }-- setBorder(type: BorderType, color: string, style: BorderStyleTypes) {- const controls = this._plugin.getSelectionManager().getCurrentControls();-- if (controls && controls.length > 0) {- controls?.forEach((control: SelectionControl) => {- const model: SelectionModel = control.model;- const range = {- startRow: model.startRow,- startColumn: model.startColumn,- endRow: model.endRow,- endColumn: model.endColumn,- };-- this._plugin.getContext().getWorkBook().getActiveSheet().getRange(range).setBorderByType(type, color, style);- });-- this._plugin.getCanvasView().updateToSheet(this._plugin.getContext().getWorkBook().getActiveSheet()!);- }- }-- // 改变边框线颜色- handleLineColor(color: string, e: MouseEvent) {- e.stopPropagation();- this._lineColor.setColor(color);- this._borderInfo.color = color;- }-- addToolButton(config: IToolBarItemProps) {- const index = this._toolList.findIndex((item) => item.name === config.name);- if (index > -1) return;- this._toolList.push(config);- }-}diff --git a/packages/base-sheets/src/Locale/en.ts b/packages/base-sheets/src/Locale/en.tsindex 9409e56dd3..6741a7f58d 100644--- a/packages/base-sheets/src/Locale/en.ts+++ b/packages/base-sheets/src/Locale/en.ts@@ -200,32 +200,7 @@ export default {middle: 'middle',bottom: 'bottom',},- currencyDetail: [- {- name: 'RMB',- value: '¥',- },- {- name: 'US dollar',- value: '$',- },- {- name: 'EUR',- value: '€',- },- {- name: 'GBP',- value: '£',- },- {- name: 'HK',- value: '$',- },- {- name: 'JPY',- value: '¥',- },- ],+dateFmtList: [{name: '1930-08-05',diff --git a/packages/base-sheets/src/Locale/zh.ts b/packages/base-sheets/src/Locale/zh.tsindex f831bda689..867e8315e7 100644--- a/packages/base-sheets/src/Locale/zh.ts+++ b/packages/base-sheets/src/Locale/zh.ts@@ -200,788 +200,7 @@ export default {middle: '居中对齐',bottom: '底部对齐',},- currencyDetail: [- {- name: '人民币',- value: '¥',- },- {- name: '美元',- value: '$',- },- {- name: '欧元',- value: '€',- },- {- name: '英镑',- value: '£',- },- {- name: '港元',- value: '$',- },- {- name: '日元',- value: '¥',- },- {- name: '阿尔巴尼亚列克',- value: 'Lek',- },- {- name: '阿尔及利亚第纳尔',- value: 'din',- },- {- name: '阿富汗尼',- value: 'Af',- },- {- name: '阿根廷比索',- value: '$',- },- {- name: '阿拉伯联合酋长国迪拉姆',- value: 'dh',- },- {- name: '阿鲁巴弗罗林',- value: 'Afl',- },- {- name: '阿曼里亚尔',- value: 'Rial',- },- {- name: '阿塞拜疆马纳特',- value: '?',- },- {- name: '埃及镑',- value: '£',- },- {- name: '埃塞俄比亚比尔',- value: 'Birr',- },- {- name: '安哥拉宽扎',- value: 'Kz',- },- {- name: '澳大利亚元',- value: '$',- },- {- name: '澳门元',- value: 'MOP',- },- {- name: '巴巴多斯元',- value: '$',- },- {- name: '巴布亚新几内亚基那',- value: 'PGK',- },- {- name: '巴哈马元',- value: '$',- },- {- name: '巴基斯坦卢比',- value: 'Rs',- },- {- name: '巴拉圭瓜拉尼',- value: 'Gs',- },- {- name: '巴林第纳尔',- value: 'din',- },- {- name: '巴拿马巴波亚',- value: 'B/',- },- {- name: '巴西里亚伊',- value: 'R$',- },- {- name: '白俄罗斯卢布',- value: 'р',- },- {- name: '百慕大元',- value: '$',- },- {- name: '保加利亚列弗',- value: 'lev',- },- {- name: '冰岛克朗',- value: 'kr',- },- {- name: '波黑可兑换马克',- value: 'KM',- },- {- name: '波兰兹罗提',- value: 'z?',- },- {- name: '玻利维亚诺',- value: 'Bs',- },- {- name: '伯利兹元',- value: '$',- },- {- name: '博茨瓦纳普拉',- value: 'P',- },- {- name: '不丹努扎姆',- value: 'Nu',- },- {- name: '布隆迪法郎',- value: 'FBu',- },- {- name: '朝鲜圆',- value: '?KP',- },- {- name: '丹麦克朗',- pos: 'after',- value: 'kr',- },- {- name: '东加勒比元',- value: '$',- },- {- name: '多米尼加比索',- value: 'RD$',- },- {- name: '俄国卢布',- pos: 'after',- value: '?',- },- {- name: '厄立特里亚纳克法',- value: 'Nfk',- },- {- name: '非洲金融共同体法郎',- value: 'CFA',- },- {- name: '菲律宾比索',- value: '?',- },- {- name: '斐济元',- value: '$',- },- {- name: '佛得角埃斯库多',- value: 'CVE',- },- {- name: '福克兰群岛镑',- value: '£',- },- {- name: '冈比亚达拉西',- value: 'GMD',- },- {- name: '刚果法郎',- value: 'FrCD',- },- {- name: '哥伦比亚比索',- value: '$',- },- {- name: '哥斯达黎加科朗',- value: '?',- },- {- name: '古巴比索',- value: '$',- },- {- name: '古巴可兑换比索',- value: '$',- },- {- name: '圭亚那元',- value: '$',- },- {- name: '哈萨克斯坦坚戈',- value: '?',- },- {- name: '海地古德',- value: 'HTG',- },- {- name: '韩元',- value: '?',- },- {- name: '荷属安的列斯盾',- value: 'NAf.',- },- {- name: '洪都拉斯拉伦皮拉',- value: 'L',- },- {- name: '吉布提法郎',- value: 'Fdj',- },- {- name: '吉尔吉斯斯坦索姆',- value: 'KGS',- },- {- name: '几内亚法郎',- value: 'FG',- },- {- name: '加拿大元',- value: '$',- },- {- name: '加纳塞地',- value: 'GHS',- },- {- name: '柬埔寨瑞尔',- value: 'Riel',- },- {- name: '捷克克朗',- pos: 'after',- value: 'K?',- },- {- name: '津巴布韦元',- value: '$',- },- {- name: '卡塔尔里亚尔',- value: 'Rial',- },- {- name: '开曼群岛元',- value: '$',- },- {- name: '科摩罗法郎',- value: 'CF',- },- {- name: '科威特第纳尔',- value: 'din',- },- {- name: '克罗地亚库纳',- value: 'kn',- },- {- name: '肯尼亚先令',- value: 'Ksh',- },- {- name: '莱索托洛蒂',- value: 'LSL',- },- {- name: '老挝基普',- value: '?',- },- {- name: '黎巴嫩镑',- value: 'L£',- },- {- name: '立陶宛立特',- value: 'Lt',- },- {- name: '利比亚第纳尔',- value: 'din',- },- {- name: '利比亚元',- value: '$',- },- {- name: '卢旺达法郎',- value: 'RF',- },- {- name: '罗马尼亚列伊',- value: 'RON',- },- {- name: '马达加斯加阿里亚里',- value: 'Ar',- },- {- name: '马尔代夫拉菲亚',- value: 'Rf',- },- {- name: '马拉维克瓦查',- value: 'MWK',- },- {- name: '马来西亚林吉特',- value: 'RM',- },- {- name: '马其顿戴第纳尔',- value: 'din',- },- {- name: '毛里求斯卢比',- value: 'MURs',- },- {- name: '毛里塔尼亚乌吉亚',- value: 'MRO',- },- {- name: '蒙古图格里克',- value: '?',- },- {- name: '孟加拉塔卡',- value: '?',- },- {- name: '秘鲁新索尔',- value: 'S/',- },- {- name: '缅甸开亚特',- value: 'K',- },- {- name: '摩尔多瓦列伊',- value: 'MDL',- },- {- name: '摩洛哥迪拉姆',- value: 'dh',- },- {- name: '莫桑比克梅蒂卡尔',- value: 'MTn',- },- {- name: '墨西哥比索',- value: '$',- },- {- name: '纳米比亚元',- value: '$',- },- {- name: '南非兰特',- value: 'R',- },- {- name: '南苏丹镑',- value: '£',- },- {- name: '尼加拉瓜科多巴',- value: 'C$',- },- {- name: '尼泊尔卢比',- value: 'Rs',- },- {- name: '尼日利亚奈拉',- value: '?',- },- {- name: '挪威克朗',- pos: 'after',- value: 'kr',- },- {- name: '乔治亚拉瑞',- value: 'GEL',- },- {- name: '人民币(离岸)',- value: '¥',- },- {- name: '瑞典克朗',- pos: 'after',- value: 'kr',- },- {- name: '瑞士法郎',- value: 'CHF',- },- {- name: '塞尔维亚第纳尔',- value: 'din',- },- {- name: '塞拉利昂利昂',- value: 'SLL',- },- {- name: '塞舌尔卢比',- value: 'SCR',- },- {- name: '沙特里亚尔',- value: 'Rial',- },- {- name: '圣多美多布拉',- value: 'Db',- },- {- name: '圣赫勒拿群岛磅',- value: '£',- },- {- name: '斯里兰卡卢比',- value: 'Rs',- },- {- name: '斯威士兰里兰吉尼',- value: 'SZL',- },- {- name: '苏丹镑',- value: 'SDG',- },- {- name: '苏里南元',- value: '$',- },- {- name: '所罗门群岛元',- value: '$',- },- {- name: '索马里先令',- value: 'SOS',- },- {- name: '塔吉克斯坦索莫尼',- value: 'Som',- },- {- name: '太平洋法郎',- pos: 'after',- value: 'FCFP',- },- {- name: '泰国铢',- value: '?',- },- {- name: '坦桑尼亚先令',- value: 'TSh',- },- {- name: '汤加潘加',- value: 'T$',- },- {- name: '特立尼达和多巴哥元',- value: '$',- },- {- name: '突尼斯第纳尔',- value: 'din',- },- {- name: '土耳其里拉',- value: '?',- },- {- name: '瓦努阿图瓦图',- value: 'VUV',- },- {- name: '危地马拉格查尔',- value: 'Q',- },- {- name: '委内瑞拉博利瓦',- value: 'Bs',- },- {- name: '文莱元',- value: '$',- },- {- name: '乌干达先令',- value: 'UGX',- },- {- name: '乌克兰格里夫尼亚',- value: 'грн.',- },- {- name: '乌拉圭比索',- value: '$',- },- {- name: '乌兹别克斯坦苏姆',- value: 'so?m',- },- {- name: '西萨摩亚塔拉',- value: 'WST',- },- {- name: '新加坡元',- value: '$',- },- {- name: '新台币',- value: 'NT$',- },- {- name: '新西兰元',- value: '$',- },- {- name: '匈牙利福林',- value: 'Ft',- },- {- name: '叙利亚镑',- value: '£',- },- {- name: '牙买加元',- value: '$',- },- {- name: '亚美尼亚德拉姆',- value: 'Dram',- },- {- name: '也门里亚尔',- value: 'Rial',- },- {- name: '伊拉克第纳尔',- value: 'din',- },- {- name: '伊朗里亚尔',- value: 'Rial',- },- {- name: '以色列新谢克尔',- value: '?',- },- {- name: '印度卢比',- value: '?',- },- {- name: '印度尼西亚卢比',- value: 'Rp',- },- {- name: '约旦第纳尔',- value: 'din',- },- {- name: '越南盾',- pos: 'after',- value: '?',- },- {- name: '赞比亚克瓦查',- value: 'ZMW',- },- {- name: '直布罗陀镑',- value: '£',- },- {- name: '智利比索',- value: '$',- },- {- name: '中非金融合作法郎',- value: 'FCFA',- },- ],- dateFmtList: [- {- name: '1930-08-05',- value: 'yyyy-MM-dd',- },- {- name: '1930/8/5',- value: 'yyyy/MM/dd',- },- {- name: '1930年8月5日',- value: 'yyyy"年"M"月"d"日"',- },- {- name: '08-05',- value: 'MM-dd',- },- {- name: '8-5',- value: 'M-d',- },- {- name: '8月5日',- value: 'M"月"d"日"',- },- {- name: '13:30:30',- value: 'h:mm:ss',- },- {- name: '13:30',- value: 'h:mm',- },- {- name: '下午01:30',- value: '上午/下午 hh:mm',- },- {- name: '下午1:30',- value: '上午/下午 h:mm',- },- {- name: '下午1:30:30',- value: '上午/下午 h:mm:ss',- },- {- name: '08-05 下午01:30',- value: 'MM-dd 上午/下午 hh:mm',- },- ],- numFmtList: [- {- name: '1235',- value: '0',- },- {- name: '1234.56',- value: '0.00',- },- {- name: '1,235',- value: '#,##0',- },- {- name: '1,234.56',- value: '#,##0.00',- },- {- name: '1,235',- value: '#,##0_);(#,##0)',- },- {- name: '1,235',- value: '#,##0_);[Red](#,##0)',- },- {- name: '1,234.56',- value: '#,##0.00_);(#,##0.00)',- },- {- name: '1,234.56',- value: '#,##0.00_);[Red](#,##0.00)',- },- {- name: '$1,235',- value: '$#,##0_);($#,##0)',- },- {- name: '$1,235',- value: '$#,##0_);[Red]($#,##0)',- },- {- name: '$1,234.56',- value: '$#,##0.00_);($#,##0.00)',- },- {- name: '$1,234.56',- value: '$#,##0.00_);[Red]($#,##0.00)',- },- {- name: '1234.56',- value: '@',- },- {- name: '123456%',- value: '0%',- },- {- name: '123456.00%',- value: '0.00%',- },- {- name: '1.23E+03',- value: '0.00E+00',- },- {- name: '1.2E+3',- value: '##0.0E+0',- },- {- name: '1234 5/9',- value: '# ?/?',- },- {- name: '1234 14/25',- value: '# ??/??',- },- {- name: '$ 1,235',- value: '_($* #,##0_);_(...($* "-"_);_(@_)',- },- {- name: '1,235',- value: '_(* #,##0_);_(*..._(* "-"_);_(@_)',- },- {- name: '$ 1,234.56',- // "value": '_($* #,##0.00_)...* "-"??_);_(@_)'- value: '_($* #,##0.00_);_(...($* "-"_);_(@_)',- },- {- name: '1,234.56',- value: '_(* #,##0.00_);...* "-"??_);_(@_)',- },- ],+button: {confirm: '确定',cancel: '取消',diff --git a/packages/base-sheets/src/Model/ToolBarModal1.ts b/packages/base-sheets/src/Model/ToolBarModal1.tsdeleted file mode 100644index 1771374500..0000000000--- a/packages/base-sheets/src/Model/ToolBarModal1.ts+++ /dev/null@@ -1,52 +0,0 @@-import { BaseSelectChildrenProps, BaseSelectProps } from '../View/UI/Common/Select/Select';-import { BaseTextButtonProps } from '../View/UI/Common/TextButton/TextButton';-import { IShowToolBarConfig } from '../View/UI/ToolBar';--enum ToolbarType {- SELECT,- BUTTON,-}--// 继承基础下拉属性,添加国际化-export interface BaseToolBarSelectChildrenProps extends BaseSelectChildrenProps {- locale?: string;- suffixLocale?: string;- children?: BaseToolBarSelectChildrenProps[];-}--interface BaseToolBarSelectProps extends BaseSelectProps {- locale?: string;- suffixLocale?: string;- children?: BaseToolBarSelectChildrenProps[];-}--export interface IToolBarItemProps extends BaseToolBarSelectProps, BaseTextButtonProps {- show?: boolean; //是否显示按钮- toolbarType?: ToolbarType;- locale?: string; //label国际化- tooltipLocale?: string; //tooltip国际化- tooltip?: string; //tooltip文字- border?: boolean;-}--export class ToolBarModel1 {- private _config: IShowToolBarConfig[];-- private _toolList: IToolBarItemProps[];-- get config(): IShowToolBarConfig[] {- return this._config;- }-- get toolList(): IToolBarItemProps[] {- return this._toolList;- }-- set config(value: IShowToolBarConfig[]) {- this._config = value;- }-- set toolList(value: IToolBarItemProps[]) {- this._toolList = value;- }-}diff --git a/packages/base-sheets/src/Model/ToolBarModel.ts b/packages/base-sheets/src/Model/ToolBarModel.tsindex 1402dca6f5..c566e1db58 100644--- a/packages/base-sheets/src/Model/ToolBarModel.ts+++ b/packages/base-sheets/src/Model/ToolBarModel.ts@@ -1,5 +1,72 @@-import { IToolBarItemProps } from '@univer/base-component';-import { IShowToolBarConfig } from '../View/UI/ToolBar';+import { BaseSelectChildrenProps, BaseSelectProps } from '../View/UI/Common/Select/Select';+import { BaseTextButtonProps } from '../View/UI/Common/TextButton/TextButton';++export interface IShowToolBarConfig {+ undoRedo?: boolean; // Undo redo+ paintFormat?: boolean; // Format brush+ currencyFormat?: boolean; // currency format+ percentageFormat?: boolean; // Percentage format+ numberDecrease?: boolean; // 'Decrease the number of decimal places'+ numberIncrease?: boolean; // 'Increase the number of decimal places+ moreFormats?: boolean; // 'More Formats'+ font?: boolean; // 'font'+ fontSize?: boolean; // 'Font size'+ bold?: boolean; // 'Bold (Ctrl+B)'+ italic?: boolean; // 'Italic (Ctrl+I)'+ strikethrough?: boolean; // 'Strikethrough (Alt+Shift+5)'+ underline?: boolean; // 'Underline (Alt+Shift+6)'+ textColor?: boolean; // 'Text color'+ fillColor?: boolean; // 'Cell color'+ border?: boolean; // 'border'+ mergeCell?: boolean; // 'Merge cells'+ horizontalAlignMode?: boolean; // 'Horizontal alignment'+ verticalAlignMode?: boolean; // 'Vertical alignment'+ textWrapMode?: boolean; // 'Wrap mode'+ textRotateMode?: boolean; // 'Text Rotation Mode'++ image?: boolean; // 'Insert picture'+ link?: boolean; // 'Insert link'+ chart?: boolean; // 'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)+ comment?: boolean; // 'comment'+ pivotTable?: boolean; // 'PivotTable'+ function?: boolean; // 'formula'+ frozenMode?: boolean; // 'freeze mode'+ sortAndFilter?: boolean; // 'Sort and filter'+ conditionalFormat?: boolean; // 'Conditional Format'+ dataValidation?: boolean; // 'Data Validation'+ splitColumn?: boolean; // 'Split column'+ screenshot?: boolean; // 'screenshot'+ findAndReplace?: boolean; // 'Find and Replace'+ protection?: boolean; // 'Worksheet protection'+ print?: boolean; // 'Print'+}++enum ToolbarType {+ SELECT,+ BUTTON,+}++// 继承基础下拉属性,添加国际化+export interface BaseToolBarSelectChildrenProps extends BaseSelectChildrenProps {+ locale?: string;+ suffixLocale?: string;+ children?: BaseToolBarSelectChildrenProps[];+}++interface BaseToolBarSelectProps extends BaseSelectProps {+ locale?: string;+ suffixLocale?: string;+ children?: BaseToolBarSelectChildrenProps[];+}++export interface IToolBarItemProps extends BaseToolBarSelectProps, BaseTextButtonProps {+ show?: boolean; //是否显示按钮+ toolbarType?: ToolbarType;+ locale?: string; //label国际化+ tooltipLocale?: string; //tooltip国际化+ tooltip?: string; //tooltip文字+ border?: boolean;+}export class ToolBarModel {private _config: IShowToolBarConfig[];diff --git a/packages/base-sheets/src/SpreadsheetPlugin.tsx b/packages/base-sheets/src/SpreadsheetPlugin.tsxindex eda77e3fc5..1a31411026 100644--- a/packages/base-sheets/src/SpreadsheetPlugin.tsx+++ b/packages/base-sheets/src/SpreadsheetPlugin.tsx@@ -1,7 +1,6 @@-import { getRefElement, IMainProps, isElement, ISlotProps, IToolBarItemProps, RefObject, render } from '@univer/base-component';+import { getRefElement, IMainProps, isElement, ISlotProps, RefObject, render } from '@univer/base-component';import { Engine, RenderEngine } from '@univer/base-render';import { AsyncFunction, Attribute, Context, IOCAttribute, IOCContainer, IRangeCellData, IRangeData, IWorkbookConfig, Plugin, PLUGIN_NAMES, Tools } from '@univer/core';-import { FormulaPlugin } from '@univer/sheets-plugin-formula';import { install, SpreadsheetPluginObserve, uninstall } from './Basics/Observer';import { RightMenuProps } from './Model/RightMenuModel';@@ -11,15 +10,16 @@ import { CanvasView } from './View/Render/CanvasView';import { BaseSheetContainerConfig, ISpreadsheetPluginConfigBase, SheetContainer } from './View/UI/SheetContainer';import {RightMenuController,- ToolBarController,InfoBarController,SheetBarControl,CellEditorController,AntLineControl,CountBarController,SheetContainerController,+ ToolBarController,} from './Controller';-import { ToolBarController1 } from './Controller/ToolBarController1';+import { IToolBarItemProps } from './Model/ToolBarModel';+import { ModalGroupController } from './Controller/ModalGroupController';export interface ISelectionConfig {selection: IRangeData;@@ -136,8 +136,6 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {private _toolBarControl: ToolBarController;- private _toolBarControl1: ToolBarController1;-private _infoBarControl: InfoBarController;private _sheetBarControl: SheetBarControl;@@ -150,7 +148,9 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {private _sheetContainerController: SheetContainerController;- private _componentList: Map<string, ComponentChildrenProps>;+ private _modalGroupController: ModalGroupController;++ private _componentList: Map<string, any>;constructor(props: Partial<ISpreadsheetPluginConfig> = {}) {super(PLUGIN_NAMES.SPREADSHEET);@@ -222,24 +222,24 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {this._rightMenuControl = new RightMenuController(this);this._toolBarControl = new ToolBarController(this);- this._toolBarControl1 = new ToolBarController1(this);this._infoBarControl = new InfoBarController(this);this._sheetBarControl = new SheetBarControl(this);this._cellEditorControl = new CellEditorController(this);this._antLineController = new AntLineControl(this);this._countBarController = new CountBarController(this);this._sheetContainerController = new SheetContainerController(this);+ this._modalGroupController = new ModalGroupController(this);// render sheet containerrender(<SheetContainer config={config} />, sheetContainer);- const formulaEngine = this.getPluginByName<FormulaPlugin>('formula')?.getFormulaEngine();+ // const formulaEngine = this.getPluginByName<FormulaPlugin>('formula')?.getFormulaEngine();// =(sum(max(B1:C10,10)*5-100,((1+1)*2+5)/2,10)+count(B1:C10,10*5-100))*5-100// =(sum(max(B1:C10,10)*5-100,((1+1)*2+5)/2,10, lambda(x,y, x*y*x)(sum(1,(1+2)*3),2))+lambda(x,y, x*y*x)(sum(1,(1+2)*3),2)+count(B1:C10,10*5-100))*5-100// =((1+2)-A1:B2 + 5)/2 + sum(indirect("A5"):B10 + A1:offset("C5", 1, 1), 100)// =1+(3*4=4)*5+1// =(-(1+2)--@A1:B2 + 5)/2 + -sum(indirect("A5"):B10# + B6# + A1:offset("C5", 1, 1) , 100) + {1,2,3;4,5,6;7,8,10} + lambda(x,y,z, x*y*z)(sum(1,(1+2)*3),2,lambda(x,y, @offset(A1:B0,x#*y#))(1,2):C20) & "美国人才" + sum((1+2%)*30%, 1+2)%- formulaEngine?.calculate(`=lambda(x,y, x*y*x)(sum(1,(1+2)*3),2)+1-max(100,200)`);+ // formulaEngine?.calculate(`=lambda(x,y, x*y*x)(sum(1,(1+2)*3),2)+1-max(100,200)`);}/**@@ -424,18 +424,19 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {this._rightMenuControl.addItem(item);}- // addToolButton(config: IToolBarItemProps) {- // this._toolBarControl1.addToolButton(config);- // }+ addToolButton(config: IToolBarItemProps) {+ this._toolBarControl.addToolButton(config);+ }registerComponent(name: string, component: any, props?: any) {- this._componentList.set(name, {- component,- props,- });+ this._componentList.set(name, component);}getRegisterComponent(name: string) {return this._componentList.get(name);}++ registerModal(name: string, component: any) {+ this._modalGroupController.addModal(name, component);+ }}diff --git a/packages/base-sheets/src/View/UI/Common/Select/Select.tsx b/packages/base-sheets/src/View/UI/Common/Select/Select.tsxindex 24ccfdacd6..757013107d 100644--- a/packages/base-sheets/src/View/UI/Common/Select/Select.tsx+++ b/packages/base-sheets/src/View/UI/Common/Select/Select.tsx@@ -17,10 +17,17 @@ enum DisplayTypes {SUFFIX,}+interface CustomComponent {+ name: string;+ props?: Record<string, any>;+}+export interface BaseSelectChildrenProps extends BaseItemProps {onKeyUp?: (...arg: any) => void;children?: BaseSelectChildrenProps[];unSelectable?: boolean; //选中后不生效事件+ customLabel?: CustomComponent;+ customSuffix?: CustomComponent;}export interface BaseSelectProps {@@ -34,6 +41,8 @@ export interface BaseSelectProps {hideSelectedIcon?: boolean;selectClassName?: string;name?: string;+ customLabel?: CustomComponent;+ customSuffix?: CustomComponent;}interface IState {@@ -89,7 +98,7 @@ export class Select extends Component<BaseSelectProps, IState> {// 显示值可变if (type === 0 || type === 3) {- if (!children) return;+ if (!children.length) return;let index = children.findIndex((item) => item.selected);if (index < 0) index = 0;const list = this.handleSelected(index);@@ -132,7 +141,7 @@ export class Select extends Component<BaseSelectProps, IState> {};} else if (type === 1) {// 输入框- if (!children) return;+ if (!children.length) return;// 匹配label和选项label确定选中项const getLabel = (label: ComponentChildren) => {if (label !== null) {@@ -186,7 +195,7 @@ export class Select extends Component<BaseSelectProps, IState> {};} else if (type === 4 || type === 5) {//固定显示值- if (!children) return;+ if (!children.length) return;let index = children.findIndex((item) => item.selected);if (index < 0) index = 0;const item = children[index];@@ -224,6 +233,7 @@ export class Select extends Component<BaseSelectProps, IState> {list[i].style = children[i].style;list[i].value = children[i].value;list[i].className = children[i].className;+ list[i].onClick = children[i].onClick;if (children[i].children) {list[i].children = this.getChildren(children[i].children!);@@ -276,12 +286,13 @@ export class Select extends Component<BaseSelectProps, IState> {// 处理选中handleSelected = (index: number | null): BaseMenuItem[] | undefined => {const { children = [], hideSelectedIcon } = this.props;-- children.forEach((item) => {- item.selected = false;- });- if (index !== null) {- children[index].selected = true;+ if (children.length) {+ children.forEach((item) => {+ item.selected = false;+ });+ if (index !== null) {+ children[index].selected = true;+ }}const list = this.resetMenu(children, hideSelectedIcon);@@ -368,7 +379,7 @@ export class Select extends Component<BaseSelectProps, IState> {<div className={`${styles.selectDouble} ${selectClassName}`}><Button type="text"><Dropdown menu={{ menu, onClick: this.onClick }} showArrow>- <div>{label}</div>+ <div className={styles.selectLabel}>{label}</div></Dropdown></Button></div>diff --git a/packages/base-sheets/src/View/UI/ModalGroup/ModalGroup.tsx b/packages/base-sheets/src/View/UI/ModalGroup/ModalGroup.tsxnew file mode 100644index 0000000000..92f2a4b641--- /dev/null+++ b/packages/base-sheets/src/View/UI/ModalGroup/ModalGroup.tsx@@ -0,0 +1,41 @@+import { Component } from '@univer/base-component';+import { PLUGIN_NAMES } from '@univer/core';+import { SpreadsheetPlugin } from '../../../SpreadsheetPlugin';+import { ModalGroupProps } from '../../../Controller/ModalGroupController';++interface IState {+ modalGroup: any[];+}++export class ModalGroup extends Component<any, IState> {+ initialize() {+ this.state = {+ modalGroup: [],+ };+ }++ componentDidMount(): void {+ this._context.getObserverManager().getObserver<ModalGroup>('onModalGroupDidMountObservable')?.notifyObservers(this);+ }++ setModalGroup(group: ModalGroupProps) {+ const plugin = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET);++ const modalGroup = group.map((item) => {+ const Modal = plugin?.getRegisterComponent(item);+ if (Modal) {+ return <Modal />;+ }+ return null;+ });++ this.setState({+ modalGroup,+ });+ }++ render() {+ const { modalGroup } = this.state;+ return <>{modalGroup.map((item) => item)}</>;+ }+}diff --git a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsxindex aed20fe3bb..ef5477f3c9 100644--- a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx+++ b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx@@ -8,7 +8,6 @@ import {Component,BaseComponentSheet,BaseComponentRender,- Description,createRef,RefObject,cloneElement,@@ -33,13 +32,14 @@ import darkSkin from '@univer/style-universheet/assets/css/skin/dark.module.lessimport greenSkin from '@univer/style-universheet/assets/css/skin/green.module.less';// app context for skin and Localeimport { SpreadsheetPlugin } from '@SpreadsheetPlugin';-import { ToolBar1 } from '../ToolBar/ToolBar1';import { RightMenu } from '../RightMenu';import { InfoBar } from '../InfoBar';import { SheetBar } from '../SheetBar';import style from './index.module.less';-import { IShowToolBarConfig } from '../ToolBar';+import { ToolBar } from '../ToolBar';import { CountBar } from '../CountBar/CountBar';+import { IShowToolBarConfig } from '../../../Model/ToolBarModel';+import { ModalGroup } from '../ModalGroup/ModalGroup';export interface ILayout {outerLeft?: boolean;@@ -651,14 +651,7 @@ export class SheetContainer extends Component<BaseSheetContainerProps, IState> {<Layout className={style.mainContent} style={{ position: 'relative' }}><Header style={{ display: layout.header ? 'block' : 'none' }}><InfoBar></InfoBar>- {/* <ToolBar- style={{- display: layout.toolBar ? 'block' : 'none',- }}- toolList={[]}- func={{ addButton }}- ></ToolBar> */}- <ToolBar1 toolList={[]}></ToolBar1>+ <ToolBar toolList={[]}></ToolBar><FormulaBar></FormulaBar></Header><Layout>@@ -693,7 +686,7 @@ export class SheetContainer extends Component<BaseSheetContainerProps, IState> {</Sider><Content className={layout.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>{/* extend main content */}- {mainList.map((item: IMainState, i) => {+ {/* {mainList.map((item: IMainState, i) => {// if (!item.show) return null;if (item.type === ISlotElement.JSX) {@@ -712,7 +705,9 @@ export class SheetContainer extends Component<BaseSheetContainerProps, IState> {return <JSXElement ref={this.refMap[item.name]} style={{ display: item.show ? '' : 'none' }} />;}return item;- })}+ })} */}++ <ModalGroup></ModalGroup>{!!layout.contentSplit && (<Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>diff --git a/packages/base-sheets/src/View/UI/ToolBar/Const.ts b/packages/base-sheets/src/View/UI/ToolBar/Const.tsindex dc68ce742c..1701d084f8 100644--- a/packages/base-sheets/src/View/UI/ToolBar/Const.ts+++ b/packages/base-sheets/src/View/UI/ToolBar/Const.ts@@ -62,67 +62,6 @@ export const FONT_SIZE_CHILDREN = [},];-export const MORE_FORMATS_CHILDREN = [- {- locale: 'defaultFmt.Automatic.text',- selected: true,- },- {- locale: 'defaultFmt.PlainText.text',- border: true,- },- {- locale: 'defaultFmt.Number.text',- suffixLocale: 'defaultFmt.Number.example',- },- {- locale: 'defaultFmt.Percent.text',- suffixLocale: 'defaultFmt.Percent.example',- },- {- locale: 'defaultFmt.Scientific.text',- suffixLocale: 'defaultFmt.Scientific.example',- border: true,- },- {- locale: 'defaultFmt.Accounting.text',- suffixLocale: 'defaultFmt.Accounting.example',- },- {- locale: 'defaultFmt.Thousand.text',- suffixLocale: 'defaultFmt.Thousand.example',- },- {- locale: 'defaultFmt.Currency.text',- suffixLocale: 'defaultFmt.Currency.example',- },- {- locale: 'defaultFmt.Digit.text',- suffixLocale: 'defaultFmt.Digit.example',- border: true,- },- {- locale: 'defaultFmt.Date.text',- suffixLocale: 'defaultFmt.Date.example',- },- {- locale: 'defaultFmt.Time.text',- suffixLocale: 'defaultFmt.Time.example',- },- {- locale: 'defaultFmt.Time24H.text',- suffixLocale: 'defaultFmt.Time24H.example',- },- {- locale: 'defaultFmt.DateTime.text',- suffixLocale: 'defaultFmt.DateTime.example',- },- {- locale: 'defaultFmt.DateTime24H.text',- suffixLocale: 'defaultFmt.DateTime.example',- },-];-export const FONT_FAMILY_CHILDREN = [{locale: 'fontFamily.TimesNewRoman',@@ -210,54 +149,74 @@ export const FONT_FAMILY_CHILDREN = [export const BORDER_LINE_CHILDREN = [{locale: 'borderLine.borderTop',- suffix: 'TopBorderIcon',+ customSuffix: {+ name: 'TopBorderIcon',+ },value: 'top',},{locale: 'borderLine.borderBottom',- suffix: 'BottomBorderIcon',+ customSuffix: {+ name: 'BottomBorderIcon',+ },value: 'bottom',},{locale: 'borderLine.borderLeft',- suffix: 'LeftBorderIcon',+ customSuffix: {+ name: 'LeftBorderIcon',+ },value: 'left',},{locale: 'borderLine.borderRight',- suffix: 'RightBorderIcon',+ customSuffix: {+ name: 'RightBorderIcon',+ },value: 'right',border: true,},{locale: 'borderLine.borderNone',- suffix: 'NoneBorderIcon',+ customSuffix: {+ name: 'NoneBorderIcon',+ },value: 'none',},{locale: 'borderLine.borderAll',- suffix: 'FullBorderIcon',+ customSuffix: {+ name: 'FullBorderIcon',+ },value: 'all',selected: true,},{locale: 'borderLine.borderOutside',- suffix: 'OuterBorderIcon',+ customSuffix: {+ name: 'OuterBorderIcon',+ },value: 'outside',},{locale: 'borderLine.borderInside',- suffix: 'InnerBorderIcon',+ customSuffix: {+ name: 'InnerBorderIcon',+ },value: 'inside',},{locale: 'borderLine.borderHorizontal',- suffix: 'StripingBorderIcon',+ customSuffix: {+ name: 'StripingBorderIcon',+ },value: 'horizontal',},{locale: 'borderLine.borderVertical',- suffix: 'VerticalBorderIcon',+ customSuffix: {+ name: 'VerticalBorderIcon',+ },value: 'vertical',},];@@ -284,17 +243,23 @@ export const MERGE_CHILDREN = [export const HORIZONTAL_ALIGN_CHILDREN = [{locale: 'align.left',- suffix: 'LeftAlignIcon',+ customSuffix: {+ name: 'LeftAlignIcon',+ },value: 1,},{locale: 'align.center',- suffix: 'CenterAlignIcon',+ customSuffix: {+ name: 'CenterAlignIcon',+ },value: 2,},{locale: 'align.right',- suffix: 'RightAlignIcon',+ customSuffix: {+ name: 'RightAlignIcon',+ },value: 3,},];@@ -302,17 +267,23 @@ export const HORIZONTAL_ALIGN_CHILDREN = [export const VERTICAL_ALIGN_CHILDREN = [{locale: 'align.top',- suffix: 'TopVerticalIcon',+ customSuffix: {+ name: 'TopVerticalIcon',+ },value: 1,},{locale: 'align.middle',- suffix: 'CenterVerticalIcon',+ customSuffix: {+ name: 'CenterVerticalIcon',+ },value: 2,},{locale: 'align.bottom',- suffix: 'BottomVerticalIcon',+ customSuffix: {+ name: 'BottomVerticalIcon',+ },value: 3,},];@@ -320,17 +291,23 @@ export const VERTICAL_ALIGN_CHILDREN = [export const TEXT_WRAP_CHILDREN = [{locale: 'textWrap.overflow',- suffix: 'OverflowIcon',+ customSuffix: {+ name: 'OverflowIcon',+ },value: 1,},{locale: 'textWrap.wrap',- suffix: 'BrIcon',+ customSuffix: {+ name: 'BrIcon',+ },value: 3,},{locale: 'textWrap.clip',- suffix: 'CutIcon',+ customSuffix: {+ name: 'CutIcon',+ },value: 2,},];@@ -338,32 +315,44 @@ export const TEXT_WRAP_CHILDREN = [export const TEXT_ROTATE_CHILDREN = [{locale: 'textRotate.none',- suffix: 'TextRotateIcon',+ customSuffix: {+ name: 'TextRotateIcon',+ },value: 0,},{locale: 'textRotate.angleUp',- suffix: 'TextRotateAngleUpIcon',+ customSuffix: {+ name: 'TextRotateAngleUpIcon',+ },value: -45,},{locale: 'textRotate.angleDown',- suffix: 'TextRotateAngleDownIcon',+ customSuffix: {+ name: 'TextRotateAngleDownIcon',+ },value: 45,},{locale: 'textRotate.vertical',- suffix: 'TextRotateVerticalIcon',+ customSuffix: {+ name: 'TextRotateVerticalIcon',+ },value: 'v',},{locale: 'textRotate.rotationUp',- suffix: 'TextRotateRotationUpIcon',+ customSuffix: {+ name: 'TextRotateRotationUpIcon',+ },value: -90,},{locale: 'textRotate.rotationDown',- suffix: 'TextRotateRotationDownIcon',+ customSuffix: {+ name: 'TextRotateRotationDownIcon',+ },value: 90,},];diff --git a/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsx b/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsxindex 707821b983..558b263d1b 100644--- a/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsx+++ b/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsx@@ -1,253 +1,54 @@-import {- BaseComponentRender,- BaseComponentSheet,- BaseToolBarProps,- Component,- createRef,- IToolBarItemProps,- ISlotElement,- RefObject,- Description,- DescriptionEnum,- BaseSelectProps,-} from '@univer/base-component';-import { Nullable, Observer, PLUGIN_NAMES, Workbook } from '@univer/core';+import { BaseComponentProps, BaseComponentRender, BaseComponentSheet, Component, createRef } from '@univer/base-component';+import { PLUGIN_NAMES } from '@univer/core';+import { IToolBarItemProps } from '../../../Model/ToolBarModel';import { SpreadsheetPlugin } from '../../../SpreadsheetPlugin';-+import { Select } from '../Common/Select/Select';+import { TextButton } from '../Common/TextButton/TextButton';import styles from './index.module.less';-import { SingleButton } from './SingleButton';--export interface IShowToolBarConfig {- undoRedo?: boolean; // Undo redo- paintFormat?: boolean; // Format brush- currencyFormat?: boolean; // currency format- percentageFormat?: boolean; // Percentage format- numberDecrease?: boolean; // 'Decrease the number of decimal places'- numberIncrease?: boolean; // 'Increase the number of decimal places- moreFormats?: boolean; // 'More Formats'- font?: boolean; // 'font'- fontSize?: boolean; // 'Font size'- bold?: boolean; // 'Bold (Ctrl+B)'- italic?: boolean; // 'Italic (Ctrl+I)'- strikethrough?: boolean; // 'Strikethrough (Alt+Shift+5)'- underline?: boolean; // 'Underline (Alt+Shift+6)'- textColor?: boolean; // 'Text color'- fillColor?: boolean; // 'Cell color'- border?: boolean; // 'border'- mergeCell?: boolean; // 'Merge cells'- horizontalAlignMode?: boolean; // 'Horizontal alignment'- verticalAlignMode?: boolean; // 'Vertical alignment'- textWrapMode?: boolean; // 'Wrap mode'- textRotateMode?: boolean; // 'Text Rotation Mode'- image?: boolean; // 'Insert picture'- link?: boolean; // 'Insert link'- chart?: boolean; // 'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)- comment?: boolean; // 'comment'- pivotTable?: boolean; // 'PivotTable'- function?: boolean; // 'formula'- frozenMode?: boolean; // 'freeze mode'- sortAndFilter?: boolean; // 'Sort and filter'- conditionalFormat?: boolean; // 'Conditional Format'- dataValidation?: boolean; // 'Data Validation'- splitColumn?: boolean; // 'Split column'- screenshot?: boolean; // 'screenshot'- findAndReplace?: boolean; // 'Find and Replace'- protection?: boolean; // 'Worksheet protection'- print?: boolean; // 'Print'+interface IProps extends BaseComponentProps {+ style?: JSX.CSSProperties;+ toolList: IToolBarItemProps[];+ // forwardRefs?: RefObject<HTMLElement>;}interface IState {toolList: IToolBarItemProps[];moreToolList: IToolBarItemProps[];defaultToolList: IToolBarItemProps[];- changeLabel: string[];more: boolean;index: number;toolbarListWidths: number[];moreText: string;}-/**- * button type- *- * 1. single : single button- * 2. select : click button, alert select options- * 3. doubleButton : left single button, right select- * 4. doubleButtonPopup : left single button, right popup- */-export class ToolBar extends Component<BaseToolBarProps, IState> {+export class ToolBar extends Component<IProps, IState> {toolbarWarp = createRef();- toolbar = createRef();+ toolbarRef = createRef();moreBtn = createRef();- FormatModal = createRef();-moreToolRef = createRef();- Render: BaseComponentRender;+ SelectRef = createRef();- private _localeObserver: Nullable<Observer<Workbook>>;-- initialize(props: BaseToolBarProps) {- // super(props);-- const { toolList, func } = props;-- // const { func } = this.props;- func?.addButton(this.addButton.bind(this));+ Render: BaseComponentRender;+ initialize(props: IProps) {const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;this.Render = component.getComponentRender();this.state = {// Button contains main button and drop down arrow, translation file contains main and right- changeLabel: ['horizontalAlignMode', 'verticalAlignMode', 'textWrapMode', 'textRotateMode', 'fillColor', 'textColor', 'border', 'mergeCell'],more: false,- toolList,+ toolList: [],defaultToolList: [],moreToolList: [],index: 0,toolbarListWidths: [],moreText: '',};-- this.initEvent();- }-- initEvent() {- // this.getContext()- // .getObserverManager()- // .getObserver('onSheetRenderDidMountObservable', 'workbook')- // ?.add((e) => {- // const mainComponent = this.getContext().getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;- // mainComponent.getMainComponent().onPointerUpObserver.add((evt: IPointerEvent | IMouseEvent) => {- // const { offsetX: evtOffsetX, offsetY: evtOffsetY } = evt;- // console.log('----mainCom----', evt);- // });- // });- }-- handleClickMoreFormats(...args: any[]) {- // console.dir(args);- }-- handleClick = (children: IToolBarItemProps, toolbarIndex: number, childrenIndex: number) => {- let prevState = this.state.toolList;- const changeLabel = this.state.changeLabel;- if (changeLabel.includes(prevState[toolbarIndex].locale!)) prevState[toolbarIndex].label! = children.icon!;- prevState[toolbarIndex].children?.forEach((item, i) => {- item.selected = i === childrenIndex;- });- this.setState({ toolList: prevState });- };-- click = (toolbarIndex: number) => {- console.log(`this is ${this.state.toolList[toolbarIndex].locale}`);- };-- // showFormatModal- showFormatModal = (e: MouseEvent, name: string) => {- this.FormatModal.current.showModal(name, true);- };-- /**- * set toollist by config setting and Locale message, some buttons will be hidden- */- setLocale(cb: () => void) {- const locale = this.context.locale;-- const more = locale.get('toolbar.more');-- this.setState((prevState) => {- const currentToolList = prevState.toolList.map((item) => {- // set current Locale string for tooltip- item.tooltip = locale.get(`toolbar.${item.locale}`);-- if (this.state.changeLabel.includes(item.locale!)) {- item.tooltip = locale.get(`toolbar.${item.locale}.main`);- item.tooltipRight = locale.get(`toolbar.${item.locale}.right`);- }- // set current Locale string for select- if (item.type === 'select') {- if (!item.children?.length) return item;- this.setLocalIconAndLabel(item);-- // null or undefined- if (!item.label) {- item.label = typeof item.label === 'object' ? item.label : item.children[0].label;- }- // string, or JSX instanceof JSX.Element, HTML string- }-- // other props-- return item;- });-- return {- toolList: currentToolList,- defaultToolList: currentToolList,- moreText: more,- };- }, cb);- }-- setLocalIconAndLabel(item: IToolBarItemProps) {- const locale = this.context.locale;- if (item.children) {- item.children.forEach((ele) => {- if (ele.locale) {- ele.label = locale.get(`${ele.locale}`);- }- if (ele.iconName) {- ele.icon = locale.get(`${ele.iconName}`);- }-- this.setLocalIconAndLabel(ele);- });- }- }-- /**- * add plugin button- */- addButton(item: IToolBarItemProps): Promise<void> {- /**- * en: There will be multiple toolbar buttons added, so you need to use prevState to add buttons from the previous state, otherwise it will cause overwriting- *- * zh: 会有多个工具栏按钮添加进来,所以需要使用prevState来从上一个状态新增按钮,否则会造成覆盖- *- * TODO: 节流,多个Button一次性渲染- */- return new Promise((resolve) => {- this.setState(- (prevState) => ({- toolList: [...prevState.toolList, item],- defaultToolList: [...prevState.toolList, item],- }),- () => {- resolve();- // this.setToolbarListWidth- }- );- });- }-- setToolBar(toolList: IToolBarItemProps[]) {- this.setState(- {- toolList,- },- () => {- this.setLocale(() => {- // this.setToolbarListWidth();- // this.resetToolbar();- });- }- );}/**@@ -303,6 +104,49 @@ export class ToolBar extends Component<BaseToolBarProps, IState> {);};+ resetLabel = (toolList: any[]) => {+ const plugin = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET);++ for (let i = 0; i < toolList.length; i++) {+ const item = toolList[i];++ // 优先寻找自定义组件+ if (item.customLabel) {+ const Label = plugin?.getRegisterComponent(item.customLabel.name);+ if (Label) {+ const props = item.customLabel.props ?? {};+ item.label = <Label {...props} />;+ }+ }++ if (item.customSuffix) {+ const Suffix = plugin?.getRegisterComponent(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);++ this.setState(+ {+ toolList,+ },+ () => {+ this.resetToolbar();+ }+ );+ };+resetToolbar = () => {/*** TODO: resize 有性能问题。@@ -320,245 +164,80 @@ export class ToolBar extends Component<BaseToolBarProps, IState> {*/const toolbarWarp = this.toolbarWarp;- // const bodyWidth = document.body.clientWidth - (152 * 2 + 70);- const toolbarList = this.state.toolbarListWidths;- let index = toolbarList.length;- for (let i = 0; i < toolbarList.length; i++) {- let itemLeft = toolbarList[i];- // console.log(toolbarList);-- // console.log(itemLeft, toolbarWarp.current.offsetWidth - 60);-- if (itemLeft > toolbarWarp.current.offsetWidth - 60) {- index = i - 1;- break;- }- }- this.setState((preState) => {- const defaultToolList = preState.toolList.slice(0, index);- // 获取contentref- const wrapper = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.getContentRef().current!;- // const wrapper = $$('.univer-content-inner-right-container');- const height = `${(wrapper as HTMLDivElement).offsetHeight}px`;- // 下拉框最大高度设置为content高度- defaultToolList.forEach((item) => {- if (item.type === 'select') {- if (item.style) {- item.style = { ...item.style, maxHeight: height };- } else {- item.style = { maxHeight: height };- }+ // const toolbarList = this.state.toolbarListWidths;+ // let index = toolbarList.length;+ // for (let i = 0; i < toolbarList.length; i++) {+ // let itemLeft = toolbarList[i];+ // if (itemLeft > toolbarWarp.current.offsetWidth - 60) {+ // index = i - 1;+ // break;+ // }+ // }+ this.setState(+ (preState) => {+ // const defaultToolList = preState.toolList.slice(0, index);+ const defaultToolList = preState.toolList;+ // const moreToolList = preState.toolList.slice(index);+ const moreToolList: IToolBarItemProps[] = [];++ return {+ defaultToolList,+ moreToolList,+ };+ },+ () => {+ // 获取contentref,Ul限制高度+ const wrapper = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.getContentRef().current!;+ const height = `${(wrapper as HTMLDivElement).offsetHeight}px`;+ const ul = this.toolbarRef.current.querySelectorAll('ul');+ for (let i = 0; i < ul.length; i++) {+ ul[i].style.maxHeight = height;}- });-- const moreToolList = preState.toolList.slice(index);- return {- defaultToolList,- moreToolList,- };- });+ }+ );};- /**- * init- */- componentWillMount() {- // // init Locale message- // this.setLocale();- // // when change Locale, update Locale message- // // do not use componentWillUpdate,it will listen all state changes- // this._localeObserver = this._context- // .getObserverManager()- // .getObserver<WorkBook>('onAfterChangeUILocaleObservable', 'workbook')- // ?.add(() => {- // this.setLocale();- // });- // // resize listener- // window.addEventListener('resize', debounce(this.resetToolbar, 300));- // this.setState((prevState) => ({- // defaultToolList: prevState.toolList,- // index: prevState.toolList.length,- // }));- }-componentDidMount() {- // this.setToolbarListWidth();- // this.resetToolbar();-this._context.getObserverManager().getObserver<ToolBar>('onToolBarDidMountObservable')?.notifyObservers(this);}- /**- * when change Locale, update Locale message- */- componentWillUnmount() {- // this._context.getObserverManager().getObserver<WorkBook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- // window.removeEventListener('resize', debounce(this.resetToolbar, 300));- }-- toolbarListRender(tool: IToolBarItemProps[]) {- let ele = tool.map((item: IToolBarItemProps, index: number) => {- if (!item.show) return null;-- this.itemRender(item);-- if (item.type === ISlotElement.SINGLE) {- return (- <SingleButton- tooltip={item.tooltip}- key={item.locale}- name={item.locale}- label={item.label}- icon={item.icon}- onClick={item.onClick}- active={item.selected}- triggerUpdate={item.triggerUpdate}- ></SingleButton>- );- }-- if (item.type === ISlotElement.SELECT) {- const Select = this.Render.renderFunction('Select');- return (- <Select- tooltip={item.tooltip}- tooltipRight={item.tooltipRight}- key={item.locale}- children={item.children as BaseSelectProps[]}- label={item.label}- icon={item.icon}- needChange={item.needChange}- selectType={item.selectType}- border={item.border}- style={item.style}- slot={item.slot || {}}- onKeyUp={item.onKeyUp}- onClick={item.onClick}- triggerUpdate={item.triggerUpdate}- />- );- }-- if (item.type === ISlotElement.JSX) {- return item.label;- }-- return null;- });- return ele;- }-- itemRender(item: IToolBarItemProps) {- const includeNumber = /\d/;-- // handle icon string to Icon JSX.Element- if (typeof item.icon === 'string' && !includeNumber.test(item.icon) && Number.isNaN(Number(item.icon)) && DescriptionEnum[DescriptionEnum[item.icon]]) {- const IconEle = this.Render.renderFunction(item.icon as keyof Description);- item.icon = <IconEle />;- }-- if (item.label === 'BorderLineColorPicker') {- const ColorPicker = this.Render.renderFunction('ColorPicker');- item.label = (- <ColorPicker- style={{ visibility: 'visible', position: 'relative', boxShadow: 'none' }}- color="#000"- onClick={(color) => {- // Update selected color- item.value = color;- }}- onCancel={() => {}}- />- );- }- // handle label string to Label JSX.Element- else if (typeof item.label === 'string' && !includeNumber.test(item.label) && Number.isNaN(Number(item.label)) && DescriptionEnum[DescriptionEnum[item.label]]) {- const LabelEle = this.Render.renderFunction(item.label as keyof Description);- item.label = <LabelEle />;- }-- // handle border line border size- if (item.locale === 'borderLine.borderSize') {- item.onClick = (ele, itemInfo) => {- item.value = itemInfo.item.value;- };- }-- // Secondary menu- if (item.children) {- item.children.forEach((childItem: IToolBarItemProps) => {- this.itemRender(childItem);- });- }- }-- render(props: BaseToolBarProps, state: IState) {- const { style, forwardRefs } = props;+ render(props: IProps, state: IState) {const { defaultToolList } = state;- // Reference forwardRef to current toolbar ref- this.toolbar = forwardRefs as RefObject<HTMLElement>;const Button = this.Render.renderFunction('Button');const Container = this.Render.renderFunction('Container');const Tooltip = this.Render.renderFunction('Tooltip');- const FormatModal = this.Render.renderFunction('FormatModal');return (<Container style={{ position: 'relative' }}><div className={styles.toolbarWarp} ref={this.toolbarWarp}>- <div className={styles.toolbar} ref={this.toolbar}>- {this.toolbarListRender(this.state.defaultToolList)}- {/* {defaultToolList.length > 0 &&- defaultToolList.map((item: IToolBarItemProps, index: number) => {- if (!item.show) return null;-- this.itemRender(item);-- if (item.type === 'single') {- return (- <SingleButton- tooltip={item.tooltip}- key={item.locale}- name={item.locale}- label={item.label}- icon={item.icon}- onClick={() => {- // TODO set active status style- item.selected = !item.selected;- item.onClick && item.onClick(item.selected);- }}- active={item.selected}- ></SingleButton>- );- }-- if (item.type === 'select') {- const Select = this.Render.renderFunction('Select');- return (- <Select- tooltip={item.tooltip}- tooltipRight={item.tooltipRight}- key={item.locale}- children={item.children as BaseSelectProps[]}- label={item.label}- icon={item.icon}- needChange={item.needChange}- selectType={item.selectType}- border={item.border}- style={item.style}- slot={item.slot || {}}- onKeyUp={item.onKeyUp}- onClick={item.onClick}- />- );- }-- if (item.type === ISlotElement.JSX) {- return item.label;- }-- return null;- })} */}+ <div className={styles.toolbar} ref={this.toolbarRef}>+ {defaultToolList.map((item) => {+ if (item.toolbarType) {+ return (+ <Tooltip title={item.tooltip} placement={'bottom'}>+ <TextButton label={item.label} onClick={item.onClick}></TextButton>+ </Tooltip>+ );+ }+ return (+ <Tooltip title={item.tooltip} placement={'bottom'}>+ <Select+ type={item.type}+ display={item.display}+ children={item.children}+ customLabel={item.customLabel}+ customSuffix={item.customSuffix}+ label={item.label}+ onClick={item.onClick}+ onKeyUp={item.onKeyUp}+ defaultColor={item.defaultColor}+ hideSelectedIcon={item.hideSelectedIcon}+ selectClassName={item.selectClassName}+ ></Select>+ </Tooltip>+ );+ })}</div>{this.state.moreToolList.length === 0 ? null : (<div ref={this.moreBtn} className={styles.singleButton}>@@ -571,10 +250,7 @@ export class ToolBar extends Component<BaseToolBarProps, IState> {)}</div>- <div className={`${styles.moreTool} ${this.state.more ? styles.moreShow : null}`} ref={this.moreToolRef}>- {/* {this.toolbarListRender(this.state.moreToolList)} */}- </div>- <FormatModal ref={this.FormatModal}></FormatModal>+ <div className={`${styles.moreTool} ${this.state.more ? styles.moreShow : null}`} ref={this.moreToolRef}></div></Container>);}diff --git a/packages/base-sheets/src/View/UI/ToolBar/ToolBar1.tsx b/packages/base-sheets/src/View/UI/ToolBar/ToolBar1.tsxdeleted file mode 100644index 47684ed198..0000000000--- a/packages/base-sheets/src/View/UI/ToolBar/ToolBar1.tsx+++ /dev/null@@ -1,253 +0,0 @@-import { BaseComponentProps, BaseComponentRender, BaseComponentSheet, Component, createRef, RefObject } from '@univer/base-component';-import { PLUGIN_NAMES } from '@univer/core';-import { IToolBarItemProps } from '../../../Model/ToolBarModal1';-import { SpreadsheetPlugin } from '../../../SpreadsheetPlugin';-import { Select } from '../Common/Select/Select';-import { TextButton } from '../Common/TextButton/TextButton';-import styles from './index.module.less';--interface IProps extends BaseComponentProps {- style?: JSX.CSSProperties;- toolList: IToolBarItemProps[];- forwardRefs?: RefObject<HTMLElement>;-}--interface IState {- toolList: IToolBarItemProps[];- moreToolList: IToolBarItemProps[];- defaultToolList: IToolBarItemProps[];- more: boolean;- index: number;- toolbarListWidths: number[];- moreText: string;-}--export class ToolBar1 extends Component<IProps, IState> {- toolbarWarp = createRef();-- toolbarRef = createRef();-- moreBtn = createRef();-- moreToolRef = createRef();-- SelectRef = createRef();-- Render: BaseComponentRender;-- initialize(props: IProps) {- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();-- this.state = {- // Button contains main button and drop down arrow, translation file contains main and right- more: false,- toolList: [],- defaultToolList: [],- moreToolList: [],- index: 0,- toolbarListWidths: [],- moreText: '',- };- }-- /**- * show more tool buttons- *- * TODO : 点击其他地方需要隐藏more buttons- */- moreTool = () => {- let more = this.state.more;- this.setState({ more: !more });-- if (!more) {- document.addEventListener('click', this.hide, true);- }- };-- hide = (e: Event) => {- if (this.moreToolRef.current.contains(e.target)) return;- e.stopImmediatePropagation();- this.setState({ more: false });- document.removeEventListener('click', this.hide, true);- };-- /**- * Gets the distance of each button from the parent element- */- setToolbarListWidth = () => {- const toolbar = this.toolbarWarp.current.querySelector(`.${styles.toolbar}`);- const toolbarLeft = toolbar.getBoundingClientRect().left;- const toolbarListWidths: number[] = []; // 每个 btn 离父元素 left 距离- const toolbarListWidths1: number[] = []; // 每个 btn 离父元素 left 距离-- toolbar.childNodes.forEach((item: Element, i: number) => {- toolbarListWidths.push(parseInt((item.getBoundingClientRect().left - toolbarLeft + item.getBoundingClientRect().width).toString()));- });- let max = 0;- let count = 0;- toolbarListWidths1.push(toolbarListWidths[0]);- toolbarListWidths.reduce((prev, next) => {- if (prev > next && count === 0) {- max = prev;- count++;- }- toolbarListWidths1.push(next + max);- return next + max;- });-- this.setState(- () => ({- toolbarListWidths: toolbarListWidths1,- }),- this.resetToolbar- );- };-- resetLabel = (toolList: any[]) => {- const plugin = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET);-- for (let i = 0; i < toolList.length; i++) {- const item = toolList[i];-- // 优先寻找自定义组件- const component = plugin?.getRegisterComponent(item.label);- if (component) {- const Label = component.component;- const props = component.props ?? {};- item.label = <Label {...props} />;- }-- const suffixComponent = plugin?.getRegisterComponent(item.suffix);- if (suffixComponent) {- const Suffix = suffixComponent.component;- const props = suffixComponent.props ?? {};- item.suffix = <Suffix {...props} />;- }-- if (item.children) {- item.children = this.resetLabel(item.children);- }- }- return toolList;- };-- setToolBar = (toolList: any[]) => {- toolList = this.resetLabel(toolList);-- this.setState(- {- toolList,- },- () => {- this.resetToolbar();- }- );- };-- resetToolbar = () => {- /**- * TODO: resize 有性能问题。- * 思路- *- * 1. toolbarWarp.current.offsetWidth 存储起来- * 2. 节流- * 3. 插件主UI拆分到其他插槽,只有按钮和简单的items放到工具栏- *- *- * zh: 根据插件数组长度,最后一个插件安装完成,执行一次。后面动态安装的插件,每安装一次计算一次- *- * en: According to the length of the plug-in array, the last plug-in is installed and executed once. The dynamically installed plugins will be calculated once for each installation- *- */-- const toolbarWarp = this.toolbarWarp;- // const toolbarList = this.state.toolbarListWidths;- // let index = toolbarList.length;- // for (let i = 0; i < toolbarList.length; i++) {- // let itemLeft = toolbarList[i];- // if (itemLeft > toolbarWarp.current.offsetWidth - 60) {- // index = i - 1;- // break;- // }- // }- this.setState(- (preState) => {- // const defaultToolList = preState.toolList.slice(0, index);- const defaultToolList = preState.toolList;- // const moreToolList = preState.toolList.slice(index);- const moreToolList: IToolBarItemProps[] = [];-- return {- defaultToolList,- moreToolList,- };- },- () => {- // 获取contentref,Ul限制高度- const wrapper = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)?.getContentRef().current!;- const height = `${(wrapper as HTMLDivElement).offsetHeight}px`;- const ul = this.toolbarRef.current.querySelectorAll('ul');- for (let i = 0; i < ul.length; i++) {- ul[i].style.maxHeight = height;- }- }- );- };-- componentDidMount() {- this._context.getObserverManager().getObserver<ToolBar1>('onToolBar1DidMountObservable')?.notifyObservers(this);- }-- render(props: IProps, state: IState) {- const { defaultToolList } = state;-- const Button = this.Render.renderFunction('Button');- const Container = this.Render.renderFunction('Container');- const Tooltip = this.Render.renderFunction('Tooltip');-- return (- <Container style={{ position: 'relative' }}>- <div className={styles.toolbarWarp} ref={this.toolbarWarp}>- <div className={styles.toolbar} ref={this.toolbarRef}>- {defaultToolList.map((item) => {- if (item.toolbarType) {- return (- <Tooltip title={item.tooltip} placement={'bottom'}>- <TextButton label={item.label} onClick={item.onClick}></TextButton>- </Tooltip>- );- }- return (- <Tooltip title={item.tooltip} placement={'bottom'}>- <Select- type={item.type}- display={item.display}- children={item.children}- label={item.label}- onClick={item.onClick}- onKeyUp={item.onKeyUp}- defaultColor={item.defaultColor}- hideSelectedIcon={item.hideSelectedIcon}- selectClassName={item.selectClassName}- ></Select>- </Tooltip>- );- })}- </div>- {this.state.moreToolList.length === 0 ? null : (- <div ref={this.moreBtn} className={styles.singleButton}>- <Tooltip title={this.state.moreText} placement={'bottom'}>- <Button type="text" onClick={this.moreTool}>- <div style={{ fontSize: '14px' }}>{this.state.moreText}</div>- </Button>- </Tooltip>- </div>- )}- </div>-- <div className={`${styles.moreTool} ${this.state.more ? styles.moreShow : null}`} ref={this.moreToolRef}></div>- </Container>- );- }-}diff --git a/packages/base-sheets/src/main.tsx b/packages/base-sheets/src/main.tsxindex b4c3e8849e..d2dd409405 100644--- a/packages/base-sheets/src/main.tsx+++ b/packages/base-sheets/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { UniverComponentSheet } from '@univer/style-universheet';import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';-import { DEFAULT_FORMULA_DATA, FormulaPlugin } from '@univer/sheets-plugin-formula';import { NumfmtPlugin } from '@univer/sheets-plugin-numfmt';const uiDefaultConfigUp = {@@ -24,7 +23,7 @@ const uiDefaultConfigUp = {const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());-FormulaPlugin.create(DEFAULT_FORMULA_DATA).installTo(univerSheetUp);+// FormulaPlugin.create(DEFAULT_FORMULA_DATA).installTo(univerSheetUp);// init spreadsheet plugin firstimport('./SpreadsheetPlugin').then(({ SpreadsheetPlugin }) => {@@ -33,6 +32,7 @@ import('./SpreadsheetPlugin').then(({ SpreadsheetPlugin }) => {let numfmtPlugin = new NumfmtPlugin();univerSheetUp.installPlugin(spreadsheetPlugin);univerSheetUp.installPlugin(clipboardPlugin);+ // univerSheetUp.installPlugin(new FindPlugin());+ univerSheetUp.installPlugin(new NumfmtPlugin());(window as any).spreadsheetPlugin = spreadsheetPlugin;- univerSheetUp.installPlugin(numfmtPlugin);});diff --git a/packages/sheets-plugin-alternating-colors/src/AlternatingColorsPlugin.tsx b/packages/sheets-plugin-alternating-colors/src/AlternatingColorsPlugin.tsxindex 8ab32a7331..fb5767af20 100644--- a/packages/sheets-plugin-alternating-colors/src/AlternatingColorsPlugin.tsx+++ b/packages/sheets-plugin-alternating-colors/src/AlternatingColorsPlugin.tsx@@ -1,6 +1,6 @@-import { IMainProps, ISlotElement, ISlotProps, IToolBarItemProps } from '@univer/base-component';-import { SheetsCommand, Context, IOCContainer, UniverSheet, Nullable, Plugin, PLUGIN_NAMES } from '@univer/core';-import { SpreadsheetPlugin } from '@univer/base-sheets';+import { ISlotElement, ISlotProps } from '@univer/base-component';+import { Context, IOCContainer, UniverSheet, Nullable, Plugin, PLUGIN_NAMES } from '@univer/core';+import { IToolBarItemProps, SpreadsheetPlugin } from '@univer/base-sheets';import { Banding } from './Banding';import { IAddBandingActionData } from './Command';import { ACTION_NAMES } from './Command/ACTION_NAMES';@@ -69,13 +69,13 @@ export class AlternatingColorsPlugin extends Plugin {this.spreadsheetPlugin?.addSider(panelItem);// extend main area- const mainItem: IMainProps = {- name: ALTERNATING_COLORS_PLUGIN_NAME,- type: ISlotElement.JSX,- content: <div>middle alternating</div>,- };+ // const mainItem: IMainProps = {+ // name: ALTERNATING_COLORS_PLUGIN_NAME,+ // type: ISlotElement.JSX,+ // content: <div>middle alternating</div>,+ // };- this.spreadsheetPlugin?.addMain(mainItem);+ // this.spreadsheetPlugin?.addMain(mainItem);this.spreadsheetPlugin?.showMainByName(ALTERNATING_COLORS_PLUGIN_NAME, true);}diff --git a/packages/sheets-plugin-alternating-colors/src/main.tsx b/packages/sheets-plugin-alternating-colors/src/main.tsxindex 2ffea546df..2dcb451a9f 100644--- a/packages/sheets-plugin-alternating-colors/src/main.tsx+++ b/packages/sheets-plugin-alternating-colors/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { AlternatingColorsPlugin } from './AlternatingColorsPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -15,4 +14,4 @@ univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new AlternatingColorsPlugin({ value: [] }));+// univerSheetUp.installPlugin(new AlternatingColorsPlugin({ value: [] }));diff --git a/packages/sheets-plugin-comment/src/main.tsx b/packages/sheets-plugin-comment/src/main.tsxindex 21a29020ee..aec5c5aa40 100644--- a/packages/sheets-plugin-comment/src/main.tsx+++ b/packages/sheets-plugin-comment/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { CommentPlugin } from './CommentPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new CommentPlugin());+// univerSheetUp.installPlugin(new CommentPlugin());diff --git a/packages/sheets-plugin-conditional-format/src/main.tsx b/packages/sheets-plugin-conditional-format/src/main.tsxindex c21611366d..8360a3bfa3 100644--- a/packages/sheets-plugin-conditional-format/src/main.tsx+++ b/packages/sheets-plugin-conditional-format/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { ConditionalFormatPlugin } from './ConditionalFormatPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new ConditionalFormatPlugin());+// univerSheetUp.installPlugin(new ConditionalFormatPlugin());diff --git a/packages/sheets-plugin-data-validation/src/main.tsx b/packages/sheets-plugin-data-validation/src/main.tsxindex 9c3936a0f0..fec99c4612 100644--- a/packages/sheets-plugin-data-validation/src/main.tsx+++ b/packages/sheets-plugin-data-validation/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { DataValidationPlugin } from './DataValidationPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new DataValidationPlugin());+// univerSheetUp.installPlugin(new DataValidationPlugin());diff --git a/packages/sheets-plugin-filter/src/main.tsx b/packages/sheets-plugin-filter/src/main.tsxindex eb1bdba7b8..cb3798ed53 100644--- a/packages/sheets-plugin-filter/src/main.tsx+++ b/packages/sheets-plugin-filter/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { FilterPlugin } from './FilterPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new FilterPlugin());+// univerSheetUp.installPlugin(new FilterPlugin());diff --git a/packages/sheets-plugin-find/src/Basic/Observer.ts b/packages/sheets-plugin-find/src/Basic/Observer.tsnew file mode 100644index 0000000000..26d379e85b--- /dev/null+++ b/packages/sheets-plugin-find/src/Basic/Observer.ts@@ -0,0 +1,19 @@+import { Observable } from '@univer/core';+import { FindPlugin } from '../FindPlugin';+import { FindModal } from '../View/UI/FindModal';+import { SearchContent } from '../View/UI/SearchContent';++export type FindPluginObserve = {+ onFindModalDidMountObservable: Observable<FindModal>;+ onSearchContentDidMountObservable: Observable<SearchContent>;+};++export function uninstall(plugin: FindPlugin) {+ plugin.deleteObserve('onFindModalDidMountObservable');+ plugin.deleteObserve('onSearchContentDidMountObservable');+}++export function install(plugin: FindPlugin) {+ plugin.pushToObserve('onFindModalDidMountObservable');+ plugin.pushToObserve('onSearchContentDidMountObservable');+}diff --git a/packages/sheets-plugin-find/src/Controller/FindController.ts b/packages/sheets-plugin-find/src/Controller/FindController.tsnew file mode 100644index 0000000000..884de8b7fa--- /dev/null+++ b/packages/sheets-plugin-find/src/Controller/FindController.ts@@ -0,0 +1,110 @@+import { BaseComponentRender, BaseComponentSheet } from '@univer/base-component';+import { IToolBarItemProps, SpreadsheetPlugin } from '@univer/base-sheets';+import { PLUGIN_NAMES } from '@univer/core';+import { FIND_PLUGIN_NAME } from '../Const/PLUGIN_NAME';+import { FindPlugin } from '../FindPlugin';++export class FindController {+ private _plugin: FindPlugin;++ private _findList: IToolBarItemProps;++ private _render: BaseComponentRender;++ private _spreadSheetPlugin: SpreadsheetPlugin;++ constructor(plugin: FindPlugin) {+ this._plugin = plugin;+ this._spreadSheetPlugin = this._plugin.getContext().getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;++ this.initRegisterComponent();++ this._findList = {+ name: FIND_PLUGIN_NAME,+ type: 4,+ tooltipLocale: 'find.findLabel',+ show: true,+ label: 'SearchIcon',+ children: [+ {+ locale: 'find.find',+ suffix: 'SearchIcon',+ onClick: () => {+ this.showModal('find', true);+ },+ },+ // {+ // locale: 'find.replace',+ // suffix: 'ReplaceIcon',+ // onClick: () => {+ // // this.showFind('replace');+ // },+ // },+ // {+ // locale: 'find.location',+ // suffix: 'LocationIcon',+ // border: true,+ // onClick: () => {+ // // this.showLocation();+ // },+ // },+ // {+ // locale: 'find.formula',+ // suffixLocale: 'find.locationExample',+ // onClick: () => {},+ // },+ // {+ // locale: 'find.date',+ // suffixLocale: 'find.locationExample',+ // },+ // {+ // locale: 'find.number',+ // suffixLocale: 'find.locationExample',+ // },+ // {+ // locale: 'find.string',+ // suffixLocale: 'find.locationExample',+ // },+ // {+ // locale: 'find.error',+ // suffixLocale: 'find.locationExample',+ // },+ // {+ // locale: 'find.condition',+ // suffixLocale: 'find.locationExample',+ // },+ // {+ // locale: 'find.rowSpan',+ // suffixLocale: 'find.locationExample',+ // },+ // {+ // locale: 'find.columnSpan',+ // suffixLocale: 'find.locationExample',+ // },+ ],+ hideSelectedIcon: true,+ };++ this._spreadSheetPlugin.addToolButton(this._findList);+ }++ // 注册自定义组件+ initRegisterComponent() {+ const component = this._plugin.getContext().getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this._render = component.getComponentRender();++ const registerIcon = {+ SearchIcon: this._render.renderFunction('SearchIcon'),+ ReplaceIcon: this._render.renderFunction('ReplaceIcon'),+ LocationIcon: this._render.renderFunction('LocationIcon'),+ };++ for (let k in registerIcon) {+ this._spreadSheetPlugin.registerComponent(k, registerIcon[k]);+ }+ }++ showModal(name: string, show: boolean) {+ this._plugin.getFindModalController().showModal(name, show);+ }+}diff --git a/packages/sheets-plugin-find/src/Controller/FindModalController.ts b/packages/sheets-plugin-find/src/Controller/FindModalController.tsnew file mode 100644index 0000000000..4709b67d6c--- /dev/null+++ b/packages/sheets-plugin-find/src/Controller/FindModalController.ts@@ -0,0 +1,133 @@+import { BaseComponentRender, BaseComponentSheet, ComponentChildren } from '@univer/base-component';+import { SpreadsheetPlugin } from '@univer/base-sheets';+import { PLUGIN_NAMES } from '@univer/core';+import { FIND_PLUGIN_NAME } from '../Const/PLUGIN_NAME';+import { FindPlugin } from '../FindPlugin';+import { FindModal } from '../View/UI/FindModal';+import { SearchContent } from '../View/UI/SearchContent';++interface GroupProps {+ locale: string;+ label?: string;+ type?: string;+}++export interface ModalDataProps {+ name: string;+ title?: string;+ locale: string;+ show: boolean;+ children: ComponentChildren | string;+ onCancel: () => void;+ group: GroupProps[];+}++export class FindModalController {+ private _plugin: FindPlugin;++ private _render: BaseComponentRender;++ private _findModal: FindModal;++ private _spreadSheetPlugin: SpreadsheetPlugin;++ private _modalData: ModalDataProps[];++ constructor(plugin: FindPlugin) {+ this._plugin = plugin;+ this._spreadSheetPlugin = this._plugin.getContext().getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;++ this._modalData = [+ // {+ // locale: 'find.location',+ // show: false,+ // group: [+ // {+ // locale: 'button.confirm',+ // type: 'primary',+ // },+ // {+ // locale: 'button.cancel',+ // },+ // ],+ // children: <LocationContent config={props.config} />,+ // onCancel: () => this.showModal(0, false),+ // },+ {+ name: 'find',+ locale: 'find.findLabel',+ show: false,+ group: [+ {+ locale: 'button.cancel',+ type: 'primary',+ },+ {+ locale: 'button.cancel',+ },+ ],+ children: FIND_PLUGIN_NAME + SearchContent.name,+ onCancel: () => {},+ },+ ];++ this.initRegisterComponent();++ this.init();+ }++ init() {+ const plugin = this._spreadSheetPlugin.getPluginByName<FindPlugin>(FIND_PLUGIN_NAME)!;++ plugin.getObserver('onFindModalDidMountObservable')!.add((component) => {+ this._findModal = component;++ this.resetModalData();+ });+ }++ // 注册自定义组件+ initRegisterComponent() {+ const component = this._plugin.getContext().getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this._render = component.getComponentRender();++ const registerIcon = {+ SearchIcon: this._render.renderFunction('SearchIcon'),+ ReplaceIcon: this._render.renderFunction('ReplaceIcon'),+ LocationIcon: this._render.renderFunction('LocationIcon'),+ };++ for (let k in registerIcon) {+ this._spreadSheetPlugin.registerComponent(k, registerIcon[k]);+ }++ this._spreadSheetPlugin.registerModal(FIND_PLUGIN_NAME + FindModal.name, 100, FindModal);+ this._spreadSheetPlugin.registerComponent(FIND_PLUGIN_NAME + SearchContent.name, SearchContent, { activeKey: 'find' });+ }++ // 转化为渲染数据+ resetModalData() {+ const locale = this._plugin.getContext().getLocale();++ this._modalData.forEach((item) => {+ item.title = locale.get(item.locale);+ if (item.group && item.group.length) {+ item.group.forEach((ele) => {+ ele.label = locale.get(ele.locale);+ });+ }+ });++ this._findModal.setModal(this._modalData);+ }++ // 显示/关闭弹窗+ showModal(name: string, show: boolean) {+ const index = this._modalData.findIndex((item) => item.name === name);+ if (index > -1) {+ this._modalData[index].show = show;++ this._findModal.setModal(this._modalData);+ }+ }+}diff --git a/packages/sheets-plugin-find/src/Controller/LocationContentController.ts b/packages/sheets-plugin-find/src/Controller/LocationContentController.tsnew file mode 100644index 0000000000..be6723a6e9--- /dev/null+++ b/packages/sheets-plugin-find/src/Controller/LocationContentController.ts@@ -0,0 +1,99 @@+import { FindPlugin } from '../FindPlugin';++export class LocationContentController {+ private _plugin: FindPlugin;++ private _locationData: any;++ constructor(plugin: FindPlugin) {+ this._plugin = plugin;++ this._locationData = [+ {+ locale: 'find.locationConstant',+ children: [+ {+ locale: 'find.date',+ disabled: true,+ checked: true,+ value: '1',+ },+ {+ locale: 'find.number',+ checked: true,+ value: '2',+ },+ {+ locale: 'find.string',+ checked: true,+ value: '3',+ },+ {+ locale: 'find.locationBool',+ checked: true,+ disabled: true,+ value: '4',+ },+ {+ locale: 'find.error',+ checked: true,+ value: '5',+ },+ ],+ value: '1',+ },+ {+ locale: 'find.locationFormula',+ children: [+ {+ locale: 'find.date',+ checked: true,+ disabled: true,+ value: '1',+ },+ {+ locale: 'find.number',+ disabled: true,+ checked: true,+ value: '2',+ },+ {+ locale: 'find.string',+ disabled: true,+ checked: true,+ value: '3',+ },+ {+ locale: 'find.locationBool',+ checked: true,+ disabled: true,+ value: '4',+ },+ {+ locale: 'find.error',+ checked: true,+ disabled: true,+ value: '5',+ },+ ],+ value: '2',+ },+ {+ locale: 'find.locationNull',+ value: '3',+ },+ {+ locale: 'find.locationCondition',+ value: '4',+ },+ {+ locale: 'find.locationRowSpan',+ value: '5',+ },+ {+ locale: 'find.locationColumnSpan',+ value: '6',+ },+ ];+ }+}diff --git a/packages/sheets-plugin-find/src/Controller/SearchContentController.ts b/packages/sheets-plugin-find/src/Controller/SearchContentController.tsnew file mode 100644index 0000000000..eabaf311db--- /dev/null+++ b/packages/sheets-plugin-find/src/Controller/SearchContentController.ts@@ -0,0 +1,127 @@+import { FIND_PLUGIN_NAME } from '../Const/PLUGIN_NAME';+import { FindPlugin } from '../FindPlugin';+import { SearchContent } from '../View/UI/SearchContent';++export class SearchContentController {+ private _searchData;++ private _plugin: FindPlugin;++ private _searchContent: SearchContent;++ private _searchText: string;++ private _matchList: string[];++ constructor(plugin: FindPlugin) {+ this._plugin = plugin;++ this._searchData = {+ tab: [+ {+ locale: 'find.find',+ key: 'find',+ },+ {+ locale: 'find.replace',+ key: 'replace',+ },+ ],+ content: [+ {+ locale: 'find.findTextbox',+ },+ {+ locale: 'find.replaceTextbox',+ },+ ],+ buttons: [+ {+ locale: 'find.allFindBtn',+ key: 'find',+ // onClick: () => this.findText(true),+ },+ {+ locale: 'find.findBtn',+ key: 'find',+ // onClick: () => this.findText(),+ },+ {+ locale: 'find.allReplaceBtn',+ key: 'replace',+ },+ {+ locale: 'find.replaceBtn',+ key: 'replace',+ },+ ],+ match: [+ {+ locale: 'find.regexTextbox',+ value: 'regex',+ },+ {+ locale: 'find.wholeTextbox',+ value: 'whole',+ },+ {+ locale: 'find.distinguishTextbox',+ value: 'capsLock',+ },+ ],+ changeSearchText: this.changeSearchText,+ getMatch: this.getMatch,+ };++ this.init();+ }++ init() {+ const plugin = this._plugin.getContext().getPluginManager().getPluginByName<FindPlugin>(FIND_PLUGIN_NAME)!;++ plugin.getObserver('onSearchContentDidMountObservable')!.add((component) => {+ this._searchContent = component;++ this.resetSearchData();+ });+ }++ resetSearchData() {+ const locale = this._plugin.getContext().getLocale();++ for (let k in this._searchData) {+ if (this._searchData[k] instanceof Array) {+ for (let i = 0; i < this._searchData[k].length; i++) {+ this._searchData[k][i].label = locale.get(this._searchData[k][i].locale);+ }+ }+ }++ this._searchContent.setSearchData(this._searchData);+ }++ findText(isFull?: boolean) {+ // @ts-ignore+ // TODO ...+ // BUG+ // let textFinder = this._context.getPluginManager().getPluginByName<FindPlugin>('pluginFind')!.createTextFinder('A1:B10', this._searchText);+ // if (this._matchList.includes('capslock')) textFinder = textFinder.matchCase(true);+ // if (this._matchList.includes('whole')) textFinder = textFinder.matchEntireCell(true);+ // if (isFull) {+ // textFinder.findAll();+ // } else {+ // textFinder.findNext();+ // }+ }++ // get search text+ changeSearchText(e: Event) {+ const target = e.target as HTMLInputElement;+ this._searchText = target.value;+ }++ // get match condition+ getMatch = (value: string[]) => {+ this._matchList = value;+ };+}diff --git a/packages/sheets-plugin-find/src/Domain/TextFind.ts b/packages/sheets-plugin-find/src/Domain/TextFind.tsindex 890bc3b5cf..e8263022cf 100644--- a/packages/sheets-plugin-find/src/Domain/TextFind.ts+++ b/packages/sheets-plugin-find/src/Domain/TextFind.ts@@ -1,323 +1,323 @@-import { Range, Worksheet, RangeList, FormatType, IRangeData } from '@univer/core';-import { getRegExpStr } from '../Util/util';-import { FindType } from '../IData';+// import { Range, Worksheet, RangeList, FormatType, IRangeData } from '@univer/core';+// import { getRegExpStr } from '../Util/util';+// import { FindType } from '../IData';-export class TextFinder {- private _text: string | FormatType;+// export class TextFinder {+// private _text: string | FormatType;- private _type: FindType; // 查找类型+// private _type: FindType; // 查找类型- private _range: Range[]; // 保存匹配到的单元格range格式+// private _range: Range[]; // 保存匹配到的单元格range格式- private _rangeData: Range[] = []; // ranglist每个单元格range格式+// private _rangeData: Range[] = []; // ranglist每个单元格range格式- private _rangeList: IRangeData[]; // 初始rangeList+// private _rangeList: IRangeData[]; // 初始rangeList- private _workSheet: Worksheet;+// private _workSheet: Worksheet;- private _index: number;+// private _index: number;- private _matchCase: boolean = false; // 大小写匹配+// private _matchCase: boolean = false; // 大小写匹配- private _matchEntire: boolean = false; // 完全匹配+// private _matchEntire: boolean = false; // 完全匹配- private _useRegEx: boolean = false; // 正则匹配+// private _useRegEx: boolean = false; // 正则匹配- private _matchFormula: boolean = false; // 匹配公式文字+// private _matchFormula: boolean = false; // 匹配公式文字- private _startRange: Range | null; // 从这个位置后开始找+// private _startRange: Range | null; // 从这个位置后开始找- constructor(workSheet: Worksheet, type: FindType, text?: string | FormatType) {- this._workSheet = workSheet;- this._type = type;- if (text) {- this._text = text;- }- this._index = -1;- this._rangeList = this._workSheet.getActiveRangeList().getRangeList();- if (- this._rangeList.length == 0 ||- (this._rangeList.length == 1 && this._rangeList[0].startRow == this._rangeList[0].endRow && this._rangeList[0].startColumn == this._rangeList[0].endColumn)- ) {- this._rangeList = [- {- startRow: 0,- endRow: this._workSheet.getLastRow(),- startColumn: 0,- endColumn: this._workSheet.getLastColumn(),- },- ];- }- for (let i = 0; i < this._rangeList.length; i++) {- const range = new Range(this._workSheet, this._rangeList[i]);- for (let j = this._rangeList[i].startRow; j <= this._rangeList[i].endRow; j++) {- for (let k = this._rangeList[i].startColumn; k <= this._rangeList[i].endColumn; k++) {- this._rangeData.push(range.getCell(j, k));- }- }- }- }+// constructor(workSheet: Worksheet, type: FindType, text?: string | FormatType) {+// this._workSheet = workSheet;+// this._type = type;+// if (text) {+// this._text = text;+// }+// this._index = -1;+// this._rangeList = this._workSheet.getActiveRangeList().getRangeList();+// if (+// this._rangeList.length == 0 ||+// (this._rangeList.length == 1 && this._rangeList[0].startRow == this._rangeList[0].endRow && this._rangeList[0].startColumn == this._rangeList[0].endColumn)+// ) {+// this._rangeList = [+// {+// startRow: 0,+// endRow: this._workSheet.getLastRow(),+// startColumn: 0,+// endColumn: this._workSheet.getLastColumn(),+// },+// ];+// }+// for (let i = 0; i < this._rangeList.length; i++) {+// const range = new Range(this._workSheet, this._rangeList[i]);+// for (let j = this._rangeList[i].startRow; j <= this._rangeList[i].endRow; j++) {+// for (let k = this._rangeList[i].startColumn; k <= this._rangeList[i].endColumn; k++) {+// this._rangeData.push(range.getCell(j, k));+// }+// }+// }+// }- /**- * Returns all cells matching the search criteria.- */- findAll(): Range[] | null {- this._index = -1;- this._match();- if (this._range.length == 0) return null;- return this._range;- }+// /**+// * Returns all cells matching the search criteria.+// */+// findAll(): Range[] | null {+// this._index = -1;+// this._match();+// if (this._range.length == 0) return null;+// return this._range;+// }- /**- * Returns the next cell matching the search criteria.- */- findNext(): Range | null {- this._match();- if (this._range.length == 0) return null;- this._index++;- if (this._index > this._range.length - 1) this._index = 0;- return this._range[this._index];- }+// /**+// * Returns the next cell matching the search criteria.+// */+// findNext(): Range | null {+// this._match();+// if (this._range.length == 0) return null;+// this._index++;+// if (this._index > this._range.length - 1) this._index = 0;+// return this._range[this._index];+// }- /**- * Returns the previous cell matching the search criteria.- */- findPrevious(): Range | null {- this._match();- if (this._range.length == 0) return null;- this._index--;- if (this._index < 0) this._index = this._range.length - 1;- return this._range[this._index];- }+// /**+// * Returns the previous cell matching the search criteria.+// */+// findPrevious(): Range | null {+// this._match();+// if (this._range.length == 0) return null;+// this._index--;+// if (this._index < 0) this._index = this._range.length - 1;+// return this._range[this._index];+// }- /**- * If true, configures the search to match the search text's case exactly, otherwise the search defaults to case-insensitive matching.- */- matchCase(matchCase: boolean): TextFinder {- this._matchCase = matchCase;- return this;- }+// /**+// * If true, configures the search to match the search text's case exactly, otherwise the search defaults to case-insensitive matching.+// */+// matchCase(matchCase: boolean): TextFinder {+// this._matchCase = matchCase;+// return this;+// }- /**- * If true, configures the search to match the entire contents of a cell; otherwise, the search defaults to partial matching.- */- matchEntireCell(matchEntire: boolean): TextFinder {- this._matchEntire = matchEntire;- return this;- }+// /**+// * If true, configures the search to match the entire contents of a cell; otherwise, the search defaults to partial matching.+// */+// matchEntireCell(matchEntire: boolean): TextFinder {+// this._matchEntire = matchEntire;+// return this;+// }- /**- * If true, configures the search to return matches that appear within formula text; otherwise cells with formulas are considered based on their displayed value.- */- matchFormulaText(matchFormulaText: boolean): TextFinder {- this._matchFormula = matchFormulaText;- return this;- }+// /**+// * If true, configures the search to return matches that appear within formula text; otherwise cells with formulas are considered based on their displayed value.+// */+// matchFormulaText(matchFormulaText: boolean): TextFinder {+// this._matchFormula = matchFormulaText;+// return this;+// }- /**- * If true, configures the search to interpret the search string as a regular expression; otherwise the search interprets the search string as normal text.- */- useRegularExpression(useRegEx: boolean): TextFinder {- this._useRegEx = useRegEx;- return this;- }+// /**+// * If true, configures the search to interpret the search string as a regular expression; otherwise the search interprets the search string as normal text.+// */+// useRegularExpression(useRegEx: boolean): TextFinder {+// this._useRegEx = useRegEx;+// return this;+// }- /**- * TODO- * 替换还需考虑编辑模式和保护模式,整个workbook- */- /**- * Replaces all matches with the specified text. Returns the number of occurrences replaced, which may be different from the number of matched cells.- */- replaceAllWith(replaceText: string): number {- const range = this.findAll();- if (!range) return 0;- const rangType = [];- for (let i = 0; i < range.length; i++) {- rangType.push(range[i].getRangeData());- }- const rangeList = new RangeList(this._workSheet, rangType);- rangeList.setValue(replaceText);- return range.length;- }+// /**+// * TODO+// * 替换还需考虑编辑模式和保护模式,整个workbook+// */+// /**+// * Replaces all matches with the specified text. Returns the number of occurrences replaced, which may be different from the number of matched cells.+// */+// replaceAllWith(replaceText: string): number {+// const range = this.findAll();+// if (!range) return 0;+// const rangType = [];+// for (let i = 0; i < range.length; i++) {+// rangType.push(range[i].getRangeData());+// }+// const rangeList = new RangeList(this._workSheet, rangType);+// rangeList.setValue(replaceText);+// return range.length;+// }- /**- * Replaces the search text in the currently matched cell with the specified text and returns the number of occurrences replaced.- */- replaceWith(replaceText: string): number {- const range = this.findNext();- if (!range) return 0;- this._index--;- range.setValue(replaceText);- return 1;- }+// /**+// * Replaces the search text in the currently matched cell with the specified text and returns the number of occurrences replaced.+// */+// replaceWith(replaceText: string): number {+// const range = this.findNext();+// if (!range) return 0;+// this._index--;+// range.setValue(replaceText);+// return 1;+// }- /**- * Configures the search to start searching immediately after the specified cell range.- */- startFrom(startRange: Range): TextFinder {- this._startRange = startRange;- return this;- }+// /**+// * Configures the search to start searching immediately after the specified cell range.+// */+// startFrom(startRange: Range): TextFinder {+// this._startRange = startRange;+// return this;+// }- /**- * Returns the current cell matching the search criteria.- */- getCurrentMatch(): Range | null {- if (this._index < 0) return null;- return this._range[this._index];- }+// /**+// * Returns the current cell matching the search criteria.+// */+// getCurrentMatch(): Range | null {+// if (this._index < 0) return null;+// return this._range[this._index];+// }- /**- * match rule- */- private _match = () => {- const choose = new Map<string | FormatType, () => Range[]>([- ['text', this._mathTxt],- ['condition', this._matchCondition],- ['intervalRow', () => this._matchInterval('row')],- ['intervalColumn', () => this._matchInterval('column')],- ['null', this._matchNull],- ['format', this._matchFormat],- ]);- let range;- if (this._type in FormatType) {- range = choose.get('format')!();- } else {- range = choose.get(this._type)!();- }- // range.sort((a, b) => a.getRangeData().startRow - b.getRangeData().startRow).sort((a, b) => a.getRangeData().startColumn - b.getRangeData().startColumn);- if (this._startRange) {- const startRange = this._startRange.getRangeData();- for (let i = 0; i < range.length; i++) {- const cell = range[i].getRangeData();- if (cell.startColumn <= startRange.endColumn) {- range.splice(i, 1);- i--;- } else if (cell.startRow < startRange.startRow) {- range.splice(i, 1);- i--;- }- }- }- this._range = range;- };+// /**+// * match rule+// */+// private _match = () => {+// const choose = new Map<string | FormatType, () => Range[]>([+// ['text', this._mathTxt],+// ['condition', this._matchCondition],+// ['intervalRow', () => this._matchInterval('row')],+// ['intervalColumn', () => this._matchInterval('column')],+// ['null', this._matchNull],+// ['format', this._matchFormat],+// ]);+// let range;+// if (this._type in FormatType) {+// range = choose.get('format')!();+// } else {+// range = choose.get(this._type)!();+// }+// // range.sort((a, b) => a.getRangeData().startRow - b.getRangeData().startRow).sort((a, b) => a.getRangeData().startColumn - b.getRangeData().startColumn);+// if (this._startRange) {+// const startRange = this._startRange.getRangeData();+// for (let i = 0; i < range.length; i++) {+// const cell = range[i].getRangeData();+// if (cell.startColumn <= startRange.endColumn) {+// range.splice(i, 1);+// i--;+// } else if (cell.startRow < startRange.startRow) {+// range.splice(i, 1);+// i--;+// }+// }+// }+// this._range = range;+// };- // 查找文本- private _mathTxt(): Range[] {- this._text = this._text as string;- const range = [];- for (let i = 0; i < this._rangeData.length; i++) {- let value = this._rangeData[i].getValue().m;- if (this._matchFormula) {- value = this._rangeData[i].getValue().f;- }- if (value != null) {- value = value.toString();- if (this._matchEntire) {- if (this._matchCase) {- if (this._text == value) {- range.push(this._rangeData[i]);- }- } else {- if (this._text.toLowerCase() == value.toLowerCase()) {- range.push(this._rangeData[i]);- }- }- } else if (this._useRegEx) {- let reg;- if (this._matchCase) {- reg = new RegExp(getRegExpStr(this._text), 'g');- } else {- reg = new RegExp(getRegExpStr(this._text), 'ig');- }+// // 查找文本+// private _mathTxt(): Range[] {+// this._text = this._text as string;+// const range = [];+// for (let i = 0; i < this._rangeData.length; i++) {+// let value = this._rangeData[i].getValue().m;+// if (this._matchFormula) {+// value = this._rangeData[i].getValue().f;+// }+// if (value != null) {+// value = value.toString();+// if (this._matchEntire) {+// if (this._matchCase) {+// if (this._text == value) {+// range.push(this._rangeData[i]);+// }+// } else {+// if (this._text.toLowerCase() == value.toLowerCase()) {+// range.push(this._rangeData[i]);+// }+// }+// } else if (this._useRegEx) {+// let reg;+// if (this._matchCase) {+// reg = new RegExp(getRegExpStr(this._text), 'g');+// } else {+// reg = new RegExp(getRegExpStr(this._text), 'ig');+// }- if (reg.test(value)) {- range.push(this._rangeData[i]);- }- } else {- let reg = new RegExp(getRegExpStr(this._text), 'ig');- if (reg.test(value)) {- range.push(this._rangeData[i]);- }- }- }- }- return range;- }+// if (reg.test(value)) {+// range.push(this._rangeData[i]);+// }+// } else {+// let reg = new RegExp(getRegExpStr(this._text), 'ig');+// if (reg.test(value)) {+// range.push(this._rangeData[i]);+// }+// }+// }+// }+// return range;+// }- // 按format寻找- private _matchFormat(): Range[] {- const range = [];- for (let i = 0; i < this._rangeData.length; i++) {- const format = this._rangeData[i].getValue().fm?.t;- if (!format) continue;- if (format == this._type) {- range.push(this._rangeData[i]);- }- }- return range;- }+// // 按format寻找+// private _matchFormat(): Range[] {+// const range = [];+// for (let i = 0; i < this._rangeData.length; i++) {+// const format = this._rangeData[i].getValue().fm?.t;+// if (!format) continue;+// if (format == this._type) {+// range.push(this._rangeData[i]);+// }+// }+// return range;+// }- // 寻找null的单元格- private _matchNull(): Range[] {- const range = [];- for (let i = 0; i < this._rangeData.length; i++) {- let value = this._rangeData[i].getValue().v;- if (value == null) {- range.push(this._rangeData[i]);- }- }- return range;- }+// // 寻找null的单元格+// private _matchNull(): Range[] {+// const range = [];+// for (let i = 0; i < this._rangeData.length; i++) {+// let value = this._rangeData[i].getValue().v;+// if (value == null) {+// range.push(this._rangeData[i]);+// }+// }+// return range;+// }- // todo: 等condition插件定好结构- // 寻找条件格式- private _matchCondition(): Range[] {- const range: Range[] = [];- return range;- }+// // todo: 等condition插件定好结构+// // 寻找条件格式+// private _matchCondition(): Range[] {+// const range: Range[] = [];+// return range;+// }- // todo: 移到UI里,增加开始行列,间隔行列数- // 寻找间隔行间隔列,移到UI里- private _matchInterval(param: 'column' | 'row'): Range[] {- const range = [];- for (let i = 0; i < this._rangeList.length; i++) {- const rangeArea = this._rangeList[i];- if (param == 'row') {- if (rangeArea.startRow == rangeArea.endRow) {- continue;- }- for (let j = rangeArea.startRow; j <= rangeArea.endRow; j++) {- if ((j - rangeArea.startRow) % 2 == 0) {- range.push(- new Range(this._workSheet, {- startRow: j,- endRow: j,- startColumn: rangeArea.startColumn,- endColumn: rangeArea.endColumn,- })- );- }- }- } else {- if (rangeArea.startColumn == rangeArea.endColumn) {- continue;- }- for (let j = rangeArea.startColumn; j <= rangeArea.endColumn; j++) {- if ((j - rangeArea.startColumn) % 2 == 0) {- range.push(- new Range(this._workSheet, {- startRow: rangeArea.startRow,- endRow: rangeArea.endRow,- startColumn: j,- endColumn: j,- })- );- }- }- }- }- return range;- }-}+// // todo: 移到UI里,增加开始行列,间隔行列数+// // 寻找间隔行间隔列,移到UI里+// private _matchInterval(param: 'column' | 'row'): Range[] {+// const range = [];+// for (let i = 0; i < this._rangeList.length; i++) {+// const rangeArea = this._rangeList[i];+// if (param == 'row') {+// if (rangeArea.startRow == rangeArea.endRow) {+// continue;+// }+// for (let j = rangeArea.startRow; j <= rangeArea.endRow; j++) {+// if ((j - rangeArea.startRow) % 2 == 0) {+// range.push(+// new Range(this._workSheet, {+// startRow: j,+// endRow: j,+// startColumn: rangeArea.startColumn,+// endColumn: rangeArea.endColumn,+// })+// );+// }+// }+// } else {+// if (rangeArea.startColumn == rangeArea.endColumn) {+// continue;+// }+// for (let j = rangeArea.startColumn; j <= rangeArea.endColumn; j++) {+// if ((j - rangeArea.startColumn) % 2 == 0) {+// range.push(+// new Range(this._workSheet, {+// startRow: rangeArea.startRow,+// endRow: rangeArea.endRow,+// startColumn: j,+// endColumn: j,+// })+// );+// }+// }+// }+// }+// return range;+// }+// }diff --git a/packages/sheets-plugin-find/src/FindPlugin.ts b/packages/sheets-plugin-find/src/FindPlugin.tsnew file mode 100644index 0000000000..d56e3c8dee--- /dev/null+++ b/packages/sheets-plugin-find/src/FindPlugin.ts@@ -0,0 +1,62 @@+import { Context, UniverSheet, Plugin, Worksheet } from '@univer/core';+// import { TextFinder } from './Domain/TextFind';+import { FindType } from './IData/IFind';+import { FIND_PLUGIN_NAME } from './Const/PLUGIN_NAME';+import { FindController } from './Controller/FindController';+import en from './Locale/en';+import zh from './Locale/zh';+import { FindPluginObserve, install } from './Basic/Observer';+import { FindModalController } from './Controller/FindModalController';+import { SearchContentController } from './Controller/SearchContentController';++export interface IFindPluginConfig {}++export class FindPlugin extends Plugin<FindPluginObserve> {+ private _findController: FindController;++ private _findModalController: FindModalController;++ private _searchContentController: SearchContentController;++ constructor(config?: IFindPluginConfig) {+ super(FIND_PLUGIN_NAME);+ }++ static create(config?: IFindPluginConfig) {+ return new FindPlugin(config);+ }++ installTo(universheetInstance: UniverSheet) {+ universheetInstance.installPlugin(this);+ }++ initialize(): void {+ const context = this.getContext();++ context.getLocale().load({+ en,+ zh,+ });++ this._findModalController = new FindModalController(this);+ this._findController = new FindController(this);+ this._searchContentController = new SearchContentController(this);+ }++ createTextFinder(workSheet: Worksheet, type: FindType, text: string) {+ // return new TextFinder(workSheet, type, text);+ }++ onMounted(ctx: Context): void {+ install(this);+ this.initialize();+ }++ onDestroy(): void {}++ onMapping(): void {}++ getFindModalController() {+ return this._findModalController;+ }+}diff --git a/packages/sheets-plugin-find/src/FindPlugin.tsx b/packages/sheets-plugin-find/src/FindPlugin.tsxdeleted file mode 100644index 9530100812..0000000000--- a/packages/sheets-plugin-find/src/FindPlugin.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { IToolBarItemProps, ISlotElement } from '@univer/base-component';-import { Context, UniverSheet, Nullable, Plugin, PLUGIN_NAMES, Worksheet } from '@univer/core';-import { SpreadsheetPlugin } from '@univer/base-sheets';-import { en, zh } from './Locale';-import { FindButton } from './UI/FindButton';-import { TextFinder } from './Domain/TextFind';-import { FindType, IConfig } from './IData/IFind';-import { FIND_PLUGIN_NAME } from './Const/PLUGIN_NAME';--export interface IFindPluginConfig {}--export class FindPlugin extends Plugin {- spreadsheetPlugin: Nullable<SpreadsheetPlugin>;-- constructor(config?: IFindPluginConfig) {- super(FIND_PLUGIN_NAME);- }-- static create(config?: IFindPluginConfig) {- return new FindPlugin(config);- }-- installTo(universheetInstance: UniverSheet) {- universheetInstance.installPlugin(this);- }-- initialize(): void {- const context = this.getContext();-- /**- * load more Locale object- */- context.getLocale().load({- en,- zh,- });- const config: IConfig = {};-- const item: IToolBarItemProps = {- locale: FIND_PLUGIN_NAME,- type: ISlotElement.JSX,- show: true,- label: <FindButton config={config} />,- };- // get spreadsheet plugin- this.spreadsheetPlugin = context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET);-- // extend comment- this.spreadsheetPlugin?.addButton(item);- }-- createTextFinder(workSheet: Worksheet, type: FindType, text: string) {- return new TextFinder(workSheet, type, text);- }-- onMounted(ctx: Context): void {- this.initialize();- }-- onDestroy(): void {}-- onMapping(): void {}-}diff --git a/packages/sheets-plugin-find/src/UI/FindButton.tsx b/packages/sheets-plugin-find/src/UI/FindButton.tsxdeleted file mode 100644index 08d773acdd..0000000000--- a/packages/sheets-plugin-find/src/UI/FindButton.tsx+++ /dev/null@@ -1,249 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, BaseSelectProps, Component, IToolBarItemProps, ModalProps } from '@univer/base-component';-import { Nullable, Observer, Workbook } from '@univer/core';-import { SpreadsheetPlugin } from '@univer/base-sheets';-import { IProps } from '../IData/IFind';-import { LocationContent } from './LocationContent';-import { SearchContent } from './SearchContent';--// Types for state-interface IState {- find: IToolBarItemProps;- modalData: ModalProps[];-}--export class FindButton extends Component<IProps, IState> {- Render: BaseComponentRender;-- private _localeObserver: Nullable<Observer<Workbook>>;-- active = 'find';-- initialize(props: IProps) {- // super(props);- const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();- const NextIcon = this.Render.renderFunction('NextIcon');- const SearchIcon = this.Render.renderFunction('SearchIcon');- const ReplaceIcon = this.Render.renderFunction('ReplaceIcon');- const LocationIcon = this.Render.renderFunction('LocationIcon');-- this.state = {- find: {- locale: 'find.findLabel',- type: 'select',- label: <SearchIcon />,- icon: <NextIcon />,- show: true,- tooltip: '',- children: [- {- locale: 'find.find',- icon: <SearchIcon />,- onClick: () => {- this.showFind('find');- },- },- {- locale: 'find.replace',- icon: <ReplaceIcon />,- onClick: () => {- this.showFind('replace');- },- },- {- locale: 'find.location',- icon: <LocationIcon />,- border: true,- onClick: () => {- this.showLocation();- },- },- {- locale: 'find.formula',- iconName: 'find.locationExample',- onClick: () => {},- },- {- locale: 'find.date',- iconName: 'find.locationExample',- },- {- locale: 'find.number',- iconName: 'find.locationExample',- },- {- locale: 'find.string',- iconName: 'find.locationExample',- },- {- locale: 'find.error',- iconName: 'find.locationExample',- },- {- locale: 'find.condition',- iconName: 'find.locationExample',- },- {- locale: 'find.rowSpan',- iconName: 'find.locationExample',- },- {- locale: 'find.columnSpan',- iconName: 'find.locationExample',- },- ],- },- modalData: [- {- locale: 'find.location',- show: false,- group: [- {- locale: 'button.confirm',- type: 'primary',- },- {- locale: 'button.cancel',- },- ],- children: <LocationContent config={props.config} />,- onCancel: () => this.showModal(0, false),- },- {- locale: 'find.findLabel',- show: false,- group: [- {- locale: 'button.cancel',- },- ],- children: <SearchContent config={props.config} activeKey="find" />,- onCancel: () => this.showModal(1, false),- },- ],- };- }-- /**- * init- */- componentWillMount() {- this.setLocale();-- // subscribe Locale change event-- this._localeObserver = this._context- .getObserverManager()- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- this.setLocale();- });- }-- /**- * destory- */- componentWillUnmount() {- this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- }-- /**- * set text by config setting and Locale message- */- setLocale() {- const locale = this._context.getLocale();- this.setState((prevState: IState) => {- let item = prevState.find;- // set current Locale string for tooltip- item.tooltip = locale.get(`${item.locale}`);- // set current Locale string for select- item.children?.forEach((ele: IToolBarItemProps) => {- if (ele.locale) {- ele.label = locale.get(`${ele.locale}`);- }- if (ele.iconName) {- ele.icon = locale.get(`${ele.iconName}`);- }- });- item.label = typeof item.label === 'object' ? item.label : item.children![0].label;-- // set current Locale string fro modal- let { modalData } = prevState;- modalData.forEach((ele) => {- ele.title = locale.get(ele.locale!);- if (ele.group && ele.group.length) {- ele.group.forEach((node) => {- node.label = locale.get(node.locale!);- });- }- });-- return {- find: item,- modalData,- };- });- }-- setValue = (value: object, fn?: () => void) => {- this.setState(- (prevState) => ({- ...value,- }),- fn- );- };-- /**- * @param index modal index- * @param isShow- */- showModal = (index: number, isShow: boolean) => {- this.setState((prevState) => {- let { modalData } = prevState;-- modalData[index].show = isShow;- return {- modalData,- };- });- };-- // show location modal- showLocation = () => {- this.showModal(0, true);- };-- // show findandreplace modal- showFind = (name: string) => {- let { modalData } = this.state;- modalData[1].children = <SearchContent config={this.props.config} activeKey={name} />;- this.setValue({ modalData });- this.showModal(1, true);- };-- /**- * Render the component's HTML- *- * @returns {void}- */- render(props: IProps, state: IState) {- const Modal = this.Render.renderFunction('Modal');- const Select = this.Render.renderFunction('Select');- const { find, modalData } = state;- // Set Provider for entire Container- return (- <>- <Select tooltip={find.tooltip} key={find.locale} children={find.children as BaseSelectProps[]} label={find.label} icon={find.icon} />- {modalData.map((item) => {- if (!item.show) return;- return (- <Modal title={item.title} visible={item.show} group={item.group} onCancel={item.onCancel}>- {item.children}- </Modal>- );- })}- </>- );- }-}diff --git a/packages/sheets-plugin-find/src/UI/LocationContent.tsx b/packages/sheets-plugin-find/src/UI/LocationContent.tsxdeleted file mode 100644index 0888b2c8f3..0000000000--- a/packages/sheets-plugin-find/src/UI/LocationContent.tsx+++ /dev/null@@ -1,223 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';-import { Nullable, Observer, Workbook } from '@univer/core';-import { SpreadsheetPlugin } from '@univer/base-sheets';-import styles from './index.module.less';--type LocationProps = {- config: any;-};-type LocationState = {- radioGroup: LabelProps[];- active: string | number;-};-type LabelProps = {- locale: string;- label?: string;- value: string;- disabled?: boolean;- children?: LabelProps[];- checked?: boolean;-};--export class LocationContent extends Component<LocationProps, LocationState> {- private _localeObserver: Nullable<Observer<Workbook>>;-- Render: BaseComponentRender;-- initialize() {- const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();- this.state = {- radioGroup: [- {- locale: 'find.locationConstant',- children: [- {- locale: 'find.date',- disabled: true,- checked: true,- value: '1',- },- {- locale: 'find.number',- checked: true,- value: '2',- },- {- locale: 'find.string',- checked: true,- value: '3',- },- {- locale: 'find.locationBool',- checked: true,- disabled: true,- value: '4',- },- {- locale: 'find.error',- checked: true,- value: '5',- },- ],- value: '1',- },- {- locale: 'find.locationFormula',- children: [- {- locale: 'find.date',- checked: true,- disabled: true,- value: '1',- },- {- locale: 'find.number',- disabled: true,- checked: true,- value: '2',- },- {- locale: 'find.string',- disabled: true,- checked: true,- value: '3',- },- {- locale: 'find.locationBool',- checked: true,- disabled: true,- value: '4',- },- {- locale: 'find.error',- checked: true,- disabled: true,- value: '5',- },- ],- value: '2',- },- {- locale: 'find.locationNull',- value: '3',- },- {- locale: 'find.locationCondition',- value: '4',- },- {- locale: 'find.locationRowSpan',- value: '5',- },- {- locale: 'find.locationColumnSpan',- value: '6',- },- ],- active: '1',- };- }-- setLocale() {- const locale = this._context.getLocale();- this.setState((prevState) => {- let { radioGroup } = prevState;- radioGroup.forEach((item) => {- item.label = locale.get(item.locale);- if (item.children) {- item.children.forEach((ele) => {- ele.label = locale.get(ele.locale);- });- }- });-- return {- radioGroup,- };- });- }-- componentWillMount() {- this.setLocale();-- // subscribe Locale change event- this._localeObserver = this._context- .getObserverManager()- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- this.setLocale();- });- }-- componentWillUnmount() {- this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- }-- setValue = (value: object, fn?: () => void) => {- this.setState(- (prevState) => ({- ...value,- }),- fn- );- };-- handleChange = (value: string) => {- let { radioGroup } = this.state;- radioGroup.forEach((item) => {- if (item.children) {- item.children.forEach((ele) => {- ele.disabled = true;- });- }- });-- radioGroup.forEach((item) => {- if (item.value === value) {- if (item.children) {- item.children.forEach((ele) => {- ele.disabled = false;- });- }- this.setValue({ active: value, radioGroup });- }- });- };-- handleCheckbox = (value: string[], locale: string) => {- let { radioGroup } = this.state;- let index = radioGroup.findIndex((item) => item.locale === locale);- radioGroup[index].children!.forEach((ele) => {- if (value.includes(ele.value)) {- ele.checked = true;- } else {- ele.checked = false;- }- });- this.setValue({ radioGroup });- };-- render(props: LocationProps, state: LocationState) {- const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');- const Radio = this.Render.renderFunction('Radio');- const RadioGroup = this.Render.renderFunction('RadioGroup');- const { radioGroup, active } = state;- return (- <div className={styles.locationContent}>- <RadioGroup vertical={true} onChange={this.handleChange} active={active}>- {radioGroup.map((item) => {- if (item.children) {- return (- <Radio value={item.value} label={item.label}>- <CheckboxGroup options={item.children} onChange={(value) => this.handleCheckbox(value, item.locale)} />- </Radio>- );- }- return <Radio value={item.value} label={item.label}></Radio>;- })}- </RadioGroup>- </div>- );- }-}diff --git a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx b/packages/sheets-plugin-find/src/View/UI/FindModal.tsxnew file mode 100644index 0000000000..f45b385277--- /dev/null+++ b/packages/sheets-plugin-find/src/View/UI/FindModal.tsx@@ -0,0 +1,73 @@+import { BaseComponentRender, BaseComponentSheet, Component, ModalProps } from '@univer/base-component';+import { PLUGIN_NAMES } from '@univer/core';+import { SpreadsheetPlugin } from '@univer/base-sheets';+import { IProps } from '../../IData/IFind';+import { FindPlugin } from '../../FindPlugin';+import { FIND_PLUGIN_NAME } from '../../Const/PLUGIN_NAME';+import { ModalDataProps } from '../../Controller/FindModalController';++// Types for state+interface IState {+ modalData: ModalProps[];+}++export class FindModal extends Component<IProps, IState> {+ Render: BaseComponentRender;++ active = 'find';++ initialize(props: IProps) {+ // super(props);+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();++ this.state = {+ modalData: [],+ };+ }++ componentDidMount() {+ const plugin = this._context.getPluginManager().getPluginByName<FindPlugin>(FIND_PLUGIN_NAME)!;+ plugin.getObserver('onFindModalDidMountObservable')!.notifyObservers(this);+ }++ setModal(modalData: ModalDataProps[]) {+ const spreadSheetPlugin = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;++ modalData.forEach((item) => {+ const component = spreadSheetPlugin.getRegisterComponent(item.children as string);+ if (component) {+ const Label = component.component;+ const props = component.props ?? {};+ item.children = <Label {...props} />;+ }+ });++ this.setState({+ modalData,+ });+ }++ /**+ * Render the component's HTML+ *+ * @returns {void}+ */+ render() {+ const Modal = this.Render.renderFunction('Modal');+ const { modalData } = this.state;+ // Set Provider for entire Container+ return (+ <>+ {modalData.map((item) => {+ if (!item.show) return;+ return (+ <Modal title={item.title} visible={item.show} group={item.group} onCancel={item.onCancel}>+ {item.children}+ </Modal>+ );+ })}+ </>+ );+ }+}diff --git a/packages/sheets-plugin-find/src/View/UI/LocationContent.tsx b/packages/sheets-plugin-find/src/View/UI/LocationContent.tsxnew file mode 100644index 0000000000..8ff0952f2e--- /dev/null+++ b/packages/sheets-plugin-find/src/View/UI/LocationContent.tsx@@ -0,0 +1,93 @@+import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';+import { Nullable, Observer, Workbook } from '@univer/core';+import { SpreadsheetPlugin } from '@univer/base-sheets';+import styles from './index.module.less';++type LocationProps = {+ config: any;+};+type LocationState = {+ radioGroup: LabelProps[];+ active: string | number;+};+type LabelProps = {+ locale: string;+ label?: string;+ value: string;+ disabled?: boolean;+ children?: LabelProps[];+ checked?: boolean;+};++export class LocationContent extends Component<LocationProps, LocationState> {+ private _localeObserver: Nullable<Observer<Workbook>>;++ Render: BaseComponentRender;++ initialize() {+ const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();+ this.state = {+ radioGroup: [],+ active: '1',+ };+ }++ handleChange = (value: string) => {+ let { radioGroup } = this.state;+ radioGroup.forEach((item) => {+ if (item.children) {+ item.children.forEach((ele) => {+ ele.disabled = true;+ });+ }+ });++ radioGroup.forEach((item) => {+ if (item.value === value) {+ if (item.children) {+ item.children.forEach((ele) => {+ ele.disabled = false;+ });+ }+ this.setValue({ active: value, radioGroup });+ }+ });+ };++ handleCheckbox = (value: string[], locale: string) => {+ let { radioGroup } = this.state;+ let index = radioGroup.findIndex((item) => item.locale === locale);+ radioGroup[index].children!.forEach((ele) => {+ if (value.includes(ele.value)) {+ ele.checked = true;+ } else {+ ele.checked = false;+ }+ });+ this.setValue({ radioGroup });+ };++ render() {+ const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');+ const Radio = this.Render.renderFunction('Radio');+ const RadioGroup = this.Render.renderFunction('RadioGroup');+ const { radioGroup, active } = this.state;+ return (+ <div className={styles.locationContent}>+ <RadioGroup vertical={true} onChange={this.handleChange} active={active}>+ {radioGroup.map((item) => {+ if (item.children) {+ return (+ <Radio value={item.value} label={item.label}>+ <CheckboxGroup options={item.children} onChange={(value) => this.handleCheckbox(value, item.locale)} />+ </Radio>+ );+ }+ return <Radio value={item.value} label={item.label}></Radio>;+ })}+ </RadioGroup>+ </div>+ );+ }+}diff --git a/packages/sheets-plugin-find/src/View/UI/SearchContent.tsx b/packages/sheets-plugin-find/src/View/UI/SearchContent.tsxnew file mode 100644index 0000000000..85d68f13eb--- /dev/null+++ b/packages/sheets-plugin-find/src/View/UI/SearchContent.tsx@@ -0,0 +1,114 @@+import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';+import { Nullable } from '@univer/core';+import { FIND_PLUGIN_NAME } from '../../Const/PLUGIN_NAME';+import { FindPlugin } from '../../FindPlugin';+import styles from './index.module.less';++interface SearchProps {+ config: any;+ activeKey?: string;+ keys?: string;+}++type SearchState = {+ tab: LabelProps[];+ content: LabelProps[];+ match: LabelProps[];+ buttons: LabelProps[];+ changeSearchText: Nullable<(e: Event) => void>;+ getMatch: Nullable<(value: string[]) => void>;+};++type LabelProps = {+ locale?: string;+ label?: string;+ value?: string;+ key?: string;+ onClick?: () => void;+};++export class SearchContent extends Component<SearchProps, SearchState> {+ Render: BaseComponentRender;++ initialize() {+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();+ this.state = {+ tab: [],+ content: [],+ buttons: [],+ match: [],+ changeSearchText: null,+ getMatch: null,+ };+ }++ componentDidMount() {+ const plugin = this._context.getPluginManager().getPluginByName<FindPlugin>(FIND_PLUGIN_NAME)!;+ plugin.getObserver('onSearchContentDidMountObservable')!.notifyObservers(this);+ }++ setSearchData(data: any) {+ this.setState({+ ...data,+ });+ }++ render(props: SearchProps, state: SearchState) {+ const Tab = this.Render.renderFunction('Tab');+ const TabPane = this.Render.renderFunction('TabPane');+ const Button = this.Render.renderFunction('Button');+ const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');+ const Input = this.Render.renderFunction('Input');+ const { tab, content, match, buttons, changeSearchText, getMatch } = state;+ const { activeKey } = props;++ if (!changeSearchText || !getMatch) return;++ return (+ <Tab activeKey={activeKey} type="card">+ {tab.map((item, index) => (+ <TabPane tab={item.label} keys={item.key} key={index}>+ <div className={styles.tabBox}>+ <div className={styles.inputBox}>+ <div className={styles.textBox}>+ <div>+ <span>{content[0].label}: </span>+ <Input onChange={(e: Event) => changeSearchText(e)} />+ </div>+ {item.key === 'replace' ? (+ <div>+ <span>{content[1].label}: </span>+ <Input />+ </div>+ ) : (+ <></>+ )}+ </div>+ <div>+ <CheckboxGroup options={match} onChange={getMatch}></CheckboxGroup>+ </div>+ </div>+ <div className={styles.btnBox}>+ {buttons.map((item, index) => {+ if (item.key === 'replace') {+ return (+ <Button key={index} onClick={item.onClick}>+ {item.label}+ </Button>+ );+ }+ return (+ <Button key={index} onClick={item.onClick}>+ {item.label}+ </Button>+ );+ })}+ </div>+ </div>+ </TabPane>+ ))}+ </Tab>+ );+ }+}diff --git a/packages/sheets-plugin-find/src/UI/SearchContent.tsx b/packages/sheets-plugin-find/src/View/UI/fuben.tsxsimilarity index 96%rename from packages/sheets-plugin-find/src/UI/SearchContent.tsxrename to packages/sheets-plugin-find/src/View/UI/fuben.tsxindex ad87210f70..5532aa15c0 100644--- a/packages/sheets-plugin-find/src/UI/SearchContent.tsx+++ b/packages/sheets-plugin-find/src/View/UI/fuben.tsx@@ -1,282 +1,282 @@-import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';-import { Nullable, Observer, Workbook } from '@univer/core';-import { SpreadsheetPlugin } from '@univer/base-sheets';-// import { Button, CheckboxGroup, Input, Tab, TabPane } from '@univer/style-universheet';-import styles from './index.module.less';-import { FindPlugin } from '../FindPlugin';--interface SearchProps {- config: any;- activeKey?: string;-}-interface ContentProps extends SearchProps {- keys?: string;-}-type SearchState = {- tab: LabelProps[];-};-type ContentState = {- content: LabelProps[];- match: LabelProps[];- buttons: LabelProps[];-};-type LabelProps = {- name: string;- label?: string;- value?: string;- key?: string;- onClick?: () => void;-};--export class SearchContent extends Component<SearchProps, SearchState> {- private _localeObserver: Nullable<Observer<Workbook>>;-- Render: BaseComponentRender;-- initialize() {- const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();- this.state = {- tab: [- {- name: 'find.find',- key: 'find',- },- {- name: 'find.replace',- key: 'replace',- },- ],- };- }-- setLocale() {- const locale = this._context.getLocale();- this.setState((prevState) => {- let { tab } = prevState;-- tab.forEach((item) => {- item.label = locale.get(item.name);- });-- return {- tab,- };- });- }-- componentWillMount() {- this.setLocale();-- // subscribe Locale change event- this._localeObserver = this._context- .getObserverManager()- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- this.setLocale();- });- }-- componentWillUnmount() {- this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- }-- setValue = (value: object, fn?: () => void) => {- this.setState(- (prevState) => ({- ...value,- }),- fn- );- };-- render(props: SearchProps, state: SearchState) {- const Tab = this.Render.renderFunction('Tab');- const TabPane = this.Render.renderFunction('TabPane');- const { tab } = state;- const { config, activeKey } = props;- return (- <Tab activeKey={activeKey} type="card">- {tab.map((item, index) => (- <TabPane tab={item.label} keys={item.key} key={index}>- <Content config={config} keys={item.key}></Content>- </TabPane>- ))}- </Tab>- );- }-}--// tab content-class Content extends Component<ContentProps, ContentState> {- Render: BaseComponentRender;-- private _localeObserver: Nullable<Observer<Workbook>>;-- private _searchText: string | RegExp;-- private _matchList: string[] = []; // match condition list-- initialize(props: ContentProps) {- const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();-- // super(props);- this._context = props.config.context;- this.state = {- content: [- {- name: 'find.findTextbox',- },- {- name: 'find.replaceTextbox',- },- ],- buttons: [- {- name: 'find.allFindBtn',- key: 'find',- onClick: () => this.findText(true),- },- {- name: 'find.findBtn',- key: 'find',- onClick: () => this.findText(),- },- {- name: 'find.allReplaceBtn',- key: 'replace',- },- {- name: 'find.replaceBtn',- key: 'replace',- },- ],- match: [- {- name: 'find.regexTextbox',- value: 'regex',- },- {- name: 'find.wholeTextbox',- value: 'whole',- },- {- name: 'find.distinguishTextbox',- value: 'capslock',- },- ],- };- }-- private setLocale() {- const locale = this._context.getLocale();- this.setState((prevState) => {- let { content, buttons, match } = prevState;-- content.forEach((item) => {- item.label = locale.get(item.name);- });- buttons.forEach((item) => {- item.label = locale.get(item.name);- });- match.forEach((item) => {- item.label = locale.get(item.name);- });-- return {- content,- buttons,- match,- };- });- }-- componentWillMount() {- this.setLocale();-- // subscribe Locale change event- this._localeObserver = this._context- .getObserverManager()- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {- this.setLocale();- });- }-- componentWillUnmount() {- this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);- }-- // get search text- private changeSearchText = (e: Event) => {- const target = e.target as HTMLInputElement;- this._searchText = target.value;- };-- // get match condition- private getMatch = (value: string[]) => {- this._matchList = value;- };-- private findText = (isFull?: boolean) => {- // @ts-ignore- // TODO ...- // BUG- let textFinder = this._context.getPluginManager().getPluginByName<FindPlugin>('pluginFind')!.createTextFinder('A1:B10', this._searchText);- if (this._matchList.includes('capslock')) textFinder = textFinder.matchCase(true);- if (this._matchList.includes('whole')) textFinder = textFinder.matchEntireCell(true);- if (isFull) {- textFinder.findAll();- } else {- textFinder.findNext();- }- };-- render(props: ContentProps, state: ContentState) {- const Button = this.Render.renderFunction('Button');- const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');- const Input = this.Render.renderFunction('Input');- const { keys } = props;- const { content, buttons, match } = state;- return (- <div className={styles.tabBox}>- <div className={styles.inputBox}>- <div className={styles.textBox}>- <div>- <span>{content[0].label}: </span>- <Input onChange={(e: Event) => this.changeSearchText(e)} />- </div>- {keys === 'replace' ? (- <div>- <span>{content[1].label}: </span>- <Input />- </div>- ) : (- <></>- )}- </div>- <div>- <CheckboxGroup options={match} onChange={this.getMatch}></CheckboxGroup>- </div>- </div>- <div className={styles.btnBox}>- {buttons.map((item, index) => {- if (keys === 'replace') {- return (- <Button key={index} onClick={item.onClick}>- {item.label}- </Button>- );- }- return (- <Button key={index} onClick={item.onClick}>- {item.label}- </Button>- );- })}- </div>- </div>- );- }-}+import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';+import { Nullable, Observer, Workbook } from '@univer/core';+import { SpreadsheetPlugin } from '@univer/base-sheets';+// import { Button, CheckboxGroup, Input, Tab, TabPane } from '@univer/style-universheet';+import styles from './index.module.less';+import { FindPlugin } from '../../FindPlugin';++interface SearchProps {+ config: any;+ activeKey?: string;+}+interface ContentProps extends SearchProps {+ keys?: string;+}+type SearchState = {+ tab: LabelProps[];+};+type ContentState = {+ content: LabelProps[];+ match: LabelProps[];+ buttons: LabelProps[];+};+type LabelProps = {+ name: string;+ label?: string;+ value?: string;+ key?: string;+ onClick?: () => void;+};++export class SearchContent extends Component<SearchProps, SearchState> {+ private _localeObserver: Nullable<Observer<Workbook>>;++ Render: BaseComponentRender;++ initialize() {+ const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();+ this.state = {+ tab: [+ {+ name: 'find.find',+ key: 'find',+ },+ {+ name: 'find.replace',+ key: 'replace',+ },+ ],+ };+ }++ setLocale() {+ const locale = this._context.getLocale();+ this.setState((prevState) => {+ let { tab } = prevState;++ tab.forEach((item) => {+ item.label = locale.get(item.name);+ });++ return {+ tab,+ };+ });+ }++ componentWillMount() {+ this.setLocale();++ // subscribe Locale change event+ this._localeObserver = this._context+ .getObserverManager()+ .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')+ ?.add(() => {+ this.setLocale();+ });+ }++ componentWillUnmount() {+ this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);+ }++ setValue = (value: object, fn?: () => void) => {+ this.setState(+ (prevState) => ({+ ...value,+ }),+ fn+ );+ };++ render(props: SearchProps, state: SearchState) {+ const Tab = this.Render.renderFunction('Tab');+ const TabPane = this.Render.renderFunction('TabPane');+ const { tab } = state;+ const { config, activeKey } = props;+ return (+ <Tab activeKey={activeKey} type="card">+ {tab.map((item, index) => (+ <TabPane tab={item.label} keys={item.key} key={index}>+ <Content config={config} keys={item.key}></Content>+ </TabPane>+ ))}+ </Tab>+ );+ }+}++// tab content+class Content extends Component<ContentProps, ContentState> {+ Render: BaseComponentRender;++ private _localeObserver: Nullable<Observer<Workbook>>;++ private _searchText: string | RegExp;++ private _matchList: string[] = []; // match condition list++ initialize(props: ContentProps) {+ const component = new SpreadsheetPlugin().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();++ // super(props);+ this._context = props.config.context;+ this.state = {+ content: [+ {+ name: 'find.findTextbox',+ },+ {+ name: 'find.replaceTextbox',+ },+ ],+ buttons: [+ {+ name: 'find.allFindBtn',+ key: 'find',+ onClick: () => this.findText(true),+ },+ {+ name: 'find.findBtn',+ key: 'find',+ onClick: () => this.findText(),+ },+ {+ name: 'find.allReplaceBtn',+ key: 'replace',+ },+ {+ name: 'find.replaceBtn',+ key: 'replace',+ },+ ],+ match: [+ {+ name: 'find.regexTextbox',+ value: 'regex',+ },+ {+ name: 'find.wholeTextbox',+ value: 'whole',+ },+ {+ name: 'find.distinguishTextbox',+ value: 'capslock',+ },+ ],+ };+ }++ private setLocale() {+ const locale = this._context.getLocale();+ this.setState((prevState) => {+ let { content, buttons, match } = prevState;++ content.forEach((item) => {+ item.label = locale.get(item.name);+ });+ buttons.forEach((item) => {+ item.label = locale.get(item.name);+ });+ match.forEach((item) => {+ item.label = locale.get(item.name);+ });++ return {+ content,+ buttons,+ match,+ };+ });+ }++ componentWillMount() {+ this.setLocale();++ // subscribe Locale change event+ this._localeObserver = this._context+ .getObserverManager()+ .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')+ ?.add(() => {+ this.setLocale();+ });+ }++ componentWillUnmount() {+ this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);+ }++ // get search text+ private changeSearchText = (e: Event) => {+ const target = e.target as HTMLInputElement;+ this._searchText = target.value;+ };++ // get match condition+ private getMatch = (value: string[]) => {+ this._matchList = value;+ };++ private findText = (isFull?: boolean) => {+ // @ts-ignore+ // TODO ...+ // BUG+ let textFinder = this._context.getPluginManager().getPluginByName<FindPlugin>('pluginFind')!.createTextFinder('A1:B10', this._searchText);+ if (this._matchList.includes('capslock')) textFinder = textFinder.matchCase(true);+ if (this._matchList.includes('whole')) textFinder = textFinder.matchEntireCell(true);+ if (isFull) {+ textFinder.findAll();+ } else {+ textFinder.findNext();+ }+ };++ render(props: ContentProps, state: ContentState) {+ const Button = this.Render.renderFunction('Button');+ const CheckboxGroup = this.Render.renderFunction('CheckboxGroup');+ const Input = this.Render.renderFunction('Input');+ const { keys } = props;+ const { content, buttons, match } = state;+ return (+ <div className={styles.tabBox}>+ <div className={styles.inputBox}>+ <div className={styles.textBox}>+ <div>+ <span>{content[0].label}: </span>+ <Input onChange={(e: Event) => this.changeSearchText(e)} />+ </div>+ {keys === 'replace' ? (+ <div>+ <span>{content[1].label}: </span>+ <Input />+ </div>+ ) : (+ <></>+ )}+ </div>+ <div>+ <CheckboxGroup options={match} onChange={this.getMatch}></CheckboxGroup>+ </div>+ </div>+ <div className={styles.btnBox}>+ {buttons.map((item, index) => {+ if (keys === 'replace') {+ return (+ <Button key={index} onClick={item.onClick}>+ {item.label}+ </Button>+ );+ }+ return (+ <Button key={index} onClick={item.onClick}>+ {item.label}+ </Button>+ );+ })}+ </div>+ </div>+ );+ }+}diff --git a/packages/sheets-plugin-find/src/UI/index.module.less b/packages/sheets-plugin-find/src/View/UI/index.module.lesssimilarity index 100%rename from packages/sheets-plugin-find/src/UI/index.module.lessrename to packages/sheets-plugin-find/src/View/UI/index.module.lessdiff --git a/packages/sheets-plugin-find/src/UI/test.js b/packages/sheets-plugin-find/src/View/UI/test.jssimilarity index 100%rename from packages/sheets-plugin-find/src/UI/test.jsrename to packages/sheets-plugin-find/src/View/UI/test.jsdiff --git a/packages/sheets-plugin-find/src/main.tsx b/packages/sheets-plugin-find/src/main.tsxindex cf611f5468..36a8946c26 100644--- a/packages/sheets-plugin-find/src/main.tsx+++ b/packages/sheets-plugin-find/src/main.tsx@@ -1,10 +1,3 @@-import { UniverSheet } from '@univer/core';-import { RenderEngine } from '@univer/base-render';-import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';-import { SpreadsheetPlugin } from '@univer/base-sheets';-import { UniverComponentSheet } from '@univer/style-universheet';-import { FindPlugin } from './FindPlugin';-const uiDefaultConfigUp = {container: 'universheet-demo-up',layout: 'auto',@@ -37,26 +30,3 @@ const uiDefaultConfigRight = {container: 'universheet-demo-right',layout: 'auto',};-const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);-univerSheetUp.installPlugin(new RenderEngine());-univerSheetUp.installPlugin(new UniverComponentSheet());-univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new FindPlugin());--const univerSheetDown = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);-univerSheetDown.installPlugin(new RenderEngine());-univerSheetDown.installPlugin(new UniverComponentSheet());-univerSheetDown.installPlugin(new SpreadsheetPlugin(uiDefaultConfigDown));-univerSheetDown.installPlugin(new FindPlugin());--const univerSheetLeft = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);-univerSheetLeft.installPlugin(new RenderEngine());-univerSheetLeft.installPlugin(new UniverComponentSheet());-univerSheetLeft.installPlugin(new SpreadsheetPlugin(uiDefaultConfigLeft));-univerSheetLeft.installPlugin(new FindPlugin());--const univerSheetRight = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);-univerSheetRight.installPlugin(new RenderEngine());-univerSheetRight.installPlugin(new UniverComponentSheet());-univerSheetRight.installPlugin(new SpreadsheetPlugin(uiDefaultConfigRight));-univerSheetRight.installPlugin(new FindPlugin());diff --git a/packages/sheets-plugin-formula/src/main.tsx b/packages/sheets-plugin-formula/src/main.tsxindex 15f48722a5..9fc18001f6 100644--- a/packages/sheets-plugin-formula/src/main.tsx+++ b/packages/sheets-plugin-formula/src/main.tsx@@ -3,8 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { FormulaPlugin } from './FormulaPlugin';-import { DEFAULT_FORMULA_DATA } from './Basic/DEFAULT_FORMULA_DATA';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,5 +12,5 @@ const uiDefaultConfigUp = {const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());-FormulaPlugin.create(DEFAULT_FORMULA_DATA).installTo(univerSheetUp);+// FormulaPlugin.create(DEFAULT_FORMULA_DATA).installTo(univerSheetUp);univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));diff --git a/packages/sheets-plugin-freeze/src/main.tsx b/packages/sheets-plugin-freeze/src/main.tsxindex 8104d53300..fe32e5ff9c 100644--- a/packages/sheets-plugin-freeze/src/main.tsx+++ b/packages/sheets-plugin-freeze/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { FreezePlugin } from './FreezePlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new FreezePlugin());+// univerSheetUp.installPlugin(new FreezePlugin());diff --git a/packages/sheets-plugin-group/src/main.tsx b/packages/sheets-plugin-group/src/main.tsxindex 67e0b49c6c..a90ac01d15 100644--- a/packages/sheets-plugin-group/src/main.tsx+++ b/packages/sheets-plugin-group/src/main.tsx@@ -15,5 +15,5 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new FilterPlugin());-univerSheetUp.installPlugin(new GroupPlugin());+// univerSheetUp.installPlugin(new FilterPlugin());+// univerSheetUp.installPlugin(new GroupPlugin());diff --git a/packages/sheets-plugin-image/src/main.tsx b/packages/sheets-plugin-image/src/main.tsxindex e066ffc835..ab8dbfb5f8 100644--- a/packages/sheets-plugin-image/src/main.tsx+++ b/packages/sheets-plugin-image/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { OverGridImagePlugin } from './OverGridImagePlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,8 +13,8 @@ univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(- new OverGridImagePlugin({- value: [],- })-);+// univerSheetUp.installPlugin(+// new OverGridImagePlugin({+// value: [],+// })+// );diff --git a/packages/sheets-plugin-link/src/main.tsx b/packages/sheets-plugin-link/src/main.tsxindex d5bec61428..1a3dd943d9 100644--- a/packages/sheets-plugin-link/src/main.tsx+++ b/packages/sheets-plugin-link/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { LinkPlugin } from './LinkPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -13,4 +12,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new LinkPlugin());+// univerSheetUp.installPlugin(new LinkPlugin());diff --git a/packages/sheets-plugin-numfmt/package.json b/packages/sheets-plugin-numfmt/package.jsonindex ed02bb58ec..cbb87edb6c 100644--- a/packages/sheets-plugin-numfmt/package.json+++ b/packages/sheets-plugin-numfmt/package.json@@ -47,9 +47,11 @@},"dependencies": {"@univer/base-component": "workspace:^0.0.1",- "@univer/base-render": "workspace:^0.0.1","@univer/base-numfmt-engine": "workspace:^0.0.1",+ "@univer/base-render": "workspace:^0.0.1",+ "@univer/base-sheets": "workspace:^0.0.1","@univer/common-plugin-data": "workspace:^0.0.1",- "@univer/core": "workspace:^0.0.1"+ "@univer/core": "workspace:^0.0.1",+ "preact": "^10.5.14"}}diff --git a/packages/sheets-plugin-numfmt/src/Basic/Observer.ts b/packages/sheets-plugin-numfmt/src/Basic/Observer.tsnew file mode 100644index 0000000000..ea1d16581d--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Basic/Observer.ts@@ -0,0 +1,15 @@+import { Observable } from '@univer/core';+import { NumfmtPlugin } from '../NumfmtPlugin';+import { NumfmtModal } from '../View/UI/NumfmtModal';++export type NumfmtPluginObserve = {+ onNumfmtModalDidMountObservable: Observable<NumfmtModal>;+};++export function uninstall(plugin: NumfmtPlugin) {+ plugin.deleteObserve('onNumfmtModalDidMountObservable');+}++export function install(plugin: NumfmtPlugin) {+ plugin.pushToObserve('onNumfmtModalDidMountObservable');+}diff --git a/packages/sheets-plugin-numfmt/src/Const/DEFAULT_DATA.ts b/packages/sheets-plugin-numfmt/src/Const/DEFAULT_DATA.tsnew file mode 100644index 0000000000..49efcff263--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Const/DEFAULT_DATA.ts@@ -0,0 +1,60 @@+export const DEFAULT_DATA = [+ {+ locale: 'defaultFmt.Automatic.text',+ selected: true,+ },+ {+ locale: 'defaultFmt.PlainText.text',+ border: true,+ },+ {+ locale: 'defaultFmt.Number.text',+ suffixLocale: 'defaultFmt.Number.example',+ },+ {+ locale: 'defaultFmt.Percent.text',+ suffixLocale: 'defaultFmt.Percent.example',+ },+ {+ locale: 'defaultFmt.Scientific.text',+ suffixLocale: 'defaultFmt.Scientific.example',+ border: true,+ },+ {+ locale: 'defaultFmt.Accounting.text',+ suffixLocale: 'defaultFmt.Accounting.example',+ },+ {+ locale: 'defaultFmt.Thousand.text',+ suffixLocale: 'defaultFmt.Thousand.example',+ },+ {+ locale: 'defaultFmt.Currency.text',+ suffixLocale: 'defaultFmt.Currency.example',+ },+ {+ locale: 'defaultFmt.Digit.text',+ suffixLocale: 'defaultFmt.Digit.example',+ border: true,+ },+ {+ locale: 'defaultFmt.Date.text',+ suffixLocale: 'defaultFmt.Date.example',+ },+ {+ locale: 'defaultFmt.Time.text',+ suffixLocale: 'defaultFmt.Time.example',+ },+ {+ locale: 'defaultFmt.Time24H.text',+ suffixLocale: 'defaultFmt.Time24H.example',+ },+ {+ locale: 'defaultFmt.DateTime.text',+ suffixLocale: 'defaultFmt.DateTime.example',+ },+ {+ locale: 'defaultFmt.DateTime24H.text',+ suffixLocale: 'defaultFmt.DateTime.example',+ },+];diff --git a/packages/sheets-plugin-numfmt/src/Const/FORMATDETAIL.ts b/packages/sheets-plugin-numfmt/src/Const/FORMATDETAIL.tsnew file mode 100644index 0000000000..ac0d8f7b20--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Const/FORMATDETAIL.ts@@ -0,0 +1,168 @@+export const CURRENCYDETAIL = [+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+ {+ locale: 'currencyDetail.RMB',+ suffix: '¥',+ },+];++export const DATEFMTLISG = [+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+ {+ label: '1930-08-05',+ suffix: 'yyyy-MM-dd',+ },+];++export const NUMBERFORMAT = [+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+ {+ label: '12350',+ suffix: '0',+ },+];diff --git a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.tsindex f7a4984185..491ce8ff02 100644--- a/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts+++ b/packages/sheets-plugin-numfmt/src/Controller/NumfmtController.ts@@ -1,14 +1,77 @@-import { SheetsCommand, Range, IRangeData, ObjectMatrix, Plugin, ACTION_NAMES, ObjectMatrixPrimitiveType } from '@univer/core';+import { SheetsCommand, Range, IRangeData, ObjectMatrix, ObjectMatrixPrimitiveType, PLUGIN_NAMES, ACTION_NAMES } from '@univer/core';+import { BaseComponentRender, BaseComponentSheet } from '@univer/base-component';+import { IToolBarItemProps, SpreadsheetPlugin } from '@univer/base-sheets';import { NumfmtModel } from '../Model/NumfmtModel';+import { NUMFMT_PLUGIN_NAME } from '../Const';+import { DEFAULT_DATA } from '../Const/DEFAULT_DATA';+import { NumfmtPlugin } from '../NumfmtPlugin';export class NumfmtController {protected _model: NumfmtModel;- protected _plugin: Plugin;+ protected _plugin: NumfmtPlugin;- constructor(plugin: Plugin) {+ private _spreadSheetPlugin: SpreadsheetPlugin;++ private _numfmtList: IToolBarItemProps;++ private _render: BaseComponentRender;++ constructor(plugin: NumfmtPlugin) {this._model = new NumfmtModel();this._plugin = plugin;+ this._spreadSheetPlugin = this._plugin.getContext().getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;++ this.initRegisterComponent();++ this._numfmtList = {+ name: NUMFMT_PLUGIN_NAME,+ type: 0,+ tooltipLocale: 'moreFormats',+ show: true,+ border: true,+ children: [+ ...DEFAULT_DATA,+ {+ locale: 'defaultFmt.CustomFormats.text',+ customSuffix: { name: 'RightIcon' },+ children: [+ {+ locale: 'format.moreCurrency',+ onClick: () => {+ this._plugin.getNumfmtModalController().showModal('currency', true);+ },+ },+ {+ locale: 'format.moreDateTime',+ onClick: () => {+ this._plugin.getNumfmtModalController().showModal('date', true);+ },+ },+ {+ locale: 'format.moreNumber',+ onClick: () => {},+ },+ ],+ },+ ],+ };++ this._spreadSheetPlugin.addToolButton(this._numfmtList);+ }++ // 注册自定义组件+ initRegisterComponent() {+ const component = this._plugin.getContext().getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this._render = component.getComponentRender();++ const registerIcon = {+ RightIcon: this._render.renderFunction('RightIcon'),+ };++ for (let k in registerIcon) {+ this._spreadSheetPlugin.registerComponent(k, registerIcon[k]);+ }}getNumfmtBySheetIdConfig(sheetId: string): ObjectMatrixPrimitiveType<string> {diff --git a/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.ts b/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.tsnew file mode 100644index 0000000000..00ff835596--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Controller/NumfmtModalController.ts@@ -0,0 +1,145 @@+import { ComponentChildren } from '@univer/base-component';+import { SpreadsheetPlugin } from '@univer/base-sheets';+import { PLUGIN_NAMES } from '@univer/core';+import { NUMFMT_PLUGIN_NAME } from '../Const';+import { CURRENCYDETAIL, DATEFMTLISG } from '../Const/FORMATDETAIL';+import { NumfmtPlugin } from '../NumfmtPlugin';+import { FormatContent } from '../View/UI/FormatContent';+import { NumfmtModal } from '../View/UI/NumfmtModal';++interface GroupProps {+ locale: string;+ label?: string;+ type?: string;+}++export interface ModalDataProps {+ name?: string;+ title?: string;+ locale: string;+ show: boolean;+ children: {+ name: string;+ props: any;+ };+ onCancel?: () => void;+ group: GroupProps[];+ modal?: ComponentChildren; // 渲染的组件+}++export class NumftmModalController {+ private _plugin: NumfmtPlugin;++ private _spreadSheetPlugin: SpreadsheetPlugin;++ private _numfmtModal: NumfmtModal;++ private _modalData: ModalDataProps[];++ constructor(plugin: NumfmtPlugin) {+ this._plugin = plugin;+ this._spreadSheetPlugin = this._plugin.getContext().getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;+ const locale = this._plugin.getContext().getLocale();++ this._modalData = [+ {+ name: 'currency',+ locale: 'toolbar.currencyFormat',+ show: false,+ group: [+ {+ locale: 'button.cancel',+ type: 'primary',+ },+ {+ locale: 'button.cancel',+ },+ ],+ children: {+ name: NUMFMT_PLUGIN_NAME + FormatContent.name,+ props: {+ data: this.resetContentData(CURRENCYDETAIL),+ onClick: (value: string) => console.dir(value),+ input: locale.get('format.decimalPlaces'),+ onChange: (value: string) => console.dir(value),+ },+ },+ },+ {+ name: 'date',+ locale: 'toolbar.currencyFormat',+ show: false,+ group: [+ {+ locale: 'button.cancel',+ type: 'primary',+ },+ {+ locale: 'button.cancel',+ },+ ],+ children: {+ name: NUMFMT_PLUGIN_NAME + FormatContent.name,+ props: {+ data: DATEFMTLISG,+ onClick: (value: string) => console.dir(value),+ },+ },+ },+ ];++ this.initRegisterComponent();++ this.init();+ }++ init() {+ this._plugin.getObserver('onNumfmtModalDidMountObservable')!.add((component) => {+ this._numfmtModal = component;++ this.resetModalData();+ });+ }++ initRegisterComponent() {+ this._spreadSheetPlugin.registerComponent(NUMFMT_PLUGIN_NAME + FormatContent.name, FormatContent);+ this._spreadSheetPlugin.registerModal(NUMFMT_PLUGIN_NAME + NumfmtModal.name, NumfmtModal);+ }++ resetContentData(data: any[]) {+ const locale = this._plugin.getContext().getLocale();++ for (let i = 0; i < data.length; i++) {+ if (data[i].locale) {+ data[i].label = locale.get(data[i].locale);+ }+ }++ return data;+ }++ // 渲染所需数据+ resetModalData() {+ const locale = this._plugin.getContext().getLocale();++ this._modalData.forEach((item) => {+ item.title = locale.get(item.locale);+ if (item.group && item.group.length) {+ item.group.forEach((ele) => {+ ele.label = locale.get(ele.locale);+ });+ }+ });++ this._numfmtModal.setModal(this._modalData);+ }++ showModal(name: string, show: boolean) {+ const index = this._modalData.findIndex((item) => item.name === name);+ if (index > -1) {+ this._modalData[index].show = show;++ this.resetModalData();+ }+ }+}diff --git a/packages/sheets-plugin-numfmt/src/Locale/en.ts b/packages/sheets-plugin-numfmt/src/Locale/en.tsnew file mode 100644index 0000000000..6ef30277e5--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Locale/en.ts@@ -0,0 +1,161 @@+export default {+ currencyDetail: {+ RMB: 'RMB',+ USdollar: 'US dollar',+ EUR: 'EUR',+ GBP: 'GBP',+ HK: 'HK',+ JPY: 'JPY',+ AlbanianLek: 'Albanian Lek',+ AlgerianDinar: 'Algerian Dinar',+ Afghani: 'Afghani',+ ArgentinePeso: 'Argentine Peso',+ UnitedArabEmiratesDirham: 'United Arab Emirates Dirham',+ ArubanFlorin: 'Aruban Florin',+ OmaniRial: 'Omani Rial',+ Azerbaijanimanat: 'Azerbaijani manat',+ EgyptianPound: 'Egyptian Pound',+ EthiopianBirr: 'Ethiopian Birr',+ AngolaKwanza: 'Angola Kwanza',+ AustralianDollar: 'Australian Dollar',+ Patacas: 'Patacas',+ BarbadosDollar: 'Barbados Dollar',+ PapuaNewGuineaKina: 'Papua New Guinea Kina',+ BahamianDollar: 'Bahamian Dollar',+ PakistanRupee: 'Pakistan Rupee',+ ParaguayanGuarani: 'Paraguayan Guarani',+ BahrainiDinar: 'Bahraini Dinar',+ PanamanianBalboa: 'Panamanian Balboa',+ Brazilianreal: 'Brazilian real',+ Belarusianruble: 'Belarusian ruble',+ BermudianDollar: 'Bermudian Dollar',+ BulgarianLev: 'Bulgarian Lev',+ IcelandKrona: 'Iceland Krona',+ BosniaHerzegovinaConvertibleMark: 'Bosnia-Herzegovina Convertible Mark',+ PolishZloty: 'Polish Zloty',+ Boliviano: 'Boliviano',+ BelizeDollar: 'Belize Dollar',+ BotswanaPula: 'Botswana Pula',+ NotDannuzhamu: 'Not Dannuzhamu',+ BurundiFranc: 'Burundi Franc',+ NorthKoreanWon: 'North Korean Won',+ DanishKrone: 'Danish Krone',+ EastCaribbeanDollar: 'East Caribbean Dollar',+ DominicaPeso: 'Dominica Peso',+ RussianRuble: 'Russian Ruble',+ EritreanNakfa: 'Eritrean Nakfa',+ CFAfranc: 'CFA franc',+ PhilippinePeso: 'Philippine Peso',+ FijiDollar: 'Fiji Dollar',+ CapeVerdeEscudo: 'Cape Verde Escudo',+ FalklandIslandsPound: 'Falkland Islands Pound',+ GambianDalasi: 'Gambian Dalasi',+ Congolesefranc: 'Congolese franc',+ ColombianPeso: 'Colombian Peso',+ CostaRicanColon: 'Costa Rican Colon',+ CubanPeso: 'Cuban Peso',+ Cubanconvertiblepeso: 'Cuban convertible peso',+ GuyanaDollar: 'Guyana Dollar',+ KazakhstanTenge: 'Kazakhstan Tenge',+ Haitiangourde: 'Haitian gourde',+ won: 'won',+ NetherlandsAntillesGuilder: 'Netherlands Antilles Guilder',+ Honduraslempiras: 'Honduras lempiras',+ DjiboutiFranc: 'Djibouti Franc',+ KyrgyzstanSom: 'Kyrgyzstan Som',+ GuineaFranc: 'Guinea Franc',+ CanadianDollar: 'Canadian Dollar',+ GhanaianCedi: 'Ghanaian Cedi',+ Cambodianriel: 'Cambodian riel',+ CzechKoruna: 'Czech Koruna',+ ZimbabweDollar: 'Zimbabwe Dollar',+ QatariRiyal: 'Qatari Riyal',+ CaymanIslandsDollar: 'Cayman Islands Dollar',+ Comorianfranc: 'Comorian franc',+ KuwaitiDinar: 'Kuwaiti Dinar',+ CroatianKuna: 'Croatian Kuna',+ KenyanShilling: 'Kenyan Shilling',+ LesothoLoti: 'Lesotho Loti',+ LaoKip: 'Lao Kip',+ LebanesePound: 'Lebanese Pound',+ Lithuanianlitas: 'Lithuanian litas',+ LibyanDinar: 'Libyan Dinar',+ LiberianDollar: 'Liberian Dollar',+ RwandaFranc: 'Rwanda Franc',+ RomanianLeu: 'Romanian Leu',+ MalagasyAriary: 'Malagasy Ariary',+ MaldivianRufiyaa: 'Maldivian Rufiyaa',+ MalawiKwacha: 'Malawi Kwacha',+ MalaysianRinggit: 'Malaysian Ringgit',+ MacedoniawearingDinar: 'Macedonia wearing Dinar',+ MauritiusRupee: 'Mauritius Rupee',+ MauritanianOuguiya: 'Mauritanian Ouguiya',+ MongolianTugrik: 'Mongolian Tugrik',+ BangladeshiTaka: 'Bangladeshi Taka',+ PeruvianNuevoSol: 'Peruvian Nuevo Sol',+ MyanmarKyat: 'Myanmar Kyat',+ MoldovanLeu: 'Moldovan Leu',+ MoroccanDirham: 'Moroccan Dirham',+ MozambiqueMetical: 'Mozambique Metical',+ MexicanPeso: 'Mexican Peso',+ NamibianDollar: 'Namibian Dollar',+ SouthAfricanRand: 'South African Rand',+ SouthSudanesePound: 'South Sudanese Pound',+ NicaraguaCordoba: 'Nicaragua Cordoba',+ NepaleseRupee: 'Nepalese Rupee',+ NigerianNaira: 'Nigerian Naira',+ NorwegianKrone: 'Norwegian Krone',+ GeorgianLari: 'Georgian Lari',+ RMBOffshore: 'RMB (Offshore)',+ SwedishKrona: 'Swedish Krona',+ SwissFranc: 'Swiss Franc',+ SerbianDinar: 'Serbian Dinar',+ SierraLeone: 'Sierra Leone',+ SeychellesRupee: 'Seychelles Rupee',+ SaudiRiyal: 'Saudi Riyal',+ SaoTomeDobra: 'Sao Tome Dobra',+ SaintHelenapound: 'Saint Helena pound',+ SriLankaRupee: 'Sri Lanka Rupee',+ SwazilandLilangeni: 'Swaziland Lilangeni',+ SudanesePound: 'Sudanese Pound',+ Surinamesedollar: 'Surinamese dollar',+ SolomonIslandsDollar: 'Solomon Islands Dollar',+ SomaliShilling: 'Somali Shilling',+ TajikistanSomoni: 'Tajikistan Somoni',+ PacificFranc: 'Pacific Franc',+ ThaiBaht: 'Thai Baht',+ TanzanianShilling: 'Tanzanian Shilling',+ TonganPaanga: "Tongan Pa'anga",+ TrinidadandTobagoDollar: 'Trinidad and Tobago Dollar',+ TunisianDinar: 'Tunisian Dinar',+ TurkishLira: 'Turkish Lira',+ VanuatuVatu: 'Vanuatu Vatu',+ GuatemalanQuetzal: 'Guatemalan Quetzal',+ CommissionBolivar: 'Commission Bolivar',+ BruneiDollar: 'Brunei Dollar',+ UgandanShilling: 'Ugandan Shilling',+ UkrainianHryvnia: 'Ukrainian Hryvnia',+ UruguayanPeso: 'Uruguayan Peso',+ Uzbekistansom: 'Uzbekistan som',+ WesternSamoaTala: 'Western Samoa Tala',+ SingaporeDollar: 'Singapore Dollar',+ NT: 'NT',+ NewZealandDollar: 'New Zealand Dollar',+ HungarianForint: 'Hungarian Forint',+ SyrianPound: 'Syrian Pound',+ JamaicanDollar: 'Jamaican Dollar',+ ArmenianDram: 'Armenian Dram',+ YemeniRial: 'Yemeni Rial',+ IraqiDinar: 'Iraqi Dinar',+ IranianRial: 'Iranian Rial',+ NewIsraeliShekel: 'New Israeli Shekel',+ IndianRupee: 'Indian Rupee',+ IndonesianRupiah: 'Indonesian Rupiah',+ JordanianDinar: 'Jordanian Dinar',+ VND: 'VND',+ ZambianKwacha: 'Zambian Kwacha',+ GibraltarPound: 'Gibraltar Pound',+ ChileanPeso: 'Chilean Peso',+ CFAFrancBEAC: 'CFA Franc BEAC',+ },+};diff --git a/packages/sheets-plugin-numfmt/src/Locale/index.ts b/packages/sheets-plugin-numfmt/src/Locale/index.tsnew file mode 100644index 0000000000..3ac4bcd0fd--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Locale/index.ts@@ -0,0 +1,4 @@+import zh from './zh';+import en from './en';++export { zh, en };diff --git a/packages/sheets-plugin-numfmt/src/Locale/zh.ts b/packages/sheets-plugin-numfmt/src/Locale/zh.tsnew file mode 100644index 0000000000..e58adf0b82--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Locale/zh.ts@@ -0,0 +1,161 @@+export default {+ currencyDetail: {+ RMB: '人民币',+ USdollar: '美元',+ EUR: '欧元',+ GBP: '英镑',+ HK: '港元',+ JPY: '日元',+ AlbanianLek: '阿尔巴尼亚列克',+ AlgerianDinar: '阿尔及利亚第纳尔',+ Afghani: '阿富汗尼',+ ArgentinePeso: '阿根廷比索',+ UnitedArabEmiratesDirham: '阿拉伯联合酋长国迪拉姆',+ ArubanFlorin: '阿鲁巴弗罗林',+ OmaniRial: '阿曼里亚尔',+ Azerbaijanimanat: '阿塞拜疆马纳特',+ EgyptianPound: '埃及镑',+ EthiopianBirr: '埃塞俄比亚比尔',+ AngolaKwanza: '安哥拉宽扎',+ AustralianDollar: '澳大利亚元',+ Patacas: '澳门元',+ BarbadosDollar: '巴巴多斯元',+ PapuaNewGuineaKina: '巴布亚新几内亚基那',+ BahamianDollar: '巴哈马元',+ PakistanRupee: '巴基斯坦卢比',+ ParaguayanGuarani: '巴拉圭瓜拉尼',+ BahrainiDinar: '巴林第纳尔',+ PanamanianBalboa: '巴拿马巴波亚',+ Brazilianreal: '巴西里亚伊',+ Belarusianruble: '白俄罗斯卢布',+ BermudianDollar: '百慕大元',+ BulgarianLev: '保加利亚列弗',+ IcelandKrona: '冰岛克朗',+ BosniaHerzegovinaConvertibleMark: '波黑可兑换马克',+ PolishZloty: '波兰兹罗提',+ Boliviano: '玻利维亚诺',+ BelizeDollar: '伯利兹元',+ BotswanaPula: '博茨瓦纳普拉',+ NotDannuzhamu: '不丹努扎姆',+ BurundiFranc: '布隆迪法郎',+ NorthKoreanWon: '朝鲜圆',+ DanishKrone: '丹麦克朗',+ EastCaribbeanDollar: '东加勒比元',+ DominicaPeso: '多米尼加比索',+ RussianRuble: '俄国卢布',+ EritreanNakfa: '厄立特里亚纳克法',+ CFAfranc: '非洲金融共同体法郎',+ PhilippinePeso: '菲律宾比索',+ FijiDollar: '斐济元',+ CapeVerdeEscudo: '佛得角埃斯库多',+ FalklandIslandsPound: '福克兰群岛镑',+ GambianDalasi: '冈比亚达拉西',+ Congolesefranc: '刚果法郎',+ ColombianPeso: '哥伦比亚比索',+ CostaRicanColon: '哥斯达黎加科朗',+ CubanPeso: '古巴比索',+ Cubanconvertiblepeso: '古巴可兑换比索',+ GuyanaDollar: '圭亚那元',+ KazakhstanTenge: '哈萨克斯坦坚戈',+ Haitiangourde: '海地古德',+ won: '韩元',+ NetherlandsAntillesGuilder: '荷属安的列斯盾',+ Honduraslempiras: '洪都拉斯拉伦皮拉',+ DjiboutiFranc: '吉布提法郎',+ KyrgyzstanSom: '吉尔吉斯斯坦索姆',+ GuineaFranc: '几内亚法郎',+ CanadianDollar: '加拿大元',+ GhanaianCedi: '加纳塞地',+ Cambodianriel: '柬埔寨瑞尔',+ CzechKoruna: '捷克克朗',+ ZimbabweDollar: '津巴布韦元',+ QatariRiyal: '卡塔尔里亚尔',+ CaymanIslandsDollar: '开曼群岛元',+ Comorianfranc: '科摩罗法郎',+ KuwaitiDinar: '科威特第纳尔',+ CroatianKuna: '克罗地亚库纳',+ KenyanShilling: '肯尼亚先令',+ LesothoLoti: '莱索托洛蒂',+ LaoKip: '老挝基普',+ LebanesePound: '黎巴嫩镑',+ Lithuanianlitas: '立陶宛立特',+ LibyanDinar: '利比亚第纳尔',+ LiberianDollar: '利比亚元',+ RwandaFranc: '卢旺达法郎',+ RomanianLeu: '罗马尼亚列伊',+ MalagasyAriary: '马达加斯加阿里亚里',+ MaldivianRufiyaa: '马尔代夫拉菲亚',+ MalawiKwacha: '马拉维克瓦查',+ MalaysianRinggit: '马来西亚林吉特',+ MacedoniawearingDinar: '马其顿戴第纳尔',+ MauritiusRupee: '毛里求斯卢比',+ MauritanianOuguiya: '毛里塔尼亚乌吉亚',+ MongolianTugrik: '蒙古图格里克',+ BangladeshiTaka: '孟加拉塔卡',+ PeruvianNuevoSol: '秘鲁新索尔',+ MyanmarKyat: '缅甸开亚特',+ MoldovanLeu: '摩尔多瓦列伊',+ MoroccanDirham: '摩洛哥迪拉姆',+ MozambiqueMetical: '莫桑比克梅蒂卡尔',+ MexicanPeso: '墨西哥比索',+ NamibianDollar: '纳米比亚元',+ SouthAfricanRand: '南非兰特',+ SouthSudanesePound: '南苏丹镑',+ NicaraguaCordoba: '尼加拉瓜科多巴',+ NepaleseRupee: '尼泊尔卢比',+ NigerianNaira: '尼日利亚奈拉',+ NorwegianKrone: '挪威克朗',+ GeorgianLari: '乔治亚拉瑞',+ RMBOffshore: '人民币(离岸)',+ SwedishKrona: '瑞典克朗',+ SwissFranc: '瑞士法郎',+ SerbianDinar: '塞尔维亚第纳尔',+ SierraLeone: '塞拉利昂利昂',+ SeychellesRupee: '塞舌尔卢比',+ SaudiRiyal: '沙特里亚尔',+ SaoTomeDobra: '圣多美多布拉',+ SaintHelenapound: '圣赫勒拿群岛磅',+ SriLankaRupee: '斯里兰卡卢比',+ SwazilandLilangeni: '斯威士兰里兰吉尼',+ SudanesePound: '苏丹镑',+ Surinamesedollar: '苏里南元',+ SolomonIslandsDollar: '所罗门群岛元',+ SomaliShilling: '索马里先令',+ TajikistanSomoni: '塔吉克斯坦索莫尼',+ PacificFranc: '太平洋法郎',+ ThaiBaht: '泰国铢',+ TanzanianShilling: '坦桑尼亚先令',+ TonganPaanga: '汤加潘加',+ TrinidadandTobagoDollar: '特立尼达和多巴哥元',+ TunisianDinar: '突尼斯第纳尔',+ TurkishLira: '土耳其里拉',+ VanuatuVatu: '瓦努阿图瓦图',+ GuatemalanQuetzal: '危地马拉格查尔',+ CommissionBolivar: '委内瑞拉博利瓦',+ BruneiDollar: '文莱元',+ UgandanShilling: '乌干达先令',+ UkrainianHryvnia: '乌克兰格里夫尼亚',+ UruguayanPeso: '乌拉圭比索',+ Uzbekistansom: '乌兹别克斯坦苏姆',+ WesternSamoaTala: '西萨摩亚塔拉',+ SingaporeDollar: '新加坡元',+ NT: '新台币',+ NewZealandDollar: '新西兰元',+ HungarianForint: '匈牙利福林',+ SyrianPound: '叙利亚镑',+ JamaicanDollar: '牙买加元',+ ArmenianDram: '亚美尼亚德拉姆',+ YemeniRial: '也门里亚尔',+ IraqiDinar: '伊拉克第纳尔',+ IranianRial: '伊朗里亚尔',+ NewIsraeliShekel: '以色列新谢克尔',+ IndianRupee: '印度卢比',+ IndonesianRupiah: '印度尼西亚卢比',+ JordanianDinar: '约旦第纳尔',+ VND: '越南盾',+ ZambianKwacha: '赞比亚克瓦查',+ GibraltarPound: '直布罗陀镑',+ ChileanPeso: '智利比索',+ CFAFrancBEAC: '中非金融合作法郎',+ },+};diff --git a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.tsindex 1ed397722f..af1ff85796 100644--- a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts+++ b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts@@ -1,11 +1,16 @@import { ActionExtensionManager, Context, IRangeData, ObjectMatrixPrimitiveType, Plugin } from '@univer/core';+import { NumfmtPluginObserve, install } from './Basic/Observer';import { NUMFMT_PLUGIN_NAME } from './Const/PLUGIN_NAME';import { NumfmtController } from './Controller/NumfmtController';+import { NumftmModalController } from './Controller/NumfmtModalController';+import { en, zh } from './Locale';import { NumfmtActionExtensionFactory } from './NumfmtActionExtensionFactory';-export class NumfmtPlugin extends Plugin {+export class NumfmtPlugin extends Plugin<NumfmtPluginObserve> {protected _controller: NumfmtController;+ private _numftmModalController: NumftmModalController;+protected _numfmtActionExtensionFactory: NumfmtActionExtensionFactory;constructor() {@@ -13,7 +18,15 @@ export class NumfmtPlugin extends Plugin {}onMounted(context: Context): void {+ install(this);++ context.getLocale().load({+ en,+ zh,+ });+this._numfmtActionExtensionFactory = new NumfmtActionExtensionFactory(this);+ this._numftmModalController = new NumftmModalController(this);this._controller = new NumfmtController(this);ActionExtensionManager.create().add(this._numfmtActionExtensionFactory);}@@ -34,4 +47,8 @@ export class NumfmtPlugin extends Plugin {setNumfmtByCoords(sheetId: string, row: number, column: number, format: string): void {this._controller.setNumfmtByCoords(sheetId, row, column, format);}++ getNumfmtModalController() {+ return this._numftmModalController;+ }}diff --git a/packages/sheets-plugin-numfmt/src/Types/index.d.ts b/packages/sheets-plugin-numfmt/src/Types/index.d.tsnew file mode 100644index 0000000000..b3c42a631d--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/Types/index.d.ts@@ -0,0 +1,13 @@+/// <reference types="vite/client" />++export * from '../index';+declare module '@univer/sheets-plugin-numfmt' {}++declare module 'es6-proxy-polyfill';+// declare module '*.less';++// use css module+declare module '*.less' {+ const resource: { [key: string]: string };+ export = resource;+}diff --git a/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsx b/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsxnew file mode 100644index 0000000000..de743141fe--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsx@@ -0,0 +1,76 @@+import { BaseComponentRender, BaseComponentSheet, Component, createRef } from '@univer/base-component';+import styles from './index.module.less';++interface IProps {+ data: any[];+ input?: string;+ onClick: (value: string) => void;+ onChange?: (value: string) => void;+}++interface IState {}++export class FormatContent extends Component<IProps, IState> {+ private _render: BaseComponentRender;++ private _ref = createRef();++ initialize(props: IProps) {+ // super(props);+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this._render = component.getComponentRender();+ }++ getInput() {+ const { input } = this.props;+ const Input = this._render.renderFunction('Input');++ if (input) {+ return (+ <div className={styles.formatInput}>+ <span>{input}:</span>+ <Input type="number" value="2" onChange={this.handleChange.bind(this)}></Input>+ </div>+ );+ }+ }++ handleClick(value: string, index: number) {+ const lis = this._ref.current.querySelectorAll('li');+ for (let i = 0; i < lis.length; i++) {+ lis[i].classList.remove(styles.formatSelected);+ }++ lis[index].classList.add(styles.formatSelected);++ this.props.onClick(value);+ }++ handleChange(e: Event) {+ const value = (e.target as HTMLInputElement).value;+ this.props.onChange?.(value);+ }++ /**+ * Render the component's HTML+ *+ * @returns {void}+ */+ render() {+ const { data } = this.props;++ return (+ <div className={styles.formatContent} ref={this._ref}>+ {this.getInput()}+ <ul>+ {data.map((item, index) => (+ <li onClick={() => this.handleClick(item.value, index)}>+ <span>{item.label}</span>+ <span>{item.suffix}</span>+ </li>+ ))}+ </ul>+ </div>+ );+ }+}diff --git a/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx b/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsxnew file mode 100644index 0000000000..987be1b604--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx@@ -0,0 +1,70 @@+import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';+import { SpreadsheetPlugin } from '@univer/base-sheets';+import { PLUGIN_NAMES } from '@univer/core';+import { NUMFMT_PLUGIN_NAME } from '../../Const';+import { ModalDataProps } from '../../Controller/NumfmtModalController';+import { NumfmtPlugin } from '../../NumfmtPlugin';++interface IProps {}++interface IState {+ modalData: ModalDataProps[];+}++export class NumfmtModal extends Component<IProps, IState> {+ private _render: BaseComponentRender;++ initialize(props: IProps) {+ // super(props);+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this._render = component.getComponentRender();++ this.state = {+ modalData: [],+ };+ }++ componentDidMount() {+ const plugin = this._context.getPluginManager().getPluginByName<NumfmtPlugin>(NUMFMT_PLUGIN_NAME)!;+ plugin.getObserver('onNumfmtModalDidMountObservable')!.notifyObservers(this);+ }++ setModal(modalData: ModalDataProps[]) {+ const spreadSheetPlugin = this._context.getPluginManager().getPluginByName<SpreadsheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;++ modalData.forEach((item) => {+ const Label = spreadSheetPlugin.getRegisterComponent(item.children.name);+ if (Label) {+ const props = item.children.props ?? {};+ item.modal = <Label {...props} />;+ }+ });++ this.setState({+ modalData,+ });+ }++ /**+ * Render the component's HTML+ *+ * @returns {void}+ */+ render() {+ const Modal = this._render.renderFunction('Modal');+ const { modalData } = this.state;+ // Set Provider for entire Container+ return (+ <>+ {modalData.map((item) => {+ if (!item.show) return;+ return (+ <Modal title={item.title} visible={item.show} group={item.group} onCancel={item.onCancel}>+ {item.modal}+ </Modal>+ );+ })}+ </>+ );+ }+}diff --git a/packages/sheets-plugin-numfmt/src/View/UI/index.module.less b/packages/sheets-plugin-numfmt/src/View/UI/index.module.lessnew file mode 100644index 0000000000..164c6db2d0--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/View/UI/index.module.less@@ -0,0 +1,36 @@+@import '@univer/style-universheet/assets/css/skin/default.module.less';++.format-content {+ .format-input {+ display: flex;++ input {+ width: 80px;+ height: 24px;+ padding: 0 5px;+ margin-left: 5px;+ }+ }++ ul {+ height: 240px;+ border: 1px solid @gray-5;+ overflow-y: auto;+ list-style: none;+ padding: 0;++ li {+ height: 30px;+ padding: 0 20px;+ border-bottom: 1px solid #dfdfdf;+ line-height: 30px;+ display: flex;+ justify-content: space-between;+ }++ .format-selected {+ color: #fff;+ background: var(--primary-color);+ }+ }+}\ No newline at end of filediff --git a/packages/sheets-plugin-numfmt/src/index.d.ts b/packages/sheets-plugin-numfmt/src/index.d.tsdeleted file mode 100644index 9d20f3e8f2..0000000000--- a/packages/sheets-plugin-numfmt/src/index.d.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './index';-declare module '@univer/sheets-plugin-numfmt' {}diff --git a/packages/sheets-plugin-numfmt/src/index.ts b/packages/sheets-plugin-numfmt/src/index.tsindex 23e4e55b3d..e74a4c124e 100644--- a/packages/sheets-plugin-numfmt/src/index.ts+++ b/packages/sheets-plugin-numfmt/src/index.ts@@ -1,3 +1,3 @@-import './Model/RegisterAction';--export * from './NumfmtPlugin';+import './Model/RegisterAction';++export * from './NumfmtPlugin';diff --git a/packages/sheets-plugin-numfmt/src/preact.d.ts b/packages/sheets-plugin-numfmt/src/preact.d.tsnew file mode 100644index 0000000000..0d9c32b84c--- /dev/null+++ b/packages/sheets-plugin-numfmt/src/preact.d.ts@@ -0,0 +1 @@+import JSX = preact.JSX;diff --git a/packages/sheets-plugin-pivot-table/src/main.tsx b/packages/sheets-plugin-pivot-table/src/main.tsxindex c5a56a39f2..7ba82620b6 100644--- a/packages/sheets-plugin-pivot-table/src/main.tsx+++ b/packages/sheets-plugin-pivot-table/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { PivotTablePlugin } from './PivotTablePlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -15,4 +14,4 @@ univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new PivotTablePlugin());+// univerSheetUp.installPlugin(new PivotTablePlugin());diff --git a/packages/sheets-plugin-print/src/main.tsx b/packages/sheets-plugin-print/src/main.tsxindex d27988fc61..2275028a18 100644--- a/packages/sheets-plugin-print/src/main.tsx+++ b/packages/sheets-plugin-print/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { PrintPlugin } from './PrintPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new PrintPlugin());+// univerSheetUp.installPlugin(new PrintPlugin());diff --git a/packages/sheets-plugin-protection/src/main.tsx b/packages/sheets-plugin-protection/src/main.tsxindex 3ea04088c7..fa9e2d830d 100644--- a/packages/sheets-plugin-protection/src/main.tsx+++ b/packages/sheets-plugin-protection/src/main.tsx@@ -4,9 +4,6 @@ import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { FilterPlugin } from '@univer/sheets-plugin-filter';-import { ProtectionPlugin } from './ProtectionPlugin';-const uiDefaultConfigUp = {container: 'universheet-demo',layout: 'auto',@@ -16,5 +13,5 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new FilterPlugin());-univerSheetUp.installPlugin(new ProtectionPlugin());+// univerSheetUp.installPlugin(new FilterPlugin());+// univerSheetUp.installPlugin(new ProtectionPlugin());diff --git a/packages/sheets-plugin-screenshot/src/main.tsx b/packages/sheets-plugin-screenshot/src/main.tsxindex 2854d80ab9..9f7bbf95dd 100644--- a/packages/sheets-plugin-screenshot/src/main.tsx+++ b/packages/sheets-plugin-screenshot/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { ScreenshotPlugin } from './ScreenshotPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -14,4 +13,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new ScreenshotPlugin());+// univerSheetUp.installPlugin(new ScreenshotPlugin());diff --git a/packages/sheets-plugin-sort/src/main.tsx b/packages/sheets-plugin-sort/src/main.tsxindex 975892e907..bc69ddc9f9 100644--- a/packages/sheets-plugin-sort/src/main.tsx+++ b/packages/sheets-plugin-sort/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { SortPlugin } from './SortPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -25,4 +24,4 @@ const univerSheetUp = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA);univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new SortPlugin());+// univerSheetUp.installPlugin(new SortPlugin());diff --git a/packages/sheets-plugin-split-column/src/main.tsx b/packages/sheets-plugin-split-column/src/main.tsxindex f4ea324303..9a4b517615 100644--- a/packages/sheets-plugin-split-column/src/main.tsx+++ b/packages/sheets-plugin-split-column/src/main.tsx@@ -3,7 +3,6 @@ import { RenderEngine } from '@univer/base-render';import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';import { SpreadsheetPlugin } from '@univer/base-sheets';import { UniverComponentSheet } from '@univer/style-universheet';-import { SplitColumnPlugin } from './SplitColumnPlugin';const uiDefaultConfigUp = {container: 'universheet-demo-up',@@ -15,4 +14,4 @@ univerSheetUp.installPlugin(new RenderEngine());univerSheetUp.installPlugin(new UniverComponentSheet());univerSheetUp.installPlugin(new SpreadsheetPlugin(uiDefaultConfigUp));-univerSheetUp.installPlugin(new SplitColumnPlugin());+// univerSheetUp.installPlugin(new SplitColumnPlugin());diff --git a/packages/style-universheet/src/Components/Demo/demo.tsx b/packages/style-universheet/src/Components/Demo/demo.tsxindex 156f4a7697..45f4f4c6b4 100644--- a/packages/style-universheet/src/Components/Demo/demo.tsx+++ b/packages/style-universheet/src/Components/Demo/demo.tsx@@ -1,50 +1,50 @@-import { BaseDemoProps, Component, DemoComponent, JSXComponent } from '@univer/base-component';--// type BaseDemoProps = {--// };--// Types for state-type IState = {};--export class Demo extends Component<BaseDemoProps, IState> {- render(props: BaseDemoProps, state: IState) {- // const { onClick } = props;- // const UniverComponentSheet = new UniverComponentSheet();- // const render = UniverComponentSheet.getComponentRender();- // const Button = render.renderFunction('Button');-- // const Container = render.renderFunction('Container');- // const CellRangeModal = render.renderClass('CellRangeModal');- // const Layout = render.renderClass('Layout');- // const Header = render.renderFunction('Header');- // const Footer = render.renderFunction('Footer');- // const Content = render.renderFunction('Content');- // const Sider = render.renderFunction('Sider');-- return (- <div style={{ position: 'fixed', left: '0', top: '0', right: '0', bottom: '0', zIndex: '1' }}>- {/* <Button onClick={onClick}>Close</Button>- <Container style={{ height: '100%', width: '100%', background: 'gray' }}>- <Layout>- <Header>- <Button>Close</Button>- </Header>- <Content>- <CellRangeModal placeholderProps="cell1"></CellRangeModal>-- </Content>- <Sider>6</Sider>- <Footer>7</Footer>- </Layout>- </Container> */}- </div>- );- }-}--export class UniverDemo implements DemoComponent {- render(): JSXComponent<BaseDemoProps> {- return Demo;- }-}+// import { BaseDemoProps, Component, DemoComponent, JSXComponent } from '@univer/base-component';++// // type BaseDemoProps = {++// // };++// // Types for state+// type IState = {};++// export class Demo extends Component<BaseDemoProps, IState> {+// render(props: BaseDemoProps, state: IState) {+// // const { onClick } = props;+// // const UniverComponentSheet = new UniverComponentSheet();+// // const render = UniverComponentSheet.getComponentRender();+// // const Button = render.renderFunction('Button');++// // const Container = render.renderFunction('Container');+// // const CellRangeModal = render.renderClass('CellRangeModal');+// // const Layout = render.renderClass('Layout');+// // const Header = render.renderFunction('Header');+// // const Footer = render.renderFunction('Footer');+// // const Content = render.renderFunction('Content');+// // const Sider = render.renderFunction('Sider');++// return (+// <div style={{ position: 'fixed', left: '0', top: '0', right: '0', bottom: '0', zIndex: '1' }}>+// {/* <Button onClick={onClick}>Close</Button>+// <Container style={{ height: '100%', width: '100%', background: 'gray' }}>+// <Layout>+// <Header>+// <Button>Close</Button>+// </Header>+// <Content>+// <CellRangeModal placeholderProps="cell1"></CellRangeModal>++// </Content>+// <Sider>6</Sider>+// <Footer>7</Footer>+// </Layout>+// </Container> */}+// </div>+// );+// }+// }++// export class UniverDemo implements DemoComponent {+// render(): JSXComponent<BaseDemoProps> {+// return Demo;+// }+// }diff --git a/packages/style-universheet/src/Components/Demo/index.ts b/packages/style-universheet/src/Components/Demo/index.tsindex 689b5cbca9..49e0977b01 100644--- a/packages/style-universheet/src/Components/Demo/index.ts+++ b/packages/style-universheet/src/Components/Demo/index.ts@@ -1 +1 @@-export * from './demo';+// export * from './demo';diff --git a/packages/style-universheet/src/Components/Modal/Modal.tsx b/packages/style-universheet/src/Components/Modal/Modal.tsxindex cf91384200..05eb352eee 100644--- a/packages/style-universheet/src/Components/Modal/Modal.tsx+++ b/packages/style-universheet/src/Components/Modal/Modal.tsx@@ -5,21 +5,28 @@ import { Drag } from '../Drag';import * as Icon from '../Icon';import styles from './index.module.less';-interface IState {}+interface IState {+ visible: boolean;+}class Modal extends Component<BaseModalProps, IState> {+ initialize() {+ this.state = {+ visible: this.props.visible ?? false,+ };+ }+handleClickCancel = (cb: Function | undefined) => {// this.setState({ visible: false });if (cb) cb();};- // showModal = (value: boolean) => {- // this.setState((prevState) => {- // return {- // visible: value,- // };- // });- // };+ showModal = (value: boolean) => {+ this.setState((prevState) => ({+ visible: value,+ }));+ };+// maskClick = (e: MouseEvent) => {// const mask = document.querySelector(`.${styles.modalMask}`);// if (e.target === mask) {@@ -33,25 +40,40 @@ class Modal extends Component<BaseModalProps, IState> {};render() {- const { title, width = 500, top = 0, style, children, className, group = [], isDrag = false, mask = true, footer = true, visible } = this.props;+ const { title, width = 500, top = 0, style, children, className, group = [], isDrag = false, mask = true, footer = true } = this.props;+ const { visible } = this.state;return (<>{visible ? (<div className={className}>- {mask ? <div className={styles.modalMask} onClick={this.props.onCancel}></div> : null}+ {mask ? (+ <div+ className={styles.modalMask}+ onClick={(e) => {+ this.props.onCancel?.(e);+ this.showModal(false);+ }}+ ></div>+ ) : null}<Drag isDrag={isDrag}><divclassName={`${isDrag ? styles.modalDargWrapper : styles.modalWrapper}`}style={{width: `${width}px`,- top: `${top}px`,+ // top: `${top}px`,...style,}}><div className={styles.modalHeader}><span>{title}</span>- <span className={styles.modalClose} onClick={this.props.onCancel}>+ <span+ className={styles.modalClose}+ onClick={(e) => {+ this.props.onCancel?.(e);+ this.showModal(false);+ }}+ ><Icon.Other.Close></Icon.Other.Close></span></div>diff --git a/packages/style-universheet/src/Components/SelectComponent/Select.tsx b/packages/style-universheet/src/Components/SelectComponent/Select.tsxindex 4e0e864c4a..63cdd1f403 100644--- a/packages/style-universheet/src/Components/SelectComponent/Select.tsx+++ b/packages/style-universheet/src/Components/SelectComponent/Select.tsx@@ -1,4 +1,4 @@-import { BaseSelectProps, createRef, ISelectButton, IToolBarItemProps, JSXComponent, SelectComponent } from '@univer/base-component';+import { BaseSelectProps, createRef, ISelectButton, JSXComponent, SelectComponent } from '@univer/base-component';import { PureComponent } from 'preact/compat';import { Button, ColorPicker, Input, Tooltip, Ul } from '../../index';import styles from './index.module.less';@@ -130,11 +130,11 @@ export class Select extends PureComponent<BaseSelectProps, BaseSelectState> {this.inputRef.current.setValue(label);}- const propsChildren = this.props.children as IToolBarItemProps[];+ const propsChildren = this.props.children as any[];// border line get selected colorif (propsChildren[10] && propsChildren[10].locale === 'borderLine.borderColor') {- const propsColorItem = propsChildren[10] as IToolBarItemProps;+ const propsColorItem = propsChildren[10] as any;const propsColorChildren = propsColorItem.children!;let borderLineSelectedColor = propsColorChildren[0].value;@@ -161,7 +161,7 @@ export class Select extends PureComponent<BaseSelectProps, BaseSelectState> {const children = this.state.children;const selected = children?.find((ele: BaseSelectProps) => ele.selected === true);- const propsChildren = this.props.children as IToolBarItemProps[];+ const propsChildren = this.props.children as any[];// toolbar font color / fill colorif (this.props.selectType === 'color') {@@ -169,7 +169,7 @@ export class Select extends PureComponent<BaseSelectProps, BaseSelectState> {}// border line get selected color, TODO: do not use borderLine.borderColor, use new prop insteadelse if (propsChildren && propsChildren[10] && propsChildren[10].locale === 'borderLine.borderColor') {- const propsColorItem = propsChildren[10] as IToolBarItemProps;+ const propsColorItem = propsChildren[10] as any;const propsColorChildren = propsColorItem.children!;let borderLineSelectedColor = propsColorChildren[0].value;diff --git a/packages/style-universheet/src/StyleUniver.ts b/packages/style-universheet/src/StyleUniver.tsindex 0313be6292..306d8cd36e 100644--- a/packages/style-universheet/src/StyleUniver.ts+++ b/packages/style-universheet/src/StyleUniver.ts@@ -30,7 +30,7 @@ import { UniverCollapse, UniverPanel } from './Components/Collapse/Collapse';import { UniverColorPicker } from './Components/ColorPicker';import { UniverColorPickerCircleButton } from './Components/ColorPickerCircleButton';import { UniverContainer } from './Components/Container';-import { UniverDemo } from './Components/Demo';+// import { UniverDemo } from './Components/Demo';import { UniverFormatModal } from './Components/FormatModal';import { UniverMenu } from './Components/Menu/Menu';import {@@ -208,9 +208,9 @@ export class UniverComponentFactory implements BaseComponentFactory {case 'Sider': {return new UniverSider() as unknown as T;}- case 'Demo': {- return new UniverDemo() as unknown as T;- }+ // case 'Demo': {+ // return new UniverDemo() as unknown as T;+ // }case 'Checkbox': {return new UniverCheckbox() as unknown as T;}