Browse Source

fix(canvas-core): to avoid fixedDocument.addBlocksAsChildren affecting the recursive creation of free layout

liuyangxing 10 tháng trước cách đây
mục cha
commit
d1c175e840

+ 3 - 0
apps/demo-free-layout/src/nodes/loop/index.ts

@@ -51,4 +51,7 @@ export const LoopNodeRegistry: FlowNodeRegistry = {
       },
     };
   },
+  onCreate() {
+    // NOTICE: 这个函数是为了避免触发固定布局 flowDocument.addBlocksAsChildren
+  },
 };

+ 3 - 0
packages/canvas-engine/free-layout-core/src/workflow-document.ts

@@ -160,6 +160,9 @@ export class WorkflowDocument extends FlowDocument {
   ): WorkflowNodeEntity {
     // 是否是一个已经存在的节点
     const isExistedNode = this.getNode(json.id);
+    if (isExistedNode) {
+      return isExistedNode;
+    }
     const parent = this.getNode(parentId ?? this.root.id) ?? this.root;
     const node = this.addNode(
       {