Back in TMCE days, we could easily get editor content with editor.getContent()
. However in new Gutenberg editor, I can't find a method to do that.
I need all editor content as HTML (the way it will be saved in database).
I found wp.block.serialize()
method which sounds promising. But seems to need blocks (as a parameter). So I'm kind of stuck.
As of version 3.1. of Gutenberg, try this:
to get the plain block content:
var originalContent = wp.data.select( "core/editor" ).getCurrentPost().content;
var editedContent = wp.data.select( "core/editor" ).getEditedPostContent();
to render the post (transform to blocks):
wp.blocks.parse( editedContent );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With