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:
@@ -406,6 +406,8 @@ def add_text_element(slide, elem, base_path=None):
|
||||
textbox = slide.shapes.add_textbox(x, y, w, h)
|
||||
tf = textbox.text_frame
|
||||
tf.text = elem.get('content', '')
|
||||
# 默认启用文字自动换行
|
||||
tf.word_wrap = True
|
||||
|
||||
# 应用字体样式
|
||||
font_style = elem.get('font', {})
|
||||
@@ -899,7 +901,8 @@ def render_text_element_to_html(elem):
|
||||
{'font-style: italic;' if font.get('italic') else ''}
|
||||
display: flex;
|
||||
align-items: center;
|
||||
white-space: pre-wrap;
|
||||
white-space: normal;
|
||||
overflow-wrap: break-word;
|
||||
"""
|
||||
|
||||
content = elem.get('content', '').replace('<', '<').replace('>', '>')
|
||||
|
||||
Reference in New Issue
Block a user