Skip to main content

Word Count

Plugin alias: wordcount

editor42.init({
plugins: 'wordcount'
});

Tracks and displays word count, character count, and character count without spaces for both the full document and the current selection. Fires periodic count updates in response to content changes and provides a dialog with all counts.

Commands

CommandDescription
editor42WordCountOpens the Word Count dialog.

Toolbar buttons

ButtonTypeDescription
wordcountButtonOpens the Word Count dialog.
ItemDescription
wordcountOpens the Word Count dialog.

Events

EventDescription
wordCountUpdateFired when counts are recalculated. Payload: { wordCount: { words, characters, charactersWithoutSpaces } }.

API

MethodDescription
body.getWordCount()Returns word count for the full document.
body.getCharacterCount()Returns character count for the full document.
body.getCharacterCountWithoutSpaces()Returns character count without spaces for the full document.
selection.getWordCount()Returns word count for the current selection.
selection.getCharacterCount()Returns character count for the current selection.
selection.getCharacterCountWithoutSpaces()Returns character count without spaces for the current selection.
getCount()Deprecated. Returns body word count. Use body.getWordCount() instead.