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.

feat(base-sheets): 1. layout set toolBar false,do not init ToolBarController

dushusirfbe4bcd825c4
diff --git a/examples/univer-preact-ts/index.html b/examples/univer-preact-ts/index.html
index bdf0c57e03..89009a3eaf 100644
--- a/examples/univer-preact-ts/index.html
+++ b/examples/univer-preact-ts/index.html
@@ -16,7 +16,7 @@
<body>
<div id="app" style="z-index: 1; position: fixed; font-size: 20px; color: green;"></div>
- <div id="universheet-demo-up" style="height: 100%;"></div>
+ <div id="universheet-demo" style="height: 100%;"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
diff --git a/examples/univer-preact-ts/package.json b/examples/univer-preact-ts/package.json
index ed1692c333..d437abb7ab 100644
--- a/examples/univer-preact-ts/package.json
+++ b/examples/univer-preact-ts/package.json
@@ -44,13 +44,10 @@
"vite-plugin-external": "1.2.3"
},
"dependencies": {
- "univer-preact-ts": "^0.0.1",
"@univer/base-render": "workspace:^0.0.1",
"@univer/base-sheets": "^0.0.1",
"@univer/common-plugin-data": "workspace:^0.0.1",
"@univer/core": "^0.0.1",
- "@univer/sheets-plugin-alternating-colors": "^0.0.1",
- "@univer/sheets-plugin-filter": "^0.0.1",
"@univer/style-universheet": "^0.0.1",
"preact": "^10.5.14"
}
diff --git a/examples/univer-preact-ts/src/index.ts b/examples/univer-preact-ts/src/index.ts
index 42e121f0a5..2d013fdf32 100644
--- a/examples/univer-preact-ts/src/index.ts
+++ b/examples/univer-preact-ts/src/index.ts
@@ -1,12 +1,13 @@
-import { IStyleConfig } from '@univer/base-component';
import { IWorkbookConfig, UniverSheet } from '@univer/core';
-import { FilterPlugin } from '@univer/sheets-plugin-filter';
-import { SheetPlugin } from '@univer/base-sheets';
-import { StyleUniver } from '@univer/style-universheet';
+import * as UniverCore from '@univer/core'
+import { RenderEngine } from '@univer/base-render';
+import { UniverComponentSheet } from '@univer/style-universheet';
+import { ISheetPluginConfig, SheetPlugin } from '@univer/base-sheets';
+import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
interface IPropsCustom {
- workbookConfig?: Partial<IWorkbookConfig>;
- spreadsheetConfig?: IStyleConfig;
+ coreConfig?: Partial<IWorkbookConfig>;
+ baseSheetsConfig?: ISheetPluginConfig;
}
/**
@@ -15,13 +16,13 @@ interface IPropsCustom {
class UniverSheetCustom {
constructor() {}
init(config: IPropsCustom = {}): UniverSheet {
- const univerSheetUp = UniverSheet.newInstance(config.workbookConfig);
+ const universheet = UniverSheet.newInstance(config.coreConfig);
- univerSheetUp.installPlugin(new StyleUniver(config.spreadsheetConfig));
- univerSheetUp.installPlugin(new SheetPlugin());
- univerSheetUp.installPlugin(new FilterPlugin());
+ universheet.installPlugin(new RenderEngine());
+ universheet.installPlugin(new UniverComponentSheet());
+ universheet.installPlugin(new SheetPlugin(config.baseSheetsConfig));
- return univerSheetUp;
+ return universheet;
}
}
/**
@@ -32,4 +33,4 @@ class UniverSheetCustom {
const univerSheetCustom = function (config?: IPropsCustom) {
return new UniverSheetCustom().init(config);
};
-export { univerSheetCustom };
+export {UniverCore, univerSheetCustom, DEFAULT_WORKBOOK_DATA };
diff --git a/examples/univer-preact-ts/src/main.tsx b/examples/univer-preact-ts/src/main.tsx
index 04341c1bd2..9c7bcc946a 100644
--- a/examples/univer-preact-ts/src/main.tsx
+++ b/examples/univer-preact-ts/src/main.tsx
@@ -1,30 +1,38 @@
-import { univerSheetCustom } from '.';
+import { univerSheetCustom, DEFAULT_WORKBOOK_DATA } from '.';
-const workbookConfig = {
- id: '',
- sheetOrder: [],
- socketEnable: BooleanNumber.FALSE,
- socketUrl: '',
- name: '',
- timeZone: '',
- appVersion: '',
- theme: '',
- skin: '',
- locale: '',
- creator: '',
- styles: [],
- sheets: [],
- lastModifiedBy: '',
- createdTime: '',
- modifiedTime: '',
+const sheetConfig = {
+ container: 'universheet-demo',
+ layout: {
+ innerRight: false,
+ outerLeft: false,
+ toolBarConfig: {
+ paintFormat: false,
+ currencyFormat: false,
+ percentageFormat: false,
+ numberDecrease: false,
+ numberIncrease: false,
+ moreFormats: false,
+ },
+ },
+ selections: {
+ 'sheet-01': [
+ {
+ selection: {
+ startRow: 0,
+ endRow: 0,
+ startColumn: 3,
+ endColumn: 3,
+ },
+ cell: {
+ row: 0,
+ column: 3,
+ },
+ },
+ ],
+ },
};
-const spreadsheetConfig = {
- container: 'universheet-demo-up',
- layout: 'auto',
-};
-
-const universheet = univerSheetCustom({
- workbookConfig: workbookConfig,
- spreadsheetConfig: spreadsheetConfig,
-});
+univerSheetCustom({
+ coreConfig: DEFAULT_WORKBOOK_DATA,
+ baseSheetsConfig: sheetConfig,
+});
\ No newline at end of file
diff --git a/examples/univer-preact-ts/vite.config.ts b/examples/univer-preact-ts/vite.config.ts
index 91ae307a59..164a5360bf 100644
--- a/examples/univer-preact-ts/vite.config.ts
+++ b/examples/univer-preact-ts/vite.config.ts
@@ -11,9 +11,9 @@ export default defineConfig({
build: {
lib: {
entry: resolve('src/index.ts'),
- name: 'UniverSheetCustomBuild',
- formats: ['es', 'umd'],
- fileName: 'univer-custom-build',
+ name: 'UniverPreactTs',
+ formats: ['es', 'cjs', 'umd', 'iife'],
+ fileName: 'univer-preact-ts',
},
outDir: './lib',
},
@@ -46,7 +46,7 @@ export default defineConfig({
// '@univer/core': '@univer/core',
// '@univer/style-universheet': '@univer/style-universheet',
// preact: 'preact',
- react: 'react',
+ // react: 'react',
},
}),
],
diff --git a/packages/base-sheets/src/Basics/Const/DEFAULT_SPREADSHEET_PLUGIN_DATA.ts b/packages/base-sheets/src/Basics/Const/DEFAULT_SPREADSHEET_PLUGIN_DATA.ts
index e914fd7ebb..c23f6647b9 100644
--- a/packages/base-sheets/src/Basics/Const/DEFAULT_SPREADSHEET_PLUGIN_DATA.ts
+++ b/packages/base-sheets/src/Basics/Const/DEFAULT_SPREADSHEET_PLUGIN_DATA.ts
@@ -1,8 +1,9 @@
+import { defaultLayout } from '../../View/UI/SheetContainer';
import { ISheetPluginConfig } from '../Interfaces/SpreadsheetConfig';
export const DEFAULT_SPREADSHEET_PLUGIN_DATA: ISheetPluginConfig = {
container: 'universheet',
- layout: 'auto',
+ layout: defaultLayout,
selections: {
'sheet-01': [
{
diff --git a/packages/base-sheets/src/SheetPlugin.tsx b/packages/base-sheets/src/SheetPlugin.tsx
index 992cafcff7..9be3330aa3 100644
--- a/packages/base-sheets/src/SheetPlugin.tsx
+++ b/packages/base-sheets/src/SheetPlugin.tsx
@@ -7,7 +7,7 @@ import { RightMenuProps } from './Model/RightMenuModel';
import { en, zh } from './Locale';
import { CANVAS_VIEW_KEY } from './View/Render/BaseView';
import { CanvasView } from './View/Render/CanvasView';
-import { BaseSheetContainerConfig, SheetContainer } from './View/UI/SheetContainer';
+import { BaseSheetContainerConfig, ILayout, SheetContainer } from './View/UI/SheetContainer';
import {
RightMenuController,
InfoBarController,
@@ -81,7 +81,7 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {
constructor(config: Partial<ISheetPluginConfig> = {}) {
super(PLUGIN_NAMES.SPREADSHEET);
- this._config = Tools.commonExtend(DEFAULT_SPREADSHEET_PLUGIN_DATA, config);
+ this._config = Tools.deepMerge(DEFAULT_SPREADSHEET_PLUGIN_DATA, config);
}
register(engineInstance: Engine) {
@@ -146,16 +146,29 @@ export class SheetPlugin extends Plugin<SheetPluginObserve, SheetContext> {
this._componentList = new Map();
+ const layout = this._config.layout as ILayout
+
this._sheetContainerController = new SheetContainerController(this);
this._modalGroupController = new ModalGroupController(this);
+ // TODO rightMenu config
this._rightMenuControl = new RightMenuController(this);
- this._toolBarControl = new ToolBarController(this);
- this._infoBarControl = new InfoBarController(this);
- this._sheetBarControl = new SheetBarControl(this);
+
+ if(layout === 'auto' || layout.toolBar){
+ this._toolBarControl = new ToolBarController(this);
+ }
+ if(layout === 'auto' || layout.infoBar){
+ this._infoBarControl = new InfoBarController(this);
+ }
+ if(layout === 'auto' || layout.sheetBar){
+ this._sheetBarControl = new SheetBarControl(this);
+ }
this._cellEditorControl = new CellEditorController(this);
this._antLineController = new AntLineControl(this);
- this._countBarController = new CountBarController(this);
+
+ if(layout === 'auto' || layout.countBar){
+ this._countBarController = new CountBarController(this);
+ }
// this._sheetContainerController = new SheetContainerController(this);
// render sheet container
diff --git a/packages/base-sheets/src/View/Render/Views/SceneViewerTestView.ts b/packages/base-sheets/src/View/Render/Views/SceneViewerTestView.ts
index 703a5d28cc..e5a9d94fb7 100644
--- a/packages/base-sheets/src/View/Render/Views/SceneViewerTestView.ts
+++ b/packages/base-sheets/src/View/Render/Views/SceneViewerTestView.ts
@@ -101,4 +101,4 @@ export class SceneViewerTestViewFactory {
return new SceneViewerTestView().initialize(scene, plugin);
}
}
-CanvasViewRegistry.add(new SceneViewerTestViewFactory());
+// CanvasViewRegistry.add(new SceneViewerTestViewFactory());
diff --git a/packages/base-sheets/src/View/Render/Views/TestView.ts b/packages/base-sheets/src/View/Render/Views/TestView.ts
index 8d9f7c519c..05baa1993f 100644
--- a/packages/base-sheets/src/View/Render/Views/TestView.ts
+++ b/packages/base-sheets/src/View/Render/Views/TestView.ts
@@ -92,4 +92,4 @@ export class TestViewFactory {
return new TestView().initialize(scene, plugin);
}
}
-CanvasViewRegistry.add(new TestViewFactory());
+// CanvasViewRegistry.add(new TestViewFactory());
diff --git a/packages/base-sheets/src/main.tsx b/packages/base-sheets/src/main.tsx
index d0de142235..0a2801f26c 100644
--- a/packages/base-sheets/src/main.tsx
+++ b/packages/base-sheets/src/main.tsx
@@ -105,6 +105,7 @@ univerSheetUp.installPlugin(new NumfmtPlugin());
const uiDefaultConfigDown = {
container: 'universheet-demo-down',
+ layout:'auto',
selections: {
'sheet-0001': [
{