Run code formatting (prettier/eslint) on existing reader format files that
were not migrated to the new structure. This ensures consistent code style
across the codebase.
## Changes
### Formatting Applied
- Added newlines at end of files
- Fixed line length and indentation
- Updated import statements for consistency
- Applied code style rules uniformly
### Files Affected
- **Comic**: background-color, chapter-markers, page-order, panel-gap
- **Ebook**: font-loader, search, view-modes
- **Manga**: vertical-scroll-mode
- **PDF**: annotation-layer, pdf-navigation, pdf-text-selection
## Purpose
These files will be removed in subsequent commits as they are replaced by
the new modular structure. The formatting ensures consistency during the
transition period and maintains code quality standards.
Note: These are non-functional formatting changes only. No logic or behavior
was modified in this commit.
Replace HTML-splitting pagination with CSS columns for true paginated
viewing. This simplifies the implementation and relies on the browser's
native column-fill behavior for accurate page breaks.
Changes:
- view-modes.ts: Use CSS columns with column-fill: auto instead of
pre-splitting HTML content into page chunks. Calculate page count
from scrollHeight / viewportHeight.
- reader-navigation.ts: Navigate by scrolling viewport height instead of
extracting discrete page content. Track page position via scroll
offset. Simplified renderSpineItem to load full spine content.
- page-calculator.ts: Simplified to track spine info (charCount,
estimatedPages) only. No more height-based content splitting.
Page calculation happens in real-time from DOM scroll position.
Benefits:
- Accurate pagination without estimation errors
- Works correctly across different font sizes and screen sizes
- Simpler code with fewer edge cases
- Natural page breaks at element boundaries via CSS
This commit implements true page-based pagination for the ebook reader,
similar to Kindle's approach where content is split into discrete pages
based on viewport size, font settings, and content layout.
Phase 1 - Bug Fixes:
- Fix goToPage to use getScrollPositionForPage instead of treating
page numbers as spine indices
- Move page calculation to initialize before first render to avoid
race condition with scroll handler
- Add fallback page calculation when pageCalculationResult is null
Phase 2 - Page Splitting:
- Add new page-splitter.ts module with CFI-based splitting for EPUB
and height-based fallback for other formats
- Integrate splitContent into page-calculator to generate discrete
page content for each spine item
- Store pages[] array in ChapterPageInfo for rendering
- Rewrite navigation (nextPage, previousPage, renderSpineItem) to
use page-based approach with currentPage tracking
- Remove old scroll-based pagination from view-modes.ts
- Update paginated mode CSS for true page clipping
Phase 3 - Progress Display:
- Update progress-indicator to use currentPage directly instead of
calculating from scroll position
- Fix getCurrentPage in reader-state to return currentPage for ebooks
Phase 4 - Interface Fixes:
- Add currentPage field to UniversalReader interface
- Update sendProgressUpdate to use currentPage directly
- Initialize currentPage to 1 on reader creation
Key features:
- Dynamic page count based on font size, line height, margins
- CFI-based page splitting preserves reading context
- Falls back to height-based splitting for non-EPUB formats
- Progress display updates immediately on page change
- Settings changes trigger page recalculation and re-render
Convert view-modes.ts to init(context) pattern with:
- Paginated mode with pagination controls
- Scrolled mode for continuous reading
- Single and double column layouts
- Event-based navigation and mode switching
- Update copy-handler.ts: export enableContextMenuCopy for text selection
- Update typography-engine.ts: export applyTypography and getFontStack
- Update view-modes.ts: export setViewMode and getCurrentViewMode
- Enable text copying with citation for ebooks
- Add typography engine with font loading and text formatting
- Add view mode support (paginated, scrolled, single/dual column)
- These features integrate with settings-manager for customization