edrlab / thorium-reader

A cross platform desktop reading app, based on the Readium Desktop toolkit
https://www.edrlab.org/software/thorium-reader/
BSD 3-Clause "New" or "Revised" License
1.73k stars 151 forks source link

Hyperlinks not working in Thorium but working in other readers #1495

Closed PhilippeBruno closed 3 years ago

PhilippeBruno commented 3 years ago

I have a fixed-layout EPUB with lots of hyperlinks at the top and bottom of each page to quickly jump to the various chapters or parts of the book:

image

While those hyperlinks are fully functional in other readers such as Lithium on Android, the old Edge browser on Windows (and I believe the Mac as well), in Thorium they simply don't work. The mouse pointer does turn into a pointing finger, but when one clicks, nothing happens.

The EPUB was sent privately to @danielweck for further investigation.

danielweck commented 3 years ago

Hello, thank you for the bug report. These "hyperlinks" are actually HTML elements such as div or img that have programmatic click handlers buried deep somewhere inside the InDesign-generated Javascript code. In other words, they are not statically-discoverable hyperlinks (i.e. <a href="..."> markup), and they somehow escape the navigation handlers that the reading system injects when rendering publication documents (we create capturing and delegated event listeners in order to intercept hyperlink activations). The good news is that I implemented a workaround, which I will publish soon :)

PhilippeBruno commented 3 years ago

@danielweck You should write fiction... You know how to build tension and deliver a final unexpected punch... Good job!

llemeurfr commented 3 years ago

This workaround will be very welcome, as an EPUB author has reported the same issue a few days ago. A structure using "data-releaseactions=goToDestination", specific to InDesign.

This issue was long time ago referenced as https://github.com/readium/readium-js-viewer/issues/350

danielweck commented 3 years ago

Unfortunately the aforementioned "workaround" would introduce tons of undesirable hacks in the codebase which is already impacted by the "base URL" special case for video/audio streaming (localhost:port instead of the custom protocol handler).

In other words, the will-navigate event interceptor cannot currently be used reliably, until we switch to a non-HTTP streamer, see discussion:

https://github.com/edrlab/thorium-reader/pull/1258#issuecomment-729247364

Code reference: https://github.com/readium/r2-navigator-js/commit/b4762aa1a09d6ba931b7ea314bd9b3e4e1f804b2

llemeurfr commented 3 years ago

In the meantime, the only solution to this specific issue is for authors to "clean up" InDesign javascript based interactions and replace them by more basic HTML interactions like <a> or <button> (which still requires js).

As we're working on the v1.7 technical debt for now, we cannot tackle the non-HTTP streamer issue at this time. It will be an important evolution, done by the end of the year or so we hope.

danielweck commented 3 years ago

Update: the upcoming Thorium release will very likely include a new Electron version (v13) which allows us to remove the dependency on an HTTP server (aka "streamer") as we can now stream audio and video media successfully without HTTP, which in turn allows us to remove the HTTP "base URL" hack (which was needed to stream audio/video media through Thorium's secure transport layer), which in turn means we can intercept inDesign-like programmatic links without infinite loop issues :) In short: I should be able to close this issue... (running tests now, to make sure there are no regressions)

PhilippeBruno commented 3 years ago

This is some great news! Let me know when it is available so that I can test it and report back.

PhilippeBruno commented 3 years ago

Hi Daniel, I have been extensively testing this feature now (in particular with the EPUB above) and all hyperlinks now work perfectly. This is truly a major improvement! Keep up the excellent work.

danielweck commented 3 years ago

Thank you for reporting back :)