首页 文章

在laravel 5中实现ckeditor

提问于
浏览
0

我想在laravel 5中实现ckeditor . 我已经安装了IvoryCKEditorBundle . 但是为了实现,文档说要注册一个名为ckeditor的新表单字段类型,它扩展了textarea .

我该怎么办?

2 回答

  • 12

    您不需要捆绑来使用CKEditor - 您可以从ckeditor website下载整个js文件包 . 获得后,将包含所有下载文件的文件夹放在js文件夹中

    在您的视图中,您现在可以引用ckeditor.js文件:

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

    接下来包括一个简短的ckeditor脚本,它可以包含自定义配置(在js / plugins / ckeditor文件夹中编辑配置):

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

    将.ckeditor添加为textarea中的类:

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

    如果您使用ajax发布内容,请使用以下内容来获取textarea值:

    var message = CKEDITOR.instances.messageArea.getData();
    
  • 0

    按照这个你可以做1分钟 .

    https://github.com/UniSharp/laravel-ckeditor
    

    谢谢 .

相关问题