Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import React from 'react'
import { createPatch } from 'diff'
import { Diff2Html } from 'diff2html'
import { Revision } from 'client/types/crowi'
interface Props {
currentRevision: Revision
previousRevision: Revision
revisionDiffOpened: boolean
}
export default class RevisionDiff extends React.Component<Props> {
render() {
const { currentRevision, previousRevision, revisionDiffOpened } = this.props
let diffViewHTML = ''
if (currentRevision.body && previousRevision.body && revisionDiffOpened) {
let previousText = previousRevision.body
if (currentRevision._id == previousRevision._id) {
previousText = ''
}
const patch = createPatch(currentRevision.path, previousText, currentRevision.body, '', '')
diffViewHTML = Diff2Html.getPrettyHtml(patch)
}
const diffView = { __html: diffViewHTML }
return <div className="revision-history-diff" dangerouslySetInnerHTML={diffView} />
}
}
|