import React from 'react'; import ReactDom from 'react-dom'; import SharedFileView from './components/shared-file-view/shared-file-view'; import SharedFileViewTip from './components/shared-file-view/shared-file-view-tip'; import { gettext } from './utils/constants'; import './css/image-file-view.css'; const { fileName, rawPath, err, prevImgPath, nextImgPath } = window.shared.pageOptions; const prevImgURL = `?p=${encodeURIComponent(prevImgPath)}`; const nextImgURL = `?p=${encodeURIComponent(nextImgPath)}`; class SharedFileViewImage extends React.Component { render() { return } />; } } class FileContent extends React.Component { componentDidMount() { document.addEventListener('keydown', (e) => { if (prevImgPath && e.keyCode == 37) { // press '<-' location.href = prevImgURL; } if (nextImgPath && e.keyCode == 39) { // press '->' location.href = nextImgURL; } }); } render() { if (err) { return ; } return (
{prevImgPath && ( )} {nextImgPath && ( )} {fileName}
); } } ReactDom.render(, document.getElementById('wrapper'));