-
-
Notifications
You must be signed in to change notification settings - Fork 309
Expand file tree
/
Copy pathindex.d.ts
More file actions
141 lines (141 loc) · 5.73 KB
/
index.d.ts
File metadata and controls
141 lines (141 loc) · 5.73 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { LineInformation, DiffMethod } from './compute-lines';
import { ReactDiffViewerStylesOverride } from './styles';
export declare enum LineNumberPrefix {
LEFT = "L",
RIGHT = "R"
}
export interface ReactDiffViewerProps {
oldValue: string;
newValue: string;
splitView?: boolean;
disableWordDiff?: boolean;
compareMethod?: DiffMethod;
extraLinesSurroundingDiff?: number;
hideLineNumbers?: boolean;
showDiffOnly?: boolean;
renderContent?: (source: string) => JSX.Element;
codeFoldMessageRenderer?: (totalFoldedLines: number, leftStartLineNumber: number, rightStartLineNumber: number) => JSX.Element;
onLineNumberClick?: (lineId: string, event: React.MouseEvent<HTMLTableCellElement>) => void;
onLineContentClick?: (params: {
direction: 'leftCode' | 'rightCode';
words: string;
}) => void;
highlightLines?: string[];
styles?: ReactDiffViewerStylesOverride;
useDarkTheme?: boolean;
leftTitle?: string | JSX.Element;
rightTitle?: string | JSX.Element;
}
export interface ReactDiffViewerState {
expandedBlocks?: number[];
}
declare class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiffViewerState> {
private styles;
static defaultProps: ReactDiffViewerProps;
static propTypes: {
oldValue: PropTypes.Validator<string>;
newValue: PropTypes.Validator<string>;
splitView: PropTypes.Requireable<boolean>;
disableWordDiff: PropTypes.Requireable<boolean>;
compareMethod: PropTypes.Requireable<any>;
renderContent: PropTypes.Requireable<(...args: any[]) => any>;
onLineNumberClick: PropTypes.Requireable<(...args: any[]) => any>;
extraLinesSurroundingDiff: PropTypes.Requireable<number>;
styles: PropTypes.Requireable<object>;
hideLineNumbers: PropTypes.Requireable<boolean>;
showDiffOnly: PropTypes.Requireable<boolean>;
highlightLines: PropTypes.Requireable<string[]>;
leftTitle: PropTypes.Requireable<string | PropTypes.ReactElementLike>;
rightTitle: PropTypes.Requireable<string | PropTypes.ReactElementLike>;
};
constructor(props: ReactDiffViewerProps);
/**
* Resets code block expand to the initial stage. Will be exposed to the parent component via
* refs.
*/
resetCodeBlocks: () => boolean;
/**
* Pushes the target expanded code block to the state. During the re-render,
* this value is used to expand/fold unmodified code.
*/
private onBlockExpand;
/**
* Computes final styles for the diff viewer. It combines the default styles with the user
* supplied overrides. The computed styles are cached with performance in mind.
*
* @param styles User supplied style overrides.
*/
private computeStyles;
/**
* Returns a function with clicked line number in the closure. Returns an no-op function when no
* onLineNumberClick handler is supplied.
*
* @param id Line id of a line.
*/
private onLineNumberClickProxy;
private onLineContentClickProxy;
/**
* Maps over the word diff and constructs the required React elements to show word diff.
*
* @param diffArray Word diff information derived from line information.
* @param renderer Optional renderer to format diff words. Useful for syntax highlighting.
*/
private renderWordDiff;
/**
* Maps over the line diff and constructs the required react elements to show line diff. It calls
* renderWordDiff when encountering word diff. This takes care of both inline and split view line
* renders.
*
* @param lineNumber Line number of the current line.
* @param type Type of diff of the current line.
* @param prefix Unique id to prefix with the line numbers.
* @param value Content of the line. It can be a string or a word diff array.
* @param additionalLineNumber Additional line number to be shown. Useful for rendering inline
* diff view. Right line number will be passed as additionalLineNumber.
* @param additionalPrefix Similar to prefix but for additional line number.
*/
private renderLine;
/**
* Generates lines for split view.
*
* @param obj Line diff information.
* @param obj.left Life diff information for the left pane of the split view.
* @param obj.right Life diff information for the right pane of the split view.
* @param index React key for the lines.
*/
private renderSplitView;
/**
* Generates lines for inline view.
*
* @param obj Line diff information.
* @param obj.left Life diff information for the added section of the inline view.
* @param obj.right Life diff information for the removed section of the inline view.
* @param index React key for the lines.
*/
renderInlineView: ({ left, right }: LineInformation, index: number) => JSX.Element;
/**
* Returns a function with clicked block number in the closure.
*
* @param id Cold fold block id.
*/
private onBlockClickProxy;
/**
* Generates cold fold block. It also uses the custom message renderer when available to show
* cold fold messages.
*
* @param num Number of skipped lines between two blocks.
* @param blockNumber Code fold block id.
* @param leftBlockLineNumber First left line number after the current code fold block.
* @param rightBlockLineNumber First right line number after the current code fold block.
*/
private renderSkippedLineIndicator;
/**
* Generates the entire diff view.
*/
private renderDiff;
render: () => JSX.Element;
}
export default DiffViewer;
export { ReactDiffViewerStylesOverride, DiffMethod };