Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
xiugai
tonytonychopper12308ddd57557b4
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsxindex ccac81519e..b9e26aea99 100644--- a/examples/univer-sheet-ts/src/main.tsx+++ b/examples/univer-sheet-ts/src/main.tsx@@ -78,7 +78,7 @@ universheet.installPlugin(},}));-FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO1).installTo(universheet);+// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO1).installTo(universheet);// universheet.installPlugin(new FormulaPlugin(DEFAULT_FORMULA_DATA_DEMO));// // ui TODO: 不要安装diff --git a/packages/base-sheets/src/Controller/SheetBarController.ts b/packages/base-sheets/src/Controller/SheetBarController.tsindex f2a4f166fb..71c52efa0b 100644--- a/packages/base-sheets/src/Controller/SheetBarController.ts+++ b/packages/base-sheets/src/Controller/SheetBarController.ts@@ -317,12 +317,12 @@ class SheetBarUIController {* 选中sheet* @param args*/- selectSheet() {}+ selectSheet() { }/*** 删除sheet*/- deleteSheet() {}+ deleteSheet() { }/*** 排序menu list@@ -330,12 +330,12 @@ class SheetBarUIController {* @param hidden* @param hideIndex*/- sortMenu(index: number, hidden?: boolean, hideIndex?: number) {}+ sortMenu(index: number, hidden?: boolean, hideIndex?: number) { }/*** 复制sheet*/- copySheet() {}+ copySheet() { }/*** 增加sheet@@ -358,7 +358,7 @@ class SheetBarUIController {/*** 隐藏sheet*/- hideSheet() {}+ hideSheet() { }/*** 取消隐藏sheet@@ -371,13 +371,13 @@ class SheetBarUIController {* 向左向右移动sheet* @param direct*/- moveSheet(direct: string) {}+ moveSheet(direct: string) { }/*** 重命名sheet* @param e*/- changeSheetName(e: Event) {}+ changeSheetName(e: Event) { }/*** 右击显示菜单diff --git a/packages/base-sheets/src/Controller/ToolBarController.ts b/packages/base-sheets/src/Controller/ToolBarController.tsindex 483adb692f..f2ca43067e 100644--- a/packages/base-sheets/src/Controller/ToolBarController.ts+++ b/packages/base-sheets/src/Controller/ToolBarController.ts@@ -1,4 +1,4 @@-import { Range, HorizontalAlign, VerticalAlign, WrapStrategy, BorderType } from '@univerjs/core';+import { Range, HorizontalAlign, VerticalAlign, WrapStrategy, BorderType, UIObserver } from '@univerjs/core';import { SheetPlugin } from '../SheetPlugin';import { SelectionControl } from './Selection/SelectionController';@@ -34,64 +34,53 @@ export class ToolbarController {const verticalAlign = range.getVerticalAlignment();const rotation = range.getTextRotation();- // console.log('cellMatrix:', cellMatrix);- // console.log('fontSize:', fontSize);- // console.log('horizontalAlign:', horizontalAlign);- // console.log('fontName:', fontName);- // console.log('verticalAlign:', verticalAlign);- // console.log('fontItalic:', fontItalic);- // console.log('fontWeight:', fontWeight);- // console.log('strikeThrough:', strikeThrough);-- const textRotateModeItem = this._toolList.find((item) => item.name === 'textRotateMode');- const fontSizeItem = this._toolList.find((item) => item.name === 'fontSize');- const fontNameItem = this._toolList.find((item) => item.name === 'font');- const fontBoldItem = this._toolList.find((item) => item.name === 'bold');- const fontItalicItem = this._toolList.find((item) => item.name === 'italic');- const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');- const underlineItem = this._toolList.find((item) => item.name === 'underline');- const horizontalAlignModeItem = this._toolList.find((item) => item.name === 'horizontalAlignMode');- const verticalAlignModeItem = this._toolList.find((item) => item.name === 'verticalAlignMode');-- if (strikethroughItem) {- strikethroughItem.active = !!(strikeThrough && strikeThrough.s);- }- if (fontNameItem) {- fontNameItem.children?.forEach((item) => {- item.selected = fontName === item.value;- });- }- if (fontSizeItem) {- fontSizeItem.children?.forEach((item) => {- item.selected = fontSize === item.value;- });- }- if (fontBoldItem) {- fontBoldItem.active = !!fontWeight;- }- if (fontItalicItem) {- fontItalicItem.active = !!fontItalic;- }- if (underlineItem) {- underlineItem.active = !!(underline && underline.s);- }- if (horizontalAlignModeItem) {- horizontalAlignModeItem.children?.forEach((item) => {- item.selected = horizontalAlign === item.value;- });- }- if (textRotateModeItem) {- textRotateModeItem.children?.forEach((item) => {- item.selected = rotation === item.value;- });- }- if (verticalAlignModeItem) {- verticalAlignModeItem.children?.forEach((item) => {- item.selected = verticalAlign === item.value;- });- }-- this.resetToolbarList();+ // const textRotateModeItem = this._toolList.find((item) => item.name === 'textRotateMode');+ // const fontSizeItem = this._toolList.find((item) => item.name === 'fontSize');+ // const fontNameItem = this._toolList.find((item) => item.name === 'font');+ // const fontBoldItem = this._toolList.find((item) => item.name === 'bold');+ // const fontItalicItem = this._toolList.find((item) => item.name === 'italic');+ // const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');+ // const underlineItem = this._toolList.find((item) => item.name === 'underline');+ // const horizontalAlignModeItem = this._toolList.find((item) => item.name === 'horizontalAlignMode');+ // const verticalAlignModeItem = this._toolList.find((item) => item.name === 'verticalAlignMode');++ // if (strikethroughItem) {+ // strikethroughItem.active = !!(strikeThrough && strikeThrough.s);+ // }+ // if (fontNameItem) {+ // fontNameItem.children?.forEach((item) => {+ // item.selected = fontName === item.value;+ // });+ // }+ // if (fontSizeItem) {+ // fontSizeItem.children?.forEach((item) => {+ // item.selected = fontSize === item.value;+ // });+ // }+ // if (fontBoldItem) {+ // fontBoldItem.active = !!fontWeight;+ // }+ // if (fontItalicItem) {+ // fontItalicItem.active = !!fontItalic;+ // }+ // if (underlineItem) {+ // underlineItem.active = !!(underline && underline.s);+ // }+ // if (horizontalAlignModeItem) {+ // horizontalAlignModeItem.children?.forEach((item) => {+ // item.selected = horizontalAlign === item.value;+ // });+ // }+ // if (textRotateModeItem) {+ // textRotateModeItem.children?.forEach((item) => {+ // item.selected = rotation === item.value;+ // });+ // }+ // if (verticalAlignModeItem) {+ // verticalAlignModeItem.children?.forEach((item) => {+ // item.selected = verticalAlign === item.value;+ // });+ // }}}@@ -101,97 +90,114 @@ export class ToolbarController {this._initialize();}+ listenEventManager() {+ this._plugin+ .getContext()+ .getUniver()+ .getGlobalContext()+ .getObserverManager()+ .requiredObserver<UIObserver<number>>('onUIChangeObservable', 'core')+ .add((msg) => {+ switch (msg.name) {+ case 'fontSize':+ this.setFontSize(msg.value!);+ break;+ }+ });++ this._plugin+ .getContext()+ .getUniver()+ .getGlobalContext()+ .getObserverManager()+ .requiredObserver<UIObserver<boolean>>('onUIChangeObservable', 'core')+ .add((msg) => {+ console.dir(msg);+ switch (msg.name) {+ case 'fontWeight':+ this.setFontWeight(msg.value!);+ break;+ }+ });+ }+_initialize() {- this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.add((value: string) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setFontFamily(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('ff', value);- }- });- this._plugin.getObserver('onAfterChangeFontSizeObservable')?.add((value: number) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setFontSize(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('fs', value);- }- });- this._plugin.getObserver('onAfterChangeFontWeightObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setFontWeight(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('bl', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontItalicObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setFontStyle(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('it', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setStrikeThrough(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('cl', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.add((value: boolean) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setUnderline(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('un', value ? '1' : '0');- }- });- this._plugin.getObserver('onAfterChangeFontColorObservable')?.add((value: string) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setFontColor(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('fc', value);- }- });- this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.add((value: string) => {- if (!this._plugin.getCellEditorController().isEditMode) {- this.setBackground(value);- } else {- this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('bg', value);- }- });- // Monitor selection changes, update toolbar button status and values TODO: 根据不同的焦点对象,接受- this._plugin.getObserver('onChangeSelectionObserver')?.add((selectionControl: SelectionControl) => {- // const currentCell = selectionControl.model.currentCell;- //- // if (currentCell) {- // let currentRangeData;- //- // if (currentCell.isMerged) {- // const mergeInfo = currentCell.mergeInfo;- //- // currentRangeData = {- // startRow: mergeInfo.startRow,- // endRow: mergeInfo.endRow,- // startColumn: mergeInfo.startColumn,- // endColumn: mergeInfo.endColumn,- // };- // } else {- // const { row, column } = currentCell;- // currentRangeData = {- // startRow: row,- // endRow: row,- // startColumn: column,- // endColumn: column,- // };- // }- //- // const cellData = this._plugin.getWorkbook().getActiveSheet().getRange(currentRangeData).getObjectValue({ isIncludeStyle: true });- // }- const manager = this._plugin.getSelectionManager();- const range = manager?.getCurrentCell();- if (range) {- this._changeToolbarState(range);- }- });+ // this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.add((value: string) => {+ // if (!this._plugin.getCellEditorController().isEditMode) {+ // this.setFontFamily(value);+ // } else {+ // this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('ff', value);+ // }+ // });+ // this._plugin.getObserver('onAfterChangeFontItalicObservable')?.add((value: boolean) => {+ // if (!this._plugin.getCellEditorController().isEditMode) {+ // this.setFontStyle(value);+ // } else {+ // this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('it', value ? '1' : '0');+ // }+ // });+ // this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.add((value: boolean) => {+ // if (!this._plugin.getCellEditorController().isEditMode) {+ // this.setStrikeThrough(value);+ // } else {+ // this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('cl', value ? '1' : '0');+ // }+ // });+ // this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.add((value: boolean) => {+ // if (!this._plugin.getCellEditorController().isEditMode) {+ // this.setUnderline(value);+ // } else {+ // this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('un', value ? '1' : '0');+ // }+ // });+ // this._plugin.getObserver('onAfterChangeFontColorObservable')?.add((value: string) => {+ // if (!this._plugin.getCellEditorController().isEditMode) {+ // this.setFontColor(value);+ // } else {+ // this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('fc', value);+ // }+ // });+ // this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.add((value: string) => {+ // if (!this._plugin.getCellEditorController().isEditMode) {+ // this.setBackground(value);+ // } else {+ // this._plugin.getCellEditorController().richText.cellTextStyle.updateFormat('bg', value);+ // }+ // });+ // // Monitor selection changes, update toolbar button status and values TODO: 根据不同的焦点对象,接受+ // this._plugin.getObserver('onChangeSelectionObserver')?.add((selectionControl: SelectionControl) => {+ // // const currentCell = selectionControl.model.currentCell;+ // //+ // // if (currentCell) {+ // // let currentRangeData;+ // //+ // // if (currentCell.isMerged) {+ // // const mergeInfo = currentCell.mergeInfo;+ // //+ // // currentRangeData = {+ // // startRow: mergeInfo.startRow,+ // // endRow: mergeInfo.endRow,+ // // startColumn: mergeInfo.startColumn,+ // // endColumn: mergeInfo.endColumn,+ // // };+ // // } else {+ // // const { row, column } = currentCell;+ // // currentRangeData = {+ // // startRow: row,+ // // endRow: row,+ // // startColumn: column,+ // // endColumn: column,+ // // };+ // // }+ // //+ // // const cellData = this._plugin.getWorkbook().getActiveSheet().getRange(currentRangeData).getObjectValue({ isIncludeStyle: true });+ // // }+ // const manager = this._plugin.getSelectionManager();+ // const range = manager?.getCurrentCell();+ // if (range) {+ // this._changeToolbarState(range);+ // }+ // });}setRedo() {diff --git a/packages/base-sheets/src/SheetPlugin.tsx b/packages/base-sheets/src/SheetPlugin.tssimilarity index 78%rename from packages/base-sheets/src/SheetPlugin.tsxrename to packages/base-sheets/src/SheetPlugin.tsindex 7c338cf93b..55ec159654 100644--- a/packages/base-sheets/src/SheetPlugin.tsx+++ b/packages/base-sheets/src/SheetPlugin.ts@@ -1,14 +1,11 @@import { Engine, RenderEngine } from '@univerjs/base-render';-import { SheetContext, Plugin, PLUGIN_NAMES, UIObserver } from '@univerjs/core';+import { SheetContext, Plugin, PLUGIN_NAMES } from '@univerjs/core';import { SheetPluginObserve, uninstall } from './Basics/Observer';-import { RightMenuProps } from './Model/RightMenuModel';import { en, zh } from './Locale';import { CANVAS_VIEW_KEY } from './View/Render/BaseView';import { CanvasView } from './View/Render/CanvasView';import { RightMenuController, InfoBarController, SheetBarControl, CellEditorController, SheetContainerController, ToolbarController } from './Controller';-import { IToolbarItemProps } from './Model/ToolbarModel';-import { ModalGroupController } from './Controller/ModalGroupController';import { install, ISheetPluginConfig } from './Basics';import { FormulaBarController } from './Controller/FormulaBarController';import { NamedRangeActionExtensionFactory } from './Basics/Register/NamedRangeActionExtension';@@ -38,10 +35,6 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {private _sheetContainerController: SheetContainerController;- private _modalGroupController: ModalGroupController;-- private _componentList: Map<string, any>;-private _namedRangeActionExtensionFactory: NamedRangeActionExtensionFactory;// private _component: BaseComponentPlugin;@@ -81,6 +74,7 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {this._cellEditorController = new CellEditorController(this);this._formulaBarController = new FormulaBarController(this);this._sheetBarControl = new SheetBarControl(this);+ this._toolbarControl = new ToolbarController(this);}initCanvasView() {@@ -114,14 +108,7 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {listenEventManager() {// TODO: move to toolbarcontrollerthis._sheetBarControl.listenEventManager();- this.getContext()- .getUniver()- .getGlobalContext()- .getObserverManager()- .requiredObserver<UIObserver<boolean>>('onUIChangeObservable', 'core')- .add((msg) => {- console.log('get click event mas:', msg);- });+ this._toolbarControl.listenEventManager();}getCanvasEngine() {@@ -200,31 +187,7 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {return this._formulaBarController;}- getModalGroupControl() {- return this._modalGroupController;- }-getSheetContainerControl() {return this._sheetContainerController;}-- addRightMenu(item: RightMenuProps[] | RightMenuProps) {- this._rightMenuControl && this._rightMenuControl.addItem(item);- }-- addToolButton(config: IToolbarItemProps) {- this._toolbarControl && this._toolbarControl.addToolButton(config);- }-- registerComponent(name: string, component: any, props?: any) {- this._componentList.set(name, component);- }-- getRegisterComponent(name: string) {- return this._componentList.get(name);- }-- registerModal(name: string, component: any) {- this._modalGroupController.addModal(name, component);- }}diff --git a/packages/base-sheets/src/View/Render/index.ts b/packages/base-sheets/src/View/Render/index.tsindex 5bc2a7586f..9089079cee 100644--- a/packages/base-sheets/src/View/Render/index.ts+++ b/packages/base-sheets/src/View/Render/index.ts@@ -1,3 +1,2 @@export * from './BaseView';export * from './CanvasView';-export * from './Views';diff --git a/packages/base-sheets/src/View/UI/ModalGroup/ModalGroup.tsx b/packages/base-sheets/src/View/UI/ModalGroup/ModalGroup.tsxdeleted file mode 100644index 2ae8c59c7b..0000000000--- a/packages/base-sheets/src/View/UI/ModalGroup/ModalGroup.tsx+++ /dev/null@@ -1,47 +0,0 @@-import { Component } from '@univerjs/base-ui';-import { PLUGIN_NAMES } from '@univerjs/core';-import { ModalGroupProps } from '../../../Controller/ModalGroupController';-import { SheetPlugin } from '../../../SheetPlugin';--interface IState {- modalGroup: any[];-}--export class ModalGroup extends Component<any, IState> {- refs: any[] = [];-- initialize() {- this.state = {- modalGroup: [],- };- }-- componentDidMount(): void {- this._context.getObserverManager().getObserver<ModalGroup>('onModalGroupDidMountObservable')?.notifyObservers(this);- }-- setModalGroup(group: ModalGroupProps) {- const plugin = this._context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);-- const modalGroup = group.map((item, index) => {- const Modal = plugin?.getRegisterComponent(item);- if (Modal) {- return <Modal ref={(ele: any) => (this.refs[index] = ele)} />;- }- return null;- });-- this.setState({- modalGroup,- });- }-- getModalGroup() {- return this.refs;- }-- render() {- const { modalGroup } = this.state;- return <>{modalGroup.map((item) => item)}</>;- }-}diff --git a/packages/base-sheets/src/View/UI/index.ts b/packages/base-sheets/src/View/UI/index.tsdeleted file mode 100644index 1463b1d603..0000000000--- a/packages/base-sheets/src/View/UI/index.ts+++ /dev/null@@ -1,2 +0,0 @@-// export * from './RightMenu';-// export * from './Common';diff --git a/packages/base-sheets/src/index.ts b/packages/base-sheets/src/index.tsindex 49d1d2e40d..481e892ca0 100644--- a/packages/base-sheets/src/index.ts+++ b/packages/base-sheets/src/index.ts@@ -2,5 +2,4 @@ export * from './SheetPlugin';export * from './Model';export * from './Controller';export * from './Basics';-export * from './View/UI';export * from './View/Render';diff --git a/packages/sheets-plugin-formula/src/Basic/Register/FormulaCellEditExtension.ts b/packages/sheets-plugin-formula/src/Basic/Register/FormulaCellEditExtension.tsindex 8fa3af30b3..85075b70ac 100644--- a/packages/sheets-plugin-formula/src/Basic/Register/FormulaCellEditExtension.ts+++ b/packages/sheets-plugin-formula/src/Basic/Register/FormulaCellEditExtension.ts@@ -1,7 +1,6 @@import { IFormulaData } from '@univerjs/base-formula-engine';import { BaseCellEditExtension, BaseCellEditExtensionFactory, ICell } from '@univerjs/base-ui';import { IRangeData, Nullable } from '@univerjs/core';-import { SheetUIPlugin, SHEET_UI_PLUGIN_NAME } from '@univerjs/ui-plugin-sheets';import { FormulaPlugin } from '../../FormulaPlugin';export class FormulaCellEditExtension extends BaseCellEditExtension {diff --git a/packages/sheets-plugin-formula/src/Controller/FormulaController.ts b/packages/sheets-plugin-formula/src/Controller/FormulaController.tsindex 1fb7fe87c4..5b77881abf 100644--- a/packages/sheets-plugin-formula/src/Controller/FormulaController.ts+++ b/packages/sheets-plugin-formula/src/Controller/FormulaController.ts@@ -1,7 +1,7 @@import { FormulaEnginePlugin, IInterpreterDatasetConfig, SheetDataType, UnitDataType, SheetNameMapType, ArrayFormulaDataType } from '@univerjs/base-formula-engine';import { SheetPlugin } from '@univerjs/base-sheets';import { PLUGIN_NAMES, SheetContext } from '@univerjs/core';-import { FORMULA_PLUGIN_NAME, CONFIG } from '../Basic';+import { FORMULA_PLUGIN_NAME } from '../Basic';import { IFormulaConfig } from '../Basic/Interfaces/IFormula';import { FormulaPlugin } from '../FormulaPlugin';import { FormulaDataModel } from '../Model/FormulaDataModel';@@ -34,47 +34,47 @@ export class FormulaController {// this._initRegisterComponent();- this._sheetPlugin.addToolButton({- name: FORMULA_PLUGIN_NAME,- locale: FORMULA_PLUGIN_NAME,- hideSelectedIcon: true,- customLabel: {- name: FORMULA_PLUGIN_NAME + FormulaLabel.name,- props: {- locale: 'formula.formula.sum',- },- },- type: 5,- show: CONFIG.show,- tooltipLocale: 'formula.formulaLabel',- children: [- {- locale: 'formula.formula.sum',- suffix: 'SUM',- },- {- locale: 'formula.formula.average',- suffix: 'AVERAGE',- },- {- locale: 'formula.formula.max',- suffix: 'MAX',- },- {- locale: 'formula.formula.min',- suffix: 'MIN',- border: true,- },- {- locale: 'formula.formula.if',- suffix: 'IF',- },- {- locale: 'formula.formula.more',- onClick: () => this._plugin.getSearchFormulaController().showFormulaModal('SearchFormula', true),- },- ],- });+ // this._sheetPlugin.addToolButton({+ // name: FORMULA_PLUGIN_NAME,+ // locale: FORMULA_PLUGIN_NAME,+ // hideSelectedIcon: true,+ // customLabel: {+ // name: FORMULA_PLUGIN_NAME + FormulaLabel.name,+ // props: {+ // locale: 'formula.formula.sum',+ // },+ // },+ // type: 5,+ // show: CONFIG.show,+ // tooltipLocale: 'formula.formulaLabel',+ // children: [+ // {+ // locale: 'formula.formula.sum',+ // suffix: 'SUM',+ // },+ // {+ // locale: 'formula.formula.average',+ // suffix: 'AVERAGE',+ // },+ // {+ // locale: 'formula.formula.max',+ // suffix: 'MAX',+ // },+ // {+ // locale: 'formula.formula.min',+ // suffix: 'MIN',+ // border: true,+ // },+ // {+ // locale: 'formula.formula.if',+ // suffix: 'IF',+ // },+ // {+ // locale: 'formula.formula.more',+ // onClick: () => this._plugin.getSearchFormulaController().showFormulaModal('SearchFormula', true),+ // },+ // ],+ // });this._initialize();}diff --git a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsxindex 7e0e541377..f6d983424a 100644--- a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx+++ b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx@@ -1,5 +1,4 @@-import { BaseComponentRender, BaseComponentSheet, Component, createRef, debounce } from '@univerjs/base-ui';-import { Select } from '@univerjs/base-sheets';+import { BaseComponentRender, BaseComponentSheet, Component, createRef, debounce, Select } from '@univerjs/base-ui';import { FunctionList } from '../../../Basic';import { FunListILabel, ILabel } from '../../../Controller/SearchFormulaModalController';import styles from './index.module.less';@@ -21,7 +20,7 @@ export class SearchFormulaContent extends Component<IProps, IState> {functionListRef = createRef();initialize() {- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;+ const component = this.getContext().getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;this._render = component.getComponentRender();const functionList = this.props.funList.children?.filter((item) => item.t === 0);diff --git a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchItem.tsx b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchItem.tsxindex 94f54860d3..d206ac8534 100644--- a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchItem.tsx+++ b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchItem.tsx@@ -1,5 +1,4 @@import { Component } from '@univerjs/base-ui';-import { CellRange } from '@univerjs/base-sheets';import { FORMULA_PLUGIN_NAME, P } from '../../../Basic';import { FunParams } from '../../../Controller/SearchFormulaModalController';import { FormulaPlugin } from '../../../FormulaPlugin';@@ -27,7 +26,7 @@ export class SearchItem extends Component<IProps, IState> {}componentDidMount() {- const plugin = this._context.getPluginManager().getPluginByName<FormulaPlugin>(FORMULA_PLUGIN_NAME)!;+ const plugin = this.getContext().getPluginManager().getPluginByName<FormulaPlugin>(FORMULA_PLUGIN_NAME)!;plugin.getObserver('onSearchItemDidMountObservable')!.notifyObservers(this);const { funParams } = this.props;diff --git a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.tsindex 84435388f6..ed7e5e3588 100644--- a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts@@ -3,7 +3,7 @@ import { SheetPlugin } from '@univerjs/base-sheets';import { BaseMenuItem, BaseSelectChildrenProps, resetDataLabel } from '@univerjs/base-ui';import { PLUGIN_NAMES, Tools, UIObserver } from '@univerjs/core';import { SheetUIPlugin } from '..';-import { DefaultRightMenuConfig, SheetRightMenuConfig, SHEET_UI_PLUGIN_NAME } from '../Basics';+import { DefaultRightMenuConfig, SheetRightMenuConfig } from '../Basics';import { RightMenu, RightMenuInput, RightMenuItem } from '../View';import styles from '../View/RightMenu/index.module.less'diff --git a/packages/ui-plugin-sheets/src/Controller/SlotController.ts b/packages/ui-plugin-sheets/src/Controller/SlotController.tsnew file mode 100644index 0000000000..8c85efb994--- /dev/null+++ b/packages/ui-plugin-sheets/src/Controller/SlotController.ts@@ -0,0 +1,40 @@+import { SheetUIPlugin } from "..";+import { Slot } from "../View";++export type SlotGroupProps = Map<string, any>;++export class ModalGroupController {+ private _slotGroup: SlotGroupProps = new Map();++ private _slot: Slot;++ private _plugin: SheetUIPlugin;++ constructor(plugin: SheetUIPlugin) {+ this._plugin = plugin;+ }++ getComponent(ref: Slot) {+ this._slot = ref+ }++ addSlot(name: string, component: any) {+ if (this._slotGroup.get(name)) return+ this._slotGroup.set(name, component)+ this.setSlot()+ }++ getSlot(name: string) {+ const slotGroup = this._slot.getSlotGroup();+ return slotGroup.get(name);+ }++ removeSlot(name: string) {+ this._slotGroup.delete(name)+ this.setSlot()+ }++ setSlot() {+ this._slot.setSlotGroup(this._slotGroup);+ }+}diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsindex b88485ba7d..39d114ac34 100644--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts@@ -143,7 +143,7 @@ export class ToolbarUIController {name: 'bold',show: this._config.bold,onClick: (isBold: boolean) => {- // this._plugin.getObserver('onAfterChangeFontWeightObservable')?.notifyObservers(isBold);+ this.setFontWeight(isBold);},},{@@ -442,4 +442,12 @@ export class ToolbarUIController {};this.setUIObserve<number>(msg);}++ setFontWeight(isBold: boolean) {+ const msg = {+ name: 'fontWeight',+ value: isBold,+ };+ this.setUIObserve<boolean>(msg);+ }}diff --git a/packages/base-sheets/src/View/UI/SideGroup/SideGroup.tsx b/packages/ui-plugin-sheets/src/View/SideGroup/SideGroup.tsxsimilarity index 100%rename from packages/base-sheets/src/View/UI/SideGroup/SideGroup.tsxrename to packages/ui-plugin-sheets/src/View/SideGroup/SideGroup.tsxdiff --git a/packages/base-sheets/src/View/UI/SideGroup/index.module.less b/packages/ui-plugin-sheets/src/View/SideGroup/index.module.lesssimilarity index 100%rename from packages/base-sheets/src/View/UI/SideGroup/index.module.lessrename to packages/ui-plugin-sheets/src/View/SideGroup/index.module.lessdiff --git a/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx b/packages/ui-plugin-sheets/src/View/Slot/Slot.tsxindex e71ec74dc0..400ddd7ca1 100644--- a/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx+++ b/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx@@ -1,16 +1,15 @@-import { BaseComponentProps } from '../../BaseComponent';-import { Component } from '../../Framework';+import { BaseComponentProps, Component } from '@univerjs/base-ui';interface IState {- slotGroup: any[];+ slotGroup: Map<string, any>;}export class Slot extends Component<BaseComponentProps, IState> {- refs: any[] = [];+ refMap = new Map();initialize() {this.state = {- slotGroup: [],+ slotGroup: new Map(),};}@@ -18,26 +17,26 @@ export class Slot extends Component<BaseComponentProps, IState> {this.props.getComponent?.(this);}- setSlotGroup(group: any[]) {- const slotGroup = group.map((item, index) => {- const Modal = plugin?.getRegisterComponent(item);- if (Modal) {- return <Modal ref={(ele: any) => (this.refs[index] = ele)} />;- }- return null;- });-+ setSlotGroup(group: Map<string, any>) {this.setState({- modalGroup,+ slotGroup: group,});}- getModalGroup() {- return this.refs;+ getSlotGroup() {+ return this.refMap;+ }++ getRender(slotGroup: Map<string, any>) {+ const group = [];+ for (let k in slotGroup) {+ group.push(<Slot ref={(ele: any) => this.refMap.set(k, ele)}></Slot>);+ }+ return group;}render() {- const { modalGroup } = this.state;- return <>{modalGroup.map((item) => item)}</>;+ const { slotGroup } = this.state;+ return <>{this.getRender(slotGroup)}</>;}}diff --git a/packages/ui-plugin-sheets/src/View/index.tsx b/packages/ui-plugin-sheets/src/View/index.tsxindex 10dce0a373..8b72e66a87 100644--- a/packages/ui-plugin-sheets/src/View/index.tsx+++ b/packages/ui-plugin-sheets/src/View/index.tsx@@ -42,3 +42,4 @@ export * from './Toolbar';export * from './RightMenu';export * from './InfoBar';export * from './Common';+export * from './Slot/Slot';