{% comment %}
    CKEditor requires you to have the resources referenced below installed under your STATIC_URL/ckeditor.
    You can download them from ckeditor.com, or include django-ckeditor in your project.
{% endcomment %}
{% load wysiwyg %}
<script type="text/javascript" src="{% wysiwyg_static_url "ckeditor" "ckeditor/ckeditor/" DJANGO_WYSIWYG_MEDIA_URL %}ckeditor.js"></script>
<script type="text/javascript">
    var django_wysiwyg_editor_configs = [];   // allow custom settings per editor ID{% block django_wysiwyg_editor_config %}
    var django_wysiwyg_editor_config = {};
  {% endblock %}

  var django_wysiwyg =
    {
        editors: {},

        enable: function django_wysiwyg_enable(editor_name, field_id, config)
        {
            if( !config ) {
                config = django_wysiwyg_editor_configs[field_id] || django_wysiwyg_editor_config;
            }

            if( !this.editors[editor_name] ) {
                this.editors[editor_name] = CKEDITOR.replace(field_id, config);
            }
        },

        disable: function django_wysiwyg_disable(editor_name)
        {
            var editor = this.editors[editor_name];
            if( editor ) {
                editor.destroy(/*noUpdate=*/false);
                this.editors[editor_name] = null;
            }
        },

        is_loaded: function django_wysiwyg_is_loaded()
        {
            return window.CKEDITOR != null;
        }
    }
</script>
