I’m trying to make my plugin "Gutenburg – compatible". I have some issues when replacing the editors contents. Before I could just change value by using #content but with Gutenburg there’s obviously a new approach with REST API.
Is there a way to grab the current value of the editor? (Not the saved value of the post!)
I want this because I want to replace values of the core/editor in realtime. It works with the classic editor active but I don’t want to require that.
let old_content = ''; old_content = wp.data.select( 'core/editor' ).getCurrentPost().content; //TINYMCE => old_content = $ ('textarea#content').html(); //Aim is to do a replace like this (and this works but only FIRST time because old_content //fetches from server/db instead of the actual editor (If I understand this correctly) wp.data.dispatch( 'core/block-editor' ).resetBlocks( wp.blocks.parse( new_content ) ); //TINYMCE: $ ('textarea#content').html( new_content );