KindEditor 编辑器使用
来源:互联网 发布:淘宝搜图片同款 编辑:程序博客网 时间:2024/06/12 00:31
需要引用的文件
<link rel="stylesheet" href="__PUBLIC__/js/kindeditor/themes/default/default.css" /><link rel="stylesheet" href="__PUBLIC__/js/kindeditor/plugins/code/prettify.css" /><script charset="utf-8" src="__PUBLIC__/js/kindeditor/kindeditor-all.js"></script><script charset="utf-8" src="__PUBLIC__/js/kindeditor/lang/zh-CN.js"></script><script charset="utf-8" src="__PUBLIC__/js/kindeditor/plugins/code/prettify.js"></script>
<div class="row"> <div class="col-md-1"> <label>内容</label></div> <div class="col-md-6"> <textarea name="content" style="width:700px;height:200px;visibility:hidden;">{$data.content} </textarea> </div></div>
<script> KindEditor.ready(function(K) { var editor1 = K.create('textarea[name="content"]', { cssPath : '__PUBLIC__/js/kindeditor/plugins/code/prettify.css', uploadJson : '__PUBLIC__/js/kindeditor/php/upload_json.php', fileManagerJson : '__PUBLIC__/js/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>
由于要使用编辑器上传图片,所以有时要修改upload_json.php 文件中上传图片的路径。另外要注意函数realpath(),由于文件路径中没有attached 这个文件夹,realpath() 会返回空,导致出错。
$php_path = dirname(__FILE__) . '/';$php_url = dirname($_SERVER['PHP_SELF']) . '/';//文件保存目录路径$save_path = $php_path . 'attached/';//文件保存目录URL$save_url = $php_url . 'attached/';//定义允许上传的文件扩展名$ext_arr = array( 'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp'), 'flash' => array('swf', 'flv'), 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'),);//最大文件大小$max_size = 1000000;$save_path = realpath($save_path) . '/';
获取编辑器中的内容
KindEditor.ready(function (K) { var editor=KindEditor.create('#content', { uploadJson : '{:U("attachment/editer_upload")}', fileManagerJson : '{:U("attachment/editer_manager")}', allowFileManager : true }); K(".submit").click(function (e) { formcheck(); var val=editor.text(); });});
0 0
- kindEditor编辑器的使用
- KindEditor编辑器的使用
- kindeditor文本编辑器使用
- 使用kindeditor文本编辑器
- kindEditor编辑器的使用
- KindEditor编辑器使用
- KindEditor编辑器的使用
- KindEditor 编辑器使用
- thinkphp使用编辑器kindeditor
- KindEditor编辑器的使用
- KindEditor编辑器使用
- KindEditor在线文本编辑器使用
- kindeditor 文本框编辑器 简单使用
- KindEditor 编辑器之简易使用
- html编辑器kindeditor的使用
- 网页编辑器kindeditor的使用
- 前端编辑器-kindeditor的使用
- struts2下kindeditor编辑器使用
- win10本地账户转微软账户的简单方法
- 开源中国的版本更新
- POJ 3304 Segments (计算几何、判断直线与线段是否相交)
- set集合容器
- 电路第一章
- KindEditor 编辑器使用
- 广播接收器 broadcast sendOrderedBroadcast android
- Python网络编程——urllib,urllib2(2),附带部分GUI基础
- 一个Linux shell脚本,关于CI上打包的
- HBase不稳定因素分析
- SourceTree使用
- [LeetCode] 292. Nim Game
- 自定义控件
- 数据结构实验之排序二:交换排序