ui: propose modal opens ticket in new tab only

This commit is contained in:
2026-01-20 14:57:26 +01:00
parent 84c295d4ce
commit 5f34a1d393
2 changed files with 57 additions and 12 deletions

View File

@@ -76,6 +76,26 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
history.replaceState(null, "", window.location.pathname + window.location.hash);
}
// ✅ Hotfix compat citabilité :
// si l'URL pointe vers un ancien hash (#p-8-xxxxxxxx) qui n'existe plus,
// on retombe sur le paragraphe actuel du même index (#p-8-YYYYYYYY).
(function resolveLegacyParagraphHash() {
const h = window.location.hash || "";
const m = h.match(/^#p-(\d+)-[0-9a-f]{8}$/i);
if (!m) return;
const oldId = h.slice(1);
if (document.getElementById(oldId)) return; // l'ancre existe, rien à faire
const idx = m[1];
const prefix = `p-${idx}-`;
const replacement = document.querySelector(`[id^="${prefix}"]`);
if (!replacement) return;
history.replaceState(null, "", `${window.location.pathname}#${replacement.id}`);
replacement.scrollIntoView({ block: "start" });
})();
const docTitle = document.body.dataset.docTitle || document.title;
const docVersion = document.body.dataset.docVersion || "";
@@ -90,7 +110,7 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
const quoteBlock = (s) =>
String(s || "")
.split(/\r?\n/)
.map((l) => `> ${l}`.trimEnd())
.map((l) => (`> ${l}`).trimEnd())
.join("\n");
function buildIssueURL(anchorId, fullText, excerpt) {
@@ -128,7 +148,7 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
`Texte actuel (extrait):`,
quoteBlock(excerpt || ""),
``,
`Note: paragraphe long → extrait (texte complet copié au clic si possible).`,
`Note: paragraphe long → extrait (pour éviter une URL trop longue).`,
];
const footer = [
@@ -214,9 +234,6 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
// la modal lit data-url en priorité (garde aussi href).
propose.dataset.url = issueUrl;
// Option B : texte complet disponible au clic (presse-papier + upgrade)
propose.dataset.full = raw;
tools.appendChild(propose);
}