kindeditor小使用
标签:
JavaScript
kindeditor编辑器
-
下载kindeditor插件包
- 提供的php文件夹中有upload_json.php,file_manager_json.php来设置文件上传。
-
引入js,css文件
<link rel="stylesheet" href="./k-editor/plugins/code/prettify.css" /> <script charset="utf-8" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="./k-editor/kindeditor-all.js"></script> <script charset="utf-8" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="./k-editor/lang/zh-CN.js"></script> <script charset="utf-8" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="./k-editor/plugins/code/prettify.js"></script>
-
html中js写入
KindEditor.ready(function(K) { var editor = K.create('#content', { cssPath : './k-editor/plugins/code/prettify.css', uploadJson : './k-editor/php/upload_json.php', fileManagerJson : './k-editor/php/file_manager_json.php', allowFileManager : true, newlineTag : 'br', afterCreate : function() { this.sync(); // 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(); // }); }, afterBlur : function(){this.sync();} }); prettyPrint(); editor.html('<?php echo htmlspecialchars_decode($content); ?>'); $('#submit').click(function() { var help_doc_id = $("#help_doc_id").val() ; var title = $("#title").val(); var content = editor.html(); $.ajax({ type: "POST", url: "help_and_support_save.php", contentType: "application/json; charset=utf-8", data: JSON.stringify({"help_doc_id":help_doc_id,"title":title,"content":content}), cache: false, dataType: 'json', success:function(res) { if( res.code == 0 ) { alert('保存成功!'); window.location.href = 'help_and_support_list.php'; } else { alert('抱歉,保存失败!' + res.data); } } }); }); });
-
- 提交的php页面中获取 content ,然后存入数据库
$content = htmlspecialchars($content);
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦