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(facade): add component api (#4125)

zhangwe0025ab11b4a
diff --git a/packages/ui/src/common/component-manager.ts b/packages/ui/src/common/component-manager.ts
index 9f11c43a4c..9e60165268 100644
--- a/packages/ui/src/common/component-manager.ts
+++ b/packages/ui/src/common/component-manager.ts
@@ -128,7 +128,7 @@ import { cloneElement, createElement, useEffect, useRef } from 'react';
type ComponentFramework = 'vue3' | 'react';
-interface IComponentOptions {
+export interface IComponentOptions {
framework?: ComponentFramework;
}
diff --git a/packages/ui/src/facade/f-univer.ts b/packages/ui/src/facade/f-univer.ts
index 82c3c1edbd..cc4a3b26d2 100644
--- a/packages/ui/src/facade/f-univer.ts
+++ b/packages/ui/src/facade/f-univer.ts
@@ -17,7 +17,7 @@
import type { IDisposable } from '@univerjs/core';
import type { IDialogPartMethodOptions, ISidebarMethodOptions } from '@univerjs/ui';
import { FUniver } from '@univerjs/core';
-import { CopyCommand, IDialogService, ISidebarService, PasteCommand } from '@univerjs/ui';
+import { ComponentManager, CopyCommand, IDialogService, ISidebarService, PasteCommand } from '@univerjs/ui';
interface IFUniverUIMixin {
copy(): Promise<boolean>;
@@ -37,6 +37,12 @@ interface IFUniverUIMixin {
* @returns the disposable object
*/
openDialog(dialog: IDialogPartMethodOptions): IDisposable;
+
+ /**
+ * Get the component manager
+ * @returns The component manager
+ */
+ getComponentManager(): ComponentManager;
}
class FUniverUIMixin extends FUniver implements IFUniverUIMixin {
@@ -63,6 +69,10 @@ class FUniverUIMixin extends FUniver implements IFUniverUIMixin {
});
return disposable;
}
+
+ override getComponentManager(): ComponentManager {
+ return this._injector.get(ComponentManager);
+ }
}
FUniver.extend(FUniverUIMixin);