projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.45k stars 1.16k forks source link

Can't create link after changing port name #935

Closed rzfzr closed 2 years ago

rzfzr commented 2 years ago

I changed the port name as #934 , however, I can't link the changed ports.

canLinkToPort is not even being called. engine.repaintCanvas seems to make no difference.

Thanks

rzfzr commented 2 years ago

Nobody has any clue on this?

rzfzr commented 2 years ago

Done, you have to edit "ports" aswell as portsIn or out, it is an object, not a list, so I add the new key and dele the old, I made a method besides addInPort...


    renamePort(oldName: string, newName: string): void {
        const portInIndex = this.portsIn.findIndex(p => p.getOptions().name === oldName)

        this.portsIn[portInIndex].getOptions().name = newName
        this.portsIn[portInIndex].getOptions().label = newName

        this.ports[newName] = this.ports[oldName];
        delete this.ports[oldName];
    }

It somehow keeps the links connected aswell