If someone stumbles upon same issue I found a way to achieve what I wanted (I hope someone is helped by this).
This is my solution: getEditedPostContent()
contains the temporary post (modified) content:
let old_content="";
if ($('textarea#content').length >0) {
old_content = $('textarea#content').html();
}
else {
//"Gutenburg" style (>=WP 5.8)
old_content = wp.data.select( 'core/editor' ).getCurrentPost().content;
if ( wp.data.select( 'core/editor' ).getEditedPostContent() ) {
old_content = wp.data.select( 'core/editor' ).getEditedPostContent();
}
}
And the actual replacement:
if ($('textarea#content').length >0) {
$('textarea#content').html( new_content );
}
else {
//"Gutenburg" style (>=WP 5.8)
wp.data.dispatch( 'core/block-editor' ).resetBlocks( wp.blocks.parse( new_content ) );
}
Related Posts:
- Gutenberg – button to parse and format all blocks?
- Where’s the Block Template Feature in WordPress?
- Gutenberg: Block validation failed
- Change order/position of Gutenberg inspector control panel
- Gutenberg Inspector Controls
- serialize_blocks breaking html tags in content
- How to use getBlockIndex
- Hide or show Gutenberg custom block using date range
- Use page Title in Gutenberg custom banner block
- How to add code to `head` with WordPress 5.9 FSE (Full Site Editing)
- Block Editor: add an aria-label to an option inside a SelectControl
- Gutenberg: Get All Attributes From «core/image» Block
- How to make the Preview button automatically open new tab?
- Gutenberg: How can I disable backspace key from deleting an empty paragraph block?
- Integrating inline tinymce editor in a component for a gutenberg block
- Where on Github, or elsewhere, can I find the code for core-blocks?
- Gutenberg translation is not working
- How to add javascript function in the “save()” of gutenberg block?
- How to check if current admin page is Gutenberg editor? [duplicate]
- Possible add color palette for a block’s inner div instead of outer?
- Programmatically trigger the gutenberg save
- Gutenberg : in the backend, I just want to store a JSON object
- wordpress gutenberg url popover custom options
- Text Editors Are Hiding Text
- Disabling deleting reusable blocks except on the reusable block manager
- Gutenberg remove Most Used group
- Gutenberg. How To Register A Custom Block Style For Specific Post Type Only
- get used blocks in post and detect changing
- Gutenberg get block name
- How has my WordPress editor become so basic? Cannot add blocks or see anything visual
- Insert SVG code (not img) in HTML block
- How to enable Block Editor on the Posts page
- React to a change of the block alignment
- Object type for block Attribute (Gutenberg)
- Controlling the RichText component outside of blocks
- Custom Gutenberg Block: How to return plain HTML with save(), without escaping?
- Removing advanced section from brand new gutenberg block
- How to allow to add gradients to core/heading block?
- Guttenberg Implementation on Front Page
- Register multiple styles / scripts in register_block_type
- How to automatically remove noreferrer from targetd link rel attribute, on render?
- Should there be concern about breaking Gutenberg updates to extended core blocks?
- How do I access onMerge, onReplace, onRemove functions for a Rich Text component in Gutenberg block code?
- How can Reusable Blocks be fully deleted?
- Make a Gutenberg Block that do WP_User_Query
- Extend Gutenberg block core/quote block
- How to get all attributes of a block in PHP?
- reload the gutenberg editer on taxonomy change
- Gutenberg Block Get Author Details
- Gutenberg Block Toolbar – remove button
- WordPress block editor embeds not working in theme (single.php)
- Cannot enable Gutenberg editor [closed]
- Remove ‘type / to choose a block’ placeholder [duplicate]
- Start a line with – without converting to list
- Quickest way of developing custom Gutenberg Blocks
- gutenberg attributes
- How to register two blocks in the same plugin
- Gutenberg: always show text color selector in editing bar
- How to lock innerBlocks within a block variation?
- How to get startIndex and endIndex from the selected block in gutenberg?
- How to fix: “The editor has encountered an unexpected error”?
- Set a minimum and maximum limit of images to select in the MediaUpload component for Block
- Compile a blocks src directory and main index.js entry file and output to different build dirs?
- Proxy External API request in PHP from Edit.js in Block Plugin
- How do I stop a dynamic Gutenberg component from re-rendering on every keystroke?
- Leave focus on custom Gutenberg block when pressing enter
- How to Analyze Blocks and find Intersection and patterns between pages
- WordPress does not hide content after “Read more” block added using gutenberg editor
- Gutenberg InnerBlocks allowed types and reusable blocks
- Why does the paragraph block automatically add class?
- How can I block embeds and show an individual preview image per block?
- add arrow icon next to read more link on latest posts gutenberg block
- Create a trailing block with programatically generated Gutenberg columns
- How to check title is being entered in Title Case?
- Gutenberg link of internal page not showing
- How do I trigger the sidebar reveal for my sidebar plugin in the Gutenberg editor?
- Create Gutenburg Block to render inline SVG
- How to extend the URLPopover render settings for the paragraph Gutenberg block?
- Custom Image Gutenberg Block With Caption
- How to make a block similar to another block
- Gutenberg: How to enqueue scripts conditionally in render_callback by checking for an attribute?
- How can I reintroduce autocompletion of Gutenberg components in Visual Code?
- Blocks – any way to have editor honor width percentages on child blocks?
- Using `esc_attr( get_block_wrapper_attributes() )`, results in `class=””wp-block-foo””`
- Block Theme Template parts – Why saving a part updates the other ones?
- No inline css, simple css file?
- How can I reset/remove background colour from a block
- Possible to use a block filter (blocks.getSaveContent.extraProps) with dynamic blocks?
- Elements positioning in a custom block
- Is it possible to get rid of the wrapping divs on a block component?
- In Full-Site-Editing, edits made to the code in a template part are not showing
- How to get appender icon to appear more often for innerblock usage
- Create a block variation of list elements
- Remove ‘default’ font option from Gutenberg typography settings
- Block-based navigation and multi-language plugins
- Custom Gallery Block – Uncaught TypeError: setAttributes is not a function
- how to display gutenberg editor in a view
- Gutenberg list items nesting and creating invalid content errors
- Trying to understand block alignment
- Custom Link Block with own background color