Commit Graph
34 Commits
Author SHA1 Message Date
john-okeefe 1223876b9d Refactor: load panel detection libs from vendor dir
Update PanelDetector to load OpenCV, TensorFlow.js, and COCO-SSD
from local vendor directory instead of importing npm packages.
This ensures the libraries are available after build and avoids
runtime dependency resolution issues.

- Change imports to use ../vendor paths instead of npm packages
- Add caching to prevent reloading libraries
- Add error handling for failed library loads with console warnings
- Update OpenCV loading to handle both default and named exports
2026-04-13 18:50:19 -04:00
john-okeefe 6d37470814 Add panel mode toggle to reader settings menu
Add a checkbox menu item to the demo reader's settings menu that
allows users to toggle panel detection mode on or off.

Implementation details:
- Adds "Panel Mode" checkbox to existing settings menu
- Uses the createMenu API with type="checkbox"
- Safely checks for togglePanelMode method availability
- Checks current panel-mode state before toggling
- Properly enables/disables panel mode via attribute API

User-facing behavior:
- Click gear icon → settings menu appears
- Check/uncheck "Panel Mode" to enable/disable
- Works seamlessly with existing layout options
- Only active when viewing fixed-layout content

This change only affects the demo reader (reader.html + reader.js),
not the foliate-js library itself. The library's panel detection
API in fixed-layout.js remains unchanged.

The panel mode toggle provides easy access to the new panel
navigation features for testing and demonstration purposes.
2026-04-13 16:51:11 -04:00
john-okeefe 36537e3728 Add panel-aware keyboard shortcuts to reader
Extend keyboard navigation to support panel mode when enabled.

Changes:
- Check for panel-mode attribute before routing key events
- Route Arrow keys and Vim keys (h/l) to panel navigation in panel mode
- Add 'P' key to toggle panel mode
- Add 'Escape' key to exit panel mode
- Maintain backward compatibility with existing page navigation

When panel mode is active:
- ArrowRight/l: next panel
- ArrowLeft/h: previous panel
- Escape/P: exit panel mode

When panel mode is inactive:
- ArrowRight/l: next page (existing behavior)
- ArrowLeft/h: previous page (existing behavior)
- P: enter panel mode (new feature)
2026-04-13 16:43:32 -04:00
John Factotum 052123beaf Add an EventTarget for transforming the book
And use it to do paginator-specific CSS replacements.

And use it to catch loading errors in reader.js.

Fixes #14
Closes #18
2025-03-29 15:09:23 +08:00
John Factotum 022ea7da87 Make <foliate-view> handle opening files directly 2024-10-12 10:48:51 +08:00
John Factotum 541bc07b6f EPUB: redo metadata parsing
- Support the `prefix` attribute (for the `property` attr on `<meta>`)
- Localized titles, names (including `sortAs`)
- `belongsTo`, including `calibre:series`
- `altIdentifier`, converted to URN where possible
- Remove `producer`. It's now `contributor` with `role: 'bkp'`.

NOTE: this is a breaking change if you assumed that `title` will always
be a string, `author` will always be an array, etc.
2024-09-18 11:28:08 +08:00
Balki 835b70a840 Reader: allow book urls to be relative (#29) 2024-07-26 14:00:54 +00: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 a63a68eda0 Add PDF support 2023-10-08 21:27:06 +08:00
John Factotum bcfb942935 Fix module path 2023-10-08 20:44:32 +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 d4453bdc5c Add functions for converting Calibre CFI to standard CFI
Also demonstrate showing highlights from Calibre in the reader
2023-05-27 19:34:10 +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 faaa2f47d4 Reader: update gap to relative
Also: use maxColumns
2023-05-01 23:15:58 +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
John Factotum 9949000a9e Use ES modules for zip.js and fflate 2023-03-20 23:49:33 +08:00
John Factotum 514cb81fe6 Reader: allow loading files from URL parameter
Fixes #3
2023-03-15 11:00:21 +08:00
John Factotum b6f514675b Reader: open external links 2022-11-04 14:40:44 +00:00
John Factotum 2b51522c43 Add .eslintrc.json
And fix issues
2022-11-04 14:12:07 +00:00
John Factotum b1ac5a943f Reader: expose the reader object globally
Makes it easier for debugging or exploring the API in the console
2022-11-04 11:00:18 +00:00
John Factotum 2a5ccb93d9 Reader: allow opening unzipped EPUBs 2022-10-27 17:41:26 +00:00
John Factotum 750458d4b7 Reader: avoid overriding the align attribute 2022-10-26 04:24:32 +00:00
John Factotum f2f41e6013 Reader: add unprefixed hyphens 2022-10-25 08:47:52 +00:00
John Factotum 6977ac005d Get rect in reader instead of view
Also expose index in `loaded` event
2022-10-25 05:55:57 +00:00
John Factotum 21bf6499a4 Reader: add progress slider 2022-10-22 18:29:52 +00:00
John Factotum 5103dc9b90 View: make it possible to do things on load
Also refactor reader, and add left/right shortcuts
2022-10-22 12:42:35 +00:00
John Factotum 3c05d0a957 Reader: add footnote popovers
Lacks a "go to" button, but at least shows something instead of nothing
2022-10-21 18:57:26 +00:00
John Factotum f39d74f932 Reader: add layout option 2022-10-21 09:53:00 +00:00
John Factotum fea239a111 Reader: show cover, title, and author in sidebar 2022-10-20 18:16:44 +00:00
John Factotum 84691787fa Reader: add title and file chooser button 2022-10-20 14:28:42 +00:00
John Factotum 9a2bb558fd Reader: add sidebar and TOC 2022-10-20 12:50:37 +00:00
John Factotum d0cd085a22 Add sample reader 2022-10-19 11:04:43 +00:00