Fix:修复复制带换行符的节点文本粘贴后会出现多行换行的问题
This commit is contained in:
parent
417376dcb6
commit
3355900bd3
@ -9,7 +9,8 @@ import {
|
|||||||
isUndef,
|
isUndef,
|
||||||
checkSmmFormatData,
|
checkSmmFormatData,
|
||||||
removeHtmlNodeByClass,
|
removeHtmlNodeByClass,
|
||||||
formatGetNodeGeneralization
|
formatGetNodeGeneralization,
|
||||||
|
nodeRichTextToTextWithWrap
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { CONSTANTS } from '../constants/constant'
|
import { CONSTANTS } from '../constants/constant'
|
||||||
|
|
||||||
@ -365,6 +366,21 @@ class RichText {
|
|||||||
},
|
},
|
||||||
theme: 'snow'
|
theme: 'snow'
|
||||||
})
|
})
|
||||||
|
// 拦截粘贴事件
|
||||||
|
this.quill.root.addEventListener('copy', event => {
|
||||||
|
event.preventDefault()
|
||||||
|
const sel = window.getSelection()
|
||||||
|
const originStr = sel.toString()
|
||||||
|
try {
|
||||||
|
const range = sel.getRangeAt(0)
|
||||||
|
const div = document.createElement('div')
|
||||||
|
div.appendChild(range.cloneContents())
|
||||||
|
const text = nodeRichTextToTextWithWrap(div.innerHTML)
|
||||||
|
event.clipboardData.setData('text/plain', text)
|
||||||
|
} catch (e) {
|
||||||
|
event.clipboardData.setData('text/plain', originStr)
|
||||||
|
}
|
||||||
|
})
|
||||||
this.quill.on('selection-change', range => {
|
this.quill.on('selection-change', range => {
|
||||||
// 刚创建的节点全选不需要显示操作条
|
// 刚创建的节点全选不需要显示操作条
|
||||||
if (this.isInserting) return
|
if (this.isInserting) return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user