EPUB saved location fix
This commit is contained in:
parent
1dcf1b09e3
commit
d773f8254c
1 changed files with 17 additions and 11 deletions
|
|
@ -17,14 +17,6 @@ const ReactReader = dynamic(() => import('react-reader').then(mod => mod.ReactRe
|
||||||
loading: () => <DocumentSkeleton />
|
loading: () => <DocumentSkeleton />
|
||||||
});
|
});
|
||||||
|
|
||||||
const colors = {
|
|
||||||
background: getComputedStyle(document.documentElement).getPropertyValue('--background'),
|
|
||||||
foreground: getComputedStyle(document.documentElement).getPropertyValue('--foreground'),
|
|
||||||
base: getComputedStyle(document.documentElement).getPropertyValue('--base'),
|
|
||||||
offbase: getComputedStyle(document.documentElement).getPropertyValue('--offbase'),
|
|
||||||
muted: getComputedStyle(document.documentElement).getPropertyValue('--muted'),
|
|
||||||
};
|
|
||||||
|
|
||||||
const getThemeStyles = (): IReactReaderStyle => {
|
const getThemeStyles = (): IReactReaderStyle => {
|
||||||
const baseStyle = {
|
const baseStyle = {
|
||||||
...ReactReaderStyle,
|
...ReactReaderStyle,
|
||||||
|
|
@ -34,6 +26,14 @@ const getThemeStyles = (): IReactReaderStyle => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const colors = {
|
||||||
|
background: getComputedStyle(document.documentElement).getPropertyValue('--background'),
|
||||||
|
foreground: getComputedStyle(document.documentElement).getPropertyValue('--foreground'),
|
||||||
|
base: getComputedStyle(document.documentElement).getPropertyValue('--base'),
|
||||||
|
offbase: getComputedStyle(document.documentElement).getPropertyValue('--offbase'),
|
||||||
|
muted: getComputedStyle(document.documentElement).getPropertyValue('--muted'),
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...baseStyle,
|
...baseStyle,
|
||||||
arrow: {
|
arrow: {
|
||||||
|
|
@ -124,15 +124,16 @@ export function EPUBViewer({ className = '' }: EPUBViewerProps) {
|
||||||
setLastDocumentLocation(id as string, location.toString());
|
setLastDocumentLocation(id as string, location.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locationRef.current = location;
|
|
||||||
|
|
||||||
setEPUBPageInChapter(displayed.page, displayed.total, chapter?.label || '');
|
setEPUBPageInChapter(displayed.page, displayed.total, chapter?.label || '');
|
||||||
|
|
||||||
// Add a small delay for initial load to ensure rendition is ready
|
// Add a small delay for initial load to ensure rendition is ready
|
||||||
if (initial) {
|
if (initial) {
|
||||||
setInitialPrevLocLoad(true);
|
rendition.current.display(location.toString()).then(() => {
|
||||||
|
setInitialPrevLocLoad(true);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
|
locationRef.current = location;
|
||||||
extractPageText(bookRef.current, rendition.current);
|
extractPageText(bookRef.current, rendition.current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +148,11 @@ export function EPUBViewer({ className = '' }: EPUBViewerProps) {
|
||||||
|
|
||||||
const updateTheme = useCallback((rendition: Rendition) => {
|
const updateTheme = useCallback((rendition: Rendition) => {
|
||||||
if (!epubTheme) return; // Only apply theme if enabled
|
if (!epubTheme) return; // Only apply theme if enabled
|
||||||
|
|
||||||
|
const colors = {
|
||||||
|
foreground: getComputedStyle(document.documentElement).getPropertyValue('--foreground'),
|
||||||
|
base: getComputedStyle(document.documentElement).getPropertyValue('--base'),
|
||||||
|
};
|
||||||
|
|
||||||
rendition.themes.override('color', colors.foreground);
|
rendition.themes.override('color', colors.foreground);
|
||||||
rendition.themes.override('background', colors.base);
|
rendition.themes.override('background', colors.base);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue