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