<!DOCTYPE html>
|
<html lang="zh">
|
<head>
|
<th:block th:include="include :: header('Summernote富文本编辑器')" />
|
<th:block th:include="include :: summernote-css" />
|
</head>
|
<body class="gray-bg">
|
<div class="wrapper wrapper-content">
|
<div class="row">
|
<div class="col-sm-12">
|
<div class="click2edit wrapper"></div>
|
</div>
|
</div>
|
</div>
|
<th:block th:include="include :: footer" />
|
<th:block th:include="include :: summernote-js" />
|
<script>
|
$(document).ready(function () {
|
$('.click2edit').summernote({
|
lang: 'zh-CN',
|
focus: true,
|
height: 400,//结合高度和disableResizeEditor的使用可以固定窗口
|
followingToolbar: false,
|
//disableResizeEditor: true,
|
callbacks: {
|
onImageUpload: function (files) {
|
sendFile(files[0], this);
|
}
|
}
|
});
|
});
|
|
// 上传文件
|
function sendFile(file, obj) {
|
var data = new FormData();
|
data.append("file", file);
|
$.ajax({
|
type: "POST",
|
url: ctx + "common/images",
|
data: data,
|
cache: false,
|
contentType: false,
|
processData: false,
|
dataType: 'json',
|
success: function (result) {
|
if (result.code == web_status.SUCCESS) {
|
$(obj).summernote('editor.insertImage', result.url, result.fileName);
|
} else {
|
$.modal.alertError(result.msg);
|
}
|
},
|
error: function (error) {
|
$.modal.alertWarning("图片上传失败。");
|
}
|
});
|
}
|
|
</script>
|
</body>
|
</html>
|