WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.58k stars 4.23k forks source link

Cannot apply formatting when block bindings are present #67479

Open saulyz opened 2 days ago

saulyz commented 2 days ago

What problem does this address?

Block with the bindings cannot be formatted. When the block has binding - the formatting controls in the BlockControls Toolbars are not shown. I understand that this is a complication. The formatting usually changes content attribute and the formatting state is saved in the content (examples: 1) the addition of <strong> tags, the wrapping text with <span class="my-custom-format">. When we apply bindings the content is being overriden and the formatting info is lost.

Image

What is your proposed solution?

"Additional CSS class" field and related attribute theoretically could be a saver, but it it is very limited and cannot fulfil the formatting of the content part. Maybe additional attribute fields inside "metadata" could pass the formatting info?

The test case is with translation shortcode. The formatting within the paragraph applies to inner elements: span, strong, etc..


<p><span class="text-size-paragraph h3-alike">[l10n id="007_INTRO_PARAGRAPH_NORWAY_ROAD_TRIP" /]</span></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><span class="text-size-paragraph text-xlarge">Default formatted <span class="text-color-paragraph color-accent">content</span> that will have <strong>post meta</strong> binding.</span></p>
<!-- /wp:paragraph -->```
SantosGuillamot commented 2 days ago

Thanks for raising this concern, @saulyz 🙂 As you say, the problem comes because the formatting modifies the content attribute and bindings override that. It could theoretically be solved by applying the HTML tags to the connected source, but I think that could cause unexpected behaviors. Maybe a mechanism to apply formatting to the whole source value could be explored.

On another note, I also believe Bits/Dynamic tokens could help here. They connect pieces of HTML instead of block attributes, so I can see that working in this use case.