Context handed to a ValidateConnection callback (and to the validate
option of CanConnectOptions) while the user drags a link end. Describes
both ends of the pending connection along with the paper and graph it lives in.
Context handed to a ValidateConnection callback (and to the validate
option of CanConnectOptions) while the user drags a link end. Describes
both ends of the pending connection along with the paper and graph it lives in.
ReadonlyendType: LinkEndWhich end the user is dragging: 'source' or 'target'.
Readonlygraph: GraphThe graph the link belongs to.
Readonlypaper: PaperThe paper the link is being drawn on.
Readonlysource: ConnectionEndThe source end of the pending connection.
Readonlytarget: ConnectionEndThe target end of the pending connection.
import { GraphProvider, Paper } from '@joint/react';
import type { ValidateConnection } from '@joint/react';
// Only accept links that end on a port named "in".
const validate: ValidateConnection = ({ target }) => target.port === 'in';
<GraphProvider>
<Paper validateConnection={validate} renderElement={() => <rect width={80} height={40} />} />
</GraphProvider>;
Decides whether a link may connect its source end to its target end. Return
trueto allow the connection,falseto reject it. Pass it (or a CanConnectOptions object) to thevalidateConnectionprop of<Paper>; the callback receives a structured ValidateConnectionParams context.