2021-04-28 07:41:20 -04:00
|
|
|
import React from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2021-05-21 07:32:51 -04:00
|
|
|
import { useEditorContext } from '../../../shared/context/editor-context'
|
2021-04-28 07:41:20 -04:00
|
|
|
|
|
|
|
export default function BinaryFileImage({ fileName, fileId, onLoad, onError }) {
|
2021-05-21 07:32:51 -04:00
|
|
|
const { projectId } = useEditorContext({
|
|
|
|
projectId: PropTypes.string.isRequired,
|
|
|
|
})
|
|
|
|
|
2021-04-28 07:41:20 -04:00
|
|
|
return (
|
|
|
|
<img
|
2021-05-21 07:32:51 -04:00
|
|
|
src={`/project/${projectId}/file/${fileId}`}
|
2021-04-28 07:41:20 -04:00
|
|
|
onLoad={onLoad}
|
|
|
|
onError={onError}
|
|
|
|
onAbort={onError}
|
|
|
|
alt={fileName}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
BinaryFileImage.propTypes = {
|
|
|
|
fileName: PropTypes.string.isRequired,
|
|
|
|
fileId: PropTypes.string.isRequired,
|
|
|
|
onLoad: PropTypes.func.isRequired,
|
|
|
|
onError: PropTypes.func.isRequired,
|
|
|
|
}
|