All Projects → gerhardsletten → React Reader

gerhardsletten / React Reader

Licence: apache-2.0
An ePub-reader for React, powered by Epub.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Reader

baruch
A mobile app where you can read and download light novels.
Stars: ✭ 68 (-73.44%)
Mutual labels:  reader
cherche
📑 Neural Search
Stars: ✭ 196 (-23.44%)
Mutual labels:  reader
limio
A rate limiting library for Go centered around intuitive and idiomatic interfaces, and designed to limit silly window syndrome.
Stars: ✭ 51 (-80.08%)
Mutual labels:  reader
NovelDokusha
Android web novel reader
Stars: ✭ 29 (-88.67%)
Mutual labels:  reader
barcode scan2
[reborned barcode_scan] A flutter plugin for reading 2D barcodes and QR codes.
Stars: ✭ 43 (-83.2%)
Mutual labels:  reader
KoHighlights
KOHighlights is a utility for viewing KOReader's highlights and/or export them to simple text, csv or html files.
Stars: ✭ 62 (-75.78%)
Mutual labels:  reader
z-reader
📘 [vscode插件] 小说阅读器,支持在线搜索和本地阅读,支持txt和epub格式
Stars: ✭ 205 (-19.92%)
Mutual labels:  reader
comic-wx
微信小程序,仿腾讯动漫,界面美观,具备常用功能。WeiXin mini program,imitating TenCent comic, is very beautiful. I think, you would like it
Stars: ✭ 60 (-76.56%)
Mutual labels:  reader
WeYue-wxapp
微Yue电子书阅读-微信小程序
Stars: ✭ 47 (-81.64%)
Mutual labels:  reader
Aperture
Aperture is a Microsub server. Currently in beta.
Stars: ✭ 62 (-75.78%)
Mutual labels:  reader
RecordParser
Zero Allocation Writer/Reader Parser for .NET Core
Stars: ✭ 155 (-39.45%)
Mutual labels:  reader
BCF-js
bcf-js is a BIM Collaboration Format (BCF) reader & parser developed and maintained by Parametricos Ltd.
Stars: ✭ 18 (-92.97%)
Mutual labels:  reader
any-text
Get text content from any file
Stars: ✭ 19 (-92.58%)
Mutual labels:  reader
CsharpVoxReader
A generic C# reader for MagicaVoxel's vox file format
Stars: ✭ 15 (-94.14%)
Mutual labels:  reader
ESP-Mail-Client
⚡️Arduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.
Stars: ✭ 78 (-69.53%)
Mutual labels:  reader
BookReader
📕 "任阅" 网络小说阅读器,3D翻页效果、txt/pdf/epub书籍阅读、Wifi传书~
Stars: ✭ 6,113 (+2287.89%)
Mutual labels:  reader
eBookReaderNX
A Nintendo Switch eBook Reader
Stars: ✭ 15 (-94.14%)
Mutual labels:  reader
Mimanganu
*ES - Lector de Manga online / offline, gratuito y de código abierto. *EN - Manga reader online / offline, free and open source. *FR - Lecteur de manga en ligne / hors ligne, gratuit et open source. *DE - Eine App um Manga zu lesen. Man kann damit Manga online und offline lesen. Es ist kostenlos und quelloffen. *IT - Manga lettore online / offline, gratuito e open source. *RU - В России Манга читает вас. Попробуйте MiMangaNu прямо сейчас.
Stars: ✭ 255 (-0.39%)
Mutual labels:  reader
bookery
Manage all your ebooks and send them to your reader
Stars: ✭ 35 (-86.33%)
Mutual labels:  reader
simple-ini-reader
Fast, Simple, Public Domain INI Reader written in C
Stars: ✭ 17 (-93.36%)
Mutual labels:  reader

React ePub reader

An ePub-reader for react powered by EpubJS #react #epubjs #webpack #babel #standardjs

See demo

React Reader logo

React wrapper for epubjs

React reader is a react-wrapper for epub.js, using the v.03 branch.

About

epub.js is a great library, and this is a wrapper for this library, making it easier to use in a React-app.

import {
  EpubView, // Underlaying epub-canvas (wrapper for epub.js iframe)
  EpubViewStyle, // Styles for EpubView, you can pass it to the instance as a style prop for customize it
  ReactReader, // A simple epub-reader with left/right button and chapter navigation
  ReactReaderStyle // Styles for the epub-reader it you need to customize it
} from "react-reader";

Basic usage

npm install react-reader --save

And in your react-component...

import React, { Component } from "react";
import { ReactReader } from "react-reader";

class App extends Component {
  render() {
    return (
      <div style={{ position: "relative", height: "100%" }}>
        {" "}
        // * Container needs a height..
        <ReactReader
          url={"/alice.epub"}
          title={"Alice in wonderland"}
          location={"epubcfi(/6/2[cover]!/6)"}
          locationChanged={epubcifi => console.log(epubcifi)}
        />
      </div>
    );
  }
}

See src/App.js for an example of using the selection api in epubjs.

ReactReader props

  • title [string] - the title of the book, displayed above the reading-canvas
  • loadingView [element] - if you want to customize the loadingView
  • showToc [bool] - whether to show the toc / toc-nav
  • locationChanged [func] - a function that receives the current location while user is reading
  • tocChanged [func] - when the reader has parsed the book you will receive an array of the chapters
  • styles [object] - override the default styles
  • epubViewStyles [object] - override the default styles for inner EpubView
  • swipeable [bool, default false] - enable swiping left/right with react-swipeable. Warning this will disable interacting with epub.js iframe content like selection

See also TypeScript definition for React Reader here (thanks to @rafaelsaback)

Additional props will be forwarded to the underlying EpubView component, like url, location, epubOptions, epubInitOptions and getRendition. See its props here

Container needs a height. The ReactReader will expand to 100% of width/height, so be sure to set a height on the parent element, either with position it absolute of window, set height or use paddingTop for proporcional scaling.

Optional use the underlying EpubView

This is just the plain epub canvas, you will then need to implement the reader stuff like chapter (toc) navigation and next/prev buttons. Take a look at the implementation in ReactReader.js

import React, { Component } from "react";
import { EpubView } from "react-reader";

class App extends Component {
  render() {
    return (
      /* The ReactReader will expand to 100% of width/height, so be sure to set a height on the parent element, either with position it absolute of window, set height or use paddingTop for proporsjonal scaling */
      <div style={{ position: "relative", height: "100%" }}>
        <EpubView
          url={"/alice.epub"}
          location={"epubcfi(/6/2[cover]!/6)"}
          locationChanged={epubcifi => console.log(epubcifi)}
          tocChanged={toc => console.log(toc)}
        />
      </div>
    );
  }
}

EpubView props

  • url [string, required] - url to the epub-file, if its on another domain, remember to add cors for the file. Epubjs fetch this by a http-call, so it need to be public available.
  • loadingView [element] - if you want to customize the loadingView
  • location [string, number] - set / update location of the epub
  • locationChanged [func] - a function that receives the current location while user is reading
  • tocChanged [func] - when the reader has parsed the book you will receive an array of the chapters
  • styles [object] - override the default styles
  • epubInitOptions [object] - pass custom properties to the epub init function, see epub.js
  • epubOptions [object] - pass custom properties to the epub rendition, see epub.js's book.renderTo function
  • getRendition [func] - when epubjs has rendered the epub-file you can get access to the epubjs-rendition object here

Handling not valid epub-files

A tip if you have problems with not valid epub-files is to override the build in DOMParser and modify the markup-string passed to its parseFromString function. This example fixes a not valid <title/> tag in an old epub, which would render as a blank page if not fixed:

const DOMParser = window.DOMParser

class OwnParser {
  parseFromString(markup, mime) {
    if (markup.indexOf('<title/>') !== -1) {
      markup = markup.replace('<title/>', '');
    }
    return new DOMParser().parseFromString(markup, mime)
  }
}

window.DOMParser = OwnParser

Usage in cordova

There is a limitation with iframe and srcdoc so you need to add this to your config.xml to make react-reader work within a cordova application:

<allow-navigation href="about:*" />

See stackoverflow.com/questions/39165545/cordova-iframe-with-html-inside-not-showing-on-ios-device

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].