富文本 图片上传
This commit is contained in:
parent
d0bd515ed4
commit
879f46b984
|
|
@ -262,7 +262,34 @@
|
|||
onChange: function (contents, $edittable) {
|
||||
// Xss 过滤掉了html 内容 ,所以用base64 保存
|
||||
$("input[name='" + this.id + "']").val(window.btoa(encodeURI(contents)));
|
||||
|
||||
},
|
||||
onImageUpload: function(files) {
|
||||
var _self = this;
|
||||
for(var i = 0; i < files.length; i++){
|
||||
var formData = new FormData();
|
||||
formData.append('file', files[i]);
|
||||
var config = {
|
||||
url: '/common/upload',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
beforeSend: function () {
|
||||
$.modal.loading("正在处理中,请稍后...");
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.code == web_status.SUCCESS) {
|
||||
$('#'+ _self.id).summernote('insertImage',result.url);
|
||||
} else if (result.code == web_status.WARNING) {
|
||||
$.modal.alertWarning(result.msg)
|
||||
} else {
|
||||
$.modal.alertError(result.msg);
|
||||
}
|
||||
$.modal.closeLoading();
|
||||
}
|
||||
};
|
||||
$.ajax(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -265,18 +265,46 @@
|
|||
#if($isSummernote)
|
||||
$(function () {
|
||||
$('.summernote').each(function (i) {
|
||||
var content = $("input[name='" + this.id + "']").val()
|
||||
content = decodeURI(window.atob(content));
|
||||
this.innerHTML = content;
|
||||
$(this).summernote({
|
||||
$('#'+this.id).summernote({
|
||||
height: 100,
|
||||
lang: 'zh-CN',
|
||||
callbacks: {
|
||||
onChange: function (contents, $edittable) {
|
||||
$("input[name='" + this.id + "']").val(window.btoa(encodeURI(contents)));
|
||||
},
|
||||
onImageUpload: function(files) {
|
||||
var _self = this;
|
||||
for(var i = 0; i < files.length; i++){
|
||||
var formData = new FormData();
|
||||
formData.append('file', files[i]);
|
||||
var config = {
|
||||
url: '/common/upload',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
beforeSend: function () {
|
||||
$.modal.loading("正在处理中,请稍后...");
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.code == web_status.SUCCESS) {
|
||||
$('#'+ _self.id).summernote('insertImage',result.url);
|
||||
} else if (result.code == web_status.WARNING) {
|
||||
$.modal.alertWarning(result.msg)
|
||||
} else {
|
||||
$.modal.alertError(result.msg);
|
||||
}
|
||||
$.modal.closeLoading();
|
||||
}
|
||||
};
|
||||
$.ajax(config)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
var content = $("input[name='" + this.id + "']").val()
|
||||
content = decodeURI(window.atob(content));
|
||||
$('#'+this.id).summernote('code',content);
|
||||
})
|
||||
});
|
||||
#end
|
||||
|
|
|
|||
Loading…
Reference in New Issue