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
chore(slide): 1.migrate ui-plugin-slide 2. optimize base-slides
Dushusirba3fc644332c
diff --git a/packages/base-sheets/src/SheetPlugin.ts b/packages/base-sheets/src/SheetPlugin.tsindex 12b018c54e..670849ea5b 100644--- a/packages/base-sheets/src/SheetPlugin.ts+++ b/packages/base-sheets/src/SheetPlugin.ts@@ -1,5 +1,5 @@import { Engine, RenderEngine } from '@univerjs/base-render';-import { SheetContext, Plugin, PLUGIN_NAMES, DEFAULT_SELECTION } from '@univerjs/core';+import { SheetContext, Plugin, PLUGIN_NAMES, DEFAULT_SELECTION, UniverSheet } from '@univerjs/core';import { SheetPluginObserve, uninstall } from './Basics/Observer';import { CANVAS_VIEW_KEY } from './View/Render/BaseView';@@ -42,6 +42,14 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {this._config = Object.assign(DEFAULT_SPREADSHEET_PLUGIN_DATA, config);}+ static create(config?: ISheetPluginConfig) {+ return new SheetPlugin(config);+ }++ installTo(universheetInstance: UniverSheet) {+ universheetInstance.installPlugin(this);+ }+initialize(context: SheetContext): void {this.context = context;diff --git a/packages/base-slides/index.html b/packages/base-slides/index.htmldeleted file mode 100644index 929f441cf5..0000000000--- a/packages/base-slides/index.html+++ /dev/null@@ -1,24 +0,0 @@-<!DOCTYPE html>-<html lang="en">--<head>- <meta charset="UTF-8" />- <link rel="icon" type="image/svg+xml" href="favicon.svg" />- <meta name="viewport" content="width=device-width, initial-scale=1.0" />- <title>UniverSlide</title>- <style>- html,- body {- height: 100%;- margin: 0;- }- </style>-</head>--<body>- <div id="app" style="z-index: 1; position: fixed; font-size: 20px; color: green;"></div>- <div id="universlide" style="height: 100%;"></div>- <script type="module" src="/src/main.tsx"></script>-</body>--</html>\ No newline at end of filediff --git a/packages/base-slides/package.json b/packages/base-slides/package.jsonindex 61bfb89662..06d1a384c3 100644--- a/packages/base-slides/package.json+++ b/packages/base-slides/package.json@@ -45,9 +45,7 @@},"dependencies": {"@univerjs/base-render": "workspace:^0.0.1",- "@univerjs/base-sheets": "workspace:^0.0.1","@univerjs/base-ui": "workspace:^0.0.1",- "@univerjs/common-plugin-data": "workspace:^0.0.1","@univerjs/core": "workspace:^0.0.1","css-vars-ponyfill": "^2.4.6","preact": "^10.12.1"diff --git a/packages/base-slides/src/Basics/Observer.ts b/packages/base-slides/src/Basics/Observer.tsindex 0e4dd54fea..f09b5f611e 100644--- a/packages/base-slides/src/Basics/Observer.ts+++ b/packages/base-slides/src/Basics/Observer.ts@@ -1,7 +1,7 @@import { IKeyboardEvent } from '@univerjs/base-render';import { Observable, Plugin } from '@univerjs/core';import { SlideContainer } from '../View/UI/SlideContainer';-import { SlideBar } from '../View/UI/SlideBar/SlideBar';+import { SlideBar } from '../../../ui-plugin-slides/src/View/SlideBar/SlideBar';import { Toolbar } from '../View/UI/ToolBar/Toolbar';export type SlidePluginObserve = {@@ -19,7 +19,7 @@ export type SlidePluginObserve = {onToolbarDidMountObservable: Observable<Toolbar>;onSlideBarDidMountObservable: Observable<SlideBar>;- onSlideBarMousedownObservable: Observable<string>;+onSlideContainerDidMountObservable: Observable<SlideContainer>;@@ -46,7 +46,7 @@ export function uninstall(plugin: Plugin) {plugin.deleteObserve('onToolbarDidMountObservable');plugin.deleteObserve('onSlideBarDidMountObservable');- plugin.deleteObserve('onSlideBarMousedownObservable');+plugin.deleteObserve('onChangeCurrentSheetObserver');plugin.deleteObserve('onSlideContainerDidMountObservable');@@ -81,7 +81,7 @@ export function install(plugin: Plugin) {plugin.pushToObserve('onToolbarDidMountObservable');- plugin.pushToObserve('onSlideBarMousedownObservable');+plugin.pushToObserve('onSheetBarDidMountObservable');plugin.pushToObserve('onCountBarDidMountObservable');diff --git a/packages/base-slides/src/Controller/SlideBarController.ts b/packages/base-slides/src/Controller/SlideBarController.tsdeleted file mode 100644index 7b443b4a8d..0000000000--- a/packages/base-slides/src/Controller/SlideBarController.ts+++ /dev/null@@ -1,79 +0,0 @@-import { ISlidePage, PLUGIN_NAMES } from '@univerjs/core';-import { SlidePlugin } from '../SlidePlugin';-import { SlideBar } from '../View/UI/SlideBar/SlideBar';--export class SlideBarController {- private _plugin: SlidePlugin;-- private _slideBar: SlideBar;-- private _pages: ISlidePage[] = [];-- constructor(plugin: SlidePlugin) {- this._plugin = plugin;-- this._init();- }-- private _init() {- const context = this._plugin.context;- const manager = context.getObserverManager();-- this._generateModel();-- manager.requiredObserver<SlideBar>('onSlideBarDidMountObservable', PLUGIN_NAMES.SLIDE).add((component) => {- this._slideBar = component;-- this._slideBar.setSlide(this._pages);-- this._plugin.getObserver('onSlideContainerDidMountObservable')?.add(() => {- const canvasView = this._getCanvasView();-- canvasView.createSlidePages(this._slideBar, this._pages);-- canvasView.getSlide().onSlideChangePageByNavigationObservable.add((pageId) => {- if (this._slideBar.state.activePageId === pageId || pageId == null) {- return;- }- this._slideBar.setState({- activePageId: pageId,- });- canvasView.activePage(pageId);- });- });-- this._plugin.getObserver('onSlideBarMousedownObservable')?.add((pageId) => {- const canvasView = this._getCanvasView();- canvasView.activePage(pageId);- });- });- }-- private _getCanvasView() {- return this._plugin.getCanvasView();- }-- private _generateModel() {- const model = this._plugin.context.getSlide();- const pages = model.getPages();- const pageOrder = model.getPageOrder();- if (!pages || !pageOrder) {- return;- }-- pageOrder.forEach((pageKey) => {- this._pages.push(pages[pageKey]);- });- }-- addSlide() {- const model = this._plugin.context.getSlide();- const canvasView = this._getCanvasView();- const newPage = model.addPage();- this._pages.push(newPage);-- this._slideBar.setSlide(this._pages);-- canvasView.createSlidePages(this._slideBar, this._pages);- }-}diff --git a/packages/base-slides/src/Controller/SlideController.ts b/packages/base-slides/src/Controller/SlideController.tsdeleted file mode 100644index 1ac6abf301..0000000000--- a/packages/base-slides/src/Controller/SlideController.ts+++ /dev/null@@ -1,14 +0,0 @@-import { BooleanNumber, CommandManager } from '@univerjs/core';-import { SlidePlugin } from '../SlidePlugin';--export class SlideController {- private _plugin: SlidePlugin;-- constructor(plugin: SlidePlugin) {- this._plugin = plugin;-- this._initialize();- }-- private _initialize() {}-}diff --git a/packages/base-slides/src/Controller/ToolbarController.ts b/packages/base-slides/src/Controller/ToolbarController.tsindex 68c8bd1950..7f63b66bbc 100644--- a/packages/base-slides/src/Controller/ToolbarController.ts+++ b/packages/base-slides/src/Controller/ToolbarController.ts@@ -1,321 +1,21 @@-import { BaseComponentRender, BaseComponentSheet } from '@univerjs/base-ui';-import { Tools, BorderType, BorderStyleTypes, HorizontalAlign, VerticalAlign, WrapStrategy, DEFAULT_STYLES } from '@univerjs/core';-import { ColorPicker } from '@univerjs/style-univer';+import { BorderType } from '@univerjs/core';import { SlidePlugin } from '../SlidePlugin';-import { defaultLayout, ILayout } from '../View/UI/SlideContainer';-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 { Toolbar } from '../View/UI/Toolbar';-import { IToolbarItemProps, ToolbarModel } from '../Model/ToolbarModel';--interface BorderInfo {+export interface BorderInfo {+ type: BorderType;color: string;- width: string;+ style: number;}/****/export class ToolbarController {- private _toolbarModel: ToolbarModel;-private _plugin: SlidePlugin;- private _toolbarComponent: Toolbar;-- private _toolList: IToolbarItemProps[];-- private _lineColor: LineColor;-- Render: BaseComponentRender;-- private _borderInfo: BorderInfo; //存储边框信息-constructor(plugin: SlidePlugin) {this._plugin = plugin;-- const pluginName = this._plugin.getPluginName();-- this._initRegisterComponent();-- const config =- this._plugin.getConfig().layout === 'auto'- ? Tools.deepClone(defaultLayout.toolbarConfig)- : Tools.deepMerge(defaultLayout.toolbarConfig, (this._plugin.getConfig().layout as ILayout).toolbarConfig);-- this._borderInfo = {- color: '#000',- width: '1',- };-- this._toolList = [- {- toolbarType: 1,- tooltipLocale: 'toolbar.undo',- customLabel: {- name: 'ForwardIcon',- },- show: config.undoRedo,- onClick: () => {- this.setUndo();- },- },- {- toolbarType: 1,- tooltipLocale: 'toolbar.redo',- customLabel: {- name: 'BackIcon',- },- show: config.undoRedo,- onClick: () => {- this.setRedo();- },- },-- {- type: 0,- tooltipLocale: 'toolbar.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: 'toolbar.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: 'toolbar.bold',- customLabel: {- name: 'BoldIcon',- },- show: config.bold,- onClick: (isBold: boolean) => {- this._plugin.getObserver('onAfterChangeFontWeightObservable')?.notifyObservers(isBold);- },- },- {- toolbarType: 1,- tooltipLocale: 'toolbar.italic',- customLabel: {- name: 'ItalicIcon',- },- show: config.italic,- onClick: (isItalic: boolean) => {- this._plugin.getObserver('onAfterChangeFontItalicObservable')?.notifyObservers(isItalic);- },- },- {- toolbarType: 1,- tooltipLocale: 'toolbar.strikethrough',- customLabel: {- name: 'DeleteLineIcon',- },- show: config.strikethrough,- onClick: (isStrikethrough: boolean) => {- this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.notifyObservers(isStrikethrough);- },- },- {- toolbarType: 1,- tooltipLocale: 'toolbar.underline',- customLabel: {- name: 'UnderLineIcon',- },- show: config.underline,- onClick: (isItalic: boolean) => {- this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.notifyObservers(isItalic);- },- },- {- type: 2,- tooltipLocale: 'toolbar.textColor.main',- customLabel: {- name: 'TextColorIcon',- },- show: config.textColor,- onClick: (color: string) => {- this._plugin.getObserver('onAfterChangeFontColorObservable')?.notifyObservers(color);- },- },- {- type: 2,- tooltipLocale: 'toolbar.fillColor.main',- customLabel: {- name: 'FillColorIcon',- },- show: config.fillColor,- onClick: (color: string) => {- this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.notifyObservers(color);- },- },- ];-- this._toolbarModel = new ToolbarModel();- this._toolbarModel.config = config;- this._toolbarModel.toolList = this._toolList;-- this.init();- }-- init() {- this._plugin.getObserver('onAfterChangeFontFamilyObservable')?.add((value: string) => {- this.setFontFamily(value);- });- this._plugin.getObserver('onAfterChangeFontSizeObservable')?.add((value: number) => {- this.setFontSize(value);- });- this._plugin.getObserver('onAfterChangeFontWeightObservable')?.add((value: boolean) => {- this.setFontWeight(value);- });- this._plugin.getObserver('onAfterChangeFontItalicObservable')?.add((value: boolean) => {- this.setFontStyle(value);- });- this._plugin.getObserver('onAfterChangeFontStrikethroughObservable')?.add((value: boolean) => {- this.setStrikeThrough(value);- });- this._plugin.getObserver('onAfterChangeFontUnderlineObservable')?.add((value: boolean) => {- this.setUnderline(value);- });- this._plugin.getObserver('onAfterChangeFontColorObservable')?.add((value: string) => {- this.setFontColor(value);- });- this._plugin.getObserver('onAfterChangeFontBackgroundObservable')?.add((value: string) => {- this.setBackground(value);- });-- this._plugin.getObserver('onToolbarDidMountObservable')?.add((component) => {- //初始化视图- this._toolbarComponent = component;- this.resetToolbarList();- });-- this._plugin.context- .getObserverManager()- .getObserver('onAfterChangeUILocaleObservable', 'workbook')- ?.add(() => {});}- private _initRegisterComponent() {- const component = this._plugin.context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- const pluginName = this._plugin.getPluginName();- this.Render = component.getComponentRender();- const registerIcon = {- ForwardIcon: this.Render.renderFunction('ForwardIcon'),- BackIcon: this.Render.renderFunction('BackIcon'),- BoldIcon: this.Render.renderFunction('BoldIcon'),- ItalicIcon: this.Render.renderFunction('ItalicIcon'),- DeleteLineIcon: this.Render.renderFunction('DeleteLineIcon'),- UnderLineIcon: this.Render.renderFunction('UnderLineIcon'),- TextColorIcon: this.Render.renderFunction('TextColorIcon'),- FillColorIcon: this.Render.renderFunction('FillColorIcon'),- MergeIcon: this.Render.renderFunction('MergeIcon'),- TopBorderIcon: this.Render.renderFunction('TopBorderIcon'),- BottomBorderIcon: this.Render.renderFunction('BottomBorderIcon'),- LeftBorderIcon: this.Render.renderFunction('LeftBorderIcon'),- RightBorderIcon: this.Render.renderFunction('RightBorderIcon'),- NoneBorderIcon: this.Render.renderFunction('NoneBorderIcon'),- FullBorderIcon: this.Render.renderFunction('FullBorderIcon'),- OuterBorderIcon: this.Render.renderFunction('OuterBorderIcon'),- InnerBorderIcon: this.Render.renderFunction('InnerBorderIcon'),- StripingBorderIcon: this.Render.renderFunction('StripingBorderIcon'),- VerticalBorderIcon: this.Render.renderFunction('VerticalBorderIcon'),- LeftAlignIcon: this.Render.renderFunction('LeftAlignIcon'),- CenterAlignIcon: this.Render.renderFunction('CenterAlignIcon'),- RightAlignIcon: this.Render.renderFunction('RightAlignIcon'),- TopVerticalIcon: this.Render.renderFunction('TopVerticalIcon'),- CenterVerticalIcon: this.Render.renderFunction('CenterVerticalIcon'),- BottomVerticalIcon: this.Render.renderFunction('BottomVerticalIcon'),- OverflowIcon: this.Render.renderFunction('OverflowIcon'),- BrIcon: this.Render.renderFunction('BrIcon'),- CutIcon: this.Render.renderFunction('CutIcon'),- TextRotateIcon: this.Render.renderFunction('TextRotateIcon'),- TextRotateAngleUpIcon: this.Render.renderFunction('TextRotateAngleUpIcon'),- TextRotateAngleDownIcon: this.Render.renderFunction('TextRotateAngleDownIcon'),- TextRotateVerticalIcon: this.Render.renderFunction('TextRotateVerticalIcon'),- TextRotateRotationUpIcon: this.Render.renderFunction('TextRotateRotationUpIcon'),- TextRotateRotationDownIcon: this.Render.renderFunction('TextRotateRotationDownIcon'),- };-- // 注册自定义组件- this._plugin.registerComponent(pluginName + LineColor.name, LineColor);- this._plugin.registerComponent(pluginName + ColorPicker.name, ColorPicker);- for (let k in registerIcon) {- this._plugin.registerComponent(k, registerIcon[k]);- }- }-- resetLocale(toolList: any[]) {- const locale = this._plugin.context.getLocale();-- for (let i = 0; i < toolList.length; i++) {- const item = toolList[i];- if (item.tooltipLocale) {- item.tooltip = locale.get(item.tooltipLocale);- }- if (item.locale) {- item.label = locale.get(item.locale);- }- if (item.suffixLocale) {- item.suffix = locale.get(item.suffixLocale);- }- if (item.children) {- item.children = this.resetLocale(item.children);- }- }- return toolList;- }-- resetToolbarList() {- const toolList = this.resetLocale(this._toolList);- this._toolbarComponent.setToolbar(toolList);- }-- setRedo() {- this._plugin.getContext().getCommandManager().redo();- }-- setUndo() {- this._plugin.getContext().getCommandManager().undo();- }-- setFontColor(value: string) {}-- setBackground(value: string) {}-- setFontSize(value: number) {}-- setFontFamily(value: string) {}-- setFontWeight(value: boolean) {}-- setFontStyle(value: boolean) {}-- setStrikeThrough(value: boolean) {}-- setUnderline(value: boolean) {}+ listenEventManager() {}}diff --git a/packages/base-slides/src/Controller/index.ts b/packages/base-slides/src/Controller/index.tsindex e69de29bb2..47f1b56674 100644--- a/packages/base-slides/src/Controller/index.ts+++ b/packages/base-slides/src/Controller/index.ts@@ -0,0 +1,3 @@+// @index(['./*.ts','./**/index.ts'], f => `export * from '${f.path}'`)+export * from './ToolbarController';+// @endindexdiff --git a/packages/base-slides/src/SlidePlugin.tsx b/packages/base-slides/src/SlidePlugin.tsxindex 4b73c80152..a8f19fff46 100644--- a/packages/base-slides/src/SlidePlugin.tsx+++ b/packages/base-slides/src/SlidePlugin.tsx@@ -1,216 +1,84 @@-import { SlideContext, Plugin, PLUGIN_NAMES, UniverSheet, Tools, AsyncFunction } from '@univerjs/core';-import { getRefElement, isElement, ISlotProps, RefObject, render } from '@univerjs/base-ui';+import { SlideContext, Plugin, PLUGIN_NAMES, UniverSlide } from '@univerjs/core';import { Engine, RenderEngine } from '@univerjs/base-render';import { zh, en } from './Locale';-import { install, SlidePluginObserve } from './Basics/Observer';-import { ToolbarController } from './Controller/ToolbarController';-import { SlideController } from './Controller/SlideController';-import { InfoBarController } from './Controller/InfoBarController';-import { BaseSlideContainerConfig, defaultLayout, ILayout, ISlidePluginConfigBase, SlideContainer } from './View/UI/SlideContainer';-import { SlideBarController } from './Controller/SlideBarController';+import { install, SlidePluginObserve, uninstall } from './Basics/Observer';import { CanvasView } from './View/Render';-export interface ISlidePluginConfig extends ISlidePluginConfigBase {- container: HTMLElement | string;-}+export interface ISlidePluginConfig {}-const DEFAULT_SLIDE_PLUGIN_DATA = {- container: 'universlide',- layout: defaultLayout,-};+const DEFAULT_SLIDE_PLUGIN_DATA = {};export class SlidePlugin extends Plugin<SlidePluginObserve, SlideContext> {private _config: ISlidePluginConfig;- private _infoBarControl: InfoBarController;-- private _splitLeftRef: RefObject<HTMLDivElement>;-- private _contentRef: RefObject<HTMLDivElement>;-- private _addButtonFunc: Function;-- private _addSiderFunc: AsyncFunction<ISlotProps>;-- private _addMainFunc: Function;-- private _showSiderByNameFunc: Function;-- private _showMainByNameFunc: Function;-private _canvasEngine: Engine;private _canvasView: CanvasView;- private _toolbarControl: ToolbarController;-- private _slideBarControl: SlideBarController;-- private _SlideController: SlideController;-- private _componentList: Map<string, any>;-constructor(config: Partial<ISlidePluginConfig> = {}) {super(PLUGIN_NAMES.SLIDE);- this._config = Tools.commonExtend(DEFAULT_SLIDE_PLUGIN_DATA, config);+ this._config = Object.assign(DEFAULT_SLIDE_PLUGIN_DATA, config);}static create(config?: ISlidePluginConfig) {return new SlidePlugin(config);}- installTo(universheetInstance: UniverSheet) {- universheetInstance.installPlugin(this);+ installTo(universlideInstance: UniverSlide) {+ universlideInstance.installPlugin(this);}- initialize(): void {- const context = this.getContext();-- this.getObserver('onSlideContainerDidMountObservable')?.add(() => {- this._initializeRender();- });+ initialize(context: SlideContext): void {+ this.context = context;- /**- * load more Locale object- */- context.getLocale().load({+ this.getGlobalContext().getLocale().load({en,zh,});-- this._componentList = new Map();-- const layout = this._config.layout as ILayout;-- if (layout.toolbar) {- this._toolbarControl = new ToolbarController(this);- }- if (layout.infoBar) {- this._infoBarControl = new InfoBarController(this);- }-- this._slideBarControl = new SlideBarController(this);- this._SlideController = new SlideController(this);-- const slideContainer = this._initContainer(this._config.container);-- const config: BaseSlideContainerConfig = {- skin: 'default',- layout: this._config.layout,- container: slideContainer,- context,- getSplitLeftRef: (ref) => {- this._splitLeftRef = ref;- },- getContentRef: (ref) => {- this._contentRef = ref;- },- addButton: (cb: Function) => {- this._addButtonFunc = cb;- },- addSider: (cb: AsyncFunction<ISlotProps>) => {- this._addSiderFunc = cb;- },- addMain: (cb: Function) => {- this._addMainFunc = cb;- },- showSiderByName: (cb: Function) => {- this._showSiderByNameFunc = cb;- },- showMainByName: (cb: Function) => {- this._showMainByNameFunc = cb;- },- onDidMount: () => {},- };-- render(<SlideContainer config={config} />, slideContainer);+ install(this);+ this.initConfig();+ this.initController();+ this.initCanvasView();+ this.registerExtension();}- /**- * Convert id to DOM- * @param container- * @returns- */- private _initContainer(container: HTMLElement | string) {- let slideContainer = null;- if (typeof container === 'string') {- const containerDOM = document.getElementById(container);- if (containerDOM == null) {- slideContainer = document.createElement('div');- slideContainer.id = container;- } else {- slideContainer = containerDOM;- }- } else if (isElement(container)) {- slideContainer = container;- } else {- slideContainer = document.createElement('div');- slideContainer.id = 'universlide';- }-- return slideContainer;+ getConfig() {+ return this._config;}- private _initializeRender() {- const engine = this.getGlobalContext().getPluginManager().getRequirePluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER).getEngine();+ initConfig() {}- this.register(engine);- }+ initController() {}- register(engineInstance: Engine) {- // The preact ref component cannot determine whether ref.current or ref.current.base is DOM- let container: HTMLElement = getRefElement(this.getContentRef());-- this._canvasEngine = engineInstance;+ initCanvasView() {+ const engine = this.getGlobalContext().getPluginManager().getRequirePluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER).getEngine();- engineInstance.setContainer(container);+ this._canvasEngine = engine;- this._canvasView = new CanvasView(engineInstance, this);- window.addEventListener('resize', () => {- engineInstance.resize();- });- // window.onresize = () => {- // engineInstance.resize();- // };+ if (this._canvasView == null) {+ this._canvasView = new CanvasView(engine, this);+ }}- getConfig() {- return this._config;+ onMounted(ctx: SlideContext): void {+ this.initialize(ctx);}- getContentRef(): RefObject<HTMLDivElement> {- return this._contentRef;+ onDestroy(): void {+ super.onDestroy();+ uninstall(this);}- getToolbarControl() {- return this._toolbarControl;- }+ registerExtension() {}- getInfoBarControl() {- return this._infoBarControl;- }+ listenEventManager() {}- getSlideBarControl() {- return this._slideBarControl;+ getCanvasEngine() {+ return this._canvasEngine;}getCanvasView() {return this._canvasView;}-- onMounted(): void {- install(this);- this.initialize();- }-- onDestroy(): void {}-- registerComponent(name: string, component: any) {- this._componentList.set(name, component);- }-- getRegisterComponent(name: string) {- return this._componentList.get(name);- }}diff --git a/packages/base-slides/src/View/Render/CanvasView.ts b/packages/base-slides/src/View/Render/CanvasView.tsindex 3535c66596..e18ccd4da3 100644--- a/packages/base-slides/src/View/Render/CanvasView.ts+++ b/packages/base-slides/src/View/Render/CanvasView.ts@@ -1,7 +1,6 @@-import { Engine, EVENT_TYPE, IWheelEvent, Layer, Rect, Scene, SceneViewer, ScrollBar, Slide, Viewport } from '@univerjs/base-render';-import { EventState, getColorStyle, IColorStyle, IPageElement, ISlidePage, Nullable, Registry, sortRules } from '@univerjs/core';+import { Engine, EVENT_TYPE, IWheelEvent, Rect, Scene, ScrollBar, Slide, Viewport } from '@univerjs/base-render';+import { EventState, getColorStyle, IColorStyle, ISlidePage, Nullable } from '@univerjs/core';import { SlidePlugin } from '../../SlidePlugin';-import { SlideBar } from '../UI/SlideBar/SlideBar';import { ObjectProvider } from './ObjectProvider';export enum SLIDE_KEY {@@ -29,14 +28,12 @@ export class CanvasView {return this._slide;}- createSlidePages(slideBar: SlideBar, pages: ISlidePage[]) {- const slideBarRef = slideBar.slideBarRef;- const thumbList = slideBarRef.current?.childNodes[0].childNodes;+ createSlidePages(thumbList: NodeListOf<ChildNode> | undefined, pages: ISlidePage[]) {if (thumbList == null || thumbList.length !== pages.length) {return;}- for (var i = 0, len = thumbList.length; i < len; i++) {+ for (let i = 0, len = thumbList.length; i < len; i++) {const thumbDom = (thumbList[i] as HTMLElement).querySelector('div');const page = pages[i];const { id } = page;@@ -50,7 +47,7 @@ export class CanvasView {}setTimeout(() => {- for (var i = 0, len = thumbList.length; i < len; i++) {+ for (let i = 0, len = thumbList.length; i < len; i++) {const thumbDom = (thumbList[i] as HTMLElement).querySelector('div');const page = pages[i];const { id } = page;@@ -101,6 +98,19 @@ export class CanvasView {this._createScene(id, this._slide, page);}+ scrollToCenter() {+ const viewMain = this._scene.getViewport(SLIDE_KEY.VIEW);+ if (!viewMain) return;+ const { left: viewPortLeft, top: viewPortTop } = this._getCenterPositionViewPort();++ const { x, y } = viewMain.getBarScroll(viewPortLeft, viewPortTop);++ viewMain.scrollTo({+ x,+ y,+ });+ }+private _initialize() {const engine = this._engine;@@ -259,7 +269,7 @@ export class CanvasView {height,});- const viewMain = new Viewport('PageViewer_' + pageId, scene, {+ const viewMain = new Viewport(`PageViewer_${pageId}`, scene, {left: 0,top: 0,bottom: 0,diff --git a/packages/base-slides/src/View/UI/Common/Item/Item.tsx b/packages/base-slides/src/View/UI/Common/Item/Item.tsxdeleted file mode 100644index b39207b35b..0000000000--- a/packages/base-slides/src/View/UI/Common/Item/Item.tsx+++ /dev/null@@ -1,35 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, BaseMenuItem, Component, ComponentChildren, joinClassNames } from '@univerjs/base-ui';-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-slides/src/View/UI/Common/Item/index.module.less b/packages/base-slides/src/View/UI/Common/Item/index.module.lessdeleted file mode 100644index 0541ceaed5..0000000000--- a/packages/base-slides/src/View/UI/Common/Item/index.module.less+++ /dev/null@@ -1,33 +0,0 @@-.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: var(--gray-15);-}diff --git a/packages/base-slides/src/View/UI/Common/Line/LineBold.tsx b/packages/base-slides/src/View/UI/Common/Line/LineBold.tsxdeleted file mode 100644index 54654aaec5..0000000000--- a/packages/base-slides/src/View/UI/Common/Line/LineBold.tsx+++ /dev/null@@ -1,56 +0,0 @@-import { Component } from '@univerjs/base-ui';-import { Nullable, Observer, Workbook } from '@univerjs/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-slides/src/View/UI/Common/Line/LineColor.tsx b/packages/base-slides/src/View/UI/Common/Line/LineColor.tsxdeleted file mode 100644index 94b2aa24de..0000000000--- a/packages/base-slides/src/View/UI/Common/Line/LineColor.tsx+++ /dev/null@@ -1,71 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, Component } from '@univerjs/base-ui';-import { Nullable, Observer, Workbook } from '@univerjs/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-slides/src/View/UI/Common/Select/Select.tsx b/packages/base-slides/src/View/UI/Common/Select/Select.tsxdeleted file mode 100644index 441d11a8b7..0000000000--- a/packages/base-slides/src/View/UI/Common/Select/Select.tsx+++ /dev/null@@ -1,412 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, BaseMenuItem, BaseMenuProps, Component, ComponentChildren } from '@univerjs/base-ui';-import { ColorPicker, Dropdown } from '@univerjs/style-univer';-import { BaseItemProps, Item } from '../Item/Item';-import styles from './index.module.less';--enum SelectTypes {- SINGLE, // 普通下拉- INPUT,- COLOR,- DOUBLE,- FIX,- DOUBLEFIX,-}--enum DisplayTypes {- LABEL,- SUFFIX,-}--interface CustomComponent {- name: string;- props?: Record<string, any>;-}--export interface BaseSelectChildrenProps extends BaseItemProps {- onKeyUp?: (...arg: any) => void;- children?: BaseSelectChildrenProps[];- unSelectable?: boolean; //选中后不生效事件- customLabel?: CustomComponent;- customSuffix?: CustomComponent;-}--export interface BaseSelectProps {- 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;- customLabel?: CustomComponent;- customSuffix?: CustomComponent;- tooltip?: 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.length) 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.length) 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.length) 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;- list[i].onClick = children[i].onClick;-- 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;- if (children.length) {- 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 = '', tooltip } = this.props;- const Button = this.Render.renderFunction('Button');-- return (- <div className={`${styles.selectSingle} ${selectClassName}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <div>{content}</div>- </Dropdown>- </Button>- </div>- );- };-- //Input下拉- getInput = () => {- const { content, menu } = this.state;- const { selectClassName = '', tooltip } = this.props;- const Input = this.Render.renderFunction('Input');- const Button = this.Render.renderFunction('Button');-- return (- <div className={`${styles.selectInput} ${selectClassName}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <Input onKeyUp={this.onKeyUp} type="number" value={content as string} />- </Dropdown>- </Button>- </div>- );- };-- //颜色选择器- getColor = () => {- const { label, selectClassName = '', tooltip } = 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 tooltip={tooltip} 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 = '', tooltip } = this.props;- const NextIcon = this.Render.renderFunction('NextIcon');- const Button = this.Render.renderFunction('Button');-- return (- <div className={`${styles.selectDouble} ${selectClassName}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} icon={<NextIcon />}>- <div className={styles.selectLabel}>{content}</div>- </Dropdown>- </Button>- </div>- );- };-- getFix = () => {- const { label, selectClassName = '', tooltip } = this.props;- const { menu } = this.state;- const Button = this.Render.renderFunction('Button');-- return (- <div className={`${styles.selectDouble} ${selectClassName}`}>- <Button type="text">- <Dropdown tooltip={tooltip} menu={{ menu, onClick: this.onClick }} showArrow>- <div className={styles.selectLabel}>{label}</div>- </Dropdown>- </Button>- </div>- );- };-- getDoubleFix = () => {- const { label, selectClassName = '', tooltip } = 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 tooltip={tooltip} 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-slides/src/View/UI/Common/Select/index.module.less b/packages/base-slides/src/View/UI/Common/Select/index.module.lessdeleted file mode 100644index 6e0db19960..0000000000--- a/packages/base-slides/src/View/UI/Common/Select/index.module.less+++ /dev/null@@ -1,112 +0,0 @@-.select-component {- position: relative;- margin: 0 3px;- height: 26px;-- &:hover {- background-color: var(--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 var(--gray-6);- }- }- }-- .select-label {- span[role='img'] {- font-size: 24px;- }- }-- button {- .button();- border-color: transparent;- height: auto;- }-}--.button() {- padding: 0px;- box-sizing: border-box;-}diff --git a/packages/base-slides/src/View/UI/Common/TextButton/TextButton.tsx b/packages/base-slides/src/View/UI/Common/TextButton/TextButton.tsxdeleted file mode 100644index 630019c0af..0000000000--- a/packages/base-slides/src/View/UI/Common/TextButton/TextButton.tsx+++ /dev/null@@ -1,47 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, Component, ComponentChildren } from '@univerjs/base-ui';-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-slides/src/View/UI/Common/TextButton/index.module.css b/packages/base-slides/src/View/UI/Common/TextButton/index.module.cssdeleted file mode 100644index 4fb4faa3e5..0000000000--- a/packages/base-slides/src/View/UI/Common/TextButton/index.module.css+++ /dev/null@@ -1,6 +0,0 @@-.text-button span[role="img"] {- font-size: 24px;-}-.text-button button {- padding: 0 5px;-}diff --git a/packages/base-slides/src/View/UI/Common/TextButton/index.module.less b/packages/base-slides/src/View/UI/Common/TextButton/index.module.lessdeleted file mode 100644index 305b85ad5c..0000000000--- a/packages/base-slides/src/View/UI/Common/TextButton/index.module.less+++ /dev/null@@ -1,9 +0,0 @@-.text-button {- span[role="img"] {- font-size: 24px;- }-- button {- padding: 0 5px;- }-}\ No newline at end of filediff --git a/packages/base-slides/src/View/UI/Common/index.ts b/packages/base-slides/src/View/UI/Common/index.tsdeleted file mode 100644index 3ac4f375d8..0000000000--- a/packages/base-slides/src/View/UI/Common/index.ts+++ /dev/null@@ -1 +0,0 @@-// Basics business componentsdiff --git a/packages/base-slides/src/View/UI/InfoBar/InfoBar.tsx b/packages/base-slides/src/View/UI/InfoBar/InfoBar.tsxdeleted file mode 100644index ef099a80e9..0000000000--- a/packages/base-slides/src/View/UI/InfoBar/InfoBar.tsx+++ /dev/null@@ -1,68 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, Component } from '@univerjs/base-ui';-import { Nullable, PLUGIN_NAMES } from '@univerjs/core';-import { BaseInfoBarProps } from '../../../Controller/InfoBarController';-import './index.less';--interface IState {- infoList: Nullable<BaseInfoBarProps>;-}--interface Iprops {}--export class InfoBar extends Component<Iprops, IState> {- Render: BaseComponentRender;-- initialize() {- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();-- this.state = {- infoList: null,- };- }-- componentDidMount() {- this._context.getObserverManager().getObserver<InfoBar>('onInfoBarDidMountObservable', PLUGIN_NAMES.SLIDE)?.notifyObservers(this);- }-- setInfoList(list: BaseInfoBarProps) {- this.setState({- infoList: list,- });- }-- render() {- if (!this.state.infoList) return;- const Button = this.Render.renderFunction('Button');- const Container = this.Render.renderFunction('Container');- const Input = this.Render.renderFunction('Input');- const Tooltip = this.Render.renderFunction('Tooltip');- const DropDownIcon = this.Render.renderFunction('DropDownIcon');- const LogoIcon = this.Render.renderFunction('LogoIcon');-- const { back, sheet, update, save, rename } = this.state.infoList;-- return (- <Container className={'universheet-info-detail'}>- <div style={{ marginRight: '18px' }}>- <Tooltip title={back.label} placement={'bottom'}>- <Button className={'universheet-info-return'} type="text">- <DropDownIcon rotate={90} />- </Button>- </Tooltip>- </div>- <div className={'sheet-name'}>- <Tooltip title={rename.label} placement={'bottom'}>- <Input bordered={false} value={sheet.label} onBlur={sheet.onBlur} />- </Tooltip>- </div>- <div id="universheet-info-detail-update" className="universheet-info-detail-update">- {update.label}- </div>- <div id="universheet-info-detail-save" className="universheet-info-detail-save">- {save.label}- </div>- </Container>- );- }-}diff --git a/packages/base-slides/src/View/UI/SlideBar/SlideBar.tsx b/packages/base-slides/src/View/UI/SlideBar/SlideBar.tsxdeleted file mode 100644index 5e3648bbaa..0000000000--- a/packages/base-slides/src/View/UI/SlideBar/SlideBar.tsx+++ /dev/null@@ -1,93 +0,0 @@-import { BaseComponentRender, BaseComponentSheet, Component, createRef } from '@univerjs/base-ui';-import { PLUGIN_NAMES, ISlidePage } from '@univerjs/core';-import styles from './index.module.less';--interface SlideBarState {- slideList: ISlidePage[];- activePageId?: string;-}--interface IProps {- addSlide: () => void;-}--export class SlideBar extends Component<IProps, SlideBarState> {- private _render: BaseComponentRender;-- slideBarRef = createRef<HTMLDivElement>();-- initialize() {- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this._render = component.getComponentRender();-- this.state = {- slideList: [],- };- }-- componentDidMount() {- this._context.getObserverManager().getObserver<SlideBar>('onSlideBarDidMountObservable', PLUGIN_NAMES.SLIDE)?.notifyObservers(this);- }-- isActive(pageId: string, index: number = 0) {- if (this.state.activePageId == null && index == 0) {- return styles.slideBarItemActive;- } else if (this.state.activePageId === pageId) {- return styles.slideBarItemActive;- }- return '';- }-- setSlide(slideList: ISlidePage[]) {- this.setState({- slideList,- });- }-- handleClick(pageId: string, index: number) {- // const item = this.slideBarRef.current?.querySelectorAll(`.${styles.slideBarItem}`);- // if (item == null) {- // return;- // }- // for (let i = 0; i < item.length; i++) {- // item[i].classList.remove(styles.slideBarItemActive);- // }- // item[index].classList.add(styles.slideBarItemActive);-- if (this.state.activePageId === pageId) {- return;- }-- this.setState({- activePageId: pageId,- });-- this._context.getObserverManager().getObserver<string>('onSlideBarMousedownObservable', PLUGIN_NAMES.SLIDE)?.notifyObservers(pageId);- }-- render() {- const Button = this._render.renderFunction('Button');- const { addSlide } = this.props;- const { slideList } = this.state;-- return (- <div className={styles.slideBar} ref={this.slideBarRef}>- <div className={styles.slideBarContent}>- {slideList.map((item, index) => {- return (- <div className={`${styles.slideBarItem} ${this.isActive(item.id, index)}`} onClick={() => this.handleClick(item.id, index)}>- <span>{index + 1}</span>- <div className={styles.slideBarBox}></div>- </div>- );- })}- </div>- <div className={styles.slideAddButton}>- <Button type="text" onClick={addSlide}>- +- </Button>- </div>- </div>- );- }-}diff --git a/packages/base-slides/src/View/UI/SlideBar/index.module.css b/packages/base-slides/src/View/UI/SlideBar/index.module.cssdeleted file mode 100644index 21032e6cfa..0000000000--- a/packages/base-slides/src/View/UI/SlideBar/index.module.css+++ /dev/null@@ -1,54 +0,0 @@-.slide-bar {- height: 100%;- display: flex;- flex-direction: column;- border-right: 1px solid #eaecf0;- background: #f5f7f9;-}-.slide-bar .slide-bar-content {- height: 100%;- padding: 0 15px;- overflow: auto;-}-.slide-bar .slide-bar-content::-webkit-scrollbar {- width: 5px;-}-.slide-bar .slide-bar-content::-webkit-scrollbar-thumb {- border-radius: 5px;- background: #eaecf0;-}-.slide-bar .slide-bar-content::-webkit-scrollbar-track {- background: #f5f7f9;-}-.slide-bar .slide-bar-content .slide-bar-item {- display: flex;- margin: 10px 0;-}-.slide-bar .slide-bar-content .slide-bar-item span {- font-size: 12px;- width: 15px;-}-.slide-bar .slide-bar-content .slide-bar-item .slide-bar-box {- margin-left: 5px;- width: 100%;- height: 150px;- background: #fff;- border: 2px solid #c0c0c0;-}-.slide-bar .slide-bar-content .slide-bar-item-active span {- color: #d66a2b;-}-.slide-bar .slide-bar-content .slide-bar-item-active .slide-bar-box {- border: 2px solid #d66a2b;-}-.slide-bar .slide-add-button {- padding: 10px 0;- text-align: center;-}-.slide-bar .slide-add-button button {- line-height: 1;- font-size: 24px;- height: auto;- width: 45px;- border-radius: 10px;-}diff --git a/packages/base-slides/src/View/UI/SlideContainer/SlideContainer.tsx b/packages/base-slides/src/View/UI/SlideContainer/SlideContainer.tsxdeleted file mode 100644index 5458f2bcb6..0000000000--- a/packages/base-slides/src/View/UI/SlideContainer/SlideContainer.tsx+++ /dev/null@@ -1,745 +0,0 @@-import {- AppContext,- IMainProps,- IMainState,- ISiderState,- ISlotElement,- ISlotProps,- Component,- BaseComponentSheet,- BaseComponentRender,- createRef,- RefObject,- cloneElement,- BaseComponentProps,- Description,-} from '@univerjs/base-ui';-import { AsyncFunction, SlideContext, IKeyType, LocaleType, PLUGIN_NAMES, Tools, Workbook } from '@univerjs/core';-import cssVars from 'css-vars-ponyfill';-import { Container, Content, Footer, Header, Layout, Sider } from '@univerjs/style-univer';-import defaultSkin from '@univerjs/style-univer/assets/css/skin/default.module.less';-import darkSkin from '@univerjs/style-univer/assets/css/skin/dark.module.less';-// All skins' less file-import greenSkin from '@univerjs/style-univer/assets/css/skin/green.module.less';-// app context for skin and Locale-import style from './index.module.less';-import { Toolbar } from '../Toolbar';-import { SlidePlugin } from '../../../SlidePlugin';-import { InfoBar } from '../InfoBar';-import { SlideBar } from '../SlideBar/SlideBar';--export interface ISlidePluginConfigBase {- layout: ILayout;-}--interface IShowToolbarConfig {- undoRedo?: boolean; // Undo redo- paintFormat?: boolean; // Format brush- currencyFormat?: boolean; // currency format- percentageFormat?: boolean; // Percentage format- numberDecrease?: boolean; // 'Decrease the number of decimal places'- numberIncrease?: boolean; // 'Increase the number of decimal places- moreFormats?: boolean; // 'More Formats'- font?: boolean; // 'font'- fontSize?: boolean; // 'Font size'- bold?: boolean; // 'Bold (Ctrl+B)'- italic?: boolean; // 'Italic (Ctrl+I)'- strikethrough?: boolean; // 'Strikethrough (Alt+Shift+5)'- underline?: boolean; // 'Underline (Alt+Shift+6)'- textColor?: boolean; // 'Text color'- fillColor?: boolean; // 'Cell color'- border?: boolean; // 'border'- mergeCell?: boolean; // 'Merge cells'- horizontalAlignMode?: boolean; // 'Horizontal alignment'- verticalAlignMode?: boolean; // 'Vertical alignment'- textWrapMode?: boolean; // 'Wrap mode'- textRotateMode?: boolean; // 'Text Rotation Mode'-- image?: boolean; // 'Insert picture'- link?: boolean; // 'Insert link'- chart?: boolean; // 'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)- comment?: boolean; // 'comment'- pivotTable?: boolean; // 'PivotTable'- function?: boolean; // 'formula'- frozenMode?: boolean; // 'freeze mode'- sortAndFilter?: boolean; // 'Sort and filter'- conditionalFormat?: boolean; // 'Conditional Format'- dataValidation?: boolean; // 'Data Validation'- splitColumn?: boolean; // 'Split column'- screenshot?: boolean; // 'screenshot'- findAndReplace?: boolean; // 'Find and Replace'- protection?: boolean; // 'Worksheet protection'- print?: boolean; // 'Print'-}--export interface ILayout {- outerLeft?: boolean;-- outerRight?: boolean;-- header?: boolean;-- footer?: boolean;-- innerLeft?: boolean;-- innerRight?: boolean;-- frozenHeaderLT?: boolean;-- frozenHeaderRT?: boolean;-- frozenHeaderLM?: boolean;-- frozenContent?: boolean;-- infoBar?: boolean;-- // Whether to show the toolbar- toolbar?: boolean;-- // Custom configuration toolbar,can be used in conjunction with showToolbar, showToolbarConfig has a higher priority- toolbarConfig?: IShowToolbarConfig;-- /**- * 左右或者上下分割content区域- *- * undefined: no split- * false: no split- * true: horizontal split- * "horizontal": horizontal split- * "vertical": vertical split- */-- contentSplit?: boolean | string;-}--export interface ISlidePluginConfigBase {- layout: ILayout;-}--export interface BaseSlideContainerConfig extends BaseComponentProps, ISlidePluginConfigBase {- container: HTMLElement;- skin: string;- context: SlideContext;- getSplitLeftRef: (ref: RefObject<HTMLDivElement>) => void;- getContentRef: (ref: RefObject<HTMLDivElement>) => void;- addButton: (cb: Function) => void;- addSider: (cb: AsyncFunction<ISlotProps>) => void;- addMain: (cb: Function) => void;- showSiderByName: (cb: Function) => void;- showMainByName: (cb: Function) => void;- onDidMount: () => void;-}--export interface BaseSlideContainerProps {- config: BaseSlideContainerConfig;-}--export const defaultLayout: ILayout = {- outerLeft: false,-- outerRight: true,-- header: true,-- footer: true,-- innerLeft: false,-- innerRight: false,-- frozenHeaderLT: true,-- frozenHeaderRT: true,-- frozenHeaderLM: true,-- frozenContent: true,-- infoBar: true,-- toolbar: true,-- toolbarConfig: {- undoRedo: true, // Undo redo- paintFormat: true, // Format brush- currencyFormat: true, // currency format- percentageFormat: true, // Percentage format- numberDecrease: true, // 'Decrease the number of decimal places'- numberIncrease: true, // 'Increase the number of decimal places- moreFormats: true, // 'More Formats'- font: true, // 'font'- fontSize: true, // 'Font size'- bold: true, // 'Bold (Ctrl+B)'- italic: true, // 'Italic (Ctrl+I)'- strikethrough: true, // 'Strikethrough (Alt+Shift+5)'- underline: true, // 'Underline (Alt+Shift+6)'- textColor: true, // 'Text color'- fillColor: true, // 'Cell color'- border: true, // 'border'- mergeCell: true, // 'Merge cells'- horizontalAlignMode: true, // 'Horizontal alignment'- verticalAlignMode: true, // 'Vertical alignment'- textWrapMode: true, // 'Wrap mode'- textRotateMode: true, // 'Text Rotation Mode'- image: true, // 'Insert picture'- link: true, // 'Insert link'- chart: true, // 'chart' (the icon is hidden, but if the chart plugin is configured, you can still create a new chart by right click)- comment: true, // 'comment'- pivotTable: true, // 'PivotTable'- function: true, // 'formula'- frozenMode: true, // 'freeze mode'- sortAndFilter: true, // 'Sort and filter'- conditionalFormat: true, // 'Conditional Format'- dataValidation: true, // 'Data Validation'- splitColumn: true, // 'Split column'- screenshot: true, // 'screenshot'- findAndReplace: true, // 'Find and Replace'- protection: true, // 'Worksheet protection'- print: true, // 'Print'- },-- contentSplit: false,-};--/**- * SlideContainer- */--// Types for state-type IState = {- layout: ILayout;- currentLocale: string;- currentSkin: string;- printVisible: boolean;- isCellEditorVisible: boolean;- siderPanelList: ISiderState[];- mainList: IMainState[];- showSider: boolean;- renderState: number;-};--/**- * One universheet instance DOM container- */-export class SlideContainer extends Component<BaseSlideContainerProps, IState> {- splitLeftRef = createRef<HTMLDivElement>();-- rightRef = createRef<HTMLDivElement>();-- menuRef = createRef();-- cellRightRef = createRef<HTMLDivElement>();-- btnRef = createRef<HTMLButtonElement>();-- contentRef = createRef<HTMLDivElement>();-- layoutContainerRef = createRef<HTMLDivElement>();-- containerRef = createRef<HTMLDivElement>();-- refMap: IKeyType<RefObject<HTMLElement> | any> = {};-- leftContentLeft: number;-- leftContentTop: number;-- rightBorderX: number;-- rightBorderY: number;-- Render: BaseComponentRender;-- constructor(props: BaseSlideContainerProps) {- super(props, { coreContext: props.config.context });-- const { container, skin, layout, context, addSider, addMain, showSiderByName, showMainByName } = props.config;-- addSider(this.addSider.bind(this));- addMain(this.addMain.bind(this));- showSiderByName(this.showSiderByName.bind(this));- showMainByName(this.showMainByName.bind(this));-- const component = this._context.getPluginManager().getPluginByName<BaseComponentSheet>('ComponentSheet')!;- this.Render = component.getComponentRender();-- this.setSkin(container, skin);-- // init state- this.state = {- layout:- layout === 'auto'- ? Tools.deepClone(defaultLayout) // The defaultLayout must be cloned, otherwise the layout object will be referenced in multiple instances- : Tools.deepMerge(defaultLayout, layout),- currentLocale: context.getLocale().options.currentLocale,- currentSkin: skin,- printVisible: true,- isCellEditorVisible: false,- siderPanelList: [],- mainList: [],- showSider: false,- renderState: 0,- };- }-- setSkin(container: HTMLElement, skin: string) {- // Collect all skins- let root = document.documentElement;-- // get all skins- const skins = {- default: defaultSkin,- dark: darkSkin,- green: greenSkin,- };-- // current skin set by user- let currentSkin = skins[skin];-- // transform "primaryColor" to "--primary-color"- currentSkin = Object.fromEntries(Object.keys(currentSkin).map((item) => [`--${item.replace(/([A-Z])/g, '-$1').toLowerCase()}`, currentSkin[item]]));-- // ie11 does not support css variables, use css-vars-ponyfill to handle- if (Tools.isIEBrowser()) {- cssVars({- // Options...-- // The container is invalid as rootElement, so the default setting is root.- // Disadvantages: In ie11, only one set of skins can be used for multiple workbooks, and it is the skin set by the last workbook- rootElement: root, // default-- variables: currentSkin,- });- } else {- // set css variable-- let sheet = getSkinStyleSheet(container.id);-- /**- * covert object to style, remove " and replace , to ;- *- * Example:- *- * before: {--primary-color:"#0188fb",--primary-color-hover:"#5391ff"}- * after: {--primary-color:#0188fb;--primary-color-hover:#5391ff;}- */-- sheet.insertRule(- `#${container.id} ${JSON.stringify(currentSkin)- .replace(/"/g, '')- .replace(/,(?=--)/g, ';')}`- );- }-- /**- * get skin style sheet- * @param id- * @returns- */-- function getSkinStyleSheet(id: string) {- const title = 'universheet-skin-style';- // avoid duplicates- for (let i = 0; i < document.styleSheets.length; i++) {- if (document.styleSheets[i].title === title) {- deleteStyleRuleIndexBySelector(document.styleSheets[i], id);-- return document.styleSheets[i];- }- }- const head = document.head || document.getElementsByTagName('head')[0];- const styleEle = document.createElement('style');- styleEle.title = title;- head.appendChild(styleEle);-- return document.styleSheets[document.styleSheets.length - 1];- }-- /**- * delete style rule in universheet-skin-style- * @param skinStyleSheet- * @param id- */- function deleteStyleRuleIndexBySelector(skinStyleSheet: CSSStyleSheet, id: string) {- let index = 0;- for (let i = 0; i < skinStyleSheet.cssRules.length; i++) {- const rule = skinStyleSheet.cssRules[i];-- if (rule instanceof CSSStyleRule && rule.selectorText === `#${id}`) {- index = i;- skinStyleSheet.deleteRule(index);- break;- }- }- }- }-- /**- * 右键菜单- */- // rightMenu = (e: MouseEvent) => {- // e.preventDefault();-- // this.rightRef.current && (this.rightRef.current as unknown as RightMenu).handleContextMenu(e);- // };-- /**- * resize split content- */- resizeSplitContent = () => {};-- /**- * split mouse down- * @param e- */- handleSplitBarMouseDown = (e: MouseEvent) => {- e = e || window.event; // Compatible with IE browser-- // Store the current mouse position-- this.leftContentLeft = this.splitLeftRef.current?.getBoundingClientRect().left!;- this.leftContentTop = this.splitLeftRef.current?.getBoundingClientRect().top!;-- const mainContainer = this.splitLeftRef.current?.parentElement;- this.rightBorderX = mainContainer?.getBoundingClientRect()?.width!;- this.rightBorderY = mainContainer?.getBoundingClientRect()?.height!;-- document.addEventListener('mousemove', this.handleSplitBarMouseMove, false);- document.addEventListener('mouseup', this.handleSplitBarMouseUp, false);- };-- /**- * split mouse move- * @param e- */- handleSplitBarMouseMove = (e: MouseEvent) => {- e = e || window.event; // Compatible with IE browser-- let diffLeft = e.clientX - this.leftContentLeft;- let diffTop = e.clientY - this.leftContentTop;-- // Prevent crossing borders- diffLeft = diffLeft >= this.rightBorderX ? this.rightBorderX : diffLeft;- diffTop = diffTop >= this.rightBorderY ? this.rightBorderY : diffTop;-- // set new width- if (this.state.layout.contentSplit === 'vertical') {- this.splitLeftRef.current!.style.height = `${diffTop}px`;- } else {- this.splitLeftRef.current!.style.width = `${diffLeft}px`;- }- };-- /**- * split mouse up- * @param e- */- handleSplitBarMouseUp = (e: MouseEvent) => {- document.removeEventListener('mousemove', this.handleSplitBarMouseMove, false);- document.removeEventListener('mouseup', this.handleSplitBarMouseUp, false);- };-- /**- * click and double click- *- * @param e- */- handleContentClick = (e: MouseEvent) => {- // TODO: get observer from observeManager- // this._onInputObserver = engine.onInputChangedObservable.add((eventData: IEvent)=>{- // })- };-- /**- * add plugin sider panel- */- addSider(item: ISlotProps): Promise<void> {- /**- * There will be multiple plugin panel added, so you need to use prevState to add panel from the previous state, otherwise it will cause overwriting- */- return new Promise((resolve) => {- this.setState(- (prevState) => {- const stateItem = Object.assign(item, {- show: false,- zIndex: prevState.siderPanelList.length + 1,- });- return {- siderPanelList: [...prevState.siderPanelList, stateItem],- };- },- () => {- resolve();- }- );- });- }-- /**- * add plugin main area- */- addMain(item: IMainProps): Promise<void> {- /**- * There will be multiple plugin main added, so you need to use prevState to add panel from the previous state, otherwise it will cause overwriting- */- return new Promise((resolve) => {- this.setState(- (prevState) => {- const stateItem = Object.assign(item, {- show: false,- zIndex: prevState.mainList.length + 1,- });- return {- mainList: [...prevState.mainList, stateItem],- };- },- () => {- resolve();- }- );- });- }-- /**- *- * show or hide panel- *- * When you open two sidebars, you need to set the zIndex of the newly opened sidebar to the highest, so every time you open a sidebar, you need to recalculate the zIndex. For example, we already have 6 sidebars, this When the 3rd sidebar is opened- *- * 1 2 3 4 5 6- *- * Set 3 to 6, then rearrange the order after 3 to 3, 4, 5, and get- *- * 1 2 6 3 4 5- */- showSiderByName(name: string, show: boolean): Promise<void> {- /**- * There will be multiple plugin panel added, so you need to use prevState to add panel from the previous state, otherwise it will cause overwriting- */- return new Promise((resolve) => {- this.setState(- (prevState) => {- let showSider = false;-- let currentZIndex = 0;- let zIndexList = prevState.siderPanelList.map((item) => {- if (item.name === name) {- currentZIndex = item.zIndex;- }- return item.zIndex;- });-- const nextState = prevState.siderPanelList.map((item) => {- // Set according to user needs- if (item.name === name) {- item.show = show;- item.zIndex = Math.max(...zIndexList);- } else if (item.zIndex > currentZIndex) {- item.zIndex--;- }-- // As long as there is a panel to be displayed, display the container- if (item.show) {- showSider = true;- }- return item;- });-- return {- siderPanelList: nextState,- showSider,- };- },- () => {- resolve();- }- );- });- }-- /**- * show or hide main- */- showMainByName(name: string, show: boolean): Promise<void> {- /**- * There will be multiple plugin panel added, so you need to use prevState to add panel from the previous state, otherwise it will cause overwriting- */- return new Promise((resolve) => {- this.setState(- (prevState) => {- const nextState = prevState.mainList.map((item) => {- // Set according to user needs- if (item.name === name) {- item.show = show;- }-- return item;- });-- return {- mainList: nextState,- };- },- () => {- resolve();- }- );- });- }-- /**- * destroy- */- componentWillUnmount() {}-- componentDidMount() {- // mount can- this.props.config.getSplitLeftRef(this.splitLeftRef);- // mount canvas- this.props.config.getContentRef(this.contentRef);-- this.props.config.onDidMount();-- this.setState(- (preState) => ({- ...preState,- renderState: 1,- }),- () => {- // After the mount is successful, an observe is issued to notify other plug-ins that they can start using dom- this.getContext()- .getPluginManager()- .getRequirePluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE)- .getObserver('onSlideContainerDidMountObservable')- ?.notifyObservers(this);- }- );-- // this.initEvent();- }-- addSlide() {- this.getContext().getPluginManager().getRequirePluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE).getSlideBarControl().addSlide();- }-- /**- * Render the component's HTML- *- * @returns {void}- */- render() {- const { addButton, context } = this.props.config;- const { layout, currentLocale, currentSkin, siderPanelList, mainList, showSider, renderState } = this.state;-- // Set Provider for entire Container- return (- <AppContext.Provider- value={{- locale: context.getLocale(),- currentLocale: context.getLocale().options.currentLocale,- coreContext: context,- }}- >- <Container ref={this.layoutContainerRef} className={style.layoutContainer}>- <Layout>- <Sider style={{ display: layout.outerLeft ? 'block' : 'none' }}></Sider>- <Layout className={style.mainContent} style={{ position: 'relative' }}>- <Header style={{ display: layout.header ? 'block' : 'none' }}>- {layout.infoBar && <InfoBar></InfoBar>}- {layout.toolbar && <Toolbar toolList={[]}></Toolbar>}- </Header>- <Layout>- <Sider- style={{- width: '300px',- display: layout.innerLeft ? 'block' : 'none',- }}- >- <SlideBar addSlide={this.addSlide.bind(this)}></SlideBar>- </Sider>- <Content className={layout.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>- {/* extend main content */}- {mainList.map((item: IMainState, i) => {- // if (!item.show) return null;-- if (item.type === ISlotElement.JSX) {- // return item.content;- return cloneElement(item.content as JSX.Element, {- style: { display: item.show ? '' : 'none' },- });- }- if (item.type === ISlotElement.JSX_STRING) {- // if (item.content === 'RichText') {- // const RichText = this.Render.renderFunction('RichText');- // return <RichText />;- // }- const JSXElement = this.Render.renderFunction(item.content as keyof Description);- this.refMap[item.name] = createRef<HTMLDivElement>();- return <JSXElement ref={this.refMap[item.name]} style={{ display: item.show ? '' : 'none' }} />;- }- return item;- })}-- {!!layout.contentSplit && (- <Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>- <div className={style.hoverCursor} onMouseDown={this.handleSplitBarMouseDown}></div>- </Container>- )}- <Container ref={this.contentRef} className={style.contentInnerRightContainer} onClick={this.handleContentClick}>- {/* <div style={{ position: 'fixed', right: '200px', top: '10px', fontSize: '14px' }}>- <span style={{ display: 'inline-block', width: 50, margin: '5px 0 0 5px' }}>皮肤</span>- <select value={currentSkin} onChange={this.changeSkin.bind(this)} style={{ width: 55 }}>- <option value="default">默认</option>- <option value="dark">暗黑</option>- <option value="green">绿色</option>- </select>-- <span style={{ display: 'inline-block', width: 50, margin: '5px 0 0 5px' }}>语言</span>-- <select value={currentLocale} onChange={this.changeLocale.bind(this)} style={{ width: 55 }}>- <option value="en">English</option>- <option value="zh">中文</option>- </select>-- <span style={{ visibility: 'hidden' }}>{renderState}</span>- </div> */}- </Container>- </Content>- <Sider- style={{- display: layout.innerRight ? 'block' : 'none',- }}- >- {/* innerRight */}- </Sider>- </Layout>- <Footer- style={{- display: layout.footer ? 'block' : 'none',- }}- ></Footer>- </Layout>- <Sider- style={{- display: layout.outerRight && showSider ? 'block' : 'none',- }}- className={style.outerRightContainer}- >- {siderPanelList.map((item: ISiderState, i) => {- if (item.type === ISlotElement.JSX) {- // return item.content;- return cloneElement(item.label as JSX.Element, {- style: { display: item.show ? '' : 'none', zIndex: item.zIndex },- });- }- return item;- })}- </Sider>- </Layout>- </Container>- </AppContext.Provider>- );- }-}diff --git a/packages/base-slides/src/View/UI/ToolBar/SingleButton.tsx b/packages/base-slides/src/View/UI/ToolBar/SingleButton.tsxdeleted file mode 100644index 561380bec7..0000000000--- a/packages/base-slides/src/View/UI/ToolBar/SingleButton.tsx+++ /dev/null@@ -1,68 +0,0 @@-import { BaseSingleButtonProps, Component, JSXComponent, SingleButtonComponent } from '@univerjs/base-ui';-import { Button, Tooltip } from '@univerjs/style-univer';--import styles from './index.module.less';--export interface SingleButtonProps {- label?: string | JSX.Element;- icon?: JSX.Element | string | null | undefined;- tooltip?: string;- name?: string;- key?: string;- onClick?: (...arg: any[]) => void;- active?: boolean;- triggerUpdate?: (func: Function) => void;-}-export interface IState {- active: boolean;-}--class SingleButton extends Component<SingleButtonProps, IState> {- initialize(props: SingleButtonProps): void {- // Mount update function, when updating the selection range, the cell formats corresponding to different ranges are different, and the toolbar status and values need to be updated in real time- const { triggerUpdate, active } = props;- triggerUpdate && triggerUpdate(this.update.bind(this));-- this.state = {- active: active || false,- };- }-- update(active: boolean) {- this.setState({ active });- }-- onClick() {- this.setState(- (prevState: IState) => ({- active: !prevState.active,- }),- () => {- this.props.onClick && this.props.onClick(this.state.active);- }- );- }-- render() {- const { name, tooltip, label, icon, onClick, key } = this.props;- const { active } = this.state;- return (- <div className={styles.singleButton} key={key}>- <Tooltip title={tooltip!} placement={'bottom'}>- <Button type="text" onClick={() => this.onClick()} active={active}>- {label}- {icon}- </Button>- </Tooltip>- </div>- );- }-}--export class UniverSingleButton implements SingleButtonComponent {- render(): JSXComponent<BaseSingleButtonProps> {- return SingleButton;- }-}--export { SingleButton };diff --git a/packages/base-slides/src/View/UI/ToolBar/Toolbar.tsx b/packages/base-slides/src/View/UI/ToolBar/Toolbar.tsxdeleted file mode 100644index 3d3f5659e3..0000000000--- a/packages/base-slides/src/View/UI/ToolBar/Toolbar.tsx+++ /dev/null@@ -1,170 +0,0 @@-import { BaseComponentProps, BaseComponentRender, BaseComponentSheet, Component, createRef } from '@univerjs/base-ui';--import { PLUGIN_NAMES } from '@univerjs/core';-import { SlidePlugin } from '../../../SlidePlugin';-import { IToolbarItemProps } from '../../../Model/ToolbarModel';-import { TextButton } from '../Common/TextButton/TextButton';-import styles from './index.module.less';-import { Select } from '../Common/Select/Select';--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 Toolbar 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);- };-- resetLabel = (toolList: any[]) => {- const plugin = this._context.getPluginManager().getPluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE);-- for (let i = 0; i < toolList.length; i++) {- const item = toolList[i];-- // 优先寻找自定义组件- if (item.customLabel) {- const Label = plugin?.getRegisterComponent(item.customLabel.name);- if (Label) {- const props = item.customLabel.props ?? {};- item.label = <Label {...props} />;- }- }-- if (item.customSuffix) {- const Suffix = plugin?.getRegisterComponent(item.customSuffix.name);- if (Suffix) {- const props = item.customSuffix.props ?? {};- item.suffix = <Suffix {...props} />;- }- }-- if (item.children) {- item.children = this.resetLabel(item.children);- }- }- return toolList;- };-- setToolbar = (toolList: any[]) => {- toolList = this.resetLabel(toolList);-- this.setState({- toolList,- });- };-- componentDidMount() {- this._context.getObserverManager().getObserver<Toolbar>('onToolbarDidMountObservable')?.notifyObservers(this);- }-- render(props: IProps, state: IState) {- const { toolList } = 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}>- {toolList.map((item) => {- if (item.toolbarType) {- return (- <Tooltip title={item.tooltip} placement={'bottom'}>- <TextButton label={item.label} onClick={item.onClick}></TextButton>- </Tooltip>- );- }- return (- <Select- tooltip={item.tooltip}- type={item.type}- display={item.display}- children={item.children}- customLabel={item.customLabel}- customSuffix={item.customSuffix}- label={item.label}- onClick={item.onClick}- onKeyUp={item.onKeyUp}- defaultColor={item.defaultColor}- hideSelectedIcon={item.hideSelectedIcon}- selectClassName={item.selectClassName}- ></Select>- );- })}- </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-slides/src/View/UI/ToolBar/index.ts b/packages/base-slides/src/View/UI/ToolBar/index.tsdeleted file mode 100644index 8b58103be2..0000000000--- a/packages/base-slides/src/View/UI/ToolBar/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from './Toolbar';-export * from './SingleButton';diff --git a/packages/base-slides/src/index.ts b/packages/base-slides/src/index.tsindex 441345842d..f147234d1d 100644--- a/packages/base-slides/src/index.ts+++ b/packages/base-slides/src/index.ts@@ -1,2 +1,3 @@export * from './SlidePlugin';+export * from './Controller';export * from './View/Render';diff --git a/packages/base-slides/src/main.tsx b/packages/base-slides/src/main.tsxdeleted file mode 100644index 51449995a6..0000000000--- a/packages/base-slides/src/main.tsx+++ /dev/null@@ -1,18 +0,0 @@-import { UniverSlide } from '@univerjs/core';-import { RenderEngine } from '@univerjs/base-render';--import { SlidePlugin } from './SlidePlugin';-import { DEFAULT_SLIDE_DATA } from '@univerjs/common-plugin-data';--const slidePluginConfig = {- container: 'universlide',- layout: {- innerLeft: true,- },-};-const univerSlideUp = UniverSlide.newInstance(DEFAULT_SLIDE_DATA);--univerSlideUp.installPlugin(new RenderEngine());-univerSlideUp.installPlugin(new UniverComponentSheet());--univerSlideUp.installPlugin(new SlidePlugin(slidePluginConfig));diff --git a/packages/base-slides/tsconfig.json b/packages/base-slides/tsconfig.jsonindex 7d1f34cc0a..96edb5d074 100644--- a/packages/base-slides/tsconfig.json+++ b/packages/base-slides/tsconfig.json@@ -34,5 +34,5 @@"include": ["src/**/*","test/**/*.test.(ts|tsx|js)"- ]+, "../ui-plugin-slides/src/View/SlideBar", "../ui-plugin-slides/src/Controller/SlideBarUIController.ts" ]}\ No newline at end of filediff --git a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.tsindex da1370aabf..ce7a2f226f 100644--- a/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts+++ b/packages/common-plugin-data/src/Docs/DEFAULT_DOCUMENT_DATA_EN.ts@@ -34,7 +34,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {},angle: 0,imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/gartner-tech-2022.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/gartner-tech-2022.png',},},layoutType: PositionedObjectLayoutType.WRAP_SQUARE,@@ -60,7 +60,7 @@ export const DEFAULT_DOCUMENT_DATA_EN: IDocumentData = {},angle: 0,imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/hype-cycle-for-emerging-tech-2022.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/hype-cycle-for-emerging-tech-2022.png',},},layoutType: PositionedObjectLayoutType.WRAP_SQUARE,diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page1.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page1.tsindex 83ea7c638d..d626ef9c1a 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page1.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page1.ts@@ -22,7 +22,7 @@ export const DEFAULT_FIRST_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/Picture1.jpg',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/Picture1.jpg',},},},diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page2.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page2.tsindex 7b44d96b80..4d64d69e77 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page2.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page2.ts@@ -22,7 +22,7 @@ export const DEFAULT_SECOND_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/Picture1.jpg',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/Picture1.jpg',},},},diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page3.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page3.tsindex 395896e9ff..c58bb480ff 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page3.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page3.ts@@ -51,7 +51,7 @@ export const DEFAULT_THIRD_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/title.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/title.png',},},},diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page4.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page4.tsindex 3e0c6bc19b..14e20d5246 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page4.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page4.ts@@ -52,7 +52,7 @@ export const DEFAULT_FORTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/title.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/title.png',},},},diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page5.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page5.tsindex 123fce0258..8f2a511a38 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page5.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page5.ts@@ -48,7 +48,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/title.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/title.png',},},},@@ -100,7 +100,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/P1.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/P1.png',},},},@@ -116,7 +116,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/P2.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/P2.png',},},},@@ -132,7 +132,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/P3.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/P3.png',},},},@@ -148,7 +148,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/P4.jpg',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/P4.jpg',},},},@@ -218,7 +218,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/icon1.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/icon1.png',},},},@@ -253,7 +253,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/icon2.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/icon2.png',},},},@@ -288,7 +288,7 @@ export const DEFAULT_FIFTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/icon3.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/icon3.png',},},},diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page6.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page6.tsindex 8803edf386..c35934052f 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page6.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page6.ts@@ -49,7 +49,7 @@ export const DEFAULT_SIXTH_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/title.png',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/title.png',},},},diff --git a/packages/common-plugin-data/src/Slides/DefaultPages/Page7.ts b/packages/common-plugin-data/src/Slides/DefaultPages/Page7.tsindex 15784dbc2a..a6a32af50f 100644--- a/packages/common-plugin-data/src/Slides/DefaultPages/Page7.ts+++ b/packages/common-plugin-data/src/Slides/DefaultPages/Page7.ts@@ -23,7 +23,7 @@ export const DEFAULT_SEVEN_PAGE = {type: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/Picture1.jpg',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/Picture1.jpg',},},},diff --git a/packages/common-plugin-data/src/Slides/UNLIMITED_SLIDE_DATA.ts b/packages/common-plugin-data/src/Slides/UNLIMITED_SLIDE_DATA.tsindex 92087f48f7..6a5fe9835f 100644--- a/packages/common-plugin-data/src/Slides/UNLIMITED_SLIDE_DATA.ts+++ b/packages/common-plugin-data/src/Slides/UNLIMITED_SLIDE_DATA.ts@@ -37,7 +37,7 @@ export function generateUnlimitedSlideData(ratio: number = 1, slideData?: ISlidetype: PageElementType.IMAGE,image: {imageProperties: {- contentUrl: 'https://minio.cnbabylon.com/univer/slide/Picture1.jpg',+ contentUrl: 'https://gcore.jsdelivr.net/gh/dream-num/static@main/univer/slide/Picture1.jpg',},},},diff --git a/packages/ui-plugin-sheets/src/Basics/Const/DefaultUniverSheetConfig.ts b/packages/ui-plugin-sheets/src/Basics/Const/DefaultUniverSheetConfig.tsindex dac496ab70..8ca69f0390 100644--- a/packages/ui-plugin-sheets/src/Basics/Const/DefaultUniverSheetConfig.ts+++ b/packages/ui-plugin-sheets/src/Basics/Const/DefaultUniverSheetConfig.ts@@ -62,7 +62,7 @@ export const DefaultSheetContainerConfig = {sheetBar: true,};-export const DefaultSheetUiConfig = {+export const DefaultSheetUIConfig = {layout: {sheetContainerConfig: DefaultSheetContainerConfig,rightMenuConfig: DefaultRightMenuConfig,diff --git a/packages/ui-plugin-sheets/src/Basics/index.ts b/packages/ui-plugin-sheets/src/Basics/index.tsindex 6e04e5205a..3490f957d5 100644--- a/packages/ui-plugin-sheets/src/Basics/index.ts+++ b/packages/ui-plugin-sheets/src/Basics/index.ts@@ -1,6 +1,4 @@export * from './Const';-export * from './Enum';export * from '../Locale';-export * from './Shared';export * from './Interfaces';export * from './Observer';diff --git a/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.ts b/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.tsindex 7ace5073ca..da8c581908 100644--- a/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/CellEditorUIController.ts@@ -25,7 +25,7 @@ export class CellEditorUIController {constructor(plugin: SheetUIPlugin) {this._plugin = plugin;- this._sheetPlugin = plugin.getUniver().getCurrentUniverSheetInstance().context.getPluginManager().getPluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET)!;+ this._sheetPlugin = plugin.getUniver().getCurrentUniverSheetInstance().context.getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET);this._initialize();}@@ -33,7 +33,7 @@ export class CellEditorUIController {// Get the RichText componentgetComponent = (ref: RichText) => {this._richText = ref;- this._initRichText();+ this.setRichText();};getCellEditor() {@@ -220,7 +220,7 @@ export class CellEditorUIController {// this._richTextEditEle}- private _initRichText() {+ private setRichText() {this._richTextEle = getRefElement(this._richText.container);this._richTextEditEle = $$('div', this._richTextEle);diff --git a/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.tsindex a16b09891d..de94487b21 100644--- a/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.ts@@ -26,7 +26,7 @@ export class FormulaBarUIController {getComponent = (ref: FormulaBar) => {this._formulaBar = ref;- this._initFormulaBar();+ this.setFormulaBar();};getFormulaBar() {@@ -88,7 +88,7 @@ export class FormulaBarUIController {// set NamedRange data}- private _initFormulaBar() {+ private setFormulaBar() {// update named ranges datathis._namedRanges = this._sheetPlugin.getContext().getWorkBook().getConfig().namedRanges;diff --git a/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.tsindex 4d3c31b97e..a46edd7ab4 100644--- a/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts@@ -1,5 +1,5 @@-import { Plugin } from '@univerjs/core';import { InfoBarModel } from '../Model/InfoBarModel';+import { SheetUIPlugin } from '../SheetUIPlugin';import { InfoBar } from '../View/InfoBar';type IProps = {@@ -21,11 +21,11 @@ export class InfoBarUIController {private _infoBar: InfoBar;- private _plugin: Plugin;+ private _plugin: SheetUIPlugin;private _infoList: BaseInfoBarProps;- constructor(plugin: Plugin) {+ constructor(plugin: SheetUIPlugin) {this._plugin = plugin;}@@ -36,7 +36,7 @@ export class InfoBarUIController {};resetInfoList(list: BaseInfoBarProps) {- const locale = this._plugin.getContext().getLocale();+ const locale = this._plugin.getGlobalContext().getLocale();for (let k in list) {if (list[k].locale) {list[k].label = locale.get(list[k].locale);diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.tsindex 07a5c6a57f..92afede1ca 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetBarUIContruller.ts@@ -235,6 +235,9 @@ export class SheetBarUIController {copySheet() {}+ /**+ * Arrow functions must be used to bind `this`, otherwise `this` will be lost when the DOM component triggers the callback+ */addSheet = (position?: string, config?: SheetUlProps): void => {this.setUIObserve('onUIChangeObservable', {name: 'addSheet',diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.tsindex 7d385c0789..ec0214acdf 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts+++ b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts@@ -59,7 +59,7 @@ export class SheetContainerUIController {getUIConfig() {const config = {- context: this._plugin.getContext(),+ context: this._plugin.getGlobalContext(),config: this._config,changeLocale: this.changeLocale,getComponent: this.getComponent,@@ -105,7 +105,7 @@ export class SheetContainerUIController {this._sheetContainer = ref;this._plugin.getObserver('onUIDidMount')?.notifyObservers(this._sheetContainer);- this._initSheetContainer();+ this.setSheetContainer();};/**@@ -169,7 +169,7 @@ export class SheetContainerUIController {this.setEventManager();}- private _initSheetContainer() {+ private setSheetContainer() {// handle drag eventthis._dragManager.handleDragAction(getRefElement(this._sheetContainer));}diff --git a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts b/packages/ui-plugin-sheets/src/SheetUIPlugin.tsindex 4023b23f5e..ccd4a64748 100644--- a/packages/ui-plugin-sheets/src/SheetUIPlugin.ts+++ b/packages/ui-plugin-sheets/src/SheetUIPlugin.ts@@ -1,7 +1,7 @@import { Plugin, UniverSheet, Tools, PLUGIN_NAMES, Context } from '@univerjs/core';import { ComponentManager, getRefElement, RegisterManager } from '@univerjs/base-ui';import { RenderEngine } from '@univerjs/base-render';-import { DefaultSheetUiConfig, installObserver, ISheetUIPluginConfig, SheetUIPluginObserve, SHEET_UI_PLUGIN_NAME } from './Basics';+import { DefaultSheetUIConfig, installObserver, ISheetUIPluginConfig, SheetUIPluginObserve, SHEET_UI_PLUGIN_NAME } from './Basics';import { zh, en } from './Locale';import { AppUIController } from './Controller/AppUIController';import { Fx } from './View/FormulaBar';@@ -19,7 +19,7 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {constructor(config?: ISheetUIPluginConfig) {super(SHEET_UI_PLUGIN_NAME);- this._config = Tools.deepMerge({}, DefaultSheetUiConfig, config);+ this._config = Tools.deepMerge({}, DefaultSheetUIConfig, config);}static create(config?: ISheetUIPluginConfig) {diff --git a/packages/ui-plugin-slides/src/Basics/Const/DefaultUniverSlideConfig.ts b/packages/ui-plugin-slides/src/Basics/Const/DefaultUniverSlideConfig.tsnew file mode 100644index 0000000000..782a76f76d--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Const/DefaultUniverSlideConfig.ts@@ -0,0 +1,46 @@+export const DefaultToolbarConfig = {+ undo: true,+ redo: true, // Undo redo+ paintFormat: true, // Format brush+ currencyFormat: true, // currency format+ percentageFormat: true, // Percentage format+ numberDecrease: true, // 'Decrease the number of decimal places'+ numberIncrease: true, // 'Increase the number of decimal places+ moreFormats: true, // 'More Formats'+ font: true, // 'font'+ fontSize: true, // 'Font size'+ bold: true, // 'Bold (Ctrl+B)'+ italic: true, // 'Italic (Ctrl+I)'+ strikethrough: true, // 'Strikethrough (Alt+Shift+5)'+ underline: true, // 'Underline (Alt+Shift+6)'+ textColor: true, // 'Text color'+ fillColor: true, // 'Cell color'+ border: true, // 'border'+ horizontalAlignMode: true, // 'Horizontal alignment'+ verticalAlignMode: true, // 'Vertical alignment'+ textWrapMode: true, // 'Wrap mode'+ textRotateMode: true, // 'Text Rotation Mode'+ mergeCell: true,+};++export const DefaultSlideContainerConfig = {+ outerLeft: false,+ outerRight: false,+ header: true,+ footer: true,+ innerLeft: false,+ innerRight: false,+ frozenHeaderLT: false,+ frozenHeaderRT: false,+ frozenHeaderLM: false,+ frozenContent: false,+ infoBar: true,+ toolbar: true,+};++export const DefaultSlideUIConfig = {+ layout: {+ slideContainerConfig: DefaultSlideContainerConfig,+ toolbarConfig: DefaultToolbarConfig,+ },+};diff --git a/packages/ui-plugin-slides/src/Basics/Const/index.ts b/packages/ui-plugin-slides/src/Basics/Const/index.tsindex 0dc96d927a..13b0e8028e 100644--- a/packages/ui-plugin-slides/src/Basics/Const/index.ts+++ b/packages/ui-plugin-slides/src/Basics/Const/index.ts@@ -1 +1,2 @@export * from './PLUGIN_NAME';+export * from './DefaultUniverSlideConfig';diff --git a/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/ISlideUIPluginConfig.ts b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/ISlideUIPluginConfig.tsnew file mode 100644index 0000000000..47ba7ee90b--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/ISlideUIPluginConfig.ts@@ -0,0 +1,14 @@+import { LocaleType } from '@univerjs/core';+import { SlideContainerConfig } from './SlideContainerConfig';+import { SlideToolbarConfig } from './ToolbarConfig';++export interface ILayout {+ slideContainerConfig?: SlideContainerConfig;+ toolbarConfig?: SlideToolbarConfig;+}++export interface ISlideUIPluginConfig {+ container?: HTMLElement | string;+ layout?: ILayout;+ locale?: LocaleType;+}diff --git a/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/SlideContainerConfig.ts b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/SlideContainerConfig.tsnew file mode 100644index 0000000000..6814da32df--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/SlideContainerConfig.ts@@ -0,0 +1,32 @@+export interface SlideContainerConfig {+ outerLeft?: boolean;++ outerRight?: boolean;++ header?: boolean;++ footer?: boolean;++ innerLeft?: boolean;++ innerRight?: boolean;++ frozenHeaderLT?: boolean;++ frozenHeaderRT?: boolean;++ frozenHeaderLM?: boolean;++ frozenContent?: boolean;++ infoBar?: boolean;++ countBar?: boolean;++ // Whether to show the toolbar+ toolbar?: boolean;++ rightMenu?: boolean;++ contentSplit?: boolean | string;+}diff --git a/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/ToolbarConfig.ts b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/ToolbarConfig.tsnew file mode 100644index 0000000000..3d818ef74e--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/ToolbarConfig.ts@@ -0,0 +1,25 @@+// sheet工具栏配置+export interface SlideToolbarConfig {+ undo?: boolean; // Undo redo+ redo?: boolean; // Undo redo+ paintFormat?: boolean; // Format brush+ currencyFormat?: boolean; // currency format+ percentageFormat?: boolean; // Percentage format+ numberDecrease?: boolean; // 'Decrease the number of decimal places'+ numberIncrease?: boolean; // 'Increase the number of decimal places+ font?: boolean; // 'font'+ moreFormats?: boolean;+ fontSize?: boolean; // 'Font size'+ bold?: boolean; // 'Bold (Ctrl+B)'+ italic?: boolean; // 'Italic (Ctrl+I)'+ strikethrough?: boolean; // 'Strikethrough (Alt+Shift+5)'+ underline?: boolean; // 'Underline (Alt+Shift+6)'+ textColor?: boolean; // 'Text color'+ fillColor?: boolean; // 'Cell color'+ border?: boolean; // 'border'+ horizontalAlignMode?: boolean; // 'Horizontal alignment'+ verticalAlignMode?: boolean; // 'Vertical alignment'+ textWrapMode?: boolean; // 'Wrap mode'+ textRotateMode?: boolean; // 'Text Rotation Mode'+ mergeCell?: boolean; // 'Merge cells'+}diff --git a/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/index.ts b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/index.tsnew file mode 100644index 0000000000..a269c2cb2b--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Interfaces/ComponentConfig/index.ts@@ -0,0 +1,2 @@+export * from './ToolbarConfig';+export * from './ISlideUIPluginConfig';diff --git a/packages/ui-plugin-slides/src/Basics/Interfaces/index.ts b/packages/ui-plugin-slides/src/Basics/Interfaces/index.tsnew file mode 100644index 0000000000..668cfd82a2--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Interfaces/index.ts@@ -0,0 +1 @@+export * from './ComponentConfig';diff --git a/packages/ui-plugin-slides/src/Basics/Observer.ts b/packages/ui-plugin-slides/src/Basics/Observer.tsnew file mode 100644index 0000000000..25d6512ac1--- /dev/null+++ b/packages/ui-plugin-slides/src/Basics/Observer.ts@@ -0,0 +1,15 @@+import { Observable } from '@univerjs/core';+import { SlideUIPlugin } from '../SlideUIPlugin';+import { SlideContainer } from '../View';++export type SlideUIPluginObserve = {+ onUIDidMount: Observable<SlideContainer>;+};++export function uninstallObserver(plugin: SlideUIPlugin) {+ plugin.deleteObserve('onUIDidMount');+}++export function installObserver(plugin: SlideUIPlugin) {+ plugin.pushToObserve('onUIDidMount');+}diff --git a/packages/ui-plugin-slides/src/Basics/index.ts b/packages/ui-plugin-slides/src/Basics/index.tsindex 640d1bb8b3..bf9df7cc55 100644--- a/packages/ui-plugin-slides/src/Basics/index.ts+++ b/packages/ui-plugin-slides/src/Basics/index.ts@@ -1,4 +1,3 @@export * from './Const';-export * from './Enum';-export * from '../Locale';-export * from './Shared';+export * from './Interfaces';+export * from './Observer';diff --git a/packages/ui-plugin-slides/src/Controller/AppUIController.ts b/packages/ui-plugin-slides/src/Controller/AppUIController.tsnew file mode 100644index 0000000000..f92032d77b--- /dev/null+++ b/packages/ui-plugin-slides/src/Controller/AppUIController.ts@@ -0,0 +1,47 @@+import { LocaleType } from '@univerjs/core';+import { SlideUIPlugin } from '../SlideUIPlugin';+import { UI } from '../View';+import { SlideContainerUIController } from './SlideContainerUIController';++export class AppUIController {+ protected _plugin: SlideUIPlugin;++ private _slideContainerController: SlideContainerUIController;++ constructor(plugin: SlideUIPlugin) {+ this._plugin = plugin;++ this._slideContainerController = new SlideContainerUIController(this._plugin);++ const UIConfig = this._slideContainerController.getUIConfig();++ UI.create({+ context: this._plugin.getGlobalContext(),+ locale: this._plugin.getGlobalContext().getLocale().getCurrentLocale(),+ changeLocale: this.changeLocale,+ UIConfig,+ container: this._plugin.getConfig().container,+ });+ }++ /**+ * Change language+ * @param {String} lang new language+ *+ * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771+ *+ */+ changeLocale = (locale: string) => {+ this._plugin+ .getGlobalContext()+ .getLocale()+ .change(locale as LocaleType);++ // publish+ this._plugin.getGlobalContext().getObserverManager().requiredObserver('onAfterChangeUILocaleObservable', 'core')!.notifyObservers();+ };++ getSlideContainerController() {+ return this._slideContainerController;+ }+}diff --git a/packages/ui-plugin-slides/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-slides/src/Controller/InfoBarUIController.tsnew file mode 100644index 0000000000..b0fc699f3a--- /dev/null+++ b/packages/ui-plugin-slides/src/Controller/InfoBarUIController.ts@@ -0,0 +1,79 @@+import { InfoBarModel } from '../Model/InfoBarModel';+import { SlideUIPlugin } from '../SlideUIPlugin';+import { InfoBar } from '../View/InfoBar';++type IProps = {+ locale?: string;+ label?: string;+ onBlur?: (e: FocusEvent) => void;+};++export interface BaseInfoBarProps {+ back: IProps;+ rename: IProps;+ save: IProps;+ slide: IProps;+ update: IProps;+}++export class InfoBarUIController {+ private _infoBarModel: InfoBarModel;++ private _infoBar: InfoBar;++ private _plugin: SlideUIPlugin;++ private _infoList: BaseInfoBarProps;++ constructor(plugin: SlideUIPlugin) {+ this._plugin = plugin;+ }++ getComponent = (ref: InfoBar) => {+ this._infoBar = ref;+ this._refreshComponent();+ this.resetInfoList(this._infoList);+ };++ resetInfoList(list: BaseInfoBarProps) {+ const locale = this._plugin.getGlobalContext().getLocale();+ for (let k in list) {+ if (list[k].locale) {+ list[k].label = locale.get(list[k].locale);+ }+ }+ this._infoBar.setInfoList(list);+ }++ setSlideName(e: FocusEvent) {+ const target = e.target as HTMLInputElement;+ const name = target.value;+ this._infoBarModel.setName(name);+ }++ private _refreshComponent(): void {+ const name = 'UniverSlide';+ // const name = this._plugin.getUniver().getCurrentUniverSlideInstance().getWorkBook().getConfig().name;+ this._infoBarModel = new InfoBarModel(name);+ this._infoList = {+ back: {+ locale: 'info.return',+ },+ rename: {+ locale: 'info.tips',+ },+ update: {+ locale: 'info.detailUpdate',+ },+ save: {+ locale: 'info.detailSave',+ },+ slide: {+ label: name,+ onBlur: (e) => {+ this.setSlideName(e);+ },+ },+ };+ }+}diff --git a/packages/ui-plugin-slides/src/Controller/SlideBarUIController.ts b/packages/ui-plugin-slides/src/Controller/SlideBarUIController.tsnew file mode 100644index 0000000000..6f0014eab8--- /dev/null+++ b/packages/ui-plugin-slides/src/Controller/SlideBarUIController.ts@@ -0,0 +1,89 @@+import { SlidePlugin } from '@univerjs/base-slides';+import { ISlidePage, PLUGIN_NAMES } from '@univerjs/core';+import { SlideUIPlugin } from '../SlideUIPlugin';+import { SlideBar } from '../View/SlideBar/SlideBar';++export class SlideBarUIController {+ private _plugin: SlideUIPlugin;++ private _slidePlugin: SlidePlugin;++ private _slideBar: SlideBar;++ private _pages: ISlidePage[] = [];++ constructor(plugin: SlideUIPlugin) {+ this._plugin = plugin;++ this._slidePlugin = plugin.getUniver().getCurrentUniverSlideInstance().context.getPluginManager().getRequirePluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE);++ this._initialize();+ }++ // 获取SlideBar组件+ getComponent = (ref: SlideBar) => {+ this._slideBar = ref;+ this.setSlideBar();+ };++ setSlideBar() {+ const canvasView = this._getCanvasView();+ this._slideBar.setSlide(this._pages, () => {+ const slideBarRef = this._slideBar.slideBarRef;+ const thumbList = slideBarRef.current?.childNodes[0].childNodes;+ canvasView.createSlidePages(thumbList, this._pages);+ });++ canvasView.getSlide().onSlideChangePageByNavigationObservable.add((pageId) => {+ if (this._slideBar.state.activePageId === pageId || pageId == null) {+ return;+ }+ this._slideBar.setState({+ activePageId: pageId,+ });+ canvasView.activePage(pageId);+ });+ }++ /**+ * Arrow functions must be used to bind `this`, otherwise `this` will be lost when the DOM component triggers the callback+ */+ addSlide = () => {+ const model = this._slidePlugin.getContext().getSlide();+ const canvasView = this._getCanvasView();+ const newPage = model.addPage();+ this._pages.push(newPage);++ this._slideBar.setSlide(this._pages, () => {+ const slideBarRef = this._slideBar.slideBarRef;+ const thumbList = slideBarRef.current?.childNodes[0].childNodes;+ canvasView.createSlidePages(thumbList, this._pages);+ });+ };++ activeSlide = (pageId: string) => {+ const canvasView = this._getCanvasView();+ canvasView.activePage(pageId);+ };++ private _initialize() {+ this._generateModel();+ }++ private _getCanvasView() {+ return this._slidePlugin.getCanvasView();+ }++ private _generateModel() {+ const model = this._slidePlugin.getContext().getSlide();+ const pages = model.getPages();+ const pageOrder = model.getPageOrder();+ if (!pages || !pageOrder) {+ return;+ }++ pageOrder.forEach((pageKey) => {+ this._pages.push(pages[pageKey]);+ });+ }+}diff --git a/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.ts b/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.tsnew file mode 100644index 0000000000..129eff1dc2--- /dev/null+++ b/packages/ui-plugin-slides/src/Controller/SlideContainerUIController.ts@@ -0,0 +1,128 @@+import { SlidePlugin } from '@univerjs/base-slides';+import { DragManager, EventManager, getRefElement } from '@univerjs/base-ui';+import { LocaleType, PLUGIN_NAMES, UniverSlide } from '@univerjs/core';+import { ISlideUIPluginConfig } from '../Basics';+import { SlideUIPlugin } from '../SlideUIPlugin';+import { SlideContainer } from '../View';+import { InfoBarUIController } from './InfoBarUIController';+import { SlideBarUIController } from './SlideBarUIController';+import { ToolbarUIController } from './ToolbarUIController';++export class SlideContainerUIController {+ protected _plugin: SlideUIPlugin;++ private _slideContainer: SlideContainer;++ private _toolbarController: ToolbarUIController;++ private _infoBarController: InfoBarUIController;++ private _slideBarController: SlideBarUIController;++ private _config: ISlideUIPluginConfig;++ private _dragManager: DragManager;++ private _eventManager: EventManager;++ constructor(plugin: SlideUIPlugin) {+ this._plugin = plugin;++ this._config = this._plugin.getConfig();++ this._initialize();++ this._toolbarController = new ToolbarUIController(this._plugin, this._config.layout?.toolbarConfig);++ this._infoBarController = new InfoBarUIController(this._plugin);++ this._slideBarController = new SlideBarUIController(this._plugin);+ }++ getUIConfig() {+ const config = {+ context: this._plugin.getContext(),+ config: this._config,+ changeLocale: this.changeLocale,+ getComponent: this.getComponent,+ // 其余组件的props+ methods: {+ toolbar: {+ getComponent: this._toolbarController.getComponent,+ },++ infoBar: {+ getComponent: this._infoBarController.getComponent,+ },+ slideBar: {+ getComponent: this._slideBarController.getComponent,+ addSlide: this._slideBarController.addSlide,+ activeSlide: this._slideBarController.activeSlide,+ },+ },+ };+ return config;+ }++ // 获取SlideContainer组件+ getComponent = (ref: SlideContainer) => {+ this._slideContainer = ref;+ this._plugin.getObserver('onUIDidMount')?.notifyObservers(this._slideContainer);++ this.setSlideContainer();+ };++ /**+ * Change language+ * @param {String} lang new language+ *+ * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771+ *+ */+ changeLocale = (locale: string) => {+ this._plugin+ .getContext()+ .getLocale()+ .change(locale as LocaleType);++ // publish+ this._plugin.getGlobalContext().getObserverManager().requiredObserver('onAfterChangeUILocaleObservable', 'core')!.notifyObservers();+ };++ getContentRef() {+ return this._slideContainer.getContentRef();+ }++ setEventManager() {+ const universlides = this._plugin.getUniver().getAllUniverSlidesInstance();+ universlides.forEach((universlide: UniverSlide) => {+ universlide.context.getPluginManager().getRequirePluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE).listenEventManager();+ });+ }++ getEventManager() {+ return this._eventManager;+ }++ getToolbarController() {+ return this._toolbarController;+ }++ UIDidMount(cb: Function) {+ if (this._slideContainer) return cb(this._slideContainer);++ this._plugin.getObserver('onUIDidMount')?.add(() => cb(this._slideContainer));+ }++ private _initialize() {+ this._dragManager = new DragManager(this._plugin);+ this._eventManager = new EventManager(this._plugin);++ this.setEventManager();+ }++ private setSlideContainer() {+ // handle drag event+ this._dragManager.handleDragAction(getRefElement(this._slideContainer));+ }+}diff --git a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.tsnew file mode 100644index 0000000000..1779930574--- /dev/null+++ b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts@@ -0,0 +1,635 @@+import { BorderInfo, SlidePlugin } from '@univerjs/base-slides';+import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';+import { BorderType, CommandManager, DEFAULT_STYLES, HorizontalAlign, IKeyValue, PLUGIN_NAMES, Tools, UIObserver, VerticalAlign, WrapStrategy } from '@univerjs/core';+import { SlideUIPlugin } from '..';+import { DefaultToolbarConfig, SlideToolbarConfig, SLIDE_UI_PLUGIN_NAME } from '../Basics';+import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';+import {+ FONT_FAMILY_CHILDREN,+ FONT_SIZE_CHILDREN,+ BORDER_LINE_CHILDREN,+ BORDER_SIZE_CHILDREN,+ MERGE_CHILDREN,+ HORIZONTAL_ALIGN_CHILDREN,+ VERTICAL_ALIGN_CHILDREN,+ TEXT_WRAP_CHILDREN,+ TEXT_ROTATE_CHILDREN,+} from '../View/Toolbar/Const';++import styles from '../View/Toolbar/index.module.less';++// 继承基础下拉属性,添加国际化+export interface BaseToolbarSelectChildrenProps extends BaseSelectChildrenProps {+ suffixLocale?: string;+ children?: BaseToolbarSelectChildrenProps[];+ labelLocale?: string;+}++export interface BaseToolbarSelectProps extends BaseSelectProps {+ suffixLocale?: string;+ children?: BaseToolbarSelectChildrenProps[];+}++enum ToolbarType {+ SELECT,+ BUTTON,+}++export interface IToolbarItemProps extends BaseToolbarSelectProps {+ active?: boolean;+ unActive?: boolean; //button不需保持状态+ show?: boolean; //是否显示按钮+ toolbarType?: ToolbarType;+ tooltip?: string; //tooltip文字+ border?: boolean;+ suffix?: ComponentChildren;+}++export class ToolbarUIController {+ private _plugin: SlideUIPlugin;++ private _slidePlugin: SlidePlugin;++ private _toolbar: Toolbar;++ private _toolList: IToolbarItemProps[];++ private _config: SlideToolbarConfig;++ private _lineColor: LineColor;++ private _lineBold: LineBold;++ private _colorSelect1: ColorSelect;++ private _textColor: string = '#000';++ private _colorSelect2: ColorSelect;++ private _background: string = '#fff';++ private _borderInfo: BorderInfo = {+ type: BorderType.ALL,+ color: '#000',+ style: 1,+ }; //存储边框信息++ constructor(plugin: SlideUIPlugin, config?: SlideToolbarConfig) {+ this._plugin = plugin;++ this._slidePlugin = plugin.getContext().getUniver().getCurrentUniverSlideInstance().context.getPluginManager().getPluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE)!;++ this._config = Tools.deepMerge({}, DefaultToolbarConfig, config);++ this._toolList = [+ {+ toolbarType: 1,+ tooltip: 'toolbar.undo',+ name: 'undo',+ unActive: true,+ customLabel: {+ name: 'ForwardIcon',+ },+ show: this._config.undo,+ onClick: () => {+ this.setUndo();+ this.hideTooltip();+ },+ },+ {+ toolbarType: 1,+ tooltip: 'toolbar.redo',+ unActive: true,+ customLabel: {+ name: 'BackIcon',+ },+ name: 'redo',+ show: this._config.redo,+ onClick: () => {+ this.setRedo();+ this.hideTooltip();+ },+ },+ {+ type: 0,+ tooltip: 'toolbar.font',+ className: styles.selectLabelString,+ name: 'font',+ show: this._config.font,+ border: true,+ onMainClick: () => {+ this.hideTooltip();+ },+ onClick: (fontFamily: string) => {+ this.setFontFamily(fontFamily);+ },+ children: FONT_FAMILY_CHILDREN,+ },+ {+ type: 1,+ tooltip: 'toolbar.fontSize',+ label: String(DEFAULT_STYLES.fs),+ name: 'fontSize',+ show: this._config.fontSize,+ onClick: (fontSize: number) => {+ this.setFontSize(fontSize);+ },+ onMainClick: () => {+ this.hideTooltip();+ },+ onPressEnter: (fontSize: number) => {+ this.setFontSize(fontSize);+ this.hideTooltip();+ },+ children: FONT_SIZE_CHILDREN,+ },+ {+ toolbarType: 1,+ tooltip: 'toolbar.bold',+ customLabel: {+ name: 'BoldIcon',+ },+ active: false,+ name: 'bold',+ show: this._config.bold,+ onClick: (e, isBold: boolean) => {+ this.setFontWeight(isBold);+ this.hideTooltip();+ },+ },+ {+ toolbarType: 1,+ tooltip: 'toolbar.italic',+ customLabel: {+ name: 'ItalicIcon',+ },+ name: 'italic',+ show: this._config.italic,+ onClick: (e, isItalic: boolean) => {+ this.setFontStyle(isItalic);+ this.hideTooltip();+ },+ },+ {+ toolbarType: 1,+ tooltip: 'toolbar.strikethrough',+ customLabel: {+ name: 'DeleteLineIcon',+ },+ name: 'strikethrough',+ show: this._config.strikethrough,+ onClick: (e, isStrikethrough: boolean) => {+ this.hideTooltip();+ const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');+ if (!strikethroughItem) return;+ strikethroughItem.active = isStrikethrough;+ this.setStrikeThrough(isStrikethrough);+ },+ },+ {+ toolbarType: 1,+ tooltip: 'toolbar.underline',+ customLabel: {+ name: 'UnderLineIcon',+ },+ name: 'underline',+ show: this._config.underline,+ onClick: (e, isUnderLine: boolean) => {+ this.hideTooltip();+ const underlineItem = this._toolList.find((item) => item.name === 'underline');+ if (!underlineItem) return;+ underlineItem.active = isUnderLine;+ this.setUnderline(isUnderLine);+ },+ },+ {+ type: 5,+ tooltip: 'toolbar.textColor.main',+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + ColorSelect.name,+ props: {+ getComponent: (ref: ColorSelect) => {+ this._colorSelect1 = ref;+ },+ color: '#000',+ customLabel: {+ name: 'TextColorIcon',+ },+ },+ },+ onClick: () => {+ this.hideTooltip();+ const textColor = this._toolList.find((item) => item.name === 'textColor');+ if (!textColor) return;+ if (!textColor.customLabel) return;+ if (!textColor.customLabel.props) return;+ textColor.customLabel.props.color = this._textColor;+ this.changeColor(this._textColor);+ },+ hideSelectedIcon: true,+ className: styles.selectColorPickerParent,+ children: [+ {+ labelLocale: 'toolbar.resetColor',+ },+ {+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,+ props: {+ onClick: (color: string, e: MouseEvent) => {+ this._colorSelect1.setColor(color);+ this._textColor = color;+ },+ },+ },+ className: styles.selectColorPicker,+ },+ ],+ name: 'textColor',+ show: this._config.textColor,+ },+ {+ type: 5,+ tooltip: 'toolbar.fillColor.main',+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + ColorSelect.name,+ props: {+ getComponent: (ref: ColorSelect) => {+ this._colorSelect2 = ref;+ },+ color: '#fff',+ customLabel: {+ name: 'FillColorIcon',+ },+ },+ },+ onClick: () => {+ this.hideTooltip();+ const fillColor = this._toolList.find((item) => item.name === 'fillColor');+ if (!fillColor) return;+ if (!fillColor.customLabel) return;+ if (!fillColor.customLabel.props) return;+ fillColor.customLabel.props.color = this._background;+ this.setBackground(this._background);+ },+ hideSelectedIcon: true,+ className: styles.selectColorPickerParent,+ children: [+ {+ labelLocale: 'toolbar.resetColor',+ },+ {+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,+ props: {+ onClick: (color: string, e: MouseEvent) => {+ this._colorSelect2.setColor(color);+ this._background = color;+ },+ },+ },+ className: styles.selectColorPicker,+ },+ ],+ name: 'fillColor',+ show: this._config.fillColor,+ },+ {+ type: 3,+ display: 1,+ show: this._config.border,+ tooltip: 'toolbar.border.main',+ className: styles.selectDoubleString,+ onClick: (value: string) => {+ if (value) {+ this._borderInfo.type = value as BorderType;+ }+ this.hideTooltip();+ this.setBorder();+ },+ name: 'border',+ children: [+ ...BORDER_LINE_CHILDREN,+ {+ name: 'borderColor',+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + LineColor.name,+ props: {+ color: '#000',+ label: 'borderLine.borderColor',+ getComponent: (ref: LineColor) => (this._lineColor = ref),+ },+ },+ unSelectable: true,+ className: styles.selectColorPickerParent,+ children: [+ {+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + ColorPicker.name,+ props: {+ onClick: (color: string, e: MouseEvent) => {+ this._lineColor.setColor(color);+ this._borderInfo.color = color;+ const borderItem = this._toolList.find((item) => item.name === 'border');+ const lineColor = borderItem?.children?.find((item) => item.name === 'borderColor');+ if (!lineColor) return;+ if (!lineColor.customLabel) return;+ if (!lineColor.customLabel.props) return;+ lineColor.customLabel.props.color = color;+ },+ },+ },+ className: styles.selectColorPicker,+ onClick: (...arg) => {+ arg[0].stopPropagation();+ },+ },+ ],+ },+ {+ customLabel: {+ name: SLIDE_UI_PLUGIN_NAME + LineBold.name,+ props: {+ img: 0,+ label: 'borderLine.borderSize',+ getComponent: (ref: LineBold) => (this._lineBold = ref),+ },+ },+ onClick: (...arg) => {+ arg[0].stopPropagation();+ this._lineBold.setImg(BORDER_SIZE_CHILDREN[arg[2]].customLabel?.name);+ this._borderInfo.style = arg[1];+ },+ className: styles.selectLineBoldParent,+ unSelectable: true,+ children: BORDER_SIZE_CHILDREN,+ },+ ],+ },+ {+ type: 5,+ tooltip: 'toolbar.mergeCell.main',+ customLabel: {+ name: 'MergeIcon',+ },+ show: this._config.mergeCell,+ onClick: (value: string) => {+ this.setMerge(value ?? 'all');+ this.hideTooltip();+ },+ name: 'mergeCell',+ children: MERGE_CHILDREN,+ },+ {+ type: 3,+ tooltip: 'toolbar.horizontalAlignMode.main',+ className: styles.selectDoubleString,+ display: 1,+ name: 'horizontalAlignMode',+ show: this._config.horizontalAlignMode,+ onClick: (value: HorizontalAlign) => {+ this.setHorizontalAlignment(value);+ this.hideTooltip();+ },+ children: HORIZONTAL_ALIGN_CHILDREN,+ },+ {+ type: 3,+ tooltip: 'toolbar.verticalAlignMode.main',+ className: styles.selectDoubleString,+ display: 1,+ name: 'verticalAlignMode',+ show: this._config.verticalAlignMode,+ onClick: (value: VerticalAlign) => {+ this.setVerticalAlignment(value);+ this.hideTooltip();+ },+ children: VERTICAL_ALIGN_CHILDREN,+ },+ {+ type: 3,+ className: styles.selectDoubleString,+ tooltip: 'toolbar.textWrapMode.main',+ display: 1,+ name: 'textWrapMode',+ show: this._config.textWrapMode,+ onClick: (value: WrapStrategy) => {+ this.setWrapStrategy(value);+ this.hideTooltip();+ },+ children: TEXT_WRAP_CHILDREN,+ },+ {+ type: 3,+ className: styles.selectDoubleString,+ name: 'textRotateMode',+ tooltip: 'toolbar.textRotateMode.main',+ display: 1,+ show: this._config.textRotateMode,+ onClick: (value: number | string) => {+ this.setTextRotation(value);+ this.hideTooltip();+ },+ children: TEXT_ROTATE_CHILDREN,+ },+ ];++ this._initialize();+ }++ // 获取Toolbar组件+ getComponent = (ref: Toolbar) => {+ this._toolbar = ref;+ this.setToolbar();+ };++ // 增加toolbar配置+ addToolbarConfig(config: IToolbarItemProps) {+ const index = this._toolList.findIndex((item) => item.name === config.name);+ if (index > -1) return;+ this._toolList.push(config);+ }++ // 删除toolbar配置+ deleteToolbarConfig(name: string) {+ const index = this._toolList.findIndex((item) => item.name === name);+ if (index > -1) {+ this._toolList.splice(index, 1);+ }+ }++ // 刷新toolbar+ setToolbar() {+ this._toolbar?.setToolbar(this._toolList);+ }++ setUIObserve<T>(msg: UIObserver<T>) {+ this._plugin.getContext().getObserverManager().requiredObserver<UIObserver<T>>('onUIChangeObservable', 'core').notifyObservers(msg);+ }++ changeColor(color: string) {+ const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');+ const underlineItem = this._toolList.find((item) => item.name === 'underline');+ this.setFontColor(color);+ if (underlineItem) {+ this.setUnderline(underlineItem.active ?? false);+ }+ if (strikethroughItem) {+ this.setStrikeThrough(strikethroughItem.active ?? false);+ }+ }++ setUndo() {+ const msg = {+ name: 'undo',+ };+ this.setUIObserve(msg);+ }++ setRedo() {+ const msg = {+ name: 'redo',+ };+ this.setUIObserve(msg);+ }++ setFontFamily(fontFamily: string) {+ const msg = {+ name: 'fontFamily',+ value: fontFamily,+ };+ this.setUIObserve(msg);+ }++ setFontSize(fontSize: number) {+ const msg = {+ name: 'fontSize',+ value: fontSize,+ };+ this.setUIObserve<number>(msg);+ }++ setFontWeight(isBold: boolean) {+ const msg = {+ name: 'fontWeight',+ value: isBold,+ };+ this.setUIObserve<boolean>(msg);+ }++ setFontStyle(isItalic: boolean) {+ const msg = {+ name: 'fontStyle',+ value: isItalic,+ };+ this.setUIObserve<boolean>(msg);+ }++ setStrikeThrough(isStrikethrough: boolean) {+ const msg = {+ name: 'strikeThrough',+ value: isStrikethrough,+ };+ this.setUIObserve<boolean>(msg);+ }++ setUnderline(isUnderLine: boolean) {+ const msg = {+ name: 'underLine',+ value: isUnderLine,+ };+ this.setUIObserve<boolean>(msg);+ }++ setFontColor(color: string) {+ const msg = {+ name: 'fontColor',+ value: color,+ };+ this.setUIObserve(msg);+ }++ setBackground(color: string) {+ const msg = {+ name: 'background',+ value: color,+ };+ this.setUIObserve(msg);+ }++ setMerge(value: string) {+ const msg = {+ name: 'merge',+ value,+ };+ this.setUIObserve(msg);+ }++ setTextRotation(value: string | number) {+ const msg = {+ name: 'textRotation',+ value,+ };+ this.setUIObserve(msg);+ }++ setWrapStrategy(value: WrapStrategy) {+ const msg = {+ name: 'wrapStrategy',+ value,+ };+ this.setUIObserve<number>(msg);+ }++ setVerticalAlignment(value: VerticalAlign) {+ const msg = {+ name: 'verticalAlignment',+ value,+ };+ this.setUIObserve<number>(msg);+ }++ setHorizontalAlignment(value: HorizontalAlign) {+ const msg = {+ name: 'horizontalAlignment',+ value,+ };+ this.setUIObserve<number>(msg);+ }++ setBorder() {+ const msg = {+ name: 'borderInfo',+ value: this._borderInfo,+ };+ this.setUIObserve<IKeyValue>(msg);+ }++ hideTooltip() {+ const dom = this._toolbar.base as HTMLDivElement;+ const tooltip = dom.querySelectorAll(`.${styles.tooltipTitle}.${styles.bottom}`);+ tooltip.forEach((item) => {+ (item as HTMLSpanElement).style.display = 'none';+ });+ }++ private _initialize() {+ this._plugin.getComponentManager().register(SLIDE_UI_PLUGIN_NAME + ColorSelect.name, ColorSelect);+ this._plugin.getComponentManager().register(SLIDE_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);+ this._plugin.getComponentManager().register(SLIDE_UI_PLUGIN_NAME + LineColor.name, LineColor);+ this._plugin.getComponentManager().register(SLIDE_UI_PLUGIN_NAME + LineBold.name, LineBold);++ CommandManager.getCommandObservers().add(({ actions }) => {+ // if (!actions || actions.length === 0) return;+ // const action = actions[0] as SlideActionBase<ISlideActionData, ISlideActionData, void>;+ // const currentUnitId = this._plugin.getContext().getUniver().getCurrentUniverSlideInstance().UniverSlideConfig.id;+ // const actionUnitId = action.getWorkBook().getUnitId();+ // if (currentUnitId !== actionUnitId) return;+ // const manager = this._slidePlugin.getSelectionManager();+ // const range = manager?.getCurrentCell();+ // if (range) {+ // this._changeToolbarState(range);+ // }+ });+ }+}diff --git a/packages/ui-plugin-slides/src/Controller/UIController.ts b/packages/ui-plugin-slides/src/Controller/UIController.tsdeleted file mode 100644index db19ec8146..0000000000--- a/packages/ui-plugin-slides/src/Controller/UIController.ts+++ /dev/null@@ -1,12 +0,0 @@-import { SlidePlugin } from '@univerjs/base-slides';-import { SlideUIPlugin } from '../SlideUIPlugin';--export class UIController {- protected _slidePlugin: SlidePlugin;-- protected _plugin: SlideUIPlugin;-- constructor(plugin: SlideUIPlugin) {- this._plugin = plugin;- }-}diff --git a/packages/ui-plugin-slides/src/Controller/index.ts b/packages/ui-plugin-slides/src/Controller/index.tsindex e69de29bb2..7881d187fb 100644--- a/packages/ui-plugin-slides/src/Controller/index.ts+++ b/packages/ui-plugin-slides/src/Controller/index.ts@@ -0,0 +1,4 @@+export * from './AppUIController';+export * from './ToolbarUIController';+export * from './SlideContainerUIController';+export * from './InfoBarUIController';diff --git a/packages/ui-plugin-slides/src/Model/InfoBarModel.ts b/packages/ui-plugin-slides/src/Model/InfoBarModel.tsnew file mode 100644index 0000000000..e9d969cf44--- /dev/null+++ b/packages/ui-plugin-slides/src/Model/InfoBarModel.ts@@ -0,0 +1,11 @@+export class InfoBarModel {+ constructor(private _name: string) {}++ get name(): string {+ return this._name;+ }++ setName(name: string) {+ this._name = name;+ }+}diff --git a/packages/ui-plugin-slides/src/SlideUIPlugin.ts b/packages/ui-plugin-slides/src/SlideUIPlugin.tsindex 1031ec6f4b..77aee41aff 100644--- a/packages/ui-plugin-slides/src/SlideUIPlugin.ts+++ b/packages/ui-plugin-slides/src/SlideUIPlugin.ts@@ -1,15 +1,25 @@-import { Plugin, Context, UniverSlide } from '@univerjs/core';+import { Plugin, Context, UniverSlide, Tools, PLUGIN_NAMES } from '@univerjs/core';+import { RegisterManager, ComponentManager, getRefElement } from '@univerjs/base-ui';+import { RenderEngine } from '@univerjs/base-render';+import { SlidePlugin } from '@univerjs/base-slides';import { zh, en } from './Locale';import { SLIDE_UI_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';-import { UIController } from './Controller/UIController';+import { AppUIController } from './Controller/AppUIController';+import { DefaultSlideUIConfig, installObserver, ISlideUIPluginConfig, SlideUIPluginObserve } from './Basics';+import { IToolbarItemProps } from './Controller';-export interface ISlideUIPluginConfig {}+export class SlideUIPlugin extends Plugin<SlideUIPluginObserve, Context> {+ private _appUIController: AppUIController;-export class SlideUIPlugin extends Plugin<any, Context> {- private _UIController: UIController;+ private _registerManager: RegisterManager;++ private _config: ISlideUIPluginConfig;++ private _componentManager: ComponentManager;constructor(config?: ISlideUIPluginConfig) {super(SLIDE_UI_PLUGIN_NAME);+ this._config = Tools.deepMerge({}, DefaultSlideUIConfig, config);}static create(config?: ISlideUIPluginConfig) {@@ -20,7 +30,8 @@ export class SlideUIPlugin extends Plugin<any, Context> {universheetInstance.installPlugin(this);}- initialize(): void {+ initialize(ctx: Context): void {+ installObserver(this);/*** load more Locale object*/@@ -29,12 +40,76 @@ export class SlideUIPlugin extends Plugin<any, Context> {zh,});- this._UIController = new UIController(this);+ this._componentManager = new ComponentManager();+ this._registerManager = new RegisterManager(this);+ this._appUIController = new AppUIController(this);+ // AppUIController initializes the DOM as an asynchronous rendering process, and must wait for the UI rendering to complete before starting to render the canvas+ this.UIDidMount(() => {+ this.initRender();+ });}- onMounted(): void {- this.initialize();+ getConfig() {+ return this._config;+ }++ initRender() {+ const engine = this.getPluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER)?.getEngine()!;+ let container = getRefElement(this._appUIController.getSlideContainerController().getContentRef());++ // mount canvas to DOM container+ engine.setContainer(container);++ this.getUniver().getCurrentUniverSlideInstance().context.getPluginManager().getRequirePluginByName<SlidePlugin>(PLUGIN_NAMES.SLIDE).getCanvasView().scrollToCenter();++ window.addEventListener('resize', () => {+ engine.resize();+ });++ // should be clear+ setTimeout(() => {+ engine.resize();+ }, 0);+ }++ initUI() {}++ onMounted(ctx: Context): void {+ this.initialize(ctx);}onDestroy(): void {}++ getAppUIController() {+ return this._appUIController;+ }++ getComponentManager() {+ return this._componentManager;+ }++ /**+ * usage this._clipboardExtensionManager.handle(data);+ * @returns+ */+ getRegisterManager(): RegisterManager {+ return this._registerManager;+ }++ /**+ * This API is used in plugins for initialization that depends on UI rendering+ * @param cb+ * @returns+ */+ UIDidMount(cb: Function) {+ this._appUIController.getSlideContainerController().UIDidMount(cb);+ }++ addToolButton(config: IToolbarItemProps) {+ this._appUIController.getSlideContainerController().getToolbarController().addToolbarConfig(config);+ }++ deleteToolButton(name: string) {+ this._appUIController.getSlideContainerController().getToolbarController().deleteToolbarConfig(name);+ }}diff --git a/packages/ui-plugin-slides/src/View/App.tsx b/packages/ui-plugin-slides/src/View/App.tsxnew file mode 100644index 0000000000..6f666e7270--- /dev/null+++ b/packages/ui-plugin-slides/src/View/App.tsx@@ -0,0 +1,70 @@+import { AppContext, BaseComponentProps, Component } from '@univerjs/base-ui';+import { LocaleType } from '@univerjs/core';+import { BaseSlideContainerProps, SlideContainer } from './SlideContainer';++export interface BaseUIProps extends BaseComponentProps {+ locale: LocaleType;+ UIConfig: BaseSlideContainerProps;+ changeLocale: (locale: string) => void;+}++interface IState {+ locale: LocaleType;+}++export class App extends Component<BaseUIProps, IState> {+ constructor(props: BaseUIProps) {+ super(props);+ this.state = {+ locale: this.props.locale,+ };+ }++ setLocale(e: Event) {+ const value = (e.target as HTMLSelectElement).value as LocaleType;+ this.props.changeLocale(value);+ this.setState({+ locale: value,+ });+ }++ render() {+ const { context, UIConfig } = this.props;+ const { locale } = this.state;++ return (+ <AppContext.Provider+ value={{+ context,+ locale,+ }}+ >+ <div+ style={{+ position: 'fixed',+ right: '250px',+ top: '14px',+ fontSize: '14px',+ zIndex: 100,+ }}+ className="univer-dev-operation"+ >+ <span+ style={{+ display: 'inline-block',+ width: 70,+ margin: '5px 0 0 5px',+ }}+ >+ Language+ </span>+ <select value={locale} onChange={this.setLocale.bind(this)} style={{ width: 70 }}>+ <option value="en">English</option>+ <option value="zh">中文</option>+ </select>+ </div>+ <SlideContainer {...UIConfig} />+ </AppContext.Provider>+ );+ }+}diff --git a/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsxnew file mode 100644index 0000000000..48a5f973ee--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Common/ColorSelect/ColorSelect.tsx@@ -0,0 +1,56 @@+import { BaseComponentProps, Component, ComponentChildren } from '@univerjs/base-ui';+import { SlideUIPlugin } from '../../..';+import { SLIDE_UI_PLUGIN_NAME } from '../../../Basics';+import styles from './index.module.less';++interface IProps extends BaseComponentProps {+ customLabel?: {+ name: string;+ props: any;+ };+ label?: ComponentChildren;+ id: string;+ color: string;+}++interface IState {+ label: ComponentChildren;+ color: string;+}++export class ColorSelect extends Component<IProps, IState> {+ componentDidMount(): void {+ const componentManager = this.getContext().getPluginManager().getPluginByName<SlideUIPlugin>(SLIDE_UI_PLUGIN_NAME)?.getComponentManager();+ let label = this.props.label;+ if (this.props.customLabel) {+ const Label = componentManager?.get(this.props.customLabel.name);+ label = <Label {...this.props.customLabel.props}></Label>;+ }+ this.setState({+ label,+ color: this.props.color,+ });+ this.props.getComponent?.(this);+ }++ componentWillReceiveProps(props: IProps) {+ this.setState({+ color: props.color,+ });+ }++ setColor(color: string) {+ this.setState({+ color,+ });+ }++ render() {+ return (+ <div className={styles.colorSelect}>+ <div>{this.state.label}</div>+ <div className={styles.colorSelectLine} style={{ background: this.state.color }}></div>+ </div>+ );+ }+}diff --git a/packages/ui-plugin-slides/src/View/Common/ColorSelect/index.module.less b/packages/ui-plugin-slides/src/View/Common/ColorSelect/index.module.lessnew file mode 100644index 0000000000..41556b46dd--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Common/ColorSelect/index.module.less@@ -0,0 +1,12 @@+.color-select {+ position: relative;++ .color-select-line {+ position: absolute;+ width: 15px;+ height: 5px;+ bottom: 0px;+ left: 50%;+ transform: translate(-50%, 0);+ }+}\ No newline at end of filediff --git a/packages/ui-plugin-slides/src/View/Common/Line/LineBold.tsx b/packages/ui-plugin-slides/src/View/Common/Line/LineBold.tsxnew file mode 100644index 0000000000..1b2b6e5f73--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Common/Line/LineBold.tsx@@ -0,0 +1,59 @@+import { BaseComponentProps, Component, Icon } from '@univerjs/base-ui';+import { SlideUIPlugin } from '../../..';+import { SLIDE_UI_PLUGIN_NAME } from '../../../Basics';++interface IState {+ img: string;+}++interface IProps extends BaseComponentProps {+ label: string;+ img: string;+}++export class LineBold extends Component<IProps, IState> {+ initialize() {+ this.state = {+ img: '',+ };+ }++ componentDidMount(): void {+ this.props.getComponent?.(this);+ }++ componentWillReceiveProps(props: IProps) {+ this.setState({+ img: props.img,+ });+ }++ setImg(img: string = '') {+ this.setState({+ img,+ });+ }++ getImg(img: string) {+ if (!img) return null;+ const span = document.querySelector('.base-sheets-line-bold') as HTMLDivElement;+ const props = { width: span.offsetWidth };+ const componentManager = this.getContext().getPluginManager().getPluginByName<SlideUIPlugin>(SLIDE_UI_PLUGIN_NAME)?.getComponentManager();+ const Img = componentManager?.get(img);+ return <Img {...(props as any)} />;+ }++ render() {+ const { img } = this.state;+ const { label } = this.props;+ return (+ <div style={{ paddingBottom: '3px', width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>+ <span className={'base-sheets-line-bold'} style={{ position: 'relative' }}>+ {this.getLocale(label)}+ <div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '14px' }}>{img.length ? this.getImg(img) : ''}</div>+ </span>+ <Icon.RightIcon />+ </div>+ );+ }+}diff --git a/packages/ui-plugin-slides/src/View/Common/Line/LineColor.tsx b/packages/ui-plugin-slides/src/View/Common/Line/LineColor.tsxnew file mode 100644index 0000000000..6d5ac26047--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Common/Line/LineColor.tsx@@ -0,0 +1,46 @@+import { BaseComponentProps, Component, Icon } from '@univerjs/base-ui';++interface IState {+ color: string;+}++interface IProps extends BaseComponentProps {+ color: string;+ label?: string;+}++export class LineColor extends Component<IProps, IState> {+ initialize() {+ this.state = {+ color: this.props.color,+ };+ }++ componentDidMount() {+ this.props.getComponent?.(this);+ }++ componentWillReceiveProps(props: IProps): void {+ this.setState({+ color: props.color,+ });+ }++ setColor(color: string) {+ this.setState({+ color,+ });+ }++ render() {+ const { color } = this.state;+ const { label } = this.props;++ return (+ <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>+ <span style={{ display: 'inline-block', borderBottom: `3px solid ${color}` }}>{this.getLocale(label)}</span>+ <Icon.RightIcon />+ </div>+ );+ }+}diff --git a/packages/ui-plugin-slides/src/View/Common/index.tsx b/packages/ui-plugin-slides/src/View/Common/index.tsxnew file mode 100644index 0000000000..f657a01caf--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Common/index.tsx@@ -0,0 +1,3 @@+export * from './ColorSelect/ColorSelect';+export * from './Line/LineBold';+export * from './Line/LineColor';diff --git a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsxnew file mode 100644index 0000000000..7509e1239c--- /dev/null+++ b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx@@ -0,0 +1,57 @@+import { BaseComponentProps, Component, Container, Input, Tooltip } from '@univerjs/base-ui';+import { Nullable } from '@univerjs/core';+import { BaseInfoBarProps } from '../../Controller/InfoBarUIController';+import styles from './index.module.less';++interface IState {+ infoList: Nullable<BaseInfoBarProps>;+}++interface IProps extends BaseComponentProps {+ renameSheet: () => void;+}++export class InfoBar extends Component<IProps, IState> {+ initialize() {+ this.state = {+ infoList: null,+ };+ }++ componentDidMount() {+ this.props.getComponent?.(this);+ }++ setInfoList(list: BaseInfoBarProps) {+ this.setState({+ infoList: list,+ });+ }++ render() {+ const { renameSheet } = this.props;+ if (!this.state.infoList) return;++ const { back, slide, update, save, rename } = this.state.infoList;++ return (+ <Container className={styles.infoDetail}>+ {/* <div style={{ marginRight: '18px' }}>+ <Tooltip title={back.label} placement={'bottom'}>+ <Button className={styles.infoReturn} type="text">+ <DropDownIcon rotate={90} />+ </Button>+ </Tooltip>+ </div> */}+ {/* <LogoIcon style={{ width: '152px', height: '32px' }} /> */}+ <div className={styles.sheetName}>+ <Tooltip title={rename.label} placement={'bottom'}>+ <Input bordered={false} value={slide.label} onBlur={renameSheet} />+ </Tooltip>+ </div>+ <div className={styles.infoDetailUpdate}>{update.label}</div>+ <div className={styles.infoDetailSave}>{save.label}</div>+ </Container>+ );+ }+}diff --git a/packages/base-slides/src/View/UI/InfoBar/index.less b/packages/ui-plugin-slides/src/View/InfoBar/index.module.lesssimilarity index 84%rename from packages/base-slides/src/View/UI/InfoBar/index.lessrename to packages/ui-plugin-slides/src/View/InfoBar/index.module.lessindex 4c52e0c4c5..bb3e266e29 100644--- a/packages/base-slides/src/View/UI/InfoBar/index.less+++ b/packages/ui-plugin-slides/src/View/InfoBar/index.module.less@@ -1,4 +1,4 @@-.universheet-info-detail {+.info-detail {position: relative;left: 0;top: 0;@@ -11,7 +11,7 @@box-shadow: 0 -1px 0 0 var(--gray-16);border-bottom: 1px solid var(--border-color-base);- .universheet-info-return {+ .info-return {font-size: 16px;padding: 0 5px;font-size: 14px;@@ -30,13 +30,13 @@margin: 0 auto;}- .universheet-info-detail-update {+ .info-detail-update {color: var(--gray-17);font-size: 12px;margin-left: 15px;}- .universheet-info-detail-save {+ .info-detail-save {color: var(--gray-7);font-size: 12px;margin: 0 5px;diff --git a/packages/base-slides/src/View/UI/InfoBar/index.ts b/packages/ui-plugin-slides/src/View/InfoBar/index.tssimilarity index 100%rename from packages/base-slides/src/View/UI/InfoBar/index.tsrename to packages/ui-plugin-slides/src/View/InfoBar/index.tsdiff --git a/packages/base-slides/src/View/UI/InfoBar/infobar-zh.md b/packages/ui-plugin-slides/src/View/InfoBar/infobar-zh.mdsimilarity index 100%rename from packages/base-slides/src/View/UI/InfoBar/infobar-zh.mdrename to packages/ui-plugin-slides/src/View/InfoBar/infobar-zh.mddiff --git a/packages/ui-plugin-slides/src/View/Render/index.ts b/packages/ui-plugin-slides/src/View/Render/index.tsdeleted file mode 100644index e69de29bb2..0000000000diff --git a/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsx b/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsxnew file mode 100644index 0000000000..8289455018--- /dev/null+++ b/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsx@@ -0,0 +1,83 @@+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, createRef, PreactContext } from '@univerjs/base-ui';+import { ISlidePage } from '@univerjs/core';+import styles from './index.module.less';++interface SlideBarState {+ slideList: ISlidePage[];+ activePageId?: string;+}++interface IProps extends BaseComponentProps {+ addSlide: () => void;+ activeSlide: (pageId: string) => void;+}++export class SlideBar extends Component<IProps, SlideBarState> {+ static contextType: PreactContext<Partial<AppContextValues>> = AppContext;++ slideBarRef = createRef<HTMLDivElement>();++ initialize() {+ this.state = {+ slideList: [],+ };+ }++ componentDidMount() {+ this.props.getComponent?.(this);+ }++ isActive(pageId: string, index: number = 0) {+ if (this.state.activePageId == null && index === 0) {+ return styles.slideBarItemActive;+ }+ if (this.state.activePageId === pageId) {+ return styles.slideBarItemActive;+ }+ return '';+ }++ setSlide(slideList: ISlidePage[], cb?: () => void) {+ this.setState(+ {+ slideList,+ },+ cb+ );+ }++ activeSlide(pageId: string, index: number) {+ if (this.state.activePageId === pageId) {+ return;+ }++ this.setState({+ activePageId: pageId,+ });++ this.props.activeSlide(pageId);+ }++ render() {+ const { addSlide } = this.props;+ const { slideList } = this.state;++ return (+ <div className={styles.slideBar} ref={this.slideBarRef}>+ <div className={styles.slideBarContent}>+ {slideList.map((item, index) => (+ <div className={`${styles.slideBarItem} ${this.isActive(item.id, index)}`} onClick={() => this.activeSlide(item.id, index)}>+ <span>{index + 1}</span>+ <div className={styles.slideBarBox}></div>+ </div>+ ))}+ </div>+ <div className={styles.slideAddButton}>+ <Button type="text" onClick={addSlide}>+ ++ </Button>+ </div>+ </div>+ );+ }+}diff --git a/packages/base-slides/src/View/UI/SlideBar/index.module.less b/packages/ui-plugin-slides/src/View/SlideBar/index.module.lesssimilarity index 100%rename from packages/base-slides/src/View/UI/SlideBar/index.module.lessrename to packages/ui-plugin-slides/src/View/SlideBar/index.module.lessdiff --git a/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsx b/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsxnew file mode 100644index 0000000000..25468962ff--- /dev/null+++ b/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsx@@ -0,0 +1,258 @@+import { BaseComponentProps, Component, Container, Content, createRef, Footer, Header, Layout, Sider } from '@univerjs/base-ui';+import defaultSkin from '@univerjs/base-ui/Basics/CSS/Skin/default.module.less';+import { Tools } from '@univerjs/core';+import cssVars from 'css-vars-ponyfill';+import style from './index.module.less';+import { InfoBar } from '../InfoBar';+import { ISlideUIPluginConfig } from '../../Basics';+import { Toolbar } from '../Toolbar';+import { SlideBar } from '../SlideBar/SlideBar';++export interface BaseSlideContainerProps extends BaseComponentProps {+ config: ISlideUIPluginConfig;+ changeLocale: (locale: string) => void;+ methods?: any;+}++/**+ * One universlide instance DOM container+ */+export class SlideContainer extends Component<BaseSlideContainerProps> {+ leftContentLeft: number;++ leftContentTop: number;++ rightBorderX: number;++ rightBorderY: number;++ splitLeftRef = createRef<HTMLDivElement>();++ contentRef = createRef<HTMLDivElement>();++ constructor(props: BaseSlideContainerProps) {+ super();+ this.changeSkin(props.config.container as string, 'default');+ }++ componentDidMount() {+ this.props.getComponent?.(this);+ }++ /**+ * split mouse down+ * @param e+ */+ handleSplitBarMouseDown = (e: MouseEvent) => {+ e = e || window.event; // Compatible with IE browser+ // Store the current mouse position+ this.leftContentLeft = this.splitLeftRef.current?.getBoundingClientRect().left!;+ this.leftContentTop = this.splitLeftRef.current?.getBoundingClientRect().top!;+ const mainContainer = this.splitLeftRef.current?.parentElement;+ this.rightBorderX = mainContainer?.getBoundingClientRect()?.width!;+ this.rightBorderY = mainContainer?.getBoundingClientRect()?.height!;+ document.addEventListener('mousemove', this.handleSplitBarMouseMove, false);+ document.addEventListener('mouseup', this.handleSplitBarMouseUp, false);+ };++ /**+ * split mouse move+ * @param e+ */+ handleSplitBarMouseMove = (e: MouseEvent) => {+ const layout = this.props.config.layout?.slideContainerConfig!;+ e = e || window.event; // Compatible with IE browser+ let diffLeft = e.clientX - this.leftContentLeft;+ let diffTop = e.clientY - this.leftContentTop;+ // Prevent crossing borders+ diffLeft = diffLeft >= this.rightBorderX ? this.rightBorderX : diffLeft;+ diffTop = diffTop >= this.rightBorderY ? this.rightBorderY : diffTop;+ // set new width+ if (layout.contentSplit === 'vertical') {+ this.splitLeftRef.current!.style.height = `${diffTop}px`;+ } else {+ this.splitLeftRef.current!.style.width = `${diffLeft}px`;+ }+ };++ /**+ * split mouse up+ * @param e+ */+ handleSplitBarMouseUp = (e: MouseEvent) => {+ document.removeEventListener('mousemove', this.handleSplitBarMouseMove, false);+ document.removeEventListener('mouseup', this.handleSplitBarMouseUp, false);+ };++ getContentRef() {+ return this.contentRef;+ }++ getSplitLeftRef() {+ return this.splitLeftRef;+ }++ /**+ * Modify Dom Skin+ */+ changeSkin(container: HTMLElement | string, skin: string) {+ // Collect all skins+ let root = document.documentElement;++ const id = typeof container === 'string' ? container : container.id;++ // get all skins+ const skins = {+ default: defaultSkin,+ };++ // current skin set by user+ let currentSkin = skins[skin];++ // transform "primaryColor" to "--primary-color"+ currentSkin = Object.fromEntries(Object.keys(currentSkin).map((item) => [`--${item.replace(/([A-Z0-9])/g, '-$1').toLowerCase()}`, currentSkin[item]]));++ // ie11 does not support css variables, use css-vars-ponyfill to handle+ if (Tools.isIEBrowser()) {+ cssVars({+ // Options...++ // The container is invalid as rootElement, so the default setting is root.+ // Disadvantages: In ie11, only one set of skins can be used for multiple workbooks, and it is the skin set by the last workbook+ rootElement: root, // default++ variables: currentSkin,+ });+ } else {+ // set css variable+ let sheet = getSkinStyleSheet(id);++ /**+ * covert object to style, remove " and replace , to ;+ *+ * Example:+ *+ * before: {--primary-color:"#0188fb",--primary-color-hover:"#5391ff"}+ * after: {--primary-color:#0188fb;--primary-color-hover:#5391ff;}+ */++ sheet.insertRule(+ `#${id} ${JSON.stringify(currentSkin)+ .replace(/"/g, '')+ .replace(/,(?=--)/g, ';')}`+ );+ }++ /**+ * get skin style sheet+ * @param id+ * @returns+ */++ function getSkinStyleSheet(id: string) {+ const title = 'universlide-skin-style';+ // avoid duplicates+ for (let i = 0; i < document.styleSheets.length; i++) {+ if (document.styleSheets[i].title === title) {+ deleteStyleRuleIndexBySelector(document.styleSheets[i], id);++ return document.styleSheets[i];+ }+ }+ const head = document.head || document.getElementsByTagName('head')[0];+ const styleEle = document.createElement('style');+ styleEle.title = title;+ head.appendChild(styleEle);++ return document.styleSheets[document.styleSheets.length - 1];+ }++ /**+ * delete style rule in universlide-skin-style+ * @param skinStyleSheet+ * @param id+ */+ function deleteStyleRuleIndexBySelector(skinStyleSheet: CSSStyleSheet, id: string) {+ let index = 0;+ for (let i = 0; i < skinStyleSheet.cssRules.length; i++) {+ const rule = skinStyleSheet.cssRules[i];++ if (rule instanceof CSSStyleRule && rule.selectorText === `#${id}`) {+ index = i;+ skinStyleSheet.deleteRule(index);+ break;+ }+ }+ }+ }++ /**+ * Render the component's HTML+ *+ * @returns {void}+ */+ render() {+ const { methods } = this.props;+ const { layout } = this.props.config;+ const config = layout?.slideContainerConfig!;+ // Set Provider for entire Container+ return (+ <Container className={style.layoutContainer}>+ <Layout>+ <Sider style={{ display: config.outerLeft ? 'block' : 'none' }}></Sider>+ <Layout className={style.mainContent} style={{ position: 'relative' }}>+ <Header style={{ display: config.header ? 'block' : 'none' }}>+ {config.infoBar && <InfoBar {...methods.infoBar}></InfoBar>}+ {config.toolbar && <Toolbar {...methods.toolbar}></Toolbar>}+ </Header>+ <Layout>+ <Sider+ style={{+ width: '300px',+ display: config.innerLeft ? 'block' : 'none',+ }}+ >+ <SlideBar {...methods.slideBar}></SlideBar>+ </Sider>+ <Content className={config.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>+ {/* <Slot {...methods.slot}></Slot> */}+ {!!config.contentSplit && (+ <Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>+ <div className={style.hoverCursor} onMouseDown={this.handleSplitBarMouseDown}></div>+ </Container>+ )}+ <Container onContextMenu={(e) => e.preventDefault()} ref={this.contentRef} className={style.contentInnerRightContainer}>+ {/* {config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>} */}+ </Container>+ {/* <Prompt show={true} title="123" content="235" /> */}+ {/* extend main content */}+ </Content>++ <Sider+ style={{+ display: config.innerRight ? 'block' : 'none',+ }}+ >+ {/* innerRight */}+ {/* <SideGroup></SideGroup> */}+ </Sider>+ </Layout>+ <Footer+ style={{+ display: config.footer ? 'block' : 'none',+ }}+ >+ {/* {config.countBar && <CountBar {...methods.countBar}></CountBar>} */}+ </Footer>+ </Layout>+ <Sider+ style={{+ display: config.outerRight ? 'block' : 'none',+ }}+ className={style.outerRightContainer}+ ></Sider>+ </Layout>+ </Container>+ );+ }+}diff --git a/packages/base-slides/src/View/UI/SlideContainer/index.module.less b/packages/ui-plugin-slides/src/View/SlideContainer/index.module.lesssimilarity index 93%rename from packages/base-slides/src/View/UI/SlideContainer/index.module.lessrename to packages/ui-plugin-slides/src/View/SlideContainer/index.module.lessindex a31af51a3a..100caac0a5 100644--- a/packages/base-slides/src/View/UI/SlideContainer/index.module.less+++ b/packages/ui-plugin-slides/src/View/SlideContainer/index.module.less@@ -1,78 +1,77 @@-.layout-container {- // theme- background-color: var(--bg);- color: var(--text-color);- height: 100%;-- .content-container-horizontal {- display: flex;- min-height: 14em;- position: relative;-- .content-inner-left-container {- // position: relative;- width: 50%;- padding-right: 10px;- flex: none;-- .hover-cursor {- position: absolute;- right: 0;- top: 0;- height: 100%;- width: 10px;- background: gray;- cursor: e-resize;- }- }-- .content-inner-right-container {- width: 50%;- flex: 1;- background: rgb(240, 240, 240);- // position: relative;- }- }-- .content-container-vertical {- display: flex;- flex-direction: column;- min-height: 14em;- position: relative;-- .content-inner-left-container {- // position: relative;- height: 50%;- padding-bottom: 10px;- flex: none;-- .hover-cursor {- position: absolute;- left: 0;- bottom: 0;- height: 10px;- width: 100%;- background: gray;- cursor: n-resize;- }- }-- .content-inner-right-container {- height: 50%;- flex: 1;- }- }-- .main-content {- background: var(--bg);- }-- .outer-right-container {- // position: relative;- flex: 0 0 280px;- > div {- position: absolute;- width: 100%;- }- }-}+.layout-container {+ // theme+ background-color: var(--bg);+ color: var(--text-color);+ height: 100%;++ .content-container-horizontal {+ display: flex;+ min-height: 14em;+ position: relative;++ .content-inner-left-container {+ // position: relative;+ width: 50%;+ padding-right: 10px;+ flex: none;++ .hover-cursor {+ position: absolute;+ right: 0;+ top: 0;+ height: 100%;+ width: 10px;+ background: gray;+ cursor: e-resize;+ }+ }++ .content-inner-right-container {+ width: 50%;+ flex: 1;+ // position: relative;+ }+ }++ .content-container-vertical {+ display: flex;+ flex-direction: column;+ min-height: 14em;+ position: relative;++ .content-inner-left-container {+ // position: relative;+ height: 50%;+ padding-bottom: 10px;+ flex: none;++ .hover-cursor {+ position: absolute;+ left: 0;+ bottom: 0;+ height: 10px;+ width: 100%;+ background: gray;+ cursor: n-resize;+ }+ }++ .content-inner-right-container {+ height: 50%;+ flex: 1;+ }+ }++ .main-content {+ background: var(--bg);+ }++ .outer-right-container {+ // position: relative;+ flex: 0 0 280px;+ > div {+ position: absolute;+ width: 100%;+ }+ }+}diff --git a/packages/base-slides/src/View/UI/SlideContainer/index.ts b/packages/ui-plugin-slides/src/View/SlideContainer/index.tssimilarity index 100%rename from packages/base-slides/src/View/UI/SlideContainer/index.tsrename to packages/ui-plugin-slides/src/View/SlideContainer/index.tsdiff --git a/packages/base-slides/src/View/UI/ToolBar/Const.ts b/packages/ui-plugin-slides/src/View/Toolbar/Const.tssimilarity index 60%rename from packages/base-slides/src/View/UI/ToolBar/Const.tsrename to packages/ui-plugin-slides/src/View/Toolbar/Const.tsindex 1701d084f8..c2db56e735 100644--- a/packages/base-slides/src/View/UI/ToolBar/Const.ts+++ b/packages/ui-plugin-slides/src/View/Toolbar/Const.ts@@ -1,358 +1,434 @@-export const FONT_SIZE_CHILDREN = [- {- label: '9',- value: 9,- },- {- label: '10',- value: 10,- },- {- label: '11',- value: 11,- },- {- label: '12',- value: 12,- },- {- label: '14',- value: 14,- },- {- label: '16',- value: 16,- },- {- label: '18',- value: 18,- },- {- label: '20',- value: 20,- },-- {- label: '22',- value: 22,- },- {- label: '24',- value: 24,- },- {- label: '26',- value: 26,- },- {- label: '28',- value: 28,- },- {- label: '36',- value: 36,- },- {- label: '48',- value: 48,- },- {- label: '72',- value: 72,- },-];--export const FONT_FAMILY_CHILDREN = [- {- locale: 'fontFamily.TimesNewRoman',- style: { 'font-family': 'Times New Roman' },- value: 'Times New Roman',- selected: true,- },- {- locale: 'fontFamily.Arial',- style: { 'font-family': 'Arial' },- value: 'Arial',- },- {- locale: 'fontFamily.Tahoma',- style: { 'font-family': 'Tahoma' },- value: 'Tahoma',- },- {- locale: 'fontFamily.Verdana',- style: { 'font-family': 'Verdana' },- value: 'Verdana',- },- {- locale: 'fontFamily.MicrosoftAccorblack',- style: { 'font-family': '微软雅黑' },- value: '微软雅黑',- },- {- locale: 'fontFamily.SimSun',- style: { 'font-family': '宋体' },- value: '宋体',- },- {- locale: 'fontFamily.SimHei',- style: { 'font-family': '黑体' },- value: '黑体',- },- {- locale: 'fontFamily.Kaiti',- style: { 'font-family': '楷体' },- value: '楷体',- },- {- locale: 'fontFamily.FangSong',- style: { 'font-family': '仿宋' },- value: '仿宋',- },- {- locale: 'fontFamily.NSimSun',- style: { 'font-family': '新宋体' },- value: '新宋体',- },- {- locale: 'fontFamily.STXinwei',- style: { 'font-family': '华文新魏' },- value: '华文新魏',- },- {- locale: 'fontFamily.STXingkai',- style: { 'font-family': '华文行楷' },- value: '华文行楷',- },- {- locale: 'fontFamily.STLiti',- style: { 'font-family': '华文隶书' },- value: '华文隶书',- },- {- locale: 'fontFamily.HanaleiFill',- style: { 'font-family': 'HanaleiFill' },- value: 'HanaleiFill',- },- {- locale: 'fontFamily.Anton',- style: { 'font-family': 'Anton' },- value: 'Anton',- },- {- locale: 'fontFamily.Pacifico',- style: { 'font-family': 'Pacifico' },- value: 'Pacifico',- },-];--export const BORDER_LINE_CHILDREN = [- {- locale: 'borderLine.borderTop',- customSuffix: {- name: 'TopBorderIcon',- },- value: 'top',- },- {- locale: 'borderLine.borderBottom',- customSuffix: {- name: 'BottomBorderIcon',- },- value: 'bottom',- },- {- locale: 'borderLine.borderLeft',- customSuffix: {- name: 'LeftBorderIcon',- },- value: 'left',- },- {- locale: 'borderLine.borderRight',- customSuffix: {- name: 'RightBorderIcon',- },- value: 'right',- border: true,- },- {- locale: 'borderLine.borderNone',- customSuffix: {- name: 'NoneBorderIcon',- },- value: 'none',- },- {- locale: 'borderLine.borderAll',- customSuffix: {- name: 'FullBorderIcon',- },- value: 'all',- selected: true,- },- {- locale: 'borderLine.borderOutside',- customSuffix: {- name: 'OuterBorderIcon',- },- value: 'outside',- },- {- locale: 'borderLine.borderInside',- customSuffix: {- name: 'InnerBorderIcon',- },- value: 'inside',- },- {- locale: 'borderLine.borderHorizontal',- customSuffix: {- name: 'StripingBorderIcon',- },- value: 'horizontal',- },- {- locale: 'borderLine.borderVertical',- customSuffix: {- name: 'VerticalBorderIcon',- },- value: 'vertical',- },-];--export const MERGE_CHILDREN = [- {- locale: 'merge.all',- value: 'all',- },- {- locale: 'merge.vertical',- value: 'vertical',- },- {- locale: 'merge.horizontal',- value: 'horizontal',- },- {- locale: 'merge.cancel',- value: 'cancel',- },-];--export const HORIZONTAL_ALIGN_CHILDREN = [- {- locale: 'align.left',- customSuffix: {- name: 'LeftAlignIcon',- },- value: 1,- },- {- locale: 'align.center',- customSuffix: {- name: 'CenterAlignIcon',- },- value: 2,- },- {- locale: 'align.right',- customSuffix: {- name: 'RightAlignIcon',- },- value: 3,- },-];--export const VERTICAL_ALIGN_CHILDREN = [- {- locale: 'align.top',- customSuffix: {- name: 'TopVerticalIcon',- },- value: 1,- },- {- locale: 'align.middle',- customSuffix: {- name: 'CenterVerticalIcon',- },- value: 2,- },- {- locale: 'align.bottom',- customSuffix: {- name: 'BottomVerticalIcon',- },- value: 3,- },-];--export const TEXT_WRAP_CHILDREN = [- {- locale: 'textWrap.overflow',- customSuffix: {- name: 'OverflowIcon',- },- value: 1,- },- {- locale: 'textWrap.wrap',- customSuffix: {- name: 'BrIcon',- },- value: 3,- },- {- locale: 'textWrap.clip',- customSuffix: {- name: 'CutIcon',- },- value: 2,- },-];--export const TEXT_ROTATE_CHILDREN = [- {- locale: 'textRotate.none',- customSuffix: {- name: 'TextRotateIcon',- },- value: 0,- },- {- locale: 'textRotate.angleUp',- customSuffix: {- name: 'TextRotateAngleUpIcon',- },- value: -45,- },- {- locale: 'textRotate.angleDown',- customSuffix: {- name: 'TextRotateAngleDownIcon',- },- value: 45,- },- {- locale: 'textRotate.vertical',- customSuffix: {- name: 'TextRotateVerticalIcon',- },- value: 'v',- },- {- locale: 'textRotate.rotationUp',- customSuffix: {- name: 'TextRotateRotationUpIcon',- },- value: -90,- },- {- locale: 'textRotate.rotationDown',- customSuffix: {- name: 'TextRotateRotationDownIcon',- },- value: 90,- },-];+import { BorderStyleTypes } from '@univerjs/core';++export const FONT_SIZE_CHILDREN = [+ {+ label: '9',+ value: 9,+ },+ {+ label: '10',+ value: 10,+ },+ {+ label: '11',+ value: 11,+ },+ {+ label: '12',+ value: 12,+ },+ {+ label: '14',+ value: 14,+ },+ {+ label: '16',+ value: 16,+ },+ {+ label: '18',+ value: 18,+ },+ {+ label: '20',+ value: 20,+ },++ {+ label: '22',+ value: 22,+ },+ {+ label: '24',+ value: 24,+ },+ {+ label: '26',+ value: 26,+ },+ {+ label: '28',+ value: 28,+ },+ {+ label: '36',+ value: 36,+ },+ {+ label: '48',+ value: 48,+ },+ {+ label: '72',+ value: 72,+ },+];++export const FONT_FAMILY_CHILDREN = [+ {+ labelLocale: 'fontFamily.TimesNewRoman',+ style: { 'font-family': 'Times New Roman' },+ value: 'Times New Roman',+ selected: true,+ },+ {+ labelLocale: 'fontFamily.Arial',+ style: { 'font-family': 'Arial' },+ value: 'Arial',+ },+ {+ labelLocale: 'fontFamily.Tahoma',+ style: { 'font-family': 'Tahoma' },+ value: 'Tahoma',+ },+ {+ labelLocale: 'fontFamily.Verdana',+ style: { 'font-family': 'Verdana' },+ value: 'Verdana',+ },+ {+ labelLocale: 'fontFamily.MicrosoftAccorblack',+ style: { 'font-family': '微软雅黑' },+ value: '微软雅黑',+ },+ {+ labelLocale: 'fontFamily.SimSun',+ style: { 'font-family': '宋体' },+ value: '宋体',+ },+ {+ labelLocale: 'fontFamily.SimHei',+ style: { 'font-family': '黑体' },+ value: '黑体',+ },+ {+ labelLocale: 'fontFamily.Kaiti',+ style: { 'font-family': '楷体' },+ value: '楷体',+ },+ {+ labelLocale: 'fontFamily.FangSong',+ style: { 'font-family': '仿宋' },+ value: '仿宋',+ },+ {+ labelLocale: 'fontFamily.NSimSun',+ style: { 'font-family': '新宋体' },+ value: '新宋体',+ },+ {+ labelLocale: 'fontFamily.STXinwei',+ style: { 'font-family': '华文新魏' },+ value: '华文新魏',+ },+ {+ labelLocale: 'fontFamily.STXingkai',+ style: { 'font-family': '华文行楷' },+ value: '华文行楷',+ },+ {+ labelLocale: 'fontFamily.STLiti',+ style: { 'font-family': '华文隶书' },+ value: '华文隶书',+ },+ {+ labelLocale: 'fontFamily.HanaleiFill',+ style: { 'font-family': 'HanaleiFill' },+ value: 'HanaleiFill',+ },+ {+ labelLocale: 'fontFamily.Anton',+ style: { 'font-family': 'Anton' },+ value: 'Anton',+ },+ {+ labelLocale: 'fontFamily.Pacifico',+ style: { 'font-family': 'Pacifico' },+ value: 'Pacifico',+ },+];++export const BORDER_LINE_CHILDREN = [+ {+ labelLocale: 'borderLine.borderTop',+ customSuffix: {+ name: 'TopBorderIcon',+ },+ value: 'top',+ },+ {+ labelLocale: 'borderLine.borderBottom',+ customSuffix: {+ name: 'BottomBorderIcon',+ },+ value: 'bottom',+ },+ {+ labelLocale: 'borderLine.borderLeft',+ customSuffix: {+ name: 'LeftBorderIcon',+ },+ value: 'left',+ },+ {+ labelLocale: 'borderLine.borderRight',+ customSuffix: {+ name: 'RightBorderIcon',+ },+ value: 'right',+ border: true,+ },+ {+ labelLocale: 'borderLine.borderNone',+ customSuffix: {+ name: 'NoneBorderIcon',+ },+ value: 'none',+ },+ {+ labelLocale: 'borderLine.borderAll',+ customSuffix: {+ name: 'FullBorderIcon',+ },+ value: 'all',+ selected: true,+ },+ {+ labelLocale: 'borderLine.borderOutside',+ customSuffix: {+ name: 'OuterBorderIcon',+ },+ value: 'outside',+ },+ {+ labelLocale: 'borderLine.borderInside',+ customSuffix: {+ name: 'InnerBorderIcon',+ },+ value: 'inside',+ },+ {+ labelLocale: 'borderLine.borderHorizontal',+ customSuffix: {+ name: 'StripingBorderIcon',+ },+ value: 'horizontal',+ },+ {+ labelLocale: 'borderLine.borderVertical',+ customSuffix: {+ name: 'VerticalBorderIcon',+ },+ value: 'vertical',+ },+];++export const BORDER_SIZE_CHILDREN = [+ {+ labelLocale: 'borderLine.borderNone',+ value: BorderStyleTypes.NONE,+ },+ {+ customLabel: {+ name: 'BorderThin',+ },+ value: BorderStyleTypes.THIN,+ },+ {+ customLabel: {+ name: 'BorderHair',+ },+ value: BorderStyleTypes.HAIR,+ },+ {+ customLabel: {+ name: 'BorderDotted',+ },+ value: BorderStyleTypes.DOTTED,+ },+ {+ customLabel: {+ name: 'BorderDashed',+ },+ value: BorderStyleTypes.DASHED,+ },+ {+ customLabel: {+ name: 'BorderDashDot',+ },+ value: BorderStyleTypes.DOTTED,+ },+ {+ customLabel: {+ name: 'BorderDashDotDot',+ },+ value: BorderStyleTypes.DASH_DOT_DOT,+ },+ {+ customLabel: {+ name: 'BorderMedium',+ },+ value: BorderStyleTypes.MEDIUM,+ },+ {+ customLabel: {+ name: 'BorderMediumDashed',+ },+ value: BorderStyleTypes.MEDIUM_DASHED,+ },+ {+ customLabel: {+ name: 'BorderMediumDashDot',+ },+ value: BorderStyleTypes.MEDIUM_DASH_DOT,+ },+ {+ customLabel: {+ name: 'BorderMediumDashDotDot',+ },+ value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,+ },+ {+ customLabel: {+ name: 'BorderThick',+ },+ value: BorderStyleTypes.THICK,+ },+];++export const MERGE_CHILDREN = [+ {+ labelLocale: 'merge.all',+ value: 'all',+ },+ {+ labelLocale: 'merge.vertical',+ value: 'vertical',+ },+ {+ labelLocale: 'merge.horizontal',+ value: 'horizontal',+ },+ {+ labelLocale: 'merge.cancel',+ value: 'cancel',+ },+];++export const HORIZONTAL_ALIGN_CHILDREN = [+ {+ labelLocale: 'align.left',+ customSuffix: {+ name: 'LeftAlignIcon',+ },+ value: 1,+ },+ {+ labelLocale: 'align.center',+ selected: true,+ customSuffix: {+ name: 'CenterAlignIcon',+ },+ value: 2,+ },+ {+ labelLocale: 'align.right',+ customSuffix: {+ name: 'RightAlignIcon',+ },+ value: 3,+ },+];++export const VERTICAL_ALIGN_CHILDREN = [+ {+ labelLocale: 'align.top',+ customSuffix: {+ name: 'TopVerticalIcon',+ },+ value: 1,+ },+ {+ labelLocale: 'align.middle',+ customSuffix: {+ name: 'CenterVerticalIcon',+ },+ value: 2,+ },+ {+ labelLocale: 'align.bottom',+ customSuffix: {+ name: 'BottomVerticalIcon',+ },+ value: 3,+ },+];++export const TEXT_WRAP_CHILDREN = [+ {+ labelLocale: 'textWrap.overflow',+ customSuffix: {+ name: 'OverflowIcon',+ },+ value: 1,+ },+ {+ labelLocale: 'textWrap.wrap',+ customSuffix: {+ name: 'BrIcon',+ },+ value: 3,+ },+ {+ labelLocale: 'textWrap.clip',+ customSuffix: {+ name: 'CutIcon',+ },+ value: 2,+ },+];++export const TEXT_ROTATE_CHILDREN = [+ {+ labelLocale: 'textRotate.none',+ customSuffix: {+ name: 'TextRotateIcon',+ },+ value: 0,+ },+ {+ labelLocale: 'textRotate.angleUp',+ customSuffix: {+ name: 'TextRotateAngleUpIcon',+ },+ value: -45,+ },+ {+ labelLocale: 'textRotate.angleDown',+ customSuffix: {+ name: 'TextRotateAngleDownIcon',+ },+ value: 45,+ },+ {+ labelLocale: 'textRotate.vertical',+ customSuffix: {+ name: 'TextRotateVerticalIcon',+ },+ value: 'v',+ },+ {+ labelLocale: 'textRotate.rotationUp',+ customSuffix: {+ name: 'TextRotateRotationUpIcon',+ },+ value: -90,+ },+ {+ labelLocale: 'textRotate.rotationDown',+ customSuffix: {+ name: 'TextRotateRotationDownIcon',+ },+ value: 90,+ },+];diff --git a/packages/base-slides/src/View/UI/ToolBar/DataBar.tsx b/packages/ui-plugin-slides/src/View/Toolbar/DataBar.tsxsimilarity index 100%rename from packages/base-slides/src/View/UI/ToolBar/DataBar.tsxrename to packages/ui-plugin-slides/src/View/Toolbar/DataBar.tsxdiff --git a/packages/base-slides/src/View/UI/ToolBar/Toolbar-zh.md b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar-zh.mdsimilarity index 100%rename from packages/base-slides/src/View/UI/ToolBar/Toolbar-zh.mdrename to packages/ui-plugin-slides/src/View/Toolbar/Toolbar-zh.mddiff --git a/packages/base-slides/src/View/UI/ToolBar/ToolBar.md b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.mdsimilarity index 100%rename from packages/base-slides/src/View/UI/ToolBar/ToolBar.mdrename to packages/ui-plugin-slides/src/View/Toolbar/Toolbar.mddiff --git a/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsxnew file mode 100644index 0000000000..cb8cdcaa83--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx@@ -0,0 +1,278 @@+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, findLocale, PreactContext, Select, Tooltip } from '@univerjs/base-ui';+import { SlideUIPlugin } from '../..';+import { SLIDE_UI_PLUGIN_NAME } from '../../Basics';+import { IToolbarItemProps } from '../../Controller';+import styles from './index.module.less';++interface IProps extends BaseComponentProps {+ style?: JSX.CSSProperties;+ toolList: IToolbarItemProps[];+}++interface IState {+ toolList: IToolbarItemProps[];+ moreToolList: IToolbarItemProps[];+ defaultToolList: IToolbarItemProps[];+ showMore: boolean;+ toolbarListWidths: number[];+}++export class Toolbar extends Component<IProps, IState> {+ static contextType: PreactContext<Partial<AppContextValues>> = AppContext;++ toolbarRef = createRef();++ moreBtnRef = createRef();++ moreToolRef = createRef();++ SelectRef = createRef();++ clientWidth = 0;++ /**+ * Gets the distance of each button from the parent element+ */+ debounceSetToolbarListWidth = debounce(() => {+ this.setToolbarListWidth();+ }, 50);++ initialize() {+ this.state = {+ // Button contains main button and drop down arrow, translation file contains main and right+ showMore: false,+ toolList: [],+ defaultToolList: [],+ moreToolList: [],+ toolbarListWidths: [],+ };+ }++ /**+ * show more tool buttons+ *+ * TODO : 点击其他地方需要隐藏more buttons+ */+ showMore = () => {+ let showMore = this.state.showMore;+ this.setState({ showMore: !showMore });++ if (!showMore) {+ document.addEventListener('click', this.hide, true);+ }+ };++ hide = (e: Event) => {+ if (this.moreToolRef.current.contains(e.target)) return;+ e.stopImmediatePropagation();+ this.setState({ showMore: false });+ document.removeEventListener('click', this.hide, true);+ };++ setToolbarListWidth = () => {+ 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;++ 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;+ }+ }+ 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;+ }++ 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: IToolbarItemProps[]) => {+ const componentManager = this.getContext().getPluginManager().getPluginByName<SlideUIPlugin>(SLIDE_UI_PLUGIN_NAME)?.getComponentManager();++ for (let i = 0; i < toolList.length; i++) {+ const item = findLocale<IToolbarItemProps>(toolList[i], this.getLocale.bind(this));+ // 优先寻找自定义组件+ if (item.customLabel) {+ const Label = componentManager?.get(item.customLabel.name);+ if (Label) {+ const props = item.customLabel.props ?? {};+ item.label = <Label {...props} />;+ }+ }++ if (item.customSuffix) {+ const Suffix = componentManager?.get(item.customSuffix.name);+ if (Suffix) {+ const props = item.customSuffix.props ?? {};+ item.suffix = <Suffix {...props} />;+ }+ }++ if (item.children) {+ item.children = this.resetLabel(item.children);+ }+ }+ return toolList;+ };++ setToolbar = (toolList: any[]) => {+ // toolList = this.resetLabel(toolList);++ this.setState(+ {+ toolList,+ defaultToolList: toolList,+ },+ () => {+ this.setToolbarListWidth();+ }+ );+ };++ resetUl = () => {+ const wrapper = this.getContext()+ .getPluginManager()+ .getPluginByName<SlideUIPlugin>(SLIDE_UI_PLUGIN_NAME)+ ?.getAppUIController()+ .getSlideContainerController()+ .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.props.getComponent?.(this);+ window.addEventListener('resize', this.debounceSetToolbarListWidth);+ }++ componentWillUnmount() {+ window.removeEventListener('resize', this.debounceSetToolbarListWidth);+ }++ // 渲染dom+ getToolbarList(list: IToolbarItemProps[]) {+ list = this.resetLabel(list);+ return list.map((item) => {+ if (item.toolbarType) {+ if (item.show) {+ return (+ <Tooltip title={this.getLocale(item.tooltip)} placement={'bottom'}>+ <Button unActive={item.unActive} className={styles.textButton} type="text" active={item.active} onClick={item.onClick}>+ {item.label}+ </Button>+ </Tooltip>+ );+ }+ } else {+ if (item.show) {+ return (+ <Select+ tooltip={this.getLocale(item.tooltip)}+ type={item.type}+ display={item.display}+ children={item.children}+ customLabel={item.customLabel}+ customSuffix={item.customSuffix}+ label={item.label}+ onClick={item.onClick}+ onPressEnter={item.onPressEnter}+ onMainClick={item.onMainClick}+ defaultColor={item.defaultColor}+ hideSelectedIcon={item.hideSelectedIcon}+ className={item.className}+ ></Select>+ );+ }+ }+ return null;+ });+ }++ render() {+ const { defaultToolList, moreToolList, showMore } = this.state;++ return (+ <Container style={{ position: 'relative' }}>+ <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={this.getLocale('toolbar.toolMoreTip')} placement={'bottom'}>+ <Button type="text" onClick={this.showMore}>+ <div style={{ fontSize: '14px' }}>{this.getLocale('toolbar.toolMore')}</div>+ </Button>+ </Tooltip>+ </div>+ </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-slides/src/View/UI/ToolBar/index.less b/packages/ui-plugin-slides/src/View/Toolbar/index.lesssimilarity index 100%rename from packages/base-slides/src/View/UI/ToolBar/index.lessrename to packages/ui-plugin-slides/src/View/Toolbar/index.lessdiff --git a/packages/base-slides/src/View/UI/ToolBar/index.module.less b/packages/ui-plugin-slides/src/View/Toolbar/index.module.lesssimilarity index 51%rename from packages/base-slides/src/View/UI/ToolBar/index.module.lessrename to packages/ui-plugin-slides/src/View/Toolbar/index.module.lessindex 502a142276..64875de941 100644--- a/packages/base-slides/src/View/UI/ToolBar/index.module.less+++ b/packages/ui-plugin-slides/src/View/Toolbar/index.module.less@@ -1,5 +1,4 @@.toolbar-warp {- height: 40px;max-height: fit-content;width: 100%;overflow: unset;@@ -25,16 +24,18 @@.toolbar {max-width: 100%;color: var(--text-color);- padding: 5px 15px;+ padding: 0 15px;height: 40px;position: relative;+ display: flex;+ align-items: center;- > div {- // margin-top: 7px;+ >div {height: 26px;display: inline-block;vertical-align: middle;- margin: 7px 3px 0 3px;+ 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,96 +57,83 @@}}+ .select-double-string {+ .drop-content {+ >div {+ width: 24px;+ }+ }+ }+.select-color-picker-parent {.select-item-content {width: 100%;}- ul {- padding: 0;- }-.select-color-picker {- padding: 0;+ cursor: default;++ &:hover {+ background: var(--bg);+ }.select-item {padding: 0;}++ .color-picker-outer {+ box-shadow: none;+ }}}- .single-button {- margin: 0 3px;-- button {- .button();- font-size: 24px;+ .select-line-bold-parent {+ .select-item-content {+ width: 100%;}}- .double-button {- position: relative;- display: flex;- align-items: center;- margin: 0 5px;-- .color-bottom {- width: 10px;- margin: 0 auto;- outline: 2px solid;- position: relative;- bottom: 4px;- }+ .select-single {+ height: 26px;+ line-height: 26px;+ }- .double-button-right {- height: 100%;- display: flex;- align-items: center;-- .double-button-right-popup {- box-shadow: var(--box-shadow-base);- background-color: var(--bg);- position: absolute;- left: 0;- top: 35px;- width: max-content;-- .double-button-menu-item {- display: flex;- align-content: center;-- .double-button-menu-item-icon {- width: 25px;- margin-right: 5px;- }-- .double-button-menu-item-content {- display: flex;- align-items: center;- }- }- }+ .select-input {+ height: 26px;+ line-height: 26px;+ }- button {- padding: 0;- padding-right: 5px;- }- }+ .select-double {+ height: 26px;+ line-height: 26px;+ }- button {- .button();- }+ button {+ padding: 0;+ height: 26px;+ }- span[role='img'] {+ span[role='img'].univericon-nextIcon {+ font-size: 12px;+ }++ .text-button {+ span[role="img"] {font-size: 24px;}++ button {+ padding: 0 5px;+ }}+}.more-button {- height: 35px;- margin: 5px;- display: none;+ position: absolute;+ right: 15px;+ top: 50%;+ transform: translateY(-50%);.button();&.more-show {@@ -154,9 +142,9 @@}.more-tool {- height: 40px;- display: none;- align-items: center;+ // height: 40px;+ // display: none;+ // align-items: center;padding: 0 10px;background-color: var(--bg);box-shadow: var(--box-shadow-base);@@ -171,15 +159,18 @@button {.button();- font-size: 24px;}}.button() {- padding: 0px 5px;+ padding: 0px;line-height: 1;}-span[role='img'].univericon-nextIcon {- font-size: 12px;+.tooltip-title {+ opacity: 1;}++.bottom {+ display: none;+}\ No newline at end of filediff --git a/packages/ui-plugin-slides/src/View/Toolbar/index.ts b/packages/ui-plugin-slides/src/View/Toolbar/index.tsnew file mode 100644index 0000000000..7c6430332b--- /dev/null+++ b/packages/ui-plugin-slides/src/View/Toolbar/index.ts@@ -0,0 +1 @@+export * from './Toolbar';diff --git a/packages/ui-plugin-slides/src/View/UI/index.ts b/packages/ui-plugin-slides/src/View/UI/index.tsdeleted file mode 100644index e69de29bb2..0000000000diff --git a/packages/ui-plugin-slides/src/View/index.tsx b/packages/ui-plugin-slides/src/View/index.tsxnew file mode 100644index 0000000000..92f17109d3--- /dev/null+++ b/packages/ui-plugin-slides/src/View/index.tsx@@ -0,0 +1,42 @@+import { isElement, render } from '@univerjs/base-ui';+import { App, BaseUIProps } from './App';++interface BaseSlideUIConfig extends BaseUIProps {+ container?: HTMLElement | string;+}++export class UI {+ constructor(props: BaseSlideUIConfig) {+ this._initialize(props);+ }++ static create(props: BaseSlideUIConfig) {+ return new UI(props);+ }++ private _initialize(props: BaseSlideUIConfig) {+ let renderContainer: HTMLElement;+ const container = props.container;++ if (typeof container === 'string') {+ const containerDOM = document.getElementById(container);+ if (containerDOM == null) {+ renderContainer = document.createElement('div');+ renderContainer.id = container;+ } else {+ renderContainer = containerDOM;+ }+ } else if (isElement(container)) {+ renderContainer = container!;+ } else {+ renderContainer = document.createElement('div');+ renderContainer.id = 'univer';+ }++ render(<App {...props} />, renderContainer);+ }+}++export * from './SlideContainer';+export * from './Toolbar';+export * from './Common';