Skip to content Skip to sidebar Skip to footer

Changing Configuration Options Of A Ckeditor Instance

I have a CKEditor instance attached to a textarea. I would like to be able change some configuration options of this instance after its creation, depending on the value of another

Solution 1:

Usually the configuration options will work only upon creation. You might be able to perform some tricks and so get some of the options to work at a later time, but that's usually more difficult.

Solution 2:

I know I am late. But I would like to share this.

If you decide on a config before the creation of a ckeditor instance and plan on overriding those configurations, it's not possible. You can definitely add more config options but cannot change any existing option.

Say you pass a config object while creation of an instance.

CKEDITOR will internally call replace function to create the instance. Which will, in turn, check if anything is present in config.js.

You provide some extra config option and also, you try to override any existing option, for eg., toolbar.

Internally, CKEDITOR will do an extend and will try to merge already existing config object and the new config object provided by config.js and finally create a new config object which it will use to create the instance.

When it extends, i.e tries to merge both the config object, it will take all the new config options and assign to final new config object. But, for existing config options which you tried to override in config.js, it will take the original option and assign to this new config object.

Hence, whatever you had provided to override existing config object is lost.

One option which you have is to destroy the current instance and use your new config object to create the instance.

I hope I was able to explain.

Post a Comment for "Changing Configuration Options Of A Ckeditor Instance"