react-native-simple-epub-reader 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/components/GestureHandler/index.js +8 -2
- package/lib/module/components/GestureHandler/index.js.map +1 -1
- package/lib/module/components/Reader.js +98 -18
- package/lib/module/components/Reader.js.map +1 -1
- package/lib/module/constants/template.js +74 -70
- package/lib/module/constants/template.js.map +1 -1
- package/lib/module/constants/theme.js +28 -11
- package/lib/module/constants/theme.js.map +1 -1
- package/lib/module/helpers/downloadEpub.js +0 -3
- package/lib/module/helpers/downloadEpub.js.map +1 -1
- package/lib/module/helpers/saveTemplateToFile.js +4 -0
- package/lib/module/helpers/saveTemplateToFile.js.map +1 -1
- package/lib/module/hooks/useInjectWebviewVariables.js +4 -2
- package/lib/module/hooks/useInjectWebviewVariables.js.map +1 -1
- package/lib/typescript/src/components/GestureHandler/index.d.ts.map +1 -1
- package/lib/typescript/src/components/Reader.d.ts +1 -1
- package/lib/typescript/src/components/Reader.d.ts.map +1 -1
- package/lib/typescript/src/constants/template.d.ts +1 -1
- package/lib/typescript/src/constants/template.d.ts.map +1 -1
- package/lib/typescript/src/constants/theme.d.ts.map +1 -1
- package/lib/typescript/src/helpers/downloadEpub.d.ts.map +1 -1
- package/lib/typescript/src/helpers/saveTemplateToFile.d.ts +1 -0
- package/lib/typescript/src/helpers/saveTemplateToFile.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useInjectWebviewVariables.d.ts +2 -1
- package/lib/typescript/src/hooks/useInjectWebviewVariables.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +4 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/GestureHandler/index.tsx +8 -0
- package/src/components/Reader.tsx +125 -17
- package/src/constants/template.ts +74 -70
- package/src/constants/theme.ts +28 -11
- package/src/helpers/downloadEpub.ts +0 -2
- package/src/helpers/saveTemplateToFile.ts +5 -0
- package/src/hooks/useInjectWebviewVariables.ts +9 -0
- package/src/types/index.ts +4 -0
package/src/constants/theme.ts
CHANGED
|
@@ -2,41 +2,58 @@ import type { Theme } from '../types';
|
|
|
2
2
|
|
|
3
3
|
export const defaultTheme: Theme = {
|
|
4
4
|
'body': {
|
|
5
|
-
background: '#
|
|
5
|
+
background: '#211F26',
|
|
6
6
|
},
|
|
7
7
|
'span': {
|
|
8
|
-
color: '#
|
|
8
|
+
color: '#ffffff !important',
|
|
9
|
+
backgroundColor: '#211F26',
|
|
9
10
|
},
|
|
10
11
|
'p': {
|
|
11
|
-
color: '#
|
|
12
|
+
color: '#ffffff !important',
|
|
13
|
+
backgroundColor: '#211F26',
|
|
12
14
|
},
|
|
13
15
|
'li': {
|
|
14
|
-
color: '#
|
|
16
|
+
color: '#ffffff !important',
|
|
17
|
+
backgroundColor: '#211F26',
|
|
15
18
|
},
|
|
16
19
|
'h1': {
|
|
17
|
-
color: '#
|
|
20
|
+
color: '#ffffff !important',
|
|
21
|
+
backgroundColor: '#211F26',
|
|
18
22
|
},
|
|
19
23
|
'h2': {
|
|
20
|
-
color: '#
|
|
24
|
+
color: '#ffffff !important',
|
|
25
|
+
backgroundColor: '#211F26',
|
|
21
26
|
},
|
|
22
27
|
'h3': {
|
|
23
|
-
color: '#
|
|
28
|
+
color: '#ffffff !important',
|
|
29
|
+
backgroundColor: '#211F26',
|
|
24
30
|
},
|
|
25
31
|
'h4': {
|
|
26
|
-
color: '#
|
|
32
|
+
color: '#ffffff !important',
|
|
33
|
+
backgroundColor: '#211F26',
|
|
27
34
|
},
|
|
28
35
|
'h5': {
|
|
29
|
-
color: '#
|
|
36
|
+
color: '#ffffff !important',
|
|
37
|
+
backgroundColor: '#211F26',
|
|
30
38
|
},
|
|
31
39
|
'h6': {
|
|
32
|
-
color: '#
|
|
40
|
+
color: '#ffffff !important',
|
|
41
|
+
backgroundColor: '#211F26',
|
|
33
42
|
},
|
|
34
43
|
'a': {
|
|
35
|
-
'color': '#
|
|
44
|
+
'color': '#ffffff !important',
|
|
45
|
+
'backgroundColor': '#211F26',
|
|
36
46
|
'pointer-events': 'auto',
|
|
37
47
|
'cursor': 'pointer',
|
|
38
48
|
},
|
|
49
|
+
'*': {
|
|
50
|
+
color: '#ffffff !important',
|
|
51
|
+
backgroundColor: '#211F26',
|
|
52
|
+
},
|
|
39
53
|
'::selection': {
|
|
40
54
|
background: 'lightskyblue',
|
|
41
55
|
},
|
|
56
|
+
'::marker': {
|
|
57
|
+
color: '#ffffff !important',
|
|
58
|
+
},
|
|
42
59
|
};
|
|
@@ -18,3 +18,8 @@ export const checkTemplateFileExists = (fileName: string) => {
|
|
|
18
18
|
const htmlFile = new File(Paths.document, fileName);
|
|
19
19
|
return htmlFile.exists;
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
export const getTemplateFileUri = (fileName: string) => {
|
|
23
|
+
const htmlFile = new File(Paths.document, fileName);
|
|
24
|
+
return htmlFile.uri;
|
|
25
|
+
};
|
|
@@ -12,6 +12,7 @@ export function useInjectWebViewVariables() {
|
|
|
12
12
|
book,
|
|
13
13
|
allowScriptedContent,
|
|
14
14
|
theme,
|
|
15
|
+
locations,
|
|
15
16
|
}: {
|
|
16
17
|
jszip: string;
|
|
17
18
|
epubjs: string;
|
|
@@ -19,7 +20,11 @@ export function useInjectWebViewVariables() {
|
|
|
19
20
|
book: string;
|
|
20
21
|
allowScriptedContent?: boolean;
|
|
21
22
|
theme: Theme;
|
|
23
|
+
locations?: string[];
|
|
22
24
|
}) => {
|
|
25
|
+
const initialLocations =
|
|
26
|
+
locations && locations.length > 0 ? JSON.stringify(locations) : 'null';
|
|
27
|
+
|
|
23
28
|
return template
|
|
24
29
|
.replace(
|
|
25
30
|
/<script id="jszip"><\/script>/,
|
|
@@ -43,6 +48,10 @@ export function useInjectWebViewVariables() {
|
|
|
43
48
|
.replace(
|
|
44
49
|
/const theme = window.theme;/,
|
|
45
50
|
`const theme = ${JSON.stringify(theme)};`
|
|
51
|
+
)
|
|
52
|
+
.replace(
|
|
53
|
+
/const initialLocations = window.locations;/,
|
|
54
|
+
`const initialLocations = ${initialLocations};`
|
|
46
55
|
);
|
|
47
56
|
},
|
|
48
57
|
[]
|
package/src/types/index.ts
CHANGED
|
@@ -67,13 +67,17 @@ export interface GestureHandlerProps {
|
|
|
67
67
|
onSwipeLeft?: () => void;
|
|
68
68
|
onSwipeRight?: () => void;
|
|
69
69
|
onTap?: () => void;
|
|
70
|
+
onPinchStart?: () => void;
|
|
70
71
|
onPinch?: (e: GestureUpdateEvent<PinchGestureHandlerEventPayload>) => void;
|
|
72
|
+
onPinchEnd?: () => void;
|
|
71
73
|
onWebViewMessage?: (event: any) => void;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
export type ReaderProps = {
|
|
75
77
|
src: string;
|
|
76
78
|
initialLocation?: string;
|
|
79
|
+
beginAt?: number;
|
|
80
|
+
waitForLocationsReady?: boolean;
|
|
77
81
|
onLocationChange?: (data: LocationChangeData) => void;
|
|
78
82
|
onLocationsReady?: (epubKey: string, locations: ePubCfi[]) => void;
|
|
79
83
|
onFinish?: () => void;
|