Revamp streaming PDF reader to render pages on demand (#2332)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
<div class="comic-reader-container" tabindex="0">
|
||||
<!-- Header -->
|
||||
<app-cbx-header [isCurrentPageBookmarked]="isCurrentPageBookmarked" [currentPageHasNotes]="currentPageHasNotes"></app-cbx-header>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<app-cbx-sidebar></app-cbx-sidebar>
|
||||
|
||||
<!-- Quick Settings -->
|
||||
@if (showQuickSettings) {
|
||||
<app-cbx-quick-settings></app-cbx-quick-settings>
|
||||
}
|
||||
|
||||
<!-- Bookmark Indicator -->
|
||||
@if (isCurrentPageBookmarked) {
|
||||
<div class="bookmark-indicator">
|
||||
<svg width="48" height="64" viewBox="0 0 48 64">
|
||||
@@ -19,7 +15,6 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Note Dialog -->
|
||||
@if (showNoteDialog) {
|
||||
<app-cbx-note-dialog
|
||||
[data]="noteDialogData"
|
||||
@@ -28,7 +23,6 @@
|
||||
></app-cbx-note-dialog>
|
||||
}
|
||||
|
||||
<!-- Main content area -->
|
||||
<div class="image-container"
|
||||
[class.two-page-view]="isTwoPageView && scrollMode === CbxScrollMode.PAGINATED"
|
||||
[class.infinite-scroll]="scrollMode === CbxScrollMode.INFINITE"
|
||||
@@ -45,9 +39,18 @@
|
||||
@if (pages.length > 0) {
|
||||
@if (scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<div class="pages-wrapper" (click)="onImageClick()">
|
||||
@for (url of imageUrls; track url) {
|
||||
<img [src]="url" alt="Page Image" class="page-image"/>
|
||||
@if (isPageTransitioning && previousImageUrls.length > 0) {
|
||||
<div class="previous-page-layer">
|
||||
@for (url of previousImageUrls; track url) {
|
||||
<img [src]="url" alt="Previous Page" class="page-image previous-image"/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="current-page-layer" [class.fade-in]="isPageTransitioning && imagesLoaded">
|
||||
@for (url of currentImageUrls; track url) {
|
||||
<img [src]="url" alt="Page Image" class="page-image" (load)="onImageLoad()"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (isAtLastPage && nextBookInSeries) {
|
||||
<div class="end-of-comic-action">
|
||||
@@ -92,6 +95,5 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<app-cbx-footer></app-cbx-footer>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
outline: none;
|
||||
}
|
||||
|
||||
// Bookmark indicator
|
||||
.bookmark-indicator {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -82,6 +81,43 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.previous-page-layer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.current-page-layer {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
|
||||
&.fade-in {
|
||||
animation: fadeIn 0.15s ease-out forwards;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0.7;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.page-image {
|
||||
object-fit: contain;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
@@ -91,10 +127,18 @@
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
&.previous-image {
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-width {
|
||||
.pages-wrapper {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
}
|
||||
@@ -109,7 +153,9 @@
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.pages-wrapper {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
@@ -123,7 +169,9 @@
|
||||
}
|
||||
|
||||
&.fit-height {
|
||||
.pages-wrapper {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -149,7 +197,9 @@
|
||||
&.fit-actual-size {
|
||||
overflow: auto;
|
||||
|
||||
.pages-wrapper {
|
||||
.pages-wrapper,
|
||||
.previous-page-layer,
|
||||
.current-page-layer {
|
||||
width: max-content;
|
||||
height: max-content;
|
||||
min-width: 0;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import {Component, HostListener, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {CommonModule, Location} from '@angular/common';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {forkJoin, Subject} from 'rxjs';
|
||||
import {filter, first, takeUntil, timeout} from 'rxjs/operators';
|
||||
import {PageTitleService} from "../../../shared/service/page-title.service";
|
||||
import {CbxReaderService} from '../../book/service/cbx-reader.service';
|
||||
import {BookService} from '../../book/service/book.service';
|
||||
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, PdfPageSpread, PdfPageViewMode, UserService} from '../../settings/user-management/user.service';
|
||||
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, PdfBackgroundColor, PdfFitMode, PdfPageSpread, PdfPageViewMode, PdfScrollMode, UserService} from '../../settings/user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Book, BookSetting, BookType} from '../../book/model/book.model';
|
||||
import {BookState} from '../../book/model/state/book-state.model';
|
||||
@@ -14,9 +14,8 @@ import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {NewPdfReaderService} from '../../book/service/new-pdf-reader.service';
|
||||
import {ReadingSessionService} from '../../../shared/service/reading-session.service';
|
||||
import {ReaderHeaderFooterVisibilityManager} from '../ebook-reader/shared/visibility.util';
|
||||
import {ReaderHeaderFooterVisibilityManager} from '../ebook-reader';
|
||||
|
||||
// Layout components
|
||||
import {CbxHeaderComponent} from './layout/header/cbx-header.component';
|
||||
import {CbxHeaderService} from './layout/header/cbx-header.service';
|
||||
import {CbxSidebarComponent} from './layout/sidebar/cbx-sidebar.component';
|
||||
@@ -62,9 +61,9 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
pageSpread: CbxPageSpread | PdfPageSpread = CbxPageSpread.ODD;
|
||||
pageViewMode: CbxPageViewMode | PdfPageViewMode = CbxPageViewMode.SINGLE_PAGE;
|
||||
backgroundColor: CbxBackgroundColor = CbxBackgroundColor.GRAY;
|
||||
fitMode: CbxFitMode = CbxFitMode.FIT_PAGE;
|
||||
scrollMode: CbxScrollMode = CbxScrollMode.PAGINATED;
|
||||
backgroundColor: CbxBackgroundColor | PdfBackgroundColor = CbxBackgroundColor.GRAY;
|
||||
fitMode: CbxFitMode | PdfFitMode = CbxFitMode.FIT_PAGE;
|
||||
scrollMode: CbxScrollMode | PdfScrollMode = CbxScrollMode.PAGINATED;
|
||||
|
||||
private touchStartX = 0;
|
||||
private touchEndX = 0;
|
||||
@@ -77,9 +76,14 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
preloadCount: number = 3;
|
||||
isLoadingMore: boolean = false;
|
||||
|
||||
private preloadedImages = new Map<string, HTMLImageElement>();
|
||||
previousImageUrls: string[] = [];
|
||||
currentImageUrls: string[] = [];
|
||||
isPageTransitioning = false;
|
||||
imagesLoaded = false;
|
||||
|
||||
private visibilityManager!: ReaderHeaderFooterVisibilityManager;
|
||||
|
||||
// Bookmark and notes state
|
||||
isCurrentPageBookmarked = false;
|
||||
currentPageHasNotes = false;
|
||||
showNoteDialog = false;
|
||||
@@ -88,7 +92,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private location = inject(Location);
|
||||
private cbxReaderService = inject(CbxReaderService);
|
||||
private pdfReaderService = inject(NewPdfReaderService);
|
||||
private bookService = inject(BookService);
|
||||
@@ -143,7 +146,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.pageTitle.setBookPageTitle(book);
|
||||
|
||||
// Initialize header and sidebar services
|
||||
const title = book.metadata?.title || book.fileName;
|
||||
this.headerService.initialize(this.bookId, title, this.destroy$);
|
||||
this.sidebarService.initialize(this.bookId, book, this.destroy$);
|
||||
@@ -198,6 +200,18 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
? PdfPageSpread[userSettings.newPdfReaderSetting.pageSpread as keyof typeof PdfPageSpread] || PdfPageSpread.ODD
|
||||
: PdfPageSpread[bookSettings.newPdfSettings?.pageSpread as keyof typeof PdfPageSpread] || PdfPageSpread[userSettings.newPdfReaderSetting.pageSpread as keyof typeof PdfPageSpread] || PdfPageSpread.ODD;
|
||||
|
||||
this.fitMode = global
|
||||
? PdfFitMode[userSettings.newPdfReaderSetting.fitMode as keyof typeof PdfFitMode] || PdfFitMode.FIT_PAGE
|
||||
: PdfFitMode[bookSettings.newPdfSettings?.fitMode as keyof typeof PdfFitMode] || PdfFitMode[userSettings.newPdfReaderSetting.fitMode as keyof typeof PdfFitMode] || PdfFitMode.FIT_PAGE;
|
||||
|
||||
this.scrollMode = global
|
||||
? PdfScrollMode[userSettings.newPdfReaderSetting.scrollMode as keyof typeof PdfScrollMode] || PdfScrollMode.PAGINATED
|
||||
: PdfScrollMode[bookSettings.newPdfSettings?.scrollMode as keyof typeof PdfScrollMode] || PdfScrollMode[userSettings.newPdfReaderSetting.scrollMode as keyof typeof PdfScrollMode] || PdfScrollMode.PAGINATED;
|
||||
|
||||
this.backgroundColor = global
|
||||
? PdfBackgroundColor[userSettings.newPdfReaderSetting.backgroundColor as keyof typeof PdfBackgroundColor] || PdfBackgroundColor.GRAY
|
||||
: PdfBackgroundColor[bookSettings.newPdfSettings?.backgroundColor as keyof typeof PdfBackgroundColor] || PdfBackgroundColor[userSettings.newPdfReaderSetting.backgroundColor as keyof typeof PdfBackgroundColor] || PdfBackgroundColor.GRAY;
|
||||
|
||||
this.currentPage = (book.pdfProgress?.page || 1) - 1;
|
||||
}
|
||||
this.alignCurrentPageToParity();
|
||||
@@ -206,6 +220,9 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.updateNotesState();
|
||||
this.isLoading = false;
|
||||
|
||||
this.updateCurrentImageUrls();
|
||||
this.preloadAdjacentPages();
|
||||
|
||||
const percentage = this.pages.length > 0 ? Math.round(((this.currentPage + 1) / this.pages.length) * 1000) / 10 : 0;
|
||||
this.readingSessionService.startSession(this.bookId, "CBX", (this.currentPage + 1).toString(), percentage);
|
||||
},
|
||||
@@ -258,14 +275,12 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.updateBookmarkState();
|
||||
});
|
||||
|
||||
// Subscribe to bookmarks$ to update state when bookmarks are loaded
|
||||
this.sidebarService.bookmarks$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => {
|
||||
this.updateBookmarkState();
|
||||
});
|
||||
|
||||
// Subscribe to notes$ to update state when notes are loaded
|
||||
this.sidebarService.notes$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(() => {
|
||||
@@ -336,7 +351,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private updateServiceStates(): void {
|
||||
// Update footer state
|
||||
this.footerService.updateState({
|
||||
currentPage: this.currentPage,
|
||||
totalPages: this.pages.length,
|
||||
@@ -346,7 +360,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
hasSeries: this.hasSeries
|
||||
});
|
||||
|
||||
// Update quick settings state
|
||||
this.quickSettingsService.updateState({
|
||||
fitMode: this.fitMode,
|
||||
scrollMode: this.scrollMode,
|
||||
@@ -355,7 +368,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
backgroundColor: this.backgroundColor
|
||||
});
|
||||
|
||||
// Update sidebar current page
|
||||
this.sidebarService.setCurrentPage(this.currentPage + 1);
|
||||
}
|
||||
|
||||
@@ -366,6 +378,155 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.updateNotesState();
|
||||
}
|
||||
|
||||
private updateCurrentImageUrls(): void {
|
||||
if (!this.pages.length) {
|
||||
this.currentImageUrls = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const urls: string[] = [];
|
||||
urls.push(this.getPageImageUrl(this.currentPage));
|
||||
|
||||
if (this.isTwoPageView && this.currentPage + 1 < this.pages.length) {
|
||||
urls.push(this.getPageImageUrl(this.currentPage + 1));
|
||||
}
|
||||
|
||||
this.currentImageUrls = urls;
|
||||
}
|
||||
|
||||
private preloadAdjacentPages(): void {
|
||||
if (!this.pages.length || this.scrollMode === CbxScrollMode.INFINITE) return;
|
||||
|
||||
const pagesToPreload: number[] = [];
|
||||
|
||||
const step = this.isTwoPageView ? 2 : 1;
|
||||
for (let i = 1; i <= 2; i++) {
|
||||
const nextPage = this.currentPage + (step * i);
|
||||
if (nextPage < this.pages.length) {
|
||||
pagesToPreload.push(nextPage);
|
||||
if (this.isTwoPageView && nextPage + 1 < this.pages.length) {
|
||||
pagesToPreload.push(nextPage + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 1; i <= 2; i++) {
|
||||
const prevPage = this.currentPage - (step * i);
|
||||
if (prevPage >= 0) {
|
||||
pagesToPreload.push(prevPage);
|
||||
if (this.isTwoPageView && prevPage + 1 < this.pages.length) {
|
||||
pagesToPreload.push(prevPage + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pagesToPreload.forEach(pageIndex => {
|
||||
const url = this.getPageImageUrl(pageIndex);
|
||||
if (!this.preloadedImages.has(url)) {
|
||||
const img = new Image();
|
||||
img.src = url;
|
||||
this.preloadedImages.set(url, img);
|
||||
}
|
||||
});
|
||||
|
||||
this.cleanupPreloadedImages(pagesToPreload);
|
||||
}
|
||||
|
||||
private cleanupPreloadedImages(keepPages: number[]): void {
|
||||
const keepUrls = new Set(keepPages.map(p => this.getPageImageUrl(p)));
|
||||
this.currentImageUrls.forEach(url => keepUrls.add(url));
|
||||
|
||||
for (const url of this.preloadedImages.keys()) {
|
||||
if (!keepUrls.has(url)) {
|
||||
this.preloadedImages.delete(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private transitionToNewPage(): void {
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
this.updateCurrentImageUrls();
|
||||
return;
|
||||
}
|
||||
|
||||
const newUrls = this.getNewImageUrls();
|
||||
|
||||
const allPreloaded = newUrls.every(url => {
|
||||
const img = this.preloadedImages.get(url);
|
||||
return img && img.complete && img.naturalWidth > 0;
|
||||
});
|
||||
|
||||
if (allPreloaded) {
|
||||
this.previousImageUrls = [...this.currentImageUrls];
|
||||
this.currentImageUrls = newUrls;
|
||||
this.isPageTransitioning = true;
|
||||
this.imagesLoaded = true;
|
||||
|
||||
setTimeout(() => {
|
||||
this.isPageTransitioning = false;
|
||||
this.previousImageUrls = [];
|
||||
}, 150);
|
||||
} else {
|
||||
this.isPageTransitioning = true;
|
||||
this.imagesLoaded = false;
|
||||
this.previousImageUrls = [...this.currentImageUrls];
|
||||
|
||||
this.preloadImagesAndTransition(newUrls);
|
||||
}
|
||||
|
||||
this.preloadAdjacentPages();
|
||||
}
|
||||
|
||||
private getNewImageUrls(): string[] {
|
||||
if (!this.pages.length) return [];
|
||||
|
||||
const urls: string[] = [];
|
||||
urls.push(this.getPageImageUrl(this.currentPage));
|
||||
|
||||
if (this.isTwoPageView && this.currentPage + 1 < this.pages.length) {
|
||||
urls.push(this.getPageImageUrl(this.currentPage + 1));
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
private preloadImagesAndTransition(urls: string[]): void {
|
||||
let loadedCount = 0;
|
||||
const totalImages = urls.length;
|
||||
|
||||
urls.forEach(url => {
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
loadedCount++;
|
||||
this.preloadedImages.set(url, img);
|
||||
|
||||
if (loadedCount === totalImages) {
|
||||
this.currentImageUrls = urls;
|
||||
this.imagesLoaded = true;
|
||||
|
||||
setTimeout(() => {
|
||||
this.isPageTransitioning = false;
|
||||
this.previousImageUrls = [];
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
img.onerror = () => {
|
||||
loadedCount++;
|
||||
if (loadedCount === totalImages) {
|
||||
this.currentImageUrls = urls;
|
||||
this.imagesLoaded = true;
|
||||
this.isPageTransitioning = false;
|
||||
this.previousImageUrls = [];
|
||||
}
|
||||
};
|
||||
img.src = url;
|
||||
});
|
||||
}
|
||||
|
||||
onImageLoad(): void {
|
||||
this.imagesLoaded = true;
|
||||
}
|
||||
|
||||
get isTwoPageView(): boolean {
|
||||
return this.pageViewMode === this.CbxPageViewMode.TWO_PAGE || this.pageViewMode === PdfPageViewMode.TWO_PAGE;
|
||||
}
|
||||
@@ -403,6 +564,7 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
if (this.currentPage !== previousPage) {
|
||||
this.transitionToNewPage();
|
||||
this.updateProgress();
|
||||
this.updateSessionProgress();
|
||||
this.updateFooterPage();
|
||||
@@ -410,6 +572,8 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
previousPage() {
|
||||
const previousPage = this.currentPage;
|
||||
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
if (this.currentPage > 0) {
|
||||
this.currentPage--;
|
||||
@@ -426,9 +590,13 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
} else {
|
||||
this.currentPage = Math.max(0, this.currentPage - 1);
|
||||
}
|
||||
this.updateProgress();
|
||||
this.updateSessionProgress();
|
||||
this.updateFooterPage();
|
||||
|
||||
if (this.currentPage !== previousPage) {
|
||||
this.transitionToNewPage();
|
||||
this.updateProgress();
|
||||
this.updateSessionProgress();
|
||||
this.updateFooterPage();
|
||||
}
|
||||
}
|
||||
|
||||
private alignCurrentPageToParity() {
|
||||
@@ -451,7 +619,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
// Quick settings handlers
|
||||
onFitModeChange(mode: CbxFitMode): void {
|
||||
this.fitMode = mode;
|
||||
this.quickSettingsService.setFitMode(mode);
|
||||
@@ -466,6 +633,9 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
this.initializeInfiniteScroll();
|
||||
setTimeout(() => this.scrollToPage(this.currentPage), 100);
|
||||
} else {
|
||||
this.updateCurrentImageUrls();
|
||||
this.preloadAdjacentPages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,6 +644,8 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.pageViewMode = mode;
|
||||
this.quickSettingsService.setPageViewMode(mode);
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateCurrentImageUrls();
|
||||
this.preloadAdjacentPages();
|
||||
this.footerService.setTwoPageView(this.isTwoPageView);
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
@@ -482,6 +654,8 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.pageSpread = spread;
|
||||
this.quickSettingsService.setPageSpread(spread);
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateCurrentImageUrls();
|
||||
this.preloadAdjacentPages();
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
@@ -558,20 +732,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
: this.cbxReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex]);
|
||||
}
|
||||
|
||||
get imageUrls(): string[] {
|
||||
if (!this.pages.length) return [];
|
||||
|
||||
const urls: string[] = [];
|
||||
|
||||
urls.push(this.getPageImageUrl(this.currentPage));
|
||||
|
||||
if (this.isTwoPageView && this.currentPage + 1 < this.pages.length) {
|
||||
urls.push(this.getPageImageUrl(this.currentPage + 1));
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
get infiniteScrollImageUrls(): string[] {
|
||||
return this.infiniteScrollPages.map(pageIndex => this.getPageImageUrl(pageIndex));
|
||||
}
|
||||
@@ -591,6 +751,9 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
newPdfSettings: {
|
||||
pageSpread: this.pageSpread as PdfPageSpread,
|
||||
pageViewMode: this.pageViewMode as PdfPageViewMode,
|
||||
fitMode: this.fitMode as PdfFitMode,
|
||||
scrollMode: this.scrollMode as PdfScrollMode,
|
||||
backgroundColor: this.backgroundColor as PdfBackgroundColor,
|
||||
}
|
||||
};
|
||||
this.bookService.updateViewerSetting(bookSetting, this.bookId).subscribe();
|
||||
@@ -635,6 +798,7 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.updateFooterPage();
|
||||
} else {
|
||||
this.alignCurrentPageToParity();
|
||||
this.transitionToNewPage();
|
||||
this.updateProgress();
|
||||
this.updateSessionProgress();
|
||||
this.updateFooterPage();
|
||||
@@ -783,7 +947,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.previousBookInSeries = hasPreviousBook ? sortedBySeriesNumber[currentBookIndex - 1] : null;
|
||||
this.nextBookInSeries = hasNextBook ? sortedBySeriesNumber[currentBookIndex + 1] : null;
|
||||
|
||||
// Update footer service with series info
|
||||
this.footerService.setSeriesBooks(this.previousBookInSeries, this.nextBookInSeries);
|
||||
this.footerService.setHasSeries(true);
|
||||
},
|
||||
@@ -803,22 +966,17 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
getBookDisplayTitle(book: Book | null): string {
|
||||
if (!book) return '';
|
||||
|
||||
const parts: string[] = [];
|
||||
|
||||
if (book.metadata?.seriesNumber) {
|
||||
parts.push(`#${book.metadata.seriesNumber}`);
|
||||
}
|
||||
|
||||
const title = book.metadata?.title || book.fileName;
|
||||
if (title) {
|
||||
parts.push(title);
|
||||
}
|
||||
|
||||
if (book.metadata?.subtitle) {
|
||||
parts.push(book.metadata.subtitle);
|
||||
}
|
||||
|
||||
return parts.join(' - ');
|
||||
}
|
||||
|
||||
@@ -835,7 +993,6 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
// Bookmark methods
|
||||
private updateBookmarkState(): void {
|
||||
this.isCurrentPageBookmarked = this.sidebarService.isPageBookmarked(this.currentPage + 1);
|
||||
}
|
||||
@@ -844,12 +1001,10 @@ export class CbxReaderComponent implements OnInit, OnDestroy {
|
||||
this.sidebarService.toggleBookmark(this.currentPage + 1);
|
||||
}
|
||||
|
||||
// Notes state methods
|
||||
private updateNotesState(): void {
|
||||
this.currentPageHasNotes = this.sidebarService.pageHasNotes(this.currentPage + 1);
|
||||
}
|
||||
|
||||
// Note dialog methods
|
||||
openNoteDialog(): void {
|
||||
this.editingNote = null;
|
||||
this.noteDialogData = {
|
||||
|
||||
+4
-12
@@ -1,21 +1,13 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Subject} from 'rxjs';
|
||||
import {
|
||||
CbxFitMode,
|
||||
CbxScrollMode,
|
||||
CbxPageViewMode,
|
||||
CbxPageSpread,
|
||||
CbxBackgroundColor,
|
||||
PdfPageViewMode,
|
||||
PdfPageSpread
|
||||
} from '../../../../settings/user-management/user.service';
|
||||
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, PdfBackgroundColor, PdfFitMode, PdfPageSpread, PdfPageViewMode, PdfScrollMode} from '../../../../settings/user-management/user.service';
|
||||
|
||||
export interface CbxQuickSettingsState {
|
||||
fitMode: CbxFitMode;
|
||||
scrollMode: CbxScrollMode;
|
||||
fitMode: CbxFitMode | PdfFitMode;
|
||||
scrollMode: CbxScrollMode | PdfScrollMode;
|
||||
pageViewMode: CbxPageViewMode | PdfPageViewMode;
|
||||
pageSpread: CbxPageSpread | PdfPageSpread;
|
||||
backgroundColor: CbxBackgroundColor;
|
||||
backgroundColor: CbxBackgroundColor | PdfBackgroundColor;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
||||
+53
-23
@@ -1,7 +1,6 @@
|
||||
@if (isOpen) {
|
||||
<div class="sidebar-overlay" (click)="onOverlayClick()" [class.closing]="closing">
|
||||
<aside class="sidebar" (click)="$event.stopPropagation()" [class.closing]="closing">
|
||||
<!-- Header with book info -->
|
||||
<header class="sidebar-header">
|
||||
@if (bookInfo.coverUrl) {
|
||||
<img
|
||||
@@ -18,14 +17,13 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Tab navigation -->
|
||||
<nav class="tabs">
|
||||
<button
|
||||
class="tab"
|
||||
[class.active]="activeTab === 'pages'"
|
||||
(click)="setActiveTab('pages')">
|
||||
<app-reader-icon name="book" class="tab-icon"></app-reader-icon>
|
||||
<span>Pages</span>
|
||||
<span>Content</span>
|
||||
</button>
|
||||
<button
|
||||
class="tab"
|
||||
@@ -49,31 +47,64 @@
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<!-- Tab content -->
|
||||
<div class="content">
|
||||
@switch (activeTab) {
|
||||
@case ('pages') {
|
||||
<ul class="page-list">
|
||||
@for (page of pages; track page.pageNumber) {
|
||||
<li>
|
||||
<button
|
||||
class="page-row"
|
||||
[class.active]="isPageActive(page.pageNumber)"
|
||||
(click)="onPageClick(page.pageNumber)">
|
||||
<span class="page-number">{{ page.pageNumber }}</span>
|
||||
<span class="page-label">{{ page.displayName }}</span>
|
||||
</button>
|
||||
</li>
|
||||
@if (isPdf && hasOutline) {
|
||||
<ul class="outline-list">
|
||||
<ng-container *ngTemplateOutlet="outlineTemplate; context: { items: pdfOutline, depth: 0 }"></ng-container>
|
||||
</ul>
|
||||
|
||||
<ng-template #outlineTemplate let-items="items" let-depth="depth">
|
||||
@for (item of items; track item.title + item.pageNumber) {
|
||||
<li class="outline-item">
|
||||
<button
|
||||
class="outline-row"
|
||||
[class.active]="isOutlineItemActive(item, items)"
|
||||
[class.has-children]="item.children && item.children.length > 0"
|
||||
[style.padding-left.px]="16 + depth * 16"
|
||||
(click)="onOutlineItemClick(item)">
|
||||
@if (item.children && item.children.length > 0) {
|
||||
<span
|
||||
class="expand-icon"
|
||||
[class.expanded]="isOutlineItemExpanded(item)"
|
||||
(click)="toggleOutlineItem(item); $event.stopPropagation()">
|
||||
<app-reader-icon name="chevron-right" [size]="14"></app-reader-icon>
|
||||
</span>
|
||||
}
|
||||
<span class="outline-title">{{ item.title }}</span>
|
||||
<span class="outline-page">{{ item.pageNumber }}</span>
|
||||
</button>
|
||||
@if (item.children && item.children.length > 0 && isOutlineItemExpanded(item)) {
|
||||
<ul class="outline-children">
|
||||
<ng-container *ngTemplateOutlet="outlineTemplate; context: { items: item.children, depth: depth + 1 }"></ng-container>
|
||||
</ul>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ng-template>
|
||||
} @else {
|
||||
<ul class="page-list">
|
||||
@for (page of pages; track page.pageNumber) {
|
||||
<li>
|
||||
<button
|
||||
class="page-row"
|
||||
[class.active]="isPageActive(page.pageNumber)"
|
||||
(click)="onPageClick(page.pageNumber)">
|
||||
<span class="page-number">{{ page.pageNumber }}</span>
|
||||
<span class="page-label">{{ page.displayName }}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@if (pages.length === 0 && !hasOutline) {
|
||||
<div class="empty-state">
|
||||
<app-reader-icon name="book" class="empty-icon" [size]="48" [strokeWidth]="1.5"></app-reader-icon>
|
||||
<p>No pages found</p>
|
||||
</div>
|
||||
}
|
||||
</ul>
|
||||
@if (pages.length === 0) {
|
||||
<div class="empty-state">
|
||||
<app-reader-icon name="book" class="empty-icon" [size]="48" [strokeWidth]="1.5"></app-reader-icon>
|
||||
<p>No pages found</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@case ('bookmarks') {
|
||||
@if (bookmarks.length > 0) {
|
||||
<ul class="item-list">
|
||||
@@ -97,7 +128,6 @@
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@case ('notes') {
|
||||
<div class="notes-container">
|
||||
@if (notes.length > 0) {
|
||||
|
||||
+83
@@ -229,6 +229,89 @@ $transition-normal: 200ms ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
// PDF Outline list
|
||||
.outline-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.outline-item {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.outline-children {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.outline-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 10px 16px;
|
||||
padding-right: 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: $text-primary;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background $transition-fast;
|
||||
gap: 8px;
|
||||
|
||||
&:hover {
|
||||
background: $hover-bg;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: $active-bg;
|
||||
color: $active-color;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&.has-children {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
color: $text-muted;
|
||||
transition: transform $transition-fast;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
color: $text-primary;
|
||||
}
|
||||
|
||||
&.expanded {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
.outline-title {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.outline-page {
|
||||
font-size: 11px;
|
||||
color: $text-muted;
|
||||
flex-shrink: 0;
|
||||
min-width: 28px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
// Item list (bookmarks & notes)
|
||||
.item-list {
|
||||
list-style: none;
|
||||
|
||||
+89
-4
@@ -5,9 +5,10 @@ import {Subject} from 'rxjs';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {CbxSidebarService, CbxSidebarTab, SidebarBookInfo} from './cbx-sidebar.service';
|
||||
import {CbxPageInfo} from '../../../../book/service/cbx-reader.service';
|
||||
import {PdfOutlineItem} from '../../../../book/service/new-pdf-reader.service';
|
||||
import {BookMark} from '../../../../../shared/service/book-mark.service';
|
||||
import {BookNoteV2} from '../../../../../shared/service/book-note-v2.service';
|
||||
import {ReaderIconComponent} from '../../../ebook-reader/shared/icon.component';
|
||||
import {ReaderIconComponent} from '../../../ebook-reader';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cbx-sidebar',
|
||||
@@ -25,6 +26,9 @@ export class CbxSidebarComponent implements OnInit, OnDestroy {
|
||||
activeTab: CbxSidebarTab = 'pages';
|
||||
bookInfo: SidebarBookInfo = { id: null, title: '', authors: '', coverUrl: null };
|
||||
pages: CbxPageInfo[] = [];
|
||||
pdfOutline: PdfOutlineItem[] | null = null;
|
||||
pdfPageCount = 0;
|
||||
expandedOutlineItems = new Set<string>();
|
||||
currentPage = 1;
|
||||
bookmarks: BookMark[] = [];
|
||||
notes: BookNoteV2[] = [];
|
||||
@@ -54,9 +58,23 @@ export class CbxSidebarComponent implements OnInit, OnDestroy {
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(pages => this.pages = pages);
|
||||
|
||||
this.sidebarService.pdfOutline$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(outline => {
|
||||
this.pdfOutline = outline;
|
||||
this.autoExpandToCurrentPage();
|
||||
});
|
||||
|
||||
this.sidebarService.pdfPageCount$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(count => this.pdfPageCount = count);
|
||||
|
||||
this.sidebarService.currentPage$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(page => this.currentPage = page);
|
||||
.subscribe(page => {
|
||||
this.currentPage = page;
|
||||
this.autoExpandToCurrentPage();
|
||||
});
|
||||
|
||||
this.sidebarService.bookmarks$
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
@@ -96,7 +114,75 @@ export class CbxSidebarComponent implements OnInit, OnDestroy {
|
||||
return this.currentPage === pageNumber;
|
||||
}
|
||||
|
||||
// Bookmark methods
|
||||
get isPdf(): boolean {
|
||||
return this.sidebarService.isPdf;
|
||||
}
|
||||
|
||||
get hasOutline(): boolean {
|
||||
return this.pdfOutline !== null && this.pdfOutline.length > 0;
|
||||
}
|
||||
|
||||
toggleOutlineItem(item: PdfOutlineItem): void {
|
||||
const key = `${item.title}-${item.pageNumber}`;
|
||||
if (this.expandedOutlineItems.has(key)) {
|
||||
this.expandedOutlineItems.delete(key);
|
||||
} else {
|
||||
this.expandedOutlineItems.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
isOutlineItemExpanded(item: PdfOutlineItem): boolean {
|
||||
const key = `${item.title}-${item.pageNumber}`;
|
||||
return this.expandedOutlineItems.has(key);
|
||||
}
|
||||
|
||||
onOutlineItemClick(item: PdfOutlineItem): void {
|
||||
this.sidebarService.navigateToPage(item.pageNumber);
|
||||
}
|
||||
|
||||
isOutlineItemActive(item: PdfOutlineItem, siblings: PdfOutlineItem[] | null): boolean {
|
||||
if (!siblings) return this.currentPage >= item.pageNumber;
|
||||
|
||||
const itemIndex = siblings.findIndex(s => s.title === item.title && s.pageNumber === item.pageNumber);
|
||||
const nextSibling = siblings[itemIndex + 1];
|
||||
|
||||
if (nextSibling) {
|
||||
return this.currentPage >= item.pageNumber && this.currentPage < nextSibling.pageNumber;
|
||||
} else {
|
||||
return this.currentPage >= item.pageNumber;
|
||||
}
|
||||
}
|
||||
|
||||
hasActiveChild(item: PdfOutlineItem): boolean {
|
||||
if (!item.children || item.children.length === 0) return false;
|
||||
|
||||
return item.children.some((child, index) => {
|
||||
if (this.isOutlineItemActive(child, item.children)) return true;
|
||||
if (this.hasActiveChild(child)) return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private autoExpandToCurrentPage(): void {
|
||||
if (!this.pdfOutline) return;
|
||||
|
||||
const expandParents = (items: PdfOutlineItem[] | null): void => {
|
||||
if (!items) return;
|
||||
|
||||
for (const item of items) {
|
||||
if (item.children && item.children.length > 0) {
|
||||
if (this.hasActiveChild(item) || this.isOutlineItemActive(item, items)) {
|
||||
const key = `${item.title}-${item.pageNumber}`;
|
||||
this.expandedOutlineItems.add(key);
|
||||
}
|
||||
expandParents(item.children);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expandParents(this.pdfOutline);
|
||||
}
|
||||
|
||||
onBookmarkClick(cfi: string): void {
|
||||
this.sidebarService.navigateToBookmark(cfi);
|
||||
}
|
||||
@@ -106,7 +192,6 @@ export class CbxSidebarComponent implements OnInit, OnDestroy {
|
||||
this.sidebarService.deleteBookmark(bookmarkId);
|
||||
}
|
||||
|
||||
// Notes methods
|
||||
onNoteClick(cfi: string): void {
|
||||
this.sidebarService.navigateToNote(cfi);
|
||||
}
|
||||
|
||||
+31
-33
@@ -1,9 +1,10 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Subject} from 'rxjs';
|
||||
import {takeUntil} from 'rxjs/operators';
|
||||
import {CbxReaderService, CbxPageInfo} from '../../../../book/service/cbx-reader.service';
|
||||
import {CbxPageInfo, CbxReaderService} from '../../../../book/service/cbx-reader.service';
|
||||
import {NewPdfReaderService, PdfOutlineItem} from '../../../../book/service/new-pdf-reader.service';
|
||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||
import {Book} from '../../../../book/model/book.model';
|
||||
import {Book, BookType} from '../../../../book/model/book.model';
|
||||
import {BookMark, BookMarkService, CreateBookMarkRequest} from '../../../../../shared/service/book-mark.service';
|
||||
import {BookNoteV2, BookNoteV2Service, CreateBookNoteV2Request, UpdateBookNoteV2Request} from '../../../../../shared/service/book-note-v2.service';
|
||||
|
||||
@@ -20,11 +21,13 @@ export type CbxSidebarTab = 'pages' | 'bookmarks' | 'notes';
|
||||
export class CbxSidebarService {
|
||||
private urlHelper = inject(UrlHelperService);
|
||||
private cbxReaderService = inject(CbxReaderService);
|
||||
private pdfReaderService = inject(NewPdfReaderService);
|
||||
private bookMarkService = inject(BookMarkService);
|
||||
private bookNoteV2Service = inject(BookNoteV2Service);
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private bookId!: number;
|
||||
private bookType!: BookType;
|
||||
|
||||
private _isOpen = new BehaviorSubject<boolean>(false);
|
||||
private _activeTab = new BehaviorSubject<CbxSidebarTab>('pages');
|
||||
@@ -35,6 +38,8 @@ export class CbxSidebarService {
|
||||
coverUrl: null
|
||||
});
|
||||
private _pages = new BehaviorSubject<CbxPageInfo[]>([]);
|
||||
private _pdfOutline = new BehaviorSubject<PdfOutlineItem[] | null>(null);
|
||||
private _pdfPageCount = new BehaviorSubject<number>(0);
|
||||
private _currentPage = new BehaviorSubject<number>(1);
|
||||
private _bookmarks = new BehaviorSubject<BookMark[]>([]);
|
||||
private _notes = new BehaviorSubject<BookNoteV2[]>([]);
|
||||
@@ -48,6 +53,8 @@ export class CbxSidebarService {
|
||||
activeTab$ = this._activeTab.asObservable();
|
||||
bookInfo$ = this._bookInfo.asObservable();
|
||||
pages$ = this._pages.asObservable();
|
||||
pdfOutline$ = this._pdfOutline.asObservable();
|
||||
pdfPageCount$ = this._pdfPageCount.asObservable();
|
||||
currentPage$ = this._currentPage.asObservable();
|
||||
bookmarks$ = this._bookmarks.asObservable();
|
||||
notes$ = this._notes.asObservable();
|
||||
@@ -55,16 +62,13 @@ export class CbxSidebarService {
|
||||
editNote$ = this._editNote.asObservable();
|
||||
bookmarksChanged$ = this._bookmarksChanged.asObservable();
|
||||
|
||||
get currentPage(): number {
|
||||
return this._currentPage.value;
|
||||
}
|
||||
|
||||
get activeTab(): CbxSidebarTab {
|
||||
return this._activeTab.value;
|
||||
get isPdf(): boolean {
|
||||
return this.bookType === 'PDF';
|
||||
}
|
||||
|
||||
initialize(bookId: number, book: Book, destroy$: Subject<void>): void {
|
||||
this.bookId = bookId;
|
||||
this.bookType = book.bookType;
|
||||
this.destroy$ = destroy$;
|
||||
|
||||
this._bookInfo.next({
|
||||
@@ -80,9 +84,25 @@ export class CbxSidebarService {
|
||||
}
|
||||
|
||||
private loadPageInfo(): void {
|
||||
this.cbxReaderService.getPageInfo(this.bookId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(pages => this._pages.next(pages));
|
||||
if (this.bookType === 'PDF') {
|
||||
this.pdfReaderService.getPageInfo(this.bookId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(pdfInfo => {
|
||||
this._pdfPageCount.next(pdfInfo.pageCount);
|
||||
this._pdfOutline.next(pdfInfo.outline);
|
||||
if (!pdfInfo.outline || pdfInfo.outline.length === 0) {
|
||||
const pages: CbxPageInfo[] = [];
|
||||
for (let i = 1; i <= pdfInfo.pageCount; i++) {
|
||||
pages.push({pageNumber: i, displayName: `Page ${i}`});
|
||||
}
|
||||
this._pages.next(pages);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.cbxReaderService.getPageInfo(this.bookId)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(pages => this._pages.next(pages));
|
||||
}
|
||||
}
|
||||
|
||||
private loadBookmarks(): void {
|
||||
@@ -97,10 +117,6 @@ export class CbxSidebarService {
|
||||
.subscribe(notes => this._notes.next(notes));
|
||||
}
|
||||
|
||||
refreshNotes(): void {
|
||||
this.loadNotes();
|
||||
}
|
||||
|
||||
setCurrentPage(page: number): void {
|
||||
this._currentPage.next(page);
|
||||
}
|
||||
@@ -125,7 +141,6 @@ export class CbxSidebarService {
|
||||
this.close();
|
||||
}
|
||||
|
||||
// Bookmark methods - using page number as the location identifier (stored in cfi field)
|
||||
isPageBookmarked(pageNumber: number): boolean {
|
||||
const pageStr = pageNumber.toString();
|
||||
return this._bookmarks.value.some(b => b.cfi === pageStr);
|
||||
@@ -177,17 +192,11 @@ export class CbxSidebarService {
|
||||
}
|
||||
}
|
||||
|
||||
// Notes methods - using page number as the location identifier (stored in cfi field)
|
||||
pageHasNotes(pageNumber: number): boolean {
|
||||
const pageStr = pageNumber.toString();
|
||||
return this._notes.value.some(n => n.cfi === pageStr);
|
||||
}
|
||||
|
||||
getNotesForPage(pageNumber: number): BookNoteV2[] {
|
||||
const pageStr = pageNumber.toString();
|
||||
return this._notes.value.filter(n => n.cfi === pageStr);
|
||||
}
|
||||
|
||||
createNote(pageNumber: number, noteContent: string, color?: string): void {
|
||||
const request: CreateBookNoteV2Request = {
|
||||
bookId: this.bookId,
|
||||
@@ -249,15 +258,4 @@ export class CbxSidebarService {
|
||||
(note.chapterTitle?.toLowerCase().includes(query))
|
||||
);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._isOpen.next(false);
|
||||
this._activeTab.next('pages');
|
||||
this._bookInfo.next({ id: null, title: '', authors: '', coverUrl: null });
|
||||
this._pages.next([]);
|
||||
this._currentPage.next(1);
|
||||
this._bookmarks.next([]);
|
||||
this._notes.next([]);
|
||||
this._notesSearchQuery.next('');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,5 @@ export * from './dialogs/metadata-dialog.component';
|
||||
export * from './dialogs/note-dialog.component';
|
||||
|
||||
export * from './shared/icon.component';
|
||||
export * from './shared/selection-popup.component';
|
||||
export * from './shared/visibility.util';
|
||||
export * from './shared/header-footer.util';
|
||||
|
||||
Reference in New Issue
Block a user