Sync inserted AI regions immediately

- Track report editor AI regions in React state instead of only scanning contentEditable DOM during render.

- Observe editor AI region mutations and refresh the AI writing target dropdown without requiring page navigation or refresh.

- Select newly inserted AI regions immediately after insertion and keep a live DOM fallback for generation.

- Harden AI region insertion so it still appends the region if execCommand has no active editor selection.

- Escape AI region names before injecting template HTML and add an accessible label for the insert button.

- Add Playwright coverage for inserting an AI region and seeing it immediately in the AI writing dropdown.

- Update report editor, feature, progress, testing, and AGENTS documentation for AI region synchronization.
This commit is contained in:
2026-05-02 04:08:48 +08:00
parent 5a4056d899
commit 7631ae34ce
7 changed files with 101 additions and 15 deletions

View File

@@ -42,6 +42,7 @@ npm run build
| E2E 登录流程 | Playwright 验证默认快捷登录进入工作台。 |
| E2E 权限过滤 | Playwright 验证超级管理员、管理员、医生在报告管理页的可见范围。 |
| E2E 报告修订 | Playwright 验证已完成报告再次完成保存后 `revision` 递增并保留历史。 |
| E2E 报告 AI 区域同步 | Playwright 验证报告编辑器中新插入的 AI 可编辑区域会立即出现在 AI 撰写目标下拉栏。 |
| E2E 个人模板 | Playwright 验证医生可保存个人模板且模板仅归属本人。 |
| E2E 模板管理 | Playwright 验证管理员新增模板后点击保存内容,模板仍保留在列表且后端可查询。 |
| E2E 路由守卫和审计日志 | Playwright 验证医生不能直进管理页,超级管理员可查看审计日志。 |
@@ -87,6 +88,7 @@ AI 第三方接口、讯飞语音上游 WebSocket、麦克风权限和真实视
| 默认快捷登录 | 已覆盖 | `e2e/login.spec.ts` |
| 报告权限 E2E | 已覆盖 | `e2e/report-permissions.spec.ts` |
| 报告修订版本 E2E | 已覆盖 | `e2e/report-revision.spec.ts` |
| 报告 AI 区域同步 E2E | 已覆盖 | `e2e/report-ai-region.spec.ts` |
| 医生个人模板 E2E | 已覆盖 | `e2e/personal-template.spec.ts` |
| 模板管理新增保存 E2E | 已覆盖 | `e2e/template-management.spec.ts` |
| 路由守卫和审计日志 E2E | 已覆盖 | `e2e/audit-and-route-guards.spec.ts` |