diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java
index 0992099e2..e06623613 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookLoreUser.java
@@ -47,6 +47,7 @@ public class BookLoreUser {
private String theme;
private String font;
private int fontSize;
+ private String flow;
}
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/EpubViewerPreferences.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/EpubViewerPreferences.java
index fca4ab55b..1c8382f86 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/EpubViewerPreferences.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/EpubViewerPreferences.java
@@ -9,5 +9,6 @@ public class EpubViewerPreferences {
private Long bookId;
private String theme;
private String font;
+ private String flow;
private Integer fontSize;
}
\ No newline at end of file
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/EpubViewerPreferencesEntity.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/EpubViewerPreferencesEntity.java
index 3e44b7005..b961dfa3e 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/EpubViewerPreferencesEntity.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/EpubViewerPreferencesEntity.java
@@ -32,4 +32,7 @@ public class EpubViewerPreferencesEntity {
@Column(name = "font_size")
private Integer fontSize;
+
+ @Column(name = "flow")
+ private String flow;
}
\ No newline at end of file
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/BooksService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/BooksService.java
index c857a737e..83ad2fca7 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/service/BooksService.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/BooksService.java
@@ -58,6 +58,7 @@ public class BooksService {
.font(epubPref.getFont())
.fontSize(epubPref.getFontSize())
.theme(epubPref.getTheme())
+ .flow(epubPref.getFlow())
.build()));
} else if (bookEntity.getBookType() == BookFileType.PDF) {
pdfViewerPreferencesRepository.findByBookIdAndUserId(bookId, user.getId())
@@ -107,6 +108,7 @@ public class BooksService {
epubPrefs.setFont(epubSettings.getFont());
epubPrefs.setFontSize(epubSettings.getFontSize());
epubPrefs.setTheme(epubSettings.getTheme());
+ epubPrefs.setFlow(epubSettings.getFlow());
epubViewerPreferencesRepository.save(epubPrefs);
} else {
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/user/UserProvisioningService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/user/UserProvisioningService.java
index 003cf7574..fecf8d588 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/service/user/UserProvisioningService.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/user/UserProvisioningService.java
@@ -218,6 +218,7 @@ public class UserProvisioningService {
.theme("white")
.font("serif")
.fontSize(150)
+ .flow("paginated")
.build();
}
diff --git a/booklore-api/src/main/resources/db/migration/V17__Add_flow_column_to_epub_viewer_preference.sql b/booklore-api/src/main/resources/db/migration/V17__Add_flow_column_to_epub_viewer_preference.sql
new file mode 100644
index 000000000..76016aaea
--- /dev/null
+++ b/booklore-api/src/main/resources/db/migration/V17__Add_flow_column_to_epub_viewer_preference.sql
@@ -0,0 +1,2 @@
+ALTER TABLE epub_viewer_preference
+ ADD COLUMN flow VARCHAR(32) NULL;
\ No newline at end of file
diff --git a/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.html b/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.html
index 98784d06c..13484cdbc 100644
--- a/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.html
+++ b/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.html
@@ -33,6 +33,9 @@
+
+
+
@@ -42,7 +45,7 @@
-
-
+
+
diff --git a/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.ts b/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.ts
index 51ea86b88..89b434bc1 100644
--- a/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.ts
+++ b/booklore-ui/src/app/book/components/epub-viewer/component/epub-viewer.component.ts
@@ -18,6 +18,7 @@ const FALLBACK_EPUB_SETTINGS = {
fontSize: 150,
fontType: 'serif',
theme: 'white',
+ flow: 'paginated',
maxFontSize: 300,
minFontSize: 50,
};
@@ -60,16 +61,15 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
currentChapter = '';
isDrawerVisible = false;
isSettingsDrawerVisible = false;
- isMobile = false;
+
private book: any;
private rendition: any;
private keyListener: (e: KeyboardEvent) => void = () => {
};
fontSize = FALLBACK_EPUB_SETTINGS.fontSize;
- selectedFontType = FALLBACK_EPUB_SETTINGS.fontType;
- selectedTheme = FALLBACK_EPUB_SETTINGS.theme;
+ selectedFontType = FALLBACK_EPUB_SETTINGS.fontType;
fontTypes: any[] = [
{label: 'Serif', value: 'serif'},
{label: 'Sans Serif', value: 'sans-serif'},
@@ -78,6 +78,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
{label: 'Monospace', value: 'monospace'},
];
+ selectedTheme = FALLBACK_EPUB_SETTINGS.theme;
themes: any[] = [
{label: 'White', value: 'white'},
{label: 'Black', value: 'black'},
@@ -85,6 +86,12 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
{label: 'Sepia', value: 'sepia'},
];
+ selectedFlow = FALLBACK_EPUB_SETTINGS.flow;
+ flows: any[] = [
+ {label: 'Scrolled', value: 'scrolled'},
+ {label: 'Paginated', value: 'paginated'}
+ ];
+
private route = inject(ActivatedRoute);
private userService = inject(UserService);
private bookService = inject(BookService);
@@ -115,8 +122,6 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
fileReader.onload = () => {
this.book = ePub(fileReader.result as ArrayBuffer);
- this.isMobile = window.innerWidth <= 768;
-
this.book.loaded.navigation.then((nav: any) => {
this.chapters = nav.toc.map((chapter: any) => ({
label: chapter.label,
@@ -124,9 +129,15 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
}));
});
+ let globalOrIndividual = myself.userSettings.perBookSetting.epub;
+
+ const flow = globalOrIndividual === 'Global'
+ ? myself.userSettings.epubReaderSetting.flow || 'paginated'
+ : individualSetting?.flow || myself.userSettings.epubReaderSetting.flow || 'paginated';
+
this.rendition = this.book.renderTo(this.epubContainer.nativeElement, {
- flow: this.isMobile ? 'scrolled' : 'paginated',
- manager: this.isMobile ? 'continuous' : 'default',
+ flow,
+ manager: flow === 'scrolled' ? 'continuous' : 'default',
width: '100%',
height: '100%',
allowScriptedContent: true,
@@ -142,15 +153,16 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
this.rendition.themes.register(name, theme);
});
- let globalOrIndividual = myself.userSettings.perBookSetting.epub;
if (globalOrIndividual === 'Global') {
this.selectedTheme = myself.userSettings.epubReaderSetting.theme || FALLBACK_EPUB_SETTINGS.theme;
this.selectedFontType = myself.userSettings.epubReaderSetting.font || FALLBACK_EPUB_SETTINGS.fontType;
this.fontSize = myself.userSettings.epubReaderSetting.fontSize || FALLBACK_EPUB_SETTINGS.fontSize;
+ this.selectedFlow = myself.userSettings.epubReaderSetting.flow || FALLBACK_EPUB_SETTINGS.flow;
} else {
this.selectedTheme = individualSetting?.theme || myself.userSettings.epubReaderSetting.theme || FALLBACK_EPUB_SETTINGS.theme;
this.selectedFontType = individualSetting?.font || myself.userSettings.epubReaderSetting.font || FALLBACK_EPUB_SETTINGS.fontType;
this.fontSize = individualSetting?.fontSize || myself.userSettings.epubReaderSetting.fontSize || FALLBACK_EPUB_SETTINGS.fontSize;
+ this.selectedFlow = individualSetting?.flow || myself.userSettings.epubReaderSetting.flow || FALLBACK_EPUB_SETTINGS.flow;
}
this.rendition.themes.select(this.selectedTheme);
@@ -172,6 +184,31 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
});
}
+ changeScrollMode(): void {
+ if (!this.rendition || !this.book) return;
+
+ const cfi = this.rendition.currentLocation()?.start?.cfi;
+ this.rendition.destroy();
+
+ this.rendition = this.book.renderTo(this.epubContainer.nativeElement, {
+ flow: this.selectedFlow,
+ manager: this.selectedFlow === 'scrolled' ? 'continuous' : 'default',
+ width: '100%',
+ height: '100%',
+ allowScriptedContent: true,
+ });
+
+ this.themesMap.forEach((theme, name) => this.rendition.themes.register(name, theme));
+ this.rendition.themes.select(this.selectedTheme);
+ this.rendition.themes.font(this.selectedFontType);
+ this.rendition.themes.fontSize(`${this.fontSize}%`);
+
+ this.setupKeyListener();
+ this.trackProgress();
+ this.rendition.display(cfi || undefined);
+ this.updateViewerSetting();
+ }
+
changeThemes(): void {
if (this.rendition) {
this.rendition.themes.select(this.selectedTheme);
@@ -211,6 +248,7 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
theme: this.selectedTheme,
font: this.selectedFontType,
fontSize: this.fontSize,
+ flow: this.selectedFlow
}
}
this.bookService.updateViewerSetting(bookSetting, this.epub.id).subscribe();
@@ -333,5 +371,4 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
}
]
]);
-
}
diff --git a/booklore-ui/src/app/book/model/book.model.ts b/booklore-ui/src/app/book/model/book.model.ts
index 80c4e7202..9a7e14e93 100644
--- a/booklore-ui/src/app/book/model/book.model.ts
+++ b/booklore-ui/src/app/book/model/book.model.ts
@@ -89,6 +89,7 @@ export interface EpubViewerSetting {
theme: string;
font: string;
fontSize: number;
+ flow: string;
}
export interface BookSetting {
diff --git a/booklore-ui/src/app/settings/user-management/user.service.ts b/booklore-ui/src/app/settings/user-management/user.service.ts
index 0882e8ee7..689ce06be 100644
--- a/booklore-ui/src/app/settings/user-management/user.service.ts
+++ b/booklore-ui/src/app/settings/user-management/user.service.ts
@@ -33,6 +33,7 @@ export interface EpubReaderSetting {
theme: string;
font: string;
fontSize: number;
+ flow: string;
}
export interface UserSettings {
diff --git a/booklore-ui/src/app/settings/user-preferences/user-preferences.component.html b/booklore-ui/src/app/settings/user-preferences/user-preferences.component.html
index 01b9ffe83..f9704a735 100644
--- a/booklore-ui/src/app/settings/user-preferences/user-preferences.component.html
+++ b/booklore-ui/src/app/settings/user-preferences/user-preferences.component.html
@@ -120,6 +120,19 @@
+ Flow:
+
+
Font Size:
diff --git a/booklore-ui/src/app/settings/user-preferences/user-preferences.component.ts b/booklore-ui/src/app/settings/user-preferences/user-preferences.component.ts
index 85b5b8d05..b9d331209 100644
--- a/booklore-ui/src/app/settings/user-preferences/user-preferences.component.ts
+++ b/booklore-ui/src/app/settings/user-preferences/user-preferences.component.ts
@@ -47,6 +47,11 @@ export class UserPreferences implements OnInit, OnDestroy {
{name: 'Monospace', key: 'monospace'}
];
+ flowOptions = [
+ {name: 'Paginated', key: 'paginated'},
+ {name: 'Scrolled', key: 'scrolled'}
+ ];
+
readonly sortingOptions = [
{label: 'Name | Ascending', value: {field: 'name', order: 'asc'}},
{label: 'Name | Descending', value: {field: 'name', order: 'desc'}},
@@ -59,6 +64,7 @@ export class UserPreferences implements OnInit, OnDestroy {
selectedZoom!: string;
selectedTheme!: string;
selectedFont!: string;
+ selectedFlow!: string;
fontSize = 100;
showSidebar = false;
selectedPdfScope!: string;
@@ -93,6 +99,7 @@ export class UserPreferences implements OnInit, OnDestroy {
this.selectedZoom = settings.pdfReaderSetting.pageZoom;
this.showSidebar = settings.pdfReaderSetting.showSidebar;
this.selectedTheme = settings.epubReaderSetting.theme;
+ this.selectedFlow = settings.epubReaderSetting.flow;
this.fontSize = settings.epubReaderSetting.fontSize;
this.selectedFont = settings.epubReaderSetting.font;
this.selectedLibrarySorting = settings.sidebarLibrarySorting;
@@ -126,6 +133,10 @@ export class UserPreferences implements OnInit, OnDestroy {
this.updatePreference(['epubReaderSetting', 'font'], this.selectedFont);
}
+ onFlowChange() {
+ this.updatePreference(['epubReaderSetting', 'flow'], this.selectedFlow);
+ }
+
onFontSizeChange() {
this.updatePreference(['epubReaderSetting', 'fontSize'], this.fontSize);
}
@@ -167,5 +178,4 @@ export class UserPreferences implements OnInit, OnDestroy {
this.onFontSizeChange();
}
}
-
}