style(reader): apply code formatting to existing format files
Run code formatting (prettier/eslint) on existing reader format files that were not migrated to the new structure. This ensures consistent code style across the codebase. ## Changes ### Formatting Applied - Added newlines at end of files - Fixed line length and indentation - Updated import statements for consistency - Applied code style rules uniformly ### Files Affected - **Comic**: background-color, chapter-markers, page-order, panel-gap - **Ebook**: font-loader, search, view-modes - **Manga**: vertical-scroll-mode - **PDF**: annotation-layer, pdf-navigation, pdf-text-selection ## Purpose These files will be removed in subsequent commits as they are replaced by the new modular structure. The formatting ensures consistency during the transition period and maintains code quality standards. Note: These are non-functional formatting changes only. No logic or behavior was modified in this commit.
This commit is contained in:
@@ -1,22 +1,27 @@
|
||||
// PDF navigation: page turning, zoom, fit modes
|
||||
// Feature Registration Pattern implementation
|
||||
|
||||
import type { ReaderContext } from "../core/reader-context";
|
||||
import { ReaderContext } from "../core/reader-context";
|
||||
|
||||
export function init(context: ReaderContext): void {
|
||||
let navState: PDFNavigationState | null = null;
|
||||
|
||||
context.events.on("reader:loaded", (detail: { container: HTMLElement; totalPages: number }) => {
|
||||
navState = {
|
||||
currentPage: 1,
|
||||
totalPages: detail.totalPages,
|
||||
currentScale: 1.0,
|
||||
fitMode: "fit-width",
|
||||
scrollContainer: detail.container.querySelector(".pdf-scroll-container") || detail.container,
|
||||
};
|
||||
setupPDFKeyboardNav(context, navState);
|
||||
setupPDFScrollTracking(context, navState);
|
||||
});
|
||||
context.events.on(
|
||||
"reader:loaded",
|
||||
(detail: { container: HTMLElement; totalPages: number }) => {
|
||||
navState = {
|
||||
currentPage: 1,
|
||||
totalPages: detail.totalPages,
|
||||
currentScale: 1.0,
|
||||
fitMode: "fit-width",
|
||||
scrollContainer:
|
||||
detail.container.querySelector(".pdf-scroll-container") ||
|
||||
detail.container,
|
||||
};
|
||||
setupPDFKeyboardNav(context, navState);
|
||||
setupPDFScrollTracking(context, navState);
|
||||
},
|
||||
);
|
||||
|
||||
context.events.on("pdf:navigate:to-page", (detail: { page: number }) => {
|
||||
if (navState) {
|
||||
@@ -54,11 +59,14 @@ export function init(context: ReaderContext): void {
|
||||
}
|
||||
});
|
||||
|
||||
context.events.on("pdf:fit:set", (detail: { mode: "fit-width" | "fit-page" | "fit-height" | "none" }) => {
|
||||
if (navState) {
|
||||
setPDFFitMode(navState, detail.mode, context);
|
||||
}
|
||||
});
|
||||
context.events.on(
|
||||
"pdf:fit:set",
|
||||
(detail: { mode: "fit-width" | "fit-page" | "fit-height" | "none" }) => {
|
||||
if (navState) {
|
||||
setPDFFitMode(navState, detail.mode, context);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
context.events.on("reader:unload", () => {
|
||||
navState = null;
|
||||
@@ -75,7 +83,11 @@ interface PDFNavigationState {
|
||||
scrollContainer: HTMLElement | null;
|
||||
}
|
||||
|
||||
function goToPDFPage(state: PDFNavigationState, pageNumber: number, context: ReaderContext): void {
|
||||
function goToPDFPage(
|
||||
state: PDFNavigationState,
|
||||
pageNumber: number,
|
||||
context: ReaderContext,
|
||||
): void {
|
||||
if (pageNumber < 1 || pageNumber > state.totalPages) return;
|
||||
|
||||
state.currentPage = pageNumber;
|
||||
@@ -89,7 +101,10 @@ function nextPDFPage(state: PDFNavigationState, context: ReaderContext): void {
|
||||
}
|
||||
}
|
||||
|
||||
function previousPDFPage(state: PDFNavigationState, context: ReaderContext): void {
|
||||
function previousPDFPage(
|
||||
state: PDFNavigationState,
|
||||
context: ReaderContext,
|
||||
): void {
|
||||
if (state.currentPage > 1) {
|
||||
goToPDFPage(state, state.currentPage - 1, context);
|
||||
}
|
||||
@@ -106,14 +121,22 @@ function scrollToPDFPage(state: PDFNavigationState, pageNumber: number): void {
|
||||
}
|
||||
}
|
||||
|
||||
function setPDFZoom(state: PDFNavigationState, scale: number, context: ReaderContext): void {
|
||||
function setPDFZoom(
|
||||
state: PDFNavigationState,
|
||||
scale: number,
|
||||
context: ReaderContext,
|
||||
): void {
|
||||
state.currentScale = scale;
|
||||
state.fitMode = "none";
|
||||
updatePDFZoom(state);
|
||||
context.events.emit("pdf:zoom-changed", { scale });
|
||||
}
|
||||
|
||||
function setPDFFitMode(state: PDFNavigationState, mode: PageFitMode, context: ReaderContext): void {
|
||||
function setPDFFitMode(
|
||||
state: PDFNavigationState,
|
||||
mode: PageFitMode,
|
||||
context: ReaderContext,
|
||||
): void {
|
||||
state.fitMode = mode;
|
||||
updatePDFZoom(state);
|
||||
context.events.emit("pdf:fit-changed", { mode });
|
||||
@@ -137,7 +160,10 @@ function updatePDFZoom(state: PDFNavigationState): void {
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function setupPDFKeyboardNav(context: ReaderContext, state: PDFNavigationState): void {
|
||||
function setupPDFKeyboardNav(
|
||||
context: ReaderContext,
|
||||
state: PDFNavigationState,
|
||||
): void {
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
||||
nextPDFPage(state, context);
|
||||
@@ -151,7 +177,10 @@ function setupPDFKeyboardNav(context: ReaderContext, state: PDFNavigationState):
|
||||
});
|
||||
}
|
||||
|
||||
function setupPDFScrollTracking(context: ReaderContext, state: PDFNavigationState): void {
|
||||
function setupPDFScrollTracking(
|
||||
context: ReaderContext,
|
||||
state: PDFNavigationState,
|
||||
): void {
|
||||
if (!state.scrollContainer) return;
|
||||
|
||||
state.scrollContainer.addEventListener("scroll", () => {
|
||||
@@ -182,4 +211,5 @@ function getCurrentPDFPage(state: PDFNavigationState): number {
|
||||
}
|
||||
|
||||
return state.currentPage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user