mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 19:11:56 +02:00
Pull project id from `EditorContext` instead of `window` in file views GitOrigin-RevId: 78c2686d8bcd1e95414631ca77143fd9ae3edbc6
27 lines
673 B
JavaScript
27 lines
673 B
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { useEditorContext } from '../../../shared/context/editor-context'
|
|
|
|
export default function BinaryFileImage({ fileName, fileId, onLoad, onError }) {
|
|
const { projectId } = useEditorContext({
|
|
projectId: PropTypes.string.isRequired,
|
|
})
|
|
|
|
return (
|
|
<img
|
|
src={`/project/${projectId}/file/${fileId}`}
|
|
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,
|
|
}
|