create-container.ts 964 B

1234567891011121314151617181920212223242526272829
  1. import { FormModel } from '@flowgram.ai/form';
  2. import { FlowDocumentContainerModule } from '@flowgram.ai/document';
  3. import { loadPlugins, Playground, PlaygroundMockTools } from '@flowgram.ai/core';
  4. import { createHistoryPlugin, HistoryService } from '@flowgram.ai/history';
  5. import { attachFormValuesChange } from '../src/utils';
  6. import { createHistoryNodePlugin } from '../src';
  7. export const createContainer = () => {
  8. const container = PlaygroundMockTools.createContainer([FlowDocumentContainerModule]);
  9. const formModel = new FormModel();
  10. const playground = container.get(Playground);
  11. loadPlugins([createHistoryPlugin({ enable: true }), createHistoryNodePlugin({})], container);
  12. playground.init();
  13. const historyService = container.get(HistoryService);
  14. historyService.context.source = container;
  15. attachFormValuesChange(formModel as any, { id: 1 } as any, historyService);
  16. return {
  17. formModel,
  18. container,
  19. historyService,
  20. };
  21. };