Adding a link targeting new node
See original GitHub issueHi ! First of all, thank you for this amazing project 😃
I have an issue when I try to add a new node and a new link at the same time.
buttonAddRefus() {
//Create a new node
const newNode = new DefaultNodeModel("Node 3","rgb(192,255,0)");
newNode.x = 500;
newNode.y = 100;
//Create new link
let newLink = new LinkModel();
//Set source on existing port : all is fine
let portStep = _.find(this.props.engine.diagramModel.getNodes(), {"name":"Node 2"})
newLink.setSourcePort(portStep.ports["out-1"]);
//Set target on new node : will generate exception
let newPort = newNode.addPort(new DefaultPortModel(true,"out-1", 'In'));
newLink.setTargetPort(newPort);
//Add node and link to model
let model = this.props.engine.diagramModel;
model.addNode(newNode);
model.addLink(newLink);
//refresh
this.props.engine.repaintCanvas()
}
this generates this error on console : \node_modules\storm-react-diagrams\dist\main.js:1 Cannot find Node Port element with nodeID: [1985738d-ccad-41cb-ac80-293d56b79d57] and name: [out-1]
This is fine when the target node already exists. I also saw that a setTimeout before adding the link works, but… hum… 😃
How can I fix it ? Thank you 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Add relationship type—ArcGIS Pro | Documentation
Add a relationship type to the link chart. The link chart will draw links between nodes based on the relationship types.
Read more >How do I add target="_blank" to a link within a specified div?
Show activity on this post. In this case, the JavaScript would add target="_blank" to all links within the div link_other . How can...
Read more >Inserting a node on an existing link... automatically - GoJS
Now, I want to drag and drop C over the existing "A-to-B" link, ... Link to the Node, add a new link from...
Read more >Add links to map nodes - MindMup
How to add links to nodes, and cross-link maps. ... You can click on the link widget and the browser will open the...
Read more >Add target attribute to LinkNode · Issue #2671 · facebook/lexical
It would be great to support target for LinkNode attribute. It is currently impossible to specify if a link should be open in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am dragging a new link to an empty spot and release to create a node then connect the link to a port. The link is dangling at (0,0) of the node. None of the tricks worked for me (e.g. setTimeout, refresh the canvas)… the only workaround i found is to
var newLink = link.clone()
and thennewLink.setTargetPort()
then remove the old link and add the new one… nosetTimeout
is required… hope this help you…also might be a workaround for https://github.com/projectstorm/react-diagrams/issues/223
Thanks @ShiroYacha !