From baf51cb65101b7011a9257ae4ad092606ccbf654 Mon Sep 17 00:00:00 2001 From: my Date: Thu, 22 Jan 2026 11:48:31 +0100 Subject: [PATCH] fix footnotes --- static/footnotes.js | 40 +++++++++++++++++----------------------- static/pagedjs.css | 13 +------------ 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/static/footnotes.js b/static/footnotes.js index 2138352..3abb31d 100644 --- a/static/footnotes.js +++ b/static/footnotes.js @@ -19,36 +19,30 @@ class endToFootNotes extends Paged.Handler { onDeclaration(declaration, dItem, dList, rule) { if (declaration.property == "--paged-note-style") { if (declaration.value.value.includes("footnote")) { - this.notestyle = 'footnotes'; + console.log('FOOTNOTES!'); + // console.log(declaration.property, declaration, rule); + this.notestyle = 'footnotes' } } } beforeParsed(content) { - if (this.notestyle !== 'footnotes') return; - - // Clean up previously injected clones (in case of re-render). - content.querySelectorAll('.pagedjs-footnote-clone').forEach((n) => n.remove()); - - // Optional: hide the original footnote list; we will clone notes inline. - const originalList = content.querySelector('.footnotes'); - if (originalList) { - originalList.classList.add('pagedjs-footnotes-hidden'); + if ('footnotes' !== this.notestyle) { + return; } - - const callouts = content.querySelectorAll(endNoteCalloutsQuery); + console.log("parsef"); + let callouts = content.querySelectorAll(endNoteCalloutsQuery); callouts.forEach((callout) => { - if (!callout.hash) return; - const note = content.querySelector(callout.hash); - if (!note) { - console.warn(`No footnote found for ${callout.hash}`); - return; - } - // Clone the note content and float it as a footnote. - const clone = document.createElement('span'); - clone.classList.add('pagedjs-footnote-clone'); - clone.innerHTML = note.innerHTML; - callout.insertAdjacentElement('afterend', clone); + console.log(callout.hash) + // console.log(callout.href) + // console.log(`#${callout.href.callout.href.hash}`) + let note = content.querySelector(callout.hash); + console.log(note); + if (!note) { return console.warn(`there is no note with the id of ${callout.hash}`) } + let noteContent = `${note.innerHTML}`; + callout.insertAdjacentHTML("afterend", noteContent); + callout.remove(); + note.remove(); }); } } diff --git a/static/pagedjs.css b/static/pagedjs.css index ed3cb86..5c9d09a 100644 --- a/static/pagedjs.css +++ b/static/pagedjs.css @@ -177,15 +177,4 @@ .pagedjs_bleed-left .pagedjs_marks-crop:last-child, .pagedjs_bleed-right .pagedjs_marks-crop:last-child{ box-shadow: 0px -1px 0px 0px var(--pagedjs-crop-shadow); -} - -/* Footnotes: clone definitions inline and float them to the footer */ -/* .pagedjs-footnote-clone { - float: footnote; - display: block; - margin: 0; - padding: 0; -} -.pagedjs-footnotes-hidden { - display: none; -} */ +} \ No newline at end of file