Gutenberg is a Javascript editor that runs in your browser. Postie is a server script that runs via wp-cron. There is no browser running when Postie does it’s work so it would be very challenging.
Thread Starter
markc
(@markc)
But surely whatever settings are persisted in the database when a user selects “convert to blocks” could be automated similar to what this plugin does?
https://wordpress.org/plugins/bulk-block-converter/
They aren’t settings – the markup is very different. All the Gutenberg logic is written in JavaScript which is not available when Postie imports the email.
There is work happening to make this available in non-JavaScript environments but it isn’t available yet.
https://core.trac.wordpress.org/ticket/47375
When that function (serialize_block) is officially available in PHP then Postie can make use of it.
Thread Starter
markc
(@markc)
Thanks for the explanation. According to that ticket in the last comment, the serialize_block functions were added to v5.3.1 quite a few months ago. Or do you mean that PHP core (not WP) needs to have a serialize_block() function too?
https://core.trac.wordpress.org/ticket/47375#comment:14
I’ll take a look but since it is still under review I’m not sure how much it can be relied upon.
Turns out this function does not transform a classic post into a blocks post. It just transforms block markup into PHP objects and vice versa.
It allows you to manipulate a blocks based post in PHP, but doesn’t do any converting.
I could wrap a Postie post in the blocks markup for a custom html block, but I don’t know if that would make any difference for you.