修改编辑器复制错误
This commit is contained in:
parent
cc61263c97
commit
2406ad3b16
|
|
@ -80,7 +80,7 @@ const customPaste = (editor, event, callback) => {
|
|||
// 显示蒙版
|
||||
loadingShow.value = true
|
||||
let htmlData = event.clipboardData.getData('text/html') // 获取粘贴的 html
|
||||
// console.log(htmlData)
|
||||
console.log(htmlData)
|
||||
if (htmlData == "") {
|
||||
htmlData = event.clipboardData.getData('text/plain') // 获取粘贴的 html
|
||||
// console.log(htmlData)
|
||||
|
|
@ -96,10 +96,11 @@ const customPaste = (editor, event, callback) => {
|
|||
|
||||
// 从html内容中查找粘贴内容中是否有图片元素,并返回img标签的属性src值的集合
|
||||
const imgSrcs = htmlData.match(/<img [^>]*src=['"]([^'"]+)[^>]*>/g);
|
||||
if (imgSrcs && Array.isArray(imgSrcs) && imgSrcs.length) {
|
||||
//有图片,处理图片
|
||||
// console.log('imgSrcs', imgSrcs)
|
||||
if (rtfData !== "") {
|
||||
// 处理 word 内图片
|
||||
if (imgSrcs && Array.isArray(imgSrcs) && imgSrcs.length) {
|
||||
// 从rtf内容中查找图片数据
|
||||
const rtfImageData = extractImageDataFromRtf(rtfData);
|
||||
// 如果找到
|
||||
|
|
@ -111,9 +112,7 @@ const customPaste = (editor, event, callback) => {
|
|||
loadingShow.value = false
|
||||
callback(false)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (imgSrcs && Array.isArray(imgSrcs) && imgSrcs.length) {
|
||||
convertImgToBase64(imgSrcs).then(imgList => {
|
||||
imgList.forEach(item => {
|
||||
htmlData = htmlData.replace(item.src, item.tar)
|
||||
|
|
@ -124,12 +123,13 @@ const customPaste = (editor, event, callback) => {
|
|||
loadingShow.value = false
|
||||
callback(false)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
//无图片,直接复制
|
||||
editor.dangerouslyInsertHtml(htmlData);
|
||||
loadingShow.value = false
|
||||
callback(false)
|
||||
}
|
||||
}
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue