引入js
<script src="__LIB__/kindeditor/kindeditor.js" type="text/javascript"></script>
html文件
<tr>
<th>描述</th><td colspan="2"><textarea id="content" name="content" class="form-control kindeditorSimple" style="height:150px;">{$info.content}</textarea></td>
</tr>
<script type="text/javascript">
KindEditor.create('#content', {
uploadJson : "{:U('Public/editorUpload')}",
allowFileManager : true,
bodyClass : 'article-content',
items : [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'emoticons', 'image', 'link']
});
</script>
//编辑器图片上传公共方法
public function editorUpload()
{
$upload = new \Think\Upload();
$upload->maxSize = 3145728;
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');
$upload->rootPath = './Public/uploads/attached/';
// 上传文件
$info = $upload->upload();
$imgUrl = '/Public/uploads/attached/' . $info['imgFile']['savepath'] . $info['imgFile']['savename'];
if (!$info) {
$this->ajaxReturn(array('error' => 1, 'message' => $upload->getError()));
} else {
$this->ajaxReturn(array('error' => 0, 'url' => $imgUrl));
}
}
详见http://zui.sexy/#javascript/htmleditor
850

被折叠的 条评论
为什么被折叠?



