添加wordcount插件后,它只会恢复到我的原始文本区域。
这是我的代码(js不是我的东西):
<textarea id="editor1" name="editor1" maxlength="10" placeholder="5000 Characters Max.(with HTML)"></textarea>
<script>
CKEDITOR.plugins.addExternal( 'wordcount', '/ckeditor/plugins/wordcount/');
config.wordcount = {
// Whether or not you want to show the Word Count
showWordCount: true,
// Whether or not you want to show the Char Count
showCharCount: false,
// Maximum allowed Word Count
maxWordCount: 4,
// Maximum allowed Char Count
maxCharCount: 10
};
CKEDITOR.replace( 'editor1', {
extraPlugins: 'colorbutton,colordialog,font,wordcount',
toolbar: [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] },
{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
]
} );
</script>
答案 0 :(得分:1)
您的config
变量(未定义)并没有做任何事情。您需要在传递给CKEDITOR.replace
或config.js
文件的对象中设置配置。有关详细信息,请参阅Setting CKEditor Configuration指南。
这里最简单的方法是将wordcount插件配置添加到CKEDITOR.replace
调用中,如下所示:
<textarea id="editor1" name="editor1" maxlength="10" placeholder="5000 Characters Max.(with HTML)"></textarea>
<script>
CKEDITOR.plugins.addExternal( 'wordcount', '../../plug/wordcount/');
CKEDITOR.replace( 'editor1', {
extraPlugins: 'colorbutton,colordialog,font,wordcount',
toolbar: [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] },
{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
],
wordcount: {
// Whether or not you want to show the Word Count
showWordCount: true,
// Whether or not you want to show the Char Count
showCharCount: false,
// Maximum allowed Word Count
maxWordCount: 4,
// Maximum allowed Char Count
maxCharCount: 10
}
} );
</script>