开发者

Django ckeditor with wordcount

Does anyone know how to integrate this wordcount plugin with the existing django-ckeditor apps? Either https://github.com/dwaiter/django-ckeditor or https://github.com/shaunsephton/django-ckeditor/.

开发者_StackOverflow

Specifically, I'm stuck at Step 4

For your CKEditor instance, use the following HTML markup (content can be any element name you wish, so long as the hidden field has its element name in the format elementWordCount)

<label for="content">Content</label>
<textarea class="ckeditor" name="content"></textarea>
<input name="contentWordCount" type="hidden" value="250" />

Where do I insert that Input element?

I'm using the widget btw.

Alternative solutions to having a wordcount plugin are welcome.


I'm the author of https://github.com/shaunsephton/django-ckeditor/. I've just updated the repo to support widget template customization.

You should now be able to integrate the wordcount plugin by specifying it as part of the CKEDITOR_CONFIGS setting:

CKEDITOR_CONFIGS = {
    'default': {
        'extraPlugins': 'wordcount',
    }
}

and then overriding the ckeditor/widget.html template to look like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<input name="contentWordCount" type="hidden" value="250" />

<textarea{{ final_attrs|safe }}>{{ value }}</textarea>
<script type="text/javascript">
    CKEDITOR.replace("{{ id }}", {{ config|safe }});
</script>

I've loaded jQuery here through Google APIs just as an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜