djangocms text_ckeditor wordcount plugin

356 Views Asked by At

I am working in a djangocms project that uses the djangocms_text_ckeditor https://github.com/divio/djangocms-text-ckeditor

I would like to integrate a wordcount plugin similar to this https://github.com/w8tcha/CKEditor-wordcount-Plugin

Have someone of you did this before successfully? It would be great if I could get the plugin via pip or so, not downloading and including it in the project. And also, how would the CKEDITOR_SETTINGS look like?

I couldn't find any workaround, just a similar post but that does not use this djangocms text editor for that purpose.

Thanks in advance!

1

There are 1 best solutions below

0
On

The extension is a javascript plugin for the ckeditor (as opposed to a djangocms plugin).

To load a javascript plugin two steps are needed:

  1. Make the js plugin resources available to ckeditor. This is done through static folder in your project wich includes all js, css etc. files. In the static folder create the folders djangocms_text_ckeditor/ckeditor/plugins. Copy the js plugin into this folder. In your case thats the whole folder wordcount. The directory tree should look like

    static
    |
    +---djangocms_text_ckeditor
    |   |
    |   +---ckeditor
    |   |   |
    |   |   +---plugins
    |   |   |   |
    |   |   |   +---wordcount
    |   |   |   |   |
    |   |   |   |   +---css
    |   |   |   |   +---lang
    |   |   |   |   +---plugin.js
    
  2. Let the djangocms plugin ckeditor know about the js plugin. To this end, look for the setting CKEDITOR_SETTINGS in your project's settings.py file. If it is not there create it. It's a dictionary that is used, e.g., to configure the toolbars. In this dictionary have a key extraPlugins with a string value that consists of comma separated names of plugins to load, e.g.,

    CKEDITOR_SETTINGS = {
        ...,
        'extraPlugins':  'cmsplugins,wordcount,glyphicons,...',
        ...,
    }
    

Hope that works for you.