Support dragging reroutes from floating links (#878)

Allows dragging reroutes from floating links.
This commit is contained in:
filtered
2025-04-03 23:08:28 +11:00
committed by GitHub
parent a4e1b39823
commit 05b0918915

View File

@@ -1250,7 +1250,10 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
const linkIds = before instanceof Reroute
? before.linkIds
: [before.id]
const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds)
const floatingLinkIds = before instanceof Reroute
? before.floatingLinkIds
: [before.id]
const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds, floatingLinkIds)
this.reroutes.set(rerouteId, reroute)
for (const linkId of linkIds) {
const link = this._links.get(linkId)
@@ -1263,6 +1266,17 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
}
}
for (const linkId of floatingLinkIds) {
const link = this.floatingLinks.get(linkId)
if (!link) continue
if (link.parentId === before.parentId) link.parentId = rerouteId
const reroutes = LLink.getReroutes(this, link)
for (const x of reroutes.filter(x => x.parentId === before.parentId)) {
x.parentId = rerouteId
}
}
return reroute
}