flow-labels-mock-register.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import {
  6. type FlowNodeRegistry,
  7. FlowTransitionLabelEnum,
  8. } from '@flowgram.ai/document';
  9. import { FlowTextKey } from '../src/flow-renderer-registry';
  10. /**
  11. * 动态接入 mock register,测试 labels
  12. */
  13. export const FlowLabelsMockRegister: FlowNodeRegistry = {
  14. type: 'mock',
  15. getLabels(transition) {
  16. return [
  17. {
  18. type: FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
  19. offset: transition.transform.outputPoint,
  20. props: {
  21. side: 'left',
  22. }
  23. },
  24. {
  25. type: FlowTransitionLabelEnum.BRANCH_DRAGGING_LABEL,
  26. offset: transition.transform.outputPoint,
  27. },
  28. {
  29. type: FlowTransitionLabelEnum.COLLAPSE_LABEL,
  30. offset: transition.transform.outputPoint,
  31. },
  32. {
  33. type: FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL,
  34. offset: transition.transform.outputPoint,
  35. },
  36. {
  37. type: FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL,
  38. offset: transition.transform.outputPoint,
  39. props: {
  40. activateNode: {
  41. getData: () => ({ hovered: true }),
  42. isVertical: true,
  43. }
  44. }
  45. },
  46. {
  47. type: FlowTransitionLabelEnum.COLLAPSE_ADDER_LABEL,
  48. offset: transition.transform.outputPoint,
  49. props: {
  50. activateNode: {
  51. getData: () => ({ hovered: true }),
  52. isVertical: true,
  53. },
  54. }
  55. },
  56. {
  57. type: FlowTransitionLabelEnum.TEXT_LABEL,
  58. offset: transition.transform.outputPoint,
  59. },
  60. {
  61. type: FlowTransitionLabelEnum.TEXT_LABEL,
  62. renderKey: FlowTextKey.LOOP_WHILE_TEXT,
  63. offset: transition.transform.outputPoint,
  64. },
  65. {
  66. type: FlowTransitionLabelEnum.TEXT_LABEL,
  67. renderKey: FlowTextKey.CATCH_TEXT,
  68. props: {
  69. style: {
  70. width: 100
  71. }
  72. },
  73. rotate: '90deg',
  74. offset: transition.transform.outputPoint,
  75. },
  76. {
  77. type: FlowTransitionLabelEnum.CUSTOM_LABEL,
  78. offset: transition.transform.outputPoint,
  79. },
  80. {
  81. type: FlowTransitionLabelEnum.CUSTOM_LABEL,
  82. renderKey: FlowTextKey.LOOP_WHILE_TEXT,
  83. offset: transition.transform.outputPoint,
  84. },
  85. {
  86. type: 'unknown' as any,
  87. offset: transition.transform.outputPoint,
  88. },
  89. ];
  90. },
  91. };