Skip to content

Conversation

PickledCakes
Copy link

Screenshot 2025-09-07 135949

Summary

  • Add EPUB Table of Contents to the Divina image reader by consuming the Readium webpub manifest.
  • Make TOC items full-row clickable for easier navigation (not just the anchor text).

Motivation

Komga’s EpubReader already exposes TOC for novels, and Thorium (also Divina-based) supports EPUB TOC. This change brings parity for manga/visual EPUBs inside Divina.

What’s changed

  • komga-webui/src/views/DivinaReader.vue
    • Fetch manifest via bookManifestUrl(bookId).
    • Build TOC entries from pub.toc (fallback to pub.landmarks if toc is missing/empty).
    • Resolve href → page by mapping against readingOrder (spine); ignore unresolved/broken hrefs.
    • Only show the TOC button when entries exist.
  • komga-webui/src/components/TocList.vue
    • Emit goto with the target page.
    • Make the entire row clickable/tappable to jump to the entry.

No server/API changes. Pure web-UI enhancement.

Behavior

  • Clicking the TOC button opens a drawer listing chapters/sections.
  • Clicking anywhere on a row navigates to the corresponding page.
  • If a publication has no TOC (or landmarks), the button is hidden and the reader behaves as before.

Edge cases & fallback logic

  • Prioritize toc; fallback to landmarks.
  • If an entry’s href doesn’t match a spine item, skip it (prevents broken anchors).
  • Reading direction (RTL/LTR) and reader settings are unchanged.

Testing

  • Verified with EPUBs containing:
    • nav.xhtml (HTML5 navigation)
    • toc.ncx (legacy NCX)
  • Confirmed navigation works with R→L and L→R page turns.
  • Web-UI build passes with no ESLint/TS errors.

Limitations / future work

  • Hierarchical TOC expand/collapse relies on TocList. Additional caret/expand logic can be added later once we have good multi-level samples.
  • This PR does not modify EpubReader (novel) behavior.

Risk

Low. Changes are isolated to DivinaReader and TocList. When no TOC exists, UI is unchanged.

@gotson
Copy link
Owner

gotson commented Sep 8, 2025

i don't understand the motivation, can you maybe explain what kind of books would be browsed as DiViNa but have a TOC ?

@PickledCakes
Copy link
Author

i don't understand the motivation, can you maybe explain what kind of books would be browsed as DiViNa but have a TOC ?

These are image-centric EPUB 3 manga (all fixed-layout) that still ship with a proper TOC (nav.xhtml or legacy toc.ncx). They render in Komga with DiViNa because the content is page images, but they do have a TOC that’s useful for jumping between chapters/extras.

In my library (~6,500 manga volumes), ~90% come from official stores and include a structured TOC. Before switching to Komga, I regularly used that TOC in the vendors’ apps to jump between chapters; I’d like the same workflow in Komga.

I’m happy to provide sample manga EPUBs with valid nav.xhtml/toc.ncx if that helps with review.

@gotson
Copy link
Owner

gotson commented Sep 8, 2025

thanks for the context. I don't think solving this in the frontend is the right way to do it. I would prefer to have some sort of support for generic TOC, which could also work for PDF, and i think ComicInfo.xml also has some kind of support for bookmarks.

I won't be accepting this PR, but i'm sure that will work for your own case.

@gotson gotson added the consider Not sure yet if this makes sense or not label Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consider Not sure yet if this makes sense or not
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants