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

24 lines
1.0 KiB
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
## 需求:修复 AI 修改确认弹窗原始版本的大段空白
### 问题背景
`defaultContent.ts` 模板源码中 `<p>` 标签之间存在大量换行和缩进空白(代码排版需要)。当 `currentHtml``.ai-content``innerHTML` 读取时这些空白被完整保留。AI 返回的 `updatedHtml` 是紧凑的(无多余空白)。`diffChars` 比对时将原始 HTML 中的空白字符标记为 `removed``\n` 被转为 `<br>` 渲染,导致左侧"原始版本"出现大段空白。
### 根因
模板源码:
```html
</p>
<p style="...">
```
读取后的 `currentHtml` 包含 `</p>\n\n <p>`,而 AI 返回的是 `</p><p>`,差异被标记为删除并渲染为多个 `<br>`
### 解决方案
`handleAIGenerate` 中:
1. `currentHtml` 提取后,添加 `.replace(/>(\s+)</g, '><')` 压缩标签间空白
2. `cleanHtml` 处理后,同样添加 `.replace(/>(\s+)</g, '><')` 保持两侧格式对齐
### 影响范围
- `src/pages/ReportEditor.tsx`