@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
23 lines (20 loc) • 832 B
JavaScript
import { createElement } from "@wordpress/element";
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { _x } from '@wordpress/i18n';
import { count as wordCount } from '@wordpress/wordcount';
export default function WordCount() {
const content = useSelect(select => select('core/editor').getEditedPostAttribute('content'));
/*
* translators: If your word count is based on single characters (e.g. East Asian characters),
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
* Do not translate into your own language.
*/
const wordCountType = _x('words', 'Word count type. Do not translate!');
return createElement("span", {
className: "word-count"
}, wordCount(content, wordCountType));
}
//# sourceMappingURL=index.js.map