WordCountConfig
The configuration of the word count feature.
ClassicEditor
.create( {
wordCount: ... // Word count feature configuration.
} )
.then( ... )
.catch( ... );Copy codeSee all editor options.
Properties
container?: HTMLElementmodule:word-count/wordcountconfig~WordCountConfig#containerAllows for providing the HTML element that the word count container will be appended to automatically.
Copy codeconst wordCountConfig = { container: document.getElementById( 'container-for-word-count' ); };displayCharacters?: booleanmodule:word-count/wordcountconfig~WordCountConfig#displayCharactersThis 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.
Copy codeconst wordCountConfig = { displayCharacters: false };The configuration above will result in the following container:
Copy code<div class="ck ck-word-count"> <div class="ck-word-count__words">Words: 4</div> </div>displayWords?: booleanmodule:word-count/wordcountconfig~WordCountConfig#displayWordsThis option allows for hiding the word counter. The element obtained through
wordCountContainerwill only preserve the characters part. Word counter is displayed by default when this configuration option is not defined.
Copy codeconst wordCountConfig = { displayWords: false };The configuration above will result in the following container:
Copy code<div class="ck ck-word-count"> <div class="ck-word-count__characters">Characters: 28</div> </div>onUpdate?: ( data: object ) => voidmodule:word-count/wordcountconfig~WordCountConfig#onUpdateThis configuration takes a function that is executed whenever the word count plugin updates its values. This function is called with one argument, which is an object with the
wordsandcharacterskeys containing the number of detected words and characters in the document.
Copy codeconst wordCountConfig = { onUpdate: function( stats ) { doSthWithWordNumber( stats.words ); doSthWithCharacterNumber( stats.characters ); } };