diff --git a/src/components/reader/BookReader.tsx b/src/components/reader/BookReader.tsx
index d7c7abe..aea53ac 100644
--- a/src/components/reader/BookReader.tsx
+++ b/src/components/reader/BookReader.tsx
@@ -194,6 +194,7 @@ export function BookReader({ book, pages, onClose }: BookReaderProps) {
onToggleControls={() => setShowControls(!showControls)}
onPreviousPage={handlePreviousPage}
onNextPage={handleNextPage}
+ onPageChange={navigateToPage}
onClose={onClose}
currentPage={currentPage}
totalPages={pages.length}
diff --git a/src/components/reader/components/ControlButtons.tsx b/src/components/reader/components/ControlButtons.tsx
index 824d68a..5662637 100644
--- a/src/components/reader/components/ControlButtons.tsx
+++ b/src/components/reader/components/ControlButtons.tsx
@@ -11,6 +11,7 @@ import {
MoveLeft,
} from "lucide-react";
import { cn } from "@/lib/utils";
+import { PageInput } from "./PageInput";
export const ControlButtons = ({
showControls,
@@ -26,6 +27,7 @@ export const ControlButtons = ({
onToggleFullscreen,
direction,
onToggleDirection,
+ onPageChange,
}: ControlButtonsProps) => {
return (
<>
@@ -82,6 +84,16 @@ export const ControlButtons = ({
>
{isFullscreen ? : }
+
e.stopPropagation()}>
+
{
+ onToggleControls();
+ onPageChange(page);
+ }}
+ />
+
{/* Bouton fermer */}
diff --git a/src/components/reader/components/PageInput.tsx b/src/components/reader/components/PageInput.tsx
new file mode 100644
index 0000000..9606ea8
--- /dev/null
+++ b/src/components/reader/components/PageInput.tsx
@@ -0,0 +1,101 @@
+import { useRef, useState } from "react";
+import { cn } from "@/lib/utils";
+import { ArrowRight } from "lucide-react";
+
+interface PageInputProps {
+ currentPage: number;
+ totalPages: number;
+ onPageChange: (page: number) => void;
+}
+
+export const PageInput = ({ currentPage, totalPages, onPageChange }: PageInputProps) => {
+ const [isEditing, setIsEditing] = useState(false);
+ const [inputValue, setInputValue] = useState(currentPage.toString());
+ const inputRef = useRef(null);
+
+ const handleKeyDown = (e: React.KeyboardEvent) => {
+ if (e.key === "Enter") {
+ handleGoToPage();
+ } else if (e.key === "Escape") {
+ setIsEditing(false);
+ setInputValue(currentPage.toString());
+ }
+ };
+
+ const handleGoToPage = () => {
+ const value = parseInt(inputValue);
+ if (!isNaN(value) && value >= 1 && value <= totalPages) {
+ onPageChange(value);
+ setIsEditing(false);
+ }
+ };
+
+ const handleClick = () => {
+ setIsEditing(true);
+ setInputValue(currentPage.toString());
+ setTimeout(() => {
+ inputRef.current?.select();
+ }, 0);
+ };
+
+ const handleBlur = (e: React.FocusEvent) => {
+ // Ne pas fermer si on clique sur le bouton "Aller à"
+ if (e.relatedTarget?.getAttribute("data-action") === "goto") {
+ return;
+ }
+ setIsEditing(false);
+ setInputValue(currentPage.toString());
+ };
+
+ const handleChange = (e: React.ChangeEvent) => {
+ // Ne garder que les chiffres
+ const value = e.target.value.replace(/[^0-9]/g, "");
+ if (value === "" || (parseInt(value) >= 1 && parseInt(value) <= totalPages)) {
+ setInputValue(value);
+ }
+ };
+
+ return (
+
+ {isEditing ? (
+ <>
+
+
+ >
+ ) : (
+
+ )}
+
+ );
+};
diff --git a/src/components/reader/types.ts b/src/components/reader/types.ts
index 052fcb0..a148164 100644
--- a/src/components/reader/types.ts
+++ b/src/components/reader/types.ts
@@ -38,6 +38,7 @@ export interface ControlButtonsProps {
onToggleControls: () => void;
onPreviousPage: () => void;
onNextPage: () => void;
+ onPageChange: (page: number) => void;
onClose?: () => void;
currentPage: number;
totalPages: number;