import { Handler } from '/csspageweaver/lib/paged.esm.js'; export default class addPagesNotes extends Handler { constructor(chunker, polisher, caller) { super(chunker, polisher, caller); } afterParsed(parsed){ let notes = parsed.querySelectorAll(".inline-note"); notes.forEach(function (note, index) { console.log(note); note.style.position = "absolute"; note.style.top = "0px"; note.style.left = "0px"; note.style.height = "0px"; let counter = note.getAttribute('data-counter-note'); let call = document.createElement('span'); call.classList.add('note_call'); call.textContent = counter; note.insertAdjacentElement('beforebegin', call); note.classList.replace('inline-note', 'body-note'); let marker = document.createElement('span'); marker.classList.add('note_marker'); marker.textContent = counter + ". "; note.prepend(marker); }); } afterPageLayout(pageElement, page, breakToken, chunker) { // move notes into previous page let notes = pageElement.querySelectorAll(".body-note"); if(notes){ let container = document.createElement('div'); container.classList.add('container-note'); notes.forEach(function (note, index) { container.appendChild(note); note.style.position = "relative"; note.style.height = "auto"; }); let pageNum = parseInt(pageElement.getAttribute('data-page-number')); let prevPage = document.querySelector('[data-page-number="' + (pageNum - 1) + '"]'); if (prevPage) { let content = prevPage.querySelector("#section_content"); if(content){ content.appendChild(container); }else{ prevPage.querySelector('.pagedjs_page_content').appendChild(container); } } } // create blank left page if ( page.element.classList.contains('pagedjs_right_page') && page.element.querySelector('[data-id="section__content"]') ) { let notesPage = chunker.addPage(); notesPage.element.classList.add('page-notes'); // Make margin boxes visible (hasContent is set during polishing, which skips added pages) notesPage.element.querySelector('.pagedjs_margin-bottom-left')?.classList.add('hasContent'); notesPage.element.querySelector('.pagedjs_margin-bottom-center')?.classList.add('hasContent'); } } }