简体   繁体   中英

djangocms text_ckeditor wordcount plugin

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!

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, eg, 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, eg,

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

Hope that works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM