Skip to content

Commit

Permalink
Add getBlockClientId docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jan 3, 2020
1 parent 48389d4 commit 96fd5fb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/block-editor/src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ export function hasInnerBlocksContext( element ) {
return !! element.querySelector( '.block-editor-block-list__layout' );
}

/**
* Finds the block client ID given any DOM node inside the block.
*
* @param {Node} node DOM node.
*
* @return {?string} Client ID or undefined if the node is not part of a block.
*/
export function getBlockClientId( node ) {
if ( node.nodeType !== node.ELEMENT_NODE ) {
node = node.parentElement;
Expand Down

0 comments on commit 96fd5fb

Please sign in to comment.