node-registries.tsx 1.9 KB

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