~~~
<script src="__TMPL__/public/hdlib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="__TMPL__/public/tinymce/jquery.tinymce.min.js"></script>
<script src="__TMPL__/public/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: 'textarea#mytextarea',
language: 'zh_CN',
language_url: "__TMPL__/public/tinymce/langs/zh_CN.js",
// images_upload_url: "{:url('portal/index/uploadImage')}",
images_upload_base_path: '/some/basepath',
images_upload_credentials: true,
automatic_uploads: true,
images_upload_handler: function(blobInfo, success, failure) {
var form = new FormData();
form.append('file', blobInfo.blob(), blobInfo.filename());
$.ajax({
url: "{:url('portal/index/uploadImage')}",
type: "post",
data: form,
processData: false,
contentType: false,
success: function(data) {
data = JSON.parse(data);
console.log(data.location);
success(data.location);
},
error: function(e) {
alert("图片上传失败");
}
});
},
file_picker_callback: function(callback, value, meta) {
var input = document.createElement('input');
input.setAttribute('type', 'file');
input.onchange = function() {
var file = this.files[0];
var form = new FormData();
form.append("file", file);
$.ajax({
url: "{:url('portal/index/uploadImage')}",
type: "post",
data: form,
processData: false,
contentType: false,
success: function(data) {
data = JSON.parse(data);
console.log(data.location);
callback(data.location);
},
error: function(e) {
alert("图片上传失败");
}
});
};
input.click();
},
plugins: [
'advlist autolink link image lists charmap hr pagebreak ',
'wordcount visualblocks visualchars fullscreen insertdatetime nonbreaking',
'table emoticons paste'
],
toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify |' +
' bullist numlist outdent indent | link image | fullpage | ' +
'forecolor backcolor emoticons',
menu: {
favs: {title: '表情', items: ' | emoticons'}
},
menubar: 'favs file edit view insert format tools table',
});
</script>
~~~