djangocms-text-ckeditor 0,0 editorconfig travis-ci gulp npm python

Text Plugin for django CMS using CKEditor


Text Plugin for django-cms with CK-Editor.

The latest version of this package supports:

  • Django >= 1.8
  • django CMS >= 3.3

.. WARNING:: - For django CMS 3.4.x use djangocms-text-ckeditor >= 3.2.x (e.g.: version 3.2.1). - For django CMS 3.3.x use djangocms-text-ckeditor >= 3.1.x (e.g.: version 3.1.0). - For django CMS 3.2.x use djangocms-text-ckeditor <= 2.9.x (e.g.: version 2.9.3). - For django CMS 3.0 and 3.1 use djangocms-text-ckeditor <= 2.7 (e.g.: version 2.7.0). - For django CMS 2.3 and 2.4 use the djangocms-text-ckeditor 1.x releases (e.g.: version 1.0.10). - For Django 1.4 and 1.5 use djangocms-text-ckeditor < 2.7. - cms.plugins.text and djangocms-text-ckeditor can’t be used at the same time.


This plugin requires django CMS 3.3 or higher to be properly installed.

  • In your projects virtualenv, run pip install djangocms-text-ckeditor.
  • Add djangocms_text_ckeditor to your INSTALLED_APPS (the order does not matter).
  • Run migrate djangocms_text_ckeditor.

Some notes:

  • If upgrading from previous djangocms_text_ckeditor, be aware that the names of the migration modules have changed:

    • Django 1.6: djangocms_text_ckeditor.migrations to djangocms_text_ckeditor.south_migrations
    • Django 1.7: djangocms_text_ckeditor.migrations_django to djangocms_text_ckeditor.migrations
  • If using Django 1.6 add 'djangocms_text_ckeditor': 'djangocms_text_ckeditor.south_migrations', to SOUTH_MIGRATION_MODULES (or define SOUTH_MIGRATION_MODULES if it does not exists);

  • If using Django 1.7 and you were using version prior to 2.5, remove djangocms_text_ckeditor from MIGRATION_MODULES;

Upgrading from cms.plugins.text

  • Remove cms.plugins.text from INSTALLED_APPS
  • Add djangocms_text_ckeditor to INSTALLED_APPS
  • Run python migrate djangocms_text_ckeditor 0001 --fake


Default content in Placeholder

If you use Django-CMS >= 3.0, you can use TextPlugin in “defaultplugins” (see docs about the CMS_PLACEHOLDER_CONF setting in Django CMS 3.0). TextPlugin requires just one value: body where you write your default HTML content. If you want to add some “default children” to your automagically added plugin (i.e. a LinkPlugin), you have to put children references in the body. References are "%(_tag_child_<order>)s" with the inserted order of chidren. For example::

    'content': {
        'name' : _('Content'),
        'plugins': ['TextPlugin', 'LinkPlugin'],
                    'body':'<p>Great websites : %(_tag_child_1)s and %(_tag_child_2)s</p>'



You can override the setting CKEDITOR_SETTINGS in your

    'language': '{{ language }}',
    'toolbar': 'CMS',
    'skin': 'moono',

This is the default dict that holds all CKEditor settings.

Customizing plugin editor #########################

To customize the plugin editor, use toolbar_CMS attribute, as in::

    'language': '{{ language }}',
    'toolbar_CMS': [
        ['Undo', 'Redo'],
        ['cmsplugins', '-', 'ShowBlocks'],
        ['Format', 'Styles'],
    'skin': 'moono',

Customizing HTMLField editor ############################

If you use HTMLField from djangocms_text_ckeditor.fields in your own models, use toolbar_HTMLField attribute::

    'language': '{{ language }}',
    'toolbar_HTMLField': [
        ['Undo', 'Redo'],
        ['Format', 'Styles'],
    'skin': 'moono',

You can further customize each HTMLField field by using different configuration parameter in your settings::

class Model1(models.Model):
    text = HTMLField(configuration='CKEDITOR_SETTINGS_MODEL1')

class Model2(models.Model):
    text = HTMLField(configuration='CKEDITOR_SETTINGS_MODEL2')

    'toolbar_HTMLField': [
        ['Undo', 'Redo'],
        ['Format', 'Styles'],
        ['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],

    'toolbar_HTMLField': [
        ['Undo', 'Redo'],
        ['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],

#. Add configuration='MYSETTING' to the HTMLField usage(s) you want to customize; #. Define a setting parameter named as the string used in the configuration argument of the HTMLField instance with the desidered configuration;

Values not specified in your custom configuration will be taken from the global CKEDITOR_SETTINGS.

For an overview of all the available settings have a look here:!/api/CKEDITOR.config

Drag & Drop Images

In IE and Firefox based browsers it is possible to drag and drop a picture into the text editor. This image is base64 encoded and lives in the ‘src’ attribute as a ‘data’ tag.

We detect this images, encode them and convert them to picture plugins. If you want to overwirite this behavior for your own picture plugin:

There is a setting called::

TEXT_SAVE_IMAGE_FUNCTION = 'djangocms_text_ckeditor.picture_save.create_picture_plugin'

you can overwrite this setting in your and point it to a function that handles image saves. Have a look at the function create_picture_plugin for details.

To completely disable the feature, set TEXT_SAVE_IMAGE_FUNCTION = None.


If you want to help translate the plugin please do it on transifex:

Usage as a model field

If you want to use the widget on your own model fields, you can! Just import the provided HTMLField like so::

from djangocms_text_ckeditor.fields import HTMLField

And use it in your models, just like a TextField::

class MyModel(models.Model):
    myfield = HTMLField(blank=True)

This field does not allow you to embed any other CMS plugins within the text editor. Plugins can only be embedded within Placeholder fields.

If you need to allow additional plugins to be embedded in a HTML field, convert the HTMLField to a Placeholderfield and configure the placeholder to only accept TextPlugin. For more information on using placeholders outside of the CMS see:

Auto Hyphenate Text

You can hyphenate the text entered into the editor, so that the HTML entity &shy; (soft-hyphen_) automatically is added in between words, at the correct syllable boundary.

To activate this feature, pip install django-softhyphen. In add 'softhyphen' to the list of INSTALLED_APPS. django-softhyphen_ also installs hyphening dictionaries for 25 natural languages.

In case you already installed django-softhyphen but do not want to soft hyphenate, set TEXT_AUTO_HYPHENATE to False.

.. _soft-hyphen: .. _django-softhyphen:

Extending the plugin

.. NOTE:: Added in version 2.0.1

You can use this plugin as base to create your own CKEditor-based plugins.

You need to create your own plugin model extending AbstractText::

from djangocms_text_ckeditor.models import AbstractText

class MyTextModel(AbstractText):
    title = models.CharField(max_length=100)

and a plugin class extending TextPlugin class::

from djangocms_text_ckeditor.cms_plugins import TextPlugin
from .models import MyTextModel

class MyTextPlugin(TextPlugin):
    name = _(u"My text plugin")
    model = MyTextModel


Note that if you override the render method that is inherited from the base TextPlugin class, any child text plugins will not render correctly. You must call the super render method in order for plugin_tags_to_user_html() to render out all child plugins located in the body field. For example::

from djangocms_text_ckeditor.cms_plugins import TextPlugin
from .models import MyTextModel

class MyTextPlugin(TextPlugin):
    name = _(u"My text plugin")
    model = MyTextModel

    def render(self, context, instance, placeholder):
        # Other custom render code you may have
    return super(MyTextPlugin, self).render(context, instance, placeholder)


You can further customize your plugin_ as other plugins.

.. _customize your plugin:

Adding plugins to the “CMS Plugins” dropdown

If you have another plugin that you want to use inside texts you can make them appear in the dropdown by making them textenabled. Check in django-cms doc how to do this.

.. _django-cms doc:

Configurable sanitizer

djangocms-text-ckeditor uses html5lib_ to sanitize HTML to avoid security issues and to check for correct HTML code. Sanitisation may strip tags usesful for some use cases such as iframe; you may customize the tags and attributes allowed by overriding the TEXT_ADDITIONAL_TAGS and TEXT_ADDITIONAL_ATTRIBUTES settings::

TEXT_ADDITIONAL_ATTRIBUTES = ('scrolling', 'allowfullscreen', 'frameborder')

In case you need more control on sanitisation you can extend AllowTokenParser class and define your logic into parse() method. For example, if you want to skip your donut attribute during sanitisation, you can create a class like this::

from djangocms_text_ckeditor.sanitizer import AllowTokenParser

class DonutAttributeParser(AllowTokenParser):

    def parse(self, attribute, val):
        return attribute.startswith('donut-')

And add your class to ALLOW_TOKEN_PARSERS settings::


NOTE: Some versions of CKEditor will pre-sanitize your text before passing it to the web server, rendering the above settings useless. To ensure this does not happen, you may need to add the following parameters to CKEDITOR_SETTINGS::

  'basicEntities': False,
  'entities': False,

To completely disable the feature, set TEXT_HTML_SANITIZE = False.

See the html5lib documentation_ for further information.

.. _html5lib: .. _html5lib documentation:


djangocms-text-ckeditor works well with aldryn-search <>_ to make text content using Haystack.

About CKEditor

The current integrated Version of CKeditor is 4.5.11. For a full documentation visit:

Building the JavaScript

djangocms-text-ckeditor distributes a javascript bundle required for the plugin to work, which contains CKEditor itself and all the necessary plugins for functioning within CMS. To build the bundle you need to have to install dependencies with npm install and then to run gulp bundle.

This command also updates the file name loaded based on the file contents.

Updating the CKEditor

Make sure to use the url in build config <>_.

Related Repositories



Text Plugin for django CMS using CKEditor ...



A plugin to incorporate Glyphicon and Font Awesome into djangocms-text-ckeditor ...



Text Plugin for django-cms with CK-Editor ...

Top Contributors

yakky vxsx czpython digi604 FinalAngel mkoistinen jrief Chive stefanfoulis ojii alesdotio astagi mmarzantowicz DylannCordel jgoettsch jsma ollb timgraham maestrofjp asmaps mattcaldwell zerok johnraz meshy adamchainz alexandrenorman piquadrat suquant vierno jvamvas


package version
dev del ^2.2.2
gulp ^3.9.1
gulp-concat ^2.6.0
gulp-eslint ^2.1.0
gulp-filter ^4.0.0
gulp-if ^2.0.1
gulp-plumber ^1.1.0
gulp-replace ^0.5.4
gulp-rev ^7.1.2
gulp-rev-replace ^0.4.3
gulp-sourcemaps ^1.6.0
gulp-uglify ^2.0.0
minimist ^1.2.0
run-sequence ^1.2.2


-   3.3.0 zip tar
-   3.2.1 zip tar
-   3.2.0 zip tar
-   3.1.0 zip tar
-   3.0.1 zip tar
-   3.0.0 zip tar
-   2.9.5 zip tar
-   2.9.4 zip tar
-   2.9.3 zip tar
-   2.9.2 zip tar
-   2.9.1 zip tar
-   2.9.0 zip tar
-   2.8.1 zip tar
-   2.8.0 zip tar
-   2.7.3 zip tar
-   2.7.2 zip tar
-   2.7.1 zip tar
-   2.7.0 zip tar
-   2.6.0 zip tar
-   2.5.3 zip tar
-   2.5.1 zip tar
-   2.4.3 zip tar
-   2.4.2 zip tar
-   2.4.1 zip tar
-   2.4.0 zip tar
-   2.3.0 zip tar
-   2.2.0 zip tar
-   2.1.6 zip tar
-   2.1.4 zip tar
-   2.1.3 zip tar