flow-document-options.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import {
  6. type FlowNodeJSON,
  7. DefaultSpacingKey,
  8. FlowTransitionLine,
  9. FlowTransitionLabel,
  10. FlowNodeRegistry,
  11. FlowNodeType,
  12. } from './typings';
  13. import { FlowNodeEntity } from './entities';
  14. export const FlowDocumentOptions = Symbol('FlowDocumentOptions');
  15. /**
  16. * 流程画布配置
  17. */
  18. export interface FlowDocumentOptions {
  19. /**
  20. * 布局,默认 垂直布局
  21. */
  22. defaultLayout?: string;
  23. /**
  24. * 所有节点的默认展开状态
  25. */
  26. allNodesDefaultExpanded?: boolean;
  27. toNodeJSON?(node: FlowNodeEntity): FlowNodeJSON;
  28. fromNodeJSON?(node: FlowNodeEntity, json: FlowNodeJSON, isFirstCreate: boolean): void;
  29. constants?: Record<string, any>;
  30. formatNodeLines?: (node: FlowNodeEntity, lines: FlowTransitionLine[]) => FlowTransitionLine[];
  31. formatNodeLabels?: (node: FlowNodeEntity, lines: FlowTransitionLabel[]) => FlowTransitionLabel[];
  32. preNodeCreate?: (node: FlowNodeEntity) => void;
  33. /**
  34. * 获取默认的节点配置
  35. */
  36. getNodeDefaultRegistry?: (type: FlowNodeType) => FlowNodeRegistry;
  37. }
  38. export const FlowDocumentOptionsDefault: FlowDocumentOptions = {
  39. allNodesDefaultExpanded: false,
  40. };
  41. /**
  42. * 支持外部 constants 自定义的 key 枚举
  43. */
  44. export const ConstantKeys = {
  45. ...DefaultSpacingKey,
  46. /**
  47. * loop 底部留白
  48. */
  49. INLINE_SPACING_BOTTOM: 'INLINE_SPACING_BOTTOM',
  50. /**
  51. * inlineBlocks 的 inlineTop
  52. * loop 循环线条上边距
  53. */
  54. INLINE_BLOCKS_INLINE_SPACING_TOP: 'INLINE_BLOCKS_INLINE_SPACING_TOP',
  55. /**
  56. * inlineBlocks 的 inlineBottom
  57. * loop 循环线条的下边距
  58. *
  59. */
  60. INLINE_BLOCKS_INLINE_SPACING_BOTTOM: 'INLINE_BLOCKS_INLINE_SPACING_BOTTOM',
  61. /***
  62. * 线条、label 默认颜色
  63. */
  64. BASE_COLOR: 'BASE_COLOR',
  65. /***
  66. * 线条、label 激活后的颜色
  67. */
  68. BASE_ACTIVATED_COLOR: 'BASE_ACTIVATED_COLOR',
  69. /**
  70. * Branch bottom margin
  71. * 分支下边距
  72. */
  73. INLINE_BLOCKS_PADDING_TOP: 'INLINE_BLOCKS_PADDING_TOP',
  74. };