feat/proposer-antifragile #31

Merged
Archicratia merged 4 commits from feat/proposer-antifragile into master 2026-01-19 21:30:26 +01:00
Showing only changes of commit 3053803c26 - Show all commits

View File

@@ -154,33 +154,23 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
tools.appendChild(citeBtn); tools.appendChild(citeBtn);
if (giteaReady) { if (giteaReady) {
const propose = document.createElement("a"); const propose = document.createElement("a");
propose.className = "para-propose"; propose.className = "para-propose";
propose.href = "#"; propose.textContent = "Proposer";
propose.textContent = "Proposer"; propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
propose.setAttribute("aria-label", "Proposer une correction sur Gitea"); propose.setAttribute("data-propose", "1");
propose.setAttribute("data-propose","1");
propose.addEventListener("click", (e) => { const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
e.preventDefault(); const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
const raw = (p.textContent || "").trim().replace(/\s+/g, " "); const url = buildIssueURL(p.id, excerpt);
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
const url = buildIssueURL(p.id, excerpt);
// on stocke l'URL pour le modal // progressive enhancement : sans JS/modal, href fonctionne.
propose.dataset.url = url.toString(); propose.href = url;
// fallback: si le modal n'existe pas -> ouverture directe // compat : la modal lit data-url en priorité (garde aussi href).
const dlg = document.getElementById("propose-modal"); propose.dataset.url = url;
if (!dlg || typeof dlg.showModal !== "function") {
window.open(propose.dataset.url, "_blank", "noopener,noreferrer");
return;
}
// si modal existe, il va intercepter le click globalement
// donc on ne fait rien ici de plus.
});
tools.appendChild(propose); tools.appendChild(propose);
} }
p.appendChild(tools); p.appendChild(tools);