Preview PDF on 'Visual preview mode' #323 (#325)

This commit is contained in:
Antoine 2017-06-23 12:32:09 -03:00 committed by Gregory Schier
parent 732d3bb805
commit 8fa948e402
2 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import React, {PropTypes, PureComponent} from 'react';
import iconv from 'iconv-lite'; import iconv from 'iconv-lite';
import autobind from 'autobind-decorator'; import autobind from 'autobind-decorator';
import {shell} from 'electron'; import {shell} from 'electron';
import {SimplePDF} from 'simple-react-pdf';
import CodeEditor from '../codemirror/code-editor'; import CodeEditor from '../codemirror/code-editor';
import ResponseWebView from './response-webview'; import ResponseWebView from './response-webview';
import ResponseRaw from './response-raw'; import ResponseRaw from './response-raw';
@ -151,6 +152,17 @@ class ResponseViewer extends PureComponent {
url={url} url={url}
/> />
); );
} else if (previewMode === PREVIEW_MODE_FRIENDLY && ct.indexOf('application/pdf') === 0) {
const justContentType = contentType.split(';')[0];
return (
<div className="scrollable-container tall wide">
<div className="scrollable">
<SimplePDF
file={`data:${justContentType};base64,${base64Body}`}
/>
</div>
</div>
);
} else if (previewMode === PREVIEW_MODE_RAW) { } else if (previewMode === PREVIEW_MODE_RAW) {
const match = contentType.match(/charset=([\w-]+)/); const match = contentType.match(/charset=([\w-]+)/);
const charset = (match && match.length >= 2) ? match[1] : 'utf-8'; const charset = (match && match.length >= 2) ? match[1] : 'utf-8';

View File

@ -140,6 +140,7 @@
"redux": "3.3.1", "redux": "3.3.1",
"redux-thunk": "2.0.1", "redux-thunk": "2.0.1",
"reselect": "2.5.4", "reselect": "2.5.4",
"simple-react-pdf": "^1.0.8",
"srp-js": "0.2.0", "srp-js": "0.2.0",
"tough-cookie": "2.3.1", "tough-cookie": "2.3.1",
"uuid": "3.0.0", "uuid": "3.0.0",