Skip to content

Commit

Permalink
Add selector to retrieve sections
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 4, 2024
1 parent 32021a3 commit d099668
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,25 @@ export function isZoomOutMode( state ) {
return state.editorMode === 'zoom-out';
}

/**
* Retrieves the client ID for the block that is acting as the element
* which contains the "sections" of a template/post.
*
* @param {Object} state - The current state.
* @return {string|undefined} The root client ID for the section, or undefined if not set.
*/
export function getSectionRootClientId( state ) {
return state.settings?.[ sectionRootClientIdKey ];
}

/**
* Retrieves the client IDs for the individual "sections"
* within the current template/post.
*
* @param {Object} state - The current state.
* @return {Array} An array of client IDs for the blocks within the section.
*/
export function getSectionClientIds( state ) {
const sectionRootClientId = getSectionRootClientId( state );
return getBlockOrder( sectionRootClientId );
}

0 comments on commit d099668

Please sign in to comment.