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(base-sheets): Modifying the data structure
tonytonychopper12397be08541f45
diff --git a/packages/base-component/src/Components/ColorPicker.ts b/packages/base-component/src/Components/ColorPicker.tsindex d3e193cf43..a5cbff5947 100644--- a/packages/base-component/src/Components/ColorPicker.ts+++ b/packages/base-component/src/Components/ColorPicker.ts@@ -7,11 +7,6 @@ export interface BaseColorPickerProps {*/color?: string;- /**- * Listen to the confirm button- */- onClick?: (color: string) => void;-/*** cancel select*/@@ -27,6 +22,8 @@ export interface BaseColorPickerProps {*/style?: JSX.CSSProperties;+ onClick?: (color: string, e: MouseEvent) => void; // 返回所选颜色+/*** class name*/diff --git a/packages/base-component/src/Components/ColorPickerCircleButton.ts b/packages/base-component/src/Components/ColorPickerCircleButton.tsindex de4e392e00..b2eabead72 100644--- a/packages/base-component/src/Components/ColorPickerCircleButton.ts+++ b/packages/base-component/src/Components/ColorPickerCircleButton.ts@@ -9,8 +9,7 @@ export interface BaseColorPickerCircleButtonProps {/*** Listen to the confirm button*/- onClick?: (color: string) => void;-+ onClick: (color: string, e?: MouseEvent) => void;/*** cancel select*/diff --git a/packages/base-component/src/Components/Description.ts b/packages/base-component/src/Components/Description.tsindex e049861ea9..7e4d8592d1 100644--- a/packages/base-component/src/Components/Description.ts+++ b/packages/base-component/src/Components/Description.ts@@ -18,6 +18,8 @@ import { CollapseComponent, PanelComponent } from './Collapse';import { UlComponent } from './Ul';import { RichTextComponent } from './RichText';import { SliderComponent } from './Slider';+import { MenuComponent } from './Menu';+import { DropdownComponent } from './Dropdown';export interface Description {Button: ButtonComponent;@@ -50,6 +52,8 @@ export interface Description {Panel: PanelComponent;FormatModal: FormatModalComponent;RichText: RichTextComponent;+ Menu: MenuComponent;+ Dropdown: DropdownComponent;// IconNextIcon: IconComponent;diff --git a/packages/base-component/src/Components/Dropdown.ts b/packages/base-component/src/Components/Dropdown.tsnew file mode 100644index 0000000000..41d3400b1f--- /dev/null+++ b/packages/base-component/src/Components/Dropdown.ts@@ -0,0 +1,16 @@+import { ComponentChildren } from 'preact';+import { BaseComponent, JSXComponent } from '../BaseComponent';+import { BaseMenuProps } from './Menu';++export interface BaseDropdownProps {+ children: ComponentChildren;+ menu: BaseMenuProps;+ placement?: 'Left' | 'Right' | 'Top' | 'Bottom';+ showArrow?: boolean;+ icon?: ComponentChildren;+ onClick?: () => void;+}++export interface DropdownComponent extends BaseComponent<BaseDropdownProps> {+ render(): JSXComponent<BaseDropdownProps>;+}diff --git a/packages/base-component/src/Components/Menu.ts b/packages/base-component/src/Components/Menu.tsindex 9efaa23a74..717af09f74 100644--- a/packages/base-component/src/Components/Menu.ts+++ b/packages/base-component/src/Components/Menu.ts@@ -4,21 +4,37 @@ import { ComponentChildren, JSX } from '../Framework';export interface BaseMenuItem {className?: string;style?: JSX.CSSProperties;- label: ComponentChildren;- children?: BaseMenuProps;+ label?: ComponentChildren;+ value?: any;+ children?: BaseMenuItem[];hide?: boolean;disabled?: boolean;- onClick?: () => void;+ onClick?: (...arg: any) => void;}export interface BaseMenuProps {- list: BaseMenuItem[];- onClick?: () => void;+ menu?: BaseMenuItem[];+ onClick?: (...arg: any) => void;className?: string;style?: JSX.CSSProperties;parent?: any;+ dom?: HTMLElement;+ ref?: any;+ deep?: number;}+export type BaseMenuState = {+ show: boolean;+ posStyle: BaseMenuStyle;+};++export type BaseMenuStyle = {+ left?: string;+ right?: string;+ top?: string;+ bottom?: string;+};+export interface MenuComponent extends BaseComponent<BaseMenuProps> {render(): JSXComponent<BaseMenuProps>;}diff --git a/packages/base-component/src/Components/index.ts b/packages/base-component/src/Components/index.tsindex 2b0e308f74..224ebce769 100644--- a/packages/base-component/src/Components/index.ts+++ b/packages/base-component/src/Components/index.ts@@ -29,3 +29,4 @@ export * from './Tab';export * from './Tooltip';export * from './Ul';export * from './Description';+export * from './Dropdown';diff --git a/packages/base-sheets/src/Basics/Observer.ts b/packages/base-sheets/src/Basics/Observer.tsindex 3527248b02..c6ebfb36fe 100644--- a/packages/base-sheets/src/Basics/Observer.ts+++ b/packages/base-sheets/src/Basics/Observer.ts@@ -3,6 +3,8 @@ import { Observable, Plugin } from '@univer/core';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';interface ISelectionControlFillConfig {}@@ -35,6 +37,9 @@ export type SpreadsheetPluginObserve = {onChangeCurrentSheetObserver: Observable<string>;onToolBarDidMountObservable: Observable<ToolBar>;+ onToolBar1DidMountObservable: Observable<ToolBar1>;++ onLineColorDidMountObservable: Observable<LineColor>;onSheetContainerDidMountObservable: Observable<SheetContainer>;@@ -101,6 +106,8 @@ export function install(plugin: Plugin) {plugin.pushToObserve('onChangeCurrentSheetObserver');plugin.pushToObserve('onToolBarDidMountObservable');+ plugin.pushToObserve('onToolBar1DidMountObservable');+ plugin.pushToObserve('onLineColorDidMountObservable');plugin.pushToObserve('onSheetBarDidMountObservable');plugin.pushToObserve('onCountBarDidMountObservable');plugin.pushToObserve('onInfoBarDidMountObservable');diff --git a/packages/base-sheets/src/Controller/ToolBarController1.ts b/packages/base-sheets/src/Controller/ToolBarController1.tsnew file mode 100644index 0000000000..21471c9ab2--- /dev/null+++ b/packages/base-sheets/src/Controller/ToolBarController1.ts@@ -0,0 +1,624 @@+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/Model/ToolBarModal1.ts b/packages/base-sheets/src/Model/ToolBarModal1.tsnew file mode 100644index 0000000000..1771374500--- /dev/null+++ b/packages/base-sheets/src/Model/ToolBarModal1.ts@@ -0,0 +1,52 @@+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/SpreadsheetPlugin.tsx b/packages/base-sheets/src/SpreadsheetPlugin.tsxindex 45a74a93b5..4c7966b608 100644--- a/packages/base-sheets/src/SpreadsheetPlugin.tsx+++ b/packages/base-sheets/src/SpreadsheetPlugin.tsx@@ -19,6 +19,7 @@ import {CountBarController,SheetContainerController,} from './Controller';+import { ToolBarController1 } from './Controller/ToolBarController1';export interface ISelectionConfig {selection: IRangeData;@@ -96,6 +97,11 @@ const DEFAULT_SPREADSHEET_PLUGIN_DATA: ISpreadsheetPluginConfig = {/*** The main sheet base, construct the sheet container and layout, mount the rendering engine*/+interface ComponentChildrenProps {+ component: any;+ props?: any;+}+export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {@Attribute()private pros: IOCAttribute;@@ -130,6 +136,8 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {private _toolBarControl: ToolBarController;+ private _toolBarControl1: ToolBarController1;+private _infoBarControl: InfoBarController;private _sheetBarControl: SheetBarControl;@@ -142,6 +150,8 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {private _sheetContainerController: SheetContainerController;+ private _componentList: Map<string, ComponentChildrenProps>;+constructor(props: Partial<ISpreadsheetPluginConfig> = {}) {super(PLUGIN_NAMES.SPREADSHEET);@@ -208,8 +218,11 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {onDidMount: () => {},};+ this._componentList = new Map();+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);@@ -414,4 +427,19 @@ export class SpreadsheetPlugin extends Plugin<SpreadsheetPluginObserve> {addRightMenu(item: RightMenuProps[] | RightMenuProps) {this._rightMenuControl.addItem(item);}++ addToolButton(config: IToolBarItemProps) {+ this._toolBarControl1.addToolButton(config);+ }++ registerComponent(name: string, component: any, props?: any) {+ this._componentList.set(name, {+ component,+ props,+ });+ }++ getRegisterComponent(name: string) {+ return this._componentList.get(name);+ }}diff --git a/packages/base-sheets/src/View/UI/Common/Item/Item.tsx b/packages/base-sheets/src/View/UI/Common/Item/Item.tsxnew file mode 100644index 0000000000..452f01885e--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/Item/Item.tsx@@ -0,0 +1,35 @@+import { BaseComponentRender, BaseComponentSheet, BaseMenuItem, Component, ComponentChildren, joinClassNames } from '@univer/base-component';+import styles from './index.module.less';++export interface BaseItemProps extends BaseMenuItem {+ selected?: boolean;+ suffix?: ComponentChildren;+ border?: boolean;+}++export class Item extends Component<BaseItemProps> {+ Render: BaseComponentRender;++ initialize() {+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();+ }++ render() {+ const CorrectIcon = this.Render.renderFunction('CorrectIcon');+ const { selected, label, suffix, disabled } = this.props;+ return (+ <div className={joinClassNames(styles.selectItem, disabled ? styles.selectDisabledItem : '')}>+ {selected ? (+ <span className={styles.selectItemSelected}>+ <CorrectIcon />+ </span>+ ) : (+ ''+ )}+ <span className={styles.selectItemContent}>{label}</span>+ {suffix ? <span className={styles.selectItemSuffix}>{suffix}</span> : ''}+ </div>+ );+ }+}diff --git a/packages/base-sheets/src/View/UI/Common/Item/index.module.less b/packages/base-sheets/src/View/UI/Common/Item/index.module.lessnew file mode 100644index 0000000000..4af2d58556--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/Item/index.module.less@@ -0,0 +1,35 @@+@import '@univer/style-universheet/assets/css/skin/base.module.less';++.select-item {+ padding: 5px 14px 5px 25px;+ display: flex;+ align-items: center;+ position: relative;+ justify-content: space-between;++ .select-item-selected {+ display: flex;+ align-items: center;+ position: absolute;+ left: 5px;+ top: 50%;+ transform: translateY(-50%) scale(1.5);+ }++ .select-item-content {+ display: block;+ }++ .select-item-suffix {+ margin-left: 10px;++ span[role="img"] {+ font-size: 24px;+ }+ }+}++.select-disabled-item {+ pointer-events: none;+ color: @gray-15;+}\ No newline at end of filediff --git a/packages/base-sheets/src/View/UI/Common/Line/LineBold.tsx b/packages/base-sheets/src/View/UI/Common/Line/LineBold.tsxnew file mode 100644index 0000000000..47b64cbe43--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/Line/LineBold.tsx@@ -0,0 +1,56 @@+import { Component } from '@univer/base-component';+import { Nullable, Observer, Workbook } from '@univer/core';++interface IState {+ locale: string;+ img: string;+}++export class LineBold extends Component<null, IState> {+ private _localeObserver: Nullable<Observer<Workbook>>;++ initialize() {+ this.state = {+ locale: '',+ img: '#000',+ };+ }++ componentWillMount() {+ this.setLocale();+ this._localeObserver = this._context+ .getObserverManager()+ .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')+ ?.add(() => {+ this.setLocale();+ });+ }++ componentWillUnmount() {+ this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);+ }++ setLocale() {+ const locale = this.context.locale;++ this.setState({+ locale: locale.get('colorPicker'),+ });+ }++ setImg(img: string) {+ this.setState({+ img,+ });+ }++ render() {+ const { locale, img } = this.state;+ return (+ <>+ <span>{locale}</span>+ <img src={img} />+ </>+ );+ }+}diff --git a/packages/base-sheets/src/View/UI/Common/Line/LineColor.tsx b/packages/base-sheets/src/View/UI/Common/Line/LineColor.tsxnew file mode 100644index 0000000000..8f792010f8--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/Line/LineColor.tsx@@ -0,0 +1,71 @@+import { BaseComponentRender, BaseComponentSheet, Component } from '@univer/base-component';+import { Nullable, Observer, Workbook } from '@univer/core';++interface IState {+ locale: string;+ color: string;+}++interface IProps {+ color: string;+}++export class LineColor extends Component<IProps, IState> {+ private _localeObserver: Nullable<Observer<Workbook>>;++ Render: BaseComponentRender;++ initialize() {+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();++ this.state = {+ locale: '',+ color: this.props.color ?? '#000',+ };+ }++ componentWillMount() {+ this.setLocale();+ this._localeObserver = this._context+ .getObserverManager()+ .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')+ ?.add(() => {+ this.setLocale();+ });+ }++ componentWillUnmount() {+ this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);+ }++ componentDidMount() {+ this._context.getObserverManager().getObserver<LineColor>('onLineColorDidMountObservable')?.notifyObservers(this);+ }++ setLocale() {+ const locale = this.context.locale;++ this.setState({+ locale: locale.get('borderLine.borderColor'),+ });+ }++ setColor(color: string) {+ this.setState({+ color,+ });+ }++ render() {+ const RightIcon = this.Render.renderFunction('RightIcon');+ const { locale, color } = this.state;++ return (+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>+ <span style={{ display: 'inline-block', borderBottom: `3px solid ${color}` }}>{locale}</span>+ <RightIcon />+ </div>+ );+ }+}diff --git a/packages/base-sheets/src/View/UI/Common/Select/Select.tsx b/packages/base-sheets/src/View/UI/Common/Select/Select.tsxnew file mode 100644index 0000000000..24ccfdacd6--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/Select/Select.tsx@@ -0,0 +1,400 @@+import { BaseComponentRender, BaseComponentSheet, BaseMenuItem, BaseMenuProps, Component, ComponentChildren } from '@univer/base-component';+import { ColorPicker, Dropdown } from '@univer/style-universheet';+import { BaseItemProps, Item } from '../Item/Item';+import styles from './index.module.less';++enum SelectTypes {+ SINGLE, // 普通下拉+ INPUT,+ COLOR,+ DOUBLE,+ FIX,+ DOUBLEFIX,+}++enum DisplayTypes {+ LABEL,+ SUFFIX,+}++export interface BaseSelectChildrenProps extends BaseItemProps {+ onKeyUp?: (...arg: any) => void;+ children?: BaseSelectChildrenProps[];+ unSelectable?: boolean; //选中后不生效事件+}++export interface BaseSelectProps {+ type?: SelectTypes;+ children?: BaseSelectChildrenProps[];+ display?: DisplayTypes;+ label?: ComponentChildren;+ onClick?: (...arg: any) => void; //下拉Ul点击事件+ onKeyUp?: (...arg: any) => void;+ defaultColor?: string;+ hideSelectedIcon?: boolean;+ selectClassName?: string;+ name?: string;+}++interface IState {+ menu: BaseMenuItem[];+ color: string;+ content: ComponentChildren;+ value: any;+}++export class Select extends Component<BaseSelectProps, IState> {+ Render: BaseComponentRender;++ ColorRef: any;++ onClick: (...arg: any) => void;++ onKeyUp: (...arg: any[]) => void;++ initialize() {+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();++ const { children = [], hideSelectedIcon } = this.props;+ const list = this.resetMenu(children, hideSelectedIcon);++ this.state = {+ menu: list,+ color: this.props.defaultColor ?? '#000',+ content: '',+ value: '',+ };+ }++ getType(type: SelectTypes) {+ switch (type) {+ case 0:+ return this.getSingle();+ case 1:+ return this.getInput();+ case 2:+ return this.getColor();+ case 3:+ return this.getDouble();+ case 4:+ return this.getFix();+ case 5:+ return this.getDoubleFix();+ }+ }++ componentDidMount() {+ const { type, display, children = [], label } = this.props;++ // 显示值可变+ if (type === 0 || type === 3) {+ if (!children) return;+ let index = children.findIndex((item) => item.selected);+ if (index < 0) index = 0;+ const list = this.handleSelected(index);+ const item = children[index];++ if (display === DisplayTypes.SUFFIX) {+ this.setState({+ content: item.suffix,+ menu: list,+ });+ } else {+ this.setState({+ content: item.label,+ menu: list,+ });+ }++ this.onClick = (...arg) => {+ const item = children[arg[2]];++ this.props.onClick?.(arg[1], arg[2], arg[3]);++ if (item.unSelectable) {+ return;+ }++ const list = this.handleSelected(arg[2]);++ if (display === DisplayTypes.SUFFIX) {+ this.setState({+ content: children[arg[2]].suffix,+ menu: list,+ });+ } else {+ this.setState({+ content: children[arg[2]].label,+ menu: list,+ });+ }+ };+ } else if (type === 1) {+ // 输入框+ if (!children) return;+ // 匹配label和选项label确定选中项+ const getLabel = (label: ComponentChildren) => {+ if (label !== null) {+ if (label === '') return;+ let index = children.findIndex((item) => label === item.label);+ let list = this.handleSelected(index < 0 ? null : index);+ this.setState({+ content: label,+ menu: list,+ });+ } else {+ let index = children.findIndex((item) => item.selected);+ if (index < 0) index = 0;+ let list = this.handleSelected(index);+ const item = children[index];++ this.setState({+ content: item.label,+ menu: list,+ });+ }+ };++ getLabel(label);++ this.onClick = (...arg) => {+ this.props.onClick?.(arg[1], arg[2], arg[3]);++ const list = this.handleSelected(arg[2]);+ this.setState({+ content: children[arg[2]].label,+ menu: list,+ });+ };++ this.onKeyUp = (e: KeyboardEvent) => {+ const value = (e.currentTarget as HTMLInputElement).value;+ this.props.onKeyUp?.(value);+ getLabel(value);+ };+ } else if (type === 2) {+ // 颜色选择器+ const list = this.handleSelected(null);+ this.setState({+ menu: list,+ });++ this.onClick = () => {+ const { color } = this.state;+ this.props.onClick?.(color);+ };+ } else if (type === 4 || type === 5) {+ //固定显示值+ if (!children) return;+ let index = children.findIndex((item) => item.selected);+ if (index < 0) index = 0;+ const item = children[index];+ const list = this.handleSelected(index);+ this.setState({+ menu: list,+ value: item.value,+ });++ this.onClick = (...arg) => {+ if (arg.length) {+ this.props.onClick?.(arg[1], arg[2], arg[3]);+ const list = this.handleSelected(arg[2]);+ this.setState({+ menu: list,+ value: children[arg[2]].value,+ });+ } else {+ this.props.onClick?.(this.state.value);+ }+ };+ }+ }++ resetMenu(children: BaseSelectChildrenProps[], hideSelectedIcon?: boolean) {+ const list: BaseMenuItem[] = [];+ for (let i = 0; i < children.length; i++) {+ let selected = false;+ if (!hideSelectedIcon) {+ selected = children[i].selected ?? false;+ }+ list[i] = { label: '' };+ list[i].label = <Item disabled={children[i].disabled} border={children[i].border} selected={selected} label={children[i].label} suffix={children[i].suffix}></Item>;+ list[i].disabled = children[i].disabled;+ list[i].style = children[i].style;+ list[i].value = children[i].value;+ list[i].className = children[i].className;++ if (children[i].children) {+ list[i].children = this.getChildren(children[i].children!);+ }+ }++ // 颜色下拉塞入colorPicker+ if (this.props.type === 2) {+ list[0] = {+ label: (+ <Item+ label={+ <ColorPicker+ style={{ display: 'block' }}+ ref={(ele) => (this.ColorRef = ele)}+ color={'#000'}+ onClick={(col: string) => {+ this.ColorRef.hideSelect();+ this.setState(+ {+ color: col,+ },+ () => {+ this.onClick();+ }+ );+ }}+ />+ }+ ></Item>+ ),+ };+ }++ return list;+ }++ getChildren(children: BaseSelectChildrenProps[]) {+ const menu: BaseMenuProps[] = children.map((item) => {+ const selected = this.props.hideSelectedIcon ? false : item.selected;+ item.label = <Item disabled={item.disabled} border={item.border} selected={selected} label={item.label} suffix={item.suffix}></Item>;+ if (item.children) {+ item.children = this.getChildren(item.children);+ }+ return item as BaseMenuItem;+ });+ return menu;+ }++ // 处理选中+ handleSelected = (index: number | null): BaseMenuItem[] | undefined => {+ const { children = [], hideSelectedIcon } = this.props;++ children.forEach((item) => {+ item.selected = false;+ });+ if (index !== null) {+ children[index].selected = true;+ }++ const list = this.resetMenu(children, hideSelectedIcon);+ return list;+ };++ // 普通下拉+ getSingle = () => {+ const { content, menu } = this.state;+ const { selectClassName = '' } = this.props;+ const Button = this.Render.renderFunction('Button');++ return (+ <div className={`${styles.selectSingle} ${selectClassName}`}>+ <Button type="text">+ <Dropdown menu={{ menu, onClick: this.onClick }} showArrow>+ <div>{content}</div>+ </Dropdown>+ </Button>+ </div>+ );+ };++ //Input下拉+ getInput = () => {+ const { content, menu } = this.state;+ const { selectClassName = '' } = this.props;+ const Input = this.Render.renderFunction('Input');+ const Button = this.Render.renderFunction('Button');++ return (+ <div className={`${styles.selectInput} ${selectClassName}`}>+ <Button type="text">+ <Dropdown menu={{ menu, onClick: this.onClick }} showArrow>+ <Input onKeyUp={this.onKeyUp} type="number" value={content as string} />+ </Dropdown>+ </Button>+ </div>+ );+ };++ //颜色选择器+ getColor = () => {+ const { label, selectClassName = '' } = this.props;+ const { color, menu } = this.state;+ const Button = this.Render.renderFunction('Button');+ const NextIcon = this.Render.renderFunction('NextIcon');++ return (+ <div className={`${styles.selectColor} ${styles.selectDouble} ${selectClassName}`}>+ <Button type="text">+ <Dropdown onClick={this.onClick} menu={{ menu, onClick: this.onClick }} icon={<NextIcon />}>+ <div className={styles.selectLabel}>{label}</div>+ <div className={styles.selectLine} style={{ background: color }}></div>+ </Dropdown>+ </Button>+ </div>+ );+ };++ getDouble = () => {+ const { content, menu } = this.state;+ const { selectClassName = '' } = this.props;+ const NextIcon = this.Render.renderFunction('NextIcon');+ const Button = this.Render.renderFunction('Button');++ return (+ <div className={`${styles.selectDouble} ${selectClassName}`}>+ <Button type="text">+ <Dropdown menu={{ menu, onClick: this.onClick }} icon={<NextIcon />}>+ <div className={styles.selectLabel}>{content}</div>+ </Dropdown>+ </Button>+ </div>+ );+ };++ getFix = () => {+ const { label, selectClassName = '' } = this.props;+ const { menu } = this.state;+ const Button = this.Render.renderFunction('Button');++ return (+ <div className={`${styles.selectDouble} ${selectClassName}`}>+ <Button type="text">+ <Dropdown menu={{ menu, onClick: this.onClick }} showArrow>+ <div>{label}</div>+ </Dropdown>+ </Button>+ </div>+ );+ };++ getDoubleFix = () => {+ const { label, selectClassName = '' } = this.props;+ const { menu } = this.state;+ const Button = this.Render.renderFunction('Button');+ const NextIcon = this.Render.renderFunction('NextIcon');++ return (+ <div className={`${styles.selectDouble} ${selectClassName}`}>+ <Button type="text">+ <Dropdown onClick={this.onClick} menu={{ menu, onClick: this.onClick }} icon={<NextIcon />}>+ <div className={styles.selectLabel}>{label}</div>+ </Dropdown>+ </Button>+ </div>+ );+ };++ render() {+ const { type = 0 } = this.props;++ return <div className={styles.selectComponent}>{this.getType(type)}</div>;+ }+}diff --git a/packages/base-sheets/src/View/UI/Common/Select/index.module.less b/packages/base-sheets/src/View/UI/Common/Select/index.module.lessnew file mode 100644index 0000000000..6be9bc3c43--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/Select/index.module.less@@ -0,0 +1,119 @@+@import '@univer/style-universheet/assets/css/skin/base.module.less';++.select-component {+ position: relative;+ margin: 0 3px;+ height: 26px;++ &:hover {+ background-color: @gray-14;+ }++ .select-button {+ padding: 0px 5px;++ span[role="img"] {+ font-size: 24px;+ }+ }++ .select-single {+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ .select-input {++ input {+ width: 38px;+ height: 20px;+ background: transparent;+ border: 1px solid transparent;++ &::-webkit-outer-spin-button,+ &::-webkit-inner-spin-button {+ -webkit-appearance: none;+ }++ &[type="number"] {+ -moz-appearance: textfield;+ }++ &:hover {+ border: 1px solid transparent;+ }++ &:focus {+ background: #fff;+ border: 1px solid var(--primary-color-hover);+ }+ }+ }++ .select-color {++ .cols-menu {+ padding: 0;+ border: none;++ .cols-menuitem {+ padding: 0;+ }++ .select-item {+ padding: 0;+ }+ }++ }++ .select-double {+ .dropdown {+ height: 24px;+ padding-right: 0;+ }++ .drop-content {+ position: relative;++ .select-line {+ position: absolute;+ width: 15px;+ height: 5px;+ background-color: #000;+ bottom: 0px;+ left: 50%;+ transform: translate(-50%, 0);+ }+ }++ .drop-icon {+ border-left: 1px solid transparent;+ }++ &:hover {+ .drop-icon {+ border-left: 1px solid @gray-6;+ }+ }++ }++ .select-label {+ span[role="img"] {+ font-size: 24px;+ }+ }++ button {+ .button();+ border-color: transparent;+ height: auto;+ }++}++.button() {+ padding: 0px;+ box-sizing: border-box;+}\ No newline at end of filediff --git a/packages/base-sheets/src/View/UI/Common/TextButton/TextButton.tsx b/packages/base-sheets/src/View/UI/Common/TextButton/TextButton.tsxnew file mode 100644index 0000000000..9c2d9bf6ea--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/TextButton/TextButton.tsx@@ -0,0 +1,47 @@+import { BaseComponentRender, BaseComponentSheet, Component, ComponentChildren } from '@univer/base-component';+import styles from './index.module.less';++export interface BaseTextButtonProps {+ active?: boolean;+ label?: ComponentChildren;+ onClick?: (...arg: any) => void;+}++interface IState {+ active?: boolean;+}++export class TextButton extends Component<BaseTextButtonProps, IState> {+ Render: BaseComponentRender;++ initialize() {+ const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ this.Render = component.getComponentRender();+ this.state = {+ active: this.props.active,+ };+ }++ handleClick = () => {+ const active = !this.state.active;+ this.props.onClick?.(active);++ this.setState({+ active,+ });+ };++ render() {+ const { label } = this.props;+ const { active } = this.state;+ const Button = this.Render.renderFunction('Button');++ return (+ <div className={styles.textButton}>+ <Button type="text" active={active} onClick={this.handleClick}>+ {label}+ </Button>+ </div>+ );+ }+}diff --git a/packages/base-sheets/src/View/UI/Common/TextButton/index.module.css b/packages/base-sheets/src/View/UI/Common/TextButton/index.module.cssnew file mode 100644index 0000000000..4fb4faa3e5--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/TextButton/index.module.css@@ -0,0 +1,6 @@+.text-button span[role="img"] {+ font-size: 24px;+}+.text-button button {+ padding: 0 5px;+}diff --git a/packages/base-sheets/src/View/UI/Common/TextButton/index.module.less b/packages/base-sheets/src/View/UI/Common/TextButton/index.module.lessnew file mode 100644index 0000000000..305b85ad5c--- /dev/null+++ b/packages/base-sheets/src/View/UI/Common/TextButton/index.module.less@@ -0,0 +1,9 @@+.text-button {+ span[role="img"] {+ font-size: 24px;+ }++ button {+ padding: 0 5px;+ }+}\ No newline at end of filediff --git a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsxindex 4caa6d3d2f..aed20fe3bb 100644--- a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx+++ b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx@@ -16,7 +16,6 @@ import {} from '@univer/base-component';import { AsyncFunction, Context, IKeyType, LocaleType, PLUGIN_NAMES, Tools, Workbook } from '@univer/core';import cssVars from 'css-vars-ponyfill';-import {Container,Content,@@ -34,11 +33,12 @@ 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, ToolBar } from '../ToolBar';+import { IShowToolBarConfig } from '../ToolBar';import { CountBar } from '../CountBar/CountBar';export interface ILayout {@@ -193,6 +193,8 @@ export class SheetContainer extends Component<BaseSheetContainerProps, IState> {rightRef = createRef<HTMLDivElement>();+ menuRef = createRef();+cellRightRef = createRef<HTMLDivElement>();btnRef = createRef<HTMLButtonElement>();@@ -649,28 +651,16 @@ export class SheetContainer extends Component<BaseSheetContainerProps, IState> {<Layout className={style.mainContent} style={{ position: 'relative' }}><Header style={{ display: layout.header ? 'block' : 'none' }}><InfoBar></InfoBar>- <ToolBar+ {/* <ToolBarstyle={{display: layout.toolBar ? 'block' : 'none',}}toolList={[]}func={{ addButton }}- ></ToolBar>+ ></ToolBar> */}+ <ToolBar1 toolList={[]}></ToolBar1><FormulaBar></FormulaBar></Header>- {/* <Menu- list={[- {- label: '哈哈哈',- },- {- label: '嘿嘿嘿',- children: {- list: [],- },- },- ]}- /> */}<Layout><Siderstyle={{diff --git a/packages/base-sheets/src/View/UI/ToolBar/Const.ts b/packages/base-sheets/src/View/UI/ToolBar/Const.tsindex de7d79ce34..dc68ce742c 100644--- a/packages/base-sheets/src/View/UI/ToolBar/Const.ts+++ b/packages/base-sheets/src/View/UI/ToolBar/Const.ts@@ -1,5 +1,3 @@-import { ISelectButton } from '@univer/base-component';-export const FONT_SIZE_CHILDREN = [{label: '9',@@ -8,7 +6,6 @@ export const FONT_SIZE_CHILDREN = [{label: '10',value: 10,- selected: true,},{label: '11',@@ -67,75 +64,62 @@ export const FONT_SIZE_CHILDREN = [export const MORE_FORMATS_CHILDREN = [{- name: 'defaultFmt.Automatic.text',+ locale: 'defaultFmt.Automatic.text',selected: true,},{- name: 'defaultFmt.PlainText.text',- selected: false,- },- {- name: 'defaultFmt.Number.text',- iconName: 'defaultFmt.Number.example',- selected: false,+ locale: 'defaultFmt.PlainText.text',border: true,},{- name: 'defaultFmt.Percent.text',- iconName: 'defaultFmt.Percent.example',- selected: false,+ locale: 'defaultFmt.Number.text',+ suffixLocale: 'defaultFmt.Number.example',},{- name: 'defaultFmt.Scientific.text',- iconName: 'defaultFmt.Scientific.example',- selected: false,+ locale: 'defaultFmt.Percent.text',+ suffixLocale: 'defaultFmt.Percent.example',},{- name: 'defaultFmt.Accounting.text',- iconName: 'defaultFmt.Accounting.example',- selected: false,+ locale: 'defaultFmt.Scientific.text',+ suffixLocale: 'defaultFmt.Scientific.example',border: true,},{- name: 'defaultFmt.Thousand.text',- iconName: 'defaultFmt.Thousand.example',- selected: false,+ locale: 'defaultFmt.Accounting.text',+ suffixLocale: 'defaultFmt.Accounting.example',},{- name: 'defaultFmt.Currency.text',- iconName: 'defaultFmt.Currency.example',- selected: false,+ locale: 'defaultFmt.Thousand.text',+ suffixLocale: 'defaultFmt.Thousand.example',},{- name: 'defaultFmt.Digit.text',- iconName: 'defaultFmt.Digit.example',- selected: false,+ locale: 'defaultFmt.Currency.text',+ suffixLocale: 'defaultFmt.Currency.example',},{- name: 'defaultFmt.Date.text',- selected: false,- iconName: 'defaultFmt.Date.example',+ locale: 'defaultFmt.Digit.text',+ suffixLocale: 'defaultFmt.Digit.example',border: true,},{- name: 'defaultFmt.Time.text',- iconName: 'defaultFmt.Time.example',- selected: false,+ locale: 'defaultFmt.Date.text',+ suffixLocale: 'defaultFmt.Date.example',+ },+ {+ locale: 'defaultFmt.Time.text',+ suffixLocale: 'defaultFmt.Time.example',},{- name: 'defaultFmt.Time24H.text',- iconName: 'defaultFmt.Time24H.example',- selected: false,+ locale: 'defaultFmt.Time24H.text',+ suffixLocale: 'defaultFmt.Time24H.example',},{- name: 'defaultFmt.DateTime.text',- iconName: 'defaultFmt.DateTime.example',- selected: false,+ locale: 'defaultFmt.DateTime.text',+ suffixLocale: 'defaultFmt.DateTime.example',},{- name: 'defaultFmt.DateTime24H.text',- iconName: 'defaultFmt.DateTime.example',- selected: false,+ locale: 'defaultFmt.DateTime24H.text',+ suffixLocale: 'defaultFmt.DateTime.example',},];@@ -226,86 +210,56 @@ export const FONT_FAMILY_CHILDREN = [export const BORDER_LINE_CHILDREN = [{locale: 'borderLine.borderTop',- icon: 'TopBorderIcon',+ suffix: 'TopBorderIcon',value: 'top',},{locale: 'borderLine.borderBottom',- icon: 'BottomBorderIcon',+ suffix: 'BottomBorderIcon',value: 'bottom',},{locale: 'borderLine.borderLeft',- icon: 'LeftBorderIcon',+ suffix: 'LeftBorderIcon',value: 'left',},{locale: 'borderLine.borderRight',- icon: 'RightBorderIcon',+ suffix: 'RightBorderIcon',value: 'right',+ border: true,},{locale: 'borderLine.borderNone',- icon: 'NoneBorderIcon',+ suffix: 'NoneBorderIcon',value: 'none',},{locale: 'borderLine.borderAll',- icon: 'FullBorderIcon',+ suffix: 'FullBorderIcon',value: 'all',selected: true,},{locale: 'borderLine.borderOutside',- icon: 'OuterBorderIcon',+ suffix: 'OuterBorderIcon',value: 'outside',},{locale: 'borderLine.borderInside',- icon: 'InnerBorderIcon',+ suffix: 'InnerBorderIcon',value: 'inside',},{locale: 'borderLine.borderHorizontal',- icon: 'StripingBorderIcon',+ suffix: 'StripingBorderIcon',value: 'horizontal',},{locale: 'borderLine.borderVertical',- icon: 'VerticalBorderIcon',+ suffix: 'VerticalBorderIcon',value: 'vertical',},- {- locale: 'borderLine.borderColor',- icon: 'RightIcon',- children: [- {- label: 'BorderLineColorPicker',- selectType: ISelectButton.JSX,- value: '#000',- },- ],- },- {- locale: 'borderLine.borderSize',- icon: 'RightIcon',- needChange: true,- value: 1,- children: [- { locale: 'borderLine.borderNone', label: '', value: 0 },- { locale: '', label: 'BorderThin', value: 1 },- { locale: '', label: 'BorderHair', value: 2 },- { locale: '', label: 'BorderDotted', value: 3 },- { locale: '', label: 'BorderDashed', value: 4 },- { locale: '', label: 'BorderDashDot', value: 5 },- { locale: '', label: 'BorderDashDotDot', value: 6 },- { locale: '', label: 'BorderMedium', value: 7 },- { locale: '', label: 'BorderMediumDashed', value: 8 },- { locale: '', label: 'BorderMediumDashDot', value: 9 },- { locale: '', label: 'BorderMediumDashDotDot', value: 10 },- { locale: '', label: 'BorderThick', value: 12 },- ],- },];export const MERGE_CHILDREN = [@@ -330,17 +284,17 @@ export const MERGE_CHILDREN = [export const HORIZONTAL_ALIGN_CHILDREN = [{locale: 'align.left',- icon: 'LeftAlignIcon',+ suffix: 'LeftAlignIcon',value: 1,},{locale: 'align.center',- icon: 'CenterAlignIcon',+ suffix: 'CenterAlignIcon',value: 2,},{locale: 'align.right',- icon: 'RightAlignIcon',+ suffix: 'RightAlignIcon',value: 3,},];@@ -348,17 +302,17 @@ export const HORIZONTAL_ALIGN_CHILDREN = [export const VERTICAL_ALIGN_CHILDREN = [{locale: 'align.top',- icon: 'TopVerticalIcon',+ suffix: 'TopVerticalIcon',value: 1,},{locale: 'align.middle',- icon: 'CenterVerticalIcon',+ suffix: 'CenterVerticalIcon',value: 2,},{locale: 'align.bottom',- icon: 'BottomVerticalIcon',+ suffix: 'BottomVerticalIcon',value: 3,},];@@ -366,17 +320,17 @@ export const VERTICAL_ALIGN_CHILDREN = [export const TEXT_WRAP_CHILDREN = [{locale: 'textWrap.overflow',- icon: 'OverflowIcon',+ suffix: 'OverflowIcon',value: 1,},{locale: 'textWrap.wrap',- icon: 'BrIcon',+ suffix: 'BrIcon',value: 3,},{locale: 'textWrap.clip',- icon: 'CutIcon',+ suffix: 'CutIcon',value: 2,},];@@ -384,32 +338,32 @@ export const TEXT_WRAP_CHILDREN = [export const TEXT_ROTATE_CHILDREN = [{locale: 'textRotate.none',- icon: 'TextRotateIcon',+ suffix: 'TextRotateIcon',value: 0,},{locale: 'textRotate.angleUp',- icon: 'TextRotateAngleUpIcon',+ suffix: 'TextRotateAngleUpIcon',value: -45,},{locale: 'textRotate.angleDown',- icon: 'TextRotateAngleDownIcon',+ suffix: 'TextRotateAngleDownIcon',value: 45,},{locale: 'textRotate.vertical',- icon: 'TextRotateVerticalIcon',+ suffix: 'TextRotateVerticalIcon',value: 'v',},{locale: 'textRotate.rotationUp',- icon: 'TextRotateRotationUpIcon',+ suffix: 'TextRotateRotationUpIcon',value: -90,},{locale: 'textRotate.rotationDown',- icon: 'TextRotateRotationDownIcon',+ suffix: 'TextRotateRotationDownIcon',value: 90,},];diff --git a/packages/base-sheets/src/View/UI/ToolBar/ToolBar1.tsx b/packages/base-sheets/src/View/UI/ToolBar/ToolBar1.tsxnew file mode 100644index 0000000000..47684ed198--- /dev/null+++ b/packages/base-sheets/src/View/UI/ToolBar/ToolBar1.tsx@@ -0,0 +1,253 @@+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/View/UI/ToolBar/index.module.less b/packages/base-sheets/src/View/UI/ToolBar/index.module.lessindex 1bfa244250..4847d87beb 100644--- a/packages/base-sheets/src/View/UI/ToolBar/index.module.less+++ b/packages/base-sheets/src/View/UI/ToolBar/index.module.less@@ -31,17 +31,51 @@height: 40px;position: relative;- > div {- margin-top: 7px;+ >div {+ // margin-top: 7px;height: 26px;display: inline-block;vertical-align: middle;+ margin: 7px 3px 0 3px;&.select-button:hover {background-color: #efefef;}}+ .cols-menu {+ overflow-y: auto;+ }++ .select-label-string {+ .drop-content {+ >div {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ width: 90px;+ }+ }+ }++ .select-color-picker-parent {+ .select-item-content {+ width: 100%;+ }++ ul {+ padding: 0;+ }++ .select-color-picker {+ padding: 0;++ .select-item {+ padding: 0;+ }+ }+ }+.single-button {margin: 0 3px;@@ -150,4 +184,4 @@span[role='img'].univericon-nextIcon {font-size: 12px;-}+}\ No newline at end of filediff --git a/packages/style-universheet/src/Components/ColorPicker/ColorPicker.tsx b/packages/style-universheet/src/Components/ColorPicker/ColorPicker.tsxindex 68d9c3b65e..488e7a93ce 100644--- a/packages/style-universheet/src/Components/ColorPicker/ColorPicker.tsx+++ b/packages/style-universheet/src/Components/ColorPicker/ColorPicker.tsx@@ -35,16 +35,13 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {ulRef = createRef();initialize(props: BaseColorPickerProps) {- // super(props);this.state = {presetColors: allColor,defaultColor: props.color || '#000',afterColor: props.color || '#000',rgb: true,setting: false,- styles: {- visibility: 'hidden',- },+ styles: {},currentLocale: '',locale: {},root: null,@@ -91,9 +88,9 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {** @eventProperty*/- onClick = (color: string) => {- this.props.onClick && this.props.onClick(color);- this.hideSelect();+ onClick = (color: string, e: MouseEvent) => {+ this.props.onClick && this.props.onClick(color, e);+ // this.hideSelect();};/**@@ -103,25 +100,19 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {*/onCancel = () => {this.props.onCancel && this.props.onCancel();- this.hideSelect();+ // this.hideSelect();};hideSelect = (e?: MouseEvent) => {if (e && this.ulRef.current.contains(e.target)) return;- this.setState((prevState) => ({ styles: { visibility: 'hidden' } }));+ this.setState((prevState) => ({ styles: { display: 'none' } }));document.removeEventListener('click', this.hideSelect, true);};showSelect = (root?: Element) => {- if (root) {- const { top, left } = this.getOffset(root, this.ulRef.current);- this.setState({ root, styles: { left: `${left}px`, top: `${top}px`, visibility: 'visible' } });- } else {- this.setState((prevState) => ({ styles: { visibility: 'visible' } }));- }-+ this.setState((prevState) => ({ styles: { display: 'block' } }));// 点击外部隐藏子组件document.addEventListener('click', this.hideSelect, true);};@@ -175,7 +166,7 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {<divclassName={styles.colorPicker}onClick={(e: MouseEvent) => {- e.stopImmediatePropagation();+ // e.stopImmediatePropagation();}}><div className={styles.picker}>@@ -190,8 +181,8 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {className={styles.pickerSwatchBtn}style={{ background: item }}onClick={(e: MouseEvent) => {- this.onChange(item);- this.onClick(item);+ // this.hideSelect();+ this.props.onClick && this.props.onClick(item, e);}}/></Tooltip>@@ -213,8 +204,8 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {<Buttontype="primary"onClick={(e: MouseEvent) => {- console.info('确定');- this.onClick(this.state.afterColor);+ this.onClick?.(this.state.afterColor, e);+ // this.hideSelect();}}>{this.state.locale.confirmColor}@@ -229,6 +220,7 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {</Button><ButtononClick={(e: MouseEvent) => {+ e.stopPropagation();this.setState({rgb: !this.state.rgb,});@@ -240,8 +232,6 @@ class ColorPicker extends Component<BaseColorPickerProps, IState> {</div>) : null}</div>- {/* {this.props.slot && this.props.slot.header ? <div className={styles.colorPickerSlot}>{this.props.slot.header.label}</div> : null} */}- {/* {this.props.solt && this.props.solt.footer ? <div className={styles.colorPickSolt}>{this.props.solt.footer}</div> : null} */}</div>);}diff --git a/packages/style-universheet/src/Components/ColorPicker/ColorPicker1.tsx b/packages/style-universheet/src/Components/ColorPicker/ColorPicker1.tsxnew file mode 100644index 0000000000..5057d7f26d--- /dev/null+++ b/packages/style-universheet/src/Components/ColorPicker/ColorPicker1.tsx@@ -0,0 +1,262 @@+import { BaseColorPickerProps, ColorPickerComponent, Component, createRef, JSXComponent } from '@univer/base-component';+import { Nullable, Observer, WorkBook } from '@univer/core';+import { Button, Tooltip } from '../index';+import { ColorPickerPanel } from './ColorPickerPanel';+import styles from './index.module.less';++let allColor = [+ ['#000', '#444', '#666', '#999', '#ccc', '#eee', '#f3f3f3', '#fff'],+ ['#f00', '#f90', '#ff0', '#0f0', '#0ff', '#00f', '#90f', '#f0f'],+ ['#f4cccc', '#fce5cd', '#fff2cc', '#d9ead3', '#d0e0e3', '#cfe2f3', '#d9d2e9', '#ead1dc'],+ ['#ea9999', '#f9cb9c', '#ffe599', '#b6d7a8', '#a2c4c9', '#9fc5e8', '#b4a7d6', '#d5a6bd'],+ ['#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6fa8dc', '#8e7cc3', '#c27ba0'],+ ['#c00', '#e69138', '#f1c232', '#6aa84f', '#45818e', '#3d85c6', '#674ea7', '#a64d79'],+ ['#900', '#b45f06', '#bf9000', '#38761d', '#134f5c', '#0b5394', '#351c75', '#741b47'],+ ['#600', '#783f04', '#7f6000', '#274e13', '#0c343d', '#073763', '#20124d', '#4c1130'],+];++// interface ColorPickerProps {+// color?: string; // 当前颜色+// onColor: (color: string, val?: boolean) => void; // 返回所选颜色+// onCancel?: () => void; //取消+// onClick?: () => void;+// onChange?: () => void;+// style?: JSX.CSSProperties;+// className?: string;+// slot?: {+// header?: IMainProps;+// footer?: IMainProps;+// };+// }++interface IState {+ presetColors: string[][];+ defaultColor: string;+ afterColor: string;+ rgb: boolean;+ setting: boolean;+ styles?: JSX.CSSProperties;+ currentLocale: string;+ locale: {+ [index: string]: string;+ };+ root: Element | null;+}++class ColorPicker1 extends Component<BaseColorPickerProps, IState> {+ private _localeObserver: Nullable<Observer<WorkBook>>;++ ulRef = createRef();++ initialize(props: BaseColorPickerProps) {+ // super(props);+ this.state = {+ presetColors: allColor,+ defaultColor: props.color || '#000',+ afterColor: props.color || '#000',+ rgb: true,+ setting: false,+ styles: {+ visibility: 'hidden',+ },+ currentLocale: '',+ locale: {},+ root: null,+ };+ }++ componentWillMount() {+ this.setLocale();+ this._localeObserver = this._context+ .getObserverManager()+ .getObserver<WorkBook>('onAfterChangeUILocaleObservable', 'workbook')+ ?.add(() => {+ this.setLocale();+ });+ }++ componentWillUnmount() {+ this._context.getObserverManager().getObserver<WorkBook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);+ }++ setLocale() {+ const locale = this.context.locale;+ const changeLocale = locale.get('colorPicker');++ this.setState({+ locale: changeLocale,+ });+ }++ /**+ * Gets the selected color+ * @param {string} presetColor new color+ * @param {boolean} val true:Close color selector+ */+ onChange = (presetColor: string) => {+ this.props.onColor(presetColor);+ this.setState({+ afterColor: presetColor,+ });+ };++ /**+ * cancel and close+ *+ * @eventProperty+ */+ onCancel = () => {+ this.props.onCancel && this.props.onCancel();+ this.hideSelect();+ };++ hideSelect = (e?: MouseEvent) => {+ if (e && this.ulRef.current.contains(e.target)) return;++ this.setState((prevState) => ({ styles: { visibility: 'hidden' } }));++ document.removeEventListener('click', this.hideSelect, true);+ };++ showSelect = (root?: Element) => {+ if (root) {+ const { top, left } = this.getOffset(root, this.ulRef.current);+ this.setState({ root, styles: { left: `${left}px`, top: `${top}px`, visibility: 'visible' } });+ } else {+ this.setState((prevState) => ({ styles: { visibility: 'visible' } }));+ }++ // 点击外部隐藏子组件+ document.addEventListener('click', this.hideSelect, true);+ };++ /**+ *+ * @param root Locate according to root+ * @param ele Element to locate+ * @returns+ */+ getOffset = (root: Element, ele: Element) => {+ const rootRect = root.getBoundingClientRect();+ const eleRect = this.ulRef.current.getBoundingClientRect();+ const w = document.documentElement.clientWidth || document.body.clientWidth;+ const h = document.documentElement.clientHeight || document.body.clientHeight;++ let left: number = 0;+ let top: number = 0;++ top = rootRect.top + eleRect.height > h ? rootRect.top - eleRect.height : rootRect.top + rootRect.height;+ left = rootRect.left + eleRect.width > w ? w - eleRect.width : rootRect.left;++ return { left, top };+ };++ /**+ * Custom switch+ * @param e+ */+ onSwitch = (e: Event) => {+ e.stopImmediatePropagation();++ new Promise((resolve, reject) => {+ this.setState({ setting: !this.state.setting });+ resolve('end');+ }).then(() => {+ if (this.state.root) {+ const { top, left } = this.getOffset(this.state.root!, this.ulRef.current);+ this.ulRef.current.style.left = `${left}px`;+ this.ulRef.current.style.top = `${top}px`;+ }+ this.props.onChange && this.props.onChange();+ });+ };++ render() {+ const obj = Object.assign(this.state.styles || {}, this.props.style);++ return (+ <div className={`${styles.colorPickerOutter} ${this.props.className}`} ref={this.ulRef} style={{ ...obj }}>+ {this.props.slot && this.props.slot.header ? <div className={styles.colorPickerSlot}>{this.props.slot.header.content}</div> : null}+ <div+ className={styles.colorPicker}+ onClick={(e: MouseEvent) => {+ // e.stopImmediatePropagation();+ }}+ >+ <div className={styles.picker}>+ <div className={styles.pickerSwatches}>+ {this.state.presetColors.map((presetColor) => (+ <div className={styles.pickerSwatchesItem}>+ {presetColor.map((item) => (+ <span className={styles.pickerSwatch} style={{ background: item }}>+ <Tooltip title={item} placement="top">+ <button+ key={item}+ className={styles.pickerSwatchBtn}+ style={{ background: item }}+ onClick={(e: MouseEvent) => {+ this.props.onColor(item);+ this.hideSelect();+ this.props.onClick && this.props.onClick();+ }}+ />+ </Tooltip>+ </span>+ ))}+ </div>+ ))}+ </div>+ <div>+ <Button onClick={this.onSwitch}>{this.state.setting ? this.state.locale.collapse : this.state.locale.customColor}</Button>+ </div>+ </div>++ {this.state.setting ? (+ <div className={styles.colorfulWarp}>+ <ColorPickerPanel color={this.state.defaultColor} rgb={this.state.rgb} onChange={this.onChange.bind(this)} />++ <div>+ <Button+ type="primary"+ onClick={(e: MouseEvent) => {+ this.props.onColor(this.state.afterColor);+ this.hideSelect();+ }}+ >+ {this.state.locale.confirmColor}+ </Button>+ <Button+ danger+ onClick={(e: MouseEvent) => {+ this.onCancel();+ }}+ >+ {this.state.locale.cancelColor}+ </Button>+ <Button+ onClick={(e: MouseEvent) => {+ this.setState({+ rgb: !this.state.rgb,+ });+ }}+ >+ {this.state.locale.change}+ </Button>+ </div>+ </div>+ ) : null}+ </div>+ {/* {this.props.slot && this.props.slot.header ? <div className={styles.colorPickerSlot}>{this.props.slot.header.label}</div> : null} */}+ {/* {this.props.solt && this.props.solt.footer ? <div className={styles.colorPickSolt}>{this.props.solt.footer}</div> : null} */}+ </div>+ );+ }+}++export class UniverColorPicker implements ColorPickerComponent {+ render(): JSXComponent<BaseColorPickerProps> {+ return ColorPicker1;+ }+}++export { ColorPicker1 };diff --git a/packages/style-universheet/src/Components/ColorPicker/ColorPickerPanel/ColorPickerPanel.tsx b/packages/style-universheet/src/Components/ColorPicker/ColorPickerPanel/ColorPickerPanel.tsxindex b8a45072da..df333675da 100644--- a/packages/style-universheet/src/Components/ColorPicker/ColorPickerPanel/ColorPickerPanel.tsx+++ b/packages/style-universheet/src/Components/ColorPicker/ColorPickerPanel/ColorPickerPanel.tsx@@ -28,7 +28,7 @@ class ColorPickerPanel extends Component<IProps, IState> {render() {return (- <div className={styles.colorPickerPanel}>+ <div className={styles.colorPickerPanel} onClick={(e) => e.stopPropagation()}><RgbaStringColorPicker className={styles.colorPicker} color={this.state.color} onChange={debounce(this.setColor.bind(this), 500)} /><div className={styles.colorPickerPanelSetting}><div className={styles.panelInput}>diff --git a/packages/style-universheet/src/Components/ColorPicker/index.module.less b/packages/style-universheet/src/Components/ColorPicker/index.module.lessindex 94394df3fb..5819eb96c1 100644--- a/packages/style-universheet/src/Components/ColorPicker/index.module.less+++ b/packages/style-universheet/src/Components/ColorPicker/index.module.less@@ -5,7 +5,6 @@padding: 10px;// padding-bottom: 0;border-radius: 10px;- position: fixed;// left: 0; // set outsidebox-shadow: var(--box-shadow-base);z-index: `getZindex('modal') `;diff --git "a/packages/style-universheet/src/Components/ColorPicker/index.module.less\345\211\257\346\234\254" "b/packages/style-universheet/src/Components/ColorPicker/index.module.less\345\211\257\346\234\254"new file mode 100644index 0000000000..b6fc7220cb--- /dev/null+++ "b/packages/style-universheet/src/Components/ColorPicker/index.module.less\345\211\257\346\234\254"@@ -0,0 +1,77 @@+.color-picker-outter {+ width: fit-content;+ display: block;+ background-color: var(--bg);+ padding: 10px;+ // padding-bottom: 0;+ border-radius: 10px;+ position: fixed;+ // left: 0; // set outside+ box-shadow: var(--box-shadow-base);+ z-index: `getZindex('modal') `;+ height: fit-content;+}++.color-picker {+ width: fit-content;+ display: flex;++ .picker {+ width: fit-content;++ .picker-swatches {+ display: flex;+ flex-wrap: nowrap;+ margin-bottom: 10px;++ .picker-swatches-item {+ display: flex;+ flex-direction: column;++ .picker-swatch {+ min-width: 20px;+ width: 20px;+ height: 20px;+ margin: 2px;+ border: 1px solid #eee;+ padding: 0;+ border-radius: 50%;+ cursor: pointer;+ outline: none;+ // overflow: hidden;++ .picker-swatch-btn {+ width: 100%;+ height: 100%;+ border-radius: 50%;+ border: none;+ }+ }+ }+ }++ button {+ display: inline-block;+ font-size: var(--font-size);+ padding: 0 5px;+ }+ }++ .colorful-warp {+ margin-left: 10px;++ button {+ font-size: var(--font-size);+ margin: 10px 10px 10px 0;+ }+ }++ .color-btn {+ border: 1px solid var(--border-color-base);+ }+}++.color-picker-slot {+ margin: 5px;+ outline: 1px solid;+}\ No newline at end of filediff --git a/packages/style-universheet/src/Components/Dropdown/Dropdown.tsx b/packages/style-universheet/src/Components/Dropdown/Dropdown.tsxnew file mode 100644index 0000000000..69d1ec8c07--- /dev/null+++ b/packages/style-universheet/src/Components/Dropdown/Dropdown.tsx@@ -0,0 +1,93 @@+import { BaseDropdownProps, JSXComponent, createRef, Component, DropdownComponent } from '@univer/base-component';+import { Icon, Menu } from '../../index';+import styles from './index.module.less';++interface IState {+ menuStyle: JSX.CSSProperties;+}++export class Dropdown extends Component<BaseDropdownProps, IState> {+ MenuRef = createRef<Menu>();++ DropRef = createRef<HTMLDivElement>();++ IconRef = createRef<HTMLDivElement>();++ protected initialize() {+ this.state = {+ menuStyle: {},+ };+ }++ handleClick = (e: MouseEvent) => {+ this.props.onClick?.();+ const { icon } = this.props;+ if (!icon) {+ this.MenuRef.current?.showMenu(true);+ }+ };++ handleSubClick = () => {+ this.MenuRef.current?.showMenu(true);+ };++ hideMenu = (e: MouseEvent) => {+ if (!this.DropRef.current || !this.DropRef.current?.contains(e.target as Node)) {+ this.MenuRef.current?.showMenu(false);+ }+ };++ componentDidMount() {+ const { placement } = this.props;+ let style: Record<string, string | number> = { position: 'absolute' };+ if (!placement || placement === 'Bottom') {+ style.left = 0;+ style.top = '100%';+ } else if (placement === 'Top') {+ style.left = 0;+ style.top = '-100%';+ } else if (placement === 'Left') {+ style.left = '-100%';+ style.top = 0;+ } else {+ style.left = '100%';+ style.top = 0;+ }+ this.setState({+ menuStyle: style,+ });+ window.addEventListener('click', this.hideMenu);+ }++ componentWillUnmount() {+ window.removeEventListener('click', this.hideMenu);+ }++ render() {+ const { children, menu, showArrow, icon } = this.props;+ const { menuStyle } = this.state;++ return (+ <div className={styles.dropdown} ref={this.DropRef}>+ <div className={styles.dropContent} onClick={this.handleClick}>+ {children}+ {showArrow ? <Icon.Format.NextIcon /> : ''}+ </div>+ {icon ? (+ <div ref={this.IconRef} className={styles.dropIcon} onClick={this.handleSubClick}>+ {icon}+ </div>+ ) : (+ ''+ )}+ <Menu onClick={menu.onClick} ref={this.MenuRef} menu={menu.menu} className={menu.className} style={{ ...menu.style, ...menuStyle }}></Menu>+ </div>+ );+ }+}++export class UniverDropdown implements DropdownComponent {+ render(): JSXComponent<BaseDropdownProps> {+ return Dropdown;+ }+}diff --git a/packages/style-universheet/src/Components/Dropdown/index.module.less b/packages/style-universheet/src/Components/Dropdown/index.module.lessnew file mode 100644index 0000000000..445e243f2c--- /dev/null+++ b/packages/style-universheet/src/Components/Dropdown/index.module.less@@ -0,0 +1,20 @@+@import '../../assets/css/skin/base.module.less';++.dropdown {+ padding: 0px 5px;+ position: relative;+ display: flex;+ align-items: center;++ .drop-content {+ display: flex;+ justify-content: space-between;+ align-items: center;+ }++ .drop-icon {+ height: 100%;+ margin-left: 5px;+ border-left: 1px solid @gray-14;+ }+}\ No newline at end of filediff --git a/packages/style-universheet/src/Components/Dropdown/index.ts b/packages/style-universheet/src/Components/Dropdown/index.tsnew file mode 100644index 0000000000..2f29bad4e6--- /dev/null+++ b/packages/style-universheet/src/Components/Dropdown/index.ts@@ -0,0 +1 @@+export * from './Dropdown';diff --git a/packages/style-universheet/src/Components/Input/input.tsx b/packages/style-universheet/src/Components/Input/input.tsxindex 5846a6cc78..b0439bbc9f 100644--- a/packages/style-universheet/src/Components/Input/input.tsx+++ b/packages/style-universheet/src/Components/Input/input.tsx@@ -30,7 +30,7 @@ export class Input extends Component<BaseInputProps, IState> {initialize(props: BaseInputProps) {// super(props);this.state = {- value: '',+ value: props.value,focused: false,};}@@ -81,6 +81,12 @@ export class Input extends Component<BaseInputProps, IState> {}}+ componentWillReceiveProps(nextProps: Readonly<BaseInputProps>) {+ if (nextProps.value && nextProps.value !== this.state.value) {+ this.setValue(nextProps.value);+ }+ }+render(props: BaseInputProps, state: IState) {const { id, disabled, type, placeholder, bordered = true, className = '', readonly } = props;const { value } = state;diff --git a/packages/style-universheet/src/Components/Menu/Menu.tsx b/packages/style-universheet/src/Components/Menu/Menu.tsxindex 47fac3aba1..000c0843ab 100644--- a/packages/style-universheet/src/Components/Menu/Menu.tsx+++ b/packages/style-universheet/src/Components/Menu/Menu.tsx@@ -1,69 +1,118 @@-import { BaseMenuProps, JSXComponent, Component, MenuComponent, createRef, BaseMenuItem, joinClassNames } from '@univer/base-component';+import { BaseMenuProps, JSXComponent, Component, MenuComponent, createRef, BaseMenuItem, joinClassNames, BaseMenuState, BaseMenuStyle } from '@univer/base-component';import styles from './index.module.less';-type IState = {- show: boolean;-};--export class Menu extends Component<BaseMenuProps, IState> {+export class Menu extends Component<BaseMenuProps, BaseMenuState> {private _MenuRef = createRef<HTMLUListElement>();private _refs: Menu[] = [];protected initialize() {this.state = {- show: true,+ show: false,+ posStyle: {},};}- handleClick = (e: MouseEvent, onClick?: () => void) => {- if (onClick) {- onClick();+ getMenuRef = () => this._MenuRef;++ handleClick = (e: MouseEvent, item: BaseMenuItem, index: number) => {+ const { deep = 0 } = this.props;+ // e.stopPropagation();+ if (item.onClick) {+ item.onClick.call(null, e, item.value, index, deep);} else if (this.props.onClick) {- this.props.onClick();+ this.props.onClick.call(null, e, item.value, index, deep);}this.showMenu(false);};showMenu = (show: boolean) => {- this.setState({- show,- });- };-- showMenuClick = (e: MouseEvent) => {- this.showMenu(false);+ this.setState(+ (prevState) => ({ show }),+ () => {+ this.getStyle();+ }+ );};mouseEnter = (e: MouseEvent, index: number) => {- const { list } = this.props;- // if (list[index].children) {- // }+ const { menu = [] } = this.props;+ if (menu[index].children) {+ this._refs[index].showMenu(true);+ }};- mouseLeave = (e: MouseEvent, index: number) => {};+ mouseLeave = (e: MouseEvent, index: number) => {+ const { menu = [] } = this.props;+ if (menu[index].children) {+ this._refs[index].showMenu(false);+ }+ };- componentDidMount() {- window.addEventListener('click', this.showMenuClick);- }+ getStyle = () => {+ const current = this._MenuRef.current;+ if (!current) return;+ let style: BaseMenuStyle = {};+ const curPosition = current.getBoundingClientRect();+ let docPosition;+ const { dom, parent } = this.props;+ // if (dom) {+ // docPosition = dom.getBoundingClientRect();+ // } else {+ docPosition = {+ left: 0,+ right: document.documentElement.clientWidth,+ top: 0,+ bottom: document.documentElement.clientHeight,+ };+ // }- componentWillUnmount() {- window.removeEventListener('click', this.showMenuClick);- }+ // 处理li中包含的ul右边界+ if (parent) {+ current.style.position = 'fixed';+ // 获取固定定位后 父元素正确的位置信息+ let parPosition = current.parentElement?.getBoundingClientRect();+ if (!parPosition) return;+ if (parPosition.right + curPosition.width > docPosition.right) {+ style.left = `${parPosition.left - curPosition.width}px`;+ style.top = `${parPosition.top}px`;+ } else {+ style.left = `${parPosition.right}px`;+ style.top = `${parPosition.top}px`;+ }+ this.setState({+ posStyle: style,+ });+ }+ // else {+ // if (curPosition.width > docPosition!.right) {+ // // 边界碰到univer-main-content右边界或者小于视口+ // style.right = '0';+ // style.left = 'auto';+ // } else {+ // style.left = '0';+ // style.right = 'auto';+ // }+ // if (curPosition.top >= docPosition.bottom) {+ // style.top = 'auto';+ // style.bottom = '100%';+ // }+ // }+ };render() {- const { className = '', style = '', list } = this.props;- const { show } = this.state;+ const { className = '', style = '', menu, deep = 0 } = this.props;+ const { show, posStyle } = this.state;- return show ? (- <ul className={joinClassNames(styles.colsMenu, className)} style={style} ref={this._MenuRef}>- {list.map((item: BaseMenuItem, index: number) => {+ return (+ <ul className={joinClassNames(styles.colsMenu, className)} style={{ ...style, ...posStyle, display: show ? 'block' : 'none' }} ref={this._MenuRef}>+ {menu?.map((item: BaseMenuItem, index: number) => {if (item.hide) return;return (<li- className={joinClassNames(styles.colsMenuitem, item.className ?? '')}+ className={joinClassNames(styles.colsMenuitem, item.className ?? '', item.disabled ? styles.colsMenuitemDisabled : '')}style={item.style ?? ''}- onClick={(e) => this.handleClick(e, item.onClick)}+ onClick={(e) => this.handleClick(e, item, index)}onMouseEnter={(e) => {this.mouseEnter(e, index);}}@@ -75,11 +124,12 @@ export class Menu extends Component<BaseMenuProps, IState> {{item.children ? (<Menuref={(ele: Menu) => (this._refs[index] = ele)}- list={item.children.list}- onClick={item.children.onClick}- className={item.children.className}- style={item.children.style}+ menu={item.children}+ onClick={item.onClick}+ className={item.className}+ style={item.style}parent={this}+ deep={deep + 1}></Menu>) : (<></>@@ -88,8 +138,6 @@ export class Menu extends Component<BaseMenuProps, IState> {);})}</ul>- ) : (- '');}}diff --git a/packages/style-universheet/src/Components/Menu/index.module.less b/packages/style-universheet/src/Components/Menu/index.module.lessindex 8f79bdf922..bec726aa0c 100644--- a/packages/style-universheet/src/Components/Menu/index.module.less+++ b/packages/style-universheet/src/Components/Menu/index.module.less@@ -23,10 +23,11 @@vertical-align: middle;user-select: none;padding: 5px 0;+ }- .cols-menu {- position: absolute;- }+ .cols-menuitem-disabled {+ pointer-events: none;+ color: @gray-15;}}diff --git a/packages/style-universheet/src/Components/Tooltip/index.module.less b/packages/style-universheet/src/Components/Tooltip/index.module.lessindex 90afafaf88..bf694f73b2 100644--- a/packages/style-universheet/src/Components/Tooltip/index.module.less+++ b/packages/style-universheet/src/Components/Tooltip/index.module.less@@ -2,8 +2,9 @@@import '../../assets/css/skin/base.module.less';@Tooltip-bg: #000000bf;+.tooltip-Group {- width: 100%;+ // width: 100%;height: 100%;display: flex;align-items: center;@@ -20,11 +21,13 @@font-size: @font-size-base;line-height: 1.5;}+.tooltip-body {width: 100%;height: 100%;display: inline-flex;- &:hover ~ .tooltip-title {++ &:hover~.tooltip-title {position: absolute;display: inline-block;z-index: `getZindex('tooltip') `;@@ -39,41 +42,48 @@.top {left: 50%;transform: translateX(-50%);+& .tooltip-triangle {- .triangleDown(@Tooltip-bg,5px);+ .triangleDown(@Tooltip-bg, 5px);bottom: -10px;left: 50%;transform: translateX(-50%);pointer-events: none;}}+.right {top: 50%;transform: translatey(-50%);+& .tooltip-triangle {- .triangleRight(@Tooltip-bg,5px);+ .triangleRight(@Tooltip-bg, 5px);right: -10px;top: 50%;transform: translateY(-50%);pointer-events: none;}}+.bottom {left: 50%;transform: translateX(-50%);+& .tooltip-triangle {- .triangleUp(@Tooltip-bg,5px);+ .triangleUp(@Tooltip-bg, 5px);top: -10px;left: 50%;transform: translateX(-50%);pointer-events: none;}}+.left {top: 50%;transform: translatey(-50%);+& .tooltip-triangle {- .triangleLeft(@Tooltip-bg,5px);+ .triangleLeft(@Tooltip-bg, 5px);left: -10px;top: 50%;transform: translateY(-50%);@@ -143,4 +153,4 @@// .tool {// transition: all 0.3s;// opacity: 0;-// }+// }\ No newline at end of filediff --git a/packages/style-universheet/src/Components/index.ts b/packages/style-universheet/src/Components/index.tsindex d0cfd8233d..64260a52ac 100644--- a/packages/style-universheet/src/Components/index.ts+++ b/packages/style-universheet/src/Components/index.ts@@ -21,6 +21,7 @@ import { Radio, RadioGroup } from './Radio';import { ResizeDialog } from './ResizeDialog';import { RichText } from './RichText/RichText';import { Select } from './SelectComponent';+import { Dropdown } from './Dropdown';import { Separator } from './Separator';import { SiderModal } from './SiderModal';import { Slider } from './Slider';@@ -68,4 +69,5 @@ export {SiderModal,ResizeDialog,RichText,+ Dropdown,};diff --git a/packages/style-universheet/src/StyleUniver.ts b/packages/style-universheet/src/StyleUniver.tsindex c5df7eafc4..0313be6292 100644--- a/packages/style-universheet/src/StyleUniver.ts+++ b/packages/style-universheet/src/StyleUniver.ts@@ -32,6 +32,7 @@ import { UniverColorPickerCircleButton } from './Components/ColorPickerCircleButimport { UniverContainer } from './Components/Container';import { UniverDemo } from './Components/Demo';import { UniverFormatModal } from './Components/FormatModal';+import { UniverMenu } from './Components/Menu/Menu';import {UniverBottomBorderIcon,UniverFillColorIcon,@@ -119,6 +120,7 @@ import { UniverSlider } from './Components/Slider';import { UniverTab, UniverTabPane } from './Components/Tabs';import { UniverTooltip } from './Components/Tooltip';import { UniverUl } from './Components/Ul';+import { UniverDropdown } from './Components/Dropdown';/***@@ -254,7 +256,12 @@ export class UniverComponentFactory implements BaseComponentFactory {case 'RichText': {return new UniverRichText() as unknown as T;}-+ case 'Menu': {+ return new UniverMenu() as unknown as T;+ }+ case 'Dropdown': {+ return new UniverDropdown() as unknown as T;+ }// Iconcase 'NextIcon': {return new UniverNextIcon() as unknown as T;