newcat / baklavajs

Graph / node editor in the browser using VueJS
http://baklava.tech
MIT License
1.52k stars 113 forks source link

Copy-Paste does not retain connection involving dynamic interfaces. #343

Closed yojeek closed 8 months ago

yojeek commented 9 months ago

As the hook only applied to the interfaces already present in copiedNode, dynamic interfaces created during load() call will appear broken.

            const tapInterfaces = (intfs: Record<string, NodeInterface<any>>) => {
                Object.values(intfs).forEach((intf) => {
                    intf.hooks.load.subscribe(token, (intfState) => {
                        const newIntfId = uuidv4();
                        idmap.set(intfState.id, newIntfId);
                        intf.id = newIntfId;
                        intf.hooks.load.unsubscribe(token);
                        return intfState;
                    });
                });
            };

            tapInterfaces(copiedNode.inputs);
            tapInterfaces(copiedNode.outputs);
newcat commented 8 months ago

Fixed in v2.3.0