-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Labels
[Feature] Block TransformsBlock transforms from one block to anotherBlock transforms from one block to another[Package] Blocks/packages/blocks/packages/blocks[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
When an array is provided to classes: property in transforms, during the mergeSchemas part of getBlockContentSchemaFromTransforms, the array gets converted into object.
This only happens when the first rawTranformSchema doesn't have classes property in it.
If the first schema has classes then every other schema's classes stays as array.
Step-by-step reproduction instructions
- Create 2 blocks.
- Register them.
- Add following Transform to the first block
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
import metadata from './block.json';
// FIRST CUSTOM BLOCK TO REGISTER
function el(node) {
return createBlock(metadata.name, {
content: node.innerHTML,
});
}
function schema() {
return {
ol: {
classes: ['*'],
children: '*',
},
};
}
const transforms = {
from: [
{
type: 'raw',
selector: 'ol',
schema: schema,
transform: el,
priority: 9,
},
],
};
export default transforms;- Add following transform to the second block.
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
import metadata from './block.json';
// SECOND CUSTOM BLOCK TO REGISTER
function el(node) {
return createBlock(metadata.name, {
content: node.innerHTML,
});
}
function schema() {
return {
ol: {
// classes: ['*'],
children: '*',
},
};
}
const transforms = {
from: [
{
type: 'raw',
selector: 'ol',
schema: schema,
transform: el,
priority: 20,
},
],
};
export default transforms;- Open a new post
- Paste the following content
<ol class="my-custom-ol list-decimal pl-5 text-gray-800">
<li class="my-custom-li">First item in the list</li>
<li class="my-custom-li">Second item in the list</li>
<li class="my-custom-li">Third item in the list</li>
</ol>Note: please run
npm run startinstead ofnpm run dev, I was not able to reproduce this error on dev but it is consistent on start.
Screenshots, screen recording, code snippet
Screen.Recording.2025-07-04.at.2.08.59.PM.mov
Environment info
- WordPress: 6.9-alpha-60272
- PHP: 8.2.28
- Server: Apache/2.4.62 (Debian)
- Database: mysqli (Server: 11.8.2-MariaDB-ubu2404 / Client: mysqlnd 8.2.28)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.2
- MU Plugins:
- Gutenberg Test Plugin, Disable Login Autofocus
- Gutenberg Test Plugin, Disable Remote Patterns
- Gutenberg Test Plugin, Enable Templates UI
- Gutenberg Test Plugin, No-cache Headers
- Gutenberg Test Plugin, Normalize Theme
- server-timing.php
- Plugins:
- aaaa 0.1.0 -- second custom block
- Example Static 0.1.0 -- first custom block
- Gutenberg 21.1.0
- Test Reports 1.2.0
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Feature] Block TransformsBlock transforms from one block to anotherBlock transforms from one block to another[Package] Blocks/packages/blocks/packages/blocks[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Type
Fields
Give feedbackNo fields configured for Bug.