Initial TrueGrowth source import

This commit is contained in:
2026-07-07 09:36:36 +08:00
commit 3b6781d695
2283 changed files with 691996 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
## Context
现有 PPT 生成先创建 Frame 和可编辑文本再为部分页面生成“配图”。用户现在期望由图片模型直接生成包含文字与背景的完整幻灯片页Frame 负责页面管理、预览、播放和导出。
## Decisions
- PPT 页面的主数据模型改为“Frame + 一张整页图片 + 生成提示词”;旧 `pptMeta.imagePrompt` 只作为兼容读取,新增语义字段用于整页重生成提示词。
- PPT 编辑面板使用当前页整图 URL 做缩略预览,避免对每个 Frame 做 canvas 截图,降低内存与渲染成本。
- 重新生成复用现有 AI 图片生成弹窗和任务队列,传入 `targetFrameId`、Frame 尺寸、自动回填和替换目标,避免新增独立生成流程。
- 回填采用成功后替换:新图生成并可插入时才删除旧整页图;失败或取消时保留旧图。
- Deck 导出继续复用现有 `ppt-export-service`,但 UI 只保留“导出所有 PPT 页面”。
## Risks / Trade-offs
- 整页图片不可逐字编辑;这是本次改造的预期取舍,用更简单的重生成替代细粒度编辑。
- 老数据可能仍包含文本元素、背景图或旧配图占位;实现时需要兼容展示,并优先按新整页图识别预览与替换。
- 图片任务异步完成,替换逻辑必须幂等,避免同一任务重复插入或删除用户后续手动调整的内容。
## Migration
- 不做批量数据迁移;打开旧 PPT Frame 时按旧 `pptMeta.imagePrompt` 回填为重生成提示词。
- 已存在的 `backgroundUrl` 不再显示编辑入口;导出旧内容仍按画布现状处理。

View File

@@ -0,0 +1,15 @@
# Change: Refactor PPT to image-first editing
## Why
当前 PPT 流程把 Frame、文本布局、配图、背景图、单页导出拆得过细`gpt-image-2` 已能生成完整 PPT 页面的前提下,这会让用户理解成本和操作步骤都偏高。
## What Changes
- 将“Frame 管理”的 PPT 使用语义改为“PPT 编辑”,以页卡方式管理 PPT 页面并展示每页预览。
- 将 PPT 生成改为整页图片范式:每页 Frame 主要承载一张完整幻灯片图片,图片包含最终文字、版式和视觉效果。
- 移除 PPT 页面背景图入口;整页图片已包含背景,更换背景不再作为 PPT 编辑动作。
- 将单页 PPT 导出入口替换为“重新生成”:用当前页图片作为参考图、原提示词预填 AI 图片生成弹窗,成功后替换回对应页面。
- 保留整套 PPT 导出能力,导出结果仍按 Frame 顺序生成完整 PPT 文件。
## Impact
- Affected specs: `ppt-editing`
- Affected code: `packages/drawnix/src/services/ppt`, `packages/drawnix/src/components/project-drawer`, `packages/drawnix/src/components/ttd-dialog`, `packages/drawnix/src/hooks/useAutoInsertToCanvas.ts`

View File

@@ -0,0 +1,57 @@
## ADDED Requirements
### Requirement: Image-First PPT Generation
The system SHALL generate PPT pages as slide Frames whose primary visual content is a complete 16:9 generated image containing the page text, layout, background, and visual design.
#### Scenario: Generate PPT pages from content
- **GIVEN** the user invokes PPT generation from a topic or mindmap
- **WHEN** the system creates the PPT pages
- **THEN** it SHALL create one Frame per page
- **AND** it SHALL associate each Frame with the whole-slide generation prompt
- **AND** it SHALL generate or enqueue one full-slide image for each page
- **AND** it SHALL insert the resulting image into the corresponding Frame as the primary slide image
#### Scenario: Page image generation fails
- **GIVEN** a PPT page image generation task fails
- **WHEN** the PPT editing panel shows the page
- **THEN** the page SHALL remain available with its original generation prompt
- **AND** the user SHALL be able to regenerate that page without recreating the whole PPT
### Requirement: PPT Editing Panel
The system SHALL present Frame-based PPT pages through a PPT editing panel that previews and manages pages in deck order.
#### Scenario: Preview PPT pages
- **GIVEN** the current canvas contains PPT Frames
- **WHEN** the user opens the PPT editing panel
- **THEN** each PPT page SHALL show a page card with its index, name, dimensions, and preview image when available
- **AND** clicking a page card SHALL focus/select the corresponding Frame on the canvas
#### Scenario: Hide obsolete PPT actions
- **GIVEN** the current canvas contains PPT Frames
- **WHEN** the PPT editing panel renders actions
- **THEN** it SHALL NOT show PPT background image controls
- **AND** it SHALL NOT show single-page PPT export actions
- **AND** it SHALL keep full-deck PPT export available
### Requirement: PPT Page Regeneration
The system SHALL replace single-page PPT export with page regeneration that uses the existing page image as a reference.
#### Scenario: Open regeneration dialog
- **GIVEN** a PPT page has a stored generation prompt
- **WHEN** the user clicks “重新生成” for that page
- **THEN** the AI image generation dialog SHALL open with the stored prompt prefilled
- **AND** the current primary slide image SHALL be attached as a reference image when available
- **AND** the target Frame id and dimensions SHALL be passed for automatic回填
#### Scenario: Regeneration succeeds
- **GIVEN** a PPT page regeneration task completes successfully
- **WHEN** the generated image is inserted back into the target Frame
- **THEN** the previous primary slide image SHALL be replaced by the new image
- **AND** the page preview SHALL show the new image
- **AND** the Frame SHALL remain in the same deck order
#### Scenario: Regeneration fails or is cancelled
- **GIVEN** a PPT page regeneration task fails or is cancelled
- **WHEN** the task finishes without a usable image
- **THEN** the previous primary slide image SHALL remain unchanged
- **AND** the page SHALL remain available for another regeneration attempt

View File

@@ -0,0 +1,17 @@
## 1. Implementation
- [x] 1.1 Extend PPT frame metadata for whole-slide prompt, slide image id/url, and generation status with fallback from old `imagePrompt`.
- [x] 1.2 Add frame image helpers to find, mark, insert, and replace the primary PPT slide image without duplicating large image data.
- [x] 1.3 Refactor topic/mindmap PPT generation to create Frame pages and submit/generate one 16:9 whole-slide image per page.
- [x] 1.4 Update PPT prompts so each page prompt asks for a complete presentation slide with readable in-image text.
- [x] 1.5 Rename the Frame tab/user copy to PPT editing while keeping generic Frame list compatibility.
- [x] 1.6 Replace Frame list rows with slide preview cards for PPT frames, using lazy image thumbnails from the current slide image URL.
- [x] 1.7 Remove PPT background image controls and single-page PPT export actions from the PPT editing panel.
- [x] 1.8 Add per-page “重新生成” action that opens AI image generation with prompt, current slide image reference, target Frame, and auto-insert replacement options.
- [x] 1.9 Update AI image task params and `useAutoInsertToCanvas` to replace the marked PPT slide image only after successful insertion.
- [x] 1.10 Keep full-deck PPT export ordered by Frame order and verify image-first pages export as expected.
## 2. Tests
- [x] 2.1 Add unit tests for PPT metadata fallback and slide image helper behavior.
- [x] 2.2 Add/adjust tests for PPT generation output: one Frame per page and one primary slide image target per page.
- [x] 2.3 Add/adjust tests for auto-insert replacement so success replaces old image and failure preserves it.
- [x] 2.4 Run targeted PPT/image-generation tests, then run a broader affected package test command if feasible.