-
Notifications
You must be signed in to change notification settings - Fork 6
/
use-html-reader.tsx
48 lines (43 loc) · 1.08 KB
/
use-html-reader.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import { useHtmlReader } from '../src';
import { Injectable } from '../src/Readium/Injectable';
import { WebpubManifest } from '../src/types';
import Footer from '../src/ui/Footer';
import Header from '../src/ui/Header';
type HTMLReaderProps = {
injectablesReflowable: Injectable[];
webpubManifestUrl: string;
manifest: WebpubManifest;
};
/**
* This sample shows setting how to use the useHTMLReader hook
* to render EPUBs. Use it when you know you're _not_ going to be
* opening PDFs.
*/
const UseHtmlReader: React.FC<HTMLReaderProps> = ({
injectablesReflowable,
webpubManifestUrl,
manifest,
}) => {
const reader = useHtmlReader({
webpubManifestUrl,
manifest,
injectablesReflowable,
});
const containerRef = React.useRef<HTMLDivElement>(null);
if (!reader || !reader.type) {
return null;
}
return (
<div>
<Header
{...reader}
headerLeft={<a href="/">Back</a>}
containerRef={containerRef}
/>
{reader.content}
<Footer {...reader} />
</div>
);
};
export default UseHtmlReader;