使用jodit版本3和此处的版本2说明:https://xdsoft.net/jodit/v.2/doc/global.html#askBeforePasteHTML用于上传图像,看来图像形式数据始终为空。
我还注意到,当我执行console.log时,永远都不会调用'process'函数,而且我不知道这是否正常。
对于我配置的内容,我希望console.log会说 数据是$ data 接着 关键是媒体
相反,数据为FormData {},键为空。
这是我的配置:
let jodit_conf =
{
/*defaultMode: Jodit.MODE_SPLIT,*/
enableDragAndDropFileToEditor: true,
uploader:
{
url: '/api/v1/user/tmp/image',
headers: {"token":`${db.token}`},
format: 'json',
pathVariableName: 'path',
filesVariableName: 'media',
process: function (resp)
{
let r = {};
r.files = resp[this.options.uploader.filesVariableName] || [];
r.path = resp.path;
r.baseurl = resp.baseurl;
r.error = resp.error;
r.msg = resp.msg;
console.log("process ", r, resp);
return r;
},
prepareData: function (data)
{
console.log("data is ", data);
console.log("keys are ", Object.keys(data));
return data;
},
isSuccess: function (resp)
{
console.log("isSuccess ", resp);
return resp.success;
},
getMsg: function (resp)
{
console.log(resp.msg);
return resp.msg.join !== undefined ? resp.msg.join(' ') : resp.msg;
},
error: function (e)
{
alert("Error placing image");
},
defaultHandlerSuccess: function (data, resp)
{
console.log("defaultHandlerSuccess ", data, resp);
var i, field = this.options.uploader.filesVariableName;
if (data[field] && data[field].length)
{
for (i = 0; i < data[field].length; i += 1)
{
this.selection.insertImage(data.baseurl + data[field][i]);
}
}
},
defaultHandlerError: function (resp)
{
this.events.fire('errorPopap', [this.options.uploader.getMsg(resp)]);
},
}
};