Skip to content

coerceBlockToDefinition

coerceBlockToDefinition(props): object

Defined in: packages/core/src/fields/blocks/utils.ts:101

Coerces an arbitrary object (e.g. pasted from the block clipboard) into a valid block of blockDef’s shape: a fresh id, keys blockDef does not declare dropped, and keys it declares but block is missing filled with their field default. blockName is kept when present and a string. Every nested block reachable through blockDef’s own fields also gets a fresh id.

Input props.

Record<string, unknown>

The untrusted candidate block object.

BlockConfig

The target field’s block type definition to coerce against.

object

The coerced block plus the keys from block that were dropped.

block: GenericBlock

droppedKeys: string[]