修复纯文本的拷贝
This commit is contained in:
parent
1af72d2bb2
commit
e67b8d10b1
|
|
@ -81,10 +81,21 @@ const customPaste = (editor, event, callback) => {
|
||||||
loadingShow.value = true
|
loadingShow.value = true
|
||||||
let htmlData = event.clipboardData.getData('text/html') // 获取粘贴的 html
|
let htmlData = event.clipboardData.getData('text/html') // 获取粘贴的 html
|
||||||
// console.log(htmlData)
|
// console.log(htmlData)
|
||||||
|
|
||||||
if (htmlData == "") {
|
if (htmlData == "") {
|
||||||
|
// 如果是纯文本
|
||||||
htmlData = event.clipboardData.getData('text/plain') // 获取粘贴的 html
|
htmlData = event.clipboardData.getData('text/plain') // 获取粘贴的 html
|
||||||
// console.log(htmlData)
|
// 将 \n 替换为 p 标签
|
||||||
|
htmlData.replace(/\r/g, '');
|
||||||
|
htmlData = '<p>' + htmlData.replace(/\n/g, '</p><p>') + '</p>'
|
||||||
|
//无图片,直接复制
|
||||||
|
editor.dangerouslyInsertHtml(htmlData);
|
||||||
|
loadingShow.value = false
|
||||||
|
callback(false)
|
||||||
|
event.preventDefault()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let rtfData = event.clipboardData.getData('text/rtf') // 获取粘贴的 html
|
let rtfData = event.clipboardData.getData('text/rtf') // 获取粘贴的 html
|
||||||
// console.log('-------------- rtfData --------------', rtfData)
|
// console.log('-------------- rtfData --------------', rtfData)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue