Reader

When creating a reader, you can specify several options. Some of them can also changed later dynamically.

A reader instance is not necessary per books. You can load different books with the same instance (but not at the same time).

const reader = createReader({
  layoutAutoResize: "container",
  forceSinglePageMode: true
  // ...
})

/**
 * Don't forget to destroy the instance when
 * you are done with it
 */
reader.destroy()

Enhancers

Using enhancers (whether official or community) are a good way to add functionality to the reader. Enhancers are not mandatory to "enhance" the reader but offer a conventional way to do so.

Just wrap the createReader function within the various enhancers you want to use.

The order is important if a specific enhancer requires another one.

import { bookmarksEnhancer } from "@prose-reader/enhancer-bookmarks"
import { searchEnhancer } from "@prose-reader/enhancer-search"
import { highlightsEnhancer } from "@prose-reader/enhancer-highlights"

const reader = highlightsEnhancer(
  bookmarksEnhancer(
    searchEnhancer(
      createReader
    )
  )
)

// enhancers have usually their own namespace by convention
reader.bookmarks.load(...)

Last updated