Supprime la couche de formes libres, déplace la navigation de page dans le panneau gauche
Build and deploy / test-python (push) Successful in 7m43s
Build and deploy / test-js (push) Successful in 57s
Build and deploy / lint-python (push) Successful in 5m29s
Build and deploy / lint-js (push) Failing after 1m16s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped
Build and deploy / sonarqube (push) Failing after 5m42s
Build and deploy / test-python (push) Successful in 7m43s
Build and deploy / test-js (push) Successful in 57s
Build and deploy / lint-python (push) Successful in 5m29s
Build and deploy / lint-js (push) Failing after 1m16s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped
Build and deploy / sonarqube (push) Failing after 5m42s
Formes libres (rectangle/cercle/triangle/trait) retirées de bout en bout (bibliothèque, rendu, panneau Propriétés, grille d'accroche, JS/CSS associés) — fonctionnalité non retenue. La bande de vignettes visuelles des pages au-dessus du canevas est remplacée par une section "Pages" dans le panneau de gauche (liste simple : ajouter/renommer/réordonner (haut/bas)/supprimer), à la place de l'ex-catégorie "Mise en page" de la bibliothèque. La route document_edit ne rend plus qu'une seule page (celle affichée) au chargement, au lieu de toutes les pages pour alimenter les anciennes vignettes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
57c4de3d8a
commit
8dc4b35dcf
@@ -4,17 +4,14 @@ document_engine — support de formation : entité racine séparée du jeu 2D
|
||||
document_engine/pages/, retour utilisateur du 21/09/2026 : "il faut
|
||||
implémenter un système de page") ; chaque page structure son propre
|
||||
contenu en deux couches sur le même canevas :
|
||||
- le flux de contenu (titre/paragraphe/image/bouton/mini-jeux), organisé
|
||||
en rangées ("row") par le moteur d'inférence de layout (voir
|
||||
document_engine/rendering/render_document_element.py) ;
|
||||
- la couche de formes libres (rectangle/cercle/triangle/trait), position-
|
||||
nées en absolu (x/y/width/height/rotation/z_index).
|
||||
le flux de contenu (titre/paragraphe/image/bouton/mini-jeux), organisé en
|
||||
rangées ("row") par le moteur d'inférence de layout (voir
|
||||
document_engine/rendering/render_document_element.py).
|
||||
|
||||
Tout est stocké dans support.db (voir db/supports/) : _document_pages (une
|
||||
ligne par page) et _document_elements (chaque élément appartient à
|
||||
exactement une page via page_id, les deux couches ci-dessus portées via
|
||||
parent_id — NULL = top-niveau ou forme libre, sinon = enfant d'une
|
||||
rangée).
|
||||
exactement une page via page_id, avec parent_id NULL au top-niveau ou
|
||||
enfant d'une rangée).
|
||||
|
||||
Aucun import croisé avec game_engine ou tout module lié au jeu 2D — voir
|
||||
le contrat import-linter dans pyproject.toml (game_engine | document_engine
|
||||
@@ -42,7 +39,6 @@ from .labels.element_kind_labels import (
|
||||
ELEMENT_KIND_LABELS,
|
||||
ELEMENT_LIBRARY,
|
||||
MINIGAME_KINDS,
|
||||
SHAPE_KINDS,
|
||||
element_default_attributes,
|
||||
)
|
||||
from .labels.memory_config import (
|
||||
@@ -103,7 +99,6 @@ __all__ = [
|
||||
"MIN_TIMER_SECONDS",
|
||||
"MIN_WORDS",
|
||||
"MINIGAME_KINDS",
|
||||
"SHAPE_KINDS",
|
||||
"add_document_element",
|
||||
"add_document_page",
|
||||
"delete_document_element",
|
||||
|
||||
@@ -11,7 +11,6 @@ from .mots_config import DEFAULT_MOTS_CONFIG
|
||||
from .quiz_config import DEFAULT_QUIZ_CONFIG
|
||||
from .scenario_config import DEFAULT_SCENARIO_CONFIG
|
||||
|
||||
SHAPE_KINDS = ("rectangle", "cercle", "triangle", "trait")
|
||||
CONTENT_KINDS = ("titre", "paragraphe", "image", "bouton")
|
||||
MINIGAME_KINDS = ("quiz", "association", "memory", "mots", "scenario", "zones")
|
||||
|
||||
@@ -19,17 +18,12 @@ MINIGAME_KINDS = ("quiz", "association", "memory", "mots", "scenario", "zones")
|
||||
# moteur de layout au dépôt d'un élément à côté d'un autre) — absent de
|
||||
# ELEMENT_LIBRARY, présent dans ELEMENT_KIND_LABELS pour l'affichage/debug.
|
||||
ELEMENT_LIBRARY: dict[str, dict[str, Any]] = {
|
||||
"mise_en_page": {"label": "Mise en page", "kinds": list(SHAPE_KINDS)},
|
||||
"contenu": {"label": "Contenu", "kinds": list(CONTENT_KINDS)},
|
||||
"minigames": {"label": "Mini-jeux", "kinds": list(MINIGAME_KINDS)},
|
||||
}
|
||||
|
||||
ELEMENT_KIND_LABELS: dict[str, str] = {
|
||||
"row": "Rangée",
|
||||
"rectangle": "Rectangle",
|
||||
"cercle": "Cercle",
|
||||
"triangle": "Triangle",
|
||||
"trait": "Trait",
|
||||
"titre": "Titre",
|
||||
"paragraphe": "Paragraphe",
|
||||
"image": "Image",
|
||||
@@ -42,19 +36,6 @@ ELEMENT_KIND_LABELS: dict[str, str] = {
|
||||
"zones": "Zones à risque",
|
||||
}
|
||||
|
||||
_SHAPE_DEFAULTS = {
|
||||
"x": 40,
|
||||
"y": 40,
|
||||
"width": 160,
|
||||
"height": 100,
|
||||
"rotation": 0,
|
||||
"z_index": 1,
|
||||
"fill": "#ff5f2e",
|
||||
"stroke": "#232a38",
|
||||
"stroke_width": 2,
|
||||
"label": "",
|
||||
}
|
||||
|
||||
_TEXT_DEFAULTS = {
|
||||
"bold": False,
|
||||
"italic": False,
|
||||
@@ -68,8 +49,6 @@ def element_default_attributes(kind: str) -> dict[str, Any]:
|
||||
"""Attributs posés à la création d'un élément de ce type — cf.
|
||||
docs/plan/PLAN.md §3.3/§3.4/§3.5 pour la liste des propriétés
|
||||
éditables par panneau, ici juste leur valeur de départ."""
|
||||
if kind in SHAPE_KINDS:
|
||||
return dict(_SHAPE_DEFAULTS)
|
||||
if kind == "titre":
|
||||
return {"content": "Nouveau titre", "style": "titre1", **_TEXT_DEFAULTS}
|
||||
if kind == "paragraphe":
|
||||
|
||||
@@ -4,10 +4,6 @@ Catalogue statique des types d'éléments du support de formation : bibliothèqu
|
||||
groupée par catégorie (panneau gauche de l'éditeur), libellés d'affichage, et
|
||||
attributs par défaut posés à la création de chaque type.
|
||||
|
||||
## `SHAPE_KINDS: tuple[str, ...]`
|
||||
`("rectangle", "cercle", "triangle", "trait")` — couche de formes libres,
|
||||
toujours en position absolue (`parent_id = NULL`).
|
||||
|
||||
## `CONTENT_KINDS: tuple[str, ...]`
|
||||
`("titre", "paragraphe", "image", "bouton")` — éléments du flux, peuvent
|
||||
être top-niveau ou enfants d'une rangée.
|
||||
@@ -21,10 +17,9 @@ formulaires de contenu dédiés hors périmètre de cette passe.
|
||||
|
||||
## `ELEMENT_LIBRARY: dict[str, dict[str, Any]]`
|
||||
Bibliothèque affichée dans le panneau gauche, groupée par catégorie
|
||||
(`mise_en_page` / `contenu` / `minigames`), chaque entrée portant un
|
||||
`label` et sa liste de `kinds`. `"row"` n'y apparaît jamais — créé
|
||||
implicitement par le moteur de layout, jamais choisi directement dans la
|
||||
bibliothèque.
|
||||
(`contenu` / `minigames`), chaque entrée portant un `label` et sa liste
|
||||
de `kinds`. `"row"` n'y apparaît jamais — créé implicitement par le
|
||||
moteur de layout, jamais choisi directement dans la bibliothèque.
|
||||
|
||||
## `ELEMENT_KIND_LABELS: dict[str, str]`
|
||||
Libellé d'affichage pour chaque `kind`, y compris `"row"` (pour
|
||||
@@ -34,7 +29,6 @@ l'affichage/debug hors bibliothèque).
|
||||
Attributs posés à la création d'un élément de ce type (voir
|
||||
`document_engine/elements/add_document_element.py`).
|
||||
- **Retour** : un dict d'attributs par défaut, dépendant du `kind` :
|
||||
formes (`x/y/width/height/rotation/z_index/fill/stroke/stroke_width/label`),
|
||||
texte (`content/style` + `bold/italic/underline/align/color`),
|
||||
image (`src/alt`), bouton (`label/target`), rangée (`gap/align/justify`),
|
||||
quiz (`DEFAULT_QUIZ_CONFIG`, voir `quiz_config.py`), association
|
||||
|
||||
@@ -3,8 +3,6 @@ import json
|
||||
import random
|
||||
from typing import Any
|
||||
|
||||
_SHAPE_TAGS = {"rectangle": "rect", "cercle": "circle", "trait": "line"}
|
||||
|
||||
|
||||
def render_document(elements: list[dict[str, Any]]) -> str:
|
||||
"""Assemble le document ENTIER à partir de la liste à plat renvoyée
|
||||
@@ -39,40 +37,6 @@ def _render_row(el: dict[str, Any], children_by_parent: dict[int | None, list[di
|
||||
return f'<div class="docRow" data-element-id="{el["id"]}" data-kind="row" style="{style}">{inner}</div>'
|
||||
|
||||
|
||||
def _render_shape(el: dict[str, Any], _children_by_parent: dict[int | None, list[dict[str, Any]]]) -> str:
|
||||
a = el["attributes"]
|
||||
x, y, width, height = a["x"], a["y"], a["width"], a["height"]
|
||||
rotation, z_index = a.get("rotation", 0), a.get("z_index", 1)
|
||||
fill = html_lib.escape(str(a.get("fill", "#ff5f2e")))
|
||||
stroke = html_lib.escape(str(a.get("stroke", "#232a38")))
|
||||
stroke_width = a.get("stroke_width", 2)
|
||||
label = html_lib.escape(str(a.get("label", "")))
|
||||
wrap_style = (
|
||||
f"position:absolute; left:{x}px; top:{y}px; width:{width}px; height:{height}px; "
|
||||
f"transform:rotate({rotation}deg); z-index:{z_index};"
|
||||
)
|
||||
kind = el["kind"]
|
||||
stroke_attrs = f'stroke="{stroke}" stroke-width="{stroke_width}"'
|
||||
if kind == "triangle":
|
||||
points = f"{width / 2},0 {width},{height} 0,{height}"
|
||||
shape_svg = f'<polygon points="{points}" fill="{fill}" {stroke_attrs}></polygon>'
|
||||
else:
|
||||
tag = _SHAPE_TAGS.get(kind, "rect")
|
||||
if tag == "circle":
|
||||
cx, cy, r = width / 2, height / 2, min(width, height) / 2
|
||||
shape_svg = f'<circle cx="{cx}" cy="{cy}" r="{r}" fill="{fill}" {stroke_attrs}></circle>'
|
||||
elif tag == "line":
|
||||
shape_svg = f'<line x1="0" y1="{height / 2}" x2="{width}" y2="{height / 2}" {stroke_attrs}></line>'
|
||||
else:
|
||||
shape_svg = f'<rect width="{width}" height="{height}" fill="{fill}" {stroke_attrs}></rect>'
|
||||
label_attr = f' aria-label="{label}"' if label else ' aria-hidden="true"'
|
||||
return (
|
||||
f'<div class="docShape" data-element-id="{el["id"]}" data-kind="{kind}" style="{wrap_style}"{label_attr}>'
|
||||
f'<svg width="{width}" height="{height}" viewBox="0 0 {width} {height}">{shape_svg}</svg>'
|
||||
f"</div>"
|
||||
)
|
||||
|
||||
|
||||
_STYLE_PRESETS = {
|
||||
"titre1": ("clamp(1.6rem,4vw,2rem)", 800, 1.15),
|
||||
"titre2": ("1.3rem", 800, 1.25),
|
||||
@@ -530,10 +494,6 @@ def _render_unknown(el: dict[str, Any], _children_by_parent: dict[int | None, li
|
||||
|
||||
_RENDERERS = {
|
||||
"row": _render_row,
|
||||
"rectangle": _render_shape,
|
||||
"cercle": _render_shape,
|
||||
"triangle": _render_shape,
|
||||
"trait": _render_shape,
|
||||
"titre": _render_text,
|
||||
"paragraphe": _render_text,
|
||||
"image": _render_image,
|
||||
|
||||
@@ -28,9 +28,6 @@ regroupement à chaque appel.
|
||||
- **Rangée** (`row`) : conteneur flex (`gap`/`align-items`/
|
||||
`justify-content` réels depuis `attributes`), enfants rendus
|
||||
récursivement.
|
||||
- **Formes** (`rectangle`/`cercle`/`triangle`/`trait`) : `<div>` positionné
|
||||
en absolu (`x`/`y`/`width`/`height`/`rotation`/`z_index` réels) contenant
|
||||
un SVG (`rect`/`circle`/`polygon`/`line` selon le type).
|
||||
- **Texte** (`titre`/`paragraphe`) : `<div>` stylé selon `style` (préréglage
|
||||
taille/graisse/interligne) et `bold`/`italic`/`underline`/`align`/`color`.
|
||||
- **Image** : `<img>`, ou un bloc placeholder si `src` est vide.
|
||||
|
||||
Reference in New Issue
Block a user