Block Types Data Edit

Namespace: core/blocks.

Selectors Selectors

Top ↑

getActiveBlockVariation getActiveBlockVariation

Returns the active block variation for a given block based on its attributes.
Variations are determined by their isActive property.
Which is either an array of block attribute keys or a function.

In case of an array of block attribute keys, the attributes are compared
to the variation’s attributes using strict equality check.

In case of function type, the function should accept a block’s attributes
and the variation’s attributes and determines if a variation is active.
A function that accepts a block’s attributes and the variation’s attributes and determines if a variation is active.

Parameters

  • state Object: Data state.
  • blockName string: Name of block (example: “core/columns”).
  • attributes Object: Block attributes used to determine active variation.
  • scope [WPBlockVariationScope]: Block variation scope name.

Returns

  • (WPBlockVariation|undefined): Active block variation.

Top ↑

getBlockStyles getBlockStyles

Returns block styles by block name.

Parameters

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

Returns

  • Array?: Block Styles.

Top ↑

getBlockSupport 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 Array|string: Feature to retrieve
  • defaultSupports *: Default value to return if not explicitly defined

Returns

  • ?*: Block support value

Top ↑

getBlockType getBlockType

Returns a block type by name.

Parameters

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

Returns

  • Object?: Block Type.

Top ↑

getBlockTypes getBlockTypes

Returns all the available block types.

Parameters

  • state Object: Data state.

Returns

  • Array: Block Types.

Top ↑

getBlockVariations getBlockVariations

Returns block variations by block name.

Parameters

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

Returns

  • (WPBlockVariation[]|void): Block variations.

Top ↑

getCategories getCategories

Returns all the available categories.

Parameters

  • state Object: Data state.

Returns

  • WPBlockCategory[]: Categories list.

Top ↑

getChildBlockNames 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.

Top ↑

getCollections getCollections

Returns all the available collections.

Parameters

  • state Object: Data state.

Returns

  • Object: Collections list.

Top ↑

getDefaultBlockName getDefaultBlockName

Returns the name of the default block name.

Parameters

  • state Object: Data state.

Returns

  • string?: Default block name.

Top ↑

getDefaultBlockVariation 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.

Top ↑

getFreeformFallbackBlockName 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.

Top ↑

getGroupingBlockName 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.

Top ↑

getUnregisteredFallbackBlockName 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.

Top ↑

hasBlockSupport 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.

Top ↑

hasChildBlocks 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.

Top ↑

hasChildBlocksWithInserterSupport 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.

Top ↑

isMatchingSearchTerm 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

  • Object[]: Whether block type matches search term.

Top ↑

Actions Actions

Top ↑

addBlockCollection 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.

Top ↑

addBlockStyles 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.

Top ↑

addBlockTypes 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.

Top ↑

addBlockVariations addBlockVariations

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

Parameters

  • blockName string: Block name.
  • variations WPBlockVariation|WPBlockVariation[]: Block variations.

Returns

  • Object: Action object.

Top ↑

removeBlockCollection 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.

Top ↑

removeBlockStyles 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.

Top ↑

removeBlockTypes removeBlockTypes

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

Parameters

  • names string|Array: Block name.

Returns

  • Object: Action object.

Top ↑

removeBlockVariations removeBlockVariations

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

Parameters

  • blockName string: Block name.
  • variationNames string|string[]: Block variation names.

Returns

  • Object: Action object.

Top ↑

setCategories setCategories

Returns an action object used to set block categories.

Parameters

  • categories Object[]: Block categories.

Returns

  • Object: Action object.

Top ↑

setDefaultBlockName setDefaultBlockName

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

Parameters

  • name string: Block name.

Returns

  • Object: Action object.

Top ↑

setFreeformFallbackBlockName 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.

Top ↑

setGroupingBlockName 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.

Top ↑

setUnregisteredFallbackBlockName 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.

Top ↑

updateCategory 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.