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,24 @@
# Proposal: 文本框默认自动换行
## Why
当前文本框渲染时,当文字内容过长时,文字可能会超出文本框边界被截断或显示不完整。系统应该默认启用文字自动换行,确保文字始终在文本框内正确显示,无需用户额外配置。
## What Changes
- 修改 `add_text_element()` 函数,默认设置 `text_frame.word_wrap = True`
- 修改 `render_text_element_to_html()` 函数,使用 `white-space: normal` 启用自动换行
- 所有文本框默认启用自动换行,无需 YAML 配置
## Capabilities
### Modified Capabilities
- `element-rendering`: 文本框默认启用文字自动换行
- `html-rendering`: HTML 预览默认启用文字自动换行
## Impact
- **Affected Code**: `yaml2pptx.py` 中的 `add_text_element()` 函数和 `render_text_element_to_html()` 函数
- **YAML Schema**: 无变化,用户无需修改现有 YAML 文件
- **Dependencies**: 无新增依赖,使用 python-pptx 现有的 TextFrame.word_wrap 属性
- **Breaking Changes**: 无,此改动能改善现有长文本显示问题