96 lines
3.6 KiB
Plaintext
96 lines
3.6 KiB
Plaintext
<dialog id="propose-modal" aria-label="Qualifier la proposition">
|
||
<form method="dialog" class="box">
|
||
<header class="hd">
|
||
<h2>Qualifier la proposition</h2>
|
||
<button value="cancel" class="x" aria-label="Fermer">✕</button>
|
||
</header>
|
||
|
||
<p class="sub">
|
||
Optionnel : choisis une intention (pour tri & traitement éditorial). Sinon, continue sans préciser.
|
||
</p>
|
||
|
||
<div class="grid">
|
||
<button type="button" data-category="cat/style">Style / lisibilité</button>
|
||
<button type="button" data-category="cat/lexique">Lexique / terminologie</button>
|
||
<button type="button" data-category="cat/argument">Argument / structure</button>
|
||
<button type="button" data-category="cat/redondance">Redondance</button>
|
||
<button type="button" data-category="cat/source">Source / vérification</button>
|
||
<button type="button" data-category="">Continuer sans préciser</button>
|
||
</div>
|
||
|
||
<footer class="ft">
|
||
<small>Astuce : touche <kbd>Esc</kbd> pour fermer.</small>
|
||
</footer>
|
||
</form>
|
||
</dialog>
|
||
|
||
<style>
|
||
dialog { border: none; padding: 0; border-radius: 16px; width: min(720px, calc(100vw - 2rem)); }
|
||
dialog::backdrop { background: rgba(0,0,0,.55); }
|
||
.box { padding: 1rem 1rem 0.75rem; }
|
||
.hd { display:flex; align-items:center; justify-content:space-between; gap:.75rem; }
|
||
.hd h2 { margin:0; font-size:1.1rem; }
|
||
.x { border:0; background:transparent; font-size:1.1rem; cursor:pointer; }
|
||
.sub { margin:.5rem 0 1rem; opacity:.9; }
|
||
.grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap:.5rem; }
|
||
.grid button { padding: .75rem .8rem; border-radius: 12px; border: 1px solid rgba(0,0,0,.18); background: rgba(255,255,255,.96); color: #111; cursor: pointer; text-align: left; }
|
||
.grid button:hover { background: #fff; }
|
||
kbd { padding:0 .35rem; border:1px solid rgba(0,0,0,.2); border-radius:6px; }
|
||
</style>
|
||
|
||
<script is:inline>
|
||
(() => {
|
||
const dlg = document.getElementById("propose-modal");
|
||
if (!dlg) return;
|
||
|
||
/** @type {URL|null} */
|
||
let pending = null;
|
||
|
||
const upsertLine = (text, key, value) => {
|
||
const re = new RegExp(`^${key}:\\s*.*$`, "mi");
|
||
// Si "continuer sans préciser" : on ne touche pas au body
|
||
if (!value) return text;
|
||
if (re.test(text)) return text.replace(re, `${key}: ${value}`);
|
||
const sep = text && !text.endsWith("\n") ? "\n" : "";
|
||
return text + sep + `${key}: ${value}\n`;
|
||
};
|
||
|
||
const openModalFor = (url) => {
|
||
pending = url;
|
||
if (typeof dlg.showModal === "function") dlg.showModal();
|
||
else window.open(url.toString(), "_blank", "noopener,noreferrer");
|
||
};
|
||
|
||
// Interception des clics sur "Proposer"
|
||
document.addEventListener("click", (e) => {
|
||
const a = e.target?.closest?.("a[data-propose]");
|
||
if (!a) return;
|
||
|
||
e.preventDefault();
|
||
|
||
// URL réelle stockée par EditionLayout (propose.dataset.url)
|
||
const rawUrl = a.dataset.url || a.getAttribute("href") || "";
|
||
if (!rawUrl || rawUrl === "#") return;
|
||
|
||
try {
|
||
openModalFor(new URL(rawUrl, window.location.origin));
|
||
} catch {
|
||
window.open(rawUrl, "_blank", "noopener,noreferrer");
|
||
}
|
||
});
|
||
|
||
// Choix d’une catégorie -> injection "Category:" + ouverture Gitea
|
||
dlg.addEventListener("click", (e) => {
|
||
const btn = e.target?.closest?.("button[data-category]");
|
||
if (!btn || !pending) return;
|
||
|
||
const cat = btn.getAttribute("data-category") || "";
|
||
const body = pending.searchParams.get("body") || "";
|
||
pending.searchParams.set("body", upsertLine(body, "Category", cat));
|
||
|
||
dlg.close();
|
||
window.open(pending.toString(), "_blank", "noopener,noreferrer");
|
||
});
|
||
})();
|
||
</script>
|