Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello!
I've written the counter plugin to count symbols (with and without blank symbols) and words for CKEditor. It uses jQuery so it will be suitable only for the sites with this library included, like Drupal based sites. It is attached to this issue - hope it will be usefull for the community and you might want to include it with the module (and to improve it if possible - for now it refreshes the counter on dataReady, blur and focus events).
Code to include it into the settings of CKEditor profile using custom module would be:
/**
* Implements hook_ckeditor_plugin().
*/
function MYMODULE_ckeditor_plugin() {
$path = drupal_get_path('module', 'MYMODULE');
return array(
'counter' => array(
'name' => 'counter',
'desc' => t('Plugin to count number of words and symbols'),
'path' => $path . '/plugins/counter/',
),
);
}
Thanks
AndyB
Comment | File | Size | Author |
---|---|---|---|
counter.png | 37.83 KB | duozersk | |
counter.tar_.gz | 964 bytes | duozersk |
Comments
Comment #1
dczepierga CreditAttribution: dczepierga commentedHi,
Really thx for this plugin...
Do u agree to add this to CKEditor module?
I think also what to do with counter refresh when writing... maybe sth like counter update on every 5 seconds when writing or sth like that?
Greetings
Comment #2
duozerskHi,
Sure, let's add it to the CKEditor module - it will be really good addition.
As for the counter refresh - I tried to do it on the 'key' event of CKEditor (then it will update on every new symbol), but it then consumes too much resources. We might want to do the refresh on the 'saveSnapshot' event or smth similar. I don't feel like doing it through setTimeout function will be a good way to go. May be CKEditor experts would suggest some other events to do the refresh.
Thanks
AndyB
Comment #3
dczepierga CreditAttribution: dczepierga commentedOk i add this to GIT and commit all changes.
Again really thx for this great plugin.
I will also add this to Drupal 7 module.
Greetings
Comment #4
duozerskGreat! Thank you for the module :)
I will let you know if I would have any improvements to it.
AndyB
Comment #5
mkesicki CreditAttribution: mkesicki commentedComment #6
soulfroysHello! Is it possible to translate the strings?
Like...
Thanks for this great plugin!
Comment #7
playeronee CreditAttribution: playeronee commentedHi,
The plugin is great.
I added it to Liferay 6.1 as CKEditor plugin. It works good on FF but it is problem on IE (7~9)
Have you got this issue? What could be reason?
Regards,
Michal
Comment #7.0
playeronee CreditAttribution: playeronee commentedadded inline screen shot
Comment #8
saga_shiftyblow CreditAttribution: saga_shiftyblow commentedCan i suggest to add to the current version of the plugin this line of code?
editor.on( 'key', count );
Having it responding to key pressure make the plugin way more useful.