1
0

feat: enable text auto-wrap for text boxes by default

- Set text_frame.word_wrap = True in add_text_element() for PPTX
- Change CSS from white-space: pre-wrap to normal in HTML preview
- Add overflow-wrap: break-word for better word breaking
- Update README.md with auto-wrap documentation
- Update element-rendering and html-rendering specs
- Archive change: 2026-03-02-add-text-auto-wrap
This commit is contained in:
2026-03-02 15:23:14 +08:00
parent cd7988cbd5
commit b2132dc06b
11 changed files with 500 additions and 173 deletions

View File

@@ -0,0 +1,37 @@
# HTML Rendering Delta
## MODIFIED Requirements
### Requirement: 系统必须渲染文本元素
系统 SHALL 将 YAML 中的文本元素转换为 HTML `<div>` 标签,应用相应的样式,并默认启用文字自动换行。
#### Scenario: 渲染基本文本元素
- **WHEN** 元素定义为 `{type: text, content: "Hello", box: [1, 2, 8, 3]}`
- **THEN** 系统生成 `<div>` 标签,内容为 "Hello",位置为 (96px, 192px),尺寸为 768x288 像素
#### Scenario: 应用文本字体样式
- **WHEN** 文本元素定义了 `font: {size: 32, bold: true, color: "#333333"}`
- **THEN** 系统应用 CSS`font-size: 32pt; font-weight: bold; color: #333333`
#### Scenario: 应用文本对齐方式
- **WHEN** 文本元素定义了 `font: {align: center}`
- **THEN** 系统应用 CSS`text-align: center`
#### Scenario: 支持多行文本(保留换行符)
- **WHEN** 文本内容包含换行符(`\n`
- **THEN** 系统使用 `white-space: pre-wrap` 保留换行符
#### Scenario: 文本元素默认启用自动换行
- **WHEN** 系统渲染任何文本元素
- **THEN** 系统应用 CSS`white-space: normal`,允许文字在容器边界处自动换行
#### Scenario: 使用 pt 单位表示字体大小
- **WHEN** 文本字体大小为 44
- **THEN** 系统使用 CSS`font-size: 44pt`(与 PPTX 保持一致)