diff --git a/apps/readest-app/src/app/reader/components/FoliateViewer.tsx b/apps/readest-app/src/app/reader/components/FoliateViewer.tsx index 91be72b9..5ac24407 100644 --- a/apps/readest-app/src/app/reader/components/FoliateViewer.tsx +++ b/apps/readest-app/src/app/reader/components/FoliateViewer.tsx @@ -84,9 +84,18 @@ const FoliateViewer: React.FC<{ ); }; + const handleKeyboardPagination = (e: KeyboardEvent) => { + if (e.key === 'ArrowLeft' || e.key === 'PageUp' || e.key === 'h') { + view?.goLeft(); + } else if (e.key === 'ArrowRight' || e.key === 'PageDown' || e.key === 'l') { + view?.goRight(); + } + }; + const docLoadHandler = (event: Event) => { const detail = (event as CustomEvent).detail; - if (handleKeyDown) detail.doc?.addEventListener('keydown', handleKeyDown); + detail.doc?.addEventListener('keydown', handleKeyDown); + detail.doc?.addEventListener('keydown', handleKeyboardPagination); }; useFoliateEvents(view, { onLoad: docLoadHandler, onRelocate: progressRelocateHandler }); diff --git a/apps/readest-app/src/app/reader/components/ReaderContent.tsx b/apps/readest-app/src/app/reader/components/ReaderContent.tsx index 375502c5..ff9e8ac1 100644 --- a/apps/readest-app/src/app/reader/components/ReaderContent.tsx +++ b/apps/readest-app/src/app/reader/components/ReaderContent.tsx @@ -49,10 +49,15 @@ const ReaderContent = () => { return getKey(ids[nextIndex]!, nextIndex); }); e.preventDefault(); + } else if (e.key === 't') { + setSideBarVisibility((prev) => !prev); } - if (e.key === 'ArrowLeft') { + }; + + const handleKeyboardPagination = (e: KeyboardEvent) => { + if (e.key === 'ArrowLeft' || e.key === 'PageUp' || e.key === 'h') { getFoliateView(sideBarBookKey)?.goLeft(); - } else if (e.key === 'ArrowRight') { + } else if (e.key === 'ArrowRight' || e.key === 'PageDown' || e.key === 'l') { getFoliateView(sideBarBookKey)?.goRight(); } }; @@ -72,8 +77,10 @@ const ReaderContent = () => { useEffect(() => { window.addEventListener('keydown', handleKeyDown); + window.addEventListener('keydown', handleKeyboardPagination); return () => { window.removeEventListener('keydown', handleKeyDown); + window.removeEventListener('keydown', handleKeyboardPagination); }; }, [sideBarBookKey]); diff --git a/apps/readest-app/src/app/reader/components/SideBar.tsx b/apps/readest-app/src/app/reader/components/SideBar.tsx index a10e0a90..938c2bc0 100644 --- a/apps/readest-app/src/app/reader/components/SideBar.tsx +++ b/apps/readest-app/src/app/reader/components/SideBar.tsx @@ -1,4 +1,5 @@ import React, { useState, useEffect } from 'react'; +import clsx from 'clsx'; import { MdSearch, MdOutlinePushPin, @@ -79,86 +80,78 @@ const SideBar: React.FC<{ const { book, bookDoc } = bookState; - return ( - isVisible && ( -
-
-
-
- -
-
- - -
-
-
- -
-
- {activeTab === 'toc' && bookDoc!.toc && ( - - )} - {activeTab === 'bookmarks' &&
Bookmarks
} - {activeTab === 'annotations' &&
Annotations
} -
-
- - - +
+
+ +
-
- {!isPinned && ( -
handleClickOverlay()} - /> - )} +
+ +
+
+ {activeTab === 'toc' && bookDoc!.toc && ( + + )} + {activeTab === 'annotations' &&
Annotations
} + {activeTab === 'bookmarks' &&
Bookmarks
} +
+
+ {['toc', 'annotations', 'bookmarks'].map((tab) => ( + + ))} +
+
- ) - ); + {!isPinned && ( +
handleClickOverlay()} + /> + )} +
+ ) : null; }; export default SideBar;