@@ -34,6 +34,7 @@ import { useBlockProps } from '@wordpress/block-editor'
3434// Replaces the current block with a block made out of attributes.
3535const createBlockWithAttributes = ( blockName , attributes , innerBlocks , design ) => {
3636 const disabledBlocks = settings . stackable_block_states || { } // eslint-disable-line camelcase
37+ let hasSubstituted = false
3738
3839 // Recursively substitute core blocks to disabled Stackable blocks
3940 const traverseBlocksAndSubstitute = blocks => {
@@ -42,8 +43,13 @@ const createBlockWithAttributes = ( blockName, attributes, innerBlocks, design )
4243
4344 // Check if the new substituted block is still disabled
4445 while ( isDisabled ) {
46+ const previousBlockName = block [ 0 ]
4547 block = substituteCoreIfDisabled ( ...block , substitutionRules )
4648 isDisabled = block [ 0 ] in disabledBlocks && disabledBlocks [ block [ 0 ] ] === BLOCK_STATE . DISABLED
49+ // If the previous block is different from the new block, substitution has been made
50+ if ( ! hasSubstituted && previousBlockName !== block [ 0 ] ) {
51+ hasSubstituted = true
52+ }
4753 }
4854
4955 // Do a preorder traversal by subsituting first before traversing
@@ -60,6 +66,11 @@ const createBlockWithAttributes = ( blockName, attributes, innerBlocks, design )
6066
6167 innerBlocks = traverseBlocksAndSubstitute ( innerBlocks )
6268
69+ if ( hasSubstituted ) {
70+ // eslint-disable-next-line no-alert
71+ alert ( 'Notice: Disabled blocks in the design will be substituted with other Stackable or core blocks' )
72+ }
73+
6374 // const { replaceBlock } = dispatch( 'core/block-editor' )
6475
6576 // For wireframes, we'll need to apply any default block attributes to
0 commit comments