Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implementing ckeditor in laravel 5

I want to implement ckeditor in laravel 5. I have already installed IvoryCKEditorBundle. but for implementation the docs says to register a new form field type called ckeditor that extends the textarea.

How should I do that?

like image 721
Cliff Avatar asked Oct 25 '25 20:10

Cliff


1 Answers

You shouldn't need a bundle to use CKEditor - you can download the whole package of js files from the ckeditor website. Once you have it, place the folder containing all the downloaded files inside of your js folder

In your view you can now reference the ckeditor.js file:

{{ HTML::script('assets/js/plugins/ckeditor/ckeditor.js') }}   

Next include a short ckeditor script, which can include custom configuration (edit config in the js/plugins/ckeditor folder):

<script type="text/javascript">
         CKEDITOR.replace( 'messageArea',
         {
          customConfig : 'config.js',
          toolbar : 'simple'
          })
</script> 

add .ckeditor as a class in your textarea:

<textarea id="messageArea" name="messageArea" rows="7" class="form-control ckeditor" placeholder="Write your message.."></textarea>

if you are posting your content using ajax, use something like this to get the textarea value:

var message = CKEDITOR.instances.messageArea.getData();
like image 148
retrograde Avatar answered Oct 27 '25 11:10

retrograde