Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wordcount plugin #1301

Closed
wwalc opened this issue Oct 15, 2018 · 13 comments · Fixed by ckeditor/ckeditor5-word-count#2
Closed

Wordcount plugin #1301

wwalc opened this issue Oct 15, 2018 · 13 comments · Fixed by ckeditor/ckeditor5-word-count#2
Assignees
Labels
type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Milestone

Comments

@wwalc
Copy link
Member

wwalc commented Oct 15, 2018

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.

@Reinmar Reinmar added type:feature This issue reports a feature request (an idea for a new functionality or a missing option). status:confirmed labels Oct 15, 2018
@Reinmar Reinmar added this to the backlog milestone Oct 15, 2018
@vivekn-procentris
Copy link

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

@Maqsyo
Copy link

Maqsyo commented Feb 26, 2019

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

@webplease
Copy link

I need it too :)

@NadaSokkar
Copy link

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

@venkateshwarans
Copy link

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.

@wwalc
Copy link
Member Author

wwalc commented May 13, 2019

@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.

@msamsel
Copy link
Contributor

msamsel commented May 31, 2019

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:
    • #^&()

@jodator
Copy link
Contributor

jodator commented May 31, 2019

@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.

@msamsel
Copy link
Contributor

msamsel commented Jun 5, 2019

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

@mlewand mlewand modified the milestones: iteration 25, iteration 26 Jun 28, 2019
Reinmar added a commit to ckeditor/ckeditor5-word-count that referenced this issue Jul 1, 2019
Feature: Introduce word count feature. Closes #1. Closes ckeditor/ckeditor5#1301.
@mlewand mlewand modified the milestones: iteration 26, iteration 25 Jul 1, 2019
@mlewand
Copy link
Contributor

mlewand commented Jul 3, 2019

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

@pritijha17
Copy link

<script src="https://cdn.ckeditor.com/ckeditor5/11.1.1/classic/ckeditor.js"></script>

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

@KellsCodes
Copy link

Please how can I use this in react app?

@mohsenbh67
Copy link

mohsenbh67 commented May 11, 2024

Please how can I use this in react app?

i used this approach:

const editorConfiguration = {
    wordCount: {
        onUpdate: (stats) => {
            const wordCountElement = document.getElementById("word-count");
            if (wordCountElement) {
                wordCountElement.innerText = `Characters: ${stats.characters}, Words: ${stats.words}`;
            }
        },
    },
};
<CKEditor
 editor={Editor}
data={editorData}
 config={editorConfiguration}
/>
<div id="word-count" ></div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.