在 Laravel 5 中实现 ckeditor

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30467275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:38:42  来源:igfitidea点击:

implementing ckeditor in laravel 5

laravellaravel-4laravel-5

提问by Cliff

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.

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

How should I do that?

我该怎么做?

回答by retrograde

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

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

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

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

{{ 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):

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

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

add .ckeditor as a class in your textarea:

在你的 textarea 中添加 .ckeditor 作为一个类:

<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:

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

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

回答by Y. Joy Ch. Singha

Follow this you can do it by 1 minute.

按照这个你可以做到1分钟。

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

Thanks.

谢谢。