fix footnotes
This commit is contained in:
parent
27d59283a3
commit
baf51cb651
|
|
@ -19,36 +19,30 @@ class endToFootNotes extends Paged.Handler {
|
||||||
onDeclaration(declaration, dItem, dList, rule) {
|
onDeclaration(declaration, dItem, dList, rule) {
|
||||||
if (declaration.property == "--paged-note-style") {
|
if (declaration.property == "--paged-note-style") {
|
||||||
if (declaration.value.value.includes("footnote")) {
|
if (declaration.value.value.includes("footnote")) {
|
||||||
this.notestyle = 'footnotes';
|
console.log('FOOTNOTES!');
|
||||||
|
// console.log(declaration.property, declaration, rule);
|
||||||
|
this.notestyle = 'footnotes'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeParsed(content) {
|
beforeParsed(content) {
|
||||||
if (this.notestyle !== 'footnotes') return;
|
if ('footnotes' !== this.notestyle) {
|
||||||
|
|
||||||
// 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');
|
|
||||||
}
|
|
||||||
|
|
||||||
const 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;
|
return;
|
||||||
}
|
}
|
||||||
// Clone the note content and float it as a footnote.
|
console.log("parsef");
|
||||||
const clone = document.createElement('span');
|
let callouts = content.querySelectorAll(endNoteCalloutsQuery);
|
||||||
clone.classList.add('pagedjs-footnote-clone');
|
callouts.forEach((callout) => {
|
||||||
clone.innerHTML = note.innerHTML;
|
console.log(callout.hash)
|
||||||
callout.insertAdjacentElement('afterend', clone);
|
// 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,14 +178,3 @@
|
||||||
.pagedjs_bleed-right .pagedjs_marks-crop:last-child{
|
.pagedjs_bleed-right .pagedjs_marks-crop:last-child{
|
||||||
box-shadow: 0px -1px 0px 0px var(--pagedjs-crop-shadow);
|
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;
|
|
||||||
} */
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue