Skip to content

Raw transforms that return an array of blocks don't get handled correctly #28370

@mirka

Description

@mirka

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

  1. 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 */
    			},
    		},
    	],
    },
  2. 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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions