contenido
Version:
Contenido is a library with a set of tools to help you create your own rich text editor on top of draft-js without thinking about how to handle things.
13 lines (8 loc) • 340 B
text/typescript
// Custom Types
import type { State } from '../../types';
const getCharCount = (state: State) => {
const plainText = state.getCurrentContent().getPlainText();
const wordArray = plainText.match(/\S+/g); // Matches words according to the whitespace.
return wordArray ? wordArray.join('').length : 0;
};
export default getCharCount;