@@ -28,6 +28,8 @@ export interface ReactDiffViewerProps {
28
28
newValue : string ;
29
29
// Enable/Disable split view.
30
30
splitView ?: boolean ;
31
+ // Set line Offset
32
+ linesOffset ?: number ;
31
33
// Enable/Disable word diff.
32
34
disableWordDiff ?: boolean ;
33
35
// JsDiff text diff method from https://github.com/kpdecker/jsdiff/tree/v4.0.1#api
@@ -83,6 +85,7 @@ class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiffViewerSt
83
85
extraLinesSurroundingDiff : 3 ,
84
86
showDiffOnly : true ,
85
87
useDarkTheme : false ,
88
+ linesOffset : 0
86
89
} ;
87
90
88
91
public static propTypes = {
@@ -106,6 +109,7 @@ class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiffViewerSt
106
109
PropTypes . string ,
107
110
PropTypes . element ,
108
111
] ) ,
112
+ linesOffset : PropTypes . number
109
113
} ;
110
114
111
115
public constructor ( props : ReactDiffViewerProps ) {
@@ -441,12 +445,13 @@ class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiffViewerSt
441
445
* Generates the entire diff view.
442
446
*/
443
447
private renderDiff = ( ) : JSX . Element [ ] => {
444
- const { oldValue, newValue, splitView, disableWordDiff, compareMethod } = this . props ;
448
+ const { oldValue, newValue, splitView, disableWordDiff, compareMethod, linesOffset } = this . props ;
445
449
const { lineInformation, diffLines } = computeLineInformation (
446
450
oldValue ,
447
451
newValue ,
448
452
disableWordDiff ,
449
453
compareMethod ,
454
+ linesOffset
450
455
) ;
451
456
const extraLines = this . props . extraLinesSurroundingDiff < 0
452
457
? 0
0 commit comments