2017-02-17 20:17:04 +01:00
|
|
|
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 = <thead>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
#
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Text
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
X
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Y
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Width
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Height
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
Font
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
const textItemRows = textItems.map((textItem, i) => <tr key={ i } style={ textItem.annotation ? {
|
|
|
|
color: textItem.annotation.color
|
|
|
|
} : null }>
|
|
|
|
<td>
|
|
|
|
<div style={ { textAlign: 'center' } }>
|
|
|
|
{ i }
|
|
|
|
</div>
|
|
|
|
<div style={ { textAlign: 'center' } }>
|
|
|
|
{ textItem.annotation ? textItem.annotation.category : '' }
|
|
|
|
</div>
|
2017-03-10 09:52:29 +01:00
|
|
|
<div style={ { textAlign: 'center', color: 'brown' } }>
|
2017-03-10 12:10:58 +01:00
|
|
|
{ textItem.type ? textItem.type.name : '' }
|
2017-03-10 09:52:29 +01:00
|
|
|
</div>
|
2017-03-10 08:49:40 +01:00
|
|
|
<div style={ { textAlign: 'center', color: 'orange' } }>
|
2017-03-24 12:30:35 +01:00
|
|
|
{ textItem.parsedElements && textItem.parsedElements.footnoteLinks.length > 0 ? <div>
|
|
|
|
Footnote-Link
|
|
|
|
</div> : '' }
|
|
|
|
{ textItem.parsedElements && textItem.parsedElements.containLinks ? <div>
|
|
|
|
Link
|
|
|
|
</div> : '' }
|
|
|
|
{ textItem.lineFormat ? <div>
|
|
|
|
{ textItem.lineFormat.name }
|
|
|
|
</div> : '' }
|
|
|
|
{ textItem.unopenedFormat ? <div>
|
|
|
|
Unopened
|
|
|
|
{ ' ' + textItem.unopenedFormat.name }
|
|
|
|
</div> : '' }
|
|
|
|
{ textItem.parsedElements && textItem.parsedElements.inlineFormats > 0 ? <div>
|
|
|
|
{ textItem.parsedElements.inlineFormats + 'x Bold/Italic' }
|
|
|
|
</div> : '' }
|
|
|
|
{ textItem.unclosedFormat ? <div>
|
|
|
|
Unclosed
|
|
|
|
{ ' ' + textItem.unclosedFormat.name }
|
|
|
|
</div> : '' }
|
2017-03-10 08:49:40 +01:00
|
|
|
</div>
|
2017-02-17 20:17:04 +01:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ showWhitespaces ? (
|
|
|
|
<pre style={ textItem.annotation ? {
|
|
|
|
color: textItem.annotation.color,
|
|
|
|
display: 'inline-block',
|
|
|
|
} : {
|
|
|
|
display: 'inline-block'
|
|
|
|
} }>{ textItem.text }</pre>
|
|
|
|
) : (textItem.text) }
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ textItem.x }
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ textItem.y }
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ textItem.width }
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ textItem.height }
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{ textItem.font }
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
2017-02-21 08:05:00 +01:00
|
|
|
<Table responsive condensed bordered>
|
2017-02-17 20:17:04 +01:00
|
|
|
{ tableHeader }
|
|
|
|
<tbody>
|
|
|
|
{ textItemRows }
|
|
|
|
</tbody>
|
|
|
|
</Table>
|
2017-03-10 08:49:40 +01:00
|
|
|
);
|
2017-02-17 20:17:04 +01:00
|
|
|
}
|
|
|
|
}
|