import React, { PropTypes } from 'react' import ContentLoader from './ContentLoader' import { MessageUtils } from '../../flow/utils.js' import CodeEditor from '../common/CodeEditor' import {formatSize} from '../../utils.js' const views = [ViewAuto, ViewImage, ViewJSON, ViewRaw, ViewFile] ViewImage.regex = /^image\/(png|jpe?g|gif|vnc.microsoft.icon|x-icon)$/i ViewImage.matches = msg => ViewImage.regex.test(MessageUtils.getContentType(msg)) ViewImage.propTypes = { flow: PropTypes.object.isRequired, message: PropTypes.object.isRequired, } export function ViewImage({ flow, message }) { return (
{json}} ViewAuto.matches = () => false ViewAuto.findView = msg => views.find(v => v.matches(msg)) || views[views.length - 1] ViewAuto.propTypes = { message: React.PropTypes.object.isRequired, flow: React.PropTypes.object.isRequired, } export function ViewAuto({ message, flow, update_content }) { const View = ViewAuto.findView(message) if (View.textView) { return