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:
co-authored by
Claude Sonnet 5
parent
746feb3796
commit
1296edc2f8
@@ -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
|
||||
|
||||
@@ -32,6 +32,17 @@ def test_securite_incendie_title_page_is_vertically_centered() -> None:
|
||||
assert entry["seed_pages"][1].get("vertical_align", "top") == "top"
|
||||
|
||||
|
||||
def test_securite_incendie_intro_paragraph_has_a_max_width() -> None:
|
||||
"""Retour utilisateur du 24/09/2026 : le sous-titre de la page de
|
||||
garde doit rester aussi étroit que dans la maquette, pas étiré sur
|
||||
toute la largeur de la page."""
|
||||
entry = doc_engine.get_document_theme_entry("securite-incendie")
|
||||
assert entry is not None
|
||||
intro_paragraph = entry["seed_pages"][0]["blocks"][2]
|
||||
assert intro_paragraph["kind"] == "paragraphe"
|
||||
assert intro_paragraph["attributes"]["max_width"] == "60ch"
|
||||
|
||||
|
||||
def test_seed_blocks_to_elements_assigns_unique_synthetic_ids() -> None:
|
||||
blocks: list[dict[str, Any]] = [
|
||||
{"kind": "titre", "attributes": {"content": "Titre"}},
|
||||
|
||||
Reference in New Issue
Block a user