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

"Convert to Blocks" fails if the block is not allowed by 'allowed_block_types_all' #66620

Open
3 of 6 tasks
kyletcooper opened this issue Oct 30, 2024 · 1 comment
Open
3 of 6 tasks
Labels
[Feature] Convert to Blocks Internally: "raw handler" [Type] Bug An existing feature does not function as intended

Comments

@kyletcooper
Copy link

Description

Attempting to "Convert to Blocks" silently fails on installations if the chosen block for a section of HTML is not allowed by the theme/plugin.

I ran into this because of old posts that have paragraphs containing a single URL (I narrowed it down to this by deleting chunks of the content until I found this was the offending HTML). These can't be converted because the converter tries to turn them into a URL Embed block but can't because that block is filtered out out using allowed_block_types_all. I'd expect this to just go to the next best block (core/paragraph) if that block isn't available.

From a brief look I think this is happening in htmlToBlocks where getRawTransforms is possibly including transforms for disallowed blocks? I'm not very familiar with this area of WordPress so that might be incorrect.

Step-by-step reproduction instructions

  1. Disable the URL Embed block using allowed_block_types_all.
  2. Create a new post.
  3. Enter the Code Editor view.
  4. Paste <p>https://www.example.com/</p>.
  5. Return to Visual Editor view.
  6. Attempt to "Convert to Blocks" on the Classic Block this creates.
  7. Nothing happens.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@kyletcooper kyletcooper added the [Type] Bug An existing feature does not function as intended label Oct 30, 2024
@kyletcooper kyletcooper changed the title "Convert to Blocks" fails if the block is not now allowed by 'allowed_block_types_all' "Convert to Blocks" fails if the block is not allowed by 'allowed_block_types_all' Oct 30, 2024
@Mamaduka
Copy link
Member

Mamaduka commented Oct 31, 2024

Thanks for contributing, @kyletcooper!

The cause of the bug looks similar to or a duplicate of the following issues - #11245 and #27835.

@Mamaduka Mamaduka added the [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable label Oct 31, 2024
@ellatrix ellatrix added [Feature] Convert to Blocks Internally: "raw handler" and removed [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable labels Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Convert to Blocks Internally: "raw handler" [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants