Skip to content

Block Transforms: Need to explicitly include metadata when creating block #71922

@t-hamano

Description

@t-hamano

What problem does this address?

We're considering moving the blockCommentId attribute from the root level into metadata.

While working on #71921, I noticed that block custom names and block comment ID disappear when a block is transformed.

This occurs when using certain attributes when executing createBlock, like this:

transform: ( { content } ) => {
	return createBlock( 'core/test', {
		content,
	} );
},

What is your proposed solution?

To properly maintain both the custom names and block comment IDs, we will probably need to go through all of the transforms.js files and change the code to something like this:

transform: ( { content, metadata } ) => {
	return createBlock( 'core/test', {
		content,
		metadata: getTransformedMetadata( metadata, 'core/test' ),
	} );
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Block TransformsBlock transforms from one block to another[Type] BugAn existing feature does not function as intended

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions