python KindEditord
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python KindEditord,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3486字,纯文字阅读大概需要5分钟。
内容图文
1、下载
- 官网下载:http://kindeditor.net/down.php
- 本地下载:http://files.cnblogs.com/files/wupeiqi/kindeditor_a5.zip
2、文件夹说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
├── asp asp示例
├── asp.net asp.net示例
├── attached 空文件夹,放置关联文件attached
├── examples HTML示例
├── jsp java示例
├── kindeditor
-
all
-
min
.js 全部JS(压缩)
├── kindeditor
-
all
.js 全部JS(未压缩)
├── kindeditor
-
min
.js 仅KindEditor JS(压缩)
├── kindeditor.js 仅KindEditor JS(未压缩)
├── lang 支持语言
├── license.txt License
├── php PHP示例
├── plugins KindEditor内部使用的插件
└── themes KindEditor主题
|
3、基本使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<textarea name
=
"content" id = "content" >< / textarea> <script src
=
"/static/jquery-1.12.4.js"
><
/
script>
<script src
=
"/static/plugins/kind-editor/kindeditor-all.js"
><
/
script>
<script>
$(function () {
initKindEditor();
});
function initKindEditor() {
var kind
= KindEditor.create( ‘#content‘ , {
width:
‘100%‘
,
/
/ 文本框宽度(可以百分比或像素)
height:
‘300px‘
,
/
/ 文本框高度(只能像素)
minWidth:
200
,
/
/ 最小宽度(数字)
minHeight:
400 / / 最小高度(数字)
});
}
<
/
script>
|
4、详细参数
http://kindeditor.net/docs/option.html
5、上传文件本质:上传图片时,点击上传 会默认帮你生成ifrem和form标签,然后在form标签里生成一个image标签,以Ajax方式发送到后台(伪Ajax)
CONIENT = ""def test(request): if request.method == "GET": return render(request,"test.html") else: content = request.POST.get("content") global CONIENT CONIENT = content print(content) return HttpResponse("...") def see(request): return render(request,"see.html",{"con":CONIENT}) import os def upload_img(request): #在之后可以根据获取到的dir判断是视频还是文件,这里没有用到 type_obj = request.POST.get("dir") print(request.POST, request.FILES) file_obj = request.FILES.get("imgFile") file_path = os.path.join("static/images/",file_obj.name) with open(file_path,"wb") as f: for chunk in file_obj.chunks(): f.write(chunk) #返回前端,可以预览 dic = { ‘error‘: 0, ‘url‘: "/" + file_path, ‘message‘: ‘错误了...‘ } import json return HttpResponse(json.dumps(dic))
urlpatterns = [ #上传图片,写文章 url(r‘^test/‘, views.test), #查看写的文章 url(r‘^see/‘, views.see), #上传图 视频 文件 url(r‘^upload_img.html‘, views.upload_img),
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form method="POST" action="/test/"> {% csrf_token %} <div> <div>文章内容</div> <div> <textarea id="id1" name="content"></textarea> </div> </div> <input type="submit" value="提交"> </form> <script src="/static/css/kindeditor-4.1.10/kindeditor-all.js"></script> <script> KindEditor.create("#id1",{ width:"700px", height:"800px", {# //items:[‘source‘, ‘|‘, ‘undo‘, ‘redo‘, ‘|‘, ‘preview‘, ‘print‘, ‘template‘, ‘code‘, ‘cut‘, ‘copy‘, ‘paste‘,#} // ‘plainpaste‘, ‘wordpaste‘, ‘|‘, ‘justifyleft‘, ‘justifycenter‘, ‘justifyright‘, // ‘justifyfull‘, ‘insertorderedlist‘, ‘insertunorderedlist‘, ‘indent‘, ‘outdent‘, ‘subscript‘, // ‘superscript‘, ‘clearhtml‘, ‘quickformat‘], //noDisableItems:[‘source‘, ‘|‘, ‘undo‘], //保留某些item //designMode:false //其它注释 //resizeType 改变窗口大小 uploadJson:"/upload_img.html", //上传文件 extraFileUploadParams:{ //上传文件时携带token "csrfmiddlewaretoken":"{{ csrf_token }}" } }) </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> {{ con | safe }} </body> </html>
原文:http://www.cnblogs.com/guobaoyuan/p/7242328.html
内容总结
以上是互联网集市为您收集整理的python KindEditord全部内容,希望文章能够帮你解决python KindEditord所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。