React-diagrams: Remove created link if it is not connected to any node

Created on 20 Feb 2019  路  5Comments  路  Source: projectstorm/react-diagrams

Hi there, kudos to the devs for this amazing lib.

I'm wondering how to remove link if it is not connected to any node. Is there any way to modify the link after it is created (when you are finished dragging the link / stop holding the mouse click)?. It seems all the available function related to link gets fired directly when creating a link by dragging the port for the first time.

Any insight is appreciated!!

Most helpful comment

I tried using import { CanvasWidget } from '@projectstorm/react-canvas-core' but this prop is not recognize.

Try this, when creating an engine
const state = engine.getStateMachine().getCurrentState();
if (state instanceof DefaultDiagramState) {
state.dragNewLink.config.allowLooseLinks = false;
}

All 5 comments

Hey, maybe the allowLooseLinks props for DiagramWidget may help you ?
<DiagramWidget css={css' background-color: #000; height: 100vh; '} diagramEngine={engine} allowLooseLinks={false} />

Oh right, I missed that props. Thankyou very much!

I tried using import { CanvasWidget } from '@projectstorm/react-canvas-core' but this prop is not recognize.

I tried using import { CanvasWidget } from '@projectstorm/react-canvas-core' but this prop is not recognize.

Have the same issue

I tried using import { CanvasWidget } from '@projectstorm/react-canvas-core' but this prop is not recognize.

Try this, when creating an engine
const state = engine.getStateMachine().getCurrentState();
if (state instanceof DefaultDiagramState) {
state.dragNewLink.config.allowLooseLinks = false;
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msaglietto picture msaglietto  路  3Comments

abhijitnandy2011 picture abhijitnandy2011  路  3Comments

kmannislands picture kmannislands  路  3Comments

maxbasque picture maxbasque  路  3Comments

Naveenraj006 picture Naveenraj006  路  3Comments