@@ -10,7 +10,7 @@ import type InvioPlugin from '../main';
10
10
import type { recResult , vRecoveryItem } from './interfaces' ;
11
11
import { FILE_REC_WARNING } from './constants' ;
12
12
import DiffView , { TDiffType } from './abstract_diff_view' ;
13
-
13
+ import { Diff2HtmlConfig , html } from 'diff2html' ;
14
14
export default class ConflictDiffView extends DiffView {
15
15
remote : recResult
16
16
versions : recResult [ ] ;
@@ -81,6 +81,13 @@ export default class ConflictDiffView extends DiffView {
81
81
this . makeMoreGeneralHtml ( ) ;
82
82
}
83
83
84
+ reload ( config ?: Partial < Diff2HtmlConfig > ) {
85
+ this . syncHistoryContentContainer . innerHTML =
86
+ this . getDiff ( config ) as string ;
87
+
88
+ this . setupViewChangeBtn ( )
89
+ }
90
+
84
91
public basicHtml ( diff : string ) : void {
85
92
// set title
86
93
this . titleEl . setText ( this . t ( 'diff_view_conflict_title' ) ) ;
@@ -91,11 +98,6 @@ export default class ConflictDiffView extends DiffView {
91
98
cls : 'sync-history-content-container-top'
92
99
} ) ;
93
100
94
- const viewChangeBtn = topAction . createDiv ( {
95
- cls : [ 'view-action' , 'btn' ] ,
96
- text : this . t ( 'view_change_btn' )
97
- } )
98
-
99
101
const diffResetBtn = topAction . createDiv ( {
100
102
cls : [ 'view-action' , 'btn' ] ,
101
103
text : this . t ( 'diff_reset_btn' )
@@ -111,9 +113,27 @@ export default class ConflictDiffView extends DiffView {
111
113
`The ${ this . file . basename } file has been overwritten with the online remote version.`
112
114
) ;
113
115
} )
116
+
117
+ // add diff to container
118
+ this . syncHistoryContentContainer . innerHTML = diff ;
119
+
120
+ // add history lists and diff to DOM
121
+ // this.contentEl.appendChild(this.leftHistory[0]);
122
+ this . contentEl . appendChild ( this . syncHistoryContentContainer ?. parentNode ) ;
123
+ this . setupViewChangeBtn ( )
124
+ this . contentEl . appendChild ( this . rightHistory [ 0 ] ) ;
125
+ }
126
+
127
+ setupViewChangeBtn ( ) {
128
+ const target = this . containerEl . querySelector ( '.d2h-file-wrapper' ) ;
129
+ const viewChangeBtn = target . createDiv ( {
130
+ cls : [ 'btn' , 'style-view-toggle' ] ,
131
+ text : this . t ( 'view_change_btn' )
132
+ } )
114
133
setTooltip ( viewChangeBtn , 'Click to change diff view' , {
115
134
placement : 'top' ,
116
135
} ) ;
136
+
117
137
viewChangeBtn . addEventListener ( 'click' , e => {
118
138
e . preventDefault ( ) ;
119
139
this . viewOutputFormat = ( 'line-by-line' === this . viewOutputFormat ) ? 'side-by-side' : 'line-by-line' ;
@@ -122,14 +142,6 @@ export default class ConflictDiffView extends DiffView {
122
142
outputFormat : this . viewOutputFormat
123
143
} ) ;
124
144
} )
125
-
126
- // add diff to container
127
- this . syncHistoryContentContainer . innerHTML = diff ;
128
-
129
- // add history lists and diff to DOM
130
- // this.contentEl.appendChild(this.leftHistory[0]);
131
- this . contentEl . appendChild ( this . syncHistoryContentContainer ?. parentNode ) ;
132
- this . contentEl . appendChild ( this . rightHistory [ 0 ] ) ;
133
145
}
134
146
135
147
async getInitialVersions ( ) {
0 commit comments