kindeditor.png

kindeditor编辑器也是一款不错的编辑器,下面我来给各位介绍thinkphp整合kindeditor编辑器方法,有需要了解的同学可参考。

具体方法
KindEditor主要特点
快速:体积小,加载速度快
开源:开放源代码,高水平,高品质
底层:内置自定义 DOM 类库,精确操作 DOM
扩展:基于插件的设计,所有功能都是插件,可根据需求增减功能
风格:修改编辑器风格非常容易,只需修改一个 CSS 文件
兼容:支持大部分主流浏览器,比如 IE、Firefox、Safari、Chrome、Opera

下面说一下kindeditor在thinkphp中的使用
步骤1:下载kindeditor编辑器http://www.kindsoft.net/
步骤2:文件引入

<link rel="stylesheet" href="__PUBLIC__/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="__PUBLIC__/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="__PUBLIC__/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>

步骤3:配置参数

<script>
    KindEditor.ready(function(K) {
        var editor1 = K.create('textarea[name="content"]', {
            cssPath : '__PUBLIC__/kindeditor/plugins/code/prettify.css',
            uploadJson : '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson : '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager : true,
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>
<textarea name="content" style="width:700px;height:200px;visibility:hidden;"></textarea>

textarea 中的content和function的content对应
kindeditor html代码过滤不能保存
这是因为编辑器默认开启了过滤模式(filterMode:true)。当filterMode为true时,编辑器会根据htmlTags设定自动过滤HTML代码,主要是为了生成干净的代码。
如果想保留所有HTML,修改kindeditor.js,请将filterMode设置成false。如果想保留特定HTML,请将filterMode设置成true后,配置htmlTags属性。
转载自:http://www.111cn.net/phper/thinkPhp/49368.htm

滇ICP备16003699号-2
最后修改:2018 年 08 月 23 日
如果觉得我的文章对你有用,请随意赞赏