@@ -10,7 +10,7 @@ import type InvioPlugin from '../main';
1010import type { recResult , vRecoveryItem } from './interfaces' ;
1111import { FILE_REC_WARNING } from './constants' ;
1212import DiffView , { TDiffType } from './abstract_diff_view' ;
13-
13+ import { Diff2HtmlConfig , html } from 'diff2html' ;
1414export default class ConflictDiffView extends DiffView {
1515 remote : recResult
1616 versions : recResult [ ] ;
@@ -81,6 +81,13 @@ export default class ConflictDiffView extends DiffView {
8181 this . makeMoreGeneralHtml ( ) ;
8282 }
8383
84+ reload ( config ?: Partial < Diff2HtmlConfig > ) {
85+ this . syncHistoryContentContainer . innerHTML =
86+ this . getDiff ( config ) as string ;
87+
88+ this . setupViewChangeBtn ( )
89+ }
90+
8491 public basicHtml ( diff : string ) : void {
8592 // set title
8693 this . titleEl . setText ( this . t ( 'diff_view_conflict_title' ) ) ;
@@ -91,11 +98,6 @@ export default class ConflictDiffView extends DiffView {
9198 cls : 'sync-history-content-container-top'
9299 } ) ;
93100
94- const viewChangeBtn = topAction . createDiv ( {
95- cls : [ 'view-action' , 'btn' ] ,
96- text : this . t ( 'view_change_btn' )
97- } )
98-
99101 const diffResetBtn = topAction . createDiv ( {
100102 cls : [ 'view-action' , 'btn' ] ,
101103 text : this . t ( 'diff_reset_btn' )
@@ -111,9 +113,27 @@ export default class ConflictDiffView extends DiffView {
111113 `The ${ this . file . basename } file has been overwritten with the online remote version.`
112114 ) ;
113115 } )
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+ } )
114133 setTooltip ( viewChangeBtn , 'Click to change diff view' , {
115134 placement : 'top' ,
116135 } ) ;
136+
117137 viewChangeBtn . addEventListener ( 'click' , e => {
118138 e . preventDefault ( ) ;
119139 this . viewOutputFormat = ( 'line-by-line' === this . viewOutputFormat ) ? 'side-by-side' : 'line-by-line' ;
@@ -122,14 +142,6 @@ export default class ConflictDiffView extends DiffView {
122142 outputFormat : this . viewOutputFormat
123143 } ) ;
124144 } )
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 ] ) ;
133145 }
134146
135147 async getInitialVersions ( ) {
0 commit comments