@@ -14,6 +14,7 @@ import {
1414 IPublicTypeEngineOptions ,
1515 IPublicModelDocumentModel ,
1616 IPublicTypePluginMeta ,
17+ IPublicTypeDisposable ,
1718} from '@alilc/lowcode-types' ;
1819import {
1920 Designer ,
@@ -60,14 +61,26 @@ export * from './modules/skeleton-types';
6061export * from './modules/designer-types' ;
6162export * from './modules/lowcode-types' ;
6263
63- async function registryInnerPlugin ( designer : Designer , editor : Editor , plugins : Plugins ) {
64+ async function registryInnerPlugin ( designer : Designer , editor : Editor , plugins : Plugins ) : Promise < IPublicTypeDisposable > {
6465 // 注册一批内置插件
66+ const componentMetaParserPlugin = componentMetaParser ( designer ) ;
67+ const defaultPanelRegistryPlugin = defaultPanelRegistry ( editor ) ;
6568 await plugins . register ( OutlinePlugin , { } , { autoInit : true } ) ;
66- await plugins . register ( componentMetaParser ( designer ) ) ;
69+ await plugins . register ( componentMetaParserPlugin ) ;
6770 await plugins . register ( setterRegistry , { } ) ;
68- await plugins . register ( defaultPanelRegistry ( editor ) ) ;
71+ await plugins . register ( defaultPanelRegistryPlugin ) ;
6972 await plugins . register ( builtinHotkey ) ;
7073 await plugins . register ( registerDefaults , { } , { autoInit : true } ) ;
74+
75+ return ( ) => {
76+ plugins . delete ( OutlinePlugin . pluginName ) ;
77+ plugins . delete ( componentMetaParserPlugin . pluginName ) ;
78+ plugins . delete ( setterRegistry . pluginName ) ;
79+ plugins . delete ( defaultPanelRegistryPlugin . pluginName ) ;
80+ plugins . delete ( defaultPanelRegistryPlugin . pluginName ) ;
81+ plugins . delete ( builtinHotkey . pluginName ) ;
82+ plugins . delete ( registerDefaults . pluginName ) ;
83+ } ;
7184}
7285
7386const innerWorkspace = new InnerWorkspace ( registryInnerPlugin , shellModelFactory ) ;
@@ -158,7 +171,7 @@ let engineContainer: HTMLElement;
158171export const version = VERSION_PLACEHOLDER ;
159172engineConfig . set ( 'ENGINE_VERSION' , version ) ;
160173
161- registryInnerPlugin ( designer , editor , plugins ) ;
174+ const pluginPromise = registryInnerPlugin ( designer , editor , plugins ) ;
162175
163176export async function init (
164177 container ?: HTMLElement ,
@@ -183,10 +196,10 @@ export async function init(
183196 }
184197 engineConfig . setEngineOptions ( engineOptions as any ) ;
185198
186- await plugins . init ( pluginPreference as any ) ;
187-
188199 const { Workbench } = common . skeletonCabin ;
189200 if ( options && options . enableWorkspaceMode ) {
201+ const disposeFun = await pluginPromise ;
202+ disposeFun && disposeFun ( ) ;
190203 render (
191204 createElement ( WorkSpaceWorkbench , {
192205 workspace : innerWorkspace ,
@@ -202,6 +215,8 @@ export async function init(
202215 return ;
203216 }
204217
218+ await plugins . init ( pluginPreference as any ) ;
219+
205220 render (
206221 createElement ( Workbench , {
207222 skeleton : innerSkeleton ,
0 commit comments