feat(reader): add document mode to the PDF viewer, overhaul PDF viewer, add different modes to CBX viewer (#306)

* feat(reader): add document mode to the PDF viewer, overhaul PDF viewer, add different modes to CBX viewer

* feat(reader): improve reader settings with brightness, emulate book mode, and click-to-paginate options

* feat(reader): add long strip scroll mode and update related settings
This commit is contained in:
brios
2026-04-22 17:26:57 -04:00
committed by Zach Yale
parent a3add5ded9
commit 61b9b53a60
47 changed files with 4458 additions and 874 deletions
@@ -33,6 +33,7 @@ import {NoteDialogResult, ReaderNoteDialogComponent} from './dialogs/note-dialog
import {EbookShortcutsHelpComponent} from './dialogs/shortcuts-help.component';
import {TranslocoPipe} from '@jsverse/transloco';
import {RelocateProgressData} from './state/progress.service';
import {WakeLockService} from '../../../shared/service/wake-lock.service';
@Component({
selector: 'app-ebook-reader',
@@ -83,6 +84,7 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
private selectionService = inject(ReaderSelectionService);
private headerService = inject(ReaderHeaderService);
private noteService = inject(ReaderNoteService);
private wakeLockService = inject(WakeLockService);
public sidebarService = inject(ReaderSidebarService);
public leftSidebarService = inject(ReaderLeftSidebarService);
@@ -108,6 +110,8 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
sectionFractions: number[] = [];
isFullscreen = false;
showShortcutsHelp = false;
immersiveMode = false;
private immersiveAutoHideTimer?: ReturnType<typeof setTimeout>;
readonly readerState = this.stateService.state;
readonly selectionState = this.selectionService.state;
@@ -161,6 +165,9 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.destroy$))
.subscribe(() => this.showShortcutsHelp = true);
// Enable wake lock after a short delay
setTimeout(() => this.wakeLockService.enable(), 1000);
this.isLoading = true;
this.initializeFoliate().pipe(
switchMap(() => this.epubCustomFontService.loadAndCacheFonts()),
@@ -180,6 +187,7 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
}
ngOnDestroy(): void {
this.wakeLockService.disable();
this.destroy$.next();
this.destroy$.complete();
this.viewManager.destroy();
@@ -193,6 +201,9 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
this.noteService.reset();
this.epubCustomFontService.cleanup();
if (this.immersiveAutoHideTimer) {
clearTimeout(this.immersiveAutoHideTimer);
}
if (this._fileUrl) {
URL.revokeObjectURL(this._fileUrl);
this._fileUrl = null;
@@ -315,7 +326,11 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
}, 500);
break;
case 'middle-single-tap':
this.toggleHeaderNavbarPinned();
if (this.immersiveMode) {
this.immersiveTemporaryShow();
} else {
this.toggleHeaderNavbarPinned();
}
break;
case 'text-selected':
this.selectionService.handleTextSelected(event.detail, event.popupPosition);
@@ -326,6 +341,9 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
case 'toggle-shortcuts-help':
this.showShortcutsHelp = !this.showShortcutsHelp;
break;
case 'toggle-immersive':
this.toggleImmersiveMode();
break;
case 'go-first-section':
this.viewManager.goToSection(0).subscribe();
break;
@@ -442,6 +460,24 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
this.visibilityManager.handleFooterZoneEnter();
}
toggleImmersiveMode(): void {
this.immersiveMode = !this.immersiveMode;
if (this.immersiveMode) {
this.visibilityManager.setImmersive(true);
} else {
this.visibilityManager.setImmersive(false);
}
}
private immersiveTemporaryShow(): void {
if (!this.immersiveMode) return;
this.visibilityManager.temporaryShow();
if (this.immersiveAutoHideTimer) clearTimeout(this.immersiveAutoHideTimer);
this.immersiveAutoHideTimer = setTimeout(() => {
this.visibilityManager.hideTemporary();
}, 3000);
}
handleSelectionAction(action: TextSelectionAction): void {
if (action.type === 'note') {
this.noteService.openNewNoteDialog();