无法在CKEditor中添加启用scayt工具栏

Unable to add enable the scayt in toolbar in CKEditor

本文关键字:启用 scayt 工具栏 添加 CKEditor      更新时间:2023-09-26

我的config.js如下

    CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here.
    // For complete reference see:
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config
    config.height='10em';
    // The toolbar groups arrangement, optimized for a single toolbar row.
    config.toolbarGroups = [
        { name: 'document',    groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        { name: 'forms' },
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
        /*{ name: 'links' },*/
        { name: 'insert' },
        { name: 'styles' },
        { name: 'colors' },
        { name: 'tools' },
        { name: 'others' }
        /*{ name: 'about' }*/
    ];
    config.enterMode = CKEDITOR.ENTER_BR;
    // The default plugins included in the basic setup define some buttons that
    // are not needed in a basic editor. They are removed here.
    config.removeButtons = 'Cut,Copy,Paste,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript';
    // Dialog windows are also simplified.
    config.removeDialogTabs = 'link:advanced';
    config.extraPlugins = 'scayt';
};

通过添加config.extraPlugins = 'scayt';我的Ckeditor被禁用,我把scayt文件夹在CKEditor的插件文件夹。如果你知道我做错了什么,请帮忙。我想在CKeditor中添加拼写检查器。

我也很纠结。对我来说,解决方案是工具栏选项必须以大写"S"开头。所以我必须用Scayt来代替Scayt

CKEDITOR.config.toolbar_MA = [
    ['Scayt', '-', 'Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo', 'Source'],
];
CKEDITOR.config.disableNativeSpellChecker = false;
CKEDITOR.config.defaultLanguage = 'fr';
CKEDITOR.config.language = 'fr';
// Turn on SCAYT automatically
CKEDITOR.config.scayt_autoStartup = true;
CKEDITOR.config.scayt_sLang = 'fr_FR';

试着添加这个:

config.scayt_autoStartup = true;

我没有定义:

config.extraPlugins = 'scayt';

它正在工作

编辑

你也可以尝试在javascript中像这样初始化:http://jsfiddle.net/ddan/usz40fb5/

var editor;
function createEditor( lang ) {
    editor && editor.destroy();
    editor = CKEDITOR.replace( 'editor', {
        plugins: 'wysiwygarea,sourcearea,basicstyles,toolbar,scayt',
        // Turn on SCAYT automatically
        scayt_autoStartup: true,
        language: lang,
    } );
}
createEditor( 'en' );

编辑

根据你的评论:

这个必须工作。使用版本4.4.3。我给的例子是使用CDN的ckeditor。如果你想替换本地的js,可以自由地包含你自己的脚本,或者下载脚本并从本地库加载。

<!-- CKeditor 4.4.3  -->
<script src="http://cdn.ckeditor.com/4.4.3/standard/ckeditor.js"></script>
<textarea  id="editor"> worng spelling</textarea>
<script>
// Shorthand for $( document ).ready()
$(function() {
    CKEDITOR.replace( 'editor', {
            scayt_autoStartup: true
    });
});
</script>

参见工作示例:http://jsfiddle.net/ddan/KS3p4/8/