1

有谁知道如何将此wordcount 插件与现有的 django-ckeditor 应用程序集成?https://github.com/dwaiter/django-ckeditor或https://github.com/shaunsephton/django-ckeditor/_

具体来说,我被困在第 4 步

对于您的 CKEditor 实例,使用以下 HTML 标记(content可以是您希望的任何元素名称,只要隐藏字段的元素名称格式为elementWordCount

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

我在哪里插入该Input元素?

我正在使用小部件顺便说一句。

欢迎使用 wordcount 插件的替代解决方案。

4

1 回答 1

4

我是https://github.com/shaunsephton/django-ckeditor/的作者。我刚刚更新了存储库以支持小部件模板自定义。

您现在应该能够通过将 wordcount 插件指定为CKEDITOR_CONFIGS设置的一部分来集成它:

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

然后覆盖ckeditor/widget.html模板看起来像这样:

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

我在这里通过 Google API 加载了 jQuery 作为示例。

于 2011-09-28T11:39:37.417 回答