I'm using the Word count Plugin on CKEditor 4, but it exceeds the character count every time.
Here is my config:
config.wordcount = {
// Whether or not you want to show the Char Count
showCharCount: true,
// Option to limit the characters in the Editor, for example 200 in this case.
charLimit: 200
};
What am I doing wrong?
I'm using the Word count Plugin on CKEditor 4, but it exceeds the character count every time.
Here is my config:
config.wordcount = {
// Whether or not you want to show the Char Count
showCharCount: true,
// Option to limit the characters in the Editor, for example 200 in this case.
charLimit: 200
};
What am I doing wrong?
Share Improve this question edited Nov 17, 2016 at 16:29 GʀᴜᴍᴘʏCᴀᴛ 9,02920 gold badges90 silver badges160 bronze badges asked May 30, 2014 at 14:56 Hari SankarHari Sankar 661 gold badge1 silver badge5 bronze badges 6- Give an example of text that "exceeds" the word count – Lee Taylor Commented May 30, 2014 at 15:00
- "Sometimes" is not the most precise description of the problem. And if this happens sometimes, then maybe you should report a bug to the plugin author? – Reinmar Commented May 30, 2014 at 15:01
- @LeeTaylor I set the char limit to 10 and just typed "xdfxcfgcdcggvg" – Hari Sankar Commented May 30, 2014 at 15:04
- 1 @HariSankar - Please edit your question and add that info. Also, change sometimes to every time, if that's what you mean. – Lee Taylor Commented May 30, 2014 at 15:08
- 1 Basically, I need to restrict users to enter not more than 2000 chars. – Hari Sankar Commented May 30, 2014 at 15:13
3 Answers
Reset to default 3The WordCount plugin only counts words - it doesn't prevent you from entering text.
I wrote a similar plugin a while ago (http://ckeditor./ment/128388#ment-128388) which counted words or characters and allowed you to enter a "warning" limit which got displayed at the bottom.
The difficultly of limiting to a specific number of characters in CKE is that markup counts as content. It's a doddle to do with a regular textarea, but once you start using having bold and anchor tags involved it's much more plicated - does your character limit include or exclude markup? If it includes then how do you want to handle closing tags? If you want to limit to words then it's a little easier, but still not a walk in the park. Of course then you have to factor in pasting too ;)
Personally if I were tackling this, I'd hook into the counter so that if you exceed the count (this excludes all markup) you disable the ability to save.
You need a ma after charLimit: 200
:
charLimit: 200,
you also need:
config.extraPlugins = "wordcount,notification";
You need to set maxCharCount: 200, hardlimit: true
maxCharCount: 200,
hardlimit: true,
Please find below the config
config.extraPlugins = 'wordcount';
config.wordcount = {
showCharCount: true,
maxCharCount: 200,
hardLimit: true,
};
for more details refer to Word Count Plugin