Download & Extend

[D6] "Counter" plugin to count symbols and words inside CKEditor

Project:CKEditor - WYSIWYG HTML editor
Version:6.x-1.6
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

counter plugin

Code to include it into the settings of CKEditor profile using custom module would be:

<?php
/**
* 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

AttachmentSize
counter.tar_.gz964 bytes
counter.png37.83 KB

Comments

#1

Status:needs review» reviewed & tested by the community

Hi,

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

#2

Hi,

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

#3

Title:Counter plugin to count symbols and words» [D6] Counter plugin to count symbols and words
Status:reviewed & tested by the community» fixed

Ok 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

#4

Great! Thank you for the module :)

I will let you know if I would have any improvements to it.

AndyB

#5

Title:[D6] Counter plugin to count symbols and words» [D6] "Counter" plugin to count symbols and words inside CKEditor
Status:fixed» closed (fixed)

#6

Hello! Is it possible to translate the strings?

Like...

<?php
         
var symbols_wo_blanks = text.length;
          var
placeholders = {
           
'@symbols': symbols,
           
'@symbols_wo_blanks': symbols_wo_blanks,
           
'@words': words
         
}
          var
countOutput = Drupal.t('@symbols / @symbols_wo_blanks symbols; @words words', placeholders);
                   
space.setHtml( '<span class="cke_counter" style="float: right">' countOutput + '</span>' );
                }
?>

Thanks for this great plugin!

nobody click here