-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocks: Normalize RichText value from string (as HTML), children #10370
Conversation
Adding to 4.0 as we need a solid compat plan for RichText before releasing its format changes. |
Can we prevent the following format from leaking into templates for posts and inner blocks? [ 'core/paragraph', [
'content' => [
'text' => 'Hello world!',
'formats' => [
null,
null,
null,
null,
null,
null,
[ [ 'type' => 'strong' ] ],
[ [ 'type' => 'strong' ] ],
[ [ 'type' => 'strong' ] ],
[ [ 'type' => 'strong' ] ],
[ [ 'type' => 'strong' ] ],
null
],
],
] ], |
…e normalization in createBlock
I made some updates to this PR. The idea is to only support the "element/children" format for templates (which is what we currently do prior to 4.0) and also updates the code to avoid baking it in Also, I'm fixing the "nested" attributes normalization (query sources) so, something like that would work: add_action( 'init', function() {
register_post_type( 'book', [
'label' => 'Book',
'show_in_rest' => true,
'public' => true,
'show_ui' => true,
'supports' => [ 'title', 'editor' ],
'template' => [
[ 'core/paragraph', [
'content' => 'Hello first paragraph!',
] ],
[ 'core/paragraph', [
'content' => [
'Hello ',
[
'type' => 'strong',
'props' => [ 'children' => 'world' ]
],
'!'
],
] ],
[ 'core/gallery', [
'images' => [
[
'url' => 'https://picsum.photos/200/300',
'caption' => [
'Hello ',
[
'type' => 'strong',
'props' => [ 'children' => 'world' ]
],
'!'
]
]
],
] ],
],
'template_lock' => 'all',
] );
} ); |
result[ key ] = [ result[ key ] ]; | ||
} else if ( ! Array.isArray( result[ key ] ) ) { | ||
result[ key ] = []; | ||
// the RichText getColorObjectByAttributeValuescomponent to handle the deprecated value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this copy and paste issue getColorObjectByAttributeValuescomponent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahaha :) sorry about that
Superseded by #10439. |
The idea of this PR is to ensure previous templates still work while avoiding leaking the new RichText structure format into the format of the templates.