1 | import * as CodeMirror from '../../';
|
2 |
|
3 | /**
|
4 | * Tracks changes in chunks from original to new.
|
5 | */
|
6 | export interface MergeViewDiffChunk {
|
7 | editFrom: number;
|
8 | editTo: number;
|
9 | origFrom: number;
|
10 | origTo: number;
|
11 | }
|
12 |
|
13 | export interface DiffView {
|
14 | /**
|
15 | * Forces the view to reload.
|
16 | */
|
17 | forceUpdate(): (mode: string) => void;
|
18 |
|
19 | /**
|
20 | * Sets whether or not the merge view should show the differences between the editor views.
|
21 | */
|
22 | setShowDifferences(showDifferences: boolean): void;
|
23 | }
|
24 |
|
25 | export interface MergeView {
|
26 | /**
|
27 | * Returns the editor instance.
|
28 | */
|
29 | editor(): CodeMirror.Editor;
|
30 |
|
31 | /**
|
32 | * Left side of the merge view.
|
33 | */
|
34 | left?: DiffView | undefined;
|
35 | leftChunks(): MergeViewDiffChunk[] | undefined;
|
36 | leftOriginal(): CodeMirror.Editor | undefined;
|
37 |
|
38 | /**
|
39 | * Right side of the merge view.
|
40 | */
|
41 | right?: DiffView | undefined;
|
42 | rightChunks(): MergeViewDiffChunk[] | undefined;
|
43 | rightOriginal(): CodeMirror.Editor | undefined;
|
44 |
|
45 | /**
|
46 | * Sets whether or not the merge view should show the differences between the editor views.
|
47 | */
|
48 | setShowDifferences(showDifferences: boolean): void;
|
49 | }
|
50 |
|
51 | export interface MergeViewConstructor {
|
52 | new (element: HTMLElement, options?: MergeViewConfiguration): MergeView;
|
53 | (element: HTMLElement, options?: MergeViewConfiguration): MergeView;
|
54 | }
|
55 |
|
56 | /**
|
57 | * Options available to MergeView.
|
58 | */
|
59 | export interface MergeViewConfiguration extends CodeMirror.EditorConfiguration {
|
60 | /**
|
61 | * Determines whether the original editor allows editing. Defaults to false.
|
62 | */
|
63 | allowEditingOriginals?: boolean | undefined;
|
64 |
|
65 | /**
|
66 | * When true stretches of unchanged text will be collapsed. When a number is given, this indicates the amount
|
67 | * of lines to leave visible around such stretches (which defaults to 2). Defaults to false.
|
68 | */
|
69 | collapseIdentical?: boolean | number | undefined;
|
70 |
|
71 | /**
|
72 | * Sets the style used to connect changed chunks of code. By default, connectors are drawn. When this is set to "align",
|
73 | * the smaller chunk is padded to align with the bigger chunk instead.
|
74 | */
|
75 | connect?: string | undefined;
|
76 |
|
77 | /**
|
78 | * Callback for when stretches of unchanged text are collapsed.
|
79 | */
|
80 | onCollapse?(mergeView: MergeView, line: number, size: number, mark: CodeMirror.TextMarker<CodeMirror.MarkerRange>): void;
|
81 |
|
82 | /**
|
83 | * Provides original version of the document to be shown on the right of the editor.
|
84 | */
|
85 | orig?: string | undefined;
|
86 |
|
87 | /**
|
88 | * Provides original version of the document to be shown on the left of the editor.
|
89 | * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
|
90 | */
|
91 | origLeft?: string | undefined;
|
92 |
|
93 | /**
|
94 | * Provides original version of document to be shown on the right of the editor.
|
95 | * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
|
96 | */
|
97 | origRight?: string | undefined;
|
98 |
|
99 | /**
|
100 | * Determines whether buttons that allow the user to revert changes are shown. Defaults to true.
|
101 | */
|
102 | revertButtons?: boolean | undefined;
|
103 |
|
104 | revertChunk?: ((
|
105 | mv: MergeView,
|
106 | from: CodeMirror.Editor,
|
107 | fromStart: CodeMirror.Position,
|
108 | fromEnd: CodeMirror.Position,
|
109 | to: CodeMirror.Editor,
|
110 | toStart: CodeMirror.Position,
|
111 | toEnd: CodeMirror.Position
|
112 | ) => void) | undefined;
|
113 |
|
114 | /**
|
115 | * When true, changed pieces of text are highlighted. Defaults to true.
|
116 | */
|
117 | showDifferences?: boolean | undefined;
|
118 | }
|
119 |
|
120 | declare module '../../' {
|
121 | const MergeView: MergeViewConstructor;
|
122 |
|
123 | interface CommandActions {
|
124 | /** Move cursor to the next diff */
|
125 | goNextDiff(cm: Editor): void;
|
126 |
|
127 | /** Move cursor to the previous diff */
|
128 | goPrevDiff(cm: Editor): void;
|
129 | }
|
130 | }
|