修改编辑器复制错误

This commit is contained in:
jacky 2024-05-23 12:01:24 +08:00
parent cc61263c97
commit 2406ad3b16
1 changed files with 12 additions and 12 deletions

View File

@ -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) => {
// htmlimgsrc
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()
}