Skip to content
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

Pasting valid Gutenberg block markup throws a "unexpected or invalid mark-up" error #2475

Open
4 tasks done
dsas opened this issue Jan 26, 2023 · 2 comments
Open
4 tasks done
Labels
[Priority] Low This issue/pull request is not immediate [Type] Bug Something that is not working as expected

Comments

@dsas
Copy link

dsas commented Jan 26, 2023

Describe the bug:

I should be able to paste some valid Gutenberg block-markup into the editor without it erroring.

To reproduce:

  1. Install co-blocks (can't reproduce without)
  2. Open the post editor
  3. 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 -->
  1. 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:

image

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:

  • This bug happens with no other plugins activated
  • This bug happens with a default WordPress theme active (can repro with TT3 and non-default themes)
  • This bug happens without the Gutenberg plugin active (can also repro with gutenberg trunk)
  • 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.

@dsas dsas added [Priority] Low This issue/pull request is not immediate [Type] Bug Something that is not working as expected labels Jan 26, 2023
@olafleur-godaddy
Copy link
Member

Thanks for the report!

@olafleur-godaddy
Copy link
Member

Reproduced in CoBlocks 2.25.5 with WP 6.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] Low This issue/pull request is not immediate [Type] Bug Something that is not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants