Sign up (with export icon)

WordCountConfig

Api-interface icon interface

The configuration of the word count feature.

ClassicEditor
	.create( {
		wordCount: ... // Word count feature configuration.
	} )
	.then( ... )
	.catch( ... );
Copy code

See all editor options.

Properties

  • Chevron-right icon

    container : HTMLElement | undefined

    Allows for providing the HTML element that the word count container will be appended to automatically.

    const wordCountConfig = {
    	container: document.getElementById( 'container-for-word-count' );
    };
    
    Copy code
  • Chevron-right icon

    displayCharacters : boolean | undefined

    This option allows for hiding the character counter. The element obtained through wordCountContainer will only preserve the words part. Character counter is displayed by default when this configuration option is not defined.

    const wordCountConfig = {
    	displayCharacters: false
    };
    
    Copy code

    The configuration above will result in the following container:

    <div class="ck ck-word-count">
    	<div class="ck-word-count__words">Words: 4</div>
    </div>
    
    Copy code
  • Chevron-right icon

    displayWords : boolean | undefined

    This option allows for hiding the word counter. The element obtained through wordCountContainer will only preserve the characters part. Word counter is displayed by default when this configuration option is not defined.

    const wordCountConfig = {
    	displayWords: false
    };
    
    Copy code

    The configuration above will result in the following container:

    <div class="ck ck-word-count">
    	<div class="ck-word-count__characters">Characters: 28</div>
    </div>
    
    Copy code
  • Chevron-right icon

    onUpdate : ( data: object ) => void | undefined

    This 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 words and characters keys containing the number of detected words and characters in the document.

    const wordCountConfig = {
    	onUpdate: function( stats ) {
    		doSthWithWordNumber( stats.words );
    		doSthWithCharacterNumber( stats.characters );
    	}
    };
    
    Copy code