2016-11-28 18:47:47 +01:00
|
|
|
import React from 'react'
|
|
|
|
|
2016-12-02 17:20:59 +01:00
|
|
|
const ShowPlaintext = (props) => {
|
2016-11-30 20:57:35 +01:00
|
|
|
return <div>
|
2017-01-18 02:41:53 +01:00
|
|
|
<pre style={{whiteSpace: 'pre-wrap'}}>
|
|
|
|
{props.text
|
|
|
|
? props.text
|
|
|
|
: props.diff
|
|
|
|
? diffToPre(props.diff)
|
|
|
|
: null
|
2016-11-30 20:57:35 +01:00
|
|
|
}
|
2016-11-28 18:47:47 +01:00
|
|
|
</pre>
|
|
|
|
</div>
|
2016-11-30 20:57:35 +01:00
|
|
|
}
|
|
|
|
|
2016-12-02 17:20:59 +01:00
|
|
|
export default ShowPlaintext
|
2016-11-30 20:57:35 +01:00
|
|
|
|
2017-01-18 02:41:53 +01:00
|
|
|
function diffToPre (diff) {
|
2016-12-09 23:07:42 +01:00
|
|
|
return diff.map((part, index) => (
|
2017-01-18 02:41:53 +01:00
|
|
|
part.added
|
|
|
|
? <ins key={index}>{part.value}</ins>
|
|
|
|
: part.removed
|
|
|
|
? <del key={index}>{part.value}</del>
|
|
|
|
: <span key={index}>{part.value}</span>
|
2016-11-30 20:57:35 +01:00
|
|
|
))
|
|
|
|
}
|