mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Some checks failed
Build Docker Images / Build docker images (push) Has been cancelled
Build Self-Hosting Docker Images / Build self-host docker images (push) Has been cancelled
Run tests / Run Codebase tests (push) Has been cancelled
Run tests / Build docker images (push) Has been cancelled
* fix: Library Header layout shift * Bump Github Actions versions. * Self-Hosting Changes * Fix Minio Environment Variable * Just make pdfs successful, due to lack of PDFHandler * Fix issue where flag was set wrong * Added an NGINX Example file * Add some documentation for self-hosting via Docker Compose * Make some adjustments to Puppeteer due to failing sites. * adjust timings * Add start of Mail Service * Fix Docker Files * More email service stuff * Add Guide to use Zapier for Email-Importing. * Ensure that if no env is provided it uses the old email settings * Add some instructions for self-hosted email * Add SNS Endpoints for Mail Watcher * Add steps and functionality for using SES and SNS for email * Uncomment a few jobs. * Added option for Firefox for parser. Was having issues with Chromium on Docker. * Add missing space. Co-authored-by: Russ Taylor <729694+russtaylor@users.noreply.github.com> * Fix some wording on the Guide * update browser extension to handle self-hosted instances * add slight documentation to options page * Fix MV * Do raw handlers for Medium * Fix images in Medium * Update self-hosting/GUIDE.md Co-authored-by: Mike Baker <1426795+mbaker3@users.noreply.github.com> * Update Guide with other variables * Add The Verge to JS-less handlers * Update regex and image-proxy * Update self-hosting/nginx/nginx.conf Co-authored-by: Mike Baker <1426795+mbaker3@users.noreply.github.com> * Update regex and image-proxy * Update self-hosting/docker-compose/docker-compose.yml Co-authored-by: Mike Baker <1426795+mbaker3@users.noreply.github.com> * Fix Minio for Export * Merge to main * Update GUIDE with newer NGINX * Update nginx config to include api/save route * Enable Native PDF View for PDFS * Enable Native PDF View for PDFS * feat:lover packages test * feat:working build * feat:alpine build * docs:api dockerfile docs * Write a PDF.js wrapper to replace pspdfkit * Revert changes for replication, set settings to have default mode * build folder got removed due to gitignore on pdf * Add Box shadow to pdf pages * Add Toggle for Progress in PDFS, enabled native viewer toggle * Update node version to LTS * Update node version to LTS * Fix Linting issues * Fix Linting issues * Make env variable nullable * Add touchend listener for mobile * Make changes to PDF for mobile * fix(android): change serverUrl to selfhosted first * feat:2 stage alpine content fetch * feat:separated start script * fix:changed to node 22 * Add back youtube functionality and add guide * trigger build * Fix cache issue on YouTube * Allow empty AWS_S3_ENDPOINT * Allow empty AWS_S3_ENDPOINT * Add GCHR for all images * Add GCHR For self hosting. * Add GCHR For self hosting. * Test prebuilt. * Test prebuilt * Test prebuilt... * Fix web image * Remove Web Image (For now) * Move docker-compose to images * Move docker-compose files to correct locations * Remove the need for ARGS * Update packages, and Typescript versions * Fix * Fix issues with build on Web * Correct push * Fix Linting issues * Fix Trace import * Add missing types * Fix Tasks * Add information into guide about self-build * Fix issues with PDF Viewer --------- Co-authored-by: keumky2 <keumky2@woowahan.com> Co-authored-by: William Theaker <wtheaker@nvidia.com> Co-authored-by: Russ Taylor <729694+russtaylor@users.noreply.github.com> Co-authored-by: David Adams <david@dadams2.com> Co-authored-by: Mike Baker <1426795+mbaker3@users.noreply.github.com> Co-authored-by: m1xxos <66390094+m1xxos@users.noreply.github.com> Co-authored-by: Adil <mr.adil777@gmail.com>
107 lines
3 KiB
TypeScript
107 lines
3 KiB
TypeScript
import { VStack } from '../../../elements/LayoutPrimitives'
|
|
import React, { useEffect, useState } from 'react'
|
|
import 'react-sliding-pane/dist/react-sliding-pane.css'
|
|
import 'pdfjs-dist/web/pdf_viewer.css'
|
|
import { PDFDocumentProxy } from 'pdfjs-dist'
|
|
|
|
export type PdfSidebarProps = {
|
|
sidebarActive: boolean
|
|
|
|
pdfDocument: PDFDocumentProxy | undefined
|
|
|
|
totalPages: number
|
|
activePage: number
|
|
setPage: (page: number) => void
|
|
}
|
|
|
|
export default function PdfSideBar(props: PdfSidebarProps) {
|
|
const [images, setImages] = useState<string[]>([])
|
|
|
|
useEffect(() => {
|
|
;(async () => {
|
|
if (props.pdfDocument) {
|
|
const propsArray = [...Array(props.pdfDocument.numPages ?? 0)];
|
|
|
|
const dataUrls = await Promise.all(propsArray.map(async (_it, i) => {
|
|
const page = await props.pdfDocument!.getPage(i + 1)
|
|
const viewport = page.getViewport({ scale: 0.3 })
|
|
const canvas = document.createElement('canvas')
|
|
const ctx = canvas.getContext('2d')
|
|
|
|
canvas.width = viewport.width
|
|
canvas.height = viewport.height
|
|
if (ctx) {
|
|
const task = page.render({ canvasContext: ctx, viewport: viewport })
|
|
return task.promise.then(() => canvas.toDataURL())
|
|
}
|
|
|
|
return "";
|
|
}))
|
|
|
|
console.log("Setting Data Urls");
|
|
setImages(dataUrls)
|
|
}
|
|
})()
|
|
}, [props.pdfDocument])
|
|
|
|
if (!props.sidebarActive) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<VStack
|
|
distribution="start"
|
|
css={{
|
|
alignItems: 'flex-start',
|
|
position: 'fixed',
|
|
left: '0px',
|
|
top: '100px',
|
|
padding: '7px',
|
|
paddingTop: '10px',
|
|
width: '250px',
|
|
height: 'calc(100% - 100px)',
|
|
borderTop: '1px solid black',
|
|
boxShadow: 'rgba(61, 66, 78, 0.5) 0px 1px 2px 0px',
|
|
background: '$thBackground2',
|
|
overflow: 'scroll',
|
|
}}
|
|
>
|
|
{[...Array(props.totalPages)].map((_it, idx) => (
|
|
<VStack
|
|
key={`pdf-page-${idx}`}
|
|
css={{ width: '80%', margin: 'auto', height: '100%' }}
|
|
onClick={() => props.setPage(idx + 1)}
|
|
>
|
|
<div
|
|
style={
|
|
idx == props.activePage - 1
|
|
? { outline: '5px solid var(--colors-thBackgroundActive)', width: '100%' }
|
|
: { width: '100%', height: '100%' }
|
|
}
|
|
>
|
|
<img
|
|
width={'100%'}
|
|
alt={`page-${idx + 1}`}
|
|
src={images[idx]}
|
|
style={{ display: 'block', objectFit: 'contain' }}
|
|
/>
|
|
</div>
|
|
<div
|
|
style={{ margin: 'auto', marginTop: '3px', marginBottom: '3px' }}
|
|
>
|
|
<span
|
|
style={{
|
|
backgroundColor: 'var(--colors-thLeftMenuBackground)',
|
|
paddingLeft: '10px',
|
|
paddingRight: '10px',
|
|
borderRadius: '10px',
|
|
}}
|
|
>
|
|
{idx + 1}
|
|
</span>
|
|
</div>
|
|
</VStack>
|
|
))}
|
|
</VStack>
|
|
)
|
|
}
|