|
|
@@ -90,7 +90,7 @@ export default {
|
|
|
// 为图片ICON绑定事件 getModule 为编辑器的内部属性
|
|
|
this[this.quillName]
|
|
|
.getModule("toolbar").addHandler("image", this.imgHandler);
|
|
|
-
|
|
|
+ this.changeParseEvent()
|
|
|
this.addLinkEvent()
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -109,6 +109,22 @@ export default {
|
|
|
}
|
|
|
this.uploadType = "image";
|
|
|
},
|
|
|
+ //change parse
|
|
|
+ changeParseEvent() {
|
|
|
+ // 自定义粘贴图片功能
|
|
|
+ this[this.quillName].root.addEventListener('paste', evt => {
|
|
|
+ console.log("evt", evt)
|
|
|
+ if (evt.clipboardData && evt.clipboardData.files && evt.clipboardData.files.length) {
|
|
|
+ evt.preventDefault();
|
|
|
+ [].forEach.call(evt.clipboardData.files, file => {
|
|
|
+ if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.handleContentFileChange({target: {files:[file]}})
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, false);
|
|
|
+ },
|
|
|
|
|
|
addLinkEvent() {
|
|
|
let dom = document.getElementsByClassName("ql-link")
|
|
|
@@ -158,8 +174,7 @@ export default {
|
|
|
}
|
|
|
// this.uploadType = "video";
|
|
|
},
|
|
|
- handleContentFileChange(e, name) {
|
|
|
- console.log('name', name)
|
|
|
+ handleContentFileChange(e) {
|
|
|
const file = e.target.files[0];
|
|
|
if (file.size / 1024/1024 > 2) {
|
|
|
this.$message.error("图片大小不得超过2M,请重新选择");
|