We have four custom node types registered in Node-RED, two of which have output junctions that serve to connect the output from parent nodes to their child nodes. We require all nodes as well as their output junctions to each have their own unique Node-RED ID. This is indeed the case when these nodes get created, because the new nodes have new IDs assigned to their junctions during the 'oneditprepare' event handling when the node properties are edited.
However, users are also able to copy and paste nodes with their junctions and connected child nodes, and then connect those nodes up elsewhere on the flow tab, without having to edit the node properties. When a node and its junctions are copied and left unedited, there is no event that fires, which we can trap and to which we can assign a handler function. This causes a problem whereby nodes are copied with their original Node-RED IDs still intact, resulting in nodes on the flow tab with duplicate Node-RED IDs. Is there an 'oneditcopy' or 'oneditpaste' event, or something similar, which would enable us to detect a node copy event, or to control what happens to copied node junctions when they are pasted or imported into the workspace?
Can you explain what do you mean by output junction? Do you mean the circular output ports on the right hand side of a node?
Also, what & why would you need these to have an ID? Are you tagging messages that leave the port with this ID? Are you doing something else in your custom nudes that attempt to inhibit or alert the user about what nodes they can/should connect? Essentially, I'm asking what is the purpose of these ID?
Lastly, are these custom nodes available to all (on GitHub/npm) or internal/private/propitiatory?
Yes, with 'junction' I mean 'the circular output ports on the right hand side of a node'. The custom nodes are proprietary, so I am unable to expand too broadly on the reason for the ID assignment to the junctions, other than to say that upon deployment, the flow node JSON model is exported and reprocessed by a legacy back-end. Removing the junction IDs would require very significant refactoring downstream. It is an option, I agree, but rather invasive and definitely not our first choice.
If you check the following code, you can see the standard code I use for my uibuilder nodes. Some of them HAVE to empty a key field when nodes are copy/pasted or imported so I came up with a standard function to do it that gets loaded into all of my nodes Editor html files.
Thank you. I've learned that copying and pasting a node and its junctions and child nodes in the editor, raises a nodes:add event. Adding a handler function for such an event enabled me to incept those nodes as they are pasted, and to interrogate the node data. I have managed to resolve my junction ID issue.