@joint/react
    Preparing search index...

    Type Alias ValidateEmbedding

    ValidateEmbedding: (context: ValidateEmbeddingParams) => boolean

    Decides whether a dragged element may be embedded into a parent element. Return true to allow the drop, false to reject it. Pass it to the validateEmbedding prop of <Paper>; the callback receives a structured ValidateEmbeddingParams context.

    Type Declaration

      • (context: ValidateEmbeddingParams): boolean
      • Parameters

        • context: ValidateEmbeddingParams

          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: Graph

            The graph the elements belong to.

          • Readonlypaper: Paper

            The paper the elements live on.

          • Readonlyparent: { id: ID; model: Element }

            The element it would be embedded into (the would-be parent).

        Returns boolean

    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>;