Skip to content

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.

xiugai

tonytonychopper123f9bcfcfa22c4
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 520f41678b..75040296fd 100644
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
-npm run pre-lint
+# npm run pre-lint
diff --git a/examples/univer-doc-ts/src/main.tsx b/examples/univer-doc-ts/src/main.tsx
index d54bedb52c..60332f3ef2 100644
--- a/examples/univer-doc-ts/src/main.tsx
+++ b/examples/univer-doc-ts/src/main.tsx
@@ -3,7 +3,7 @@ import { RenderEngine } from '@univerjs/base-render';
import { DocPlugin } from '@univerjs/base-docs';
import { DEFAULT_DOCUMENT_DATA_EN } from '@univerjs/common-plugin-data';
-import { DocUIPlugin } from "@univerjs/ui-plugin-docs";
+import { DocUIPlugin } from '@univerjs/ui-plugin-docs';
// univer
const univer = new Univer();
@@ -15,12 +15,16 @@ univer.install(new RenderEngine());
const univerdoc = UniverDoc.newInstance(DEFAULT_DOCUMENT_DATA_EN);
univer.addUniverDoc(univerdoc);
+univerdoc.installPlugin(new DocPlugin());
+
// univerdoc.installPlugin(new DocPlugin());
-univer.install(new DocUIPlugin({
- container: 'univerdoc',
- layout: {
- docContainerConfig:{
- innerLeft: true,
- }
- },
-}))
+univer.install(
+ new DocUIPlugin({
+ container: 'univerdoc',
+ layout: {
+ docContainerConfig: {
+ innerLeft: true,
+ },
+ },
+ })
+);
diff --git a/packages/base-docs/src/Controller/DocumentController.ts b/packages/base-docs/src/Controller/DocumentController.ts
index df2478a414..a5c56ce636 100644
--- a/packages/base-docs/src/Controller/DocumentController.ts
+++ b/packages/base-docs/src/Controller/DocumentController.ts
@@ -1,9 +1,9 @@
-import { BooleanNumber, CommandManager } from '@univerjs/core';
import { DocPlugin, IDocPluginConfig } from '../DocPlugin';
import { InputController } from './InputController';
export class DocumentController {
private _inputController: InputController;
+
constructor(private _plugin: DocPlugin, private _config: Partial<IDocPluginConfig> = {}) {
this._initialize();
}
diff --git a/packages/base-docs/src/Controller/InfoBarController.ts b/packages/base-docs/src/Controller/InfoBarController.ts
index 12ee661414..81629a9d70 100644
--- a/packages/base-docs/src/Controller/InfoBarController.ts
+++ b/packages/base-docs/src/Controller/InfoBarController.ts
@@ -1,7 +1,4 @@
-import { PLUGIN_NAMES } from '@univerjs/core';
-import { InfoBarModel } from '../Model/InfoBarModel';
import { DocPlugin } from '../DocPlugin';
-import { InfoBar } from '../View/UI/InfoBar';
type IProps = {
locale?: string;
@@ -18,67 +15,9 @@ export interface BaseInfoBarProps {
}
export class InfoBarController {
- private _infoBarModel: InfoBarModel;
-
- private _infoBar: InfoBar;
-
private _plugin: DocPlugin;
- private _infoList: BaseInfoBarProps;
-
constructor(plugin: DocPlugin) {
this._plugin = plugin;
-
- // TODO get name from config
- const name = 'UniverDoc Demo';
- this._infoBarModel = new InfoBarModel(name);
-
- this._infoList = {
- back: {
- locale: 'info.return',
- },
- update: {
- locale: 'info.detailUpdate',
- },
- save: {
- locale: 'info.detailSave',
- },
- rename: {
- locale: 'info.tips',
- },
- sheet: {
- label: name,
- onBlur: (e) => {
- this.setDocName(e);
- },
- },
- };
- this._initialize();
- }
-
- private _initialize() {
- const context = this._plugin.context;
- const manager = context.getObserverManager();
-
- manager.requiredObserver<InfoBar>('onInfoBarDidMountObservable', PLUGIN_NAMES.DOCUMENT).add((component) => {
- this._infoBar = component;
- this.resetInfoList(this._infoList);
- });
- }
-
- resetInfoList(list: BaseInfoBarProps) {
- const locale = this._plugin.context.getLocale();
- for (let k in list) {
- if (list[k].locale) {
- list[k].label = locale.get(list[k].locale);
- }
- }
- this._infoBar.setInfoList(list);
- }
-
- setDocName(e: FocusEvent) {
- const target = e.target as HTMLInputElement;
- const name = target.value;
- this._infoBarModel.setName(name);
}
}
diff --git a/packages/base-docs/src/Controller/InputController.ts b/packages/base-docs/src/Controller/InputController.ts
index 8875c0356d..13a01ae3db 100644
--- a/packages/base-docs/src/Controller/InputController.ts
+++ b/packages/base-docs/src/Controller/InputController.ts
@@ -1,6 +1,6 @@
import { Documents, IDocumentSkeletonSpan, SpanType } from '@univerjs/base-render';
import { TextSelection } from '@univerjs/base-render/src/Component/Docs/Common/TextSelection';
-import { KeyboardKeyType, Logger, Nullable } from '@univerjs/core';
+import { KeyboardKeyType, Nullable } from '@univerjs/core';
import { DocPlugin } from '../DocPlugin';
export class InputController {
diff --git a/packages/base-docs/src/Controller/ToolbarController.ts b/packages/base-docs/src/Controller/ToolbarController.ts
index 5b4ff11bdc..cb0a360f80 100644
--- a/packages/base-docs/src/Controller/ToolbarController.ts
+++ b/packages/base-docs/src/Controller/ToolbarController.ts
@@ -1,23 +1,4 @@
-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 { DocPlugin } from '../DocPlugin';
-import { defaultLayout, ILayout } from '../View/UI/DocContainer';
-
-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 {
color: string;
@@ -28,291 +9,9 @@ interface BorderInfo {
*
*/
export class ToolbarController {
- private _toolbarModel: ToolbarModel;
-
private _plugin: DocPlugin;
- private _toolbarComponent: Toolbar;
-
- private _toolList: IToolbarItemProps[];
-
- private _lineColor: LineColor;
-
- Render: BaseComponentRender;
-
- private _borderInfo: BorderInfo; //存储边框信息
-
constructor(plugin: DocPlugin) {
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'),
- };
-
- 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) {}
}
diff --git a/packages/base-docs/src/DocPlugin.tsx b/packages/base-docs/src/DocPlugin.tsx
index ea807e8a41..b2d25cdf4d 100644
--- a/packages/base-docs/src/DocPlugin.tsx
+++ b/packages/base-docs/src/DocPlugin.tsx
@@ -1,59 +1,36 @@
-import { DocContext, Plugin, PLUGIN_NAMES, UniverSheet, Tools, AsyncFunction } from '@univerjs/core';
+import { DocContext, Plugin, PLUGIN_NAMES, UniverSheet } from '@univerjs/core';
+import { Engine, RenderEngine } from '@univerjs/base-render';
import { zh, en } from './Locale';
-import { IOCContainer } from '@univerjs/core';
-import { Component, getRefElement, isElement, ISlotProps, RefObject, render } from '@univerjs/base-ui';
import { DocPluginObserve, install } from './Basics/Observer';
import { ToolbarController } from './Controller/ToolbarController';
import { DocumentController } from './Controller/DocumentController';
-import { BaseDocContainerConfig, defaultLayout, DocContainer, IDocPluginConfigBase, ILayout } from './View/UI/DocContainer';
import { InfoBarController } from './Controller/InfoBarController';
-import { Engine, RenderEngine } from '@univerjs/base-render';
import { CanvasView } from './View/Render/CanvasView';
import { CANVAS_VIEW_KEY } from './View/Render';
import { DocsView } from './View/Render/Views';
+import { IDocPluginConfigBase } from './Interface';
-export interface IDocPluginConfig extends IDocPluginConfigBase {
- container: HTMLElement | string;
-}
+export interface IDocPluginConfig extends IDocPluginConfigBase {}
-const DEFAULT_DOCUMENT_PLUGIN_DATA = {
- container: 'univerdoc',
- layout: defaultLayout,
-};
+const DEFAULT_DOCUMENT_PLUGIN_DATA = {};
export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
private _config: IDocPluginConfig;
- private _toolbarRef: RefObject<HTMLElement>;
- private _infoBarControl: InfoBarController;
-
- private _splitLeftRef: RefObject<HTMLDivElement>;
- private _contentRef: RefObject<HTMLDivElement>;
+ private _infoBarControl: InfoBarController;
private _canvasView: CanvasView;
- private _addButtonFunc: Function;
-
- private _addSiderFunc: AsyncFunction<ISlotProps>;
-
- private _addMainFunc: Function;
-
- private _showSiderByNameFunc: Function;
-
- private _showMainByNameFunc: Function;
-
private _canvasEngine: Engine;
private _toolbarControl: ToolbarController;
private _documentController: DocumentController;
- private _componentList: Map<string, any>;
-
constructor(config: Partial<IDocPluginConfig> = {}) {
super(PLUGIN_NAMES.DOCUMENT);
- this._config = Tools.commonExtend(DEFAULT_DOCUMENT_PLUGIN_DATA, config);
+ this._config = Object.assign(DEFAULT_DOCUMENT_PLUGIN_DATA, config);
}
static create(config?: IDocPluginConfig) {
@@ -64,117 +41,33 @@ export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
universheetInstance.installPlugin(this);
}
- initialize(): void {
- const context = this.getContext();
-
- this.getObserver('onDocContainerDidMountObservable')?.add(() => {
- this._initializeRender();
- });
+ initialize(ctx: DocContext): void {
+ this.context = ctx;
- /**
- * load more Locale object
- */
- context.getLocale().load({
- en: en,
- zh: zh,
+ 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);
- }
+ install(this);
+ this.initController();
+ this.initCanvasView();
+ }
+ initController() {
this._toolbarControl = new ToolbarController(this);
this._infoBarControl = new InfoBarController(this);
- this._documentController = new DocumentController(this, this.config);
-
- const docContainer = this._initContainer(this._config.container);
-
- const config: BaseDocContainerConfig = {
- skin: 'default',
- layout: this._config.layout,
- container: docContainer,
- 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(<DocContainer config={config} />, docContainer);
- }
-
- /**
- * Convert id to DOM
- * @param container
- * @returns
- */
- private _initContainer(container: HTMLElement | string) {
- let docContainer = null;
- if (typeof container === 'string') {
- const containerDOM = document.getElementById(container);
- if (containerDOM == null) {
- docContainer = document.createElement('div');
- docContainer.id = container;
- } else {
- docContainer = containerDOM;
- }
- } else if (isElement(container)) {
- docContainer = container;
- } else {
- docContainer = document.createElement('div');
- docContainer.id = 'univerdoc';
- }
-
- return docContainer;
+ this._documentController = new DocumentController(this, this._config);
}
- private _initializeRender() {
- const engine = this.getPluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER)?.getEngine()!;
-
- this.register(engine);
- }
-
- 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;
-
- engineInstance.setContainer(container);
+ initCanvasView() {
+ const engine = this.getContext().getUniver().getGlobalContext().getPluginManager().getPluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER)?.getEngine()!;
- this._canvasView = new CanvasView(engineInstance, this);
+ this._canvasEngine = engine;
- window.addEventListener('resize', () => {
- engineInstance.resize();
- });
- // window.onresize = () => {
- // engineInstance.resize();
- // };
+ if (this._canvasView == null) {
+ this._canvasView = new CanvasView(engine, this);
+ }
}
getConfig() {
@@ -205,9 +98,6 @@ export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
return this.getMainComponent().getEditorInputEvent();
}
- getContentRef(): RefObject<HTMLDivElement> {
- return this._contentRef;
- }
getToolbarControl() {
return this._toolbarControl;
}
@@ -217,17 +107,8 @@ export class DocPlugin extends Plugin<DocPluginObserve, DocContext> {
}
onMounted(ctx: DocContext): void {
- install(this);
- this.initialize();
+ this.initialize(ctx);
}
onDestroy(): void {}
-
- registerComponent(name: string, component: Component, props?: any) {
- this._componentList.set(name, component);
- }
-
- getRegisterComponent(name: string) {
- return this._componentList.get(name);
- }
}
diff --git a/packages/base-docs/src/Interface/DocPluginConfig.ts b/packages/base-docs/src/Interface/DocPluginConfig.ts
new file mode 100644
index 0000000000..b7542483af
--- /dev/null
+++ b/packages/base-docs/src/Interface/DocPluginConfig.ts
@@ -0,0 +1 @@
+export interface IDocPluginConfigBase {}
diff --git a/packages/base-docs/src/Interface/index.ts b/packages/base-docs/src/Interface/index.ts
new file mode 100644
index 0000000000..671565ae07
--- /dev/null
+++ b/packages/base-docs/src/Interface/index.ts
@@ -0,0 +1 @@
+export * from './DocPluginConfig';
diff --git a/packages/base-docs/src/View/UI/Common/Item/Item.tsx b/packages/base-docs/src/View/UI/Common/Item/Item.tsx
deleted file mode 100644
index b39207b35b..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/Item/index.module.less b/packages/base-docs/src/View/UI/Common/Item/index.module.less
deleted file mode 100644
index 0541ceaed5..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/Line/LineBold.tsx b/packages/base-docs/src/View/UI/Common/Line/LineBold.tsx
deleted file mode 100644
index 54654aaec5..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/Line/LineColor.tsx b/packages/base-docs/src/View/UI/Common/Line/LineColor.tsx
deleted file mode 100644
index 94b2aa24de..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/Select/Select.tsx b/packages/base-docs/src/View/UI/Common/Select/Select.tsx
deleted file mode 100644
index 441d11a8b7..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/Select/index.module.less b/packages/base-docs/src/View/UI/Common/Select/index.module.less
deleted file mode 100644
index 6e0db19960..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/TextButton/TextButton.tsx b/packages/base-docs/src/View/UI/Common/TextButton/TextButton.tsx
deleted file mode 100644
index 630019c0af..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/TextButton/index.module.css b/packages/base-docs/src/View/UI/Common/TextButton/index.module.css
deleted file mode 100644
index 4fb4faa3e5..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/Common/TextButton/index.module.less b/packages/base-docs/src/View/UI/Common/TextButton/index.module.less
deleted file mode 100644
index 305b85ad5c..0000000000
--- a/packages/base-docs/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 file
diff --git a/packages/base-docs/src/View/UI/Common/index.ts b/packages/base-docs/src/View/UI/Common/index.ts
deleted file mode 100644
index 3ac4f375d8..0000000000
--- a/packages/base-docs/src/View/UI/Common/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-// Basics business components
diff --git a/packages/base-docs/src/View/UI/DocContainer/DocContainer.tsx b/packages/base-docs/src/View/UI/DocContainer/DocContainer.tsx
deleted file mode 100644
index 4a153f9200..0000000000
--- a/packages/base-docs/src/View/UI/DocContainer/DocContainer.tsx
+++ /dev/null
@@ -1,739 +0,0 @@
-import {
- AppContext,
- IMainProps,
- IMainState,
- ISiderState,
- ISlotElement,
- ISlotProps,
- Component,
- BaseComponentSheet,
- BaseComponentRender,
- createRef,
- RefObject,
- cloneElement,
- BaseComponentProps,
- Description,
-} from '@univerjs/base-ui';
-import { AsyncFunction, ContextBase, DocContext, 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 { DocPlugin } from '../../../DocPlugin';
-import { InfoBar } from '../InfoBar';
-
-export interface IDocPluginConfigBase {
- 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 IDocPluginConfigBase {
- layout: ILayout;
-}
-
-export interface BaseDocContainerConfig extends BaseComponentProps, IDocPluginConfigBase {
- container: HTMLElement;
- skin: string;
- context: ContextBase;
- 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 BaseDocContainerProps {
- config: BaseDocContainerConfig;
-}
-
-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,
-};
-
-/**
- * DocContainer
- */
-
-// 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 DocContainer extends Component<BaseDocContainerProps, 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: BaseDocContainerProps) {
- 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<DocPlugin>(PLUGIN_NAMES.DOCUMENT)
- .getObserver('onDocContainerDidMountObservable')
- ?.notifyObservers(this);
- }
- );
-
- // this.initEvent();
- }
-
- /**
- * 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={{
- display: layout.innerLeft ? 'block' : 'none',
- }}
- >
- {/* innerLeft */}
- </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-docs/src/View/UI/InfoBar/InfoBar.tsx b/packages/base-docs/src/View/UI/InfoBar/InfoBar.tsx
deleted file mode 100644
index 02c159f9cb..0000000000
--- a/packages/base-docs/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.DOCUMENT)?.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-docs/src/View/UI/ToolBar/SingleButton.tsx b/packages/base-docs/src/View/UI/ToolBar/SingleButton.tsx
deleted file mode 100644
index 561380bec7..0000000000
--- a/packages/base-docs/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-docs/src/View/UI/ToolBar/Toolbar.tsx b/packages/base-docs/src/View/UI/ToolBar/Toolbar.tsx
deleted file mode 100644
index 6373512d47..0000000000
--- a/packages/base-docs/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 { DocPlugin } from '../../../DocPlugin';
-import { IToolbarItemProps } from '../../../Model/ToolbarModel';
-import { Select } from '../Common/Select/Select';
-import { TextButton } from '../Common/TextButton/TextButton';
-import styles from './index.module.less';
-
-interface IProps extends BaseComponentProps {
- style?: JSX.CSSProperties;
- toolList: IToolbarItemProps[];
- // forwardRefs?: RefObject<HTMLElement>;
-}
-
-interface IState {
- toolList: IToolbarItemProps[];
- moreToolList: IToolbarItemProps[];
- defaultToolList: IToolbarItemProps[];
- more: boolean;
- index: number;
- toolbarListWidths: number[];
- moreText: string;
-}
-
-export class 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<DocPlugin>(PLUGIN_NAMES.DOCUMENT);
-
- 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-docs/src/View/UI/ToolBar/index.module.css b/packages/base-docs/src/View/UI/ToolBar/index.module.css
deleted file mode 100644
index f22cf03dfb..0000000000
--- a/packages/base-docs/src/View/UI/ToolBar/index.module.css
+++ /dev/null
@@ -1,146 +0,0 @@
-.toolbar-warp {
- height: 40px;
- max-height: fit-content;
- width: 100%;
- overflow: unset;
- box-sizing: border-box;
- font-size: var(--font-size);
- background-color: var(--bg);
- position: relative;
- display: flex;
- align-items: center;
- border-bottom: 1px solid var(--border-color-base);
-}
-.toolbar-warp .single-button.more-hide {
- display: none;
-}
-.toolbar-warp .single-button.more-show {
- display: block;
-}
-.toolbar {
- max-width: 100%;
- color: var(--text-color);
- padding: 5px 15px;
- height: 40px;
- position: relative;
-}
-.toolbar > div {
- height: 26px;
- display: inline-block;
- vertical-align: middle;
- margin: 7px 3px 0 3px;
-}
-.toolbar > div.select-button:hover {
- background-color: #efefef;
-}
-.toolbar .cols-menu {
- overflow-y: auto;
-}
-.toolbar .select-label-string .drop-content > div {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- width: 90px;
-}
-.toolbar .select-color-picker-parent .select-item-content {
- width: 100%;
-}
-.toolbar .select-color-picker-parent ul {
- padding: 0;
-}
-.toolbar .select-color-picker-parent .select-color-picker {
- padding: 0;
-}
-.toolbar .select-color-picker-parent .select-color-picker .select-item {
- padding: 0;
-}
-.toolbar .single-button {
- margin: 0 3px;
-}
-.toolbar .single-button button {
- padding: 0px 5px;
- line-height: 1;
- font-size: 24px;
-}
-.toolbar .double-button {
- position: relative;
- display: flex;
- align-items: center;
- margin: 0 5px;
-}
-.toolbar .double-button .color-bottom {
- width: 10px;
- margin: 0 auto;
- outline: 2px solid;
- position: relative;
- bottom: 4px;
-}
-.toolbar .double-button .double-button-right {
- height: 100%;
- display: flex;
- align-items: center;
-}
-.toolbar .double-button .double-button-right .double-button-right-popup {
- box-shadow: var(--box-shadow-base);
- background-color: var(--bg);
- position: absolute;
- left: 0;
- top: 35px;
- width: max-content;
-}
-.toolbar .double-button .double-button-right .double-button-right-popup .double-button-menu-item {
- display: flex;
- align-content: center;
-}
-.toolbar .double-button .double-button-right .double-button-right-popup .double-button-menu-item .double-button-menu-item-icon {
- width: 25px;
- margin-right: 5px;
-}
-.toolbar .double-button .double-button-right .double-button-right-popup .double-button-menu-item .double-button-menu-item-content {
- display: flex;
- align-items: center;
-}
-.toolbar .double-button .double-button-right button {
- padding: 0;
- padding-right: 5px;
-}
-.toolbar .double-button button {
- padding: 0px 5px;
- line-height: 1;
-}
-.toolbar .double-button span[role='img'] {
- font-size: 24px;
-}
-.more-button {
- height: 35px;
- margin: 5px;
- display: none;
- padding: 0px 5px;
- line-height: 1;
-}
-.more-button.more-show {
- display: block;
-}
-.more-tool {
- height: 40px;
- display: none;
- align-items: center;
- padding: 0 10px;
- background-color: var(--bg);
- box-shadow: var(--box-shadow-base);
- position: absolute;
- right: 2em;
- top: 40px;
- z-index: 100;
-}
-.more-tool.more-show {
- display: flex;
-}
-.more-tool button {
- padding: 0px 5px;
- line-height: 1;
- font-size: 24px;
-}
-span[role='img'].univericon-nextIcon {
- font-size: 12px;
-}
diff --git a/packages/base-docs/src/View/UI/ToolBar/index.ts b/packages/base-docs/src/View/UI/ToolBar/index.ts
deleted file mode 100644
index 8b58103be2..0000000000
--- a/packages/base-docs/src/View/UI/ToolBar/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './Toolbar';
-export * from './SingleButton';
diff --git a/packages/base-ui/src/Components/Button/Button.tsx b/packages/base-ui/src/Components/Button/Button.tsx
index 50a2eef128..fecdd5bac5 100644
--- a/packages/base-ui/src/Components/Button/Button.tsx
+++ b/packages/base-ui/src/Components/Button/Button.tsx
@@ -59,7 +59,7 @@ class Button extends Component<BaseButtonProps, IState> {
getClass() {
const { isActive } = this.state;
- const { type, shape, danger, block, loading, size, className, unActive } = this.props;
+ const { type, shape, danger, block, loading, size, className } = this.props;
return joinClassNames(
styles.btn,
{
@@ -76,7 +76,7 @@ class Button extends Component<BaseButtonProps, IState> {
}
handleClick = (e: MouseEvent) => {
- const { disabled, onClick, unActive } = this.props;
+ const { disabled, onClick, unActive = true } = this.props;
if (disabled) {
e.preventDefault();
diff --git a/packages/sheets-plugin-find/src/Controller/FindController.ts b/packages/sheets-plugin-find/src/Controller/FindController.ts
index f77ba12a65..5a5a687d40 100644
--- a/packages/sheets-plugin-find/src/Controller/FindController.ts
+++ b/packages/sheets-plugin-find/src/Controller/FindController.ts
@@ -14,7 +14,6 @@ export class FindController {
name: FIND_PLUGIN_NAME,
toolbarType: 1,
tooltip: 'find.findLabel',
- unActive: true,
customLabel: {
name: 'SearchIcon',
},
diff --git a/packages/sheets-plugin-find/src/Controller/FindModalController.ts b/packages/sheets-plugin-find/src/Controller/FindModalController.ts
index d67e6923f9..a828d9fe26 100644
--- a/packages/sheets-plugin-find/src/Controller/FindModalController.ts
+++ b/packages/sheets-plugin-find/src/Controller/FindModalController.ts
@@ -22,12 +22,37 @@ export class FindModalController {
this._findModal?.showFindModal(show);
}
+ findNext(text: string) {
+ const TextFinder = this._plugin.getTextFinder().searchText(text);
+ if (!TextFinder) return { count: 0, current: 0 };
+ TextFinder.findNext();
+ const count = TextFinder.getCount();
+ const current = TextFinder.getCurrentIndex();
+ return {
+ count,
+ current: current + 1,
+ };
+ }
+
+ replaceText(text: string) {
+ const TextFinder = this._plugin.getTextFinder().searchText(text);
+ if (!TextFinder) return;
+ TextFinder.replaceWith(text);
+ const count = TextFinder.getCount();
+ const current = TextFinder.getCurrentIndex();
+ return {
+ count,
+ current: current + 1,
+ };
+ }
+
private _initialize() {
const sheetUIPlugin = this._plugin.getContext().getUniver().getGlobalContext().getPluginManager().getRequirePluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME);
sheetUIPlugin.addSlot(FIND_PLUGIN_NAME + FindModal.name, {
component: FindModal,
props: {
getComponent: this.getComponent.bind(this),
+ findNext: this.findNext.bind(this),
},
});
}
diff --git a/packages/sheets-plugin-find/src/Domain/TextFind.ts b/packages/sheets-plugin-find/src/Domain/TextFind.ts
index 676c57d059..1884a3646b 100644
--- a/packages/sheets-plugin-find/src/Domain/TextFind.ts
+++ b/packages/sheets-plugin-find/src/Domain/TextFind.ts
@@ -1,323 +1,375 @@
-// import { Range, Worksheet, RangeList, FormatType, IRangeData } from '@univerjs/core';
-// import { getRegExpStr } from '../Util/util';
-// import { FindType } from '../IData';
-
-// export class TextFinder {
-// private _text: string | FormatType;
-
-// private _type: FindType; // 查找类型
-
-// private _range: Range[]; // 保存匹配到的单元格range格式
-
-// private _rangeData: Range[] = []; // ranglist每个单元格range格式
-
-// private _rangeList: IRangeData[]; // 初始rangeList
-
-// private _workSheet: Worksheet;
-
-// private _index: number;
-
-// private _matchCase: boolean = false; // 大小写匹配
-
-// private _matchEntire: boolean = false; // 完全匹配
-
-// private _useRegEx: boolean = false; // 正则匹配
-
-// private _matchFormula: boolean = false; // 匹配公式文字
-
-// private _startRange: Range | null; // 从这个位置后开始找
-
-// constructor(workSheet: Worksheet, type: FindType, text?: string | FormatType) {
-// this._workSheet = workSheet;
-// this._type = type;
-// if (text) {
-// this._text = text;
-// }
-// this._index = -1;
-// this._rangeList = this._workSheet.getActiveRangeList().getRangeList();
-// if (
-// this._rangeList.length == 0 ||
-// (this._rangeList.length == 1 && this._rangeList[0].startRow == this._rangeList[0].endRow && this._rangeList[0].startColumn == this._rangeList[0].endColumn)
-// ) {
-// this._rangeList = [
-// {
-// startRow: 0,
-// endRow: this._workSheet.getLastRow(),
-// startColumn: 0,
-// endColumn: this._workSheet.getLastColumn(),
-// },
-// ];
-// }
-// for (let i = 0; i < this._rangeList.length; i++) {
-// const range = new Range(this._workSheet, this._rangeList[i]);
-// for (let j = this._rangeList[i].startRow; j <= this._rangeList[i].endRow; j++) {
-// for (let k = this._rangeList[i].startColumn; k <= this._rangeList[i].endColumn; k++) {
-// this._rangeData.push(range.getCell(j, k));
-// }
-// }
-// }
-// }
-
-// /**
-// * Returns all cells matching the search criteria.
-// */
-// findAll(): Range[] | null {
-// this._index = -1;
-// this._match();
-// if (this._range.length == 0) return null;
-// return this._range;
-// }
-
-// /**
-// * Returns the next cell matching the search criteria.
-// */
-// findNext(): Range | null {
-// this._match();
-// if (this._range.length == 0) return null;
-// this._index++;
-// if (this._index > this._range.length - 1) this._index = 0;
-// return this._range[this._index];
-// }
-
-// /**
-// * Returns the previous cell matching the search criteria.
-// */
-// findPrevious(): Range | null {
-// this._match();
-// if (this._range.length == 0) return null;
-// this._index--;
-// if (this._index < 0) this._index = this._range.length - 1;
-// return this._range[this._index];
-// }
-
-// /**
-// * If true, configures the search to match the search text's case exactly, otherwise the search defaults to case-insensitive matching.
-// */
-// matchCase(matchCase: boolean): TextFinder {
-// this._matchCase = matchCase;
-// return this;
-// }
-
-// /**
-// * If true, configures the search to match the entire contents of a cell; otherwise, the search defaults to partial matching.
-// */
-// matchEntireCell(matchEntire: boolean): TextFinder {
-// this._matchEntire = matchEntire;
-// return this;
-// }
-
-// /**
-// * If true, configures the search to return matches that appear within formula text; otherwise cells with formulas are considered based on their displayed value.
-// */
-// matchFormulaText(matchFormulaText: boolean): TextFinder {
-// this._matchFormula = matchFormulaText;
-// return this;
-// }
-
-// /**
-// * If true, configures the search to interpret the search string as a regular expression; otherwise the search interprets the search string as normal text.
-// */
-// useRegularExpression(useRegEx: boolean): TextFinder {
-// this._useRegEx = useRegEx;
-// return this;
-// }
-
-// /**
-// * TODO
-// * 替换还需考虑编辑模式和保护模式,整个workbook
-// */
-// /**
-// * Replaces all matches with the specified text. Returns the number of occurrences replaced, which may be different from the number of matched cells.
-// */
-// replaceAllWith(replaceText: string): number {
-// const range = this.findAll();
-// if (!range) return 0;
-// const rangType = [];
-// for (let i = 0; i < range.length; i++) {
-// rangType.push(range[i].getRangeData());
-// }
-// const rangeList = new RangeList(this._workSheet, rangType);
-// rangeList.setValue(replaceText);
-// return range.length;
-// }
-
-// /**
-// * Replaces the search text in the currently matched cell with the specified text and returns the number of occurrences replaced.
-// */
-// replaceWith(replaceText: string): number {
-// const range = this.findNext();
-// if (!range) return 0;
-// this._index--;
-// range.setValue(replaceText);
-// return 1;
-// }
-
-// /**
-// * Configures the search to start searching immediately after the specified cell range.
-// */
-// startFrom(startRange: Range): TextFinder {
-// this._startRange = startRange;
-// return this;
-// }
-
-// /**
-// * Returns the current cell matching the search criteria.
-// */
-// getCurrentMatch(): Range | null {
-// if (this._index < 0) return null;
-// return this._range[this._index];
-// }
-
-// /**
-// * match rule
-// */
-// private _match = () => {
-// const choose = new Map<string | FormatType, () => Range[]>([
-// ['text', this._mathTxt],
-// ['condition', this._matchCondition],
-// ['intervalRow', () => this._matchInterval('row')],
-// ['intervalColumn', () => this._matchInterval('column')],
-// ['null', this._matchNull],
-// ['format', this._matchFormat],
-// ]);
-// let range;
-// if (this._type in FormatType) {
-// range = choose.get('format')!();
-// } else {
-// range = choose.get(this._type)!();
-// }
-// // range.sort((a, b) => a.getRangeData().startRow - b.getRangeData().startRow).sort((a, b) => a.getRangeData().startColumn - b.getRangeData().startColumn);
-// if (this._startRange) {
-// const startRange = this._startRange.getRangeData();
-// for (let i = 0; i < range.length; i++) {
-// const cell = range[i].getRangeData();
-// if (cell.startColumn <= startRange.endColumn) {
-// range.splice(i, 1);
-// i--;
-// } else if (cell.startRow < startRange.startRow) {
-// range.splice(i, 1);
-// i--;
-// }
-// }
-// }
-// this._range = range;
-// };
-
-// // 查找文本
-// private _mathTxt(): Range[] {
-// this._text = this._text as string;
-// const range = [];
-// for (let i = 0; i < this._rangeData.length; i++) {
-// let value = this._rangeData[i].getValue().m;
-// if (this._matchFormula) {
-// value = this._rangeData[i].getValue().f;
-// }
-// if (value != null) {
-// value = value.toString();
-// if (this._matchEntire) {
-// if (this._matchCase) {
-// if (this._text == value) {
-// range.push(this._rangeData[i]);
-// }
-// } else {
-// if (this._text.toLowerCase() == value.toLowerCase()) {
-// range.push(this._rangeData[i]);
-// }
-// }
-// } else if (this._useRegEx) {
-// let reg;
-// if (this._matchCase) {
-// reg = new RegExp(getRegExpStr(this._text), 'g');
-// } else {
-// reg = new RegExp(getRegExpStr(this._text), 'ig');
-// }
-
-// if (reg.test(value)) {
-// range.push(this._rangeData[i]);
-// }
-// } else {
-// let reg = new RegExp(getRegExpStr(this._text), 'ig');
-// if (reg.test(value)) {
-// range.push(this._rangeData[i]);
-// }
-// }
-// }
-// }
-// return range;
-// }
-
-// // 按format寻找
-// private _matchFormat(): Range[] {
-// const range = [];
-// for (let i = 0; i < this._rangeData.length; i++) {
-// const format = this._rangeData[i].getValue().fm?.t;
-// if (!format) continue;
-// if (format == this._type) {
-// range.push(this._rangeData[i]);
-// }
-// }
-// return range;
-// }
-
-// // 寻找null的单元格
-// private _matchNull(): Range[] {
-// const range = [];
-// for (let i = 0; i < this._rangeData.length; i++) {
-// let value = this._rangeData[i].getValue().v;
-// if (value == null) {
-// range.push(this._rangeData[i]);
-// }
-// }
-// return range;
-// }
-
-// // todo: 等condition插件定好结构
-// // 寻找条件格式
-// private _matchCondition(): Range[] {
-// const range: Range[] = [];
-// return range;
-// }
-
-// // todo: 移到UI里,增加开始行列,间隔行列数
-// // 寻找间隔行间隔列,移到UI里
-// private _matchInterval(param: 'column' | 'row'): Range[] {
-// const range = [];
-// for (let i = 0; i < this._rangeList.length; i++) {
-// const rangeArea = this._rangeList[i];
-// if (param == 'row') {
-// if (rangeArea.startRow == rangeArea.endRow) {
-// continue;
-// }
-// for (let j = rangeArea.startRow; j <= rangeArea.endRow; j++) {
-// if ((j - rangeArea.startRow) % 2 == 0) {
-// range.push(
-// new Range(this._workSheet, {
-// startRow: j,
-// endRow: j,
-// startColumn: rangeArea.startColumn,
-// endColumn: rangeArea.endColumn,
-// })
-// );
-// }
-// }
-// } else {
-// if (rangeArea.startColumn == rangeArea.endColumn) {
-// continue;
-// }
-// for (let j = rangeArea.startColumn; j <= rangeArea.endColumn; j++) {
-// if ((j - rangeArea.startColumn) % 2 == 0) {
-// range.push(
-// new Range(this._workSheet, {
-// startRow: rangeArea.startRow,
-// endRow: rangeArea.endRow,
-// startColumn: j,
-// endColumn: j,
-// })
-// );
-// }
-// }
-// }
-// }
-// return range;
-// }
-// }
+import { Range, RangeList, FormatType, IGridRange, ObjectMatrix, ICellData, Nullable } from '@univerjs/core';
+import { SheetPlugin } from '@univerjs/base-sheets';
+import { getRegExpStr } from '../Util/util';
+import { FindType } from '../IData';
+import { SelectSearch } from '../View/UI/FindModal';
+import { FindPlugin } from '../FindPlugin';
+
+export class TextFinder {
+ private _plugin: FindPlugin;
+
+ private _text: string | FormatType;
+
+ private _type: FindType = 'text'; // 查找类型
+
+ private _searchRange: SelectSearch = SelectSearch.CurrentSheet; //查找范围
+
+ private _range: IGridRange[]; // 保存匹配到的单元格range格式
+
+ private _rangeData: IGridRange[] = []; // rangList每个单元格range格式
+
+ private _index: number;
+
+ private _matchCase: boolean = false; // 大小写匹配
+
+ private _matchEntire: boolean = false; // 完全匹配
+
+ private _useRegEx: boolean = false; // 正则匹配
+
+ private _matchFormula: boolean = false; // 匹配公式文字
+
+ private _startRange: Nullable<Range>; // 从这个位置后开始找
+
+ constructor(plugin: FindPlugin) {
+ this._plugin = plugin;
+ }
+
+ /**
+ * Returns all cells matching the search criteria.
+ */
+ findAll(): Nullable<TextFinder> {
+ this._match();
+ if (!this._range.length) return null;
+ return this;
+ }
+
+ /**
+ * Returns the next cell matching the search criteria.
+ */
+ findNext(): Nullable<TextFinder> {
+ if (this._range.length === 0) return null;
+ this._index++;
+ if (this._index > this._range.length - 1) this._index = 0;
+ this._highlightCell(this._range[this._index]);
+ return this;
+ }
+
+ /**
+ * Returns the previous cell matching the search criteria.
+ */
+ findPrevious(): Nullable<TextFinder> {
+ if (this._range.length === 0) return null;
+ this._index--;
+ if (this._index < 0) this._index = this._range.length - 1;
+ this._highlightCell(this._range[this._index]);
+ return this;
+ }
+
+ getCount(): number {
+ return this._range.length;
+ }
+
+ getCurrentIndex(): number {
+ return this._index;
+ }
+
+ /**
+ * If true, configures the search to match the search text's case exactly, otherwise the search defaults to case-insensitive matching.
+ */
+ matchCase(matchCase: boolean): TextFinder {
+ this._matchCase = matchCase;
+ return this;
+ }
+
+ /**
+ * If true, configures the search to match the entire contents of a cell; otherwise, the search defaults to partial matching.
+ */
+ matchEntireCell(matchEntire: boolean): TextFinder {
+ this._matchEntire = matchEntire;
+ return this;
+ }
+
+ /**
+ * If true, configures the search to return matches that appear within formula text; otherwise cells with formulas are considered based on their displayed value.
+ */
+ matchFormulaText(matchFormulaText: boolean): TextFinder {
+ this._matchFormula = matchFormulaText;
+ return this;
+ }
+
+ /**
+ * If true, configures the search to interpret the search string as a regular expression; otherwise the search interprets the search string as normal text.
+ */
+ useRegularExpression(useRegEx: boolean): TextFinder {
+ this._useRegEx = useRegEx;
+ return this;
+ }
+
+ /**
+ * TODO
+ * 替换还需考虑编辑模式和保护模式,整个workbook
+ */
+ /**
+ * Replaces all matches with the specified text. Returns the number of occurrences replaced, which may be different from the number of matched cells.
+ */
+ replaceAllWith(replaceText: string): number {
+ const range = this.findAll();
+ if (!range) return 0;
+ const rangType = [];
+ for (let i = 0; i < range.length; i++) {
+ rangType.push(range[i].getRangeData());
+ }
+ const rangeList = new RangeList(this._workSheet, rangType);
+ rangeList.setValue(replaceText);
+ return range.length;
+ }
+
+ /**
+ * Replaces the search text in the currently matched cell with the specified text and returns the number of occurrences replaced.
+ */
+ replaceWith(replaceText: string): number {
+ if (!this._range.length) return 0;
+ const range = this._range[this._index];
+ const sheet = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(range.sheetId);
+ sheet?.getRange(range.rangeData).setValue(replaceText);
+
+ this._index--;
+ return 1;
+ }
+
+ /**
+ * Configures the search to start searching immediately after the specified cell range.
+ */
+ startFrom(startRange: Range): TextFinder {
+ this._startRange = startRange;
+ return this;
+ }
+
+ /**
+ * Returns the current cell matching the search criteria.
+ */
+ getCurrentMatch(): IGridRange | null {
+ if (this._index < 0) return null;
+ return this._range[this._index];
+ }
+
+ // 开始查找
+ searchText(text: string | FormatType, type: FindType = 'text', searchRange: SelectSearch = SelectSearch.CurrentSheet): TextFinder | null {
+ if (!text) return null;
+ // 查找范围变化或者初始化rangeData
+ if (this._searchRange !== searchRange || !this._rangeData.length) {
+ this._getRange(searchRange);
+ }
+ // 查找文字或者类型变化
+ if (this._text !== text || this._type !== type) {
+ this._type = type;
+ this._text = text;
+ this._index = -1;
+ this.findAll();
+ }
+ return this;
+ }
+
+ private _getRange(searchRange: SelectSearch) {
+ if (searchRange === SelectSearch.CurrentSheet) {
+ const sheet = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();
+ const sheetId = sheet.getSheetId();
+ const rangeList: IGridRange = {
+ sheetId,
+ rangeData: {
+ startRow: 0,
+ endRow: sheet.getLastRow(),
+ startColumn: 0,
+ endColumn: sheet.getLastColumn(),
+ },
+ };
+ this._rangeData = [rangeList];
+ }
+ }
+
+ /**
+ * match rule
+ */
+ private _match = () => {
+ const matchMap = new Map<string | FormatType, () => IGridRange[]>([
+ ['text', this._mathTxt.bind(this)],
+ // ['condition', this._matchCondition],
+ // ['intervalRow', () => this._matchInterval('row')],
+ // ['intervalColumn', () => this._matchInterval('column')],
+ // ['null', this._matchNull],
+ // ['format', this._matchFormat],
+ ]);
+ let range;
+ if (this._type in FormatType) {
+ range = matchMap.get('format')!();
+ } else {
+ range = matchMap.get(this._type)!();
+ }
+ // range.sort((a, b) => a.getRangeData().startRow - b.getRangeData().startRow).sort((a, b) => a.getRangeData().startColumn - b.getRangeData().startColumn);
+ // if (this._startRange) {
+ // const startRange = this._startRange.getRangeData();
+ // for (let i = 0; i < range.length; i++) {
+ // const cell = range[i].getRangeData();
+ // if (cell.startColumn <= startRange.endColumn) {
+ // range.splice(i, 1);
+ // i--;
+ // } else if (cell.startRow < startRange.startRow) {
+ // range.splice(i, 1);
+ // i--;
+ // }
+ // }
+ // }
+ this._range = range;
+ };
+
+ // 查找文本
+ private _mathTxt(): IGridRange[] {
+ const range: IGridRange[] = [];
+ for (let i = 0; i < this._rangeData.length; i++) {
+ const sheet = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(this._rangeData[i].sheetId);
+ if (!sheet) return [];
+ let matrix: ObjectMatrix<ICellData> = new ObjectMatrix<ICellData>();
+ if (this._matchFormula) {
+ // matrix = this._rangeData[i].getValue().f;
+ } else {
+ matrix = sheet.getRange(this._rangeData[i].rangeData).getMatrix();
+ }
+
+ if (this._matchEntire) {
+ matrix.forValue((row, col, value) => {
+ if (!value.m) return;
+ if ((this._matchCase && value.m === this._text) || (this._text as string).toLowerCase() === value.m.toLowerCase()) {
+ range.push({
+ sheetId: this._rangeData[i].sheetId,
+ rangeData: {
+ startRow: row,
+ endRow: row,
+ startColumn: col,
+ endColumn: col,
+ },
+ });
+ }
+ });
+ }
+ // else if (this._useRegEx) {
+ // let reg;
+ // if (this._matchCase) {
+ // reg = new RegExp(getRegExpStr(this._text), 'g');
+ // } else {
+ // reg = new RegExp(getRegExpStr(this._text), 'ig');
+ // }
+
+ // if (reg.test(value)) {
+ // range.push(this._rangeData[i]);
+ // }
+ // }
+ else {
+ let reg = new RegExp(getRegExpStr(this._text as string), 'ig');
+ matrix.forValue((row, col, value) => {
+ if (!value.m) return;
+ if (reg.test(value.m)) {
+ range.push({
+ sheetId: this._rangeData[i].sheetId,
+ rangeData: {
+ startRow: row,
+ endRow: row,
+ startColumn: col,
+ endColumn: col,
+ },
+ });
+ }
+ });
+ }
+ }
+ return range;
+ }
+
+ // 高亮匹配单元格
+ private _highlightCell(range: IGridRange) {
+ this._plugin
+ .getContext()
+ .getUniver()
+ .getCurrentUniverSheetInstance()
+ .getWorkBook()
+ .getContext()
+ .getPluginManager()
+ .getPluginByName<SheetPlugin>('spreadsheet')
+ ?.getSelectionManager()
+ .setCurrentCell(range);
+ }
+
+ // 按format寻找
+ // private _matchFormat(): Range[] {
+ // const range = [];
+ // for (let i = 0; i < this._rangeData.length; i++) {
+ // const format = this._rangeData[i].getValue().fm?.t;
+ // if (!format) continue;
+ // if (format === this._type) {
+ // range.push(this._rangeData[i]);
+ // }
+ // }
+ // return range;
+ // }
+
+ // 寻找null的单元格
+ // private _matchNull(): Range[] {
+ // const range = [];
+ // for (let i = 0; i < this._rangeData.length; i++) {
+ // let value = this._rangeData[i].getValue()?.v;
+ // if (value == null) {
+ // range.push(this._rangeData[i]);
+ // }
+ // }
+ // return range;
+ // }
+
+ // todo: 等condition插件定好结构
+ // 寻找条件格式
+ // private _matchCondition(): Range[] {
+ // const range: Range[] = [];
+ // return range;
+ // }
+
+ // todo: 移到UI里,增加开始行列,间隔行列数
+ // 寻找间隔行间隔列,移到UI里
+ // private _matchInterval(param: 'column' | 'row'): Range[] {
+ // const range = [];
+ // for (let i = 0; i < this._rangeList.length; i++) {
+ // const rangeArea = this._rangeList[i];
+ // if (param === 'row') {
+ // if (rangeArea.startRow === rangeArea.endRow) {
+ // continue;
+ // }
+ // for (let j = rangeArea.startRow; j <= rangeArea.endRow; j++) {
+ // if ((j - rangeArea.startRow) % 2 === 0) {
+ // range.push(
+ // new Range(this._workSheet, {
+ // startRow: j,
+ // endRow: j,
+ // startColumn: rangeArea.startColumn,
+ // endColumn: rangeArea.endColumn,
+ // })
+ // );
+ // }
+ // }
+ // } else {
+ // if (rangeArea.startColumn === rangeArea.endColumn) {
+ // continue;
+ // }
+ // for (let j = rangeArea.startColumn; j <= rangeArea.endColumn; j++) {
+ // if ((j - rangeArea.startColumn) % 2 === 0) {
+ // range.push(
+ // new Range(this._workSheet, {
+ // startRow: rangeArea.startRow,
+ // endRow: rangeArea.endRow,
+ // startColumn: j,
+ // endColumn: j,
+ // })
+ // );
+ // }
+ // }
+ // }
+ // }
+ // return range;
+ // }
+}
diff --git a/packages/sheets-plugin-find/src/FindPlugin.ts b/packages/sheets-plugin-find/src/FindPlugin.ts
index 8cb2ac2de9..48c4f4d671 100644
--- a/packages/sheets-plugin-find/src/FindPlugin.ts
+++ b/packages/sheets-plugin-find/src/FindPlugin.ts
@@ -9,6 +9,7 @@ import en from './Locale/en';
import zh from './Locale/zh';
import { FindPluginObserve, install } from './Basics/Observer';
import { FindModalController } from './Controller/FindModalController';
+import { TextFinder } from './Domain';
export interface IFindPluginConfig {}
@@ -17,6 +18,8 @@ export class FindPlugin extends Plugin<FindPluginObserve> {
private _findModalController: FindModalController;
+ private _textFinder: TextFinder;
+
constructor(config?: IFindPluginConfig) {
super(FIND_PLUGIN_NAME);
}
@@ -28,6 +31,7 @@ export class FindPlugin extends Plugin<FindPluginObserve> {
installTo(universheetInstance: UniverSheet) {
universheetInstance.installPlugin(this);
+ this._textFinder = new TextFinder(this);
this._findModalController = new FindModalController(this);
this._findController = new FindController(this);
@@ -62,4 +66,8 @@ export class FindPlugin extends Plugin<FindPluginObserve> {
getFindModalController() {
return this._findModalController;
}
+
+ getTextFinder() {
+ return this._textFinder;
+ }
}
diff --git a/packages/sheets-plugin-find/src/Locale/en.ts b/packages/sheets-plugin-find/src/Locale/en.ts
index 8537000001..9f484c4d19 100644
--- a/packages/sheets-plugin-find/src/Locale/en.ts
+++ b/packages/sheets-plugin-find/src/Locale/en.ts
@@ -21,7 +21,7 @@ export default {
findTextbox: 'Find Content',
replaceTextbox: 'Replace Content',
-
+ search: 'Search',
matchCase: 'Match case',
matchAll: 'Match entire cell contents',
matchInFormula: 'Also search within formulas',
@@ -39,6 +39,8 @@ export default {
modeTip: 'This operation is not available in this mode',
searchTargetSheet: 'Sheet',
+ specific: 'Specific range',
+ searchAll: 'All sheets',
searchTargetCell: 'Cell',
searchTargetValue: 'Value',
diff --git a/packages/sheets-plugin-find/src/Locale/zh.ts b/packages/sheets-plugin-find/src/Locale/zh.ts
index 0354101712..7a054a6c78 100644
--- a/packages/sheets-plugin-find/src/Locale/zh.ts
+++ b/packages/sheets-plugin-find/src/Locale/zh.ts
@@ -38,6 +38,8 @@ export default {
modeTip: '该模式下不可进行此操作',
searchTargetSheet: '工作表',
+ specific: '具体范围',
+ searchAll: '所有工作表',
searchTargetCell: '单元格',
searchTargetValue: '值',
@@ -45,6 +47,7 @@ export default {
noReplceTip: '没有可替换的内容',
noMatchTip: '找不到匹配项',
+ search: '搜索',
successTip: '已经帮您搜索并进行了${xlength}处替换',
diff --git a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx b/packages/sheets-plugin-find/src/View/UI/FindModal.tsx
index 761c16f284..35f0dfb5fd 100644
--- a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx
+++ b/packages/sheets-plugin-find/src/View/UI/FindModal.tsx
@@ -1,22 +1,49 @@
-import { BaseCheckboxGroupOptions, BaseComponentProps, CheckboxGroup, Component, Icon, Input, Modal, Select } from '@univerjs/base-ui';
+import { BaseCheckboxGroupOptions, BaseComponentProps, Button, CellRange, CheckboxGroup, Component, createRef, Icon, Input, Modal, Select } from '@univerjs/base-ui';
+import { BaseItemProps } from '@univerjs/base-ui/src/Components/Item/Item';
import styles from './index.module.less';
+type searchResult = {
+ count: number;
+ current: number;
+};
+
// Types for props
-export interface IProps extends BaseComponentProps {}
+export interface IProps extends BaseComponentProps {
+ findNext: (value: string) => searchResult;
+}
// Types for state
interface IState {
show: boolean;
- title: string;
hideAdvanced: boolean;
+ showRange: boolean;
+ current: number;
+ count: number;
+}
+
+export enum SelectSearch {
+ CurrentSheet,
+ AllSheets,
+ Range,
}
export class FindModal extends Component<IProps, IState> {
- active = 'find';
+ private _searchRef = createRef();
private _matchGroup: BaseCheckboxGroupOptions[] = [];
- initialize(props: IProps) {
+ private _select: BaseItemProps[] = [];
+
+ constructor() {
+ super();
+ this.state = {
+ show: false,
+ hideAdvanced: true,
+ showRange: false,
+ current: 0,
+ count: 0,
+ };
+
this._matchGroup = [
{
name: '',
@@ -35,11 +62,20 @@ export class FindModal extends Component<IProps, IState> {
},
];
- this.state = {
- show: false,
- title: 'find.find',
- hideAdvanced: true,
- };
+ this._select = [
+ {
+ label: 'find.searchTargetSheet',
+ value: SelectSearch.CurrentSheet,
+ },
+ {
+ label: 'find.searchAll',
+ value: SelectSearch.AllSheets,
+ },
+ {
+ label: 'find.specific',
+ value: SelectSearch.Range,
+ },
+ ];
}
componentDidMount() {
@@ -61,42 +97,108 @@ export class FindModal extends Component<IProps, IState> {
return arr;
}
+ // 国际化Select
+ getSelect() {
+ const arr = JSON.parse(JSON.stringify(this._select));
+ arr.forEach((element: BaseCheckboxGroupOptions) => {
+ element.label = this.getLocale(element.label as string);
+ });
+ return arr;
+ }
+
handleChange(value) {
console.dir(value);
}
+ handleHideAdvanced(hide: boolean) {
+ this.setState({
+ hideAdvanced: hide,
+ });
+ }
+
+ selectSearch(value: number) {
+ if (value === SelectSearch.Range) {
+ this.setState({
+ showRange: true,
+ });
+ return;
+ }
+ this.setState({
+ showRange: false,
+ });
+ }
+
+ search() {
+ const value = this._searchRef.current.getValue();
+ if (!value) return;
+ const { count, current } = this.props.findNext(value);
+ this.setState({
+ count,
+ current,
+ });
+ }
+
/**
* Render the component's HTML
*
* @returns {void}
*/
render() {
- const { show, title, hideAdvanced } = this.state;
+ const { show, hideAdvanced, showRange, current, count } = this.state;
// Set Provider for entire Container
return (
- <Modal className={styles.findModal} isDrag footer={false} title={this.getLocale(title)} visible={show}>
- <div className={styles.findAdvance} style={{ display: hideAdvanced ? 'block' : 'none' }}>
- <Input></Input>
- <p>
+ <Modal
+ onCancel={() => this.handleHideAdvanced(true)}
+ className={styles.findModal}
+ isDrag
+ footer={false}
+ mask={false}
+ title={this.getLocale(hideAdvanced ? 'find.find' : 'find.findLabel')}
+ visible={show}
+ >
+ <div className={styles.box}>
+ {hideAdvanced ? null : <span>{this.getLocale('find.find')}</span>}
+ <Input ref={this._searchRef}></Input>
+ {count ? (
+ <div className={styles.count}>
+ <span>
+ <Icon.Format.NextIcon rotate={90}></Icon.Format.NextIcon>
+ </span>
+ {current}/{count}
+ <span>
+ <Icon.Format.NextIcon rotate={-90}></Icon.Format.NextIcon>
+ </span>
+ </div>
+ ) : null}
+ </div>
+ {hideAdvanced ? (
+ <p style={{ display: hideAdvanced ? 'block' : 'none' }} onClick={() => this.handleHideAdvanced(false)}>
{this.getLocale('find.replace')}/{this.getLocale('find.advanced')}
<Icon.Format.NextIcon />
</p>
- </div>
- <div className={styles.box}>
- <span>{this.getLocale('find.find')}</span>
- <Input></Input>
- </div>
- <div className={styles.box}>
- <span>{this.getLocale('find.replaceWith')}</span>
- <Input></Input>
- </div>
- <div className={styles.box}>
- <span>{this.getLocale('find.replaceWith')}</span>
- <Select></Select>
- </div>
- <div>
- <CheckboxGroup options={this.getMatchGroup()} onChange={this.handleChange}></CheckboxGroup>
- </div>
+ ) : (
+ <>
+ <div className={styles.box}>
+ <span>{this.getLocale('find.replaceWith')}</span>
+ <Input></Input>
+ </div>
+ <div className={styles.box}>
+ <span>{this.getLocale('find.search')}</span>
+ <Select onClick={this.selectSearch.bind(this)} type={0} children={this.getSelect()}></Select>
+ {showRange ? <CellRange /> : null}
+ </div>
+ <div className={styles.box}>
+ <span></span>
+ <CheckboxGroup options={this.getMatchGroup()} onChange={this.handleChange}></CheckboxGroup>
+ </div>
+ <div className={styles.buttonGroup}>
+ <Button type="primary">{this.getLocale('button.cancel')}</Button>
+ <Button>{this.getLocale('find.allReplaceBtn')}</Button>
+ <Button>{this.getLocale('find.replace')}</Button>
+ <Button onClick={this.search.bind(this)}>{this.getLocale('find.find')}</Button>
+ </div>
+ </>
+ )}
</Modal>
);
}
diff --git a/packages/sheets-plugin-find/src/View/UI/index.module.less b/packages/sheets-plugin-find/src/View/UI/index.module.less
index 6479b0d5b7..96996ca1ef 100644
--- a/packages/sheets-plugin-find/src/View/UI/index.module.less
+++ b/packages/sheets-plugin-find/src/View/UI/index.module.less
@@ -5,12 +5,81 @@
border-radius: 4px;
}
- .find-advance {
- p {
- text-align: center;
+ .cell-range-modal {
+ width: 30%;
+ margin-left: 1rem;
+
+ input {
+ height: 36px;
+ }
+ }
+
+ p {
+ text-align: center;
+ cursor: pointer;
+ }
+
+ .box {
+ display: flex;
+ font-size: 14px;
+ align-items: center;
+ margin-bottom: 1.5rem;
+ position: relative;
+
+ &:first-of-type {
+ margin-top: .5rem;
+ }
+
+ .count {
+ position: absolute;
+ top: 0;
+ right: 0;
+ z-index: 1;
+ height: 36px;
+ line-height: 36px;
+
+ >span {
+ padding: 0 5px;
+ }
+ }
+
+ >span {
+ width: 50px;
+ flex-shrink: 0
+ }
+
+ .select-component {
+ height: 36px;
cursor: pointer;
+ border: 1px solid #dadce0;
+ }
+
+ .drop-content {
+ height: 36px;
}
}
- .box {}
+ .checkbox-group {
+ display: flex;
+ flex-direction: column;
+
+ .checkbox-wrapper {
+ margin-bottom: 1rem;
+ }
+ }
+
+ .buttonGroup {
+ margin-top: 2rem;
+ display: flex;
+ flex-direction: row-reverse;
+
+ button {
+ margin-left: .5rem;
+ border-radius: 4px;
+ height: 36px;
+ line-height: 16px;
+ letter-spacing: 0.25px;
+ padding: 9px 24px 11px 24px;
+ }
+ }
}
\ No newline at end of file
diff --git a/packages/ui-plugin-docs/src/Basics/Const/DefaultUniverDocConfig.ts b/packages/ui-plugin-docs/src/Basics/Const/DefaultUniverDocConfig.ts
new file mode 100644
index 0000000000..25f8ec018d
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Basics/Const/DefaultUniverDocConfig.ts
@@ -0,0 +1,38 @@
+export const DefaultToolbarConfig = {
+ undo: true,
+ redo: true, // Undo redo
+ 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'
+ horizontalAlignMode: true, // 'Horizontal alignment'
+ verticalAlignMode: true, // 'Vertical alignment'
+ textWrapMode: true, // 'Wrap mode'
+ textRotateMode: true, // 'Text Rotation Mode'
+};
+
+export const DefaultDocContainerConfig = {
+ 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 DefaultDocUiConfig = {
+ layout: {
+ docContainerConfig: DefaultDocContainerConfig,
+ toolbarConfig: DefaultToolbarConfig,
+ },
+};
diff --git a/packages/ui-plugin-docs/src/Basics/Const/index.ts b/packages/ui-plugin-docs/src/Basics/Const/index.ts
index 0dc96d927a..8f3879e182 100644
--- a/packages/ui-plugin-docs/src/Basics/Const/index.ts
+++ b/packages/ui-plugin-docs/src/Basics/Const/index.ts
@@ -1 +1,2 @@
export * from './PLUGIN_NAME';
+export * from './DefaultUniverDocConfig';
diff --git a/packages/ui-plugin-docs/src/Basics/Interfaces/ComponentConfig/IDocUIPluginConfig.ts b/packages/ui-plugin-docs/src/Basics/Interfaces/ComponentConfig/IDocUIPluginConfig.ts
new file mode 100644
index 0000000000..126d21c926
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Basics/Interfaces/ComponentConfig/IDocUIPluginConfig.ts
@@ -0,0 +1,63 @@
+export interface ILayout {
+ docContainerConfig?: DocContainerConfig;
+ toolbarConfig?: DocToolbarConfig;
+}
+
+export interface IDocUIPluginConfig {
+ container?: HTMLElement | string;
+ layout?: ILayout;
+}
+
+export interface DocContainerConfig {
+ outerLeft?: boolean;
+
+ outerRight?: boolean;
+
+ header?: boolean;
+
+ footer?: boolean;
+
+ innerLeft?: boolean;
+
+ innerRight?: boolean;
+
+ frozenHeaderLT?: boolean;
+
+ frozenHeaderRT?: boolean;
+
+ frozenHeaderLM?: boolean;
+
+ frozenContent?: boolean;
+
+ infoBar?: boolean;
+
+ toolbar?: boolean;
+
+ contentSplit?: boolean | string;
+}
+
+// doc工具栏配置
+export interface DocToolbarConfig {
+ 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-docs/src/Basics/Interfaces/ComponentConfig/index.ts b/packages/ui-plugin-docs/src/Basics/Interfaces/ComponentConfig/index.ts
new file mode 100644
index 0000000000..8922bd2559
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Basics/Interfaces/ComponentConfig/index.ts
@@ -0,0 +1 @@
+export * from './IDocUIPluginConfig';
diff --git a/packages/ui-plugin-docs/src/Basics/Interfaces/index.ts b/packages/ui-plugin-docs/src/Basics/Interfaces/index.ts
new file mode 100644
index 0000000000..668cfd82a2
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Basics/Interfaces/index.ts
@@ -0,0 +1 @@
+export * from './ComponentConfig';
diff --git a/packages/ui-plugin-docs/src/Basics/index.ts b/packages/ui-plugin-docs/src/Basics/index.ts
index 640d1bb8b3..14c41ec033 100644
--- a/packages/ui-plugin-docs/src/Basics/index.ts
+++ b/packages/ui-plugin-docs/src/Basics/index.ts
@@ -2,3 +2,4 @@ export * from './Const';
export * from './Enum';
export * from '../Locale';
export * from './Shared';
+export * from './Interfaces';
diff --git a/packages/ui-plugin-docs/src/Controller/AppUIController.ts b/packages/ui-plugin-docs/src/Controller/AppUIController.ts
new file mode 100644
index 0000000000..23bcf8edee
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Controller/AppUIController.ts
@@ -0,0 +1,47 @@
+import { LocaleType } from '@univerjs/core';
+import { DocUIPlugin } from '../DocUIPlugin';
+import { UI } from '../View';
+import { DocContainerUIController } from './DocContainerUIController';
+
+export class AppUIController {
+ protected _plugin: DocUIPlugin;
+
+ private _docContainerController: DocContainerUIController;
+
+ constructor(plugin: DocUIPlugin) {
+ this._plugin = plugin;
+
+ this._docContainerController = new DocContainerUIController(this._plugin);
+
+ const UIConfig = this._docContainerController.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();
+ };
+
+ getDocContainerController() {
+ return this._docContainerController;
+ }
+}
diff --git a/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts b/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts
new file mode 100644
index 0000000000..2eb42f3376
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Controller/DocContainerUIController.ts
@@ -0,0 +1,113 @@
+import { EventManager } from '@univerjs/base-ui';
+import { LocaleType, UniverDoc } from '@univerjs/core';
+import { IDocUIPluginConfig } from '../Basics';
+import { DocUIPlugin } from '../DocUIPlugin';
+import { DocContainer } from '../View';
+import { InfoBarUIController } from './InfoBarUIController';
+import { ToolbarUIController } from './ToolbarUIController';
+
+export class DocContainerUIController {
+ protected _plugin: DocUIPlugin;
+
+ private _docContainer: DocContainer;
+
+ private _toolbarController: ToolbarUIController;
+
+ private _infoBarController: InfoBarUIController;
+
+ private _config: IDocUIPluginConfig;
+
+ private _eventManager: EventManager;
+
+ constructor(plugin: DocUIPlugin) {
+ 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);
+ }
+
+ 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,
+ // renameSheet: this._infoBarController.renameSheet,
+ },
+ },
+ };
+ return config;
+ }
+
+ // 获取SheetContainer组件
+ getComponent = (ref: DocContainer) => {
+ this._docContainer = ref;
+ this._plugin.getObserver('onUIDidMount')?.notifyObservers(this._docContainer);
+
+ this._initDocContainer();
+ };
+
+ /**
+ * 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._docContainer.getContentRef();
+ }
+
+ setEventManager() {
+ const univerDocs = this._plugin.getUniver().getAllUniverDocsInstance();
+ univerDocs.forEach((univerDoc: UniverDoc) => {
+ // univerDocs.getWorkBook().getContext().getPluginManager().getRequirePluginByName<SheetPlugin>(PLUGIN_NAMES.SPREADSHEET).listenEventManager();
+ });
+ }
+
+ getEventManager() {
+ return this._eventManager;
+ }
+
+ getToolbarController() {
+ return this._toolbarController;
+ }
+
+ UIDidMount(cb: Function) {
+ if (this._docContainer) return cb(this._docContainer);
+
+ this._plugin.getObserver('onUIDidMount')?.add(() => cb(this._docContainer));
+ }
+
+ private _initialize() {
+ this._eventManager = new EventManager(this._plugin);
+
+ this.setEventManager();
+ }
+
+ private _initDocContainer() {
+ // handle drag event
+ }
+}
diff --git a/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts
new file mode 100644
index 0000000000..18a599f037
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Controller/InfoBarUIController.ts
@@ -0,0 +1,79 @@
+import { DocUIPlugin } from '../DocUIPlugin';
+import { InfoBarModel } from '../Model';
+import { InfoBar } from '../View/InfoBar';
+
+type IProps = {
+ locale?: string;
+ label?: string;
+ onBlur?: (e: FocusEvent) => void;
+};
+
+export interface BaseInfoBarProps {
+ back: IProps;
+ rename: IProps;
+ save: IProps;
+ sheet: IProps;
+ update: IProps;
+}
+
+export class InfoBarUIController {
+ private _infoBarModel: InfoBarModel;
+
+ private _infoBar: InfoBar;
+
+ private _plugin: DocUIPlugin;
+
+ private _infoList: BaseInfoBarProps;
+
+ constructor(plugin: DocUIPlugin) {
+ this._plugin = plugin;
+ }
+
+ getComponent = (ref: InfoBar) => {
+ this._infoBar = ref;
+ this._refreshComponent();
+ this.resetInfoList(this._infoList);
+ };
+
+ resetInfoList(list: BaseInfoBarProps) {
+ const locale = this._plugin.getContext().getLocale();
+ for (let k in list) {
+ if (list[k].locale) {
+ list[k].label = locale.get(list[k].locale);
+ }
+ }
+ this._infoBar.setInfoList(list);
+ }
+
+ setSheetName(e: FocusEvent) {
+ const target = e.target as HTMLInputElement;
+ const name = target.value;
+ this._infoBarModel.setName(name);
+ }
+
+ private _refreshComponent(): void {
+ const name = 'UniverDoc';
+ // const name = this._plugin.getContext().getUniver().getCurrentUniverDocInstance().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',
+ },
+ sheet: {
+ label: name,
+ onBlur: (e) => {
+ this.setSheetName(e);
+ },
+ },
+ };
+ }
+}
diff --git a/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts
new file mode 100644
index 0000000000..74258c466e
--- /dev/null
+++ b/packages/ui-plugin-docs/src/Controller/ToolbarUIController.ts
@@ -0,0 +1,609 @@
+import { BaseSelectChildrenProps, BaseSelectProps, ColorPicker, ComponentChildren } from '@univerjs/base-ui';
+import {
+ CommandManager,
+ DEFAULT_STYLES,
+ HorizontalAlign,
+ ISheetActionData,
+ SheetActionBase,
+ Tools,
+ UIObserver,
+ VerticalAlign,
+ WrapStrategy,
+ Range,
+ FontWeight,
+ FontItalic,
+} from '@univerjs/core';
+import { DefaultToolbarConfig, DocToolbarConfig, DOC_UI_PLUGIN_NAME } from '../Basics';
+import { DocUIPlugin } from '../DocUIPlugin';
+import { Toolbar } from '../View';
+import { ColorSelect } from '../View/Common';
+import { FONT_FAMILY_CHILDREN, FONT_SIZE_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: DocUIPlugin;
+
+ private _toolbar: Toolbar;
+
+ private _toolList: IToolbarItemProps[];
+
+ private _config: DocToolbarConfig;
+
+ private _colorSelect1: ColorSelect;
+
+ private _textColor: string = '#000';
+
+ private _colorSelect2: ColorSelect;
+
+ private _background: string = '#fff';
+
+ constructor(plugin: DocUIPlugin, config?: DocToolbarConfig) {
+ this._plugin = plugin;
+
+ this._config = Tools.deepMerge({}, DefaultToolbarConfig, config);
+
+ this._toolList = [
+ {
+ toolbarType: 1,
+ tooltip: 'toolbar.undo',
+ name: 'undo',
+ customLabel: {
+ name: 'ForwardIcon',
+ },
+ show: this._config.undo,
+ onClick: () => {
+ this.setUndo();
+ this.hideTooltip();
+ },
+ },
+ {
+ toolbarType: 1,
+ tooltip: 'toolbar.redo',
+ 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',
+ },
+ unActive: false,
+ name: 'bold',
+ show: this._config.bold,
+ onClick: (e, isBold: boolean) => {
+ this.setFontWeight(isBold);
+ this.hideTooltip();
+ },
+ },
+ {
+ toolbarType: 1,
+ tooltip: 'toolbar.italic',
+ customLabel: {
+ name: 'ItalicIcon',
+ },
+ unActive: false,
+ name: 'italic',
+ show: this._config.italic,
+ onClick: (e, isItalic: boolean) => {
+ this.setFontStyle(isItalic);
+ this.hideTooltip();
+ },
+ },
+ {
+ toolbarType: 1,
+ tooltip: 'toolbar.strikethrough',
+ customLabel: {
+ name: 'DeleteLineIcon',
+ },
+ unActive: false,
+ 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',
+ },
+ unActive: false,
+ 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: DOC_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: DOC_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: DOC_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: DOC_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,
+ 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);
+ }
+
+ 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);
+ }
+
+ 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 _changeToolbarState(range: Range): void {
+ const workbook = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook();
+ const worksheet = workbook.getActiveSheet();
+ if (worksheet) {
+ const isBold = range.getFontWeight();
+ const IsItalic = range.getFontStyle();
+ const strikeThrough = range.getStrikeThrough();
+ const fontSize = range.getFontSize();
+ const fontWeight = range.getFontWeight();
+ const fontName = range.getFontFamily();
+ const fontItalic = range.getFontStyle();
+ // const fontColor = range.getFontColor();
+ // const background = range.getBackground();
+ const underline = range.getUnderline();
+ const horizontalAlign = range.getHorizontalAlignment() ?? HorizontalAlign.LEFT;
+ const verticalAlign = range.getVerticalAlignment() ?? VerticalAlign.BOTTOM;
+ const rotation = range.getTextRotation();
+ const warp = range.getWrapStrategy() ?? WrapStrategy.CLIP;
+
+ const bold = this._toolList.find((item) => item.name === 'bold');
+ const italic = this._toolList.find((item) => item.name === 'italic');
+ const textRotateModeItem = this._toolList.find((item) => item.name === 'textRotateMode');
+ const fontSizeItem = this._toolList.find((item) => item.name === 'fontSize');
+ const fontNameItem = this._toolList.find((item) => item.name === 'font');
+ const fontBoldItem = this._toolList.find((item) => item.name === 'bold');
+ const fontItalicItem = this._toolList.find((item) => item.name === 'italic');
+ // const textColor = this._toolList.find((item) => item.name === 'textColor')
+ // const fillColor = this._toolList.find((item) => item.name === 'fillColor')
+ const strikethroughItem = this._toolList.find((item) => item.name === 'strikethrough');
+ const underlineItem = this._toolList.find((item) => item.name === 'underline');
+ const horizontalAlignModeItem = this._toolList.find((item) => item.name === 'horizontalAlignMode');
+ const verticalAlignModeItem = this._toolList.find((item) => item.name === 'verticalAlignMode');
+ const textWrapMode = this._toolList.find((item) => item.name === 'textWrapMode');
+
+ if (bold) {
+ bold.active = isBold === FontWeight.BOLD;
+ }
+
+ if (italic) {
+ italic.active = IsItalic === FontItalic.ITALIC;
+ }
+
+ if (strikethroughItem) {
+ strikethroughItem.active = !!(strikeThrough && strikeThrough.s);
+ }
+ if (fontNameItem) {
+ fontNameItem.children?.forEach((item) => {
+ item.selected = fontName === item.value;
+ });
+ }
+ if (fontSizeItem) {
+ fontSizeItem.label = fontSize.toString();
+ }
+ if (fontBoldItem) {
+ fontBoldItem.active = !!fontWeight;
+ }
+ if (fontItalicItem) {
+ fontItalicItem.active = !!fontItalic;
+ }
+ if (underlineItem) {
+ underlineItem.active = !!(underline && underline.s);
+ }
+ if (horizontalAlignModeItem) {
+ horizontalAlignModeItem.children?.forEach((item) => {
+ item.selected = horizontalAlign === item.value;
+ });
+ }
+ if (textRotateModeItem) {
+ textRotateModeItem.children?.forEach((item) => {
+ if (rotation.v) {
+ item.selected = item.value === 'v';
+ } else {
+ item.selected = rotation.a === item.value;
+ }
+ });
+ }
+ if (verticalAlignModeItem) {
+ verticalAlignModeItem.children?.forEach((item) => {
+ item.selected = verticalAlign === item.value;
+ });
+ }
+ if (textWrapMode) {
+ textWrapMode.children?.forEach((item) => {
+ item.selected = warp === item.value;
+ });
+ }
+
+ this.setToolbar();
+ }
+ }
+
+ private _initialize() {
+ this._plugin.getComponentManager().register(DOC_UI_PLUGIN_NAME + ColorSelect.name, ColorSelect);
+ this._plugin.getComponentManager().register(DOC_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);
+
+ CommandManager.getCommandObservers().add(({ actions }) => {
+ if (!actions || actions.length === 0) return;
+ const action = actions[0] as SheetActionBase<ISheetActionData, ISheetActionData, void>;
+
+ const currentUnitId = this._plugin.getContext().getUniver().getCurrentUniverSheetInstance().getWorkBook().getUnitId();
+ const actionUnitId = action.getWorkBook().getUnitId();
+
+ if (currentUnitId !== actionUnitId) return null;
+ });
+ }
+}
diff --git a/packages/ui-plugin-docs/src/Controller/UIController.ts b/packages/ui-plugin-docs/src/Controller/UIController.ts
deleted file mode 100644
index d3a078f449..0000000000
--- a/packages/ui-plugin-docs/src/Controller/UIController.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { DocPlugin } from '@univerjs/base-docs';
-import { DocUIPlugin } from '../DocUIPlugin';
-
-export class UIController {
- protected _docPlugin: DocPlugin;
-
- protected _plugin: DocUIPlugin;
-
- constructor(plugin: DocUIPlugin) {
- this._plugin = plugin;
- }
-}
diff --git a/packages/ui-plugin-docs/src/Controller/index.ts b/packages/ui-plugin-docs/src/Controller/index.ts
index e69de29bb2..4d272a0de3 100644
--- a/packages/ui-plugin-docs/src/Controller/index.ts
+++ b/packages/ui-plugin-docs/src/Controller/index.ts
@@ -0,0 +1,4 @@
+export * from './AppUIController';
+export * from './ToolbarUIController';
+export * from './DocContainerUIController';
+export * from './InfoBarUIController';
diff --git a/packages/ui-plugin-docs/src/DocUIPlugin.ts b/packages/ui-plugin-docs/src/DocUIPlugin.ts
index cc20172321..30294cb8fb 100644
--- a/packages/ui-plugin-docs/src/DocUIPlugin.ts
+++ b/packages/ui-plugin-docs/src/DocUIPlugin.ts
@@ -1,15 +1,23 @@
-import { Plugin, Context, UniverDoc } from '@univerjs/core';
+import { Plugin, Context, UniverDoc, PLUGIN_NAMES, Tools } from '@univerjs/core';
+import { RenderEngine } from '@univerjs/base-render';
+import { ComponentManager, getRefElement, RegisterManager } from '@univerjs/base-ui';
import { zh, en } from './Locale';
import { DOC_UI_PLUGIN_NAME } from './Basics/Const/PLUGIN_NAME';
-import { UIController } from './Controller/UIController';
-
-export interface IDocUIPluginConfig {}
+import { DefaultDocUiConfig, IDocUIPluginConfig } from './Basics';
+import { AppUIController } from './Controller';
export class DocUIPlugin extends Plugin<any, Context> {
- private _UIController: UIController;
+ private _appUIController: AppUIController;
+
+ private _config: IDocUIPluginConfig;
+
+ private _registerManager: RegisterManager;
+
+ private _componentManager: ComponentManager;
constructor(config?: IDocUIPluginConfig) {
super(DOC_UI_PLUGIN_NAME);
+ this._config = Tools.deepMerge({}, DefaultDocUiConfig, config);
}
static create(config?: IDocUIPluginConfig) {
@@ -20,7 +28,7 @@ export class DocUIPlugin extends Plugin<any, Context> {
universheetInstance.installPlugin(this);
}
- initialize(): void {
+ initialize(ctx: Context): void {
/**
* load more Locale object
*/
@@ -29,11 +37,62 @@ export class DocUIPlugin extends Plugin<any, Context> {
zh,
});
- this._UIController = new UIController(this);
+ this._componentManager = new ComponentManager();
+ this._appUIController = new AppUIController(this);
+
+ this.UIDidMount(() => {
+ this.initRender();
+ });
+ }
+
+ getConfig() {
+ return this._config;
+ }
+
+ initRender() {
+ const engine = this.getPluginByName<RenderEngine>(PLUGIN_NAMES.BASE_RENDER)?.getEngine()!;
+ let container = getRefElement(this._appUIController.getDocContainerController().getContentRef());
+
+ // mount canvas to DOM container
+ engine.setContainer(container);
+
+ window.addEventListener('resize', () => {
+ engine.resize();
+ });
+
+ // should be clear
+ setTimeout(() => {
+ engine.resize();
+ }, 0);
+ }
+
+ 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.getDocContainerController().UIDidMount(cb);
}
- onMounted(): void {
- this.initialize();
+ onMounted(ctx: Context): void {
+ this.initialize(ctx);
}
onDestroy(): void {}
diff --git a/packages/ui-plugin-docs/src/Locale/en.ts b/packages/ui-plugin-docs/src/Locale/en.ts
index 54163bc14e..8b5d1e9acc 100644
--- a/packages/ui-plugin-docs/src/Locale/en.ts
+++ b/packages/ui-plugin-docs/src/Locale/en.ts
@@ -1,8 +1,528 @@
export default {
- ui: {
- tooltip: 'UI',
+ spreadsheetLabel: 'Spreadsheet',
+ spreadsheetRightLabel: 'more Sheets',
+ spreadsheet: {
one: 'one',
two: 'two',
three: 'three',
},
+
+ toolbar: {
+ undo: 'Undo',
+ redo: 'Redo',
+ paintFormat: 'Paint format',
+ currencyFormat: 'Format as currency',
+ percentageFormat: 'Format as percent',
+ numberDecrease: 'Decrease decimal places',
+ numberIncrease: 'Increase decimal places',
+ moreFormats: 'More formats',
+ font: 'Font',
+ fontSize: 'Font size',
+ bold: 'Bold (Ctrl+B)',
+ italic: 'Italic (Ctrl+I)',
+ strikethrough: 'Strikethrough (Alt+Shift+5)',
+ underline: 'Underline',
+ textColor: {
+ main: 'Text color',
+ right: 'Choose color',
+ },
+ resetColor: 'Reset',
+ customColor: 'CUSTOM',
+ alternatingColors: 'Alternating colors',
+ confirmColor: 'OK',
+ cancelColor: 'Cancel',
+ collapse: 'Collapse',
+ fillColor: {
+ main: 'Fill color',
+ right: 'Choose color',
+ },
+ border: {
+ main: 'Border',
+ right: 'Border style',
+ },
+ mergeCell: {
+ main: 'Merge cells',
+ right: 'Choose merge type',
+ },
+ horizontalAlignMode: {
+ main: 'Horizontal align',
+ right: 'Alignment',
+ },
+ verticalAlignMode: {
+ main: 'Vertical align',
+ right: 'Alignment',
+ },
+ textWrapMode: {
+ main: 'Text wrap',
+ right: 'Text wrap mode',
+ },
+ textRotateMode: {
+ main: 'Text rotate',
+ right: 'Text rotate mode',
+ },
+ freezeTopRow: 'Freeze top row',
+ sortAndFilter: 'Sort and filter',
+ findAndReplace: 'Find and replace',
+ sum: 'SUM',
+ autoSum: 'Auto SUM',
+ moreFunction: 'More functions',
+ conditionalFormat: 'Conditional format',
+ comment: 'Comment',
+ pivotTable: 'Pivot Table',
+ chart: 'Chart',
+ screenshot: 'Screenshot',
+ splitColumn: 'Split text',
+ insertImage: 'Insert image',
+ insertLink: 'Insert link',
+ dataValidation: 'Data validation',
+ protection: 'Protect the sheet',
+
+ clearText: 'Clear color',
+ noColorSelectedText: 'No color is selected',
+
+ toolMore: 'More',
+ toolLess: 'Less',
+ toolClose: 'Close',
+ toolMoreTip: 'More features',
+ moreOptions: 'More options',
+
+ cellFormat: 'Cell format config',
+ print: 'Print',
+ borderMethod: {
+ top: 'Upper frame line',
+ bottom: 'Lower frame line',
+ left: 'Left frame line',
+ right: 'Right frame line',
+ },
+ more: 'More',
+ },
+ defaultFmt: {
+ Automatic: {
+ text: 'Automatic',
+ value: 'General',
+ example: '',
+ },
+ Number: {
+ text: 'Number',
+ value: '##0.00',
+ example: '1000.12',
+ },
+ Percent: {
+ text: 'Percent',
+ value: '#0.00%',
+ example: '12.21%',
+ },
+ PlainText: {
+ text: 'Plain text',
+ value: '@',
+ example: '',
+ },
+ Scientific: {
+ text: 'Scientific',
+ value: '0.00E+00',
+ example: '1.01E+5',
+ },
+ Accounting: {
+ text: 'Accounting',
+ value: '¥(0.00)',
+ example: '¥(1200.09)',
+ },
+ Thousand: {
+ text: 'Ten Thousand',
+ value: 'w',
+ example: '1亿2000万2500',
+ },
+ Currency: {
+ text: 'Currency',
+ value: '¥0.00',
+ example: '¥1200.09',
+ },
+ Digit: {
+ text: '万元2位小数',
+ value: 'w0.00',
+ example: '2万2500.55',
+ },
+ Date: {
+ text: 'Date',
+ value: 'yyyy-MM-dd',
+ example: '2017-11-29',
+ },
+ Time: { text: 'Time', value: 'hh:mm AM/PM', example: '3:00 PM' },
+ Time24H: { text: 'Time 24H', value: 'hh:mm', example: '15:00' },
+ DateTime: { text: 'Date time', value: 'yyyy-MM-dd hh:mm AM/PM', example: '2017-11-29 3:00 PM' },
+ DateTime24H: { text: 'Date time 24H', value: 'yyyy-MM-dd hh:mm', example: '2017-11-29 15:00' },
+ CustomFormats: { text: 'Custom Formats', value: 'fmtOtherSelf', example: '' },
+ },
+ format: {
+ moreCurrency: 'More currency formats',
+ moreDateTime: 'More date and time formats',
+ moreNumber: 'More number formats',
+
+ titleCurrency: 'Currency formats',
+ decimalPlaces: 'Decimal places',
+ titleDateTime: 'Date and time formats',
+ titleNumber: 'Number formats',
+ },
+ fontFamily: {
+ TimesNewRoman: 'Times New Roman',
+ Arial: 'Arial',
+ Tahoma: 'Tahoma',
+ Verdana: 'Verdana',
+ MicrosoftAccorblack: 'Microsoft Accor black ',
+ SimSun: 'SimSun',
+ SimHei: 'SimHei',
+ Kaiti: 'Kaiti',
+ FangSong: 'FangSong',
+ NSimSun: 'NSimSun',
+ STXinwei: 'STXinwei',
+ STXingkai: 'STXingkai',
+ STLiti: 'STLiti',
+ HanaleiFill: 'HanaleiFill',
+ Anton: 'Anton',
+ Pacifico: 'Pacifico',
+ },
+ print: {
+ normalBtn: 'Normal',
+ layoutBtn: 'Page Layout',
+ pageBtn: 'Page break preview',
+
+ menuItemPrint: 'Print (Ctrl+P)',
+ menuItemAreas: 'Print areas',
+ menuItemRows: 'Print title rows',
+ menuItemColumns: 'Print title columns',
+ },
+ align: {
+ left: 'left',
+ center: 'center',
+ right: 'right',
+
+ top: 'top',
+ middle: 'middle',
+ bottom: 'bottom',
+ },
+
+ dateFmtList: [
+ {
+ name: '1930-08-05',
+ value: 'yyyy-MM-dd',
+ },
+ {
+ name: '1930/8/5',
+ value: 'yyyy/MM/dd',
+ },
+ {
+ name: '08-05',
+ value: 'MM-dd',
+ },
+ {
+ name: '8-5',
+ value: 'M-d',
+ },
+ {
+ name: '13:30:30',
+ value: 'h:mm:ss',
+ },
+ {
+ name: '13:30',
+ value: 'h:mm',
+ },
+ {
+ name: 'PM 01:30',
+ value: 'AM/PM hh:mm',
+ },
+ {
+ name: 'PM 1:30',
+ value: 'AM/PM h:mm',
+ },
+ {
+ name: 'PM 1:30:30',
+ value: 'AM/PM h:mm:ss',
+ },
+ {
+ name: '08-05 PM 01:30',
+ value: 'MM-dd AM/PM hh:mm',
+ },
+ ],
+ numFmtList: [
+ {
+ name: '1235',
+ value: '0',
+ },
+ {
+ name: '1234.56',
+ value: '0.00',
+ },
+ {
+ name: '1,235',
+ value: '#,##0',
+ },
+ {
+ name: '1,234.56',
+ value: '#,##0.00',
+ },
+ {
+ name: '1,235',
+ value: '#,##0_);(#,##0)',
+ },
+ {
+ name: '1,235',
+ value: '#,##0_);[Red](#,##0)',
+ },
+ {
+ name: '1,234.56',
+ value: '#,##0.00_);(#,##0.00)',
+ },
+ {
+ name: '1,234.56',
+ value: '#,##0.00_);[Red](#,##0.00)',
+ },
+ {
+ name: '$1,235',
+ value: '$#,##0_);($#,##0)',
+ },
+ {
+ name: '$1,235',
+ value: '$#,##0_);[Red]($#,##0)',
+ },
+ {
+ name: '$1,234.56',
+ value: '$#,##0.00_);($#,##0.00)',
+ },
+ {
+ name: '$1,234.56',
+ value: '$#,##0.00_);[Red]($#,##0.00)',
+ },
+ {
+ name: '1234.56',
+ value: '@',
+ },
+ {
+ name: '123456%',
+ value: '0%',
+ },
+ {
+ name: '123456.00%',
+ value: '0.00%',
+ },
+ {
+ name: '1.23E+03',
+ value: '0.00E+00',
+ },
+ {
+ name: '1.2E+3',
+ value: '##0.0E+0',
+ },
+ {
+ name: '1234 5/9',
+ value: '# ?/?',
+ },
+ {
+ name: '1234 14/25',
+ value: '# ??/??',
+ },
+ {
+ name: '$ 1,235',
+ value: '_($* #,##0_);_(...($* "-"_);_(@_)',
+ },
+ {
+ name: '1,235',
+ value: '_(* #,##0_);_(*..._(* "-"_);_(@_)',
+ },
+ {
+ name: '$ 1,234.56',
+ // "value": '_($* #,##0.00_)...* "-"??_);_(@_)'
+ value: '_($* #,##0.00_);_(...($* "-"_);_(@_)',
+ },
+ {
+ name: '1,234.56',
+ value: '_(* #,##0.00_);...* "-"??_);_(@_)',
+ },
+ ],
+ button: {
+ confirm: 'OK',
+ cancel: 'Cancel',
+ close: 'Close',
+ update: 'Update',
+ delete: 'Delete',
+ insert: 'Insert',
+ prevPage: 'Previous',
+ nextPage: 'Next',
+ total: 'total:',
+ },
+ punctuation: {
+ tab: 'Tab',
+ semicolon: 'semicolond',
+ comma: 'comma',
+ space: 'space',
+ },
+ colorPicker: {
+ collapse: 'Collapse',
+ customColor: 'CUSTOM',
+ change: 'Change',
+ confirmColor: 'OK',
+ cancelColor: 'Cancel',
+ },
+ borderLine: {
+ borderTop: 'borderTop',
+ borderBottom: 'borderBottom',
+ borderLeft: 'borderLeft',
+ borderRight: 'borderRight',
+ borderNone: 'borderNone',
+ borderAll: 'borderAll',
+ borderOutside: 'borderOutside',
+ borderInside: 'borderInside',
+ borderHorizontal: 'borderHorizontal',
+ borderVertical: 'borderVertical',
+ borderColor: 'borderColor',
+ borderSize: 'borderSize',
+ },
+ merge: {
+ all: 'Merge all',
+ vertical: 'Vertical merge',
+ horizontal: 'Horizontal merger',
+ cancel: 'Cancel merge',
+ overlappingError: 'Cannot merge overlapping areas',
+ partiallyError: 'Cannot perform this operation on partially merged cells',
+ },
+ textWrap: {
+ overflow: 'Overflow',
+ wrap: 'Wrap',
+ clip: 'Clip',
+ },
+ textRotate: {
+ none: 'None',
+ angleUp: 'Tilt Up',
+ angleDown: 'Tilt Down',
+ vertical: 'Stack Vertically',
+ rotationUp: 'Rotate Up',
+ rotationDown: 'Rotate Down',
+ },
+ sheetConfig: {
+ delete: 'Delete',
+ copy: 'Copy',
+ rename: 'Rename',
+ changeColor: 'Change color',
+ hide: 'Hide',
+ unhide: 'Unhide',
+ moveLeft: 'Move left',
+ moveRight: 'Move right',
+ resetColor: 'Reset color',
+ cancelText: 'Cancel',
+ chooseText: 'Confirm color',
+
+ tipNameRepeat: 'The name of the tab page cannot be repeated! Please revise',
+ noMoreSheet: 'The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.',
+ confirmDelete: 'Are you sure to delete',
+ redoDelete: 'Can be undo by Ctrl+Z',
+ noHide: "Can't hide, at least keep one sheet tag",
+ chartEditNoOpt: 'This operation is not allowed in chart editing mode!',
+ sheetNameSpecCharError: 'The name cannot contain:[ ] : ? * / \' "',
+ sheetNameCannotIsEmptyError: 'Sheet name cannot be empty',
+ },
+ rightClick: {
+ copy: 'Copy',
+ copyAs: 'Copy as',
+ cut: 'Cut',
+ paste: 'Paste',
+ insert: 'Insert',
+ insertRow: 'InsertRow',
+ insertColumn: 'InsertColumn',
+ delete: 'Delete',
+ deleteCell: 'Delete cell',
+ deleteSelected: 'Delete selected ',
+ hide: 'Hide',
+ hideSelected: 'Hide selected ',
+ showHide: 'Show hidden ',
+ toTopAdd: 'Towards Top Add',
+ toBottomAdd: 'Towards Bottom Add',
+ toLeftAdd: 'Towards Left Add',
+ toRightAdd: 'Towards Right Add',
+ deleteSelectedRow: 'Delete selected row',
+ deleteSelectedColumn: 'Delete selected column',
+ hideSelectedRow: 'Hide selected row',
+ showHideRow: 'Show selected row',
+ rowHeight: 'Row height',
+ hideSelectedColumn: 'Hide selected column',
+ showHideColumn: 'Show hide column',
+ columnWidth: 'Column width',
+ to: 'Towards',
+ left: 'Left',
+ right: 'Right',
+ top: 'Top',
+ bottom: 'Bottom',
+ moveLeft: 'Move left',
+ moveUp: 'Move up',
+ add: 'Add',
+ row: 'Row',
+ column: 'Column',
+ width: 'Width',
+ height: 'Height',
+ number: 'Number',
+ confirm: 'Confirm',
+ orderAZ: 'A-Z order',
+ orderZA: 'Z-A order',
+ clearContent: 'Clear content',
+ matrix: 'Matrix operation',
+ sortSelection: 'Sort',
+ filterSelection: 'Filter',
+ chartGeneration: 'Create chart',
+ firstLineTitle: 'first line title',
+ untitled: 'untitled',
+ array1: 'One-dimensional array',
+ array2: 'Two-dimensional array',
+ array3: 'Multidimensional Arrays',
+ diagonal: 'Diagonal',
+ antiDiagonal: 'Anti-diagonal',
+ diagonalOffset: 'Diagonal offset',
+ offset: 'Offset',
+ boolean: 'Boolean',
+ flip: 'Flip',
+ upAndDown: 'Up and down',
+ leftAndRight: 'Left and right',
+ clockwise: 'Clockwise',
+ counterclockwise: 'Counterclockwise',
+ transpose: 'Transpose',
+ matrixCalculation: 'Matrix calculation',
+ plus: 'Plus',
+ minus: 'Minus',
+ multiply: 'Multiply',
+ divided: 'Divided',
+ power: 'Power',
+ root: 'Root',
+ log: 'Log',
+ delete0: 'Delete 0 values at both ends',
+ removeDuplicate: 'Remove duplicate values',
+ byRow: 'By row',
+ byCol: 'By column',
+ generateNewMatrix: 'Generate new matrix',
+ },
+ info: {
+ detailUpdate: 'New opened',
+ detailSave: 'Local cache restored',
+ row: '',
+ column: '',
+ loading: 'Loading...',
+
+ copy: 'Copy',
+ return: 'Exit',
+ rename: 'Rename',
+ tips: 'Rename',
+ noName: 'Untitled spreadsheet',
+ wait: 'waiting for update',
+
+ add: 'Add',
+ addLast: 'more rows at bottom',
+ backTop: 'Back to the top',
+ // eslint-disable-next-line no-template-curly-in-string
+ pageInfo: 'Total ${total},${totalPage} page,current ${currentPage}',
+ nextPage: 'Next',
+
+ tipInputNumber: 'Please enter the number',
+ tipInputNumberLimit: 'The increase range is limited to 1-100',
+
+ tipRowHeightLimit: 'Row height must be between 0 ~ 545',
+ tipColumnWidthLimit: 'The column width must be between 0 ~ 2038',
+ // eslint-disable-next-line no-template-curly-in-string
+ pageInfoFull: 'Total ${total},${totalPage} page,All data displayed',
+ },
};
diff --git a/packages/ui-plugin-docs/src/Locale/zh.ts b/packages/ui-plugin-docs/src/Locale/zh.ts
index 3af3fac77c..d9e3a8b42e 100644
--- a/packages/ui-plugin-docs/src/Locale/zh.ts
+++ b/packages/ui-plugin-docs/src/Locale/zh.ts
@@ -1,8 +1,391 @@
export default {
- ui: {
- tooltip: 'UI',
+ spreadsheetLabel: '插件',
+ spreadsheetRightLabel: '更多 Sheets',
+ spreadsheet: {
one: '一',
two: '二',
three: '三',
},
+ // toolbar.undo
+ toolbar: {
+ undo: '撤销',
+ redo: '重做',
+ paintFormat: '格式刷',
+ currencyFormat: '货币格式',
+ percentageFormat: '百分比格式',
+ numberDecrease: '减少小数位数',
+ numberIncrease: '增加小数位数',
+ moreFormats: '更多格式',
+ font: '字体',
+ fontSize: '字号大小',
+ bold: '粗体 (Ctrl+B)',
+ italic: '斜体 (Ctrl+I)',
+ strikethrough: '删除线 (Alt+Shift+5)',
+ underline: '下划线',
+ textColor: {
+ main: '文本颜色',
+ right: '颜色选择',
+ },
+ resetColor: '重置颜色',
+ customColor: '自定义',
+ alternatingColors: '交替颜色',
+ confirmColor: '确定颜色',
+ cancelColor: '取消',
+ collapse: '收起',
+ fillColor: {
+ main: '单元格颜色',
+ right: '颜色选择',
+ },
+ border: {
+ main: '边框',
+ right: '边框类型',
+ },
+ mergeCell: {
+ main: '合并单元格',
+ right: '选择合并类型',
+ },
+ horizontalAlignMode: {
+ main: '水平对齐',
+ right: '对齐方式',
+ },
+ verticalAlignMode: {
+ main: '垂直对齐',
+ right: '对齐方式',
+ },
+ textWrapMode: {
+ main: '文本换行',
+ right: '换行方式',
+ },
+ textRotateMode: {
+ main: '文本旋转',
+ right: '旋转方式',
+ },
+ freezeTopRow: '冻结首行',
+ sortAndFilter: '排序和筛选',
+ findAndReplace: '查找替换',
+ sum: '求和',
+ autoSum: '自动求和',
+ moreFunction: '更多函数',
+ conditionalalFormat: '条件格式',
+ comment: '批注',
+ pivotTable: '数据透视表',
+ chart: '图表',
+ screenshot: '截图',
+ splitColumn: '分列',
+ insertImage: '插入图片',
+ insertLink: '插入链接',
+ dataValidation: '数据验证',
+ protection: '保护工作表内容',
+
+ clearText: '清除颜色选择',
+ noColorSelectedText: '没有颜色被选择',
+
+ toolMore: '更多',
+ toolLess: '少于',
+ toolClose: '收起',
+ toolMoreTip: '更多功能',
+ moreOptions: '更多选项',
+
+ cellFormat: '设置单元格格式',
+ print: '打印',
+ borderMethod: {
+ top: '上框线',
+ bottom: '下框线',
+ left: '左框线',
+ right: '右框线',
+ },
+ more: '更多',
+ },
+ defaultFmt: {
+ Automatic: {
+ text: '自动',
+ value: 'General',
+ example: '',
+ },
+ Number: {
+ text: '数字',
+ value: '##0.00',
+ example: '1000.12',
+ },
+ Percent: {
+ text: '百分比',
+ value: '#0.00%',
+ example: '12.21%',
+ },
+ PlainText: {
+ text: '纯文本',
+ value: '@',
+ example: '',
+ },
+ Scientific: {
+ text: '科学计数',
+ value: '0.00E+00',
+ example: '1.01E+5',
+ },
+ Accounting: {
+ text: '会计',
+ value: '¥(0.00)',
+ example: '¥(1200.09)',
+ },
+ Thousand: {
+ text: '万元',
+ value: 'w',
+ example: '1亿2000万2500',
+ },
+ Currency: {
+ text: '货币',
+ value: '¥0.00',
+ example: '¥1200.09',
+ },
+ Digit: {
+ text: '万元2位小数',
+ value: 'w0.00',
+ example: '2万2500.55',
+ },
+ Date: {
+ text: '日期',
+ value: 'yyyy-MM-dd',
+ example: '2017-11-29',
+ },
+ Time: { text: '时间', value: 'hh:mm AM/PM', example: '3:00 PM' },
+ Time24H: { text: '时间24H', value: 'hh:mm', example: '15:00' },
+ DateTime: { text: '日期时间', value: 'yyyy-MM-dd hh:mm AM/PM', example: '2017-11-29 3:00 PM' },
+ DateTime24H: { text: '日期时间24H', value: 'yyyy-MM-dd hh:mm', example: '2017-11-29 15:00' },
+ CustomFormats: { text: '自定义格式', value: 'fmtOtherSelf', example: '' },
+ },
+ format: {
+ moreCurrency: '更多货币格式',
+ moreDateTime: '更多日期与时间格式',
+ moreNumber: '更多数字格式',
+
+ titleCurrency: '货币格式',
+ decimalPlaces: '小数位数',
+ titleDateTime: '日期与时间格式',
+ titleNumber: '数字格式',
+ },
+ fontFamily: {
+ TimesNewRoman: 'Times New Roman',
+ Arial: 'Arial',
+ Tahoma: 'Tahoma',
+ Verdana: 'Verdana',
+ MicrosoftAccorblack: '微软雅黑',
+ SimSun: '宋体',
+ SimHei: '黑体',
+ Kaiti: '楷体',
+ FangSong: '仿宋',
+ NSimSun: '新宋体',
+ STXinwei: '华文新魏',
+ STXingkai: '华文行楷',
+ STLiti: '华文隶书',
+ HanaleiFill: 'HanaleiFill',
+ Anton: 'Anton',
+ Pacifico: 'Pacifico',
+ },
+ print: {
+ normalBtn: '常规视图',
+ layoutBtn: '页面布局',
+ pageBtn: '分页预览',
+
+ menuItemPrint: '打印(Ctrl+P)',
+ menuItemAreas: '打印区域',
+ menuItemRows: '打印标题行',
+ menuItemColumns: '打印标题列',
+ },
+ align: {
+ left: '左对齐',
+ center: '中间对齐',
+ right: '右对齐',
+
+ top: '顶部对齐',
+ middle: '居中对齐',
+ bottom: '底部对齐',
+ },
+
+ button: {
+ confirm: '确定',
+ cancel: '取消',
+ close: '关闭',
+ update: 'Update',
+ delete: 'Delete',
+ insert: '新建',
+ prevPage: '上一页',
+ nextPage: '下一页',
+ total: '总共:',
+ },
+ punctuation: {
+ tab: 'Tab 键',
+ semicolon: '分号',
+ comma: '逗号',
+ space: '空格',
+ },
+ colorPicker: {
+ collapse: '收起',
+ customColor: '自定义',
+ change: '切换',
+ confirmColor: '确定',
+ cancelColor: '取消',
+ },
+ borderLine: {
+ borderTop: '上框线',
+ borderBottom: '下框线',
+ borderLeft: '左框线',
+ borderRight: '右框线',
+ borderNone: '无',
+ borderAll: '所有',
+ borderOutside: '外侧',
+ borderInside: '内侧',
+ borderHorizontal: '内侧横线',
+ borderVertical: '内侧竖线',
+ borderColor: '边框颜色',
+ borderSize: '边框粗细',
+ },
+ merge: {
+ all: '全部合并',
+ vertical: '垂直合并',
+ horizontal: '水平合并',
+ cancel: '取消合并',
+ overlappingError: '不能合并重叠区域',
+ partiallyError: '无法对部分合并单元格执行此操作',
+ },
+ textWrap: {
+ overflow: '溢出',
+ wrap: '自动换行',
+ clip: '截断',
+ },
+ textRotate: {
+ none: '无旋转',
+ angleUp: '向上倾斜',
+ angleDown: '向下倾斜',
+ vertical: '竖排文字',
+ rotationUp: '向上90°',
+ rotationDown: '向下90°',
+ },
+ sheetConfig: {
+ delete: '删除',
+ copy: '复制',
+ rename: '重命名',
+ changeColor: '更改颜色',
+ hide: '隐藏',
+ unhide: '取消隐藏',
+ moveLeft: '向左移',
+ moveRight: '向右移',
+ resetColor: '重置颜色',
+ cancelText: '取消',
+ chooseText: '确定颜色',
+
+ tipNameRepeat: '标签页的名称不能重复!请重新修改',
+ noMoreSheet: '工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。',
+ confirmDelete: '是否删除',
+ redoDelete: '可以通过Ctrl+Z撤销删除',
+ noHide: '不能隐藏, 至少保留一个sheet标签',
+ chartEditNoOpt: '图表编辑模式下不允许该操作!',
+ sheetNameSpecCharError: "名称不能超过31个字符,首尾不能是' 且名称不能包含:\r\n[ ] : \\ ? * /",
+ sheetNameCannotIsEmptyError: '名称不能为空!',
+ },
+ rightClick: {
+ copy: '复制',
+ copyAs: '复制为',
+ cut: '剪切',
+ paste: '粘贴',
+ insert: '插入',
+ delete: '删除',
+ insertRow: '插入行',
+ insertColumn: '插入列',
+ deleteCell: '删除单元格',
+ deleteSelected: '删除选中',
+ hide: '隐藏',
+ hideSelected: '隐藏选中',
+ showHide: '显示隐藏',
+ toTopAdd: '向上增加',
+ toBottomAdd: '向下增加',
+ toLeftAdd: '向左增加',
+ toRightAdd: '向右增加',
+ deleteSelectedRow: '删除选中行',
+ deleteSelectedColumn: '删除选中列',
+ hideSelectedRow: '隐藏选中行',
+ showHideRow: '显示隐藏行',
+ rowHeight: '行高',
+ hideSelectedColumn: '隐藏选中列',
+ showHideColumn: '显示隐藏列',
+ columnWidth: '列宽',
+ to: '向',
+ left: '左',
+ right: '右',
+ top: '上',
+ bottom: '下',
+ moveLeft: '左移',
+ moveUp: '上移',
+ add: '增加',
+ row: '行',
+ column: '列',
+ width: '宽',
+ height: '高',
+ number: '数字',
+ confirm: '确认',
+ orderAZ: 'A-Z顺序排列',
+ orderZA: 'Z-A降序排列',
+ clearContent: '清除内容',
+ matrix: '矩阵操作选区',
+ sortSelection: '排序选区',
+ filterSelection: '筛选选区',
+ chartGeneration: '图表生成',
+ firstLineTitle: '首行为标题',
+ untitled: '无标题',
+ array1: '一维数组',
+ array2: '二维数组',
+ array3: '多维数组',
+ diagonal: '对角线',
+ antiDiagonal: '反对角线',
+ diagonalOffset: '对角偏移',
+ offset: '偏移量',
+ boolean: '布尔值',
+ flip: '翻转',
+ upAndDown: '上下',
+ leftAndRight: '左右',
+ clockwise: '顺时针',
+ counterclockwise: '逆时针',
+ transpose: '转置',
+ matrixCalculation: '矩阵计算',
+ plus: '加',
+ minus: '减',
+ multiply: '乘',
+ divided: '除',
+ power: '次方',
+ root: '次方根',
+ log: 'log',
+ delete0: '删除两端0值',
+ removeDuplicate: '删除重复值',
+ byRow: '按行',
+ byCol: '按列',
+ generateNewMatrix: '生成新矩阵',
+ },
+ info: {
+ detailUpdate: '新打开',
+ detailSave: '已恢复本地缓存',
+ row: '行',
+ column: '列',
+ loading: '渲染中···',
+
+ copy: '副本',
+ return: '返回',
+ rename: '重命名',
+ tips: '重命名',
+ noName: '无标题的电子表格',
+ wait: '待更新',
+
+ add: '添加',
+ addLast: '在底部添加',
+ backTop: '回到顶部',
+ // eslint-disable-next-line no-template-curly-in-string
+ pageInfo: '共${total}条,${totalPage}页,当前已显示${currentPage}页',
+ nextPage: '下一页',
+
+ tipInputNumber: '请输入数字',
+ tipInputNumberLimit: '增加范围限制在1-100',
+
+ tipRowHeightLimit: '行高必须在0 ~ 545之间',
+ tipColumnWidthLimit: '列宽必须在0 ~ 2038之间',
+ // eslint-disable-next-line no-template-curly-in-string
+ pageInfoFull: '共${total}条,${totalPage}页,已显示全部数据',
+ },
};
diff --git a/packages/ui-plugin-docs/src/Model/InfoBarModel.ts b/packages/ui-plugin-docs/src/Model/InfoBarModel.ts
new file mode 100644
index 0000000000..e9d969cf44
--- /dev/null
+++ b/packages/ui-plugin-docs/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-docs/src/Model/index.ts b/packages/ui-plugin-docs/src/Model/index.ts
index e69de29bb2..769508d212 100644
--- a/packages/ui-plugin-docs/src/Model/index.ts
+++ b/packages/ui-plugin-docs/src/Model/index.ts
@@ -0,0 +1 @@
+export * from './InfoBarModel';
diff --git a/packages/ui-plugin-docs/src/View/App.tsx b/packages/ui-plugin-docs/src/View/App.tsx
new file mode 100644
index 0000000000..49d7d08465
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/App.tsx
@@ -0,0 +1,70 @@
+import { AppContext, BaseComponentProps, Component } from '@univerjs/base-ui';
+import { LocaleType } from '@univerjs/core';
+import { BaseDocContainerProps, DocContainer } from './DocContainer';
+
+export interface BaseUIProps extends BaseComponentProps {
+ locale: LocaleType;
+ UIConfig: BaseDocContainerProps;
+ 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>
+ <DocContainer {...UIConfig} />
+ </AppContext.Provider>
+ );
+ }
+}
diff --git a/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx
new file mode 100644
index 0000000000..b4289f5d65
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/Common/ColorSelect/ColorSelect.tsx
@@ -0,0 +1,56 @@
+import { BaseComponentProps, Component, ComponentChildren } from '@univerjs/base-ui';
+import { DocUIPlugin } from '../../..';
+import { DOC_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<DocUIPlugin>(DOC_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-docs/src/View/Common/ColorSelect/index.module.css b/packages/ui-plugin-docs/src/View/Common/ColorSelect/index.module.css
new file mode 100644
index 0000000000..d2777b3979
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/Common/ColorSelect/index.module.css
@@ -0,0 +1,11 @@
+.color-select {
+ position: relative;
+}
+.color-select .color-select-line {
+ position: absolute;
+ width: 15px;
+ height: 5px;
+ bottom: 0px;
+ left: 50%;
+ transform: translate(-50%, 0);
+}
diff --git a/packages/ui-plugin-docs/src/View/Common/ColorSelect/index.module.less b/packages/ui-plugin-docs/src/View/Common/ColorSelect/index.module.less
new file mode 100644
index 0000000000..41556b46dd
--- /dev/null
+++ b/packages/ui-plugin-docs/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 file
diff --git a/packages/ui-plugin-docs/src/View/Common/index.tsx b/packages/ui-plugin-docs/src/View/Common/index.tsx
new file mode 100644
index 0000000000..6177edb882
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/Common/index.tsx
@@ -0,0 +1 @@
+export * from './ColorSelect/ColorSelect';
diff --git a/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx b/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx
new file mode 100644
index 0000000000..3231d58b80
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx
@@ -0,0 +1,251 @@
+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 { IDocUIPluginConfig } from '../../Basics';
+import { Toolbar } from '../Toolbar';
+import { InfoBar } from '../InfoBar';
+
+export interface BaseDocContainerProps extends BaseComponentProps {
+ config: IDocUIPluginConfig;
+ changeLocale: (locale: string) => void;
+ methods?: any;
+}
+
+/**
+ * One univerdoc instance DOM container
+ */
+export class DocContainer extends Component<BaseDocContainerProps> {
+ leftContentLeft: number;
+
+ leftContentTop: number;
+
+ rightBorderX: number;
+
+ rightBorderY: number;
+
+ splitLeftRef = createRef<HTMLDivElement>();
+
+ contentRef = createRef<HTMLDivElement>();
+
+ constructor(props: BaseDocContainerProps) {
+ 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?.docContainerConfig!;
+ 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 doc = getSkinStyleDoc(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;}
+ */
+
+ doc.insertRule(
+ `#${id} ${JSON.stringify(currentSkin)
+ .replace(/"/g, '')
+ .replace(/,(?=--)/g, ';')}`
+ );
+ }
+
+ /**
+ * get skin style doc
+ * @param id
+ * @returns
+ */
+
+ function getSkinStyleDoc(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 univerdoc-skin-style
+ * @param skinStyleDoc
+ * @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?.docContainerConfig!;
+ // 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={{
+ display: config.innerLeft ? 'block' : 'none',
+ }}
+ >
+ {/* innerLeft */}
+ </Sider>
+ <Content className={config.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>
+ {!!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}></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',
+ }}
+ ></Footer>
+ </Layout>
+ <Sider
+ style={{
+ display: config.outerRight ? 'block' : 'none',
+ }}
+ className={style.outerRightContainer}
+ ></Sider>
+ </Layout>
+ </Container>
+ );
+ }
+}
diff --git a/packages/base-docs/src/View/UI/DocContainer/index.module.less b/packages/ui-plugin-docs/src/View/DocContainer/index.module.less
similarity index 91%
rename from packages/base-docs/src/View/UI/DocContainer/index.module.less
rename to packages/ui-plugin-docs/src/View/DocContainer/index.module.less
index 407785ea2d..100caac0a5 100644
--- a/packages/base-docs/src/View/UI/DocContainer/index.module.less
+++ b/packages/ui-plugin-docs/src/View/DocContainer/index.module.less
@@ -1,79 +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;
- // position: relative;
- background: rgb(224, 235, 237);
- }
- }
-
- .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;
- background: rgb(224, 235, 237);
- }
- }
-
- .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-docs/src/View/UI/DocContainer/index.ts b/packages/ui-plugin-docs/src/View/DocContainer/index.ts
similarity index 100%
rename from packages/base-docs/src/View/UI/DocContainer/index.ts
rename to packages/ui-plugin-docs/src/View/DocContainer/index.ts
diff --git a/packages/ui-plugin-docs/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-docs/src/View/InfoBar/InfoBar.tsx
new file mode 100644
index 0000000000..d2ce4d4dd4
--- /dev/null
+++ b/packages/ui-plugin-docs/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, sheet, 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={sheet.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-docs/src/View/UI/InfoBar/index.less b/packages/ui-plugin-docs/src/View/InfoBar/index.module.less
similarity index 84%
rename from packages/base-docs/src/View/UI/InfoBar/index.less
rename to packages/ui-plugin-docs/src/View/InfoBar/index.module.less
index 4c52e0c4c5..bb3e266e29 100644
--- a/packages/base-docs/src/View/UI/InfoBar/index.less
+++ b/packages/ui-plugin-docs/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-docs/src/View/UI/InfoBar/index.ts b/packages/ui-plugin-docs/src/View/InfoBar/index.ts
similarity index 100%
rename from packages/base-docs/src/View/UI/InfoBar/index.ts
rename to packages/ui-plugin-docs/src/View/InfoBar/index.ts
diff --git a/packages/base-docs/src/View/UI/InfoBar/infobar-zh.md b/packages/ui-plugin-docs/src/View/InfoBar/infobar-zh.md
similarity index 100%
rename from packages/base-docs/src/View/UI/InfoBar/infobar-zh.md
rename to packages/ui-plugin-docs/src/View/InfoBar/infobar-zh.md
diff --git a/packages/ui-plugin-docs/src/View/Render/index.ts b/packages/ui-plugin-docs/src/View/Render/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/base-docs/src/View/UI/ToolBar/Const.ts b/packages/ui-plugin-docs/src/View/Toolbar/Const.ts
similarity index 60%
rename from packages/base-docs/src/View/UI/ToolBar/Const.ts
rename to packages/ui-plugin-docs/src/View/Toolbar/Const.ts
index 1701d084f8..c2db56e735 100644
--- a/packages/base-docs/src/View/UI/ToolBar/Const.ts
+++ b/packages/ui-plugin-docs/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-docs/src/View/UI/ToolBar/DataBar.tsx b/packages/ui-plugin-docs/src/View/Toolbar/DataBar.tsx
similarity index 100%
rename from packages/base-docs/src/View/UI/ToolBar/DataBar.tsx
rename to packages/ui-plugin-docs/src/View/Toolbar/DataBar.tsx
diff --git a/packages/base-docs/src/View/UI/ToolBar/Toolbar-zh.md b/packages/ui-plugin-docs/src/View/Toolbar/Toolbar-zh.md
similarity index 100%
rename from packages/base-docs/src/View/UI/ToolBar/Toolbar-zh.md
rename to packages/ui-plugin-docs/src/View/Toolbar/Toolbar-zh.md
diff --git a/packages/base-docs/src/View/UI/ToolBar/ToolBar.md b/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.md
similarity index 100%
rename from packages/base-docs/src/View/UI/ToolBar/ToolBar.md
rename to packages/ui-plugin-docs/src/View/Toolbar/Toolbar.md
diff --git a/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx
new file mode 100644
index 0000000000..4394ca3a29
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/Toolbar/Toolbar.tsx
@@ -0,0 +1,274 @@
+import { AppContext, AppContextValues, BaseComponentProps, Button, Component, Container, createRef, debounce, findLocale, PreactContext, Select, Tooltip } from '@univerjs/base-ui';
+import { DocUIPlugin } from '../..';
+import { DOC_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<DocUIPlugin>(DOC_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<DocUIPlugin>(DOC_UI_PLUGIN_NAME)?.getAppUIController().getDocContainerController().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-docs/src/View/UI/ToolBar/index.less b/packages/ui-plugin-docs/src/View/Toolbar/index.less
similarity index 100%
rename from packages/base-docs/src/View/UI/ToolBar/index.less
rename to packages/ui-plugin-docs/src/View/Toolbar/index.less
diff --git a/packages/base-docs/src/View/UI/ToolBar/index.module.less b/packages/ui-plugin-docs/src/View/Toolbar/index.module.less
similarity index 51%
rename from packages/base-docs/src/View/UI/ToolBar/index.module.less
rename to packages/ui-plugin-docs/src/View/Toolbar/index.module.less
index 4b6a2d43f5..64875de941 100644
--- a/packages/base-docs/src/View/UI/ToolBar/index.module.less
+++ b/packages/ui-plugin-docs/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;
height: 26px;
display: inline-block;
vertical-align: middle;
- margin: 7px 3px 0 3px;
+ margin: 0 3px;
+ cursor: pointer;
&.select-button:hover {
background-color: #efefef;
@@ -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 file
diff --git a/packages/ui-plugin-docs/src/View/Toolbar/index.ts b/packages/ui-plugin-docs/src/View/Toolbar/index.ts
new file mode 100644
index 0000000000..7c6430332b
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/Toolbar/index.ts
@@ -0,0 +1 @@
+export * from './Toolbar';
diff --git a/packages/ui-plugin-docs/src/View/UI/index.ts b/packages/ui-plugin-docs/src/View/UI/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/ui-plugin-docs/src/View/index.tsx b/packages/ui-plugin-docs/src/View/index.tsx
new file mode 100644
index 0000000000..e4c0ec1953
--- /dev/null
+++ b/packages/ui-plugin-docs/src/View/index.tsx
@@ -0,0 +1,41 @@
+import { isElement, render } from '@univerjs/base-ui';
+import { App, BaseUIProps } from './App';
+
+interface BaseDicUIConfig extends BaseUIProps {
+ container?: HTMLElement | string;
+}
+
+export class UI {
+ constructor(props: BaseDicUIConfig) {
+ this._initialize(props);
+ }
+
+ static create(props: BaseDicUIConfig) {
+ return new UI(props);
+ }
+
+ private _initialize(props: BaseDicUIConfig) {
+ 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 './DocContainer';
+export * from './Toolbar';
diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts
index bec04a524f..3db535348e 100644
--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts
+++ b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts
@@ -102,7 +102,6 @@ export class ToolbarUIController {
toolbarType: 1,
tooltip: 'toolbar.undo',
name: 'undo',
- unActive: true,
customLabel: {
name: 'ForwardIcon',
},
@@ -115,7 +114,6 @@ export class ToolbarUIController {
{
toolbarType: 1,
tooltip: 'toolbar.redo',
- unActive: true,
customLabel: {
name: 'BackIcon',
},
@@ -165,7 +163,7 @@ export class ToolbarUIController {
customLabel: {
name: 'BoldIcon',
},
- active: false,
+ unActive: false,
name: 'bold',
show: this._config.bold,
onClick: (e, isBold: boolean) => {
@@ -179,6 +177,7 @@ export class ToolbarUIController {
customLabel: {
name: 'ItalicIcon',
},
+ unActive: false,
name: 'italic',
show: this._config.italic,
onClick: (e, isItalic: boolean) => {
@@ -192,6 +191,7 @@ export class ToolbarUIController {
customLabel: {
name: 'DeleteLineIcon',
},
+ unActive: false,
name: 'strikethrough',
show: this._config.strikethrough,
onClick: (e, isStrikethrough: boolean) => {
@@ -208,6 +208,7 @@ export class ToolbarUIController {
customLabel: {
name: 'UnderLineIcon',
},
+ unActive: false,
name: 'underline',
show: this._config.underline,
onClick: (e, isUnderLine: boolean) => {
diff --git a/test.html b/test.html
deleted file mode 100644
index 9291bc5892..0000000000
--- a/test.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- .main {
- width: 100px;
- height: 100px;
- background: #abcdef;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- </style>
-</head>
-
-<body>
- <div class="main">嘿嘿嘿</div>
- <button>click</button>
-</body>
-<script>
-
-</script>
-
-</html>
\ No newline at end of file
diff --git a/test.js b/test.js
new file mode 100644
index 0000000000..ca52143d24
--- /dev/null
+++ b/test.js
@@ -0,0 +1 @@
+console.dir(111);