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,16 @@
# Change: add canvas text-to-speech toolbar
## Why
画布里的文本与 Card/Markdown 已支持选中和编辑,但缺少和知识库一致的语音朗读入口。用户在画布上阅读长文本时需要直接朗读,不应先跳转到知识库。
## What Changes
-`popup-toolbar` 为文本与 Card/Markdown 选择态增加语音朗读按钮
- 复用现有 Web Speech 朗读能力,统一播放、暂停、继续交互
- Card 内存在局部文本选区时优先朗读选区,否则朗读整卡内容
## Impact
- Affected specs: `canvas-text-to-speech`
- Affected code:
- `packages/drawnix/src/components/toolbar/popup-toolbar/*`
- `packages/drawnix/src/hooks/useTextToSpeech.ts`
- `packages/drawnix/src/i18n.tsx`

View File

@@ -0,0 +1,21 @@
## ADDED Requirements
### Requirement: Canvas popup toolbar text-to-speech
The system SHALL expose a text-to-speech action in the canvas popup toolbar when the current selection contains readable text or markdown content.
#### Scenario: Read a selected text element
- **GIVEN** the user has selected a text-bearing canvas element
- **WHEN** the popup toolbar is shown
- **THEN** the toolbar SHALL display a text-to-speech action
- **AND** activating the action SHALL read the selected element content aloud
#### Scenario: Prefer card text selection over full card content
- **GIVEN** the user has selected a card element with markdown content
- **AND** the user has highlighted a portion of text inside the card body
- **WHEN** the text-to-speech action is activated
- **THEN** the system SHALL read the highlighted text instead of the full card content
#### Scenario: Toggle pause and resume while speaking
- **GIVEN** the canvas text-to-speech action is currently reading content aloud
- **WHEN** the user activates the same action again
- **THEN** the system SHALL pause the current reading
- **AND** a subsequent activation SHALL resume the same reading session

View File

@@ -0,0 +1,30 @@
## ADDED Requirements
### Requirement: Read selected canvas text aloud
The system SHALL expose a text-to-speech action in the popup toolbar when the current canvas selection contains readable text content.
#### Scenario: Read a selected text element
- **GIVEN** the user selects a canvas text element with non-empty text
- **WHEN** the popup toolbar is shown
- **THEN** the toolbar SHALL display a speech action
- **AND** activating the action SHALL read the text content aloud
#### Scenario: Pause and resume active speech
- **GIVEN** canvas text-to-speech is currently speaking
- **WHEN** the user activates the same speech action again
- **THEN** the system SHALL pause playback
- **AND** activating it once more SHALL resume playback
### Requirement: Prefer explicit Card text selection
The system SHALL prefer a concrete text selection inside a selected Card or Markdown container over the full element content.
#### Scenario: Read selected text inside a Card
- **GIVEN** the user has selected a Card on the canvas
- **AND** the user has highlighted a text range inside the Card body
- **WHEN** the speech action is activated
- **THEN** the system SHALL read only the highlighted text range
#### Scenario: Fall back to the whole Card content
- **GIVEN** the user has selected a Card on the canvas
- **AND** there is no active text range inside the Card body
- **WHEN** the speech action is activated
- **THEN** the system SHALL read the Card title and body content

View File

@@ -0,0 +1,5 @@
## 1. Implementation
- [x] 1.1 抽取共享 `useTextToSpeech` Hook保持知识库兼容
- [x] 1.2 为 `popup-toolbar` 增加画布文本提取与语音按钮显示逻辑
- [x] 1.3 支持 Card/Markdown 局部文本选区优先朗读
- [x] 1.4 补充翻译与针对性测试