diff --git a/packages/block-library/src/query/index.js b/packages/block-library/src/query/index.js index 0a60e6c81e255..0a70eadd005af 100644 --- a/packages/block-library/src/query/index.js +++ b/packages/block-library/src/query/index.js @@ -77,7 +77,10 @@ export default function addDisplayKeyToBlockMetadata( } return { ...blockSettings, - [ blockMetadataDisplayKey ]: { role: 'content' }, + supports: { + ...blockSettings.supports, + [ blockMetadataDisplayKey ]: { role: 'content' }, + }, }; } diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index 4fc9ee1bb0981..507aaaec8f758 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -177,11 +177,9 @@ function getBlockSettingsFromMetadata( { textdomain, ...metadata } ) { ]; const settings = Object.fromEntries( - Reflect.ownKeys( metadata ) - .map( ( key ) => [ key, metadata[ key ] ] ) - .filter( ( [ key ] ) => - allowedFields.some( ( field ) => field === key ) - ) + Object.entries( metadata ).filter( ( [ key ] ) => + allowedFields.includes( key ) + ) ); if ( textdomain ) { diff --git a/packages/blocks/src/api/utils.js b/packages/blocks/src/api/utils.js index e4e443032a344..4d3fcebaab92d 100644 --- a/packages/blocks/src/api/utils.js +++ b/packages/blocks/src/api/utils.js @@ -374,7 +374,7 @@ export const __experimentalGetBlockAttributesNamesByRole = ( ...args ) => { export function isContentBlock( name ) { const blockType = getBlockType( name ); - if ( blockType?.[ blockMetadataDisplayKey ]?.role === 'content' ) { + if ( blockType.supports?.[ blockMetadataDisplayKey ]?.role === 'content' ) { return true; } diff --git a/packages/blocks/src/store/reducer.js b/packages/blocks/src/store/reducer.js index d1714e3f2bce5..ac652b9189031 100644 --- a/packages/blocks/src/store/reducer.js +++ b/packages/blocks/src/store/reducer.js @@ -95,17 +95,14 @@ function bootstrappedBlockTypes( state = {}, action ) { } } else { newDefinition = Object.fromEntries( - Reflect.ownKeys( blockType ) + Object.entries( blockType ) .filter( - ( key ) => - blockType[ key ] !== null && - blockType[ key ] !== undefined + ( [ , value ] ) => + value !== null && value !== undefined ) - .map( ( key ) => [ - typeof key === 'symbol' - ? key - : camelCase( key.toString() ), - blockType[ key ], + .map( ( [ key, value ] ) => [ + camelCase( key ), + value, ] ) ); newDefinition.name = name;