I know inserting core/heading or core/paragraph with content but it was not working when inserting core/post-excerpt as -
let postExcerpt = 'Excerpt content here';
let insertedBlock = wp.blocks.createBlock( 'core/post-excerpt', {
content: postExcerpt,
});
wp.data.dispatch('core/block-editor').insertBlocks( [insertedBlock ]);
// Save the post
wp.data.dispatch( 'core/editor' ).savePost();
It is inserting new post-excerpt block but not adding any content.
I did also try 'excerpt: postExcerpt' instead of 'content: postExcerpt' but didn't work.
I am missing something I think. Thanks in advance.