Skip to main content
Version: 4.3

ValidateEmbedding

type ValidateEmbedding = (context) => 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.

Parameters​

ParameterType
contextValidateEmbeddingParams

Returns​

boolean

Example​

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

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub