feat(reader): add PDF annotations, Range streaming, and optimized chunk loading (#2701)
This commit is contained in:
+5
-24
@@ -145,26 +145,7 @@
|
||||
<span class="file-size">{{ getFileSizeInMB(book.primaryFile) }}</span>
|
||||
</div>
|
||||
<div class="file-actions">
|
||||
@if (book.primaryFile.bookType === 'PDF') {
|
||||
<p-button
|
||||
icon="pi pi-book"
|
||||
size="small"
|
||||
text
|
||||
severity="primary"
|
||||
[pTooltip]="t('readTooltip')"
|
||||
tooltipPosition="top"
|
||||
(onClick)="read(book.id)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-play"
|
||||
size="small"
|
||||
text
|
||||
severity="info"
|
||||
[pTooltip]="t('streamingReaderTooltip')"
|
||||
tooltipPosition="top"
|
||||
(onClick)="read(book.id, 'pdf-streaming')">
|
||||
</p-button>
|
||||
} @else if (book.primaryFile.bookType === 'EPUB') {
|
||||
@if (book.primaryFile.bookType === 'EPUB') {
|
||||
<p-button
|
||||
icon="pi pi-book"
|
||||
size="small"
|
||||
@@ -183,7 +164,7 @@
|
||||
tooltipPosition="top"
|
||||
(onClick)="read(book.id, 'epub-streaming')">
|
||||
</p-button>
|
||||
} @else if (book.primaryFile.bookType && ['FB2', 'MOBI', 'AZW3', 'CBX'].includes(book.primaryFile.bookType)) {
|
||||
} @else if (book.primaryFile.bookType && ['PDF', 'FB2', 'MOBI', 'AZW3', 'CBX'].includes(book.primaryFile.bookType)) {
|
||||
<p-button
|
||||
icon="pi pi-book"
|
||||
size="small"
|
||||
@@ -241,7 +222,7 @@
|
||||
<span class="file-size">{{ getFileSizeInMB(format) }}</span>
|
||||
</div>
|
||||
<div class="file-actions">
|
||||
@if (format.bookType === 'PDF' || format.bookType === 'EPUB') {
|
||||
@if (format.bookType === 'EPUB') {
|
||||
<p-button
|
||||
icon="pi pi-book"
|
||||
size="small"
|
||||
@@ -258,9 +239,9 @@
|
||||
severity="info"
|
||||
[pTooltip]="t('streamingReaderTooltip')"
|
||||
tooltipPosition="top"
|
||||
(onClick)="read(book.id, format.bookType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', format.bookType)">
|
||||
(onClick)="read(book.id, 'epub-streaming', format.bookType)">
|
||||
</p-button>
|
||||
} @else if (format.bookType && ['FB2', 'MOBI', 'AZW3', 'CBX'].includes(format.bookType)) {
|
||||
} @else if (format.bookType && ['PDF', 'FB2', 'MOBI', 'AZW3', 'CBX'].includes(format.bookType)) {
|
||||
<p-button
|
||||
icon="pi pi-book"
|
||||
size="small"
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import {TranslocoDirective} from '@jsverse/transloco';
|
||||
|
||||
export interface ReadEvent {
|
||||
bookId: number;
|
||||
reader?: 'pdf-streaming' | 'epub-streaming';
|
||||
reader?: 'epub-streaming';
|
||||
bookType?: BookType;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export class MetadataTabsComponent {
|
||||
return this.bookInSeries && this.bookInSeries.length > 1 ? 'series' : 'similar';
|
||||
}
|
||||
|
||||
read(bookId: number, reader?: 'pdf-streaming' | 'epub-streaming', bookType?: BookType): void {
|
||||
read(bookId: number, reader?: 'epub-streaming', bookType?: BookType): void {
|
||||
this.readBook.emit({ bookId, reader, bookType });
|
||||
}
|
||||
|
||||
|
||||
+5
-11
@@ -105,13 +105,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
map((book): MenuItem[] => {
|
||||
const items: MenuItem[] = [];
|
||||
const primaryType = book.primaryFile?.bookType;
|
||||
if (primaryType === 'PDF') {
|
||||
items.push({
|
||||
label: this.t.translate('metadata.viewer.menuStreamingReader'),
|
||||
icon: 'pi pi-play',
|
||||
command: () => this.read(book.id, 'pdf-streaming')
|
||||
});
|
||||
} else if (primaryType === 'EPUB') {
|
||||
if (primaryType === 'EPUB') {
|
||||
items.push({
|
||||
label: this.t.translate('metadata.viewer.menuStreamingReader'),
|
||||
icon: 'pi pi-play',
|
||||
@@ -133,8 +127,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
uniqueAltTypes.forEach(formatType => {
|
||||
if (formatType === 'PDF' || formatType === 'EPUB') {
|
||||
// For PDF/EPUB, offer both standard and streaming readers
|
||||
if (formatType === 'EPUB') {
|
||||
// For EPUB, offer both standard and streaming readers
|
||||
items.push({
|
||||
label: formatType,
|
||||
icon: this.getFileIcon(formatType),
|
||||
@@ -147,7 +141,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
{
|
||||
label: this.t.translate('metadata.viewer.menuStreamingReader'),
|
||||
icon: 'pi pi-play',
|
||||
command: () => this.read(book.id, formatType === 'PDF' ? 'pdf-streaming' : 'epub-streaming', formatType)
|
||||
command: () => this.read(book.id, 'epub-streaming', formatType)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -474,7 +468,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
this.isExpanded = !this.isExpanded;
|
||||
}
|
||||
|
||||
read(bookId: number | undefined, reader?: "pdf-streaming" | "epub-streaming", bookType?: BookType): void {
|
||||
read(bookId: number | undefined, reader?: "epub-streaming", bookType?: BookType): void {
|
||||
if (bookId) this.bookService.readBook(bookId, reader, bookType);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user