CKEditor: Change value from config.js at runtime?


April 2019


2.5k time


I would like to have a switch for CKEditor's feature "forcePasteAsPlainText" that you can enable in config.js:

CKEDITOR.editorConfig = function( config ) {
  config.forcePasteAsPlainText = true;

From my website's js-file I now try to change the value for forcePasteAsPlainText with jquery:

 if(typeof(CKEDITOR) !== 'undefined') { 
    $('#filterTextButton').click(function () {
        CKEDITOR.config.forcePasteAsPlainText = !CKEDITOR.config.forcePasteAsPlainText;
        if(CKEDITOR.config.forcePasteAsPlainText) {
        else {

Problem is that I cannot access CKEDITOR.config.forcePasteAsPlainText. I get an undefined.

Converting the object CKEDITOR.config to a string, I see that there is an object named CKEDITOR.config.plugins holding a parameter called "pastetext" (belonging to forcePasteAsPlainText). But I don't know how to read or set this anew.

I read that one possibility to change the config value is to reinitialize the entire editor by replacing it at runtime... but there must be another solution!?

PS: I read here that you could use the following but this did not work for me:

CKEDITOR.on('instanceReady', function(ev) {
   ev.editor._.commands.paste = ev.editor._.commands.pastetext;

1 answers


Unfortunately, it isn't possible to modify forcePasteAsPlaintext without reinitializing editor. You can check here that this config setting is used only once - at startup.

Alternative solution is to switch off/on forcing paste as plaintext manually. E.g. like this:

// Set to false to switch forcing off.
var force = true;

editor.on( 'beforeCommandExec', function ( evt )
     var mode =;
     if ( force && == 'paste' && mode != 'html' )
         editor.execCommand( 'pastetext' );
}, null, null, 0 );

editor.on( 'beforePaste', function( evt )
    if ( force ) = 'text';