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 custom

dushusir2f73e6b4fda3
diff --git a/cli/src/templates/base/src/index.ts b/cli/src/templates/base/src/index.ts
index 245449c0b4..e0eaae3c5a 100644
--- a/cli/src/templates/base/src/index.ts
+++ b/cli/src/templates/base/src/index.ts
@@ -1,3 +1,2 @@
-import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';
+export * from './<%= projectUpperValue %>Plugin';
-export { <%= projectUpperValue %>Plugin };
diff --git a/cli/src/templates/common-plugin/src/index.ts b/cli/src/templates/common-plugin/src/index.ts
index 245449c0b4..7b959cf8c0 100644
--- a/cli/src/templates/common-plugin/src/index.ts
+++ b/cli/src/templates/common-plugin/src/index.ts
@@ -1,3 +1 @@
-import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';
-
-export { <%= projectUpperValue %>Plugin };
+export * from './<%= projectUpperValue %>Plugin';
\ No newline at end of file
diff --git a/cli/src/templates/docs-plugin/src/index.ts b/cli/src/templates/docs-plugin/src/index.ts
index 245449c0b4..7b959cf8c0 100644
--- a/cli/src/templates/docs-plugin/src/index.ts
+++ b/cli/src/templates/docs-plugin/src/index.ts
@@ -1,3 +1 @@
-import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';
-
-export { <%= projectUpperValue %>Plugin };
+export * from './<%= projectUpperValue %>Plugin';
\ No newline at end of file
diff --git a/cli/src/templates/sheets-plugin/src/index.ts b/cli/src/templates/sheets-plugin/src/index.ts
index 245449c0b4..7b959cf8c0 100644
--- a/cli/src/templates/sheets-plugin/src/index.ts
+++ b/cli/src/templates/sheets-plugin/src/index.ts
@@ -1,3 +1 @@
-import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';
-
-export { <%= projectUpperValue %>Plugin };
+export * from './<%= projectUpperValue %>Plugin';
\ No newline at end of file
diff --git a/cli/src/templates/slides-plugin/src/index.ts b/cli/src/templates/slides-plugin/src/index.ts
index 245449c0b4..c0766d34b3 100644
--- a/cli/src/templates/slides-plugin/src/index.ts
+++ b/cli/src/templates/slides-plugin/src/index.ts
@@ -1,3 +1 @@
-import { <%= projectUpperValue %>Plugin } from './<%= projectUpperValue %>Plugin';
-
-export { <%= projectUpperValue %>Plugin };
+export * from './<%= projectUpperValue %>Plugin';
diff --git a/examples/univer-preact-ts/package.json b/examples/univer-preact-ts/package.json
index 4a409a5cec..aa7d432cac 100644
--- a/examples/univer-preact-ts/package.json
+++ b/examples/univer-preact-ts/package.json
@@ -44,13 +44,18 @@
"vite-plugin-external": "1.2.3"
},
"dependencies": {
+ "@univer/base-docs": "workspace:^0.0.1",
"@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/base-sheets": "workspace:^0.0.1",
+ "@univer/base-slides": "workspace:^0.0.1",
"@univer/common-plugin-data": "workspace:^0.0.1",
- "@univer/core": "^0.0.1",
- "@univer/style-universheet": "^0.0.1",
+ "@univer/common-plugin-register": "workspace:^0.0.1",
+ "@univer/core": "workspace:^0.0.1",
+ "@univer/sheets-plugin-clipboard": "workspace:^0.0.1",
+ "@univer/sheets-plugin-clipboard-office": "workspace:^0.0.1",
+ "@univer/sheets-plugin-formula": "workspace:^0.0.1",
+ "@univer/sheets-plugin-numfmt": "workspace:^0.0.1",
+ "@univer/style-universheet": "workspace:^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 b826f399a5..24d52e0094 100644
--- a/examples/univer-preact-ts/src/index.ts
+++ b/examples/univer-preact-ts/src/index.ts
@@ -6,10 +6,17 @@ 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';
+import { DEFAULT_FORMULA_DATA, FormulaPlugin, IFormulaConfig } from '@univer/sheets-plugin-formula';
+import { INumfmtPluginConfig, NumfmtPlugin } from '@univer/sheets-plugin-numfmt';
+import { RegisterPlugin } from '@univer/common-plugin-register';
+import { ClipboardPlugin } from '@univer/sheets-plugin-clipboard';
+import { ClipboardOfficePlugin } from '@univer/sheets-plugin-clipboard-office';
interface ISheetPropsCustom {
coreConfig?: Partial<IWorkbookConfig>;
baseSheetsConfig?: ISheetPluginConfig;
+ numfmtConfig?:INumfmtPluginConfig;
+ formulaConfig?: IFormulaConfig;
}
/**
@@ -23,6 +30,12 @@ class UniverSheetCustom {
universheet.installPlugin(new RenderEngine());
universheet.installPlugin(new UniverComponentSheet());
universheet.installPlugin(new SheetPlugin(config.baseSheetsConfig));
+ universheet.installPlugin(new NumfmtPlugin(config.numfmtConfig));
+ FormulaPlugin.create(config.formulaConfig).installTo(universheet);
+
+ universheet.installPlugin(new RegisterPlugin());
+ universheet.installPlugin(new ClipboardPlugin());
+ universheet.installPlugin(new ClipboardOfficePlugin());
return universheet;
}
@@ -94,4 +107,4 @@ const univerSlideCustom = function (config?: ISlidePropsCustom) {
return new UniverSlideCustom().init(config);
};
-export {UniverCore, univerSheetCustom,univerDocCustom,univerSlideCustom, DEFAULT_WORKBOOK_DATA };
+export {UniverCore, univerSheetCustom,univerDocCustom,univerSlideCustom, DEFAULT_WORKBOOK_DATA, DEFAULT_FORMULA_DATA };
diff --git a/examples/univer-vanilla-ts/src/main.tsx b/examples/univer-vanilla-ts/src/main.tsx
index 9bcfe2f37e..83f5626bad 100644
--- a/examples/univer-vanilla-ts/src/main.tsx
+++ b/examples/univer-vanilla-ts/src/main.tsx
@@ -60,28 +60,16 @@ univerSheetUp.installPlugin(new RegisterPlugin());
univerSheetUp.installPlugin(new ClipboardPlugin());
univerSheetUp.installPlugin(new ClipboardOfficePlugin());
-const uiDefaultConfigDown = {
- container: 'universheet-demo-down',
- selections: {
- 'sheet-0001': [
- {
- selection: {
- startRow: 2,
- endRow: 2,
- startColumn: 3,
- endColumn: 3,
- },
- cell: {
- row: 2,
- column: 3,
- },
- },
- ],
- },
-};
-const univerSheetDown = UniverSheet.newInstance(DEFAULT_WORKBOOK_DATA_DOWN);
+
+const univerSheetDown = UniverSheet.newInstance();
univerSheetDown.installPlugin(new RenderEngine());
univerSheetDown.installPlugin(new UniverComponentSheet());
-univerSheetDown.installPlugin(new SheetPlugin(uiDefaultConfigDown));
+univerSheetDown.installPlugin(new SheetPlugin());
+univerSheetDown.installPlugin(new NumfmtPlugin());
+FormulaPlugin.create().installTo(univerSheetDown);
+
+univerSheetDown.installPlugin(new RegisterPlugin());
+univerSheetDown.installPlugin(new ClipboardPlugin());
+univerSheetDown.installPlugin(new ClipboardOfficePlugin());
diff --git a/packages/base-docs/src/index.ts b/packages/base-docs/src/index.ts
index b092aeeb92..7ace7013bc 100644
--- a/packages/base-docs/src/index.ts
+++ b/packages/base-docs/src/index.ts
@@ -1,3 +1 @@
-import { DocPlugin } from './DocPlugin';
-
-export { DocPlugin };
+export * from './DocPlugin';
diff --git a/packages/base-slides/src/index.ts b/packages/base-slides/src/index.ts
index 906fcfff62..d177a18908 100644
--- a/packages/base-slides/src/index.ts
+++ b/packages/base-slides/src/index.ts
@@ -1,3 +1 @@
-import { SlidePlugin } from './SlidePlugin';
-
-export { SlidePlugin };
+export * from './SlidePlugin';
diff --git a/packages/common-plugin-register/package.json b/packages/common-plugin-register/package.json
index 9885333230..449a122800 100644
--- a/packages/common-plugin-register/package.json
+++ b/packages/common-plugin-register/package.json
@@ -50,6 +50,7 @@
"vite": "^2.4.4"
},
"dependencies": {
- "@univer/core": "workspace:^0.0.1"
+ "@univer/core": "workspace:^0.0.1",
+ "preact": "^10.5.14"
}
}
diff --git a/packages/common-plugin-register/src/index.ts b/packages/common-plugin-register/src/index.ts
index 099c04bc67..370b473a81 100644
--- a/packages/common-plugin-register/src/index.ts
+++ b/packages/common-plugin-register/src/index.ts
@@ -1,4 +1,3 @@
export * from './Basic';
-import { RegisterPlugin } from './RegisterPlugin';
+export * from './RegisterPlugin';
-export { RegisterPlugin };
diff --git a/packages/core/src/Basics/SheetContext.ts b/packages/core/src/Basics/SheetContext.ts
index 4a6737da9e..71ac3f5128 100644
--- a/packages/core/src/Basics/SheetContext.ts
+++ b/packages/core/src/Basics/SheetContext.ts
@@ -15,8 +15,8 @@ export class SheetContext extends ContextBase {
constructor(univerSheetData: Partial<IWorkbookConfig> = {}) {
super();
this._locale.initialize(univerSheetData.locale);
- this._workbook = new Workbook(univerSheetData, this);
this._setObserver();
+ this._workbook = new Workbook(univerSheetData, this);
}
protected _setObserver(): void {
diff --git a/packages/core/src/Sheets/Domain/Workbook.ts b/packages/core/src/Sheets/Domain/Workbook.ts
index 7f8544cf6a..30c0c080b1 100644
--- a/packages/core/src/Sheets/Domain/Workbook.ts
+++ b/packages/core/src/Sheets/Domain/Workbook.ts
@@ -88,7 +88,7 @@ export class Workbook {
// One worksheet by default
if (Tools.isEmptyObject(sheets)) {
- sheets[DEFAULT_WORKSHEET.id] = DEFAULT_WORKSHEET;
+ sheets[DEFAULT_WORKSHEET.id] = Object.assign(DEFAULT_WORKSHEET,{status: BooleanNumber.TRUE});
}
let firstWorksheet = null;
diff --git a/packages/sheets-plugin-clipboard-office/package.json b/packages/sheets-plugin-clipboard-office/package.json
index ba1fee8c9a..cfa5f02cd3 100644
--- a/packages/sheets-plugin-clipboard-office/package.json
+++ b/packages/sheets-plugin-clipboard-office/package.json
@@ -51,6 +51,7 @@
},
"dependencies": {
"@univer/common-plugin-register": "workspace:^0.0.1",
- "@univer/core": "workspace:^0.0.1"
+ "@univer/core": "workspace:^0.0.1",
+ "preact": "^10.5.14"
}
}
diff --git a/packages/sheets-plugin-clipboard-office/src/index.ts b/packages/sheets-plugin-clipboard-office/src/index.ts
index 24191dc326..13900e4d96 100644
--- a/packages/sheets-plugin-clipboard-office/src/index.ts
+++ b/packages/sheets-plugin-clipboard-office/src/index.ts
@@ -1,3 +1 @@
-import { ClipboardOfficePlugin } from './ClipboardOfficePlugin';
-
-export { ClipboardOfficePlugin };
+export * from './ClipboardOfficePlugin';
diff --git a/packages/sheets-plugin-clipboard/src/index.ts b/packages/sheets-plugin-clipboard/src/index.ts
index 295361ea3a..394bfa5251 100644
--- a/packages/sheets-plugin-clipboard/src/index.ts
+++ b/packages/sheets-plugin-clipboard/src/index.ts
@@ -1,3 +1,2 @@
-import { ClipboardPlugin } from './ClipboardPlugin';
+export * from './ClipboardPlugin';
-export { ClipboardPlugin };
diff --git a/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.ts b/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.ts
index 4d111c2269..1fec4a8cef 100644
--- a/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.ts
+++ b/packages/sheets-plugin-formula/src/Basic/Register/FormulaActionExtension.ts
@@ -30,6 +30,8 @@ export class FormulaActionExtension extends BaseActionExtension<ISetRangeDataAct
const workBook = this._plugin.getContext().getWorkBook();
let cellValue = this.actionData.cellValue;
+ if(Tools.isEmptyObject(formulaData)) return
+
const cellData = new ObjectMatrix(formulaData[unitId][sheetId]);
// a range TODO api will trigger here
diff --git a/packages/sheets-plugin-formula/src/Basic/index.ts b/packages/sheets-plugin-formula/src/Basic/index.ts
index 80af640480..cf54b84a75 100644
--- a/packages/sheets-plugin-formula/src/Basic/index.ts
+++ b/packages/sheets-plugin-formula/src/Basic/index.ts
@@ -1,2 +1,3 @@
export * from './Cache';
export * from './Const';
+export * from './Interfaces'
diff --git a/packages/sheets-plugin-formula/src/index.ts b/packages/sheets-plugin-formula/src/index.ts
index c8d3bd820a..49eafa08d3 100644
--- a/packages/sheets-plugin-formula/src/index.ts
+++ b/packages/sheets-plugin-formula/src/index.ts
@@ -2,5 +2,4 @@
import './Model/RegisterAction';
export * from './FormulaPlugin';
-export * from './Basic/Const/DEFAULT_FORMULA_DATA';
-export * from './Basic/Const/PLUGIN_NAME';
+export * from './Basic'
diff --git a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts
index 20d95c0ba3..93ee72eb36 100644
--- a/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts
+++ b/packages/sheets-plugin-numfmt/src/NumfmtPlugin.ts
@@ -6,6 +6,8 @@ import { NumfmtModalController } from './Controller/NumfmtModalController';
import { en, zh } from './Locale';
import { NumfmtActionExtensionFactory } from './Basic/Register/NumfmtActionExtension';
+export interface INumfmtPluginConfig {}
+
export class NumfmtPlugin extends Plugin<NumfmtPluginObserve, SheetContext> {
protected _controller: NumfmtController;
@@ -13,10 +15,14 @@ export class NumfmtPlugin extends Plugin<NumfmtPluginObserve, SheetContext> {
protected _numfmtActionExtensionFactory: NumfmtActionExtensionFactory;
- constructor() {
+ constructor(config?: INumfmtPluginConfig) {
super(NUMFMT_PLUGIN_NAME);
}
+ static create(config?: INumfmtPluginConfig) {
+ return new NumfmtPlugin(config);
+ }
+
onMounted(context: SheetContext): void {
install(this);