Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change height for only one textarea using ckeditor

I get 3 ckeditor textareas in one page. The problem is that I want one of the textarea to be the same size than twice the others. I can't find how to resize ONLY ONE textarea.

<script type="text/javascript">
        CKEDITOR.config.height='600px';
</script>

Works fine but it changes all the textareas. I also tried

<script type="text/javascript">            
     CKEDITOR.replace('Resolution',{
                height  : '400px',
   });
</script>

But this doesn't work... I tried to change my config.js file but still nothing. If i put in my config.js

CKEDITOR.editorConfig = function( config ) {

        config.width = '1000px';
        config.height = '700px'; 
};

It doesn't work.

To summarize: How can i resize a textarea using its ID ??

like image 629
Hearner Avatar asked Jun 02 '15 12:06

Hearner


People also ask

How to increase HEIGHT of textarea in CKEditor?

CKEDITOR. editorConfig = function( config ) { config. width = '1000px'; config. height = '700px'; };

How do I change Ckeditor height?

The CKEDITOR. config. height option sets the height of the editing area with CKEditor 4 content — it does not include the toolbar or the bottom bar. This configuration option accepts an integer (to denote a value in pixels) or any CSS-defined length unit except percent ( % ) values which are not supported.

What is Ckeditor replace?

The CKEditor 4 Find and Replace feature allows for finding and replacing any text in the editor easily. It helps the user find words, word parts or phrases matching the case of the searched text, which is especially helpful in lengthy documents and one that may utilize certain words in different contexts.

How do you implement Ckeditor?

To start, create a simple HTML page with a <textarea> element in it. You will then need to do two things: Include the <script> element loading CKEditor 4 in your page. Use the CKEDITOR.


1 Answers

Used CSS to change height on the editor:

.ck-editor__editable {
  min-height: 200px;
}

Here is one more example (based on CKEditor5):

let theEditor;

ClassicEditor
  .create(document.querySelector('#editor'), {

    toolbar: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote']
  })
  .then(editor => {
    theEditor = editor;

  })
  .catch(error => {
    console.error(error);
  });


function getDataFromTheEditor() {
  return theEditor.getData();
}

document.getElementById('getdata').addEventListener('click', () => {
  alert(getDataFromTheEditor());
});
.ck-editor__editable {
  min-height: 200px;
}
<script src="https://cdn.ckeditor.com/ckeditor5/10.0.1/classic/ckeditor.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea name="content" id="editor">
<p>Here goes the initial content of the editor.</p>
</textarea>
<button id="getdata">Print data</button>
like image 122
Penny Liu Avatar answered Oct 19 '22 19:10

Penny Liu