fix(reactflowUtils.ts): import Edge from reactflow to fix type error
refactor(reactflowUtils.ts): update updateIds function to handle changes in edge sourceHandle and targetHandle properties
This commit is contained in:
parent
db473f6f0d
commit
3a185d915d
1 changed files with 6 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { Connection, ReactFlowInstance } from "reactflow";
|
import { Connection, Edge, ReactFlowInstance } from "reactflow";
|
||||||
import { APITemplateType } from "../types/api";
|
import { APITemplateType } from "../types/api";
|
||||||
import {
|
import {
|
||||||
FlowType,
|
FlowType,
|
||||||
|
|
@ -142,19 +142,13 @@ export function updateIds(newFlow, getNodeId) {
|
||||||
// Add the new node to the list of nodes in state
|
// Add the new node to the list of nodes in state
|
||||||
});
|
});
|
||||||
|
|
||||||
newFlow.edges.forEach((e) => {
|
newFlow.edges.forEach((e: Edge) => {
|
||||||
e.source = idsMap[e.source];
|
e.source = idsMap[e.source];
|
||||||
e.target = idsMap[e.target];
|
e.target = idsMap[e.target];
|
||||||
let sourceHandleSplitted = e.sourceHandle.split("|");
|
const sourceHandleObject: sourceHandleType = JSON.parse(e.sourceHandle);
|
||||||
e.sourceHandle =
|
e.sourceHandle = JSON.stringify({ ...sourceHandleObject, id: e.source });
|
||||||
sourceHandleSplitted[0] +
|
const targetHandleObject: targetHandleType = JSON.parse(e.targetHandle);
|
||||||
"|" +
|
e.targetHandle = JSON.stringify({ ...targetHandleObject, id: e.target });
|
||||||
e.source +
|
|
||||||
"|" +
|
|
||||||
sourceHandleSplitted.slice(2).join("|");
|
|
||||||
let targetHandleSplitted = e.targetHandle.split("|");
|
|
||||||
e.targetHandle =
|
|
||||||
targetHandleSplitted.slice(0, -1).join("|") + "|" + e.target;
|
|
||||||
e.id =
|
e.id =
|
||||||
"reactflow__edge-" +
|
"reactflow__edge-" +
|
||||||
e.source +
|
e.source +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue