coblocks
coblocks copied to clipboard
Pasting valid Gutenberg block markup throws a "unexpected or invalid mark-up" error
Describe the bug:
I should be able to paste some valid Gutenberg block-markup into the editor without it erroring.
To reproduce:
- Install co-blocks (can't reproduce without)
- Open the post editor
- Paste the following, completely valid mark-up (or insert a pattern with the same):
<!-- wp:heading {"className":"has-custom-font","fontFamily":"dm-sans"} -->
<h2 class="wp-block-heading has-custom-font has-dm-sans-font-family">Summer<br>Vibe</h2>
<!-- /wp:heading -->
- See "This block contains unexpected or invalid content." message
The problem isn't limited to heading blocks, the same happens for paragraphs too (and probably more).
Expected behavior:
I expected a Heading block to be inserted without any mention of unexpected errors.
Screenshots:

Console output says:
Block validation: Block validation failed for `core/heading` (
Object { name: "core/heading", icon: {…}, keywords: (2) […], attributes: {…}, providesContext: {}, usesContext: [], supports: {…}, styles: [], variations: [], save: heading_save_save(_ref)
, … }
).
Content generated by `save` function:
<h2 class="wp-block-heading has-dm-sans-font-family has-custom-font" style="font-family:dm-sans">Summer<br>Vibe</h2>
Content retrieved from post body:
<h2 class="wp-block-heading has-custom-font has-dm-sans-font-family">Summer<br>Vibe</h2>
I think applyStyle is taking the fontFamily block attribute and putting it into the style prop, even though that's not necessary in Core.
Isolating the problem:
- [x] This bug happens with no other plugins activated
- [x] This bug happens with a default WordPress theme active (can repro with TT3 and non-default themes)
- [x] This bug happens without the Gutenberg plugin active (can also repro with gutenberg trunk)
- [x] I can reproduce this bug consistently using the steps above
WordPress version:
6.2
Gutenberg version:
Either trunk at the time of writing, GB1.15 or whatever WP6.2 ships.
Thanks for the report!
Reproduced in CoBlocks 2.25.5 with WP 6.1.1