import { AnnotationsLayer } from "@thorium/components/AnnotationsLayer"; import { PDFViewer } from "@thorium/components/PDFViewer"; import { q } from "@thorium/context/AppContext"; import Button from "@thorium/ui/Button"; import { GlbLivePreview } from "@thorium/ui/FilesMenu"; import { Icon } from "@thorium/ui/Icon"; import { SVGImageLoader } from "@thorium/ui/SVGImageLoader"; import { cn } from "@thorium/utils/cn"; import { Suspense, useEffect, useRef, useState } from "react"; export function DocViewer({ id, filePath, annotations, }: { id: number; filePath: string; annotations: [number, number, number][][][]; }) { const ext1 = filePath.match(/\..{3,4}$/gi); const ext = ext1 ? ext1[0].replace(".", "").toLowerCase() : ""; switch (ext) { case "glb": case "gltf": return ; case "mov": case "mp4": case "ogv": case "webm": case "m4v": return ; case "pdf": return ( { await q.documents.addAnnotation.netSend({ annotation: points, documentId: id, page, }); }} onClearAnnotations={(page) => q.documents.clearAnnotations.netSend({ documentId: id, page }) } onUndoAnnotation={(page) => q.documents.undoAnnotations.netSend({ documentId: id, page })} /> ); case "m4a": case "wav": case "mp3": case "ogg": case "aiff": case "aif": return ; case "svg": return ( ); case "jpg": case "jpeg": case "png": case "apng": case "gif": case "webp": case "avif": return ; default: return null; } } function ImagePreview({ id, filePath, annotations, }: { id: number; filePath: string; annotations: [number, number, number][][][]; }) { return ( <> {annotations[0] && annotations[0].length > 0 ? (
) : null}
{ await q.documents.addAnnotation.netSend({ annotation: points, documentId: id, page: 0, }); }} />
); } function AudioPlayer({ src }: { src: string }) { const [playing, setPlaying] = useState(false); const audioRef = useRef(null); return (
); } function VideoPlayer({ src }: { src: string }) { const [playing, setPlaying] = useState(false); const videoRef = useRef(null); const [buttonShown, setButtonShown] = useState(false); const disappearRef = useRef | null>(null); useEffect(() => { return () => { if (disappearRef.current) { clearTimeout(disappearRef.current); } }; }); return (
); }