Block Types Data Edit

Namespace: core/blocks.

Selectors Selectors

# getBlockStyles

Returns block styles by block name.

Parameters

  • state Object: Data state.
  • name string: Block type name.

Returns

  • ?Array: Block Styles.

# getBlockSupport

Returns the block support value for a feature, if defined.

Parameters

  • state Object: Data state.
  • nameOrType (string|Object): Block name or type object
  • feature string: Feature to retrieve
  • defaultSupports *: Default value to return if not explicitly defined

Returns

  • ?*: Block support value

# getBlockType

Returns a block type by name.

Parameters

  • state Object: Data state.
  • name string: Block type name.

Returns

  • ?Object: Block Type.

# getBlockTypes

Returns all the available block types.

Parameters

  • state Object: Data state.

Returns

  • Array: Block Types.

# getBlockVariations

Returns block variations by block name.

Parameters

  • state Object: Data state.
  • blockName string: Block type name.
  • scope [WPBlockVariationScope]: Block variation scope name.

Returns

  • (Array<WPBlockVariation>|void): Block variations.

# getCategories

Returns all the available categories.

Parameters

  • state Object: Data state.

Returns

  • Array: Categories list.

# getChildBlockNames

Returns an array with the child blocks of a given block.

Parameters

  • state Object: Data state.
  • blockName string: Block type name.

Returns

  • Array: Array of child block names.

# getCollections

Returns all the available collections.

Parameters

  • state Object: Data state.

Returns

  • Object: Collections list.

# getDefaultBlockName

Returns the name of the default block name.

Parameters

  • state Object: Data state.

Returns

  • ?string: Default block name.

# getDefaultBlockVariation

Returns the default block variation for the given block type.
When there are multiple variations annotated as the default one,
the last added item is picked. This simplifies registering overrides.
When there is no default variation set, it returns the first item.

Parameters

  • state Object: Data state.
  • blockName string: Block type name.
  • scope [WPBlockVariationScope]: Block variation scope name.

Returns

  • ?WPBlockVariation: The default block variation.

# getFreeformFallbackBlockName

Returns the name of the block for handling non-block content.

Parameters

  • state Object: Data state.

Returns

  • ?string: Name of the block for handling non-block content.

# getGroupingBlockName

Returns the name of the block for handling unregistered blocks.

Parameters

  • state Object: Data state.

Returns

  • ?string: Name of the block for handling unregistered blocks.

# getUnregisteredFallbackBlockName

Returns the name of the block for handling unregistered blocks.

Parameters

  • state Object: Data state.

Returns

  • ?string: Name of the block for handling unregistered blocks.

# hasBlockSupport

Returns true if the block defines support for a feature, or false otherwise.

Parameters

  • state Object: Data state.
  • nameOrType (string|Object): Block name or type object.
  • feature string: Feature to test.
  • defaultSupports boolean: Whether feature is supported by default if not explicitly defined.

Returns

  • boolean: Whether block supports feature.

# hasChildBlocks

Returns a boolean indicating if a block has child blocks or not.

Parameters

  • state Object: Data state.
  • blockName string: Block type name.

Returns

  • boolean: True if a block contains child blocks and false otherwise.

# hasChildBlocksWithInserterSupport

Returns a boolean indicating if a block has at least one child block with inserter support.

Parameters

  • state Object: Data state.
  • blockName string: Block type name.

Returns

  • boolean: True if a block contains at least one child blocks with inserter support and false otherwise.

# isMatchingSearchTerm

Returns true if the block type by the given name or object value matches a
search term, or false otherwise.

Parameters

  • state Object: Blocks state.
  • nameOrType (string|Object): Block name or type object.
  • searchTerm string: Search term by which to filter.

Returns

  • Array<Object>: Whether block type matches search term.

Top ↑

Actions Actions

# addBlockCollection

Returns an action object used to add block collections

Parameters

  • namespace string: The namespace of the blocks to put in the collection
  • title string: The title to display in the block inserter
  • icon Object: (optional) The icon to display in the block inserter

Returns

  • Object: Action object.

# addBlockStyles

Returns an action object used in signalling that new block styles have been added.

Parameters

  • blockName string: Block name.
  • styles (Array|Object): Block styles.

Returns

  • Object: Action object.

# addBlockTypes

Returns an action object used in signalling that block types have been added.

Parameters

  • blockTypes (Array|Object): Block types received.

Returns

  • Object: Action object.

# addBlockVariations

Returns an action object used in signalling that new block variations have been added.

Parameters

  • blockName string: Block name.
  • variations (WPBlockVariation|Array<WPBlockVariation>): Block variations.

Returns

  • Object: Action object.

# removeBlockCollection

Returns an action object used to remove block collections

Parameters

  • namespace string: The namespace of the blocks to put in the collection

Returns

  • Object: Action object.

# removeBlockStyles

Returns an action object used in signalling that block styles have been removed.

Parameters

  • blockName string: Block name.
  • styleNames (Array|string): Block style names.

Returns

  • Object: Action object.

# removeBlockTypes

Returns an action object used to remove a registered block type.

Parameters

  • names (string|Array): Block name.

Returns

  • Object: Action object.

# removeBlockVariations

Returns an action object used in signalling that block variations have been removed.

Parameters

  • blockName string: Block name.
  • variationNames (string|Array<string>): Block variation names.

Returns

  • Object: Action object.

# setCategories

Returns an action object used to set block categories.

Parameters

  • categories Array<Object>: Block categories.

Returns

  • Object: Action object.

# setDefaultBlockName

Returns an action object used to set the default block name.

Parameters

  • name string: Block name.

Returns

  • Object: Action object.

# setFreeformFallbackBlockName

Returns an action object used to set the name of the block used as a fallback
for non-block content.

Parameters

  • name string: Block name.

Returns

  • Object: Action object.

# setGroupingBlockName

Returns an action object used to set the name of the block used
when grouping other blocks
eg: in “Group/Ungroup” interactions

Parameters

  • name string: Block name.

Returns

  • Object: Action object.

# setUnregisteredFallbackBlockName

Returns an action object used to set the name of the block used as a fallback
for unregistered blocks.

Parameters

  • name string: Block name.

Returns

  • Object: Action object.

# updateCategory

Returns an action object used to update a category.

Parameters

  • slug string: Block category slug.
  • category Object: Object containing the category properties that should be updated.

Returns

  • Object: Action object.