Add “Fit Mode” and “View Mode” options to CBX reader (#1327)
This commit is contained in:
@@ -132,6 +132,9 @@ public class BookLoreUser {
|
||||
public static class CbxReaderSetting {
|
||||
private CbxPageSpread pageSpread;
|
||||
private CbxPageViewMode pageViewMode;
|
||||
private CbxPageFitMode fitMode;
|
||||
private CbxPageScrollMode scrollMode;
|
||||
private CbxBackgroundColor backgroundColor;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
+4
-2
@@ -1,7 +1,6 @@
|
||||
package com.adityachandel.booklore.model.dto;
|
||||
|
||||
import com.adityachandel.booklore.model.enums.CbxPageSpread;
|
||||
import com.adityachandel.booklore.model.enums.CbxPageViewMode;
|
||||
import com.adityachandel.booklore.model.enums.*;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -11,4 +10,7 @@ public class CbxViewerPreferences {
|
||||
private Long bookId;
|
||||
private CbxPageSpread pageSpread;
|
||||
private CbxPageViewMode pageViewMode;
|
||||
private CbxPageFitMode fitMode;
|
||||
private CbxPageScrollMode scrollMode;
|
||||
private CbxBackgroundColor backgroundColor;
|
||||
}
|
||||
+13
-2
@@ -1,7 +1,6 @@
|
||||
package com.adityachandel.booklore.model.entity;
|
||||
|
||||
import com.adityachandel.booklore.model.enums.CbxPageSpread;
|
||||
import com.adityachandel.booklore.model.enums.CbxPageViewMode;
|
||||
import com.adityachandel.booklore.model.enums.*;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
@@ -33,4 +32,16 @@ public class CbxViewerPreferencesEntity {
|
||||
@Column(name = "view_mode")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private CbxPageViewMode pageViewMode;
|
||||
|
||||
@Column(name = "fit_mode")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private CbxPageFitMode fitMode;
|
||||
|
||||
@Column(name = "scroll_mode")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private CbxPageScrollMode scrollMode;
|
||||
|
||||
@Column(name = "background_color")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private CbxBackgroundColor backgroundColor;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.adityachandel.booklore.model.enums;
|
||||
|
||||
public enum CbxBackgroundColor {
|
||||
GRAY,
|
||||
BLACK,
|
||||
WHITE
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.adityachandel.booklore.model.enums;
|
||||
|
||||
public enum CbxPageFitMode {
|
||||
ACTUAL_SIZE,
|
||||
FIT_PAGE,
|
||||
FIT_WIDTH,
|
||||
FIT_HEIGHT,
|
||||
AUTO
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package com.adityachandel.booklore.model.enums;
|
||||
|
||||
public enum CbxPageScrollMode {
|
||||
PAGINATED,
|
||||
INFINITE
|
||||
}
|
||||
@@ -219,6 +219,9 @@ public class BookService {
|
||||
.bookId(bookId)
|
||||
.pageViewMode(cbxPref.getPageViewMode())
|
||||
.pageSpread(cbxPref.getPageSpread())
|
||||
.fitMode(cbxPref.getFitMode())
|
||||
.scrollMode(cbxPref.getScrollMode())
|
||||
.backgroundColor(cbxPref.getBackgroundColor())
|
||||
.build()));
|
||||
} else {
|
||||
throw ApiError.UNSUPPORTED_BOOK_TYPE.createException();
|
||||
@@ -295,6 +298,9 @@ public class BookService {
|
||||
CbxViewerPreferences cbxSettings = bookViewerSettings.getCbxSettings();
|
||||
cbxPrefs.setPageSpread(cbxSettings.getPageSpread());
|
||||
cbxPrefs.setPageViewMode(cbxSettings.getPageViewMode());
|
||||
cbxPrefs.setFitMode(cbxSettings.getFitMode());
|
||||
cbxPrefs.setScrollMode(cbxSettings.getScrollMode());
|
||||
cbxPrefs.setBackgroundColor(cbxSettings.getBackgroundColor());
|
||||
cbxViewerPreferencesRepository.save(cbxPrefs);
|
||||
|
||||
} else {
|
||||
|
||||
+3
@@ -77,6 +77,9 @@ public class DefaultUserSettingsProvider {
|
||||
return BookLoreUser.UserSettings.CbxReaderSetting.builder()
|
||||
.pageViewMode(CbxPageViewMode.SINGLE_PAGE)
|
||||
.pageSpread(CbxPageSpread.ODD)
|
||||
.fitMode(CbxPageFitMode.FIT_HEIGHT)
|
||||
.scrollMode(CbxPageScrollMode.PAGINATED)
|
||||
.backgroundColor(CbxBackgroundColor.GRAY)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -164,13 +164,6 @@ public class UserService {
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
public List<BookLoreUser> getUsersWithLibraryAccess(Long libraryId) {
|
||||
return userRepository.findAllByLibraries_Id(libraryId)
|
||||
.stream()
|
||||
.map(bookLoreUserTransformer::toDTO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean meetsMinimumPasswordRequirements(String password) {
|
||||
return password != null && password.length() >= 6;
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE cbx_viewer_preference
|
||||
ADD COLUMN fit_mode VARCHAR(16) NULL,
|
||||
ADD COLUMN scroll_mode VARCHAR(16) NULL,
|
||||
ADD COLUMN background_color VARCHAR(16) NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
[max]="pages.length"
|
||||
placeholder="Page"
|
||||
class="page-input"
|
||||
/>
|
||||
/>
|
||||
<button
|
||||
class="go-button"
|
||||
(click)="goToPageInput !== null && goToPage(goToPageInput)"
|
||||
@@ -40,32 +40,128 @@
|
||||
</div>
|
||||
|
||||
<div class="spread-controls">
|
||||
@if (isTwoPageView) {
|
||||
<button class="view-button spread-toggle" (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
|
||||
<span>{{ pageSpread === 'ODD' ? '⬅️' : '➡️' }}</span>
|
||||
<div class="desktop-controls">
|
||||
<div class="fit-mode-dropdown">
|
||||
<button class="view-button fit-mode-toggle"
|
||||
(click)="toggleFitModeDropdown()"
|
||||
title="Fit Mode">
|
||||
<span>{{ displayLabel }}</span>
|
||||
</button>
|
||||
@if (showFitModeDropdown) {
|
||||
<div class="fit-mode-menu">
|
||||
@for (mode of fitModeOptions; track mode.value) {
|
||||
<button
|
||||
class="fit-mode-option"
|
||||
[class.active]="fitMode === mode.value"
|
||||
(click)="selectFitMode(mode.value)">
|
||||
<span class="fit-mode-icon">{{ mode.icon }}</span>
|
||||
<span class="fit-mode-label">{{ mode.label }}</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button class="view-button scroll-toggle" (click)="toggleScrollMode()" title="Toggle Scroll Mode">
|
||||
<span>{{ scrollModeIcon }}</span>
|
||||
</button>
|
||||
}
|
||||
<button class="view-button layout-toggle" (click)="toggleView()" title="Toggle View">
|
||||
<span>{{ isTwoPageView ? '📄' : '📖' }}</span>
|
||||
</button>
|
||||
<button class="view-button background-toggle" (click)="toggleBackground()" title="Toggle Background Color">
|
||||
<span>{{ backgroundColorIcon }}</span>
|
||||
</button>
|
||||
@if (isTwoPageView && scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<button class="view-button spread-toggle" (click)="toggleSpreadDirection()" title="Toggle Spread Direction">
|
||||
<span>{{ pageSpread === CbxPageSpread.ODD ? '⬅️' : '➡️' }}</span>
|
||||
</button>
|
||||
}
|
||||
@if (scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<button class="view-button layout-toggle" (click)="toggleView()" title="Toggle View">
|
||||
<span>{{ isTwoPageView ? '📄' : '📖' }}</span>
|
||||
</button>
|
||||
}
|
||||
<button class="view-button background-toggle" (click)="toggleBackground()" title="Toggle Background Color">
|
||||
<span>{{ backgroundColorIcon }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mobile-controls">
|
||||
<button class="view-button more-options-toggle"
|
||||
(click)="toggleMobileOptionsDropdown()"
|
||||
title="More Options">
|
||||
<span>⋮</span>
|
||||
</button>
|
||||
@if (showMobileOptionsDropdown) {
|
||||
<div class="mobile-options-menu">
|
||||
<button class="mobile-option" (click)="selectMobileOption('fitMode')">
|
||||
<span class="option-icon">{{ displayLabel }}</span>
|
||||
<span class="option-label">Fit Mode</span>
|
||||
</button>
|
||||
@if (showFitModeSubmenu) {
|
||||
<div class="submenu">
|
||||
@for (mode of fitModeOptions; track mode.value) {
|
||||
<button
|
||||
class="submenu-option"
|
||||
[class.active]="fitMode === mode.value"
|
||||
(click)="selectFitModeFromMobile(mode.value)">
|
||||
<span class="fit-mode-icon">{{ mode.icon }}</span>
|
||||
<span class="fit-mode-label">{{ mode.label }}</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<button class="mobile-option" (click)="toggleScrollModeFromMobile()">
|
||||
<span class="option-icon">{{ scrollModeIcon }}</span>
|
||||
<span class="option-label">Scroll Mode</span>
|
||||
</button>
|
||||
@if (isTwoPageView && scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<button class="mobile-option" (click)="toggleSpreadDirectionFromMobile()">
|
||||
<span class="option-icon">{{ pageSpread === CbxPageSpread.ODD ? '⬅️' : '➡️' }}</span>
|
||||
<span class="option-label">Spread Direction</span>
|
||||
</button>
|
||||
}
|
||||
@if (scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<button class="mobile-option" (click)="toggleViewFromMobile()">
|
||||
<span class="option-icon">{{ isTwoPageView ? '📄' : '📖' }}</span>
|
||||
<span class="option-label">Layout</span>
|
||||
</button>
|
||||
}
|
||||
<button class="mobile-option" (click)="toggleBackgroundFromMobile()">
|
||||
<span class="option-icon">{{ backgroundColorIcon }}</span>
|
||||
<span class="option-label">Background</span>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="image-container"
|
||||
[class.two-page-view]="isTwoPageView"
|
||||
[class.bg-black]="backgroundColor === 'black'"
|
||||
[class.bg-gray]="backgroundColor === 'gray'"
|
||||
[class.bg-white]="backgroundColor === 'white'">
|
||||
[class.two-page-view]="isTwoPageView && scrollMode === CbxScrollMode.PAGINATED"
|
||||
[class.infinite-scroll]="scrollMode === CbxScrollMode.INFINITE"
|
||||
[class.fit-actual-size]="fitMode === CbxFitMode.ACTUAL_SIZE"
|
||||
[class.fit-page]="fitMode === CbxFitMode.FIT_PAGE"
|
||||
[class.fit-width]="fitMode === CbxFitMode.FIT_WIDTH"
|
||||
[class.fit-height]="fitMode === CbxFitMode.FIT_HEIGHT"
|
||||
[class.fit-auto]="fitMode === CbxFitMode.AUTO"
|
||||
[class.bg-black]="backgroundColor === CbxBackgroundColor.BLACK"
|
||||
[class.bg-gray]="backgroundColor === CbxBackgroundColor.GRAY"
|
||||
[class.bg-white]="backgroundColor === CbxBackgroundColor.WHITE"
|
||||
(scroll)="onScroll($event)">
|
||||
@if (!isLoading) {
|
||||
@if (pages.length > 0) {
|
||||
<div class="pages-wrapper">
|
||||
@for (url of imageUrls; track url) {
|
||||
<img [src]="url" alt="Page Image" class="page-image"/>
|
||||
}
|
||||
</div>
|
||||
@if (scrollMode === CbxScrollMode.PAGINATED) {
|
||||
<div class="pages-wrapper">
|
||||
@for (url of imageUrls; track url) {
|
||||
<img [src]="url" alt="Page Image" class="page-image"/>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="infinite-scroll-wrapper">
|
||||
@for (url of infiniteScrollImageUrls; track url; let i = $index) {
|
||||
<img [src]="url" alt="Page {{ infiniteScrollPages[i] + 1 }}" class="page-image"/>
|
||||
}
|
||||
@if (isLoadingMore) {
|
||||
<div class="loading-more">
|
||||
<p-progressSpinner class="small-spinner"></p-progressSpinner>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="no-pages">
|
||||
<p>No pages available.</p>
|
||||
@@ -73,7 +169,7 @@
|
||||
}
|
||||
} @else {
|
||||
<div class="loading-container">
|
||||
<p-progressSpinner styleClass="custom-spinner"></p-progressSpinner>
|
||||
<p-progressSpinner class="custom-spinner"></p-progressSpinner>
|
||||
<p class="loading-text">Processing pages... This may take a few seconds on first load. Future loads will be significantly faster.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -26,9 +26,11 @@
|
||||
min-width: 0;
|
||||
|
||||
.goto-page-controls {
|
||||
flex: 0 0 auto;
|
||||
flex: 1;
|
||||
order: 1;
|
||||
min-width: fit-content;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
@@ -86,7 +88,7 @@
|
||||
}
|
||||
|
||||
.page-controls {
|
||||
flex: 1;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -152,11 +154,130 @@
|
||||
}
|
||||
|
||||
.spread-controls {
|
||||
flex: 0 0 auto;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
order: 3;
|
||||
min-width: fit-content;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
|
||||
.mobile-controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.desktop-controls {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.desktop-controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile-controls {
|
||||
display: block;
|
||||
position: relative;
|
||||
|
||||
.more-options-toggle {
|
||||
width: 32px;
|
||||
height: 28px;
|
||||
|
||||
span {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.mobile-options-menu {
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
right: 0;
|
||||
background: #2d2d2d;
|
||||
border: 1px solid #555;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
|
||||
z-index: 1001;
|
||||
min-width: 180px;
|
||||
overflow: hidden;
|
||||
|
||||
.mobile-option {
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-size: 13px;
|
||||
border-bottom: 1px solid #404040;
|
||||
|
||||
.option-icon {
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #3a3a3a;
|
||||
}
|
||||
}
|
||||
|
||||
.submenu {
|
||||
background: #252525;
|
||||
border-top: 1px solid #404040;
|
||||
|
||||
.submenu-option {
|
||||
width: 100%;
|
||||
padding: 8px 12px 8px 36px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
|
||||
.fit-mode-icon {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.fit-mode-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #3a3a3a;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #4a90e2;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.view-button {
|
||||
width: 28px;
|
||||
@@ -180,6 +301,68 @@
|
||||
border-color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.fit-mode-dropdown {
|
||||
position: relative;
|
||||
|
||||
.fit-mode-toggle {
|
||||
width: auto;
|
||||
min-width: 28px;
|
||||
padding: 0 6px;
|
||||
|
||||
span {
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.fit-mode-menu {
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
right: 0;
|
||||
background: #2d2d2d;
|
||||
border: 1px solid #555;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
|
||||
z-index: 1001;
|
||||
min-width: 160px;
|
||||
overflow: hidden;
|
||||
|
||||
.fit-mode-option {
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
|
||||
.fit-mode-icon {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.fit-mode-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #3a3a3a;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #4a90e2;
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +375,7 @@
|
||||
padding: 0.5rem;
|
||||
background: #0f0f0f;
|
||||
min-height: 0;
|
||||
position: relative;
|
||||
|
||||
&.bg-black {
|
||||
background: #000000;
|
||||
@@ -205,39 +389,234 @@
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.pages-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
&:not(.infinite-scroll) {
|
||||
.pages-wrapper {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
max-width: calc(50% - 0.5rem);
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
border-radius: 4px;
|
||||
transition: transform 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-width {
|
||||
.pages-wrapper {
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.pages-wrapper {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-height {
|
||||
.pages-wrapper {
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: 100%;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: 100%;
|
||||
max-width: calc(50% - 0.5rem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-actual-size {
|
||||
overflow: auto;
|
||||
|
||||
.pages-wrapper {
|
||||
width: max-content;
|
||||
height: max-content;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-page {
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
max-width: calc(50% - 0.5rem);
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-auto {
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
&.two-page-view {
|
||||
.page-image {
|
||||
max-width: calc(50% - 0.5rem);
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.two-page-view) {
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
&.infinite-scroll {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
align-items: flex-start;
|
||||
|
||||
.infinite-scroll-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
.page-image {
|
||||
height: auto;
|
||||
width: auto;
|
||||
object-fit: contain;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
border-radius: 4px;
|
||||
transition: transform 0.2s ease;
|
||||
.page-image {
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
||||
border-radius: 4px;
|
||||
transition: none;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
&:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-width .page-image {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
&.fit-height {
|
||||
.infinite-scroll-wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: calc(100vh - 60px - 2rem);
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-actual-size {
|
||||
overflow-x: auto;
|
||||
|
||||
.infinite-scroll-wrapper {
|
||||
align-items: center;
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-page {
|
||||
.infinite-scroll-wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: calc(100vh - 60px - 2rem);
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.fit-auto {
|
||||
.infinite-scroll-wrapper {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.page-image {
|
||||
max-width: 100%;
|
||||
max-height: calc(100vh - 60px - 2rem);
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-more {
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,4 +643,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep .small-spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,19 @@ import {Component, HostListener, inject, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {CbxReaderService} from '../../service/cbx-reader.service';
|
||||
import {BookService} from '../../service/book.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {
|
||||
CbxFitMode,
|
||||
CbxPageSpread,
|
||||
CbxPageViewMode,
|
||||
CbxScrollMode,
|
||||
PdfPageSpread,
|
||||
PdfPageViewMode,
|
||||
UserService,
|
||||
CbxBackgroundColor
|
||||
} from '../../../settings/user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {forkJoin} from 'rxjs';
|
||||
import {BookSetting, BookType, CbxPageSpread, CbxPageViewMode, PdfPageSpread, PdfPageViewMode} from '../../model/book.model';
|
||||
import {BookSetting, BookType} from '../../model/book.model';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {NewPdfReaderService} from '../../service/new-pdf-reader.service';
|
||||
@@ -18,7 +27,6 @@ import {NewPdfReaderService} from '../../service/new-pdf-reader.service';
|
||||
styleUrl: './cbx-reader.component.scss'
|
||||
})
|
||||
export class CbxReaderComponent implements OnInit {
|
||||
|
||||
bookType!: BookType;
|
||||
|
||||
goToPageInput: number | null = null;
|
||||
@@ -29,8 +37,8 @@ export class CbxReaderComponent implements OnInit {
|
||||
|
||||
pageSpread: CbxPageSpread | PdfPageSpread = CbxPageSpread.ODD;
|
||||
pageViewMode: CbxPageViewMode | PdfPageViewMode = CbxPageViewMode.SINGLE_PAGE;
|
||||
|
||||
backgroundColor: 'black' | 'gray' | 'white' = 'gray';
|
||||
backgroundColor: CbxBackgroundColor = CbxBackgroundColor.GRAY;
|
||||
fitMode: CbxFitMode = CbxFitMode.FIT_PAGE;
|
||||
|
||||
private touchStartX = 0;
|
||||
private touchEndX = 0;
|
||||
@@ -42,6 +50,35 @@ export class CbxReaderComponent implements OnInit {
|
||||
private userService = inject(UserService);
|
||||
private messageService = inject(MessageService);
|
||||
|
||||
|
||||
showFitModeDropdown: boolean = false;
|
||||
showMobileOptionsDropdown: boolean = false;
|
||||
showFitModeSubmenu: boolean = false;
|
||||
|
||||
fitModeOptions = [
|
||||
{value: CbxFitMode.FIT_PAGE, label: 'Fit Page', icon: '⬜'},
|
||||
{value: CbxFitMode.FIT_WIDTH, label: 'Fit Width', icon: '↔️'},
|
||||
{value: CbxFitMode.FIT_HEIGHT, label: 'Fit Height', icon: '↕️'},
|
||||
{value: CbxFitMode.ACTUAL_SIZE, label: 'Actual Size', icon: '1:1'},
|
||||
{value: CbxFitMode.AUTO, label: 'Automatic', icon: '🔄'}
|
||||
];
|
||||
|
||||
scrollMode: CbxScrollMode = CbxScrollMode.PAGINATED;
|
||||
|
||||
infiniteScrollPages: number[] = [];
|
||||
preloadCount: number = 3;
|
||||
isLoadingMore: boolean = false;
|
||||
|
||||
protected readonly CbxScrollMode = CbxScrollMode;
|
||||
protected readonly CbxFitMode = CbxFitMode;
|
||||
protected readonly CbxBackgroundColor = CbxBackgroundColor;
|
||||
protected readonly CbxPageViewMode = CbxPageViewMode;
|
||||
protected readonly CbxPageSpread = CbxPageSpread;
|
||||
|
||||
private static readonly TYPE_PDF = 'PDF';
|
||||
private static readonly TYPE_CBX = 'CBX';
|
||||
private static readonly SETTING_GLOBAL = 'Global';
|
||||
|
||||
ngOnInit() {
|
||||
this.route.paramMap.subscribe((params) => {
|
||||
this.isLoading = true;
|
||||
@@ -56,36 +93,51 @@ export class CbxReaderComponent implements OnInit {
|
||||
const userSettings = myself.userSettings;
|
||||
this.bookType = book.bookType;
|
||||
|
||||
const pagesObservable = this.bookType === 'PDF'
|
||||
const pagesObservable = this.bookType === CbxReaderComponent.TYPE_PDF
|
||||
? this.pdfReaderService.getAvailablePages(this.bookId)
|
||||
: this.cbxReaderService.getAvailablePages(this.bookId);
|
||||
|
||||
pagesObservable.subscribe({
|
||||
next: (pages) => {
|
||||
|
||||
this.pages = pages;
|
||||
if (this.bookType === 'CBX') {
|
||||
const global = userSettings.perBookSetting.cbx === 'Global';
|
||||
if (this.bookType === CbxReaderComponent.TYPE_CBX) {
|
||||
const global = userSettings.perBookSetting.cbx === CbxReaderComponent.SETTING_GLOBAL;
|
||||
this.pageViewMode = global
|
||||
? userSettings.cbxReaderSetting.pageViewMode || CbxPageViewMode.SINGLE_PAGE
|
||||
: bookSettings.cbxSettings?.pageViewMode || userSettings.cbxReaderSetting.pageViewMode || CbxPageViewMode.SINGLE_PAGE;
|
||||
? this.CbxPageViewMode[userSettings.cbxReaderSetting.pageViewMode as keyof typeof CbxPageViewMode] || this.CbxPageViewMode.SINGLE_PAGE
|
||||
: this.CbxPageViewMode[bookSettings.cbxSettings?.pageViewMode as keyof typeof CbxPageViewMode] || this.CbxPageViewMode[userSettings.cbxReaderSetting.pageViewMode as keyof typeof CbxPageViewMode] || this.CbxPageViewMode.SINGLE_PAGE;
|
||||
|
||||
this.pageSpread = global
|
||||
? userSettings.cbxReaderSetting.pageSpread || CbxPageSpread.ODD
|
||||
: bookSettings.cbxSettings?.pageSpread || userSettings.cbxReaderSetting.pageSpread || CbxPageSpread.ODD;
|
||||
? this.CbxPageSpread[userSettings.cbxReaderSetting.pageSpread as keyof typeof CbxPageSpread] || this.CbxPageSpread.ODD
|
||||
: this.CbxPageSpread[bookSettings.cbxSettings?.pageSpread as keyof typeof CbxPageSpread] || this.CbxPageSpread[userSettings.cbxReaderSetting.pageSpread as keyof typeof CbxPageSpread] || this.CbxPageSpread.ODD;
|
||||
|
||||
this.fitMode = global
|
||||
? this.CbxFitMode[userSettings.cbxReaderSetting.fitMode as keyof typeof CbxFitMode] || this.CbxFitMode.FIT_PAGE
|
||||
: this.CbxFitMode[bookSettings.cbxSettings?.fitMode as keyof typeof CbxFitMode] || this.CbxFitMode[userSettings.cbxReaderSetting.fitMode as keyof typeof CbxFitMode] || this.CbxFitMode.FIT_PAGE;
|
||||
|
||||
this.scrollMode = global
|
||||
? this.CbxScrollMode[userSettings.cbxReaderSetting.scrollMode as keyof typeof CbxScrollMode] || CbxScrollMode.PAGINATED
|
||||
: this.CbxScrollMode[bookSettings.cbxSettings?.scrollMode as keyof typeof CbxScrollMode] || this.CbxScrollMode[userSettings.cbxReaderSetting.scrollMode as keyof typeof CbxScrollMode] || CbxScrollMode.PAGINATED;
|
||||
|
||||
this.backgroundColor = global
|
||||
? this.CbxBackgroundColor[userSettings.cbxReaderSetting.backgroundColor as keyof typeof CbxBackgroundColor] || CbxBackgroundColor.GRAY
|
||||
: this.CbxBackgroundColor[bookSettings.cbxSettings?.backgroundColor as keyof typeof CbxBackgroundColor] || this.CbxBackgroundColor[userSettings.cbxReaderSetting.backgroundColor as keyof typeof CbxBackgroundColor] || CbxBackgroundColor.GRAY;
|
||||
|
||||
this.currentPage = (book.cbxProgress?.page || 1) - 1;
|
||||
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
this.initializeInfiniteScroll();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bookType === 'PDF') {
|
||||
const global = userSettings.perBookSetting.pdf === 'Global';
|
||||
if (this.bookType === CbxReaderComponent.TYPE_PDF) {
|
||||
const global = userSettings.perBookSetting.pdf === CbxReaderComponent.SETTING_GLOBAL;
|
||||
this.pageViewMode = global
|
||||
? userSettings.newPdfReaderSetting.pageViewMode || PdfPageViewMode.SINGLE_PAGE
|
||||
: bookSettings.newPdfSettings?.pageViewMode || userSettings.newPdfReaderSetting.pageViewMode || PdfPageViewMode.SINGLE_PAGE;
|
||||
? PdfPageViewMode[userSettings.newPdfReaderSetting.pageViewMode as keyof typeof PdfPageViewMode] || PdfPageViewMode.SINGLE_PAGE
|
||||
: PdfPageViewMode[bookSettings.newPdfSettings?.pageViewMode as keyof typeof PdfPageViewMode] || PdfPageViewMode[userSettings.newPdfReaderSetting.pageViewMode as keyof typeof PdfPageViewMode] || PdfPageViewMode.SINGLE_PAGE;
|
||||
|
||||
this.pageSpread = global
|
||||
? userSettings.newPdfReaderSetting.pageSpread || PdfPageSpread.ODD
|
||||
: bookSettings.newPdfSettings?.pageSpread || userSettings.newPdfReaderSetting.pageSpread || PdfPageSpread.ODD;
|
||||
? 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.currentPage = (book.pdfProgress?.page || 1) - 1;
|
||||
}
|
||||
@@ -109,52 +161,81 @@ export class CbxReaderComponent implements OnInit {
|
||||
}
|
||||
|
||||
get isTwoPageView(): boolean {
|
||||
return this.pageViewMode === CbxPageViewMode.TWO_PAGE || this.pageViewMode === PdfPageViewMode.TWO_PAGE;
|
||||
return this.pageViewMode === this.CbxPageViewMode.TWO_PAGE || this.pageViewMode === PdfPageViewMode.TWO_PAGE;
|
||||
}
|
||||
|
||||
get backgroundColorIcon(): string {
|
||||
switch (this.backgroundColor) {
|
||||
case 'black': return '⚫';
|
||||
case 'gray': return '🔘';
|
||||
case 'white': return '⚪';
|
||||
default: return '🔘';
|
||||
case CbxBackgroundColor.BLACK:
|
||||
return '⚫';
|
||||
case CbxBackgroundColor.GRAY:
|
||||
return '🔘';
|
||||
case CbxBackgroundColor.WHITE:
|
||||
return '⚪';
|
||||
default:
|
||||
return '🔘';
|
||||
}
|
||||
}
|
||||
|
||||
toggleBackground(): void {
|
||||
switch (this.backgroundColor) {
|
||||
case 'black':
|
||||
this.backgroundColor = 'gray';
|
||||
case CbxBackgroundColor.BLACK:
|
||||
this.backgroundColor = CbxBackgroundColor.GRAY;
|
||||
break;
|
||||
case 'gray':
|
||||
this.backgroundColor = 'white';
|
||||
case CbxBackgroundColor.GRAY:
|
||||
this.backgroundColor = CbxBackgroundColor.WHITE;
|
||||
break;
|
||||
case 'white':
|
||||
this.backgroundColor = 'black';
|
||||
case CbxBackgroundColor.WHITE:
|
||||
this.backgroundColor = CbxBackgroundColor.BLACK;
|
||||
break;
|
||||
}
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
toggleView() {
|
||||
if (!this.isTwoPageView && this.isPhonePortrait()) return;
|
||||
this.pageViewMode = this.isTwoPageView ? (this.bookType === "CBX" ? CbxPageViewMode.SINGLE_PAGE : PdfPageViewMode.SINGLE_PAGE) : (this.bookType === "CBX" ? CbxPageViewMode.TWO_PAGE : PdfPageViewMode.TWO_PAGE);
|
||||
this.pageViewMode = this.isTwoPageView
|
||||
? (this.bookType === CbxReaderComponent.TYPE_CBX ? this.CbxPageViewMode.SINGLE_PAGE : PdfPageViewMode.SINGLE_PAGE)
|
||||
: (this.bookType === CbxReaderComponent.TYPE_CBX ? this.CbxPageViewMode.TWO_PAGE : PdfPageViewMode.TWO_PAGE);
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
toggleSpreadDirection() {
|
||||
if (this.pageSpread === CbxPageSpread.ODD || this.pageSpread === PdfPageSpread.ODD) {
|
||||
this.pageSpread = this.bookType === "CBX" ? CbxPageSpread.EVEN : PdfPageSpread.EVEN;
|
||||
if (this.pageSpread === this.CbxPageSpread.ODD || this.pageSpread === PdfPageSpread.ODD) {
|
||||
this.pageSpread = this.bookType === CbxReaderComponent.TYPE_CBX ? this.CbxPageSpread.EVEN : PdfPageSpread.EVEN;
|
||||
} else {
|
||||
this.pageSpread = this.bookType === "CBX" ? CbxPageSpread.ODD : PdfPageSpread.ODD;
|
||||
this.pageSpread = this.bookType === CbxReaderComponent.TYPE_CBX ? this.CbxPageSpread.ODD : PdfPageSpread.ODD;
|
||||
}
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
toggleScrollMode(): void {
|
||||
this.scrollMode = this.scrollMode === CbxScrollMode.PAGINATED
|
||||
? CbxScrollMode.INFINITE
|
||||
: CbxScrollMode.PAGINATED;
|
||||
|
||||
this.updateViewerSetting();
|
||||
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
this.initializeInfiniteScroll();
|
||||
setTimeout(() => this.scrollToPage(this.currentPage), 100);
|
||||
}
|
||||
}
|
||||
|
||||
nextPage() {
|
||||
const previousPage = this.currentPage;
|
||||
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
if (this.currentPage < this.pages.length - 1) {
|
||||
this.currentPage++;
|
||||
this.scrollToPage(this.currentPage);
|
||||
this.updateProgress();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isTwoPageView) {
|
||||
if (this.currentPage + 2 < this.pages.length) {
|
||||
this.currentPage += 2;
|
||||
@@ -171,6 +252,15 @@ export class CbxReaderComponent implements OnInit {
|
||||
}
|
||||
|
||||
previousPage() {
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
if (this.currentPage > 0) {
|
||||
this.currentPage--;
|
||||
this.scrollToPage(this.currentPage);
|
||||
this.updateProgress();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isTwoPageView) {
|
||||
this.currentPage = Math.max(0, this.currentPage - 2);
|
||||
} else {
|
||||
@@ -199,6 +289,226 @@ export class CbxReaderComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
toggleFitModeDropdown(): void {
|
||||
this.showFitModeDropdown = !this.showFitModeDropdown;
|
||||
}
|
||||
|
||||
selectFitMode(mode: CbxFitMode): void {
|
||||
this.fitMode = mode;
|
||||
this.showFitModeDropdown = false;
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
toggleMobileOptionsDropdown(): void {
|
||||
this.showMobileOptionsDropdown = !this.showMobileOptionsDropdown;
|
||||
this.showFitModeSubmenu = false;
|
||||
}
|
||||
|
||||
selectMobileOption(option: string): void {
|
||||
if (option === 'fitMode') {
|
||||
this.showFitModeSubmenu = !this.showFitModeSubmenu;
|
||||
}
|
||||
}
|
||||
|
||||
selectFitModeFromMobile(mode: CbxFitMode): void {
|
||||
this.fitMode = mode;
|
||||
this.showFitModeSubmenu = false;
|
||||
this.showMobileOptionsDropdown = false;
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
|
||||
toggleScrollModeFromMobile(): void {
|
||||
this.toggleScrollMode();
|
||||
this.showMobileOptionsDropdown = false;
|
||||
}
|
||||
|
||||
toggleSpreadDirectionFromMobile(): void {
|
||||
this.toggleSpreadDirection();
|
||||
this.showMobileOptionsDropdown = false;
|
||||
}
|
||||
|
||||
toggleViewFromMobile(): void {
|
||||
this.toggleView();
|
||||
this.showMobileOptionsDropdown = false;
|
||||
}
|
||||
|
||||
toggleBackgroundFromMobile(): void {
|
||||
this.toggleBackground();
|
||||
this.showMobileOptionsDropdown = false;
|
||||
}
|
||||
|
||||
get displayLabel(): string {
|
||||
const option = this.fitModeOptions.find(opt => opt.value === this.fitMode);
|
||||
return option ? option.icon : '↔️';
|
||||
}
|
||||
|
||||
get scrollModeIcon(): string {
|
||||
return this.scrollMode === CbxScrollMode.PAGINATED ? '📄' : '📜';
|
||||
}
|
||||
|
||||
private initializeInfiniteScroll(): void {
|
||||
this.infiniteScrollPages = [];
|
||||
const endIndex = Math.min(this.currentPage + this.preloadCount, this.pages.length);
|
||||
for (let i = this.currentPage; i < endIndex; i++) {
|
||||
this.infiniteScrollPages.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
onScroll(event: Event): void {
|
||||
if (this.scrollMode !== CbxScrollMode.INFINITE || this.isLoadingMore) return;
|
||||
|
||||
const container = event.target as HTMLElement;
|
||||
const scrollPosition = container.scrollTop + container.clientHeight;
|
||||
const scrollHeight = container.scrollHeight;
|
||||
|
||||
if (scrollPosition >= scrollHeight * 0.8) {
|
||||
this.loadMorePages();
|
||||
}
|
||||
|
||||
this.updateCurrentPageFromScroll(container);
|
||||
}
|
||||
|
||||
private loadMorePages(): void {
|
||||
if (this.isLoadingMore) return;
|
||||
|
||||
const lastLoadedIndex = this.infiniteScrollPages[this.infiniteScrollPages.length - 1];
|
||||
if (lastLoadedIndex >= this.pages.length - 1) return;
|
||||
|
||||
this.isLoadingMore = true;
|
||||
const endIndex = Math.min(lastLoadedIndex + this.preloadCount + 1, this.pages.length);
|
||||
|
||||
setTimeout(() => {
|
||||
for (let i = lastLoadedIndex + 1; i < endIndex; i++) {
|
||||
this.infiniteScrollPages.push(i);
|
||||
}
|
||||
this.isLoadingMore = false;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
private updateCurrentPageFromScroll(container: HTMLElement): void {
|
||||
const images = container.querySelectorAll('.page-image');
|
||||
const containerRect = container.getBoundingClientRect();
|
||||
|
||||
for (let i = 0; i < images.length; i++) {
|
||||
const img = images[i] as HTMLElement;
|
||||
const rect = img.getBoundingClientRect();
|
||||
|
||||
if (rect.top <= containerRect.top + containerRect.height / 2 &&
|
||||
rect.bottom >= containerRect.top + containerRect.height / 2) {
|
||||
const newPage = this.infiniteScrollPages[i];
|
||||
if (newPage !== this.currentPage) {
|
||||
this.currentPage = newPage;
|
||||
this.updateProgress();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getPageImageUrl(pageIndex: number): string {
|
||||
return this.bookType === CbxReaderComponent.TYPE_PDF
|
||||
? this.pdfReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex])
|
||||
: 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));
|
||||
}
|
||||
|
||||
private updateViewerSetting(): void {
|
||||
const bookSetting: BookSetting = this.bookType === CbxReaderComponent.TYPE_CBX
|
||||
? {
|
||||
cbxSettings: {
|
||||
pageSpread: this.pageSpread as CbxPageSpread,
|
||||
pageViewMode: this.pageViewMode as CbxPageViewMode,
|
||||
fitMode: this.fitMode as CbxFitMode,
|
||||
scrollMode: this.scrollMode as CbxScrollMode,
|
||||
backgroundColor: this.backgroundColor as CbxBackgroundColor,
|
||||
}
|
||||
}
|
||||
: {
|
||||
newPdfSettings: {
|
||||
pageSpread: this.pageSpread as PdfPageSpread,
|
||||
pageViewMode: this.pageViewMode as PdfPageViewMode,
|
||||
}
|
||||
};
|
||||
this.bookService.updateViewerSetting(bookSetting, this.bookId).subscribe();
|
||||
}
|
||||
|
||||
updateProgress(): void {
|
||||
const percentage = this.pages.length > 0
|
||||
? Math.round(((this.currentPage + 1) / this.pages.length) * 1000) / 10
|
||||
: 0;
|
||||
|
||||
if (this.bookType === CbxReaderComponent.TYPE_CBX) {
|
||||
this.bookService.saveCbxProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
|
||||
}
|
||||
if (this.bookType === CbxReaderComponent.TYPE_PDF) {
|
||||
this.bookService.savePdfProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
goToPage(page: number): void {
|
||||
if (page < 1 || page > this.pages.length) return;
|
||||
|
||||
const targetIndex = page - 1;
|
||||
if (targetIndex === this.currentPage) return;
|
||||
|
||||
this.currentPage = targetIndex;
|
||||
|
||||
if (this.scrollMode === CbxScrollMode.INFINITE) {
|
||||
this.ensurePageLoaded(targetIndex);
|
||||
this.scrollToPage(targetIndex);
|
||||
this.updateProgress();
|
||||
} else {
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateProgress();
|
||||
}
|
||||
}
|
||||
|
||||
private scrollToPage(pageIndex: number): void {
|
||||
this.ensurePageLoaded(pageIndex);
|
||||
|
||||
setTimeout(() => {
|
||||
const container = document.querySelector('.image-container.infinite-scroll') as HTMLElement;
|
||||
if (!container) return;
|
||||
|
||||
const images = container.querySelectorAll('.page-image');
|
||||
const indexInScroll = this.infiniteScrollPages.indexOf(pageIndex);
|
||||
|
||||
if (indexInScroll >= 0 && indexInScroll < images.length) {
|
||||
const targetImage = images[indexInScroll] as HTMLElement;
|
||||
targetImage.scrollIntoView({behavior: 'smooth', block: 'start'});
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
private ensurePageLoaded(pageIndex: number): void {
|
||||
if (this.infiniteScrollPages.includes(pageIndex)) return;
|
||||
|
||||
this.infiniteScrollPages = [];
|
||||
const startIndex = Math.max(0, pageIndex - 1);
|
||||
const endIndex = Math.min(pageIndex + this.preloadCount, this.pages.length);
|
||||
|
||||
for (let i = startIndex; i < endIndex; i++) {
|
||||
this.infiniteScrollPages.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('window:keydown', ['$event'])
|
||||
handleKeyDown(event: KeyboardEvent) {
|
||||
if (event.key === 'ArrowRight') this.nextPage();
|
||||
@@ -228,7 +538,7 @@ export class CbxReaderComponent implements OnInit {
|
||||
|
||||
private enforcePortraitSinglePageView() {
|
||||
if (this.isPhonePortrait() && this.isTwoPageView) {
|
||||
this.pageViewMode = this.bookType === "CBX" ? CbxPageViewMode.SINGLE_PAGE : PdfPageViewMode.SINGLE_PAGE;
|
||||
this.pageViewMode = this.bookType === CbxReaderComponent.TYPE_CBX ? CbxPageViewMode.SINGLE_PAGE : PdfPageViewMode.SINGLE_PAGE;
|
||||
this.updateViewerSetting();
|
||||
}
|
||||
}
|
||||
@@ -237,64 +547,15 @@ export class CbxReaderComponent implements OnInit {
|
||||
return window.innerWidth < 768 && window.innerHeight > window.innerWidth;
|
||||
}
|
||||
|
||||
private getPageImageUrl(pageIndex: number): string {
|
||||
return this.bookType === 'PDF'
|
||||
? this.pdfReaderService.getPageImageUrl(this.bookId, this.pages[pageIndex])
|
||||
: 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));
|
||||
@HostListener('document:click', ['$event'])
|
||||
onDocumentClick(event: MouseEvent): void {
|
||||
const target = event.target as HTMLElement;
|
||||
if (!target.closest('.fit-mode-dropdown')) {
|
||||
this.showFitModeDropdown = false;
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
private updateViewerSetting(): void {
|
||||
const bookSetting: BookSetting = this.bookType === "CBX"
|
||||
? {
|
||||
cbxSettings: {
|
||||
pageSpread: this.pageSpread as CbxPageSpread,
|
||||
pageViewMode: this.pageViewMode as CbxPageViewMode,
|
||||
}
|
||||
}
|
||||
: {
|
||||
newPdfSettings: {
|
||||
pageSpread: this.pageSpread as PdfPageSpread,
|
||||
pageViewMode: this.pageViewMode as PdfPageViewMode,
|
||||
}
|
||||
};
|
||||
this.bookService.updateViewerSetting(bookSetting, this.bookId).subscribe();
|
||||
}
|
||||
|
||||
updateProgress(): void {
|
||||
const percentage = this.pages.length > 0
|
||||
? Math.round(((this.currentPage + 1) / this.pages.length) * 1000) / 10
|
||||
: 0;
|
||||
|
||||
if (this.bookType === 'CBX') {
|
||||
this.bookService.saveCbxProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
|
||||
if (!target.closest('.mobile-controls')) {
|
||||
this.showMobileOptionsDropdown = false;
|
||||
this.showFitModeSubmenu = false;
|
||||
}
|
||||
if (this.bookType === 'PDF') {
|
||||
this.bookService.savePdfProgress(this.bookId, this.currentPage + 1, percentage).subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
goToPage(page: number): void {
|
||||
if (page < 1 || page > this.pages.length) return;
|
||||
|
||||
const targetIndex = page - 1;
|
||||
if (targetIndex === this.currentPage) return;
|
||||
|
||||
this.currentPage = targetIndex;
|
||||
this.alignCurrentPageToParity();
|
||||
this.updateProgress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Shelf} from './shelf.model';
|
||||
import {NewPdfReaderSetting} from '../../settings/user-management/user.service';
|
||||
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, NewPdfReaderSetting} from '../../settings/user-management/user.service';
|
||||
import {BookReview} from '../../book-review-service';
|
||||
|
||||
export type BookType = "PDF" | "EPUB" | "CBX";
|
||||
@@ -193,6 +193,9 @@ export interface EpubViewerSetting {
|
||||
export interface CbxViewerSetting {
|
||||
pageSpread: CbxPageSpread;
|
||||
pageViewMode: CbxPageViewMode;
|
||||
fitMode: CbxFitMode;
|
||||
scrollMode?: CbxScrollMode;
|
||||
backgroundColor?: CbxBackgroundColor;
|
||||
}
|
||||
|
||||
export interface BookSetting {
|
||||
@@ -209,26 +212,6 @@ export interface BookRecommendation {
|
||||
similarityScore: number;
|
||||
}
|
||||
|
||||
export const enum CbxPageViewMode {
|
||||
SINGLE_PAGE = 'SINGLE_PAGE',
|
||||
TWO_PAGE = 'TWO_PAGE',
|
||||
}
|
||||
|
||||
export const enum CbxPageSpread {
|
||||
EVEN = 'EVEN',
|
||||
ODD = 'ODD',
|
||||
}
|
||||
|
||||
export const enum PdfPageViewMode {
|
||||
SINGLE_PAGE = 'SINGLE_PAGE',
|
||||
TWO_PAGE = 'TWO_PAGE',
|
||||
}
|
||||
|
||||
export const enum PdfPageSpread {
|
||||
EVEN = 'EVEN',
|
||||
ODD = 'ODD',
|
||||
}
|
||||
|
||||
export interface BulkMetadataUpdateRequest {
|
||||
bookIds: number[];
|
||||
authors?: string[];
|
||||
|
||||
+17
-4
@@ -68,18 +68,31 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private setupUserStateSubscription() {
|
||||
let prevHasKoboTokenPermission = false;
|
||||
let prevIsAdmin = false;
|
||||
this.userService.userState$.pipe(
|
||||
filter(userState => !!userState?.user && userState.loaded),
|
||||
takeUntil(this.destroy$)
|
||||
).subscribe(userState => {
|
||||
this.hasKoboTokenPermission = (userState.user?.permissions.canSyncKobo) ?? false;
|
||||
this.isAdmin = userState.user?.permissions.admin ?? false;
|
||||
if (this.hasKoboTokenPermission) {
|
||||
const currHasKoboTokenPermission = (userState.user?.permissions.canSyncKobo) ?? false;
|
||||
const currIsAdmin = userState.user?.permissions.admin ?? false;
|
||||
|
||||
if (currHasKoboTokenPermission && !prevHasKoboTokenPermission) {
|
||||
this.hasKoboTokenPermission = true;
|
||||
this.loadKoboUserSettings();
|
||||
} else {
|
||||
this.hasKoboTokenPermission = currHasKoboTokenPermission;
|
||||
}
|
||||
if (this.isAdmin) {
|
||||
|
||||
if (currIsAdmin && !prevIsAdmin) {
|
||||
this.isAdmin = true;
|
||||
this.loadKoboAdminSettings();
|
||||
} else {
|
||||
this.isAdmin = currIsAdmin;
|
||||
}
|
||||
|
||||
prevHasKoboTokenPermission = currHasKoboTokenPermission;
|
||||
prevIsAdmin = currIsAdmin;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -45,14 +45,17 @@ export class KoreaderSettingsComponent implements OnInit, OnDestroy {
|
||||
hasPermission = false;
|
||||
|
||||
ngOnInit() {
|
||||
let prevHasPermission = false;
|
||||
this.userService.userState$.pipe(
|
||||
filter(userState => !!userState?.user && userState.loaded),
|
||||
takeUntil(this.destroy$)
|
||||
).subscribe(userState => {
|
||||
this.hasPermission = (userState.user?.permissions.canSyncKoReader || userState.user?.permissions.admin) ?? false;
|
||||
if (this.hasPermission) {
|
||||
const currHasPermission = (userState.user?.permissions.canSyncKoReader || userState.user?.permissions.admin) ?? false;
|
||||
this.hasPermission = currHasPermission;
|
||||
if (currHasPermission && !prevHasPermission) {
|
||||
this.loadKoreaderSettings();
|
||||
}
|
||||
prevHasPermission = currHasPermission;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -64,13 +64,18 @@ export class OpdsSettingsV2 implements OnInit, OnDestroy {
|
||||
ngOnInit(): void {
|
||||
this.loading = true;
|
||||
|
||||
let prevHasPermission = false;
|
||||
this.userService.userState$.pipe(
|
||||
filter(state => !!state?.user && state.loaded),
|
||||
takeUntil(this.destroy$),
|
||||
tap(state => {
|
||||
this.hasPermission = !!(state.user?.permissions.canAccessOpds || state.user?.permissions.admin);
|
||||
}),
|
||||
filter(() => this.hasPermission),
|
||||
filter(() => {
|
||||
const shouldRun = this.hasPermission && !prevHasPermission;
|
||||
prevHasPermission = this.hasPermission;
|
||||
return shouldRun;
|
||||
}),
|
||||
tap(() => this.loadAppSettings())
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
+72
@@ -48,5 +48,77 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Fit Mode</label>
|
||||
<div class="radio-group">
|
||||
@for (mode of cbxFitModes; track mode) {
|
||||
<div class="radio-option">
|
||||
<p-radiobutton
|
||||
[inputId]="mode.key"
|
||||
name="fitMode"
|
||||
[value]="mode.key"
|
||||
[(ngModel)]="selectedCbxFitMode">
|
||||
</p-radiobutton>
|
||||
<label [for]="mode.key">{{ mode.name }}</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Select how images should be scaled to fit the reader window.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Scroll Mode</label>
|
||||
<div class="radio-group">
|
||||
@for (mode of cbxScrollModes; track mode) {
|
||||
<div class="radio-option">
|
||||
<p-radiobutton
|
||||
[inputId]="mode.key"
|
||||
name="scrollMode"
|
||||
[value]="mode.key"
|
||||
[(ngModel)]="selectedCbxScrollMode">
|
||||
</p-radiobutton>
|
||||
<label [for]="mode.key">{{ mode.name }}</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Choose between paginated or infinite scroll reading experience.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Background Color</label>
|
||||
<div class="radio-group">
|
||||
@for (color of cbxBackgroundColors; track color) {
|
||||
<div class="radio-option">
|
||||
<p-radiobutton
|
||||
[inputId]="color.key"
|
||||
name="backgroundColor"
|
||||
[value]="color.key"
|
||||
[(ngModel)]="selectedCbxBackgroundColor">
|
||||
</p-radiobutton>
|
||||
<label [for]="color.key">{{ color.name }}</label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Set the background color for the comic reader.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+62
-10
@@ -1,8 +1,7 @@
|
||||
import {Component, inject, Input} from '@angular/core';
|
||||
import {RadioButton} from 'primeng/radiobutton';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {CbxPageSpread, CbxPageViewMode} from '../../../book/model/book.model';
|
||||
import {UserSettings} from '../../user-management/user.service';
|
||||
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, UserSettings} from '../../user-management/user.service';
|
||||
import {ReaderPreferencesService} from '../reader-preferences-service';
|
||||
|
||||
@Component({
|
||||
@@ -20,31 +19,84 @@ export class CbxReaderPreferencesComponent {
|
||||
|
||||
private readonly readerPreferencesService = inject(ReaderPreferencesService);
|
||||
|
||||
private static readonly SETTING_ROOT = 'cbxReaderSetting';
|
||||
private static readonly PROP_PAGE_SPREAD = 'pageSpread';
|
||||
private static readonly PROP_PAGE_VIEW_MODE = 'pageViewMode';
|
||||
private static readonly PROP_FIT_MODE = 'fitMode';
|
||||
private static readonly PROP_SCROLL_MODE = 'scrollMode';
|
||||
private static readonly PROP_BACKGROUND_COLOR = 'backgroundColor';
|
||||
|
||||
readonly cbxSpreads = [
|
||||
{name: 'Even', key: 'EVEN'},
|
||||
{name: 'Odd', key: 'ODD'}
|
||||
{name: 'Even', key: CbxPageSpread.EVEN},
|
||||
{name: 'Odd', key: CbxPageSpread.ODD}
|
||||
];
|
||||
|
||||
readonly cbxViewModes = [
|
||||
{name: 'Single Page', key: 'SINGLE_PAGE'},
|
||||
{name: 'Two Page', key: 'TWO_PAGE'},
|
||||
{name: 'Single Page', key: CbxPageViewMode.SINGLE_PAGE},
|
||||
{name: 'Two Page', key: CbxPageViewMode.TWO_PAGE},
|
||||
];
|
||||
|
||||
readonly cbxFitModes = [
|
||||
{name: 'Fit Page', key: CbxFitMode.FIT_PAGE},
|
||||
{name: 'Fit Width', key: CbxFitMode.FIT_WIDTH},
|
||||
{name: 'Fit Height', key: CbxFitMode.FIT_HEIGHT},
|
||||
{name: 'Actual Size', key: CbxFitMode.ACTUAL_SIZE},
|
||||
{name: 'Automatic', key: CbxFitMode.AUTO}
|
||||
];
|
||||
|
||||
readonly cbxScrollModes = [
|
||||
{name: 'Paginated', key: CbxScrollMode.PAGINATED},
|
||||
{name: 'Infinite', key: CbxScrollMode.INFINITE}
|
||||
];
|
||||
|
||||
readonly cbxBackgroundColors = [
|
||||
{name: 'Gray', key: CbxBackgroundColor.GRAY},
|
||||
{name: 'Black', key: CbxBackgroundColor.BLACK},
|
||||
{name: 'White', key: CbxBackgroundColor.WHITE}
|
||||
];
|
||||
|
||||
get selectedCbxSpread(): CbxPageSpread {
|
||||
return this.userSettings.cbxReaderSetting.pageSpread;
|
||||
return this.userSettings.cbxReaderSetting.pageSpread ?? CbxPageSpread.EVEN;
|
||||
}
|
||||
|
||||
set selectedCbxSpread(value: CbxPageSpread) {
|
||||
this.userSettings.cbxReaderSetting.pageSpread = value;
|
||||
this.readerPreferencesService.updatePreference(['cbxReaderSetting', 'pageSpread'], value);
|
||||
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_PAGE_SPREAD], value);
|
||||
}
|
||||
|
||||
get selectedCbxViewMode(): CbxPageViewMode {
|
||||
return this.userSettings.cbxReaderSetting.pageViewMode;
|
||||
return this.userSettings.cbxReaderSetting.pageViewMode ?? CbxPageViewMode.SINGLE_PAGE;
|
||||
}
|
||||
|
||||
set selectedCbxViewMode(value: CbxPageViewMode) {
|
||||
this.userSettings.cbxReaderSetting.pageViewMode = value;
|
||||
this.readerPreferencesService.updatePreference(['cbxReaderSetting', 'pageViewMode'], value);
|
||||
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_PAGE_VIEW_MODE], value);
|
||||
}
|
||||
|
||||
get selectedCbxFitMode(): CbxFitMode {
|
||||
return this.userSettings.cbxReaderSetting.fitMode ?? CbxFitMode.FIT_PAGE;
|
||||
}
|
||||
|
||||
set selectedCbxFitMode(value: CbxFitMode) {
|
||||
this.userSettings.cbxReaderSetting.fitMode = value;
|
||||
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_FIT_MODE], value);
|
||||
}
|
||||
|
||||
get selectedCbxScrollMode(): CbxScrollMode {
|
||||
return this.userSettings.cbxReaderSetting.scrollMode ?? CbxScrollMode.PAGINATED;
|
||||
}
|
||||
|
||||
set selectedCbxScrollMode(value: CbxScrollMode) {
|
||||
this.userSettings.cbxReaderSetting.scrollMode = value;
|
||||
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_SCROLL_MODE], value);
|
||||
}
|
||||
|
||||
get selectedCbxBackgroundColor(): CbxBackgroundColor {
|
||||
return this.userSettings.cbxReaderSetting.backgroundColor ?? CbxBackgroundColor.GRAY;
|
||||
}
|
||||
|
||||
set selectedCbxBackgroundColor(value: CbxBackgroundColor) {
|
||||
this.userSettings.cbxReaderSetting.backgroundColor = value;
|
||||
this.readerPreferencesService.updatePreference([CbxReaderPreferencesComponent.SETTING_ROOT, CbxReaderPreferencesComponent.PROP_BACKGROUND_COLOR], value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import {BehaviorSubject, Observable, throwError} from 'rxjs';
|
||||
import {API_CONFIG} from '../../config/api-config';
|
||||
import {Library} from '../../book/model/library.model';
|
||||
import {catchError, distinctUntilChanged, finalize, shareReplay, tap} from 'rxjs/operators';
|
||||
import {CbxPageSpread, CbxPageViewMode, PdfPageSpread, PdfPageViewMode} from '../../book/model/book.model';
|
||||
import {AuthService} from '../../core/service/auth.service';
|
||||
|
||||
export interface EntityViewPreferences {
|
||||
@@ -44,12 +43,51 @@ export interface PerBookSetting {
|
||||
|
||||
export type PageSpread = 'off' | 'even' | 'odd';
|
||||
|
||||
export enum CbxBackgroundColor {
|
||||
GRAY = 'GRAY',
|
||||
BLACK = 'BLACK',
|
||||
WHITE = 'WHITE'
|
||||
}
|
||||
|
||||
export interface PdfReaderSetting {
|
||||
pageSpread: PageSpread;
|
||||
pageZoom: string;
|
||||
showSidebar: boolean;
|
||||
}
|
||||
|
||||
export enum CbxPageViewMode {
|
||||
SINGLE_PAGE = 'SINGLE_PAGE',
|
||||
TWO_PAGE = 'TWO_PAGE',
|
||||
}
|
||||
|
||||
export enum CbxPageSpread {
|
||||
EVEN = 'EVEN',
|
||||
ODD = 'ODD',
|
||||
}
|
||||
|
||||
export enum PdfPageViewMode {
|
||||
SINGLE_PAGE = 'SINGLE_PAGE',
|
||||
TWO_PAGE = 'TWO_PAGE',
|
||||
}
|
||||
|
||||
export enum PdfPageSpread {
|
||||
EVEN = 'EVEN',
|
||||
ODD = 'ODD',
|
||||
}
|
||||
|
||||
export enum CbxFitMode {
|
||||
ACTUAL_SIZE = 'ACTUAL_SIZE',
|
||||
FIT_PAGE = 'FIT_PAGE',
|
||||
FIT_WIDTH = 'FIT_WIDTH',
|
||||
FIT_HEIGHT = 'FIT_HEIGHT',
|
||||
AUTO = 'AUTO'
|
||||
}
|
||||
|
||||
export enum CbxScrollMode {
|
||||
PAGINATED = 'PAGINATED',
|
||||
INFINITE = 'INFINITE'
|
||||
}
|
||||
|
||||
export interface EpubReaderSetting {
|
||||
theme: string;
|
||||
font: string;
|
||||
@@ -64,6 +102,9 @@ export interface EpubReaderSetting {
|
||||
export interface CbxReaderSetting {
|
||||
pageSpread: CbxPageSpread;
|
||||
pageViewMode: CbxPageViewMode;
|
||||
fitMode: CbxFitMode;
|
||||
scrollMode?: CbxScrollMode;
|
||||
backgroundColor?: CbxBackgroundColor;
|
||||
}
|
||||
|
||||
export interface NewPdfReaderSetting {
|
||||
|
||||
Reference in New Issue
Block a user