Skip to content

normalizeBlock

normalizeBlock(node, options): Omit<TypedObject | PortableTextTextBlock<TypedObject | PortableTextSpan>, "_key"> & object

Defined in: block-tools/src/util/normalizeBlock.ts:48

Normalizes a block by ensuring it has a _key property. If the block is a portable text block, additional normalization is applied:

  • Ensures it has children and markDefs properties
  • Ensures it has at least one child (adds an empty span if empty)
  • Joins sibling spans that has the same marks
  • Removes decorators that are not allowed according to the schema
  • Removes marks that have no annotation definition

TypedObject

The block to normalize

BlockNormalizationOptions = {}

Options for normalization process. See BlockNormalizationOptions

Omit<TypedObject | PortableTextTextBlock<TypedObject | PortableTextSpan>, "_key"> & object

Normalized block