adods
adods

Reputation: 328

CKEditor 4 - replaceAll() with custom config

After checking the source code, it seems that CKEDITOR.replaceAll function can't pass any custom config on call.

Is there any workaround, so that I can pass different custom config to specific textarea?

e.g. I want all textarea that has class "advanced" have different browse image path from textarea with class "normal"

Upvotes: 3

Views: 4977

Answers (2)

Colin Shipton
Colin Shipton

Reputation: 159

For anyone else landing here after a Google search Anna Oleksiuk answer pointed me in the right direction for what I wanted to achieve. I had multiple textarea fields on the page, some which needed a basic config (i.e. comments), some which needed the standard config and some which neeeded to remain as a standard textarea, the following worked for me:

CKEDITOR.replaceAll(function (textarea, config) {
  if (textarea.className === "ck-standard") {
    config.customConfig = "/theme/js/ckeditor/standard.js";
    return true;
  }
  else if (textarea.className === "ck-basic") {
    config.customConfig = "/theme/js/ckeditor/basic.js";
    return true;
  }

  return false;
});

The key element as far as I was concerned was return false; to stop any other fields being converted.

Upvotes: 1

Anna Oleksiuk
Anna Oleksiuk

Reputation: 64

CKEDITOR.replaceAll(function(textarea,config) {
    if(textarea.className == "advanced")
    {
        config.removeButtons = 'About';
        return true;
    }
    else if(textarea.className == "basic")
    {
        config.removeButtons = 'Cut,Copy,Paste,About,Save,NewPage,DocProps,Preview,Templates,PasteFromWord,SelectAll,Scayt,SpellChecker,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,JustifyLeft,JustifyCenter,JustifyRight,JustifyBlock,Flash,Smiley,Styles,Font,FontSize,Blockquote,Format,Image,Table,Link';
        config.uiColor = '#AADC6E';
        return true;
    }
});

Upvotes: 2

Related Questions