Files
Mdeical_Sur_Report/工程分析/20260420_0009/功能变更实现方案文档.md
admin 963a7541c9 fix: Diff modal原始版本大段空白修复(20260420_0009)
- currentHtml提取后添加 replace(/>(\s+)</g, '><') 压缩标签间空白
- cleanHtml处理后同样压缩, 确保diff两侧格式对齐
- 消除模板源码排版换行被diff算法误识别为删除内容的问题
2026-04-20 00:10:31 +08:00

20 lines
746 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 功能变更实现方案文档20260420_0009
## 实现方案
### 变更点 1currentHtml 提取后压缩空白
Line 933
```ts
const currentHtml = targetRegionEl ? targetRegionEl.innerHTML.replace(/&#8203;/g, '').trim() : '';
```
→ 添加 `.replace(/>(\s+)</g, '><')`
### 变更点 2cleanHtml 处理后压缩空白
Line 1016-1020
`cleanHtml.trim()` 之后追加 `.replace(/>(\s+)</g, '><')`
### 设计理由
- `>(\s+)<` 正则匹配任意 HTML 标签之间的空白字符(换行、空格、制表符),替换为 `><` 使 HTML 紧凑
- 仅影响 diff 比对前的数据清洗,不影响编辑器实际渲染
- 两侧(原始版本和 AI 版本)都做同样处理,确保 diff 只比对有意义的内容差异