Description
When a raw transform returns an array of blocks instead of a single block, the result doesn't get handled correctly.
Step-by-step reproduction instructions
-
In the registerBlockType() call of a test block (using npx @wordpress/create-block test-block or something), add a transform like so:
transforms: {
from: [
{
type: 'raw',
isMatch: () => true,
transform: () => {
const blocks = [
createBlock( 'create-block/test-block' ),
createBlock( 'create-block/test-block' ),
];
return blocks; /* doesn't work */
// return blocks[ 0 ]; /* this works */
},
},
],
},
-
Go to the editor at /wp-admin/post-new.php and paste a string like <p>test block</p>.
Expected behaviour
The pasted string is transformed into two 'create-block/test-block' blocks.
Actual behaviour
Nothing happens (the pasted string just disappears without any error messages).
WordPress information
- WordPress version: 5.7-alpha-49991
- Gutenberg version: Current
master (9.8.0 ?)
- Are all plugins except Gutenberg deactivated? Yes
- Are you using a default theme (e.g. Twenty Twenty-One)? Yes
Device information
- Device: Desktop
- Operating system: macOS 10.15.7
- Browser: Chrome 87.0.4280.141
Description
When a
rawtransform returns an array of blocks instead of a single block, the result doesn't get handled correctly.Step-by-step reproduction instructions
In the
registerBlockType()call of a test block (usingnpx @wordpress/create-block test-blockor something), add a transform like so:Go to the editor at
/wp-admin/post-new.phpand paste a string like<p>test block</p>.Expected behaviour
The pasted string is transformed into two
'create-block/test-block'blocks.Actual behaviour
Nothing happens (the pasted string just disappears without any error messages).
WordPress information
master(9.8.0 ?)Device information