2018-07-05 04:49:12 +02:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2018-08-02 02:53:38 +02:00
|
|
|
import { stopContextMenu } from 'util/contextMenu';
|
2018-07-05 04:49:12 +02:00
|
|
|
|
|
|
|
type Props = {
|
2018-08-02 02:53:38 +02:00
|
|
|
source: string,
|
2018-07-05 04:49:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class PdfViewer extends React.PureComponent<Props> {
|
2018-10-15 02:27:09 +02:00
|
|
|
constructor(props: Props) {
|
2018-07-05 07:24:04 +02:00
|
|
|
super(props);
|
|
|
|
this.viewer = React.createRef();
|
|
|
|
}
|
|
|
|
|
2018-10-15 02:27:09 +02:00
|
|
|
viewer: { current: any };
|
|
|
|
|
2018-07-05 04:49:12 +02:00
|
|
|
render() {
|
|
|
|
const { source } = this.props;
|
|
|
|
return (
|
2018-08-02 02:53:38 +02:00
|
|
|
<div className="file-render__viewer" onContextMenu={stopContextMenu}>
|
|
|
|
<webview ref={this.viewer} src={`chrome://pdf-viewer/index.html?src=file://${source}`} />
|
2018-07-05 07:24:04 +02:00
|
|
|
</div>
|
2018-07-05 04:49:12 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PdfViewer;
|