Jelajahi Sumber

fix(auto-layout): rankdir top to bottom (#972)

Louis Young 2 bulan lalu
induk
melakukan
5b80e4fbf7

+ 1 - 0
packages/plugins/free-auto-layout-plugin/src/layout/type.ts

@@ -109,6 +109,7 @@ export interface LayoutOptions {
   animationDuration?: number;
   disableFitView?: boolean;
   filterNode?: (params: { node: WorkflowNodeEntity; parent?: WorkflowNodeEntity }) => boolean;
+  filterLine?: (params: { line: WorkflowLineEntity }) => boolean;
 }
 
 export interface LayoutConfig {

+ 4 - 2
packages/plugins/free-auto-layout-plugin/src/services.ts

@@ -89,7 +89,9 @@ export class AutoLayoutService {
     const blocks = node.blocks.filter((blockNode) =>
       options.filterNode ? options.filterNode?.({ node: blockNode, parent: node.parent }) : true
     );
-    const edges = this.getNodesAllLines(blocks);
+    const edges = this.getNodesAllLines(blocks).filter((edge) =>
+      options.filterLine ? options.filterLine?.({ line: edge }) : true
+    );
 
     // 创建子布局节点
     const layoutNodes = this.createLayoutNodes(blocks, options);
@@ -124,7 +126,7 @@ export class AutoLayoutService {
   /** 创建线条布局数据 */
   private createLayoutEdge(edge: WorkflowLineEntity): LayoutEdge | undefined {
     const { from, to } = edge.info;
-    if (!from || !to || edge.vertical) {
+    if (!from || !to) {
       return;
     }
     const layoutEdge: LayoutEdge = {