fix: Diff modal原始版本大段空白修复(20260420_0009)

- currentHtml提取后添加 replace(/>(\s+)</g, '><') 压缩标签间空白
- cleanHtml处理后同样压缩, 确保diff两侧格式对齐
- 消除模板源码排版换行被diff算法误识别为删除内容的问题
This commit is contained in:
2026-04-20 00:10:31 +08:00
parent e549419a4c
commit 963a7541c9
4 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
# 功能变更实现方案文档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 只比对有意义的内容差异