fix footnotes

This commit is contained in:
my 2026-01-22 11:48:31 +01:00
parent 27d59283a3
commit baf51cb651
2 changed files with 18 additions and 35 deletions

View file

@ -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 = `<span class="pagedjs-end-to-footnote">${note.innerHTML}</span>`;
callout.insertAdjacentHTML("afterend", noteContent);
callout.remove();
note.remove();
});
}
}

View file

@ -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;
} */
}