fix: 修复富文本超链接不支持跳转当前窗口问题

This commit is contained in:
wangjiahao 2024-09-26 14:48:22 +08:00
parent 7c1fa23b5b
commit c7bbabf26f

View File

@ -204,6 +204,7 @@ watch(
canEdit.value = false canEdit.value = false
reShow() reShow()
myValue.value = assignment(element.value.propValue.textValue) myValue.value = assignment(element.value.propValue.textValue)
console.log('===myValue.value=' + myValue.value)
ed.setContent(myValue.value) ed.setContent(myValue.value)
} }
} }
@ -263,6 +264,23 @@ const initCurFieldsChange = () => {
} }
} }
const jumpTargetAdaptor = () => {
setTimeout(() => {
const paragraphs = document.querySelectorAll('p')
paragraphs.forEach(p => {
// p onclick event.stopPropagation
if (
p.getAttribute('onclick') &&
p.getAttribute('onclick').includes('event.stopPropagation()')
) {
return // stopPropagation
}
// onclick
p.setAttribute('onclick', 'event.stopPropagation()')
})
}, 1000)
}
const assignment = content => { const assignment = content => {
const on = content.match(/\[(.+?)\]/g) const on = content.match(/\[(.+?)\]/g)
if (on) { if (on) {
@ -288,8 +306,10 @@ const assignment = content => {
//De //De
content = content.replace(/href="#\//g, 'href="/#/') content = content.replace(/href="#\//g, 'href="/#/')
content = content.replace(/href=\\"#\//g, 'href=\\"/#/') content = content.replace(/href=\\"#\//g, 'href=\\"/#/')
content = content.replace(/href=\\"#\//g, 'href=\\"/#/')
resetSelect() resetSelect()
initFontFamily(content) initFontFamily(content)
jumpTargetAdaptor()
return content return content
} }
const initFontFamily = htmlText => { const initFontFamily = htmlText => {