mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 07:33:36 -05:00
577497b655
[misc] add readonly mirror of full project content on the client GitOrigin-RevId: 940bd93bfd587f83ca383d10fc44579b38fc3e88
29 lines
729 B
TypeScript
29 lines
729 B
TypeScript
import { useProjectContext } from '../../../shared/context/project-context'
|
|
import { useSnapshotContext } from '@/features/ide-react/context/snapshot-context'
|
|
import { BinaryFile } from '@/features/file-view/types/binary-file'
|
|
|
|
export default function FileViewImage({
|
|
file,
|
|
onLoad,
|
|
onError,
|
|
}: {
|
|
file: BinaryFile
|
|
onLoad: () => void
|
|
onError: () => void
|
|
}) {
|
|
const { _id: projectId } = useProjectContext()
|
|
const { fileTreeFromHistory } = useSnapshotContext()
|
|
|
|
return (
|
|
<img
|
|
src={
|
|
fileTreeFromHistory
|
|
? `/project/${projectId}/blob/${file.hash}`
|
|
: `/project/${projectId}/file/${file.id}`
|
|
}
|
|
onLoad={onLoad}
|
|
onError={onError}
|
|
alt={file.name}
|
|
/>
|
|
)
|
|
}
|