WordPress / gutenberg

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

Auto convert to blocks #64129

Open ellatrix opened 1 month ago

ellatrix commented 1 month ago

Let's slowly try to auto convert classic content to blocks.

Ideas from @mtias: let's start small, don't do it for post types without revisions, maybe opt-in for non-exact conversions.

To do list:

Cc @azaozz @mtias

mtias commented 1 month ago

Another further thought on opt-in / opt-out: we could add a flag in wp_config : AUTO_CONVERT_TO_BLOCKS which could support a post type array argument.

azaozz commented 1 month ago

Been looking / thinking about this a bit and have few questions/comments:

  1. Perhaps it would be better to convert all "freeform" content in all cases, not only if this is an old post that has never been edited in Gutenberg and doesn't contain any blocks. There doesn't seem to be a good reason to have "loose HTML" between blocks. This may have been considered "parity with the old editor" but that was 5 years ago? :)
  2. Assuming after some content has been auto-converted, there will be a user-notice that would contain an "Undo" button. What should happen when a user clicks that Undo?
    • As far as I see best would be to "convert" the freeform content into HTML block(s). Otherwise will have to set some prop to prevent the auto-convert-to-blocks-on-load from happening the next time the post is opened for editing or it may get really annoying for some users. Creating HTML blocks from the freeform blocks has other advantages: better structure of the posts edited in the block editor (there will not be any "loose HTML" between blocks), no more need to run autop on displaying them, resolving the buginess/unexpected results around using setFreeformContentHandlerName, etc.
    • If the above sounds good, the HTML block would need some updates, mostly a "Convert to Blocks" button, and "Visual Editor" button that would load TinyMCE on demand.
    • If it doesn't sound good perhaps the core/freeform blocks can be made permanent, i.e. saved in the DB as any other block. Thinking this will still make it possible to not run autop on every page load on the front-end which will be a very nice speed improvement.
saulyz commented 1 month ago

Let's say we run a multisite. There can be various combinations among sites: a) run Gutenberg and have posts, pages (use block themes); b) run Gutenberg but use ACF on Custom Post types, c) run legacy themes with Classic editor on posts and pages.

I understand that suggested option AUTO_CONVERT_TO_BLOCKS would affect only group A. And for group C, only after migration to block themes this would start making impact.

As conversion to blocks is inevitable, this might not cause any real problem.

However there can be some situations to consider:

What would be very helpful with AUTO_CONVERT_TO_BLOCKS introduction is that we could mark all these posts as failing. And further maybe alert via log or email. The editors or authors might initiate the auto convert, but the administrators are ones to solve the issues. So flagging failing auto conversions would make a more efficient discovery.