refactor(frontend): rename booklore-ui to frontend
- Frontend path: - rename the tracked Angular app tree from `booklore-ui/` to `frontend/` - preserve file contents during the move so this commit stays focused on the path change itself - Frontend docs: - update the moved frontend README and contribution guide where they refer to the renamed folder - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
+291
@@ -0,0 +1,291 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsReader.ebook'">
|
||||
<div class="epub-preferences-container">
|
||||
|
||||
<div class="settings-group">
|
||||
<h3 class="group-title">{{ t('appearance') }}</h3>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('theme') }}</label>
|
||||
<div class="theme-selector">
|
||||
@for (theme of themes; track theme) {
|
||||
<button
|
||||
type="button"
|
||||
class="theme-option"
|
||||
[class.selected]="selectedTheme === theme.name"
|
||||
(click)="selectedTheme = theme.name"
|
||||
[attr.aria-label]="theme.label"
|
||||
[pTooltip]="theme.label"
|
||||
tooltipPosition="bottom">
|
||||
<span class="theme-colors">
|
||||
<span class="theme-color" [style.background-color]="theme.light.bg"></span>
|
||||
<span class="theme-color" [style.background-color]="theme.dark.bg"></span>
|
||||
</span>
|
||||
@if (selectedTheme === theme.name) {
|
||||
<i class="pi pi-check"></i>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('themeDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('darkMode') }}</label>
|
||||
<div class="button-group">
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="!isDark"
|
||||
(click)="isDark = false">
|
||||
<i class="pi pi-sun"></i>
|
||||
<span class="option-text">{{ t('light') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="isDark"
|
||||
(click)="isDark = true">
|
||||
<i class="pi pi-moon"></i>
|
||||
<span class="option-text">{{ t('dark') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('darkModeDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<h3 class="group-title">{{ t('typography') }}</h3>
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('fontFamily') }}</label>
|
||||
<div class="button-group">
|
||||
@for (font of fonts; track font) {
|
||||
<button
|
||||
type="button"
|
||||
class="option-button font-button"
|
||||
[class.selected]="selectedFont === font.key"
|
||||
[class.separator]="font.key === 'separator'"
|
||||
[attr.data-font]="font.key"
|
||||
[disabled]="font.key === 'separator'"
|
||||
(click)="selectedFont = font.key"
|
||||
[pTooltip]="font.name"
|
||||
tooltipPosition="bottom">
|
||||
<span class="option-text" [style.font-family]="font.key && font.key.startsWith('custom:') ? getCustomFontName(font.key) : null">
|
||||
{{ font.displayName }}
|
||||
</span>
|
||||
</button>
|
||||
}
|
||||
|
||||
@if (!customFontsReady) {
|
||||
<p-skeleton width="3.5rem" height="2.5rem" borderRadius="6px"></p-skeleton>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('fontFamilyDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('fontSize') }}</label>
|
||||
<div class="font-size-controls">
|
||||
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseFontSize()"></p-button>
|
||||
<span class="font-size-value">{{ fontSize }}pt</span>
|
||||
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseFontSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('fontSizeDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('lineHeight') }}</label>
|
||||
<div class="font-size-controls">
|
||||
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseLineHeight()"></p-button>
|
||||
<span class="font-size-value">{{ lineHeight.toFixed(1) }}</span>
|
||||
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseLineHeight()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('lineHeightDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('textJustification') }}</label>
|
||||
<div class="button-group">
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="!justify"
|
||||
(click)="justify = false">
|
||||
<i class="pi pi-align-left"></i>
|
||||
<span class="option-text">{{ t('left') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="justify"
|
||||
(click)="justify = true">
|
||||
<i class="pi pi-align-justify"></i>
|
||||
<span class="option-text">{{ t('justified') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('textJustificationDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('hyphenation') }}</label>
|
||||
<div class="button-group">
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="!hyphenate"
|
||||
(click)="hyphenate = false">
|
||||
<i class="pi pi-times"></i>
|
||||
<span class="option-text">{{ t('off') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="hyphenate"
|
||||
(click)="hyphenate = true">
|
||||
<i class="pi pi-check"></i>
|
||||
<span class="option-text">{{ t('on') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('hyphenationDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<h3 class="group-title">{{ t('layout') }}</h3>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('flow') }}</label>
|
||||
<div class="button-group">
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="flow === 'paginated'"
|
||||
(click)="flow = 'paginated'">
|
||||
<i class="pi pi-clone"></i>
|
||||
<span class="option-text">{{ t('paginated') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="option-button"
|
||||
[class.selected]="flow === 'scrolled'"
|
||||
(click)="flow = 'scrolled'">
|
||||
<i class="pi pi-arrows-v"></i>
|
||||
<span class="option-text">{{ t('scrolled') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('flowDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('maxColumns') }}</label>
|
||||
<div class="font-size-controls">
|
||||
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount > 1 ? maxColumnCount - 1 : 1"></p-button>
|
||||
<span class="font-size-value">{{ maxColumnCount }}</span>
|
||||
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="maxColumnCount = maxColumnCount < 4 ? maxColumnCount + 1 : 4"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('maxColumnsDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('columnGap') }}</label>
|
||||
<div class="font-size-controls">
|
||||
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseGap()"></p-button>
|
||||
<span class="font-size-value">{{ gap * 100 | number : '1.0-0' }}%</span>
|
||||
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseGap()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('columnGapDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('maxWidth') }}</label>
|
||||
<div class="font-size-controls">
|
||||
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxInlineSize()"></p-button>
|
||||
<span class="font-size-value">{{ maxInlineSize }}px</span>
|
||||
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxInlineSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('maxWidthDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('maxHeight') }}</label>
|
||||
<div class="font-size-controls">
|
||||
<p-button icon="pi pi-minus" size="small" rounded outlined (click)="decreaseMaxBlockSize()"></p-button>
|
||||
<span class="font-size-value">{{ maxBlockSize }}px</span>
|
||||
<p-button icon="pi pi-plus" size="small" rounded outlined (click)="increaseMaxBlockSize()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('maxHeightDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
@use '../../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.epub-preferences-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1.5rem;
|
||||
border-radius: 0.75rem;
|
||||
border: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
|
||||
|
||||
.group-title {
|
||||
font-size: settings.$settings-section-title-size;
|
||||
font-weight: settings.$settings-section-title-weight;
|
||||
color: var(--p-text-color);
|
||||
margin: 0 0 0.5rem 0;
|
||||
padding-bottom: 0.75rem;
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--text-color) 10%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 2rem;
|
||||
padding: 0.25rem 0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.setting-label {
|
||||
display: block;
|
||||
font-weight: settings.$settings-section-title-weight;
|
||||
color: var(--p-text-color);
|
||||
font-size: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.setting-label-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.setting-label {
|
||||
margin-bottom: 0;
|
||||
flex-shrink: 0;
|
||||
min-width: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-description {
|
||||
color: var(--p-text-muted-color);
|
||||
font-size: settings.$settings-section-description-size;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-group {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
label {
|
||||
font-size: settings.$settings-section-description-size;
|
||||
color: var(--p-text-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.font-size-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
.font-size-value {
|
||||
min-width: 3rem;
|
||||
text-align: center;
|
||||
font-weight: settings.$settings-label-weight;
|
||||
color: var(--p-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.theme-selector {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.theme-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
background: color-mix(in srgb, var(--text-color) 5%, transparent);
|
||||
color: var(--text-color);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
min-width: 48px;
|
||||
|
||||
.theme-colors {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
padding: 0;
|
||||
border-radius: 0.5rem;
|
||||
overflow: hidden;
|
||||
border: 2px solid color-mix(in srgb, var(--text-color) 20%, transparent);
|
||||
box-sizing: border-box;
|
||||
width: 72px;
|
||||
height: 36px;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.theme-color {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: inline-block;
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
i {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--primary-color);
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.theme-colors {
|
||||
border-color: color-mix(in srgb, var(--primary-color) 40%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
&.selected {
|
||||
.theme-colors {
|
||||
border-color: var(--primary-color);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 15%, transparent);
|
||||
}
|
||||
color: var(--primary-color);
|
||||
background: color-mix(in srgb, var(--primary-color) 10%, transparent);
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.button-group {
|
||||
@include settings.settings-button-group;
|
||||
|
||||
.option-button {
|
||||
&.font-button {
|
||||
font-size: 1rem;
|
||||
|
||||
&[data-font="serif"] .option-text {
|
||||
font-family: Georgia, 'Times New Roman', serif;
|
||||
}
|
||||
|
||||
&[data-font="sans-serif"] .option-text {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
&[data-font="roboto"] .option-text {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
&[data-font="cursive"] .option-text {
|
||||
font-family: cursive;
|
||||
}
|
||||
|
||||
&[data-font="monospace"] .option-text {
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
|
||||
// Custom font buttons use the loaded font
|
||||
&[data-font^="custom:"] .option-text {
|
||||
font-size: settings.$settings-section-description-size;
|
||||
}
|
||||
}
|
||||
|
||||
&.separator {
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
opacity: 0.6;
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
font-weight: settings.$settings-section-title-weight;
|
||||
color: var(--p-text-muted-color);
|
||||
min-width: auto;
|
||||
padding: 0.25rem 0.5rem;
|
||||
|
||||
&:hover {
|
||||
transform: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
import {DecimalPipe} from '@angular/common';
|
||||
import {Component, effect, inject, Input, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TranslocoDirective} from '@jsverse/transloco';
|
||||
import {ReaderPreferencesService} from '../reader-preferences.service';
|
||||
import {UserSettings} from '../../user-management/user.service';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {CustomFontService} from '../../../../shared/service/custom-font.service';
|
||||
import {CustomFont} from '../../../../shared/model/custom-font.model';
|
||||
import {skip, Subject, takeUntil} from 'rxjs';
|
||||
import {addCustomFontsToDropdown} from '../../../../shared/util/custom-font.util';
|
||||
import {Skeleton} from 'primeng/skeleton';
|
||||
import {themes} from '../../../readers/ebook-reader/state/themes.constant';
|
||||
|
||||
@Component({
|
||||
selector: 'app-epub-reader-preferences-component',
|
||||
imports: [
|
||||
Button,
|
||||
DecimalPipe,
|
||||
FormsModule,
|
||||
TranslocoDirective,
|
||||
Tooltip,
|
||||
Skeleton
|
||||
],
|
||||
templateUrl: './epub-reader-preferences-component.html',
|
||||
styleUrl: './epub-reader-preferences-component.scss'
|
||||
})
|
||||
export class EpubReaderPreferencesComponent implements OnInit, OnDestroy {
|
||||
|
||||
@Input() userSettings!: UserSettings;
|
||||
|
||||
private readonly readerPreferencesService = inject(ReaderPreferencesService);
|
||||
private readonly customFontService = inject(CustomFontService);
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
customFonts: CustomFont[] = [];
|
||||
|
||||
fonts = [
|
||||
{name: 'Book Default', displayName: 'Default', key: null},
|
||||
{name: 'Serif', displayName: 'Serif', key: 'serif'},
|
||||
{name: 'Sans Serif', displayName: 'Sans Serif', key: 'sans-serif'},
|
||||
{name: 'Roboto', displayName: 'Roboto', key: 'roboto'},
|
||||
{name: 'Cursive', displayName: 'Cursive', key: 'cursive'},
|
||||
{name: 'Monospace', displayName: 'Monospace', key: 'monospace'}
|
||||
];
|
||||
|
||||
readonly themes = themes;
|
||||
|
||||
customFontsReady = false;
|
||||
|
||||
private readonly syncFontsEffect = effect(() => {
|
||||
const fonts = this.customFontService.fonts();
|
||||
if (fonts.length > 0 || !this.customFontService.isFontsLoading()) {
|
||||
this.customFontsReady = true;
|
||||
}
|
||||
if (this.hasCustomFontsChanged(fonts)) {
|
||||
this.onFontsChanged(fonts);
|
||||
}
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
private async onFontsChanged(fonts: CustomFont[]): Promise<void> {
|
||||
try {
|
||||
const selectedFontDeleted = this.isCurrentlySelectedFontDeleted(fonts);
|
||||
|
||||
this.customFonts = fonts;
|
||||
await this.customFontService.loadAllFonts(fonts);
|
||||
this.updateFontsDropdown(fonts);
|
||||
|
||||
if (selectedFontDeleted) {
|
||||
this.resetToDefaultFont();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to process custom fonts:', err);
|
||||
}
|
||||
}
|
||||
|
||||
private hasCustomFontsChanged(newFonts: CustomFont[]): boolean {
|
||||
if (newFonts.length !== this.customFonts.length) {
|
||||
return true;
|
||||
}
|
||||
const newIds = new Set(newFonts.map(f => f.id));
|
||||
const currentIds = new Set(this.customFonts.map(f => f.id));
|
||||
return newFonts.some(f => !currentIds.has(f.id)) || this.customFonts.some(f => !newIds.has(f.id));
|
||||
}
|
||||
|
||||
private updateFontsDropdown(fonts: CustomFont[]): void {
|
||||
this.fonts = this.fonts.filter(font => !font.key || !font.key.startsWith('custom:'));
|
||||
addCustomFontsToDropdown(fonts, this.fonts, 'preference');
|
||||
}
|
||||
|
||||
private isCurrentlySelectedFontDeleted(newFonts: CustomFont[]): boolean {
|
||||
const fontFamily = this.userSettings.ebookReaderSetting.fontFamily;
|
||||
if (!fontFamily || !fontFamily.startsWith('custom:')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const fontId = fontFamily.split(':')[1];
|
||||
const fontStillExists = newFonts.some(font => font.id === parseInt(fontId, 10));
|
||||
return !fontStillExists;
|
||||
}
|
||||
|
||||
private resetToDefaultFont(): void {
|
||||
console.log('Selected custom font was deleted, resetting to default font');
|
||||
this.selectedFont = null;
|
||||
}
|
||||
|
||||
get selectedTheme(): string | null {
|
||||
return this.userSettings.ebookReaderSetting.theme;
|
||||
}
|
||||
|
||||
set selectedTheme(value: string | null) {
|
||||
if (typeof value === "string") {
|
||||
this.userSettings.ebookReaderSetting.theme = value;
|
||||
}
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'theme'], value);
|
||||
}
|
||||
|
||||
get selectedFont(): string | null {
|
||||
return this.userSettings.ebookReaderSetting.fontFamily;
|
||||
}
|
||||
|
||||
set selectedFont(value: string | null) {
|
||||
if (typeof value === "string") {
|
||||
this.userSettings.ebookReaderSetting.fontFamily = value;
|
||||
} else {
|
||||
this.userSettings.ebookReaderSetting.fontFamily = null as any;
|
||||
}
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'fontFamily'], value);
|
||||
}
|
||||
|
||||
get fontSize(): number {
|
||||
return this.userSettings.ebookReaderSetting.fontSize;
|
||||
}
|
||||
|
||||
set fontSize(value: number) {
|
||||
this.userSettings.ebookReaderSetting.fontSize = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'fontSize'], value);
|
||||
}
|
||||
|
||||
get lineHeight(): number {
|
||||
return this.userSettings.ebookReaderSetting.lineHeight;
|
||||
}
|
||||
|
||||
set lineHeight(value: number) {
|
||||
this.userSettings.ebookReaderSetting.lineHeight = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'lineHeight'], value);
|
||||
}
|
||||
|
||||
get justify(): boolean {
|
||||
return this.userSettings.ebookReaderSetting.justify;
|
||||
}
|
||||
|
||||
set justify(value: boolean) {
|
||||
this.userSettings.ebookReaderSetting.justify = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'justify'], value);
|
||||
}
|
||||
|
||||
get hyphenate(): boolean {
|
||||
return this.userSettings.ebookReaderSetting.hyphenate;
|
||||
}
|
||||
|
||||
set hyphenate(value: boolean) {
|
||||
this.userSettings.ebookReaderSetting.hyphenate = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'hyphenate'], value);
|
||||
}
|
||||
|
||||
get maxColumnCount(): number {
|
||||
return this.userSettings.ebookReaderSetting.maxColumnCount;
|
||||
}
|
||||
|
||||
set maxColumnCount(value: number) {
|
||||
this.userSettings.ebookReaderSetting.maxColumnCount = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'maxColumnCount'], value);
|
||||
}
|
||||
|
||||
get gap(): number {
|
||||
return this.userSettings.ebookReaderSetting.gap;
|
||||
}
|
||||
|
||||
set gap(value: number) {
|
||||
this.userSettings.ebookReaderSetting.gap = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'gap'], value);
|
||||
}
|
||||
|
||||
get maxInlineSize(): number {
|
||||
return this.userSettings.ebookReaderSetting.maxInlineSize;
|
||||
}
|
||||
|
||||
set maxInlineSize(value: number) {
|
||||
this.userSettings.ebookReaderSetting.maxInlineSize = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'maxInlineSize'], value);
|
||||
}
|
||||
|
||||
get maxBlockSize(): number {
|
||||
return this.userSettings.ebookReaderSetting.maxBlockSize;
|
||||
}
|
||||
|
||||
set maxBlockSize(value: number) {
|
||||
this.userSettings.ebookReaderSetting.maxBlockSize = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'maxBlockSize'], value);
|
||||
}
|
||||
|
||||
get isDark(): boolean {
|
||||
return this.userSettings.ebookReaderSetting.isDark;
|
||||
}
|
||||
|
||||
set isDark(value: boolean) {
|
||||
this.userSettings.ebookReaderSetting.isDark = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'isDark'], value);
|
||||
}
|
||||
|
||||
get flow(): 'paginated' | 'scrolled' {
|
||||
return this.userSettings.ebookReaderSetting.flow;
|
||||
}
|
||||
|
||||
set flow(value: 'paginated' | 'scrolled') {
|
||||
this.userSettings.ebookReaderSetting.flow = value;
|
||||
this.readerPreferencesService.updatePreference(['ebookReaderSetting', 'flow'], value);
|
||||
}
|
||||
|
||||
increaseFontSize() {
|
||||
if (this.fontSize < 72) {
|
||||
this.fontSize += 1;
|
||||
}
|
||||
}
|
||||
|
||||
decreaseFontSize() {
|
||||
if (this.fontSize > 8) {
|
||||
this.fontSize -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
increaseLineHeight() {
|
||||
if (this.lineHeight < 3) {
|
||||
this.lineHeight = Math.round((this.lineHeight + 0.1) * 10) / 10;
|
||||
}
|
||||
}
|
||||
|
||||
decreaseLineHeight() {
|
||||
if (this.lineHeight > 1) {
|
||||
this.lineHeight = Math.round((this.lineHeight - 0.1) * 10) / 10;
|
||||
}
|
||||
}
|
||||
|
||||
increaseGap() {
|
||||
|
||||
if (this.gap < 0.5) {
|
||||
this.gap = Math.round((this.gap + 0.05) * 100) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
decreaseGap() {
|
||||
if (this.gap > 0) {
|
||||
this.gap = Math.round((this.gap - 0.05) * 100) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
increaseMaxInlineSize() {
|
||||
if (this.maxInlineSize < 2000) {
|
||||
this.maxInlineSize += 50;
|
||||
}
|
||||
}
|
||||
|
||||
decreaseMaxInlineSize() {
|
||||
if (this.maxInlineSize > 400) {
|
||||
this.maxInlineSize -= 50;
|
||||
}
|
||||
}
|
||||
|
||||
increaseMaxBlockSize() {
|
||||
if (this.maxBlockSize < 2000) {
|
||||
this.maxBlockSize += 50;
|
||||
}
|
||||
}
|
||||
|
||||
decreaseMaxBlockSize() {
|
||||
if (this.maxBlockSize > 400) {
|
||||
this.maxBlockSize -= 50;
|
||||
}
|
||||
}
|
||||
|
||||
getCustomFontName(fontKey: string): string | null {
|
||||
if (!fontKey || !fontKey.startsWith('custom:')) {
|
||||
return null;
|
||||
}
|
||||
const fontId = parseInt(fontKey.split(':')[1]);
|
||||
const customFont = this.customFonts.find(f => f.id === fontId);
|
||||
return customFont ? customFont.fontName : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user