node-registries.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { FlowNodeRegistry } from '@flowgram.ai/fixed-layout-editor';
  2. import { nanoid } from 'nanoid';
  3. /**
  4. * 自定义节点注册
  5. */
  6. export const nodeRegistries: FlowNodeRegistry[] = [
  7. {
  8. /**
  9. * 自定义节点类型
  10. */
  11. type: 'condition',
  12. /**
  13. * 自定义节点扩展:
  14. * - loop: 扩展为循环节点
  15. * - start: 扩展为开始节点
  16. * - dynamicSplit: 扩展为分支节点
  17. * - end: 扩展为结束节点
  18. * - tryCatch: 扩展为 tryCatch 节点
  19. * - default: 扩展为普通节点 (默认)
  20. */
  21. extend: 'dynamicSplit',
  22. /**
  23. * 节点配置信息
  24. */
  25. meta: {
  26. // isStart: false, // 是否为开始节点
  27. // isNodeEnd: false, // 是否为结束节点,结束节点后边无法再添加节点
  28. // draggable: false, // 是否可拖拽,如开始节点和结束节点无法拖拽
  29. // selectable: false, // 触发器等开始节点不能被框选
  30. // deleteDisable: true, // 禁止删除
  31. // copyDisable: true, // 禁止copy
  32. // addDisable: true, // 禁止添加
  33. },
  34. onAdd() {
  35. return {
  36. id: `condition_${nanoid(5)}`,
  37. type: 'condition',
  38. data: {
  39. title: 'Condition',
  40. },
  41. blocks: [
  42. {
  43. id: nanoid(5),
  44. type: 'block',
  45. data: {
  46. title: 'If_0',
  47. },
  48. },
  49. {
  50. id: nanoid(5),
  51. type: 'block',
  52. data: {
  53. title: 'If_1',
  54. },
  55. },
  56. ],
  57. };
  58. },
  59. },
  60. {
  61. type: 'custom',
  62. meta: {},
  63. onAdd() {
  64. return {
  65. id: `custom_${nanoid(5)}`,
  66. type: 'custom',
  67. data: {
  68. title: 'Custom',
  69. content: 'this is custom content'
  70. }
  71. }
  72. }
  73. }
  74. ];