ueditor和后台通信的功能较多,这里列一下编辑器和后台通信的功能:
为了规范化前后端通信的请求,这里统一规范前端请求格式和后端数据返回格式
cb({"key": "value"})
以下是各类型的请求说明
请求参数:
GET {"action": "config"} POST "upfile": File Data返回格式:
// 需要支持callback参数,返回jsonp格式
{
"imageUrl": "http://localhost/ueditor/php/controller.php?action=uploadimage",
"imagePath": "/ueditor/php/",
"imageFieldName": "upfile",
"imageMaxSize": 2048,
"imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"]
}
请求参数:
GET {"action": "uploadimage"} POST "upfile": File Data返回格式:
{
"state": "SUCCESS",
"url": "upload/demo.jpg",
"title": "demo.jpg",
"original": "demo.jpg"
}
请求参数:
GET {"action": "uploadscrawl"} POST "content": Base64 Data返回格式:
{
"state": "SUCCESS",
"url": "upload/demo.jpg",
"title": "demo.jpg",
"original": "demo.jpg"
}
请求参数:
GET {"action": "uploadvideo"} POST "upfile": File Data返回格式:
{
"state": "SUCCESS",
"url": "upload/demo.mp4",
"title": "demo.mp4",
"original": "demo.mp4"
}
请求参数:
GET {"action": "uploadfile"} POST "upfile": File Data返回格式:
{
"state": "SUCCESS",
"url": "upload/demo.zip",
"title": "demo.zip",
"original": "demo.zip"
}
请求参数:
GET {"action": "listimage", "start": 0, "size": 20}返回格式:
// 需要支持callback参数,返回jsonp格式
{
"state": "SUCCESS",
"list": [{
"url": "upload/1.jpg"
}, {
"url": "upload/2.jpg"
}, ],
"start": 20,
"total": 100
}
请求参数:
GET { "action": "catchimage", "source": [ "http://a.com/1.jpg", "http://a.com/2.jpg" ] }返回格式:
// 需要支持callback参数,返回jsonp格式
// list项的state属性和最外面的state格式一致
{
"state": "SUCCESS",
"list": [{
"url": "upload/1.jpg",
"source": "http://b.com/2.jpg",
"state": "SUCCESS"
}, {
"url": "upload/2.jpg",
"source": "http://b.com/2.jpg",
"state": "SUCCESS"
}, ]
}