Ajoute une largeur maximale optionnelle aux blocs de texte (titre/paragraphe)

Nouvel attribut max_width (vide par défaut = pleine largeur, inchangé)
sur les kinds titre/paragraphe, réglable depuis leur panneau
Propriétés. Le sous-titre de la page de garde du thème Sécurité
Incendie l'utilise (60ch) pour rester conforme à la maquette d'origine,
qui ne l'étirait pas sur toute la largeur de la page.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
william
2026-09-24 10:39:18 +02:00
co-authored by Claude Sonnet 5
parent 746feb3796
commit 1296edc2f8
8 changed files with 69 additions and 2 deletions
+33
View File
@@ -400,3 +400,36 @@ def test_bouton_with_attachment_filename_renders_data_attribute(tmp_support_slug
html = doc_engine.render_document(doc_engine.list_document_elements(slug, page_id))
assert 'data-attachment-filename="fiche-consignes.pdf"' in html
def test_paragraphe_default_max_width_is_empty(tmp_support_slug_cleanup: Any) -> None:
slug, page_id = _new_support(tmp_support_slug_cleanup)
element_id = doc_engine.add_document_element(slug, "paragraphe", page_id=page_id)
element = doc_engine.get_document_element(slug, element_id)
assert element is not None
assert element["attributes"]["max_width"] == ""
html = doc_engine.render_document(doc_engine.list_document_elements(slug, page_id))
assert "max-width" not in html
def test_paragraphe_with_max_width_adds_it_to_the_inline_style(tmp_support_slug_cleanup: Any) -> None:
slug, page_id = _new_support(tmp_support_slug_cleanup)
element_id = doc_engine.add_document_element(slug, "paragraphe", page_id=page_id)
doc_engine.update_document_element_attributes(
slug, element_id, {"content": "Texte", "style": "paragraphe", "max_width": "60ch"}
)
html = doc_engine.render_document(doc_engine.list_document_elements(slug, page_id))
assert "max-width:60ch;" in html
def test_paragraphe_max_width_is_escaped(tmp_support_slug_cleanup: Any) -> None:
slug, page_id = _new_support(tmp_support_slug_cleanup)
element_id = doc_engine.add_document_element(slug, "paragraphe", page_id=page_id)
doc_engine.update_document_element_attributes(
slug, element_id, {"content": "Texte", "style": "paragraphe", "max_width": '"><script>alert(1)</script>'}
)
html = doc_engine.render_document(doc_engine.list_document_elements(slug, page_id))
assert "<script>" not in html