|
|
@ -75,7 +75,6 @@ |
|
|
|
readOnly: this.readonly |
|
|
|
readOnly: this.readonly |
|
|
|
}, |
|
|
|
}, |
|
|
|
loading: false, |
|
|
|
loading: false, |
|
|
|
quillArr: [], |
|
|
|
|
|
|
|
qu: null |
|
|
|
qu: null |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
@ -125,8 +124,7 @@ |
|
|
|
const editor = eval(toeval) |
|
|
|
const editor = eval(toeval) |
|
|
|
// 初始化编辑器 |
|
|
|
// 初始化编辑器 |
|
|
|
this.Quill = new Quill(editor, this.options); |
|
|
|
this.Quill = new Quill(editor, this.options); |
|
|
|
this.quillArr.push(this.Quill) |
|
|
|
const ins = this.Quill |
|
|
|
|
|
|
|
|
|
|
|
// 默认值 |
|
|
|
// 默认值 |
|
|
|
this.Quill.pasteHTML(this.currentValue); |
|
|
|
this.Quill.pasteHTML(this.currentValue); |
|
|
|
if(this.toTop){ |
|
|
|
if(this.toTop){ |
|
|
@ -156,9 +154,35 @@ |
|
|
|
this.Quill.on('editor-change', (eventName, ...args) => { |
|
|
|
this.Quill.on('editor-change', (eventName, ...args) => { |
|
|
|
this.$emit('on-editor-change', eventName, ...args); |
|
|
|
this.$emit('on-editor-change', eventName, ...args); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 监听粘贴事件 |
|
|
|
|
|
|
|
ins.root.addEventListener('paste', 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 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const param = new FormData() |
|
|
|
|
|
|
|
param.append('file', file) |
|
|
|
|
|
|
|
// 把图片上传到服务器,不然会直接把base64存到数据库 |
|
|
|
|
|
|
|
this.$post(this.api.fileupload, param, { |
|
|
|
|
|
|
|
headers: { "Content-Type": "multipart/form-data" } |
|
|
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
|
|
var range = ins.getSelection() |
|
|
|
|
|
|
|
console.log(333, range) |
|
|
|
|
|
|
|
if (range) { |
|
|
|
|
|
|
|
// 在当前光标位置插入图片 |
|
|
|
|
|
|
|
ins.insertEmbed(range.index, 'image', res.data.filesResult.fileUrl) |
|
|
|
|
|
|
|
// 将光标移动到图片后面 |
|
|
|
|
|
|
|
ins.setSelection(range.index + 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).catch(res => {}) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, false) |
|
|
|
}, |
|
|
|
}, |
|
|
|
beforeUpload(file){ |
|
|
|
beforeUpload(file){ |
|
|
|
console.log('上传前:',this.qu,this.toref,this.Quill,this.quillArr) |
|
|
|
|
|
|
|
this.loading = true |
|
|
|
this.loading = true |
|
|
|
}, |
|
|
|
}, |
|
|
|
editorUploadSuccess (res) { |
|
|
|
editorUploadSuccess (res) { |
|
|
|