refine upload

This commit is contained in:
Pan
2017-04-24 15:13:17 +08:00
parent 47b24ca8b9
commit 9cd68d95ee
9 changed files with 99 additions and 54 deletions

View File

@@ -100,47 +100,38 @@
this.$emit('input', editor.getContent({ format: 'raw' }));
});
},
images_dataimg_filter(img) {
setTimeout(() => {
const $image = $(img);
$image.removeAttr('width');
$image.removeAttr('height');
if ($image[0].height && $image[0].width) {
$image.attr('data-wscntype', 'image');
$image.attr('data-wscnh', $image[0].height);
$image.attr('data-wscnw', $image[0].width);
$image.addClass('wscnph');
}
}, 0);
return img
},
images_upload_handler(blobInfo, success, failure, progress) {
progress(0);
const token = _this.$store.getters.token;
getToken(token).then(response => {
const url = response.data.qiniu_url;
const formData = new FormData();
formData.append('token', response.data.qiniu_token);
formData.append('key', response.data.qiniu_key);
formData.append('file', blobInfo.blob(), url);
upload(formData).then(() => {
success(url);
progress(100);
// setTimeout(() => {
// const doc = tinymce.activeEditor.getDoc();
// const $$ = tinymce.dom.DomQuery;
// const $image = $$(doc).find('img[src="' + url + '"]')
// $image.addClass('wscnph');
// $image.attr('data-wscntype', 'image');
// $image.attr('data-wscnh', $image[0].height || 640);
// $image.attr('data-wscnw', $image[0].width || 640);
// }, 0);
})
}).catch(err => {
failure('出现未知问题,刷新页面,或者联系程序员')
console.log(err);
});
},
// images_dataimg_filter(img) {
// setTimeout(() => {
// const $image = $(img);
// $image.removeAttr('width');
// $image.removeAttr('height');
// if ($image[0].height && $image[0].width) {
// $image.attr('data-wscntype', 'image');
// $image.attr('data-wscnh', $image[0].height);
// $image.attr('data-wscnw', $image[0].width);
// $image.addClass('wscnph');
// }
// }, 0);
// return img
// },
// images_upload_handler(blobInfo, success, failure, progress) {
// progress(0);
// const token = _this.$store.getters.token;
// getToken(token).then(response => {
// const url = response.data.qiniu_url;
// const formData = new FormData();
// formData.append('token', response.data.qiniu_token);
// formData.append('key', response.data.qiniu_key);
// formData.append('file', blobInfo.blob(), url);
// upload(formData).then(() => {
// success(url);
// progress(100);
// })
// }).catch(err => {
// failure('出现未知问题,刷新页面,或者联系程序员')
// console.log(err);
// });
// },
setup(editor) {
editor.addButton('h2', {
title: '小标题', // tooltip text seen on mouseover