Copy & Paste all items (#302)

* Add copy & paste of groups & reroutes

Complete rewrite of copy & paste
Fixes a bug where failure to clone a node would corrupt all subsequent nodes
No longer mutates nodes when copying

* Fix name collision

* Fix cannot copy specified nodes to clipboard

* Allow mapping of original IDs to pasted clones
This commit is contained in:
filtered
2024-11-14 02:21:23 +11:00
committed by GitHub
parent 4c0c05ee6d
commit cc084811d9
3 changed files with 177 additions and 95 deletions

View File

@@ -1265,7 +1265,9 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
* @param linkIds IDs of links that pass through this reroute
*/
setReroute({ id, parentId, pos, linkIds }: SerialisableReroute): Reroute {
id ??= ++this.state.lastRerouteId
if (id > this.state.lastRerouteId) this.state.lastRerouteId = id
const reroute = this.reroutes.get(id) ?? new Reroute(id, this)
reroute.update(parentId, pos, linkIds)
this.reroutes.set(id, reroute)