Files
Forge-Engine/static/document/document-editor.css
T
williamandClaude Sonnet 5 9d87a4bfef
Build and deploy / test-python (push) Failing after 1m3s
Build and deploy / test-js (push) Successful in 48s
Build and deploy / lint-python (push) Failing after 1m2s
Build and deploy / lint-js (push) Failing after 1m5s
Build and deploy / build-and-push (push) Skipped
Build and deploy / deploy (push) Skipped
Build and deploy / sonarqube (push) Failing after 1m5s
Implemente le mini-jeu Quiz (questions/choix/points/timer)
document_engine/labels/quiz_config.py (nouveau) : modele de donnees
complet, meme convention resolve_X/sanitize_X que
game_engine/rendering/quiz_box_config.py cote jeu (aucun import
croise) - DEFAULT_QUIZ_CONFIG, sanitize_quiz_config (valide/nettoie
chaque question independamment, jamais ne leve, tronque a 2-4 choix,
remet correct_index a 0 si hors bornes/non-entier, clampe points >= 0
et timer_seconds dans [5,300]), quiz_total_points.

Cote serveur, routes/document/document_element_update.py revalide
desormais un quiz avant persistance (seul kind qui en a besoin - les
autres n'ont que des attributs scalaires sans structure a garantir) et
renvoie les attributs REELLEMENT persistes dans sa reponse, pour que
le client ne derive jamais de la verite serveur apres un nettoyage
serveur (ex. choix en trop tronque).

Cote editeur (static/document/js/document-editor.js), le panneau
Proprietes d'un quiz est desormais reel : chronometre optionnel,
couleur de theme, liste de questions repetable (ajout/suppression),
chacune avec son texte, un nombre de choix ajustable (2-4, les
inputs texte suivent), le choix correct via un radio par question,
et les points gagnes. Le rendu canevas (render_document_element.py)
affiche un resume reel (nombre de questions, total des points,
minuteur) au lieu du placeholder generique.

Tests : document_engine/labels/quiz_config.py couvert par 13 tests
purs (tests/document/test_quiz_config.py, sans Flask - defauts,
troncature, validation, cas limites dont bool comme correct_index) +
1 test de route verifiant la sanitization a l'ecriture et le rendu.

SKIP=djlint : backlog H021 pre-existant, aucun template touche ici.
ruff/mypy --strict/vulture/bandit/import-linter/eslint/stylelint tous
verts ; 63 tests cibles (document + onboarding + auth) verifies
fraichement + verification manuelle live via le serveur de dev
(ajout, sanitization sur choix invalides/en trop, rendu du resume
avec minuteur).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-20 11:40:48 +02:00

877 lines
17 KiB
CSS

/* document-editor.css — éditeur de support de formation (voir
docs/plan/PLAN.md). Tout est scopé sous .docEditor3 : aucune règle ici
ne touche jamais html[data-theme] (figé "dark" pour le reste du site,
voir templates/base.html) — le thème clair/sombre de CET éditeur est un
attribut data-theme posé sur .docEditor3 lui-même (voir
static/document/js/document-editor.js), avec ses propres tokens
--doc-* ci-dessous plutôt que les --forge-* globaux. */
/* Demande explicite : l'éditeur occupe TOUTE la largeur de la fenêtre,
bord à bord — .content limite normalement à 760px (voir static/style.css)
et .content-wide à 1600px, tous deux avec un padding fixe. Neutralisé
ici pour cette page précise seulement (ce fichier n'est chargé QUE par
templates/document/document_edit.html) : même sélecteur que la règle du
site (`body.objectEditBody > main.content`, spécificité identique),
mais chargé après static/style.css dans <head> (voir son
{% block extra_head %}) donc prioritaire à spécificité égale. */
body.objectEditBody > main.content {
max-width: none;
width: 100%;
padding: 0;
margin: 0;
}
.docEditor3 {
--doc-bg: var(--forge-bg);
--doc-bg-2: var(--forge-bg-secondary);
--doc-card: var(--forge-card);
--doc-border: var(--forge-border);
--doc-text: var(--forge-text);
--doc-muted: var(--forge-text-muted);
--doc-accent: var(--accent);
--doc-accent-2: var(--accent-2);
--doc-glow: 0 0 0 1px rgb(255 95 46 / 25%), 0 8px 24px -6px rgb(255 95 46 / 25%);
/* Remplit main.content (voir body.objectEditBody dans static/style.css :
`main.content` y est déjà `flex:1 1 auto; min-height:0; overflow:hidden;
display:flex; flex-direction:column;`) — jamais `position:fixed` : cet
ancêtre a `overflow:hidden`, qui ROGNE VISUELLEMENT tout descendant
`position:fixed` à sa propre boîte (laquelle commence sous la barre de
navigation du site, pas au vrai sommet du viewport) — bug réel trouvé
le 20/09/2026 : le bandeau d'outils (56px) tombait alors entièrement
dans la zone rognée, invisible, alors que le reste de l'éditeur
semblait décalé vers le haut à sa place. */
flex: 1 1 auto;
min-height: 0;
display: flex;
flex-direction: column;
background: var(--doc-bg);
color: var(--doc-text);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.docEditor3[data-theme="light"] {
--doc-bg: #f6f5f2;
--doc-bg-2: #fff;
--doc-card: #fff;
--doc-border: #e3e1db;
--doc-text: #14161c;
--doc-muted: #6b7280;
--doc-glow: 0 0 0 1px rgb(255 95 46 / 30%), 0 8px 24px -6px rgb(255 95 46 / 30%);
}
.docEditor3 * {
box-sizing: border-box;
}
.docEditor3 button {
font-family: inherit;
}
/* ===== TOPBAR ===== */
.docTopbar {
height: 56px;
flex-shrink: 0;
background: var(--doc-bg-2);
border-bottom: 1px solid var(--doc-border);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
gap: 12px;
}
.docCrumb {
display: flex;
align-items: center;
gap: 8px;
font-size: 14px;
font-weight: 600;
min-width: 0;
overflow: hidden;
}
.docCrumbDim {
color: var(--doc-muted);
font-weight: 400;
white-space: nowrap;
text-decoration: none;
}
.docCrumbCur {
font-weight: 700;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: var(--doc-text);
}
.docTopbarActions {
display: flex;
align-items: center;
gap: 10px;
flex-shrink: 0;
}
.docIconBtn {
width: 34px;
height: 34px;
border-radius: 10px;
border: 1px solid var(--doc-border);
background: transparent;
color: var(--doc-text);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.docIconBtn:hover:not(:disabled) {
border-color: var(--doc-muted);
}
.docIconBtn:disabled {
opacity: 0.35;
cursor: default;
}
.docDividerV {
width: 1px;
height: 22px;
background: var(--doc-border);
margin: 0 4px;
}
.docBtnSecondary {
height: 34px;
padding: 0 14px;
border-radius: 10px;
border: 1px solid var(--doc-border);
background: transparent;
color: var(--doc-text);
font-size: 14px;
font-weight: 600;
display: flex;
align-items: center;
gap: 7px;
cursor: pointer;
}
.docBtnSecondary:hover {
border-color: var(--doc-muted);
}
.docBtnPrimary {
border-color: var(--doc-accent);
color: var(--doc-accent);
}
.docBtnPrimary:hover {
background: rgb(255 95 46 / 8%);
}
.docWidthPicker {
display: flex;
gap: 4px;
background: var(--doc-card);
border: 1px solid var(--doc-border);
border-radius: 10px;
padding: 3px;
}
.docWidthBtn {
border: none;
background: transparent;
color: var(--doc-muted);
font-size: 12.5px;
font-weight: 600;
padding: 5px 10px;
border-radius: 7px;
cursor: pointer;
}
.docWidthBtn.is-active {
background: rgb(255 95 46 / 12%);
color: var(--doc-accent);
}
/* ===== BODY LAYOUT ===== */
.docBodyWrap {
flex: 1;
display: flex;
min-height: 0;
position: relative;
}
.docSidebar {
flex-shrink: 0;
background: var(--doc-bg-2);
padding: 20px 16px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 22px;
}
.docSidebarLeft {
width: 248px;
border-right: 1px solid var(--doc-border);
}
.docSidebarRight {
width: 300px;
border-left: 1px solid var(--doc-border);
}
.docSectionLabel {
font-size: 12px;
font-weight: 700;
letter-spacing: 0.04em;
color: var(--doc-muted);
margin-bottom: 10px;
}
.docShapesGrid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.docLibItem {
border: 1px solid var(--doc-border);
border-radius: 10px;
cursor: grab;
background: var(--doc-card);
transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.docLibItem:hover {
border-color: var(--doc-accent);
box-shadow: var(--doc-glow);
}
.docLibItem--shape {
padding: 10px 8px;
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
}
.docLibItem--row {
padding: 9px 10px;
display: flex;
align-items: center;
gap: 10px;
}
.docLibItem span:last-child {
font-size: 12.5px;
font-weight: 600;
}
.docLibList {
display: flex;
flex-direction: column;
gap: 6px;
}
.docLibIcon {
width: 18px;
height: 18px;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 14px;
flex-shrink: 0;
}
.docLibIcon--rectangle::before { content: "▭"; }
.docLibIcon--cercle::before { content: "○"; }
.docLibIcon--triangle::before { content: "△"; }
.docLibIcon--trait::before { content: "―"; }
.docLibIcon--paragraphe::before { content: "¶"; }
.docLibIcon--image::before { content: "🖼"; }
.docLibIcon--bouton::before { content: "⬚"; }
.docLibIcon--titre::before {
content: "T";
font-weight: 800;
}
.docLibIcon--quiz::before {
content: "?";
color: var(--doc-accent);
font-weight: 800;
}
.docLibIcon--association::before {
content: "⇄";
color: var(--doc-accent);
}
.docLibIcon--memory::before {
content: "▤";
color: var(--doc-accent);
}
.docLibIcon--mots::before {
content: "▦";
color: var(--doc-accent);
}
.docLibIcon--scenario::before {
content: "◈";
color: var(--doc-accent);
}
.docLibIcon--zones::before {
content: "⚠";
color: var(--doc-accent);
}
/* ---- CANVAS ---- */
.docCanvasArea {
flex: 1;
background: var(--doc-bg);
padding: 36px 40px;
overflow: auto;
display: flex;
justify-content: center;
position: relative;
}
.docPage {
width: 760px;
max-width: 100%;
height: fit-content;
background: var(--doc-card);
border: 1px solid var(--doc-border);
border-radius: 16px;
box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
padding: 48px 52px;
position: relative;
transform-origin: top center;
transition: width 0.2s ease;
}
/* Enfant qui reçoit le HTML rendu (voir #docPage vs #docPageContent dans
document-editor.js — le rafraîchissement du canevas ne remplace QUE ce
contenu, jamais .docPage elle-même, pour que .docSnapGridOverlay,
sa voisine, survive à chaque rafraîchissement). */
.docPageContent {
display: flex;
flex-direction: column;
gap: 18px;
}
.docPage.docPage--fixedWidth {
width: var(--doc-preview-width, 760px);
padding: 28px 20px;
}
.docRow {
position: relative;
}
.docRow > [data-element-id] {
flex: 1 1 220px;
min-width: 0;
}
[data-element-id] {
position: relative;
border-radius: 8px;
padding: 6px;
margin: -6px;
cursor: pointer;
transition: background 0.1s ease;
}
[data-kind="row"] > [data-element-id] {
margin: 0;
}
[data-element-id]:hover {
background: rgb(255 95 46 / 6%);
}
[data-element-id].docSelected {
background: rgb(255 95 46 / 10%);
outline: 1px dashed var(--doc-accent);
}
[data-element-id].docDropTarget--before {
box-shadow: inset 0 3px 0 0 var(--doc-accent);
}
[data-element-id].docDropTarget--after {
box-shadow: inset 0 -3px 0 0 var(--doc-accent);
}
[data-element-id].docDropTarget--mergeLeft {
box-shadow: inset 3px 0 0 0 var(--doc-accent);
}
[data-element-id].docDropTarget--mergeRight {
box-shadow: inset -3px 0 0 0 var(--doc-accent);
}
.docShape[data-element-id] {
padding: 0;
margin: 0;
border-radius: 0;
}
.docShape[data-element-id].docSelected {
outline: 2px solid var(--doc-accent);
background: transparent;
}
.docText {
outline: none;
}
.docImage.docImagePlaceholder {
width: 100%;
height: 190px;
border-radius: 10px;
background: var(--doc-bg-2);
border: 1px dashed var(--doc-border);
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
color: var(--doc-muted);
font-size: 13px;
font-weight: 600;
}
img.docImage {
max-width: 100%;
border-radius: 10px;
display: block;
}
.docButton {
border: none;
border-radius: 999px;
padding: 10px 22px;
font-weight: 700;
font-size: 14px;
background: var(--doc-accent);
color: #14100c;
cursor: pointer;
}
.docMinigame {
border: 1px solid var(--doc-accent);
border-radius: 12px;
padding: 18px 20px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
background: rgb(255 95 46 / 8%);
}
.docMinigameLabel {
font-size: 15px;
font-weight: 700;
}
.docMinigamePlaceholder {
font-size: 12.5px;
color: var(--doc-muted);
}
.docUnknown {
font-size: 12.5px;
color: var(--doc-muted);
border: 1px dashed var(--doc-border);
border-radius: 8px;
padding: 10px;
}
/* ---- grille d'accroche (formes libres) — voir docs/plan/PLAN.md,
"grille d'accroche réelle" : visible en overlay pendant le déplacement
d'une forme (voir .docPage--dragging-shape ci-dessous), jamais
décorative. */
.docSnapGridOverlay {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 1;
opacity: 0;
transition: opacity 0.1s ease;
background-image:
linear-gradient(to right, rgb(255 95 46 / 12%) 1px, transparent 1px),
linear-gradient(to bottom, rgb(255 95 46 / 12%) 1px, transparent 1px);
background-size: var(--doc-snap-size, 8px) var(--doc-snap-size, 8px);
}
.docPage.docPage--dragging-shape .docSnapGridOverlay {
opacity: 1;
}
.docZoomPill {
position: absolute;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
background: var(--doc-card);
border: 1px solid var(--doc-border);
border-radius: 999px;
height: 36px;
padding: 0 6px;
display: flex;
align-items: center;
gap: 6px;
box-shadow: 0 2px 6px rgb(0 0 0 / 30%);
}
.docZoomPill button {
width: 26px;
height: 26px;
border-radius: 999px;
border: none;
background: transparent;
color: var(--doc-text);
cursor: pointer;
font-size: 15px;
font-weight: 700;
}
.docZoomPill button:hover {
background: var(--doc-bg-2);
}
.docZoomPill span {
font-size: 12.5px;
font-weight: 700;
color: var(--doc-muted);
width: 40px;
text-align: center;
}
/* ---- RIGHT SIDEBAR : Propriétés ---- */
.docField {
display: flex;
flex-direction: column;
gap: 6px;
margin-bottom: 14px;
}
.docFieldRow {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
}
.docField label,
.docFieldRow .docFieldLabel {
font-size: 13px;
color: var(--doc-muted);
}
.docField input,
.docField textarea,
.docField select {
border: 1px solid var(--doc-border);
border-radius: 8px;
padding: 8px 10px;
font-size: 13px;
color: var(--doc-text);
background: var(--doc-card);
font-family: inherit;
width: 100%;
resize: vertical;
}
.docSwatches {
display: flex;
gap: 8px;
}
.docSwatch {
width: 22px;
height: 22px;
border-radius: 50%;
border: 2px solid transparent;
cursor: pointer;
}
.docSwatch.is-active {
border-color: var(--doc-text);
}
.docSegmented {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.docSegBtn {
padding: 6px 10px;
border-radius: 8px;
border: 1px solid var(--doc-border);
background: var(--doc-card);
font-size: 12.5px;
font-weight: 600;
color: var(--doc-text);
cursor: pointer;
}
.docSegBtn.is-active {
background: rgb(255 95 46 / 12%);
color: var(--doc-accent);
border-color: var(--doc-accent);
}
.docToolbarRow {
display: flex;
gap: 6px;
margin-bottom: 14px;
}
.docFmtBtn {
width: 32px;
height: 32px;
border-radius: 8px;
border: 1px solid var(--doc-border);
background: var(--doc-card);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 14px;
font-weight: 800;
color: var(--doc-text);
}
.docFmtBtn.is-active {
background: rgb(255 95 46 / 12%);
border-color: var(--doc-accent);
color: var(--doc-accent);
}
.docFmtBtn.docFmtBtn--italic {
font-style: italic;
font-weight: 400;
}
.docFmtBtn.docFmtBtn--underline {
text-decoration: underline;
font-weight: 400;
}
.docDeleteBtn {
width: 100%;
height: 38px;
border-radius: 10px;
border: 1px solid var(--status-danger, #f04438);
background: transparent;
color: var(--status-danger, #f04438);
font-weight: 700;
cursor: pointer;
margin-top: 6px;
}
.docDeleteBtn:hover {
background: rgb(240 68 56 / 10%);
}
/* ---- Quiz : liste de questions répétable, chacune avec sa propre liste
de choix répétable (voir forgeDocRenderQuizProps, static/document/js/
document-editor.js) ---- */
.docQuizQuestionsLabel {
margin-top: 10px;
}
.docQuizQuestion {
border: 1px solid var(--doc-border);
border-radius: 10px;
padding: 12px;
margin-bottom: 10px;
background: var(--doc-card);
}
.docQuizQuestionHeader {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.docQuizRemoveBtn {
border: none;
background: transparent;
color: var(--doc-muted);
cursor: pointer;
font-size: 14px;
}
.docQuizRemoveBtn:hover {
color: var(--status-danger, #f04438);
}
.docQuizChoicesList {
display: flex;
flex-direction: column;
gap: 6px;
margin: 8px 0;
}
.docQuizChoiceRow {
display: flex;
align-items: center;
gap: 8px;
}
.docQuizChoiceRow input[type="text"] {
flex: 1;
}
.docQuizAddBtn {
width: 100%;
justify-content: center;
margin-top: 4px;
}
.docEmptyState {
font-size: 13px;
color: var(--doc-muted);
text-align: center;
padding: 30px 10px;
}
/* ===== BOTTOM NAV (mobile) ===== */
.docBottomNav {
display: none;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 58px;
background: var(--doc-bg-2);
border-top: 1px solid var(--doc-border);
z-index: 40;
align-items: stretch;
justify-content: space-around;
}
.docBottomNav button {
flex: 1;
background: transparent;
border: none;
color: var(--doc-muted);
cursor: pointer;
font-size: 12px;
font-weight: 600;
}
.docBottomNav button.is-active {
color: var(--doc-accent);
}
.docSidebarClose {
display: none;
}
/* ===== MODE APERÇU : masque tout le chrome d'édition ===== */
.docEditor3.docEditor3--preview .docSidebarLeft,
.docEditor3.docEditor3--preview .docSidebarRight,
.docEditor3.docEditor3--preview .docBottomNav,
.docEditor3.docEditor3--preview .docZoomPill {
display: none;
}
.docEditor3.docEditor3--preview [data-element-id] {
cursor: default;
pointer-events: none;
}
.docEditor3.docEditor3--preview [data-element-id]:hover,
.docEditor3.docEditor3--preview [data-element-id].docSelected {
background: transparent;
outline: none;
}
.docEditor3.docEditor3--preview .docCanvasArea {
padding: 40px;
}
/* ===== RESPONSIVE (chrome de l'éditeur lui-même, <900px) ===== */
@media (width <= 900px) {
.docCrumbDim {
display: none;
}
.docTopbar {
padding: 0 14px;
}
.docBtnLabel {
display: none;
}
.docBtnSecondary {
padding: 0 10px;
}
.docWidthPicker {
display: none;
}
.docCanvasArea {
padding: 18px 14px 84px;
}
.docPage {
padding: 28px 20px;
}
.docSidebar {
/* position:absolute relative à .docBodyWrap (position:relative, voir
plus haut) plutôt que position:fixed relative au viewport : ce
dernier subirait le même rognage par overflow:hidden que .docEditor3
(voir son commentaire) — inutile de toute façon ici, .docBodyWrap
exclut déjà .docTopbar/.docBottomNav (ses frères, jamais ses
parents), inset:0 suffit sans aucun calcul de hauteur de bandeau. */
position: absolute;
inset: 0;
width: 100%;
z-index: 30;
transition: transform 0.25s ease;
}
.docSidebarLeft {
transform: translateX(-100%);
}
.docSidebarRight {
transform: translateX(100%);
}
.docSidebar.is-open {
transform: translateX(0);
}
.docSidebarClose {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
font-weight: 600;
color: var(--doc-muted);
margin-bottom: 16px;
cursor: pointer;
padding: 0 16px;
}
.docBottomNav {
display: flex;
}
}