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

tonytonychopper123c62db43b93bd
diff --git a/packages/base-ui/src/Components/Layout/Layout.tsx b/packages/base-ui/src/Components/Layout/Layout.tsx
index 4b59c06d9b..46bfbe69c1 100644
--- a/packages/base-ui/src/Components/Layout/Layout.tsx
+++ b/packages/base-ui/src/Components/Layout/Layout.tsx
@@ -1,17 +1,6 @@
-import {
- BaseLayoutProps,
- Component,
- ContentComponent,
- createRef,
- FooterComponent,
- forwardRef,
- getFirstChildren,
- HeaderComponent,
- JSXComponent,
- LayoutComponent,
- Ref,
- SiderComponent,
-} from '@univerjs/base-ui';
+import { Component, createRef, forwardRef, Ref } from '../../Framework';
+import { BaseLayoutProps } from '../../Interfaces';
+import { getFirstChildren } from '../../Utils';
import styles from './index.module.less';
// Types for props
@@ -106,29 +95,3 @@ const Sider = (props: BaseLayoutProps) => {
};
export { Layout, Header, Footer, Content, Sider };
-
-export class UniverLayout implements LayoutComponent {
- render(): JSXComponent<BaseLayoutProps> {
- return Layout;
- }
-}
-export class UniverHeader implements HeaderComponent {
- render(): JSXComponent<BaseLayoutProps> {
- return Header;
- }
-}
-export class UniverFooter implements FooterComponent {
- render(): JSXComponent<BaseLayoutProps> {
- return Footer;
- }
-}
-export class UniverContent implements ContentComponent {
- render(): JSXComponent<BaseLayoutProps> {
- return Content;
- }
-}
-export class UniverSider implements SiderComponent {
- render(): JSXComponent<BaseLayoutProps> {
- return Sider;
- }
-}
diff --git a/packages/core/src/Basics/Context.ts b/packages/core/src/Basics/Context.ts
index 2e197511f3..b6090294e8 100644
--- a/packages/core/src/Basics/Context.ts
+++ b/packages/core/src/Basics/Context.ts
@@ -7,6 +7,8 @@ import { ContextBase } from './ContextBase';
export class Context extends ContextBase {
constructor(univerData: Partial<IUniverData> = {}) {
super();
+
+ this._locale.initialize();
}
protected _setObserver(): void {}
diff --git a/packages/core/src/Shared/Locale.ts b/packages/core/src/Shared/Locale.ts
index 1933644eee..81e03fb596 100644
--- a/packages/core/src/Shared/Locale.ts
+++ b/packages/core/src/Shared/Locale.ts
@@ -121,6 +121,10 @@ export class Locale {
this.options.currentLocale = locale;
}
+ getCurrentLocale() {
+ return this.options.currentLocale;
+ }
+
/**
* get value from Locale object and key
* @param locale - A specified language pack
diff --git a/packages/style-univer/package.json b/packages/style-univer/package.json
deleted file mode 100644
index 141afb6357..0000000000
--- a/packages/style-univer/package.json
+++ /dev/null
@@ -1,58 +0,0 @@
-{
- "name": "@univerjs/style-univer",
- "version": "0.0.1",
- "description": "Universheet normal plugin UI manager",
- "keywords": [],
- "author": "DreamNum <[email protected]>",
- "license": "MIT",
- "main": "./src/index.ts",
- "module": "./src/index.ts",
- "types": "./src/Types/index.d.ts",
- "publishConfig": {
- "main": "./lib/univer-style-univer.cjs.js",
- "module": "./lib/univer-style-univer.es.js",
- "types": "./lib/index.d.ts"
- },
- "exports": {
- ".": "./src/index.ts",
- "./*": "./src/*"
- },
- "directories": {
- "lib": "lib"
- },
- "scripts": {
- "test": "jest -c jest.config.js",
- "test:cover": "cross-env NODE_ENV=--experimental-vm-modules jest --coverage",
- "dev": "vite",
- "build": "tsc && vite build",
- "watch": "vite build",
- "link": "pnpm link ./",
- "serve": "vite preview"
- },
- "devDependencies": {
- "@preact/preset-vite": "2.0.0",
- "@testing-library/preact": "^2.0.1",
- "@types/jest": "^27.5.2",
- "@types/node": "^16.4.6",
- "debug": "^4.3.3",
- "enzyme": "^3.11.0",
- "enzyme-adapter-preact-pure": "^3.3.0",
- "identity-obj-proxy": "^3.0.0",
- "jest-dev-server": "^6.1.1",
- "jest-environment-jsdom": "^29.0.3",
- "less": "^4.1.1",
- "ts-jest": "29.0.1",
- "ts-node": "^10.2.1",
- "typescript": "^4.4.1-rc",
- "vite": "^2.4.4",
- "vite-plugin-external": "1.2.3"
- },
- "dependencies": {
- "@univerjs/base-ui": "workspace:^0.0.1",
- "@univerjs/core": "workspace:^0.0.1",
- "css-vars-ponyfill": "^2.4.6",
- "nanoid": "^4.0.0",
- "preact": "^10.5.14",
- "react-colorful": "^5.3.0"
- }
-}
diff --git a/packages/ui-plugin-sheets/src/Basic/Enum/index.ts b/packages/ui-plugin-sheets/src/Basic/Enum/index.ts
deleted file mode 100644
index 8ab1531b5b..0000000000
--- a/packages/ui-plugin-sheets/src/Basic/Enum/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './LocaleType';
diff --git a/packages/ui-plugin-sheets/src/Basic/Shared/index.ts b/packages/ui-plugin-sheets/src/Basic/Shared/index.ts
deleted file mode 100644
index 28d40166a9..0000000000
--- a/packages/ui-plugin-sheets/src/Basic/Shared/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Locale';
diff --git a/packages/ui-plugin-sheets/src/Basics/Enum/LocaleType.ts b/packages/ui-plugin-sheets/src/Basics/Enum/LocaleType.ts
deleted file mode 100644
index a820b34120..0000000000
--- a/packages/ui-plugin-sheets/src/Basics/Enum/LocaleType.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Internationalized enumeration information.
- *
- * Refer to {@link https://github.com/ladjs/i18n-locales | i18n-locales}
- */
-export enum LocaleType {
- EN = 'en',
- ZH = 'zh',
-}
-
-export type LocaleTypes = `${LocaleType}`;
diff --git a/packages/ui-plugin-sheets/src/Basics/Interfaces/ComponentConfig/ISheetsPluginConfig.ts b/packages/ui-plugin-sheets/src/Basics/Interfaces/ComponentConfig/ISheetsPluginConfig.ts
index 539dd534b2..e24a0fb7b9 100644
--- a/packages/ui-plugin-sheets/src/Basics/Interfaces/ComponentConfig/ISheetsPluginConfig.ts
+++ b/packages/ui-plugin-sheets/src/Basics/Interfaces/ComponentConfig/ISheetsPluginConfig.ts
@@ -1,8 +1,7 @@
import { SheetRightMenuConfig } from './RightMenuConfig';
import { SheetContainerConfig } from './SheetContainerConfig';
import { SheetToolBarConfig } from './ToolBarConfig';
-import { SheetContext } from '@univerjs/core';
-import { LocaleType } from '../../Enum';
+import { Context } from '@univerjs/core/src/Basics/Context';
export interface ILayout {
sheetContainerConfig?: SheetContainerConfig;
@@ -13,7 +12,5 @@ export interface ILayout {
export interface ISheetsPluginConfig {
container?: HTMLElement | string;
layout?: ILayout;
- skin?: string;
- locale?: LocaleType;
- context?: SheetContext;
+ context?: Context;
}
diff --git a/packages/ui-plugin-sheets/src/Basics/Observer.ts b/packages/ui-plugin-sheets/src/Basics/Observer.ts
new file mode 100644
index 0000000000..d92066c6a6
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/Basics/Observer.ts
@@ -0,0 +1,17 @@
+import { Observable } from '@univerjs/core';
+import { SheetUIPlugin } from '../SheetUIPlugin';
+
+export type SheetUIPluginObserve = {
+ onAfterChangeUISkinObservable: Observable<void>;
+ onAfterChangeUILocaleObservable: Observable<void>;
+};
+
+export function uninstallObserver(plugin: SheetUIPlugin) {
+ plugin.deleteObserve('onAfterChangeUISkinObservable');
+ plugin.deleteObserve('onAfterChangeUILocaleObservable');
+}
+
+export function installObserver(plugin: SheetUIPlugin) {
+ plugin.pushToObserve('onAfterChangeUISkinObservable');
+ plugin.pushToObserve('onAfterChangeUILocaleObservable');
+}
diff --git a/packages/ui-plugin-sheets/src/Basics/Shared/Locale.ts b/packages/ui-plugin-sheets/src/Basics/Shared/Locale.ts
deleted file mode 100644
index 7b0d38860e..0000000000
--- a/packages/ui-plugin-sheets/src/Basics/Shared/Locale.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-import { Nullable, Tools } from '@univerjs/core';
-import { LocaleType } from '../../Enum';
-
-/**
- * The data structure stored by the Locale class
- */
-export type ILocaleOptions = {
- /**
- * Current Locale such as 'en' / 'en-US' / 'zh' / ''zh-CN / 'zh-TW'
- *
- * @remarks
- * See {@link LocaleType| the LocaleType enum} for more details.
- *
- * @defaultValue `LocaleType.EN`
- */
- currentLocale: LocaleType;
-
- /**
- * The content of international translation, stored in key-value form,
- *
- * @example
- * Locale data like
- * ```json
- * {
- * "en": {
- * "name": "value"
- * },
- * "zh": {
- * "name": "值"
- * }
- * }
- * ```
- */
- locales: object;
-};
-
-/**
- * Basic English internationalization object
- *
- * The internationalized language pack of the plug-in will be dynamically loaded in each plug-in.
- */
-const zh = {};
-const en = {};
-
-/**
- * Internationalization
- *
- * @remarks
- * Get inspiration from the react-intl-universal project, see {@link https://github.com/alibaba/react-intl-universal | the protocol spec}.
- *
- * @beta
- */
-export class Locale {
- options: ILocaleOptions;
-
- constructor(locale: Nullable<LocaleType>) {
- this.options = {
- // use config first, or get language setting from browser
- currentLocale: locale || ['zh', 'zh-CN'].includes(Tools.getLanguage()) ? LocaleType.ZH : LocaleType.EN,
- locales: { zh, en },
- };
- }
-
- initialize(locale: Nullable<LocaleType>) {
- this.options = {
- // use config first, or get language setting from browser
- currentLocale: locale || ['zh', 'zh-CN'].includes(Tools.getLanguage()) ? LocaleType.ZH : LocaleType.EN,
- locales: { zh, en },
- };
- }
-
- /**
- * Get the formatted message by key
- *
- * @example
- * ```ts
- * Locale.get('name')
- * ```
- *
- * @param key - The string representing key in Locale data file
- * @returns Get the translation corresponding to the Key
- */
- get(key: string | undefined): string {
- if (key) {
- const { locales, currentLocale } = this.options;
- return (Locale.getValue(locales[currentLocale], key) as string) || '';
- }
- return String();
- }
-
- getObject<T>(key: string): T {
- const { locales, currentLocale } = this.options;
- return Locale.getValue(locales[currentLocale], key) as unknown as T;
- }
-
- /**
- * Load more locales after init
- *
- * @example
- * ```ts
- * Locale.load({zh,en})
- * ```
- *
- * @param locales - Locale object
- * @returns void
- *
- */
- load(locales: object): void {
- Tools.deepMerge(this.options.locales, locales);
- }
-
- /**
- * change Locale
- *
- * @example
- * Change to Chinese
- * ```ts
- * Locale.change(LocaleType.ZH)
- * ```
- *
- * @param locale - Locale Type, see {@link LocaleType}
- *
- */
- change(locale: LocaleType): void {
- this.options.currentLocale = locale;
- }
-
- /**
- * get value from Locale object and key
- * @param locale - A specified language pack
- * @param key - Specify key
- * @returns Get the translation corresponding to the Key
- *
- * @private
- */
- private static getValue(locale: object, key: string): Nullable<string | object> {
- try {
- return locale[key] ? locale[key] : key.split('.').reduce((a, b) => a[b], locale);
- } catch (error) {
- console.error('Key %s not found', key);
- }
- }
-}
diff --git a/packages/ui-plugin-sheets/src/Basics/index.ts b/packages/ui-plugin-sheets/src/Basics/index.ts
index 14c41ec033..6e04e5205a 100644
--- a/packages/ui-plugin-sheets/src/Basics/index.ts
+++ b/packages/ui-plugin-sheets/src/Basics/index.ts
@@ -3,3 +3,4 @@ export * from './Enum';
export * from '../Locale';
export * from './Shared';
export * from './Interfaces';
+export * from './Observer';
diff --git a/packages/ui-plugin-sheets/src/Controller/SheetUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetUIController.ts
index 5c9968261a..9604e1484a 100644
--- a/packages/ui-plugin-sheets/src/Controller/SheetUIController.ts
+++ b/packages/ui-plugin-sheets/src/Controller/SheetUIController.ts
@@ -1,9 +1,109 @@
+import { LocaleType } from '@univerjs/core';
+import { ISheetsPluginConfig } from '../Basics';
import { SheetUIPlugin } from '../SheetUIPlugin';
+import { SheetContainer, UI } from '../View';
export class SheetUIController {
protected _plugin: SheetUIPlugin;
+ private _sheetContainer: SheetContainer;
+
+ // private _toolbarController: ToolBarController;
+
+ // private _cellEditorController: CellEditorController;
+
+ // private _infoBarController: InfoBarController;
+
+ // private _rightMenuController: RightMenuController;
+
+ // private _countBarController: CountBarController;
+
+ // private _sheetBarController: SheetBarControl;
+
+ private _config: ISheetsPluginConfig;
+
constructor(plugin: SheetUIPlugin) {
this._plugin = plugin;
+
+ this._config = this._plugin.getConfig();
+
+ this._initialize();
+
+ // this._toolbarController = new ToolBarController(this._plugin);
+ // this._cellEditorController = new CellEditorController(this._plugin);
+ // this._infoBarController = new InfoBarController(this._plugin);
+ // this._rightMenuController = new RightMenuController(this._plugin);
+ // this._countBarController = new CountBarController(this._plugin);
+ // this._sheetBarController = new SheetBarControl(this._plugin);
+
+ // 初始化UI
+ const config = {
+ config: this._config,
+ changeSkin: this.changeSkin,
+ changeLocale: this.changeLocale,
+ getComponent: this.getComponent,
+ methods: {
+ toolbar: {
+ // getComponent: this._toolbarController.getComponent,
+ },
+ cellEditor: {
+ // getComponent: this._cellEditorController.getComponent,
+ },
+ infoBar: {
+ // getComponent: this._infoBarController.getComponent,
+ // renameSheet: this._infoBarController.renameSheet,
+ },
+ rightMenu: {
+ // getComponent: this._rightMenuController.getComponent,
+ },
+ countBar: {
+ // getComponent: this._countBarController.getComponent,
+ },
+ sheetBar: {
+ // getComponent: this._sheetBarController.getComponent,
+ // addSheet: this._sheetBarController.addSheet,
+ // selectSheet: this._sheetBarController.selectSheet,
+ // changeSheetName: this._sheetBarController.changeSheetName,
+ },
+ },
+ };
+ UI.create(config);
+ }
+
+ private _initialize() {}
+
+ // 获取SheetContainer组件
+ getComponent = (ref: SheetContainer) => {
+ this._sheetContainer = ref;
+ };
+
+ /**
+ * Change skin
+ * @param {String} lang new skin
+ */
+ changeSkin = () => {
+ // publish
+ this._plugin.getObserver('onAfterChangeUISkinObservable')!.notifyObservers();
+ };
+
+ /**
+ * 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.getObserver('onAfterChangeUILocaleObservable')!.notifyObservers();
+ };
+
+ getContentRef() {
+ return this._sheetContainer.getContentRef();
}
}
diff --git a/packages/ui-plugin-sheets/src/SheetUIPlugin.tsx b/packages/ui-plugin-sheets/src/SheetUIPlugin.tsx
index 1a55416035..1a9f692845 100644
--- a/packages/ui-plugin-sheets/src/SheetUIPlugin.tsx
+++ b/packages/ui-plugin-sheets/src/SheetUIPlugin.tsx
@@ -1,15 +1,14 @@
import { Plugin, UniverSheet, Tools } from '@univerjs/core';
import { zh, en } from './Locale';
import { SheetUIController } from './Controller/SheetUIController';
-import { DefaultSheetUiConfig, ISheetsPluginConfig, Locale, SHEET_UI_PLUGIN_NAME } from './Basic';
+import { DefaultSheetUiConfig, installObserver, ISheetsPluginConfig, SheetUIPluginObserve, SHEET_UI_PLUGIN_NAME } from './Basics';
+import { Context } from '@univerjs/core/src/Basics/Context';
-export class SheetUIPlugin extends Plugin {
+export class SheetUIPlugin extends Plugin<SheetUIPluginObserve, Context> {
private _sheetsController: SheetUIController;
private _config: ISheetsPluginConfig;
- private _locale: Locale;
-
constructor(config?: ISheetsPluginConfig) {
super(SHEET_UI_PLUGIN_NAME);
this._config = Tools.deepMerge({}, DefaultSheetUiConfig, config);
@@ -23,20 +22,25 @@ export class SheetUIPlugin extends Plugin {
univerInstance.installPlugin(this);
}
- initialize(): void {
+ initialize(ctx: Context): void {
+ installObserver(this);
+ this._config.context = ctx;
const context = this.getContext();
-
/**
* load more Locale object
*/
context.getLocale().load({
- en: en,
- zh: zh,
+ zh,
+ en,
});
this._sheetsController = new SheetUIController(this);
}
+ getConfig() {
+ return this._config;
+ }
+
onMounted(): void {
this.initialize();
}
diff --git a/packages/ui-plugin-sheets/src/View/UniverContainer/UniverContainer.tsx b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx
similarity index 55%
rename from packages/ui-plugin-sheets/src/View/UniverContainer/UniverContainer.tsx
rename to packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx
index f6cbf45a07..72fd6c9e6e 100644
--- a/packages/ui-plugin-sheets/src/View/UniverContainer/UniverContainer.tsx
+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx
@@ -1,39 +1,29 @@
-import { Tools } from '@univerjs/core';
-import { Container, Content, Footer, Header, Layout, Sider } from '@univerjs/style-univer';
-import cssVars from 'css-vars-ponyfill';
-import defaultSkin from '@univerjs/style-univer/assets/css/skin/default.module.less';
-import darkSkin from '@univerjs/style-univer/assets/css/skin/dark.module.less';
-import greenSkin from '@univerjs/style-univer/assets/css/skin/green.module.less';
-import { BaseComponentProps } from '../../BaseComponent';
-import { AppContext } from '../../Common';
-import { Component, createRef } from '../../Framework';
import style from './index.module.less';
import { ToolBar } from '../ToolBar';
import { InfoBar } from '../InfoBar';
-import { UniverConfig } from '../../Basics/Interfaces/ComponentConfig/UniverConfig';
import { RightMenu } from '../RightMenu';
import { CountBar } from '../CountBar';
import { SheetBar } from '../SheetBar';
+import { AppContext, BaseComponentProps, Component, createRef } from '@univerjs/base-ui';
+import { ISheetsPluginConfig } from '../../Basics';
export interface BaseSheetContainerProps extends BaseComponentProps {
- config: UniverConfig;
+ config: ISheetsPluginConfig;
container?: HTMLElement;
changeSkin: () => void;
changeLocale: (locale: string) => void;
- mountCanvas?: (container: HTMLElement) => void;
methods?: any;
}
// Types for state
interface IState {
currentLocale: string;
- currentSkin: string;
}
/**
* One universheet instance DOM container
*/
-export class UniverContainer extends Component<BaseSheetContainerProps, IState> {
+export class SheetContainer extends Component<BaseSheetContainerProps, IState> {
leftContentLeft: number;
leftContentTop: number;
@@ -48,18 +38,14 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
constructor(props: BaseSheetContainerProps) {
super(props, { context: props.config.context });
- const defaultSkin = props.config.skin ?? 'default';
// init state
this.state = {
- currentLocale: props.config.locale ?? 'zh',
- currentSkin: defaultSkin,
+ currentLocale: this._context.getLocale().getCurrentLocale() ?? 'zh',
};
- this.changeSkin(props.container!, defaultSkin);
}
componentDidMount() {
this.props.getComponent?.(this);
- // this.props.mountCanvas?.(this.getContentRef().current!);
}
/**
@@ -83,7 +69,7 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
* @param e
*/
handleSplitBarMouseMove = (e: MouseEvent) => {
- const layout = this.props.config.layout!;
+ const layout = this.props.config.layout?.sheetContainerConfig!;
e = e || window.event; // Compatible with IE browser
let diffLeft = e.clientX - this.leftContentLeft;
let diffTop = e.clientY - this.leftContentTop;
@@ -115,101 +101,6 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
return this.splitLeftRef;
}
- handleChangeSkin(e: Event) {
- const { changeSkin } = this.props;
- const target = e.target as HTMLSelectElement;
- const skin = target.value;
- this.setState(
- {
- currentSkin: skin,
- },
- () => {
- this.changeSkin(this.props.container!, skin);
- }
- );
- changeSkin();
- }
-
- /**
- * Modify Dom Skin
- */
- changeSkin(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-Z0-9])/g, '-$1').toLowerCase()}`, currentSkin[item]]));
- // ie11 does not support css variables, use css-vars-ponyfill to handle
- if (Tools.isIEBrowser()) {
- cssVars({
- // Options...
- // The container is invalid as rootElement, so the default setting is root.
- // Disadvantages: In ie11, only one set of skins can be used for multiple workbooks, and it is the skin set by the last workbook
- rootElement: root, // default
- variables: currentSkin,
- });
- } else {
- // set css variable
- let sheet = getSkinStyleSheet(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;
- }
- }
- }
- }
-
setLocale(e: Event) {
const { changeLocale } = this.props;
const target = e.target as HTMLSelectElement;
@@ -233,8 +124,8 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
render() {
const { methods } = this.props;
const { context, layout } = this.props.config;
- const { currentLocale, currentSkin } = this.state;
- const config = layout!;
+ const { currentLocale } = this.state;
+ const config = layout?.sheetContainerConfig!;
// Set Provider for entire Container
return (
<AppContext.Provider
@@ -247,8 +138,8 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
<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>}
+ {/* {config.infoBar && <InfoBar {...methods.infoBar}></InfoBar>}
+ {config.toolBar && <ToolBar {...methods.toolbar}></ToolBar>} */}
{/* {config.infoBar && <InfoBar></InfoBar>}
{config.formulaBar && <FormulaBar></FormulaBar>} */}
</Header>
@@ -269,14 +160,8 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
</Container>
)}
<Container ref={this.contentRef} className={style.contentInnerRightContainer}>
- {config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>}
+ {/* {config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>} */}
<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.handleChangeSkin.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.setLocale.bind(this)} style={{ width: 55 }}>
<option value="en">English</option>
@@ -299,8 +184,8 @@ export class UniverContainer extends Component<BaseSheetContainerProps, IState>
display: config.footer ? 'block' : 'none',
}}
>
- {config.sheetBar && <SheetBar {...methods.sheetBar}></SheetBar>}
- {config.countBar && <CountBar {...methods.countBar}></CountBar>}
+ {/* {config.sheetBar && <SheetBar {...methods.sheetBar}></SheetBar>} */}
+ {/* {config.countBar && <CountBar {...methods.countBar}></CountBar>} */}
</Footer>
</Layout>
<Sider
diff --git a/packages/ui-plugin-sheets/src/View/UniverContainer/index.module.less b/packages/ui-plugin-sheets/src/View/SheetContainer/index.module.less
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/UniverContainer/index.module.less
rename to packages/ui-plugin-sheets/src/View/SheetContainer/index.module.less
diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/index.ts b/packages/ui-plugin-sheets/src/View/SheetContainer/index.ts
new file mode 100644
index 0000000000..10af32f11d
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/index.ts
@@ -0,0 +1 @@
+export * from './SheetContainer';
diff --git a/packages/ui-plugin-sheets/src/View/UniverContainer/index.ts b/packages/ui-plugin-sheets/src/View/UniverContainer/index.ts
deleted file mode 100644
index 2d4a88ebe5..0000000000
--- a/packages/ui-plugin-sheets/src/View/UniverContainer/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './UniverContainer';
diff --git a/packages/ui-plugin-sheets/src/View/index.tsx b/packages/ui-plugin-sheets/src/View/index.tsx
index 144926d7fd..56c416cdba 100644
--- a/packages/ui-plugin-sheets/src/View/index.tsx
+++ b/packages/ui-plugin-sheets/src/View/index.tsx
@@ -1,6 +1,5 @@
-import { render } from '../Framework';
-import { isElement } from '../Utils';
-import { BaseSheetContainerProps, UniverContainer } from './UniverContainer';
+import { isElement, render } from '@univerjs/base-ui';
+import { BaseSheetContainerProps, SheetContainer } from './SheetContainer';
export class UI {
constructor(props: BaseSheetContainerProps) {
@@ -12,26 +11,28 @@ export class UI {
}
private _initialize(props: BaseSheetContainerProps) {
- let univerContainer: HTMLElement;
+ let sheetContainer: HTMLElement;
const container = props.config.container;
if (typeof container === 'string') {
const containerDOM = document.getElementById(container);
if (containerDOM == null) {
- univerContainer = document.createElement('div');
- univerContainer.id = container;
+ sheetContainer = document.createElement('div');
+ sheetContainer.id = container;
} else {
- univerContainer = containerDOM;
+ sheetContainer = containerDOM;
}
} else if (isElement(container)) {
- univerContainer = container!;
+ sheetContainer = container!;
} else {
- univerContainer = document.createElement('div');
- univerContainer.id = 'univer';
+ sheetContainer = document.createElement('div');
+ sheetContainer.id = 'univer';
}
- props.container = univerContainer;
+ props.container = sheetContainer;
- render(<UniverContainer {...props} />, univerContainer);
+ render(<SheetContainer {...props} />, sheetContainer);
}
}
+
+export * from './SheetContainer';