CKEDITOR settings override other settings

Asked

Viewed 582 times

1

On the same page I have 2 texarea. Since one of them is to be small and the other standard.

The pattern has autogrow and the small arrow maximum height of 100px.

The problem is that one configuration overwrites the other.

if(cksize == "small"){
    CKEDITOR.config.height = 100;
    CKEDITOR.config.autoGrow_maxHeight = 100;
}else{
    CKEDITOR.config.height = 0;
    CKEDITOR.config.autoGrow_maxHeight = 0;
}

There’s a way I can pass these options in the options json?

CKEDITOR.replace(id, options);

Being that inside that options would have all settings and height.

1 answer

2


Probably the author of the question has already solved his problem, but I will leave an answer to any similar questions. By calling CKEDITOR.config, you are advising Ckeditor that you intend to change the data of any instance of Ckeditor configured on the current page. That is, you will change the settings of the two instances you created. What can be done is, when creating the Ckeditor instance in Textarea, store this instance in a variable. You could create and configure the two instances in this way (taking into account that the smaller Textarea would have the id='editor1' and the standard id='editor2'):

var editor1 = CKEDITOR.replace('editor1');
var editor2 = CKEDITOR.replace('editor2');

editor1.config.height = 100;
editor1.config.autoGrow_maxHeight = 100;

editor2.config.height = 0;
editor2.config.autoGrow_maxHeight = 0;

This way you also eliminate the need for if.

  • Perfect, brother. 4 years later and still helping. Rs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.