Blocks: Normalize RichText value from string (as HTML), children#10370
Closed
Blocks: Normalize RichText value from string (as HTML), children#10370
Conversation
Contributor
|
Adding to 4.0 as we need a solid compat plan for RichText before releasing its format changes. |
Member
|
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
Contributor
|
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',
] );
} ); |
gziolo
reviewed
Oct 9, 2018
| result[ key ] = [ result[ key ] ]; | ||
| } else if ( ! Array.isArray( result[ key ] ) ) { | ||
| result[ key ] = []; | ||
| // the RichText getColorObjectByAttributeValuescomponent to handle the deprecated value. |
Member
There was a problem hiding this comment.
Is this copy and paste issue getColorObjectByAttributeValuescomponent?
Contributor
There was a problem hiding this comment.
hahaha :) sorry about that
This was referenced Oct 9, 2018
Member
|
Superseded by #10439. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.