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): toolbar resize
tonytonychopper123b5e2d01f1d10
diff --git a/packages/base-component/package.json b/packages/base-component/package.jsonindex 9eb506ccea..746f810f1e 100644--- a/packages/base-component/package.json+++ b/packages/base-component/package.json@@ -5,23 +5,17 @@"keywords": [],"author": "DreamNum <[email protected]>","license": "MIT",- "main": "./lib/univer-base-component.cjs.js",- "module": "./lib/univer-base-component.es.js",- "browser": {- "./lib/univer-base-component.cjs.js": "./src/index.ts",- "./lib/univer-base-component.es.js": "./src/index.ts"- },- "types": "./src/Types/index.d.ts",+ "main": "./src/index.ts",+ "module": "./src/index.ts",+ "types": "./src/index.d.ts","exports": {- ".": {- "import": {- "node": "./lib/univer-base-component.cjs.js",- "default": "./lib/univer-base-component.es.js"- },- "require": "./lib/univer-base-component.cjs.js",- "types": "./lib/univer-base-component.d.ts"- },- "./*": "./src/*"+ ".": "./src/index.ts",+ "./*": "./src/*"+ },+ "publishConfig": {+ "main": "./lib/univer-base-component.umd.js",+ "module": "./lib/univer-base-component.es.js",+ "types": "./lib/univer-base-component.d.ts"},"directories": {"lib": "lib"@@ -33,8 +27,6 @@"test:cover": "cross-env NODE_ENV=--experimental-vm-modules jest --coverage","dev": "vite","build": "tsc && vite build",- "watch": "vite build",- "link": "pnpm link ./","serve": "vite preview"},"devDependencies": {@@ -44,6 +36,8 @@"@types/node": "^16.4.6","@vitejs/plugin-legacy": "^1.5.1","debug": "^4.3.3",+ "enzyme": "^3.11.0",+ "enzyme-adapter-preact-pure": "^3.3.0","identity-obj-proxy": "^3.0.0","jest-dev-server": "^6.1.1","jest-environment-jsdom": "^29.0.3",diff --git a/packages/base-render/package.json b/packages/base-render/package.jsonindex 828eecea64..6269c4ed2d 100644--- a/packages/base-render/package.json+++ b/packages/base-render/package.json@@ -5,23 +5,17 @@"keywords": [],"author": "DreamNum <[email protected]>","license": "MIT",- "main": "./lib/univer-base-render.cjs.js",- "module": "./lib/univer-base-render.es.js",- "browser": {- "./lib/univer-base-render.cjs.js": "./src/index.ts",- "./lib/univer-base-render.es.js": "./src/index.ts"- },+ "main": "./src/index.ts",+ "module": "./src/index.ts","types": "./src/Types/index.d.ts","exports": {- ".": {- "import": {- "node": "./lib/univer-base-render.cjs.js",- "default": "./lib/univer-base-render.es.js"- },- "require": "./lib/univer-base-render.cjs.js",- "types": "./lib/univer-base-render.d.ts"- },- "./*": "./src/*"+ ".": "./src/index.ts",+ "./*": "./src/*"+ },+ "publishConfig": {+ "main": "./lib/univer-base-render.umd.js",+ "module": "./lib/univer-base-render.es.js",+ "types": "./lib/univer-base-render.d.ts"},"directories": {"lib": "lib"@@ -30,8 +24,6 @@"test": "jest","dev": "vite","build": "tsc && vite build",- "watch": "vite build",- "link": "pnpm link ./","serve": "vite preview"},"devDependencies": {@@ -40,6 +32,8 @@"@types/jest": "^27.5.2","@types/node": "^16.4.6","@vitejs/plugin-legacy": "^1.5.1",+ "enzyme": "^3.11.0",+ "enzyme-adapter-preact-pure": "^3.3.0","identity-obj-proxy": "^3.0.0","jest-dev-server": "^6.1.1","jest-environment-jsdom": "^29.0.3",diff --git a/packages/base-sheets/package.json b/packages/base-sheets/package.jsonindex f30f20fa28..be640a6afa 100644--- a/packages/base-sheets/package.json+++ b/packages/base-sheets/package.json@@ -5,23 +5,17 @@"keywords": [],"author": "DreamNum <[email protected]>","license": "MIT",- "main": "./lib/univer-base-sheets.cjs.js",- "module": "./lib/univer-base-sheets.es.js",- "browser": {- "./lib/univer-base-sheets.cjs.js": "./src/index.ts",- "./lib/univer-base-sheets.es.js": "./src/index.ts"- },+ "main": "./src/index.ts",+ "module": "./src/index.ts","types": "./src/Types/index.d.ts","exports": {- ".": {- "import": {- "node": "./lib/univer-base-sheets.cjs.js",- "default": "./lib/univer-base-sheets.es.js"- },- "require": "./lib/univer-base-sheets.cjs.js",- "types": "./lib/univer-base-sheets.d.ts"- },- "./*": "./src/*"+ ".": "./src/index.ts",+ "./*": "./src/*"+ },+ "publishConfig": {+ "main": "./lib/univer-base-sheets.umd.js",+ "module": "./lib/univer-base-sheets.es.js",+ "types": "./lib/univer-base-sheets.d.ts"},"directories": {"lib": "lib"@@ -32,8 +26,6 @@"test:debug": "PWDEBUG=1 npx playwright test","dev": "vite","build": "tsc && vite build",- "watch": "vite build",- "link": "pnpm link ./","serve": "vite preview"},"devDependencies": {@@ -42,6 +34,8 @@"@types/jest": "^27.5.2","@types/node": "^16.4.6","@vitejs/plugin-legacy": "^1.5.1",+ "enzyme": "^3.11.0",+ "enzyme-adapter-preact-pure": "^3.3.0","identity-obj-proxy": "^3.0.0","jest-dev-server": "^6.1.1","jest-environment-jsdom": "^29.0.3",@@ -58,7 +52,6 @@"@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/Controller/SideGroupController.ts b/packages/base-sheets/src/Controller/SideGroupController.tsnew file mode 100644index 0000000000..3dffea425e--- /dev/null+++ b/packages/base-sheets/src/Controller/SideGroupController.ts@@ -0,0 +1,80 @@+import { SheetPlugin } from '../SheetPlugin';+import { SideGroup } from '../View/UI/SideGroup/SideGroup';++export interface SideProps {+ name: string;+ zIndex: number;+ show?: boolean;+ onClick: (name: string) => void;+}++export type SideGroupProps = SideProps[];++export class SideGroupController {+ private _SideGroup: SideGroupProps;++ private _SideGroupComponent: SideGroup;++ private _plugin: SheetPlugin;++ constructor(plugin: SheetPlugin) {+ this._plugin = plugin;++ this._SideGroup = [];++ this.init();+ }++ init() {+ this._plugin.getObserver('onSideGroupDidMountObservable')?.add((component) => {+ //初始化视图+ this._SideGroupComponent = component;+ });+ }++ addSide(name: string, component: any) {+ const index = this._SideGroup.findIndex((item) => item.name === name);+ if (index < 0) {+ this._plugin.registerComponent(name, component);+ this._SideGroup.push({+ name,+ zIndex: this._SideGroup.length + 1,+ show: false,+ onClick: this.activeSide,+ });+ }+ }++ removeSide(name: string) {+ const index = this._SideGroup.findIndex((item) => item.name === name);+ if (index > -1) {+ for (let i = index + 1; i < this._SideGroup.length; i++) {+ this._SideGroup[i].zIndex -= 1;+ }+ this._SideGroup.splice(index, 1);+ this._SideGroupComponent.setSideGroup(this._SideGroup);+ }+ }++ activeSide(name: string) {+ const index = this._SideGroup.findIndex((item) => item.name === name);+ if (index > -1) {+ for (let i = index + 1; i < this._SideGroup.length; i++) {+ this._SideGroup[i].zIndex -= 1;+ }+ this._SideGroup[index].zIndex = this._SideGroup.length;+ this._SideGroup[index].show = true;+ this._SideGroup.sort((a, b) => a.zIndex - b.zIndex);++ this._SideGroupComponent.setSideGroup(this._SideGroup);+ }+ }++ hideSide(name: string) {+ const index = this._SideGroup.findIndex((item) => item.name === name);+ if (index > -1) {+ this._SideGroup[index].show = false;+ this._SideGroupComponent.setSideGroup(this._SideGroup);+ }+ }+}diff --git a/packages/base-sheets/src/Controller/ToolBarController.ts b/packages/base-sheets/src/Controller/ToolBarController.tsindex 4fae70ffea..e20857e588 100644--- a/packages/base-sheets/src/Controller/ToolBarController.ts+++ b/packages/base-sheets/src/Controller/ToolBarController.ts@@ -39,6 +39,8 @@ export class ToolBarController {private _toolList: IToolBarItemProps[];+ private _moreText: Record<string, string>;+private _lineColor: LineColor;Render: BaseComponentRender;@@ -210,6 +212,7 @@ export class ToolBarController {display: 1,show: config.border,tooltipLocale: 'toolbar.border.main',+ className: styles.selectDoubleString,onClick: (type) => {// console.dir(type);// console.dir(this._borderInfo);@@ -273,6 +276,7 @@ export class ToolBarController {{type: 3,tooltipLocale: 'toolbar.horizontalAlignMode.main',+ className: styles.selectDoubleString,display: 1,show: config.horizontalAlignMode,onClick: (value: HorizontalAlign) => {@@ -283,6 +287,7 @@ export class ToolBarController {{type: 3,tooltipLocale: 'toolbar.verticalAlignMode.main',+ className: styles.selectDoubleString,display: 1,show: config.verticalAlignMode,onClick: (value: VerticalAlign) => {@@ -292,6 +297,7 @@ export class ToolBarController {},{type: 3,+ className: styles.selectDoubleString,tooltipLocale: 'toolbar.textWrapMode.main',display: 1,show: config.textWrapMode,@@ -302,6 +308,7 @@ export class ToolBarController {},{type: 3,+ className: styles.selectDoubleString,tooltipLocale: 'toolbar.textRotateMode.main',display: 1,show: config.textRotateMode,@@ -312,6 +319,8 @@ export class ToolBarController {},];+ this._moreText = { more: 'toolbar.toolMore', tip: 'toolbar.toolMoreTip' };+this._toolBarModel = new ToolBarModel();this._toolBarModel.config = config;this._toolBarModel.toolList = this._toolList;@@ -500,8 +509,13 @@ export class ToolBarController {}resetToolBarList() {+ const locale = this._plugin.context.getLocale();+const toolList = this.resetLocale(this._toolList);- this._toolBarComponent.setToolBar(toolList);+ this._toolBarComponent.setToolBar(toolList, {+ more: locale.get(this._moreText.more),+ tip: locale.get(this._moreText.tip),+ });}setRedo() {diff --git a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsxindex e0afaf9129..47d9b0b925 100644--- a/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx+++ b/packages/base-sheets/src/View/UI/SheetContainer/SheetContainer.tsx@@ -39,6 +39,7 @@ import { IShowToolBarConfig } from '../../../Model/ToolBarModel';import { ModalGroup } from '../ModalGroup/ModalGroup';import { SheetPlugin } from '../../../SheetPlugin';import { FormulaBar } from '../FormulaBar';+import { SideGroup } from '../SideGroup/SideGroup';export interface ILayout {outerLeft?: boolean;@@ -743,6 +744,7 @@ export class SheetContainer extends Component<BaseSheetContainerProps, IState> {}}>{/* innerRight */}+ <SideGroup></SideGroup></Sider></Layout><Footerdiff --git a/packages/base-sheets/src/View/UI/SideGroup/SideGroup.tsx b/packages/base-sheets/src/View/UI/SideGroup/SideGroup.tsxnew file mode 100644index 0000000000..9290ab9a27--- /dev/null+++ b/packages/base-sheets/src/View/UI/SideGroup/SideGroup.tsx@@ -0,0 +1,58 @@+import { Component } from '@univer/base-component';+import { PLUGIN_NAMES } from '@univer/core';+import { SideProps } from '../../../Controller/SideGroupController';+import { SheetPlugin } from '../../../SheetPlugin';++interface IState {+ sideGroup: any[];+}++interface SideRenderProps extends SideProps {+ side?: any;+}++export class SideGroup extends Component<any, IState> {+ initialize() {+ this.state = {+ sideGroup: [],+ };+ }++ componentDidMount(): void {+ this._context.getObserverManager().getObserver<SideGroup>('onSideGroupDidMountObservable')?.notifyObservers(this);+ }++ setSideGroup(group: SideRenderProps[]) {+ const plugin = this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);++ const sideGroup = group.map((item) => {+ const Side = plugin?.getRegisterComponent(item.name);+ if (Side) {+ item.side = <Side></Side>;+ }+ return item;+ });++ this.setState({+ sideGroup,+ });+ }++ render() {+ const { sideGroup } = this.state;+ return (+ <div>+ {sideGroup.map((item) => {+ if (item.show) {+ return (+ <div onClick={() => item.onClick(item.name)} style={{ zIndex: item.zIndex }}>+ {item.side}+ </div>+ );+ }+ return <></>;+ })}+ </div>+ );+ }+}diff --git a/packages/base-sheets/src/View/UI/SideGroup/index.module.less b/packages/base-sheets/src/View/UI/SideGroup/index.module.lessnew file mode 100644index 0000000000..e69de29bb2diff --git a/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsx b/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsxindex 4e9f975b71..0c43fabb46 100644--- a/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsx+++ b/packages/base-sheets/src/View/UI/ToolBar/ToolBar.tsx@@ -1,4 +1,4 @@-import { BaseComponentProps, BaseComponentRender, BaseComponentSheet, Component, createRef } from '@univer/base-component';+import { BaseComponentProps, BaseComponentRender, BaseComponentSheet, Component, createRef, debounce } from '@univer/base-component';import { PLUGIN_NAMES } from '@univer/core';import { IToolBarItemProps } from '../../../Model/ToolBarModel';import { SheetPlugin } from '../../../SheetPlugin';@@ -9,25 +9,21 @@ 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;+ showMore: boolean;toolbarListWidths: number[];- moreText: string;+ moreText: Record<string, string>;}export class ToolBar extends Component<IProps, IState> {- toolbarWarp = createRef();-toolbarRef = createRef();- moreBtn = createRef();+ moreBtnRef = createRef();moreToolRef = createRef();@@ -35,19 +31,20 @@ export class ToolBar extends Component<IProps, IState> {Render: BaseComponentRender;- initialize(props: IProps) {+ clientWidth = 0;++ initialize() {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,+ showMore: false,toolList: [],defaultToolList: [],moreToolList: [],- index: 0,toolbarListWidths: [],- moreText: '',+ moreText: {},};}@@ -56,11 +53,11 @@ export class ToolBar extends Component<IProps, IState> {** TODO : 点击其他地方需要隐藏more buttons*/- moreTool = () => {- let more = this.state.more;- this.setState({ more: !more });+ showMore = () => {+ let showMore = this.state.showMore;+ this.setState({ showMore: !showMore });- if (!more) {+ if (!showMore) {document.addEventListener('click', this.hide, true);}};@@ -68,40 +65,89 @@ export class ToolBar extends Component<IProps, IState> {hide = (e: Event) => {if (this.moreToolRef.current.contains(e.target)) return;e.stopImmediatePropagation();- this.setState({ more: false });+ this.setState({ showMore: false });document.removeEventListener('click', this.hide, true);};/*** Gets the distance of each button from the parent element*/+ debounceSetToolbarListWidth = debounce(() => {+ this.setToolbarListWidth();+ }, 50);+setToolbarListWidth = () => {- const toolbar = this.toolbarWarp.current.querySelector(`.${styles.toolbar}`);- const toolbarLeft = toolbar.getBoundingClientRect().left;- const toolbarListWidths: number[] = []; // 每个 btn 离父元素 left 距离- const toolbarListWidths1: number[] = []; // 每个 btn 离父元素 left 距离+ if (!this.clientWidth) {+ this.clientWidth = document.documentElement.clientWidth;+ }+ const list = this.toolbarRef.current.querySelectorAll(`.${styles.toolbarWarp} > div`);+ const moreButtonWidth = this.moreBtnRef.current.clientWidth;+ let width = 60 + moreButtonWidth;+ let index = null;- 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++;+ const clientWidth = document.documentElement.clientWidth;+ if (clientWidth <= this.clientWidth) {+ // 向左resize+ this.clientWidth = clientWidth;+ for (let i = 0; i < list.length; i++) {+ width += list[i].clientWidth + 6;++ if (width > clientWidth) {+ index = i;+ break;+ }}- toolbarListWidths1.push(next + max);- return next + max;- });+ if (index !== null) {+ this.setState(+ {+ defaultToolList: this.state.toolList.slice(0, index),+ moreToolList: index ? this.state.toolList.slice(index) : [],+ },+ () => {+ this.resetUl();+ this.forceUpdate();+ }+ );+ }+ } else {+ // 向右resize+ this.clientWidth = clientWidth;+ if (this.state.moreToolList.length) {+ let toolWidth = 30 + moreButtonWidth;+ for (let i = 0; i < list.length; i++) {+ toolWidth += list[i].clientWidth + 6;+ }- this.setState(- () => ({- toolbarListWidths: toolbarListWidths1,- }),- this.resetToolbar- );+ const moreList = this.moreToolRef.current.querySelectorAll(`.${styles.moreTool} > div`);+ let moreIndex = null;+ let last = false; //最后一个元素++ for (let i = 0; i < moreList.length; i++) {+ toolWidth += moreList[i].clientWidth + 6;++ if (toolWidth > clientWidth) {+ moreIndex = i;+ break;+ } else if (i === moreList.length - 1) {+ moreIndex = i;+ last = true;+ }+ }++ if (moreIndex !== null) {+ this.setState(+ {+ defaultToolList: this.state.defaultToolList.concat(this.state.moreToolList.slice(0, last ? moreIndex + 1 : moreIndex)),+ moreToolList: last ? [] : this.state.moreToolList.slice(moreIndex),+ },+ () => {+ this.resetUl();+ this.forceUpdate();+ }+ );+ }+ }+ }};resetLabel = (toolList: any[]) => {@@ -134,75 +180,73 @@ export class ToolBar extends Component<IProps, IState> {return toolList;};- setToolBar = (toolList: any[]) => {+ setToolBar = (toolList: any[], moreText: Record<string, string>) => {toolList = this.resetLabel(toolList);this.setState({toolList,+ defaultToolList: toolList,+ moreText,},() => {- this.resetToolbar();+ this.setToolbarListWidth();});};- 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<SheetPlugin>(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;- }- }- );+ resetUl = () => {+ const wrapper = this._context.getPluginManager().getPluginByName<SheetPlugin>(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<ToolBar>('onToolBarDidMountObservable')?.notifyObservers(this);+ window.addEventListener('resize', this.debounceSetToolbarListWidth);+ }++ componentWillUnmount() {+ window.removeEventListener('resize', this.debounceSetToolbarListWidth);}- render(props: IProps, state: IState) {- const { defaultToolList } = state;+ // 渲染dom+ getToolBarList(list: IToolBarItemProps[]) {+ const Tooltip = this.Render.renderFunction('Tooltip');++ return list.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}+ className={item.className}+ ></Select>+ </Tooltip>+ );+ });+ }++ render() {+ const { defaultToolList, moreToolList, moreText, showMore } = this.state;const Button = this.Render.renderFunction('Button');const Container = this.Render.renderFunction('Container');@@ -210,47 +254,25 @@ export class ToolBar extends Component<IProps, IState> {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}- customLabel={item.customLabel}- customSuffix={item.customSuffix}- label={item.label}- onClick={item.onClick}- onKeyUp={item.onKeyUp}- defaultColor={item.defaultColor}- hideSelectedIcon={item.hideSelectedIcon}- className={item.className}- ></Select>- </Tooltip>- );- })}+ <div className={`${styles.toolbarWarp} ${styles.toolbar}`} ref={this.toolbarRef}>+ {this.getToolBarList(defaultToolList)}++ <div ref={this.moreBtnRef} className={styles.moreButton} style={{ visibility: moreToolList.length ? 'visible' : 'hidden' }}>+ <Tooltip title={moreText.tip} placement={'bottom'}>+ <Button type="text" onClick={this.showMore}>+ <div style={{ fontSize: '14px' }}>{moreText.more}</div>+ </Button>+ </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>+ {moreToolList.length ? (+ <div style={{ visibility: showMore ? 'visible' : 'hidden' }} className={`${styles.moreTool} ${styles.toolbar}`} ref={this.moreToolRef}>+ {this.getToolBarList(moreToolList)}+ </div>+ ) : (+ ''+ )}</Container>);}diff --git a/packages/base-sheets/src/View/UI/ToolBar/index.module.css b/packages/base-sheets/src/View/UI/ToolBar/index.module.cssnew file mode 100644index 0000000000..275fb32dfd--- /dev/null+++ b/packages/base-sheets/src/View/UI/ToolBar/index.module.css@@ -0,0 +1,95 @@+.toolbar-warp {+ max-height: fit-content;+ width: 100%;+ overflow: unset;+ box-sizing: border-box;+ font-size: var(--font-size);+ background-color: var(--bg);+ position: relative;+ display: flex;+ align-items: center;+ border-bottom: 1px solid var(--border-color-base);+}+.toolbar-warp .single-button.more-hide {+ display: none;+}+.toolbar-warp .single-button.more-show {+ display: block;+}+.toolbar {+ max-width: 100%;+ color: var(--text-color);+ padding: 0 15px;+ height: 40px;+ position: relative;+ display: flex;+ align-items: center;+}+.toolbar > div {+ height: 26px;+ display: inline-block;+ vertical-align: middle;+ margin: 0 3px;+ cursor: pointer;+}+.toolbar > div.select-button:hover {+ background-color: #efefef;+}+.toolbar .cols-menu {+ overflow-y: auto;+}+.toolbar .select-label-string .drop-content > div {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ width: 90px;+}+.toolbar .select-color-picker-parent .select-item-content {+ width: 100%;+}+.toolbar .select-color-picker-parent ul {+ padding: 0;+}+.toolbar .select-color-picker-parent .select-color-picker {+ padding: 0;+}+.toolbar .select-color-picker-parent .select-color-picker .select-item {+ padding: 0;+}+.toolbar button {+ padding: 0;+ height: 26px;+}+.more-button {+ height: 35px;+ margin: 5px;+ display: none;+ padding: 0px;+ line-height: 1;+}+.more-button.more-show {+ display: block;+}+.more-tool {+ height: 40px;+ display: none;+ align-items: center;+ padding: 0 10px;+ background-color: var(--bg);+ box-shadow: var(--box-shadow-base);+ position: absolute;+ right: 2em;+ top: 40px;+ z-index: 100;+}+.more-tool.more-show {+ display: flex;+}+.more-tool button {+ padding: 0px;+ line-height: 1;+ font-size: 24px;+}+span[role='img'].univericon-nextIcon {+ font-size: 12px;+}diff --git a/packages/base-sheets/src/View/UI/ToolBar/index.module.less b/packages/base-sheets/src/View/UI/ToolBar/index.module.lessindex 4d40cd3f93..f87068c887 100644--- a/packages/base-sheets/src/View/UI/ToolBar/index.module.less+++ b/packages/base-sheets/src/View/UI/ToolBar/index.module.less@@ -30,12 +30,13 @@display: flex;align-items: center;- > div {+ >div {height: 26px;display: inline-block;vertical-align: middle;margin: 0 3px;cursor: pointer;+&.select-button:hover {background-color: #efefef;}@@ -47,7 +48,7 @@.select-label-string {.drop-content {- > div {+ >div {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;@@ -56,6 +57,14 @@}}+ .select-double-string {+ .drop-content {+ >div {+ // width: 26px;+ }+ }+ }+.select-color-picker-parent {.select-item-content {width: 100%;@@ -120,4 +129,4 @@span[role='img'].univericon-nextIcon {font-size: 12px;-}+}\ No newline at end of filediff --git a/packages/common-plugin-data/package.json b/packages/common-plugin-data/package.jsonindex 011937c096..715fd4a30e 100644--- a/packages/common-plugin-data/package.json+++ b/packages/common-plugin-data/package.json@@ -3,28 +3,17 @@"version": "0.0.1","description": "","author": "",- "main": "./lib/univer-common-plugin-data.cjs.js",- "module": "./lib/univer-common-plugin-data.es.js",- "browser": {- "./lib/univer-common-plugin-data.cjs.js": "./src/index.ts",- "./lib/univer-common-plugin-data.es.js": "./src/index.ts"- },- "types": "./src/Types/index.d.ts",+ "main": "./src/index.ts",+ "module": "./src/index.ts",+ "types": "./src/type.d.ts","publishConfig": {- "main": "./lib/univer-common-plugin-data.cjs.js",- "module": "./lib/univer-common-plugin-data.es.js",- "types": "./lib/univer-common-plugin-data.d.ts"+ "main": "./lib/index.umd.js",+ "module": "./lib/index.es.js",+ "types": "./lib/index.d.ts"},"exports": {- ".": {- "import": {- "node": "./lib/univer-common-plugin-data.cjs.js",- "default": "./lib/univer-common-plugin-data.es.js"- },- "require": "./lib/univer-common-plugin-data.cjs.js",- "types": "./lib/univer-common-plugin-data.d.ts"- },- "./*": "./src/*"+ ".": "./src/index.ts",+ "./*": "./src/*"},"directories": {"lib": "lib"@@ -37,8 +26,6 @@"test": "cross-env NODE_ENV=--experimental-vm-modules jest","dev": "vite","build": "tsc && vite build",- "watch": "vite build",- "link": "pnpm link ./","serve": "vite preview"},"license": "MIT",diff --git a/packages/core/package.json b/packages/core/package.jsonindex a9ba49f331..a5740ffa77 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -3,23 +3,17 @@"version": "0.0.1","description": "","author": "",- "main": "./lib/univer-core.js",- "module": "./lib/univer-core.mjs",- "browser": {- "./lib/univer-core.js": "./src/index.ts",- "./lib/univer-core.mjs": "./src/index.ts"+ "main": "./src/index.ts",+ "module": "./src/index.ts",+ "types": "./src/type.d.ts",+ "publishConfig": {+ "main": "./lib/index.umd.js",+ "module": "./lib/index.es.js",+ "types": "./dist/core.d.ts"},- "types": "./src/Types/index.d.ts","exports": {- ".": {- "import": {- "node": "./lib/univer-core.js",- "default": "./lib/univer-core.mjs"- },- "require": "./lib/univer-core.js",- "types": "./lib/univer-core.d.ts"- },- "./*": "./src/*"+ ".": "./src/index.ts",+ "./*": "./src/*"},"files": ["lib"@@ -31,8 +25,6 @@"test": "cross-env NODE_ENV=--experimental-vm-modules jest --config=jest.config.js","dev": "vite","build": "tsc && vite build",- "watch": "vite build",- "link": "pnpm link ./","api": "node ./api.js","tsc": "tsc","serve": "node test/Server/server.js"diff --git a/packages/style-universheet/package.json b/packages/style-universheet/package.jsonindex 5b12ff42ea..07b8c5b3a7 100644--- a/packages/style-universheet/package.json+++ b/packages/style-universheet/package.json@@ -5,23 +5,17 @@"keywords": [],"author": "DreamNum <[email protected]>","license": "MIT",- "main": "./lib/univer-style-univer.cjs.js",- "module": "./lib/univer-style-univer.es.js",- "browser": {- "./lib/univer-style-univer.cjs.js": "./src/index.ts",- "./lib/univer-style-univer.es.js": "./src/index.ts"- },- "types": "./src/Types/index.d.ts",+ "main": "./src/index.ts",+ "module": "./src/index.ts",+ "types": "./src/index.d.ts","exports": {- ".": {- "import": {- "node": "./lib/univer-style-univer.cjs.js",- "default": "./lib/univer-style-univer.es.js"- },- "require": "./lib/univer-style-univer.cjs.js",- "types": "./lib/univer-style-univer.d.ts"- },- "./*": "./src/*"+ ".": "./src/index.ts",+ "./*": "./src/*"+ },+ "publishConfig": {+ "main": "./lib/univer-style-univer.umd.js",+ "module": "./lib/univer-style-univer.es.js",+ "types": "./lib/univer-style-univer.d.ts"},"directories": {"lib": "lib"@@ -31,8 +25,6 @@"test:cover": "cross-env NODE_ENV=--experimental-vm-modules jest --coverage","dev": "vite","build": "tsc && vite build",- "watch": "vite build",- "link": "pnpm link ./","serve": "vite preview"},"devDependencies": {diff --git a/packages/style-universheet/src/Components/Dropdown/index.module.css b/packages/style-universheet/src/Components/Dropdown/index.module.cssnew file mode 100644index 0000000000..c755a0430e--- /dev/null+++ b/packages/style-universheet/src/Components/Dropdown/index.module.css@@ -0,0 +1,21 @@+/*+1. 所有的变量加到这里,复用+2. 组件要用的话,在这定义好,导入组件使用+3. 需要作为皮肤变量的,导入到所有皮肤中导出使用+*/+.dropdown {+ padding: 0px 5px;+ position: relative;+ display: flex;+ align-items: center;+}+.dropdown .drop-content {+ display: flex;+ justify-content: space-between;+ align-items: center;+}+.dropdown .drop-icon {+ height: 100%;+ margin-left: 5px;+ border-left: 1px solid #efefef;+}diff --git a/packages/style-universheet/src/Components/Dropdown/index.module.less b/packages/style-universheet/src/Components/Dropdown/index.module.lessindex 445e243f2c..c798035145 100644--- a/packages/style-universheet/src/Components/Dropdown/index.module.less+++ b/packages/style-universheet/src/Components/Dropdown/index.module.less@@ -6,6 +6,7 @@display: flex;align-items: center;+.drop-content {display: flex;justify-content: space-between;@@ -17,4 +18,5 @@margin-left: 5px;border-left: 1px solid @gray-14;}+}\ No newline at end of file