create-panel-manager-plugin.ts 710 B

123456789101112131415161718192021
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import { definePluginCreator } from '@flowgram.ai/core';
  6. import { defineConfig } from './services/panel-config';
  7. import { PanelManager, PanelManagerConfig, PanelLayer } from './services';
  8. export const createPanelManagerPlugin = definePluginCreator<Partial<PanelManagerConfig>>({
  9. onBind: ({ bind }, opt) => {
  10. bind(PanelManager).to(PanelManager).inSingletonScope();
  11. bind(PanelManagerConfig).toConstantValue(defineConfig(opt));
  12. },
  13. onInit(ctx) {
  14. ctx.playground.registerLayer(PanelLayer);
  15. const panelManager = ctx.container.get<PanelManager>(PanelManager);
  16. panelManager.init();
  17. },
  18. });