Open farling42 opened 9 months ago
Things to look at: IntersectionObserver JournalSheet._onPageScroll JournalSheet._observeHeadings JournalSheet.synchroniseSidebar _activatePagesInView
The <ol class="directory-list scrollable">
has the scrollTop
property that varies when the TOC is scrolled up and down.
JournalSheet._observeHeadings
looks for all the h1-h6 headings in the journal page, and then sets up the InteractionObserver.
const headings = Array.fromRange(6, 1).map(n => `h${n}`).join(",");
element.querySelectorAll(`.journal-entry-page :is(${headings})`).forEach(el => headingObserver.observe(el));
This would need to include the headings in the PDF iframe as well as the normal pages.
Simply call scrollIIntoView() on the entry in the TOC which matches the page/header.
Ensure that the visible part of the TOC mirrors the visible part of the PDF when the PDF view is changed.