Skip to content

Commit

Permalink
Block Hooks: Set ignoredHookedBlocks metada attr upon insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Feb 1, 2024
1 parent a006a4b commit 5ff53fc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1936,9 +1936,26 @@ const buildBlockTypeItem =
blockType.name,
'inserter'
);

let initialAttributes = {};

const hookedBlocksForCurrentBlock = getBlockTypes()?.filter(
( { blockHooks } ) => blockHooks && id in blockHooks
);

if ( hookedBlocksForCurrentBlock?.length ) {
initialAttributes = {
metadata: {
ignoredHookedBlocks: hookedBlocksForCurrentBlock.map(
( { name } ) => name
),
},
};
}

return {
...blockItemBase,
initialAttributes: {},
initialAttributes,
description: blockType.description,
category: blockType.category,
keywords: blockType.keywords,
Expand Down

0 comments on commit 5ff53fc

Please sign in to comment.