From c7bbabf26fbb798ec2cc6e4ef6c023eb22f94238 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 26 Sep 2024 14:48:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E8=B6=85=E9=93=BE=E6=8E=A5=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E5=BD=93=E5=89=8D=E7=AA=97=E5=8F=A3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rich-text/DeRichTextView.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue b/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue index 407bfc96d3..4263a24ffb 100644 --- a/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue +++ b/core/core-frontend/src/custom-component/rich-text/DeRichTextView.vue @@ -204,6 +204,7 @@ watch( canEdit.value = false reShow() myValue.value = assignment(element.value.propValue.textValue) + console.log('===myValue.value=' + 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 on = content.match(/\[(.+?)\]/g) if (on) { @@ -288,8 +306,10 @@ const assignment = content => { //De 本地跳转失效问题 content = content.replace(/href="#\//g, 'href="/#/') content = content.replace(/href=\\"#\//g, 'href=\\"/#/') + content = content.replace(/href=\\"#\//g, 'href=\\"/#/') resetSelect() initFontFamily(content) + jumpTargetAdaptor() return content } const initFontFamily = htmlText => {