0.2.0 ⢠Published 4 years ago
react-epub-viewer v0.2.0
React-Epub-Viewer
React-Epub-Viewer is Epub Viewer for React.js powered by Epub.js v0.3
You can use React-Epub-Viewer together with React.
Getting Started
š¢ Online Demo š You can check the Demo Code
Features
- Table of contents
- Setting
- Font
- Font size
- Line height
- Viewer horizontal margin
- Viewer vertical margin
Change viewer type
- Scrolled-doc
true/false - Spread
true/false
- Scrolled-doc
Current Page Information
- Current chapter name
- Current page number
- Total page number
- Move page by arrow keys
- Highlight (Using
mouseupevent)- Select highlight color
Getting the Code
Install library from NPM
npm install react-epub-viewerImport viewer component
import { useRef } from 'react'
import {
EpubViewer,
ReactEpubViewer
} from 'react-epub-viewer'
const App = () => {
const viewerRef = useRef(null);
return (
<div style={{ position: "relative", height: "100%" }}>
<ReactEpubViewer
url={'files/Alices Adventures in Wonderland.epub'}
ref={viewerRef}
/>
</div>
);
}
export default AppYou can find other parameters in Component Props(##Component Props).
Component Props
You can see also Types for React-Epub-Viewer here.
EpubViewer Props
ref- RefObject Viewer Refurl- string - Epub file pathepubFileOptions- [object] Epub file option (Epub.js BookOption)epubOptions- [object] Epub viewer option (Epub.js RenditionOption)style- object Epub wrapper stylelocation- string Epub CFI or Spine hrefbookChanged- function Run when epub book changedrenditionChanged- function Run when rendition changedpageChanged- function Run when page changedtocChanged- function Run when toc changedselectionChanged- function Run when selectedloadingView- ReactNode React Loading Component
ReactEpubViewer Props
ref- RefObject Viewer Refurl- string Epub file pathviewerLayout- object Viewer layout values (header height, footer height, etc...)viewerOption- object Viewer option (whether is flow or is spread)onBookInfoChange- function Run when book information changedonPageChange- function Run when page changedonTocChange- function Run when toc changedonSelection- function Run when selectedloadingView- ReactNode React Loading Component
Contribuing
If you would like to contribute, please follow the guideline! Thank you! š