@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
18 lines (15 loc) • 490 B
JavaScript
import { useSelect } from '@wordpress/data';
import { count as characterCount } from '@wordpress/wordcount';
import { store as editorStore } from '../../store';
/**
* Renders the character count of the post content.
*
* @return {number} The character count.
*/
export default function CharacterCount() {
const content = useSelect(
( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),
[]
);
return characterCount( content, 'characters_including_spaces' );
}