1.0.8 • Published 2 years ago

react-jepub v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

react-jepub

Simple EPUB builder library, works in modern browsers.

Installation

npm install --save react-jepub
    import {jEpub} from "react-jepub"
    
    const jepub = new jEpub()
    // jepub.init({
    // do something
 

Usage

const jepub = new jEpub()
jepub.init({
    i18n: 'en', // Internationalization
    title: 'Book title',
    dir: 'ltr',
    author: 'Book author',
    publisher: 'Book publisher',
    description: '<b>Book</b> description', // optional
    tags: [ 'epub', 'tag' ] // optional
})
  • i18n only include the language codes defined in i18n.json
  • description: HTML string.
  • tags: Array.

Set published date

jepub.date(date: object)
  • date: Date Object.

Set identifier

jepub.uuid(id: string | number)
  • id: Unique id.

Add cover

jepub.cover(data: object)
  • data: A Blob or an ArrayBuffer object from XMLHttpRequest.

Add notes

jepub.notes(content: string)
  • content: HTML string.

Add chapter *

jepub.add(title: string, content: string | array, index?:number)
  • title: Plain text.
  • content:
    • string: HTML string.
    • array: Plain text for each item.
  • index: Item index.

Add image

jepub.image(data: object, IMG_ID: string)
  • data: A Blob or an ArrayBuffer object from XMLHttpRequest.
  • IMG_ID: Unique id.

Place <%= image[IMG_ID] %> inside the chapter's content (HTML string only), where you want to display it.

Generate EPUB *

jepub.generate(type = 'blob', onUpdate?: metadata => void)

Static methods +

Convert HTML to text

jEpub.html2text(html: string, noBr = false)
  • html: HTML string.
  • noBr: Boolean. Add line break after Block-level elements.

Development

npm start

Builds are concatenated and minified using Webpack and Babel.

npm run build
1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago