Search code examples
ckeditorspell-checking

Enable/Disable Spell Check in Ckeditor (SCAYT) dynamically


I'm using SCAYT plugin for ckeditor with multiple languages.I have enabled scayt automatically on startup. via code I want to disable spell check when the user chooses language as Chinese/Japanese in the dropdown through the code. How can I do this ?


Solution

  • Use editor.execCommand to do enable/disable SCAYT manually (via code):

    CKEDITOR.instances.yourInstance.execCommand( 'scaytcheck' );
    

    If you want to decide whether to enable SCAT or not on the startup, use pluginsLoaded event to override the config option (see: fiddle):

    CKEDITOR.replace( 'editor', {
        plugins: 'wysiwygarea,sourcearea,basicstyles,toolbar,scayt',
        // Turn on SCAYT automatically
        scayt_autoStartup: true,
        on: {
            configLoaded: function() {
                // Disable SCAYT when japanese.
                if ( this.config.language == 'ja' )
                    this.config.scayt_autoStartup = false;
            }
        }
    } );