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.

chore: update API

Wenzhao Hu3e40f8ab8d18
diff --git a/README-zh.md b/README-zh.md
index a732cfbd61..469090a42c 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -50,6 +50,8 @@ Univer 的功能特性包括:
- 🧮 高性能的公式引擎,支持 Web Worker
- 🌍 国际化支持
+点击[这里](https://univer.work/guides/features)以了解 Univer 目前已经推出的功能。
+
## 例子
| 链接 | 预览 |
@@ -57,8 +59,6 @@ Univer 的功能特性包括:
| [多实例](https://univer.work/playground/?title=Multi%20Instance)<br>在同一个网页中运行多个 Univer 实例 | ![](./docs/img/multi-instances.png) |
| [Uniscript](https://univer.work/playground/?title=Uniscript)<br>使用 Uniscript 来自动化工作流 | ![](./docs/img/uniscript.png) |
-
-
## 使用
我们建议通过将 Univer 作为 npm 包使用,请参考文档上的[快速开始](https://univer.work/guides/quick-start/)小节。我们还准备了一个[在线 playground](https://univer.work/playground/),你无需在本地安装 Univer 就可以体验使用 Univer 开发。
diff --git a/packages/facade/src/apis/facade.ts b/packages/facade/src/apis/facade.ts
index 8162d49178..126138f49a 100644
--- a/packages/facade/src/apis/facade.ts
+++ b/packages/facade/src/apis/facade.ts
@@ -15,7 +15,7 @@
*/
import type { IWorkbookData } from '@univerjs/core';
-import { IUniverInstanceService } from '@univerjs/core';
+import { IUniverInstanceService, Univer } from '@univerjs/core';
import { Inject, Injector } from '@wendellhu/redi';
import { FWorkbook } from './sheet/f-workbook';
@@ -24,7 +24,8 @@ export class FUniver {
/**
* Create a FUniver instance, if the injector is not provided, it will create a new Univer instance.
*/
- static newInstance(injector: Injector): FUniver {
+ static newAPI(wrapped: Univer | Injector): FUniver {
+ const injector = wrapped instanceof Univer ? wrapped.__getInjector() : wrapped;
return injector.createInstance(FUniver);
}
diff --git a/packages/uniscript/src/services/script-execution.service.ts b/packages/uniscript/src/services/script-execution.service.ts
index 8eded3326a..e8f9dca6e0 100644
--- a/packages/uniscript/src/services/script-execution.service.ts
+++ b/packages/uniscript/src/services/script-execution.service.ts
@@ -32,12 +32,12 @@ export class UniscriptExecutionService extends Disposable {
async execute(code: string): Promise<boolean> {
this._logService.log('[UniscriptExecutionService]', 'executing Uniscript...');
- const facadeInstance = FUniver.newInstance(this._injector);
+ const apiInstance = FUniver.newAPI(this._injector);
// eslint-disable-next-line @typescript-eslint/no-implied-eval
const scriptFunction = new Function('Univer', `(() => {${code}})()`);
try {
- scriptFunction(facadeInstance);
+ scriptFunction(apiInstance);
return true;
} catch (e) {
this._logService.error(e);