WordCountConfig (wordcount)
@ckeditor/ckeditor5-wordcount/src/wordcount
The configuration of the word count feature.
ClassicEditor
.create( {
wordCount: ... // Word count feature configuration.
} )
.then( ... )
.catch( ... );See all editor options.
Filtering
Properties
-
container : HTMLElementThis option allows on providing an HTML element where word count container will be appended automatically.
const wordCountConfig = { container: document.getElementById( 'container-for-word-count' ); } -
displayCharacters : BooleanThis option allows for hiding the character counter. The element obtained through
wordCountContainerwill only preserve the words part. Character counter is displayed by default when this configuration option is not defined.const wordCountConfig = { displayCharacters: false }The mentioned configuration will result in the following container
<div class="ck ck-word-count"> <div class="ck-word-count__words">Words: 4</div> </div> -
displayWords : BooleanThis option allows for hiding the word count. The element obtained through
wordCountContainerwill only preserve the characters part. word count is displayed by default when this configuration option is not defined.const wordCountConfig = { displayWords: false }The mentioned configuration will result with the followed container:
<div class="ck ck-word-count"> <div class="ck-word-count__characters">Characters: 28</div> </div> -
onUpdate : functionThis configuration takes a function, which is executed whenever the word-count plugin updates its values. This function is called with one argument, which is an object with
wordsandcharacterskeys containing a number of detected words and characters in the document.const wordCountConfig = { onUpdate: function( stats ) { doSthWithWordNumber( stats.words ); doSthWithCharacterNumber( stats.characters ); } }