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(build): build for universlide

dushusirff406976792e
diff --git a/examples/univer-preact-ts/package.json b/examples/univer-preact-ts/package.json
index d437abb7ab..4a409a5cec 100644
--- a/examples/univer-preact-ts/package.json
+++ b/examples/univer-preact-ts/package.json
@@ -46,6 +46,8 @@
"dependencies": {
"@univer/base-render": "workspace:^0.0.1",
"@univer/base-sheets": "^0.0.1",
+ "@univer/base-docs": "^0.0.1",
+ "@univer/base-slides": "^0.0.1",
"@univer/common-plugin-data": "workspace:^0.0.1",
"@univer/core": "^0.0.1",
"@univer/style-universheet": "^0.0.1",
diff --git a/examples/univer-preact-ts/src/index.ts b/examples/univer-preact-ts/src/index.ts
index 2d013fdf32..b826f399a5 100644
--- a/examples/univer-preact-ts/src/index.ts
+++ b/examples/univer-preact-ts/src/index.ts
@@ -1,11 +1,13 @@
-import { IWorkbookConfig, UniverSheet } from '@univer/core';
+import { IDocumentData, ISlideData, IWorkbookConfig, UniverDoc, UniverSheet, UniverSlide } from '@univer/core';
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 { IDocPluginConfig, DocPlugin } from '@univer/base-docs';
+import { ISlidePluginConfig, SlidePlugin } from '@univer/base-slides';
import { DEFAULT_WORKBOOK_DATA } from '@univer/common-plugin-data';
-interface IPropsCustom {
+interface ISheetPropsCustom {
coreConfig?: Partial<IWorkbookConfig>;
baseSheetsConfig?: ISheetPluginConfig;
}
@@ -15,7 +17,7 @@ interface IPropsCustom {
*/
class UniverSheetCustom {
constructor() {}
- init(config: IPropsCustom = {}): UniverSheet {
+ init(config: ISheetPropsCustom = {}): UniverSheet {
const universheet = UniverSheet.newInstance(config.coreConfig);
universheet.installPlugin(new RenderEngine());
@@ -30,7 +32,66 @@ class UniverSheetCustom {
* @param config
* @returns
*/
-const univerSheetCustom = function (config?: IPropsCustom) {
+const univerSheetCustom = function (config?: ISheetPropsCustom) {
return new UniverSheetCustom().init(config);
};
-export {UniverCore, univerSheetCustom, DEFAULT_WORKBOOK_DATA };
+
+interface IDocPropsCustom {
+ coreConfig?: Partial<IDocumentData>;
+ baseDocsConfig?: IDocPluginConfig;
+}
+
+/**
+ * Initialize the core and all plugins
+ */
+class UniverDocCustom {
+ constructor() {}
+ init(config: IDocPropsCustom = {}): UniverDoc {
+ const univerdoc = UniverDoc.newInstance(config.coreConfig);
+
+ univerdoc.installPlugin(new RenderEngine());
+ univerdoc.installPlugin(new UniverComponentSheet());
+ univerdoc.installPlugin(new DocPlugin(config.baseDocsConfig));
+
+ return univerdoc;
+ }
+}
+/**
+ * Wrapped into a function,easy to use
+ * @param config
+ * @returns
+ */
+const univerDocCustom = function (config?: IDocPropsCustom) {
+ return new UniverDocCustom().init(config);
+};
+
+interface ISlidePropsCustom {
+ coreConfig?: Partial<ISlideData>;
+ baseSlidesConfig?: ISlidePluginConfig;
+}
+
+/**
+ * Initialize the core and all plugins
+ */
+class UniverSlideCustom {
+ constructor() {}
+ init(config: ISlidePropsCustom = {}): UniverSlide {
+ const universlide = UniverSlide.newInstance(config.coreConfig);
+
+ universlide.installPlugin(new RenderEngine());
+ universlide.installPlugin(new UniverComponentSheet());
+ universlide.installPlugin(new SlidePlugin(config.baseSlidesConfig));
+
+ return universlide;
+ }
+}
+/**
+ * Wrapped into a function,easy to use
+ * @param config
+ * @returns
+ */
+const univerSlideCustom = function (config?: ISlidePropsCustom) {
+ return new UniverSlideCustom().init(config);
+};
+
+export {UniverCore, univerSheetCustom,univerDocCustom,univerSlideCustom, DEFAULT_WORKBOOK_DATA };
diff --git a/packages/base-docs/src/View/Render/CanvasView.ts b/packages/base-docs/src/View/Render/CanvasView.ts
index eb80724b35..d48ccd82aa 100644
--- a/packages/base-docs/src/View/Render/CanvasView.ts
+++ b/packages/base-docs/src/View/Render/CanvasView.ts
@@ -65,7 +65,10 @@ export class CanvasView {
engine.runRenderLoop(() => {
scene.render();
- document.getElementById('app')!.innerText = `fps:${Math.round(engine.getFps()).toString()}`;
+ const app = document.getElementById('app');
+ if(app){
+ app.innerText = `fps:${Math.round(engine.getFps()).toString()}`;
+ }
});
}
diff --git a/packages/base-sheets/src/Controller/FormulaBarController.ts b/packages/base-sheets/src/Controller/FormulaBarController.ts
index bf0545619f..6a15165938 100644
--- a/packages/base-sheets/src/Controller/FormulaBarController.ts
+++ b/packages/base-sheets/src/Controller/FormulaBarController.ts
@@ -24,9 +24,9 @@ export class FormulaBarController {
manager.requiredObserver<FormulaBar>('onFormulaBarDidMountObservable', PLUGIN_NAMES.SPREADSHEET).add((component) => {
this._formulaBar = component;
});
- debugger
+
this._plugin.getObserver('onChangeSelectionObserver')?.add((selectionControl: SelectionControl) => {
- debugger
+
const currentCell = selectionControl.model.currentCell;
if (currentCell) {