Skip to content

Commit

Permalink
Improve insertBlocks documentation to ensure it mentions reasons the …
Browse files Browse the repository at this point in the history
…action may fail silently (#50078)
  • Loading branch information
talldan authored Apr 26, 2023
1 parent 832da50 commit dcebabc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ _Parameters_

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

Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if a templateLock is active on the block list.

_Parameters_

- _block_ `Object`: Block object to insert.
Expand All @@ -1206,6 +1208,8 @@ _Returns_

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

Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if a templateLock is active on the block list.

_Parameters_

- _blocks_ `Object[]`: Block objects to insert.
Expand Down
7 changes: 7 additions & 0 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ export function moveBlockToPosition(
/**
* Action that inserts a single block, optionally at a specific index respective a root block list.
*
* Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
* a templateLock is active on the block list.
*
* @param {Object} block Block object to insert.
* @param {?number} index Index at which block should be inserted.
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
Expand Down Expand Up @@ -572,12 +575,16 @@ export function insertBlock(
/**
* Action that inserts an array of blocks, optionally at a specific index respective a root block list.
*
* Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
* a templateLock is active on the block list.
*
* @param {Object[]} blocks Block objects to insert.
* @param {?number} index Index at which block should be inserted.
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
* @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
* @param {?Object} meta Optional Meta values to be passed to the action object.
*
* @return {Object} Action object.
*/
export const insertBlocks =
Expand Down

0 comments on commit dcebabc

Please sign in to comment.