From 2e94ede31beef71127fa233e88c5970a5932ea77 Mon Sep 17 00:00:00 2001 From: liangjiami <2249412933@qq.com> Date: Thu, 17 Jul 2025 17:01:17 +0800 Subject: [PATCH] 1 --- .../view/mobile/topic_nas/help_detail.html | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/app/index/view/mobile/topic_nas/help_detail.html b/app/index/view/mobile/topic_nas/help_detail.html index ae867184..23b325fa 100644 --- a/app/index/view/mobile/topic_nas/help_detail.html +++ b/app/index/view/mobile/topic_nas/help_detail.html @@ -176,33 +176,26 @@ }, 300); }); // 英文截断处理 - $('#rendered-content').css({ - 'word-wrap': 'break-word', - 'overflow-wrap': 'break-word', - 'word-break': 'normal', - 'white-space': 'normal', + // 目标容器:富文本内容所在的元素 + const contentContainer = $('#rendered-content'); + + // 遍历所有包含文本内容的标签(p、h1-h6、strong等) + contentContainer.find('*').each(function() { + const $element = $(this); + const htmlContent = $element.html(); + + // 条件1:排除内容仅为一个 的标签(如

 

) + if (htmlContent.trim() === ' ') { + return; // 不处理,继续下一个元素 + } + + // 条件2:检查是否包含 且有实际文本内容 + if (htmlContent.includes(' ')) { + // 将所有 替换为普通空格(有效占位符,支持单词完整换行) + const newContent = htmlContent.replace(/ /g, ' '); + $element.html(newContent); + } }); - - // 处理函数 - function processTextNodes($element) { - $element.contents().each(function() { - if (this.nodeType === 3) { // 文本节点 - let $parent = $(this).parent(); - let cleanHtml = $parent.html() - .replace(/<[^>]+>/g, '') // 移除所有标签 - .replace(/\s/g, ''); // 移除所有空白 - - if (cleanHtml !== ' ') { - $(this).replaceWith(this.nodeValue.replace(/ /g, ' ')); - } - } else if (this.nodeType === 1) { // 元素节点 - processTextNodes($(this)); - } - }); - } - - // 执行处理 - processTextNodes($('#rendered-content')); }); {/block} \ No newline at end of file