Context handed to a ValidateEmbedding callback while an element is
dragged over a candidate parent. Use it to compare the dragged child against
the parent it would drop into.
Context handed to a ValidateEmbedding callback while an element is
dragged over a candidate parent. Use it to compare the dragged child against
the parent it would drop into.
Readonlychild: { id: ID; model: Element }The element being dragged (the would-be child).
Readonlygraph: GraphThe graph the elements belong to.
Readonlypaper: PaperThe paper the elements live on.
Readonlyparent: { id: ID; model: Element }The element it would be embedded into (the would-be parent).
import { GraphProvider, Paper } from '@joint/react';
import type { ValidateEmbedding } from '@joint/react';
// Only "container" elements may accept children.
const validate: ValidateEmbedding = ({ parent }) => parent.model.get('type') === 'container';
<GraphProvider>
<Paper validateEmbedding={validate} renderElement={() => <rect width={80} height={40} />} />
</GraphProvider>;
Decides whether a dragged element may be embedded into a parent element. Return
trueto allow the drop,falseto reject it. Pass it to thevalidateEmbeddingprop of<Paper>; the callback receives a structured ValidateEmbeddingParams context.