The Block Editor’s Data Edit

Namespace: core/block-editor.

Selectors

Top ↑

areInnerBlocksControlled

Checks if a given block has controlled inner blocks.

Parameters

  • state Object: Global application state.
  • clientId string: The block to check.

Returns

  • boolean: True if the block has controlled inner blocks.

Top ↑

canEditBlock

Determines if the given block is allowed to be edited.

Parameters

  • state Object: Editor state.
  • clientId string: The block client Id.

Returns

  • boolean: Whether the given block is allowed to be edited.

Top ↑

canInsertBlocks

Determines if the given blocks are allowed to be inserted into the block
list.

Parameters

  • state Object: Editor state.
  • clientIds string: The block client IDs to be inserted.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Whether the given blocks are allowed to be inserted.

Top ↑

canInsertBlockType

Determines if the given block type is allowed to be inserted into the block list.

Parameters

  • state Object: Editor state.
  • blockName string: The name of the block type, e.g.’ core/paragraph’.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Whether the given block type is allowed to be inserted.

Top ↑

canLockBlockType

Determines if the given block type can be locked/unlocked by a user.

Parameters

  • state Object: Editor state.
  • nameOrType (string|Object): Block name or type object.

Returns

  • boolean: Whether a given block type can be locked/unlocked.

Top ↑

canMoveBlock

Determines if the given block is allowed to be moved.

Parameters

  • state Object: Editor state.
  • clientId string: The block client Id.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Whether the given block is allowed to be moved.

Top ↑

canMoveBlocks

Determines if the given blocks are allowed to be moved.

Parameters

  • state Object: Editor state.
  • clientIds string: The block client IDs to be moved.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Whether the given blocks are allowed to be moved.

Top ↑

canRemoveBlock

Determines if the given block is allowed to be deleted.

Parameters

  • state Object: Editor state.
  • clientId string: The block client Id.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Whether the given block is allowed to be removed.

Top ↑

canRemoveBlocks

Determines if the given blocks are allowed to be removed.

Parameters

  • state Object: Editor state.
  • clientIds string: The block client IDs to be removed.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Whether the given blocks are allowed to be removed.

Top ↑

didAutomaticChange

Returns true if the last change was an automatic change, false otherwise.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether the last change was automatic.

Top ↑

getAdjacentBlockClientId

Returns the client ID of the block adjacent one at the given reference
startClientId and modifier directionality. Defaults start startClientId to
the selected block, and direction as next block. Returns null if there is no
adjacent block.

Parameters

  • state Object: Editor state.
  • startClientId ?string: Optional client ID of block from which to search.
  • modifier ?number: Directionality multiplier (1 next, -1 previous).

Returns

  • ?string: Return the client ID of the block, or null if none exists.

Top ↑

getBlock

Returns a block given its client ID. This is a parsed copy of the block,
containing its blockName, clientId, and current attributes state. This
is not the block’s registration settings, which must be retrieved from the
blocks module registration store.

getBlock recurses through its inner blocks until all its children blocks have
been retrieved. Note that getBlock will not return the child inner blocks of
an inner block controller. This is because an inner block controller syncs
itself with its own entity, and should therefore not be included with the
blocks of a different entity. For example, say you call getBlocks( TP ) to
get the blocks of a template part. If another template part is a child of TP,
then the nested template part’s child blocks will not be returned. This way,
the template block itself is considered part of the parent, but the children
are not.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • Object: Parsed block object.

Top ↑

getBlockAttributes

Returns a block’s attributes given its client ID, or null if no block exists with
the client ID.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • Object?: Block attributes.

Top ↑

getBlockCount

Returns the number of blocks currently present in the post.

Parameters

  • state Object: Editor state.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • number: Number of blocks in the post.

Top ↑

getBlockHierarchyRootClientId

Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks.

Parameters

  • state Object: Editor state.
  • clientId string: Block from which to find root client ID.

Returns

  • string: Root client ID

Top ↑

getBlockIndex

Returns the index at which the block corresponding to the specified client
ID occurs within the block order, or -1 if the block does not exist.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • number: Index at which block exists in order.

Top ↑

getBlockInsertionPoint

Returns the insertion point, the index at which the new inserted block would
be placed. Defaults to the last index.

Parameters

  • state Object: Editor state.

Returns

  • Object: Insertion point object with rootClientId, index.

Top ↑

getBlockListSettings

Returns the Block List settings of a block, if any exist.

Parameters

  • state Object: Editor state.
  • clientId ?string: Block client ID.

Returns

  • ?Object: Block settings of the block if set.

Top ↑

getBlockMode

Returns the block’s editing mode, defaulting to “visual” if not explicitly
assigned.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • Object: Block editing mode.

Top ↑

getBlockName

Returns a block’s name given its client ID, or null if no block exists with
the client ID.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • string: Block name.

Top ↑

getBlockOrder

Returns an array containing all block client IDs in the editor in the order
they appear. Optionally accepts a root client ID of the block list for which
the order should be returned, defaulting to the top-level block order.

Parameters

  • state Object: Editor state.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • Array: Ordered client IDs of editor blocks.

Top ↑

getBlockParents

Given a block client ID, returns the list of all its parents from top to bottom.

Parameters

  • state Object: Editor state.
  • clientId string: Block from which to find root client ID.
  • ascending boolean: Order results from bottom to top (true) or top to bottom (false).

Returns

  • Array: ClientIDs of the parent blocks.

Top ↑

getBlockParentsByBlockName

Given a block client ID and a block name, returns the list of all its parents
from top to bottom, filtered by the given name(s). For example, if passed
‘core/group’ as the blockName, it will only return parents which are group
blocks. If passed [ 'core/group', 'core/cover'], as the blockName, it will
return parents which are group blocks and parents which are cover blocks.

Parameters

  • state Object: Editor state.
  • clientId string: Block from which to find root client ID.
  • blockName string|string[]: Block name(s) to filter.
  • ascending boolean: Order results from bottom to top (true) or top to bottom (false).

Returns

  • Array: ClientIDs of the parent blocks.

Top ↑

getBlockRootClientId

Given a block client ID, returns the root block from which the block is
nested, an empty string for top-level blocks, or null if the block does not
exist.

Parameters

  • state Object: Editor state.
  • clientId string: Block from which to find root client ID.

Returns

  • ?string: Root client ID, if exists

Top ↑

getBlocks

Returns all block objects for the current post being edited as an array in
the order they appear in the post. Note that this will exclude child blocks
of nested inner block controllers.

Parameters

  • state Object: Editor state.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • Object[]: Post blocks.

Top ↑

getBlocksByClientId

Given an array of block client IDs, returns the corresponding array of block
objects.

Parameters

  • state Object: Editor state.
  • clientIds string[]: Client IDs for which blocks are to be returned.

Returns

  • WPBlock[]: Block objects.

Top ↑

getBlockSelectionEnd

Returns the current block selection end. This value may be null, and it
may represent either a singular block selection or multi-selection end.
A selection is singular if its start and end match.

Parameters

  • state Object: Global application state.

Returns

  • ?string: Client ID of block selection end.

Top ↑

getBlockSelectionStart

Returns the current block selection start. This value may be null, and it
may represent either a singular block selection or multi-selection start.
A selection is singular if its start and end match.

Parameters

  • state Object: Global application state.

Returns

  • ?string: Client ID of block selection start.

Top ↑

getBlockTransformItems

Determines the items that appear in the available block transforms list.

Each item object contains what’s necessary to display a menu item in the
transform list and handle its selection.

The ‘frecency’ property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
that combines block usage frequenty and recency.

Items are returned ordered descendingly by their ‘frecency’.

Parameters

  • state Object: Editor state.
  • blocks Object|Object[]: Block object or array objects.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • WPEditorTransformItem[]: Items that appear in inserter.

Type Definition

  • WPEditorTransformItem Object

Properties

  • id string: Unique identifier for the item.
  • name string: The type of block to create.
  • title string: Title of the item, as it appears in the inserter.
  • icon string: Dashicon for the item, as it appears in the inserter.
  • isDisabled boolean: Whether or not the user should be prevented from inserting this item.
  • frecency number: Heuristic that combines frequency and recency.

Top ↑

getClientIdsOfDescendants

Returns an array containing the clientIds of all descendants of the blocks
given. Returned ids are ordered first by the order of the ids given, then
by the order that they appear in the editor.

Parameters

  • state Object: Global application state.
  • clientIds Array: Array of blocks to inspect.

Returns

  • Array: ids of descendants.

Top ↑

getClientIdsWithDescendants

Returns an array containing the clientIds of the top-level blocks and
their descendants of any depth (for nested blocks). Ids are returned
in the same order that they appear in the editor.

Parameters

  • state Object: Global application state.

Returns

  • Array: ids of top-level and descendant blocks.

Top ↑

getDraggedBlockClientIds

Returns the client ids of any blocks being directly dragged.

This does not include children of a parent being dragged.

Parameters

  • state Object: Global application state.

Returns

  • string[]: Array of dragged block client ids.

Top ↑

getFirstMultiSelectedBlockClientId

Returns the client ID of the first block in the multi-selection set, or null
if there is no multi-selection.

Parameters

  • state Object: Editor state.

Returns

  • ?string: First block client ID in the multi-selection set.

Top ↑

getGlobalBlockCount

Returns the total number of blocks, or the total number of blocks with a specific name in a post.
The number returned includes nested blocks.

Parameters

  • state Object: Global application state.
  • blockName ?string: Optional block name, if specified only blocks of that type will be counted.

Returns

  • number: Number of blocks in the post, or number of blocks with name equal to blockName.

Top ↑

getInserterItems

Determines the items that appear in the inserter. Includes both static
items (e.g. a regular block type) and dynamic items (e.g. a reusable block).

Each item object contains what’s necessary to display a button in the
inserter and handle its selection.

The ‘frecency’ property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
that combines block usage frequenty and recency.

Items are returned ordered descendingly by their ‘utility’ and ‘frecency’.

Parameters

  • state Object: Editor state.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • WPEditorInserterItem[]: Items that appear in inserter.

Type Definition

  • WPEditorInserterItem Object

Properties

  • id string: Unique identifier for the item.
  • name string: The type of block to create.
  • initialAttributes Object: Attributes to pass to the newly created block.
  • title string: Title of the item, as it appears in the inserter.
  • icon string: Dashicon for the item, as it appears in the inserter.
  • category string: Block category that the item is associated with.
  • keywords string[]: Keywords that can be searched to find this item.
  • isDisabled boolean: Whether or not the user should be prevented from inserting this item.
  • frecency number: Heuristic that combines frequency and recency.

Top ↑

getLastMultiSelectedBlockClientId

Returns the client ID of the last block in the multi-selection set, or null
if there is no multi-selection.

Parameters

  • state Object: Editor state.

Returns

  • ?string: Last block client ID in the multi-selection set.

Top ↑

getLowestCommonAncestorWithSelectedBlock

Given a block client ID, returns the lowest common ancestor with selected client ID.

Parameters

  • state Object: Editor state.
  • clientId string: Block from which to find common ancestor client ID.

Returns

  • string: Common ancestor client ID or undefined

Top ↑

getMultiSelectedBlockClientIds

Returns the current multi-selection set of block client IDs, or an empty
array if there is no multi-selection.

Parameters

  • state Object: Editor state.

Returns

  • Array: Multi-selected block client IDs.

Top ↑

getMultiSelectedBlocks

Returns the current multi-selection set of blocks, or an empty array if
there is no multi-selection.

Parameters

  • state Object: Editor state.

Returns

  • Array: Multi-selected block objects.

Top ↑

getMultiSelectedBlocksEndClientId

Returns the client ID of the block which ends the multi-selection set, or
null if there is no multi-selection.

This is not necessarily the last client ID in the selection.

Related

  • getLastMultiSelectedBlockClientId

Parameters

  • state Object: Editor state.

Returns

  • ?string: Client ID of block ending multi-selection.

Top ↑

getMultiSelectedBlocksStartClientId

Returns the client ID of the block which begins the multi-selection set, or
null if there is no multi-selection.

This is not necessarily the first client ID in the selection.

Related

  • getFirstMultiSelectedBlockClientId

Parameters

  • state Object: Editor state.

Returns

  • ?string: Client ID of block beginning multi-selection.

Top ↑

getNextBlockClientId

Returns the next block’s client ID from the given reference start ID.
Defaults start to the selected block. Returns null if there is no next
block.

Parameters

  • state Object: Editor state.
  • startClientId ?string: Optional client ID of block from which to search.

Returns

  • ?string: Adjacent block’s client ID, or null if none exists.

Top ↑

getPreviousBlockClientId

Returns the previous block’s client ID from the given reference start ID.
Defaults start to the selected block. Returns null if there is no previous
block.

Parameters

  • state Object: Editor state.
  • startClientId ?string: Optional client ID of block from which to search.

Returns

  • ?string: Adjacent block’s client ID, or null if none exists.

Top ↑

getSelectedBlock

Returns the currently selected block, or null if there is no selected block.

Parameters

  • state Object: Global application state.

Returns

  • ?Object: Selected block.

Top ↑

getSelectedBlockClientId

Returns the currently selected block client ID, or null if there is no
selected block.

Parameters

  • state Object: Editor state.

Returns

  • ?string: Selected block client ID.

Top ↑

getSelectedBlockClientIds

Returns the current selection set of block client IDs (multiselection or single selection).

Parameters

  • state Object: Editor state.

Returns

  • Array: Multi-selected block client IDs.

Top ↑

getSelectedBlockCount

Returns the number of blocks currently selected in the post.

Parameters

  • state Object: Global application state.

Returns

  • number: Number of blocks selected in the post.

Top ↑

getSelectedBlocksInitialCaretPosition

Returns the initial caret position for the selected block.
This position is to used to position the caret properly when the selected block changes.
If the current block is not a RichText, having initial position set to 0 means “focus block”

Parameters

  • state Object: Global application state.

Returns

  • 0|-1|null: Initial position.

Top ↑

getSelectionEnd

Returns the current selection end block client ID, attribute key and text
offset.

Parameters

  • state Object: Block editor state.

Returns

  • WPBlockSelection: Selection end information.

Top ↑

getSelectionStart

Returns the current selection start block client ID, attribute key and text
offset.

Parameters

  • state Object: Block editor state.

Returns

  • WPBlockSelection: Selection start information.

Top ↑

getSettings

Returns the editor settings.

Parameters

  • state Object: Editor state.

Returns

  • Object: The editor settings object.

Top ↑

getTemplate

Returns the defined block template

Parameters

  • state boolean:

Returns

  • ?Array: Block Template.

Top ↑

getTemplateLock

Returns the defined block template lock. Optionally accepts a root block
client ID as context, otherwise defaulting to the global context.

Parameters

  • state Object: Editor state.
  • rootClientId ?string: Optional block root client ID.

Returns

  • ?string: Block Template Lock

Top ↑

hasBlockMovingClientId

Returns whether block moving mode is enabled.

Parameters

  • state Object: Editor state.

Returns

  • string: Client Id of moving block.

Top ↑

hasInserterItems

Determines whether there are items to show in the inserter.

Parameters

  • state Object: Editor state.
  • rootClientId ?string: Optional root client ID of block list.

Returns

  • boolean: Items that appear in inserter.

Top ↑

hasMultiSelection

Returns true if a multi-selection has been made, or false otherwise.

Parameters

  • state Object: Editor state.

Returns

  • boolean: Whether multi-selection has been made.

Top ↑

hasSelectedBlock

Returns true if there is a single selected block, or false otherwise.

Parameters

  • state Object: Editor state.

Returns

  • boolean: Whether a single block is selected.

Top ↑

hasSelectedInnerBlock

Returns true if one of the block’s inner blocks is selected.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.
  • deep boolean: Perform a deep check.

Returns

  • boolean: Whether the block as an inner block selected

Top ↑

isAncestorBeingDragged

Returns whether a parent/ancestor of the block is being dragged.

Parameters

  • state Object: Global application state.
  • clientId string: Client id for block to check.

Returns

  • boolean: Whether the block’s ancestor is being dragged.

Top ↑

isAncestorMultiSelected

Returns true if an ancestor of the block is multi-selected, or false
otherwise.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • boolean: Whether an ancestor of the block is in multi-selection set.

Top ↑

isBlockBeingDragged

Returns whether the block is being dragged.

Only returns true if the block is being directly dragged,
not if the block is a child of a parent being dragged.
See isAncestorBeingDragged for child blocks.

Parameters

  • state Object: Global application state.
  • clientId string: Client id for block to check.

Returns

  • boolean: Whether the block is being dragged.

Top ↑

isBlockHighlighted

Returns true if the current highlighted block matches the block clientId.

Parameters

  • state Object: Global application state.
  • clientId string: The block to check.

Returns

  • boolean: Whether the block is currently highlighted.

Top ↑

isBlockInsertionPointVisible

Returns true if we should show the block insertion point.

Parameters

  • state Object: Global application state.

Returns

  • ?boolean: Whether the insertion point is visible or not.

Top ↑

isBlockMultiSelected

Returns true if the client ID occurs within the block multi-selection, or
false otherwise.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • boolean: Whether block is in multi-selection set.

Top ↑

isBlockSelected

Returns true if the block corresponding to the specified client ID is
currently selected and no multi-selection exists, or false otherwise.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • boolean: Whether block is selected and multi-selection exists.

Top ↑

isBlockValid

Returns whether a block is valid or not.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • boolean: Is Valid.

Top ↑

isBlockWithinSelection

Returns true if the block corresponding to the specified client ID is
currently selected but isn’t the last of the selected blocks. Here “last”
refers to the block sequence in the document, not the sequence of
multi-selection, which is why state.selectionEnd isn’t used.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • boolean: Whether block is selected and not the last in the selection.

Top ↑

isCaretWithinFormattedText

Deprecated

Returns true if the caret is within formatted text, or false otherwise.

Returns

  • boolean: Whether the caret is within formatted text.

Top ↑

isDraggingBlocks

Returns true if the user is dragging blocks, or false otherwise.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether user is dragging blocks.

Top ↑

isFirstMultiSelectedBlock

Returns true if a multi-selection exists, and the block corresponding to the
specified client ID is the first block of the multi-selection set, or false
otherwise.

Parameters

  • state Object: Editor state.
  • clientId string: Block client ID.

Returns

  • boolean: Whether block is first in multi-selection.

Top ↑

isLastBlockChangePersistent

Returns true if the most recent block change is be considered persistent, or
false otherwise. A persistent change is one committed by BlockEditorProvider
via its onChange callback, in addition to onInput.

Parameters

  • state Object: Block editor state.

Returns

  • boolean: Whether the most recent block change was persistent.

Top ↑

isMultiSelecting

Whether in the process of multi-selecting or not. This flag is only true
while the multi-selection is being selected (by mouse move), and is false
once the multi-selection has been settled.

Related

  • hasMultiSelection

Parameters

  • state Object: Global application state.

Returns

  • boolean: True if multi-selecting, false if not.

Top ↑

isNavigationMode

Returns whether the navigation mode is enabled.

Parameters

  • state Object: Editor state.

Returns

  • boolean: Is navigation mode enabled.

Top ↑

isSelectionEnabled

Selector that returns if multi-selection is enabled or not.

Parameters

  • state Object: Global application state.

Returns

  • boolean: True if it should be possible to multi-select blocks, false if multi-selection is disabled.

Top ↑

isTyping

Returns true if the user is typing, or false otherwise.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether user is typing.

Top ↑

isValidTemplate

Returns whether the blocks matches the template or not.

Parameters

  • state boolean:

Returns

  • ?boolean: Whether the template is valid or not.

Top ↑

wasBlockJustInserted

Tells if the block with the passed clientId was just inserted.

Parameters

  • state Object: Global application state.
  • clientId Object: Client Id of the block.
  • source ?string: Optional insertion source of the block.

Returns

  • boolean: True if the block matches the last block inserted from the specified source.

Top ↑

Actions

Top ↑

clearSelectedBlock

Action that clears the block selection.

Returns

  • Object: Action object.

Top ↑

duplicateBlocks

Action that duplicates a list of blocks.

Parameters

  • clientIds string[]:
  • updateSelection boolean:

Top ↑

enterFormattedText

Deprecated

Returns an action object used in signalling that the caret has entered formatted text.

Returns

  • Object: Action object.

Top ↑

exitFormattedText

Deprecated

Returns an action object used in signalling that the user caret has exited formatted text.

Returns

  • Object: Action object.

Top ↑

flashBlock

Action that “flashes” the block with a given clientId by rhythmically highlighting it.

Parameters

  • clientId string: Target block client ID.

Top ↑

hideInsertionPoint

Action that hides the insertion point.

Returns

  • Object: Action object.

Top ↑

insertAfterBlock

Action that inserts an empty block after a given block.

Parameters

  • clientId string:

Top ↑

insertBeforeBlock

Action that inserts an empty block before a given block.

Parameters

  • clientId string:

Top ↑

insertBlock

Action that inserts a single block, optionally at a specific index respective a root block list.

Parameters

  • block Object: Block object to insert.
  • index ?number: Index at which block should be inserted.
  • rootClientId ?string: Optional root client ID of block list on which to insert.
  • updateSelection ?boolean: If true block selection will be updated. If false, block selection will not change. Defaults to true.
  • meta ?Object: Optional Meta values to be passed to the action object.

Returns

  • Object: Action object.

Top ↑

insertBlocks

Action that inserts an array of blocks, optionally at a specific index respective a root block list.

Parameters

  • blocks Object[]: Block objects to insert.
  • index ?number: Index at which block should be inserted.
  • rootClientId ?string: Optional root client ID of block list on which to insert.
  • updateSelection ?boolean: If true block selection will be updated. If false, block selection will not change. Defaults to true.
  • initialPosition 0|-1|null: Initial focus position. Setting it to null prevent focusing the inserted block.
  • meta ?Object: Optional Meta values to be passed to the action object.

Returns

  • Object: Action object.

Top ↑

insertDefaultBlock

Action that adds a new block of the default type to the block list.

Parameters

  • attributes ?Object: Optional attributes of the block to assign.
  • rootClientId ?string: Optional root client ID of block list on which to append.
  • index ?number: Optional index where to insert the default block.

Top ↑

mergeBlocks

Action that merges two blocks.

Parameters

  • firstBlockClientId string: Client ID of the first block to merge.
  • secondBlockClientId string: Client ID of the second block to merge.

Top ↑

moveBlocksDown

Undocumented declaration.

Top ↑

moveBlocksToPosition

Action that moves given blocks to a new position.

Parameters

  • clientIds ?string: The client IDs of the blocks.
  • fromRootClientId ?string: Root client ID source.
  • toRootClientId ?string: Root client ID destination.
  • index number: The index to move the blocks to.

Top ↑

moveBlocksUp

Undocumented declaration.

Top ↑

moveBlockToPosition

Action that moves given block to a new position.

Parameters

  • clientId ?string: The client ID of the block.
  • fromRootClientId ?string: Root client ID source.
  • toRootClientId ?string: Root client ID destination.
  • index number: The index to move the block to.

Top ↑

multiSelect

Action that changes block multi-selection.

Parameters

  • start string: First block of the multi selection.
  • end string: Last block of the multiselection.
  • __experimentalInitialPosition number|null: Optional initial position. Pass as null to skip focus within editor canvas.

Top ↑

receiveBlocks

Deprecated

Returns an action object used in signalling that blocks have been received.
Unlike resetBlocks, these should be appended to the existing known set, not
replacing.

Parameters

  • blocks Object[]: Array of block objects.

Returns

  • Object: Action object.

Top ↑

removeBlock

Returns an action object used in signalling that the block with the
specified client ID is to be removed.

Parameters

  • clientId string: Client ID of block to remove.
  • selectPrevious boolean: True if the previous block should be selected when a block is removed.

Returns

  • Object: Action object.

Top ↑

removeBlocks

Yields action objects used in signalling that the blocks corresponding to
the set of specified client IDs are to be removed.

Parameters

  • clientIds string|string[]: Client IDs of blocks to remove.
  • selectPrevious boolean: True if the previous block should be selected when a block is removed.

Top ↑

replaceBlock

Action that replaces a single block with one or more replacement blocks.

Parameters

  • clientId (string|string[]): Block client ID to replace.
  • block (Object|Object[]): Replacement block(s).

Returns

  • Object: Action object.

Top ↑

replaceBlocks

Action that replaces given blocks with one or more replacement blocks.

Parameters

  • clientIds (string|string[]): Block client ID(s) to replace.
  • blocks (Object|Object[]): Replacement block(s).
  • indexToSelect number: Index of replacement block to select.
  • initialPosition 0|-1|null: Index of caret after in the selected block after the operation.
  • meta ?Object: Optional Meta values to be passed to the action object.

Returns

  • Object: Action object.

Top ↑

replaceInnerBlocks

Returns an action object used in signalling that the inner blocks with the
specified client ID should be replaced.

Parameters

  • rootClientId string: Client ID of the block whose InnerBlocks will re replaced.
  • blocks Object[]: Block objects to insert as new InnerBlocks
  • updateSelection ?boolean: If true block selection will be updated. If false, block selection will not change. Defaults to false.
  • initialPosition 0|-1|null: Initial block position.

Returns

  • Object: Action object.

Top ↑

resetBlocks

Action that resets blocks state to the specified array of blocks, taking precedence
over any other content reflected as an edit in state.

Parameters

  • blocks Array: Array of blocks.

Top ↑

resetSelection

Returns an action object used in signalling that selection state should be
reset to the specified selection.

Parameters

  • selectionStart WPBlockSelection: The selection start.
  • selectionEnd WPBlockSelection: The selection end.
  • initialPosition 0|-1|null: Initial block position.

Returns

  • Object: Action object.

Top ↑

selectBlock

Returns an action object used in signalling that the block with the
specified client ID has been selected, optionally accepting a position
value reflecting its selection directionality. An initialPosition of -1
reflects a reverse selection.

Parameters

  • clientId string: Block client ID.
  • initialPosition 0|-1|null: Optional initial position. Pass as -1 to reflect reverse selection.

Returns

  • Object: Action object.

Top ↑

selectionChange

Action that changes the position of the user caret.

Parameters

  • clientId string|WPSelection: The selected block client ID.
  • attributeKey string: The selected block attribute key.
  • startOffset number: The start offset.
  • endOffset number: The end offset.

Returns

  • Object: Action object.

Top ↑

selectNextBlock

Yields action objects used in signalling that the block following the given
clientId should be selected.

Parameters

  • clientId string: Block client ID.

Top ↑

selectPreviousBlock

Yields action objects used in signalling that the block preceding the given
clientId should be selected.

Parameters

  • clientId string: Block client ID.

Top ↑

setBlockMovingClientId

Action that enables or disables the block moving mode.

Parameters

  • hasBlockMovingClientId string|null: Enable/Disable block moving mode.

Top ↑

setHasControlledInnerBlocks

Action that sets whether a block has controlled inner blocks.

Parameters

  • clientId string: The block’s clientId.
  • hasControlledInnerBlocks boolean: True if the block’s inner blocks are controlled.

Top ↑

setNavigationMode

Action that enables or disables the navigation mode.

Parameters

  • isNavigationMode string: Enable/Disable navigation mode.

Top ↑

setTemplateValidity

Action that resets the template validity.

Parameters

  • isValid boolean: template validity flag.

Returns

  • Object: Action object.

Top ↑

showInsertionPoint

Action that shows the insertion point.

Parameters

  • rootClientId ?string: Optional root client ID of block list on which to insert.
  • index ?number: Index at which block should be inserted.
  • __unstableOptions Object: Whether or not to show an inserter button.

Returns

  • Object: Action object.

Top ↑

startDraggingBlocks

Returns an action object used in signalling that the user has begun to drag blocks.

Parameters

  • clientIds string[]: An array of client ids being dragged

Returns

  • Object: Action object.

Top ↑

startMultiSelect

Action that starts block multi-selection.

Returns

  • Object: Action object.

Top ↑

startTyping

Returns an action object used in signalling that the user has begun to type.

Returns

  • Object: Action object.

Top ↑

stopDraggingBlocks

Returns an action object used in signalling that the user has stopped dragging blocks.

Returns

  • Object: Action object.

Top ↑

stopMultiSelect

Action that stops block multi-selection.

Returns

  • Object: Action object.

Top ↑

stopTyping

Returns an action object used in signalling that the user has stopped typing.

Returns

  • Object: Action object.

Top ↑

synchronizeTemplate

Action that synchronizes the template with the list of blocks.

Returns

  • Object: Action object.

Top ↑

toggleBlockHighlight

Action that toggles the highlighted block state.

Parameters

  • clientId string: The block’s clientId.
  • isHighlighted boolean: The highlight state.

Top ↑

toggleBlockMode

Returns an action object used to toggle the block editing mode between
visual and HTML modes.

Parameters

  • clientId string: Block client ID.

Returns

  • Object: Action object.

Top ↑

toggleSelection

Action that enables or disables block selection.

Parameters

  • isSelectionEnabled [boolean]: Whether block selection should be enabled.

Returns

  • Object: Action object.

Top ↑

updateBlock

Action that updates the block with the specified client ID.

Parameters

  • clientId string: Block client ID.
  • updates Object: Block attributes to be merged.

Returns

  • Object: Action object.

Top ↑

updateBlockAttributes

Action that updates attributes of multiple blocks with the specified client IDs.

Parameters

  • clientIds string|string[]: Block client IDs.
  • attributes Object: Block attributes to be merged. Should be keyed by clientIds if uniqueByBlock is true.
  • uniqueByBlock boolean: true if each block in clientIds array has a unique set of attributes

Returns

  • Object: Action object.

Top ↑

updateBlockListSettings

Action that changes the nested settings of a given block.

Parameters

  • clientId string: Client ID of the block whose nested setting are being received.
  • settings Object: Object with the new settings for the nested block.

Returns

  • Object: Action object

Top ↑

updateSettings

Action that updates the block editor settings.

Parameters

  • settings Object: Updated settings

Returns

  • Object: Action object

Top ↑

validateBlocksToTemplate

Block validity is a function of blocks state (at the point of a
reset) and the template setting. As a compromise to its placement
across distinct parts of state, it is implemented here as a side-
effect of the block reset action.

Parameters

  • blocks Array: Array of blocks.