feat: Added support for copying and pasting images in article editor (#10044)

This commit is contained in:
Muhsin Keloth
2024-08-29 18:50:52 +05:30
committed by GitHub
parent 098825c149
commit 6dda1e8c8f

View File

@@ -120,7 +120,6 @@ export default {
if (fileUrl) { if (fileUrl) {
this.onImageUploadStart(fileUrl); this.onImageUploadStart(fileUrl);
} }
useAlert(this.$t('HELP_CENTER.ARTICLE_EDITOR.IMAGE_UPLOAD.SUCCESS'));
} catch (error) { } catch (error) {
useAlert(this.$t('HELP_CENTER.ARTICLE_EDITOR.IMAGE_UPLOAD.ERROR')); useAlert(this.$t('HELP_CENTER.ARTICLE_EDITOR.IMAGE_UPLOAD.ERROR'));
} }
@@ -173,6 +172,18 @@ export default {
blur: () => { blur: () => {
this.onBlur(); this.onBlur();
}, },
paste: (view, event) => {
const data = event.clipboardData.files;
if (data.length > 0) {
data.forEach(file => {
// Check if the file is an image
if (file.type.includes('image')) {
this.uploadImageToStorage(file);
}
});
event.preventDefault();
}
},
}, },
}); });
}, },