打赏

kindeditor使用

下载地址http://kindeditor.net/down.php

@官方文档

使用步骤:

引入js

<script charset="utf-8" src="resource/kindeditor-4.1.7/kindeditor.js"></script>
<script charset="utf-8" src="resource/kindeditor-4.1.7/lang/zh_CN.js"></script>
View Code

 

 

编辑器初始化:

KindEditor.ready(function(K) {
        var editor1 = K.create('#editor_id',{
                                    uploadJson : '<%=basePath%>resource/kindeditor-4.1.7/jsp/upload_json.jsp',
                                    fileManagerJson : '<%=basePath%>resource/kindeditor-4.1.7/jsp/file_manager_json.jsp',
                                    allowFileManager : true,
                                    imageSizeLimit : '2MB', //批量上传图片单张最大容量
                                    imageUploadLimit : 5, //批量上传图片同时上传最多个数
                                    afterCreate : function() {
                                        var self = this;
                                        K.ctrl(document, 13, function() {
                                            self.sync();
                                            document.forms['example'].submit();
                                        });
                                        K.ctrl(self.edit.doc, 13, function() {
                                            self.sync();
                                            document.forms['example'].submit();
                                        });
                                    }
                                });
            });
View Code

 

html代码:

<textarea id="editor_id" name="newsContent"  ></textarea>
View Code

上传图片注意:

1,保存功能无需自己编写后台代码,配置好uploadJson 、 fileManagerJson 即可

2,若多图上传失败,请检查uploadJson 、 fileManagerJson的路径

posted @ 2017-05-25 14:21  每天都要学一点  阅读(170)  评论(0编辑  收藏  举报