fix: TOC PDF - forcer le rechargement de l'iframe (BUG-063 complement)
CI / lint (push) Successful in 1m37s
CI / security (push) Successful in 1m15s
CI / test (push) Successful in 3m36s
CI / build (push) Successful in 59s
CI / e2e (push) Successful in 11m13s

This commit is contained in:
2026-09-17 21:16:46 -04:00
parent f7e068baed
commit 7f0f64a42e
13 changed files with 46 additions and 22 deletions
+8 -5
View File
@@ -521,10 +521,12 @@ function applyPrettyHighlight(codeEl, lang, text) {
/**
* Jump the inline PDF viewer to a specific page.
*
* The browser's built-in PDF viewer lives in an ``about:blank`` content window,
* so assigning ``contentWindow.location.hash`` never reaches the document (the
* TOC links used to do exactly that and did nothing). Reloading the iframe with
* the ``#page=N`` fragment is the supported way to target a page.
* The browser's built-in PDF viewer lives in an ``about:blank`` content window
* (so ``contentWindow.location.hash`` never reaches the document) **and** it
* ignores a same-document fragment navigation: changing only ``#page=N`` on the
* iframe ``src`` does not move the page. A changing query parameter forces a
* real reload, and the ``#page=N`` fragment is then honoured at load — the only
* reliable way to target a page with the native viewer.
*
* @param {HTMLElement} area - Content area containing the ``.pdf-iframe``.
* @param {string|number} page - 1-based page number from the PDF outline.
@@ -534,7 +536,8 @@ export function navigatePdfToPage(area, page) {
if (!iframe || page === null || page === undefined || page === '') return;
const base = iframe.getAttribute('data-pdf-url') || iframe.src.split('#')[0];
iframe.setAttribute('data-pdf-url', base);
iframe.src = `${base}#page=${page}`;
const sep = base.includes('?') ? '&' : '?';
iframe.src = `${base}${sep}_pdfpage=${Date.now()}#page=${page}`;
}
export function renderFile(data) {