import React from 'react'; import Table from 'react-bootstrap/lib/Table' // Displays an array of TextItem as a table export default class TextItemTable extends React.Component { static propTypes = { textItems: React.PropTypes.array.isRequired, showWhitespaces: React.PropTypes.bool }; render() { const {showWhitespaces, textItems} = this.props; const tableHeader = # Text X Y Width Height Font const textItemRows = textItems.map((textItem, i) =>
{ i }
{ textItem.annotation ? textItem.annotation.category : '' }
{ textItem.type ? textItem.type.name : '' }
{ textItem.parsedElements && textItem.parsedElements.footnoteLinks.length > 0 ?
Footnote-Link
: '' } { textItem.parsedElements && textItem.parsedElements.containLinks ?
Link
: '' } { textItem.lineFormat ?
{ textItem.lineFormat.name }
: '' } { textItem.unopenedFormat ?
Unopened { ' ' + textItem.unopenedFormat.name }
: '' } { textItem.parsedElements && textItem.parsedElements.inlineFormats > 0 ?
{ textItem.parsedElements.inlineFormats + 'x Bold/Italic' }
: '' } { textItem.unclosedFormat ?
Unclosed { ' ' + textItem.unclosedFormat.name }
: '' }
{ showWhitespaces ? (
{ textItem.text }
) : (textItem.text) } { textItem.x } { textItem.y } { textItem.width } { textItem.height } { textItem.font } ) return ( { tableHeader } { textItemRows }
); } }