From 7631ae34ced00455953768e4939d8bd539009b83 Mon Sep 17 00:00:00 2001 From: admin <572701190@qq.com> Date: Sat, 2 May 2026 04:08:48 +0800 Subject: [PATCH] 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. --- AGENTS.md | 2 +- docs/features.md | 2 +- docs/modules/report-editor.md | 2 + docs/progress.md | 2 + docs/testing.md | 2 + e2e/report-ai-region.spec.ts | 25 +++++++++++ src/pages/ReportEditor.tsx | 81 +++++++++++++++++++++++++++++------ 7 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 e2e/report-ai-region.spec.ts diff --git a/AGENTS.md b/AGENTS.md index 537e782..f5a1f57 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -343,7 +343,7 @@ PostgreSQL 数据模型。当前覆盖 `Tenant`、`Department`、`User`、`UserS - 报告管理按角色过滤 - 管理员本部门报告范围和医生本人报告范围 - 模板可用范围,含部门模板和医生个人模板 -- Playwright E2E 通过真实后端 API seed 覆盖登录、报告权限、报告修订版本、医生个人模板、模板管理新增保存、路由守卫和审计日志 +- Playwright E2E 通过真实后端 API seed 覆盖登录、报告权限、报告修订版本、报告 AI 区域同步、医生个人模板、模板管理新增保存、路由守卫和审计日志 - 后端权限策略覆盖报告、模板、用户管理和管理员创建规则 - 后端 Dashboard 统计按角色范围过滤 - 后端报告 metadata 兼容映射和 `ReportMedia` 视频/关键帧组装 diff --git a/docs/features.md b/docs/features.md index dc8a131..192f5a1 100644 --- a/docs/features.md +++ b/docs/features.md @@ -41,7 +41,7 @@ | 视频上传 | 真实集成 | 使用浏览器 File API 和对象 URL即时预览,并优先通过 `/api/files` 以 `kind = VIDEO` 写入后端文件资源。 | | 自动抽帧 | 真实集成 | 使用 `