docs: guide d'utilisation enrichi + navigation clavier — sections Tabs, Édition, Graphe, Palette, Partage, Sauvegardes, Sécurité
This commit is contained in:
+54
-1
@@ -214,6 +214,7 @@ function initHelpNavigation() {
|
||||
const helpContent = document.querySelector(".help-content");
|
||||
const helpBody = document.getElementById("help-body");
|
||||
const navLinks = document.querySelectorAll(".help-nav-link");
|
||||
const navList = document.querySelector(".help-nav-list");
|
||||
|
||||
if (!helpContent || !helpBody || !navLinks.length) return;
|
||||
|
||||
@@ -225,11 +226,63 @@ function initHelpNavigation() {
|
||||
const targetSection = document.getElementById(targetId);
|
||||
if (targetSection) {
|
||||
targetSection.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
// Focus the section for accessibility
|
||||
targetSection.setAttribute("tabindex", "-1");
|
||||
targetSection.focus({ preventScroll: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Scroll spy - update active nav link based on scroll position
|
||||
// ── Keyboard navigation inside nav list ──
|
||||
if (navList) {
|
||||
navList.addEventListener("keydown", (e) => {
|
||||
const items = [...navList.querySelectorAll(".help-nav-link")];
|
||||
const currentIdx = items.indexOf(document.activeElement);
|
||||
|
||||
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
||||
e.preventDefault();
|
||||
const next = (currentIdx + 1) % items.length;
|
||||
items[next].focus();
|
||||
} else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
||||
e.preventDefault();
|
||||
const prev = (currentIdx - 1 + items.length) % items.length;
|
||||
items[prev].focus();
|
||||
} else if (e.key === "Home") {
|
||||
e.preventDefault();
|
||||
items[0].focus();
|
||||
} else if (e.key === "End") {
|
||||
e.preventDefault();
|
||||
items[items.length - 1].focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Make nav items focusable
|
||||
navList.querySelectorAll("li").forEach((li) => {
|
||||
li.setAttribute("role", "none"); // remove listitem role for cleaner a11y
|
||||
});
|
||||
}
|
||||
|
||||
// ── Keyboard: Ctrl+↑/↓ inside help body to jump between sections ──
|
||||
helpBody.addEventListener("keydown", (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
||||
e.preventDefault();
|
||||
const sections = [...document.querySelectorAll(".help-section")];
|
||||
const currentSection = sections.find((s) => {
|
||||
const rect = s.getBoundingClientRect();
|
||||
return rect.top >= 0 && rect.top < 100;
|
||||
});
|
||||
if (!currentSection) return;
|
||||
|
||||
const currentIdx = sections.indexOf(currentSection);
|
||||
if (e.key === "ArrowDown" && currentIdx < sections.length - 1) {
|
||||
sections[currentIdx + 1].scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
} else if (e.key === "ArrowUp" && currentIdx > 0) {
|
||||
sections[currentIdx - 1].scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ── Scroll spy ──
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
entries.forEach((entry) => {
|
||||
|
||||
Reference in New Issue
Block a user