Skip to content

Commit

Permalink
Preview PDF on 'Visual preview mode' Kong#323
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine38660 committed Jun 23, 2017
1 parent 2d08bfb commit df56d3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/ui/components/viewers/response-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {PropTypes, PureComponent} from 'react';
import iconv from 'iconv-lite';
import autobind from 'autobind-decorator';
import {shell} from 'electron';
import {SimplePDF} from 'simple-react-pdf';
import CodeEditor from '../codemirror/code-editor';
import ResponseWebView from './response-webview';
import ResponseRaw from './response-raw';
Expand Down Expand Up @@ -151,6 +152,17 @@ class ResponseViewer extends PureComponent {
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) {
const match = contentType.match(/charset=([\w-]+)/);
const charset = (match && match.length >= 2) ? match[1] : 'utf-8';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"redux": "3.3.1",
"redux-thunk": "2.0.1",
"reselect": "2.5.4",
"simple-react-pdf": "^1.0.8",
"srp-js": "0.2.0",
"tough-cookie": "2.3.1",
"uuid": "3.0.0",
Expand Down

0 comments on commit df56d3d

Please sign in to comment.