get the automatically generated excerpt
The REST API always includes the auto-generated excerpt by default, so try with getEntityRecord()
like so:
Note though, if the user edited the actual excerpt (i.e. the “Excerpt” panel in the Settings sidebar and not your metaExcerpt
value), then the currentExcerpt
would also use the excerpt the user has just edited.
withSelect( function( select, props ) {
const _post = select( 'core/editor' ).getCurrentPost();
const post = select( 'core' ).getEntityRecord( 'postType', _post.type, _post.id );
return {
metaValue: select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ props.metaKey ],
metaExcerpt : select( 'core/editor' ).getEditedPostAttribute( 'excerpt' ),
metaContent : select( 'core/editor' ).getEditedPostAttribute( 'content' ),
currentExcerpt : post ? post.excerpt.rendered : '',
};
} ... your code.
Then with the TextareaControl
, use placeholder: props.metaExcerpt || props.currentExcerpt
.