wp-rest-blocks icon indicating copy to clipboard operation
wp-rest-blocks copied to clipboard

Plugin breaks on block editor WordPress 5.9 RC

Open adambrgmn opened this issue 2 years ago • 9 comments

Hey! I'm testing out the latest version of WP, 5.9 on a small project. And right now it seems like this plugin breaks the block editor. This plugin seems to prevent rendering post content in the editor at all.

I think the issue is naming the field in the api blocks. Because if I rename the field to something different the editor works as expected again. I haven't been able to find the real issue in the gutenberg code. But I'm guessing that they somehow populate the blocks property in the code. But when it is already set initially they don't touch it. I'm not sure but will keep digging deeper.

adambrgmn avatar Jan 24 '22 07:01 adambrgmn

I did some more testing and my assumption seem to be more or less correct.

The following code in the terminal when editing a post:

window.wp.data.select('core/block-editor').getBlocks()

Prints a block with the same shape and structure as this plugin generates. But that is not the shape that the editor expects.

adambrgmn avatar Jan 24 '22 08:01 adambrgmn

@adambrgmn Hey, did you find a fix for this ?

erralb avatar Mar 02 '22 13:03 erralb

@erralb No proper fix. I brought the whole plugin into my own source and renamed the api field to something like wp_blocks instead.

adambrgmn avatar Mar 03 '22 09:03 adambrgmn

@adambrgmn thanks for your response.

As a workaround, I installed the "Free Soul Deactivate Plugins" plugin and I deactivated the WP Rest Blocks plugin when editing posts / using Gutenberg : https://wordpress.org/support/topic/deactivate-plugins-on-editor-gutenberg/

It's fixing the block editor, but I still have to check if the blocks are correctly queried through the API.

erralb avatar Mar 03 '22 10:03 erralb

For now I am using this hotfix plugin that renames the blocks attribute to parsed_blocks (but only if we are in the block editor).

https://gist.github.com/lukasbesch/ed9cdd5c7df0eb620b2b9cb48fd7935c

I could not find out yet why exactly blocks does not work as an attribute. As the fix is only needed for the block editor I assumed it has something to do with the internal/preloaded requests. But even if I forcefully do not preload the current post with edit context, it does not work. So somewhere in the initialisation of the block editor something breaks with the blocks key.

lukasbesch avatar Apr 12 '22 22:04 lukasbesch

I am seeing this issue on Wordpress 6.0.1.

I love this plugin, I was able to make an awesome website with it by pulling the images out of the gallery block. But now, on both the Wordpress website and the Wordpress app, my posts don't show the gallery blocks. I have to disable the plugin to be able to edit or see anything.

It would be great if this feature could make it as an official Wordpress feature in the REST api. I believe this is the ticket on the Wordpress tracker.

sahandnayebaziz avatar Jul 31 '22 18:07 sahandnayebaziz

I am seeing this issue on Wordpress 6.0.1.

I love this plugin, I was able to make an awesome website with it by pulling the images out of the gallery block. But now, on both the Wordpress website and the Wordpress app, my posts don't show the gallery blocks. I have to disable the plugin to be able to edit or see anything.

It would be great if this feature could make it as an official Wordpress feature in the REST api. I believe this is the ticket on the Wordpress tracker.

That ticket was last modified 2 years ago. This is not looking good.

It's a shame, this one little feature could really modernize WordPress a lot, by allowing Gutenberg to be used as a headless CMS editor.

FalkoJoseph avatar Dec 18 '23 21:12 FalkoJoseph

I have since migrated to Sanity, but if someday all block data comes through over the API on Wordpress, I'll be right back to using it!

sahandnayebaziz avatar Dec 18 '23 21:12 sahandnayebaziz

I have since migrated to Sanity, but if someday all block data comes through over the API on Wordpress, I'll be right back to using it!

I'm currently working on a starterkit using Astro as the front-end and WordPress as the backend.

So far I'm not running into any problems whatsoever. I do however stick to ACF blocks instead of Gutenberg blocks, since the Gutenberg API & structure changes way too frequently and is more prone to bugs.

Also in a headless setup, native Gutenberg doesn't make too much sense anyway, since you'd have to maintain the live preview mode in WordPress as well.

Hope this helps, if you're ever planning to use WordPress with this plugin again. :)

FalkoJoseph avatar Dec 18 '23 22:12 FalkoJoseph