Ckeditor5: Wordcount plugin

Created on 15 Oct 2018  路  11Comments  路  Source: ckeditor/ckeditor5

It looks like people are looking for "word count" or "character count" in our documentation and can't find it. I'm creating this issue to track demand for such a plugin. If anyone is looking for such plugin, add 馃憤. Also please write a comment what's your use case for it, so that we could better understand what's the purpose of this plugin.

feature

Most helpful comment

This feature recently was merged to the master branch 馃帀 It now provides a convenient API to track amount of words in the editor.

Basic configuration should looks something like that:

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        // Configuration details.
    } )
    .then( editor => {
        const wordCountPlugin = editor.plugins.get( 'WordCount' );
        // Your custom element where the word count should be applied to:
        const wordCountWrapper = document.getElementById( 'word-count' );

        wordCountWrapper.appendChild( wordCountPlugin.wordCountContainer );
    } )
    .catch( ... );

Or you can just observe words and characters properties of the WordCount instance if you need more control.

More info will be available in the docs.

Sample screencast:
Screencast showing text statistics as end user types in the editor

All 11 comments

I need the word/character count plugin to limit the user to 7000 characters. Something similar to the word count plugin available for CKEditor 4 - https://ckeditor.com/cke4/addon/wordcount

Our customers asks explizit for such a functionality - so we need it :P

I need it too :)

We need this functionality too. We're currently using the word count plugin in ckeditor 4 to show the count of paragraphs, words, & characters, & it would be great to have this feature available in ckeditor 5

Is it still an open issue? Or we have a solution for it now? We are trying to create a dynamic template for creating multiple choice questions where we have to restrict user by characters for the 'Options' field.

@venkateshwarans thank you for explaining your use case. Yes, the issue is still open and seeing the 馃憤 under it makes it quite probable that we'll handle it at some point. Unfortunately there is no ETA for it yet as we scheduled many things already. If you'd like to speed things up and sponsor the development of the plugin, then please contact us.

If you'd like to work on the plugin by yourself, then sharing with others a link to the repository in a comment may help, maybe other interested users would like to help somehow once you provide some starting point.

I scan through some word count features and I see some different approach in each of them. There are few things worth considering:

  1. Non-whitespace word separators:

    • foo/bar

    • foo(bar)

    • foo-bar <- (this probably should be considered always as single word)

  2. Non alphanumeric strings:

    • #^&()

@msamsel the unicode has some preatty neat article about detecting word boundaries - maybe it could be taken into consideration. Also there's a algorithm to skip words in modifySelection().

Edit: For future me: Word segmenation in Unicode.

I've provide specification for the plugin in:
https://github.com/ckeditor/ckeditor5-word-count/issues/1

This feature recently was merged to the master branch 馃帀 It now provides a convenient API to track amount of words in the editor.

Basic configuration should looks something like that:

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        // Configuration details.
    } )
    .then( editor => {
        const wordCountPlugin = editor.plugins.get( 'WordCount' );
        // Your custom element where the word count should be applied to:
        const wordCountWrapper = document.getElementById( 'word-count' );

        wordCountWrapper.appendChild( wordCountPlugin.wordCountContainer );
    } )
    .catch( ... );

Or you can just observe words and characters properties of the WordCount instance if you need more control.

More info will be available in the docs.

Sample screencast:
Screencast showing text statistics as end user types in the editor

its not worked for me after napm save ? can any one send me steps to display character count for ckeditor 5th version.

Was this page helpful?
0 / 5 - 0 ratings