feat(editor): Add undo/redo create connection in new canvas (no-changelog) (#10141)

This commit is contained in:
Alex Grozav
2024-07-22 20:26:47 +03:00
committed by GitHub
parent 7e1eeb4c31
commit ada1256898
4 changed files with 77 additions and 4 deletions

View File

@@ -74,6 +74,32 @@ export function mapLegacyConnectionsToCanvasConnections(
return mappedConnections;
}
export function mapLegacyConnectionToCanvasConnection(
sourceNode: INodeUi,
targetNode: INodeUi,
legacyConnection: [IConnection, IConnection],
): Connection {
const source = sourceNode.id;
const sourceHandle = createCanvasConnectionHandleString({
mode: CanvasConnectionMode.Output,
type: legacyConnection[0].type,
index: legacyConnection[0].index,
});
const target = targetNode.id;
const targetHandle = createCanvasConnectionHandleString({
mode: CanvasConnectionMode.Input,
type: legacyConnection[1].type,
index: legacyConnection[1].index,
});
return {
source,
sourceHandle,
target,
targetHandle,
};
}
export function parseCanvasConnectionHandleString(handle: string | null | undefined) {
const [mode, type, index] = (handle ?? '').split('/');