Browse Source

fix(editor-client): postpone the sequence of custom service registration (#135)

Louis Young 9 months ago
parent
commit
5eda36286e

+ 2 - 0
packages/client/editor/src/index.ts

@@ -70,3 +70,5 @@ export * from './clients';
  */
 
 export * from '@flowgram.ai/node-variable-plugin';
+
+export { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';

+ 1 - 2
packages/client/editor/src/preset/editor-default-preset.ts

@@ -1,7 +1,6 @@
 import { interfaces } from 'inversify';
 import { FlowRendererContainerModule, FlowRendererRegistry } from '@flowgram.ai/renderer';
 import { createReduxDevToolPlugin } from '@flowgram.ai/redux-devtool-plugin';
-import { createPlaygroundReactPreset } from '@flowgram.ai/playground-react';
 import { createNodeVariablePlugin } from '@flowgram.ai/node-variable-plugin';
 import { createNodeCorePlugin } from '@flowgram.ai/node-core-plugin';
 import { createMaterialsPlugin } from '@flowgram.ai/materials-plugin';
@@ -121,6 +120,6 @@ export function createDefaultPreset<CTX extends EditorPluginContext = EditorPlug
       })
     );
 
-    return createPlaygroundReactPreset<CTX>(opts, plugins)(ctx);
+    return plugins;
   };
 }

+ 3 - 1
packages/client/fixed-layout-editor/src/preset/fixed-layout-preset.ts

@@ -19,6 +19,7 @@ import {
   FlowNodesTransformLayer,
   FlowScrollBarLayer,
   FlowScrollLimitLayer,
+  createPlaygroundReactPreset,
 } from '@flowgram.ai/editor';
 
 import { FlowOperationService } from '../types';
@@ -152,6 +153,7 @@ export function createFixedLayoutPreset(
         },
       })
     );
-    return plugins;
+
+    return createPlaygroundReactPreset(opts, plugins)(ctx);
   };
 }

+ 3 - 1
packages/client/free-layout-editor/src/preset/free-layout-preset.ts

@@ -29,6 +29,7 @@ import {
   FlowNodesTransformLayer,
   FlowScrollBarLayer,
   FlowScrollLimitLayer,
+  createPlaygroundReactPreset,
 } from '@flowgram.ai/editor';
 
 import { FreeLayoutProps, FreeLayoutPluginContext } from './free-layout-props';
@@ -240,6 +241,7 @@ export function createFreeLayoutPreset(
         ...(opts.selectBox || {}),
       })
     );
-    return plugins;
+
+    return createPlaygroundReactPreset(opts, plugins)(ctx);
   };
 }

+ 6 - 7
packages/client/playground-react/src/preset/playground-react-preset.ts

@@ -17,6 +17,12 @@ export function createPlaygroundReactPreset<CTX extends PluginContext = PluginCo
 ): PluginsProvider<CTX> {
   return (ctx: CTX) => {
     plugins = plugins.slice();
+    /**
+     * 注册背景 (放前面插入), 默认打开
+     */
+    if (opts.background || opts.background === undefined) {
+      plugins.push(createBackgroundPlugin(opts.background || {}));
+    }
     /**
      * 注册快捷键
      */
@@ -70,13 +76,6 @@ export function createPlaygroundReactPreset<CTX extends PluginContext = PluginCo
         containerModules: opts.containerModules || [],
       })
     );
-
-    /**
-     * 注册背景 (放最后插入), 默认打开
-     */
-    if (opts.background || opts.background === undefined) {
-      plugins.push(createBackgroundPlugin(opts.background || {}));
-    }
     return plugins;
   };
 }