64 Commits
Author SHA1 Message Date
john-okeefe 832e3d37cc Merge branch 'johnfactotum:main' into main 2026-05-24 19:55:25 -04:00
john-okeefe 74c317d58c Allow explicit PDF.js resource paths for bundler compatibility
Bundlers like Vite cannot resolve directory paths (cmaps/, standard_fonts/)
through the new URL(..., import.meta.url) pattern. Add optional config to
makePDF, makeBook, and View.open so consumers can provide explicit URLs.

When options are not provided, falls back to import.meta.url resolution
(preserving existing behavior for direct module usage).
2026-05-09 21:03:39 -04:00
Francesco Martini 78914aef44 Use original hrefs for external links and add isExternal in fb2.js (#129) 2026-05-01 19:24:25 +00:00
ArtificialSloth 6e13f240f7 Add draw options for search matches (#122) 2026-04-08 15:10:47 +00:00
Huang Xin 0d4a92ae75 Add optional highlight function when initializing TTS (#82) 2025-06-16 17:28:18 +00:00
Huang Xin 27f8b57d05 Init view TTS with text segmentation granularity (#47)
in order to support more TTS backends

This PR also fixes a potential off-by-one error at the end boundary of the segment using `sentence` granularity.
2025-02-13 07:52:03 +00:00
John Factotum 022ea7da87 Make <foliate-view> handle opening files directly 2024-10-12 10:48:51 +08:00
John Factotum 916dfb13ac View: don't destroy book on close
The book object is not created by the view class so it has no business
destroying it.

Fix bug caused by 1e952102bd where closing
the footnote view destroys the book, when it should not be destroyed,
being still displayed by another view
2024-09-30 18:50:07 +08:00
John Factotum 693341f008 PDF: fix links 2024-09-28 14:29:47 +08:00
John Factotum 1e952102bd PDF: rerender when scale changes
The fixed-layout renderer now accepts an object for the return value of
`load()` (on the `book.sections` items). If it's an object, the `src`
is the URL of the section, and `onZoom`, if present, will be called
when the viewport is zoomed. With this you can scale the page yourself
rather than relying on the renderer's own scaling with CSS transform.

Also upgraded to PDF.js 4.6.82. And now internal links are broken...
Don't know how to fix that yet.
2024-09-28 12:12:59 +08:00
John Factotum ba403301a2 View: add ability to automatically hide cursor
Controlled by the boolean attribute `autohide-cursor`
2024-09-27 10:24:45 +08:00
John Factotum f3afcabd96 Media Overlay: support playback-active-class 2024-09-26 13:23:40 +08:00
John Factotum 5600b6c0dc Migrate to ESLint 9 and fix linting issues 2024-04-23 12:59:31 +08:00
John Factotum 2a6012d749 Move section marks calculation to view
Also try to fix section mark epsilon
2023-11-02 16:10:40 +08:00
John Factotum 96d51e654a Fix page list progress 2023-10-10 22:54:27 +08:00
John Factotum 27a290ff59 Allow processing hrefs in TOC asynchronously 2023-10-08 20:42:47 +08:00
John Factotum f0aa16113f EPUB: fix media: properties 2023-10-08 05:33:56 +08:00
John Factotum 1ff15bdc26 EPUB: add support for media overlay playback 2023-10-06 01:23:44 +08:00
John Factotum 83cce01797 Make text walker a separate module 2023-10-01 18:19:13 +08:00
John Factotum ecefeb86e1 TTS: split document into ranges of block elements 2023-10-01 01:18:43 +08:00
John Factotum 87605c5235 TTS: add paused seeking 2023-09-28 23:42:33 +08:00
John Factotum 7ebf99b2cd TTS: add seeking to prev/next paragraph 2023-09-28 17:22:09 +08:00
John Factotum fdec0b2037 TTS: add starting/resuming speaking from mark/range
Also:
- Fix `ssml:alphabet` attribute being ignored when set on root
- Convert `<br>` to `<break>`
2023-09-28 02:02:56 +08:00
John Factotum 403882e66d Add TTS
Add function to convert current page to SSML, with `<mark>`s inserted
using `Intl.segmenter`.

The actual speaking is up to the reader, who should call
`hightlightSpeechMark()` upon mark events.
2023-09-27 02:18:40 +08:00
John Factotum 0a9c418711 Allow getting page/TOC item for ranges 2023-09-24 02:37:33 +08:00
John Factotum df95960f82 Expose relocation reason
And fix history not updated when scrolling in scroll mode
2023-08-17 15:18:20 +08:00
John Factotum 44c5eca4e9 Paginator: add scroll amount option 2023-08-11 08:14:30 +08:00
John Factotum 739a00f7f9 Really fix navigation history not working after reopening book 2023-07-31 11:52:41 +08:00
John Factotum c66f2e65d9 Fix navigation history not working after reopening book
Also remove renderer element when closing
2023-07-31 11:45:39 +08:00
John Factotum 6d1ffe1b81 Save more location info 2023-07-05 10:33:32 +08:00
John Factotum 2e5dda77e0 Unload section when destroying the renderer 2023-06-01 01:44:00 +08:00
John Factotum ed4c1b8b48 Highlight search results
The code looks very inefficient but I guess you can always optimize it
later...
2023-05-29 01:09:50 +08:00
John Factotum d5d1541d3b Paginator: use CSS grid
Massively simplify margin/padding and header/footer layout and eliminate
unnecessary resizes and resize loops.

Also remove layout and style API from View, as these are only applicable
to the paginator.
2023-05-28 22:17:56 +08:00
John Factotum 22956c1ae7 Fix going to annotation 2023-05-27 17:09:18 +08:00
John Factotum 36a8fb62e7 Fix history state not updated when swiping 2023-05-27 00:04:26 +08:00
John Factotum a9681ee7eb Add event and properties for history navigation availability 2023-05-19 23:30:22 +08:00
John Factotum d1ec0dad40 Fix initial history state 2023-05-19 02:44:32 +08:00
John Factotum bafd64f408 Add navigation history 2023-05-19 02:19:41 +08:00
John Factotum 57ab79d598 Replace deselect with more general content access method 2023-05-16 19:12:26 +08:00
John Factotum edea003b2f Add option to show start of main body text as defined in landmarks 2023-05-16 16:21:56 +08:00
John Factotum 0a3f4b8f27 Use Shadow DOM 2023-05-15 20:00:35 +08:00
John Factotum 4acfc050ea Turn View into a custom element, and use DOM events
Also change "relocated" -> "relocate"
2023-05-15 15:27:18 +08:00
John Factotum 1396bd2b89 Yield when search finishes
This allows distinguishing between finished and aborted (with `Generator
.prototype.return`) search
2023-05-13 07:18:22 +08:00
John Factotum 5da3be5200 Add destroy method
Which revokes all blob URLs and removes the element from document.
2023-05-09 14:02:07 +08:00
John Factotum 9e4ef02fa8 Rename uri to href 2023-05-03 17:22:55 +08:00
John Factotum 8a69caf1dd Fix CFI for fixed-layout books 2023-04-26 17:27:51 +08:00
John Factotum b1346280fd Make range available when reporting current location 2023-04-26 17:26:13 +08:00
John Factotum abf95a4e9a Fix text direction info
The spec changed and has been implemented in WebKit:
https://bugs.webkit.org/show_bug.cgi?id=252444

But not in Chromium yet:
https://crbug.com/v8/13835
2023-04-23 14:00:17 +08:00
John Factotum 182ab10182 Remove getPosition()
The original idea of including this function in `./view.js` seems to be
that it's shared between the demo reader and Foliate. But

- It's currently not used in the demo reader any more.
- It works, but it lacks features.
- In any case it's not coupled with anything else in `./view.js`, so at
  best it should be a separate module.

Also: remove unused variable and fix indentation
2023-04-02 00:32:33 +08:00
John Factotum 7d721611fa Improve handling of links
- Remove special handling of footnotes
- Open all links by default
- Reader can return `true` to prevent default action
- Expose link handling as a method, which the reader can use to set up
  links outside renderers (e.g. in popup footnotes)
2023-03-28 16:01:51 +08:00