@@ -45,6 +45,9 @@ const useWindowData = () => {
45
45
const [ leftJsonStr , setLeftJsonStr ] = React . useState ( '{}' )
46
46
const [ rightJsonStr , setRightJsonStr ] = React . useState ( '{}' )
47
47
const [ diffResult , setJYCMResult ] = React . useState ( { } ) ;
48
+ const [ leftTitle , setLeftTitle ] = React . useState ( 'Left' ) ;
49
+ const [ rightTitle , setRightTitle ] = React . useState ( 'Right' ) ;
50
+
48
51
49
52
const obData = React . useCallback ( ( ) => {
50
53
// // @ts -ignore
@@ -53,6 +56,19 @@ const useWindowData = () => {
53
56
safeJSONCallback ( window . jycmLeftJsonStr , v => setLeftJsonStr ( v ) )
54
57
// @ts -ignore
55
58
safeJSONCallback ( window . jycmRightJsonStr , v => setRightJsonStr ( v ) )
59
+
60
+ // @ts -ignore
61
+ if ( window . jycmLeftTitle ) {
62
+ // @ts -ignore
63
+ setLeftTitle ( window . jycmLeftTitle )
64
+ }
65
+
66
+ // @ts -ignore
67
+ if ( window . jycmRightTitle ) {
68
+ // @ts -ignore
69
+ setRightTitle ( window . c )
70
+ }
71
+
56
72
// @ts -ignore
57
73
if ( window . diffResult && typeof window . diffResult === 'object' ) {
58
74
// @ts -ignore
@@ -65,7 +81,9 @@ const useWindowData = () => {
65
81
return {
66
82
leftJsonStr,
67
83
rightJsonStr,
68
- diffResult
84
+ diffResult,
85
+ leftTitle,
86
+ rightTitle
69
87
}
70
88
}
71
89
@@ -74,6 +92,8 @@ function SandBox() {
74
92
leftJsonStr,
75
93
rightJsonStr,
76
94
diffResult,
95
+ leftTitle,
96
+ rightTitle
77
97
} = useWindowData ( ) ;
78
98
79
99
// use this can ave your time! see provider below
@@ -96,7 +116,7 @@ function SandBox() {
96
116
{ /* <JYCMRender leftTitle="BenchMark" rightTitle="Actual" /> */ }
97
117
< div style = { { display : "flex" , alignItems : "center" , height : "100%" } } >
98
118
< div style = { { flexGrow : 1 , height : "100%" } } >
99
- < JYCMRender leftTitle = 'Left' rightTitle = 'Right' />
119
+ < JYCMRender leftTitle = { leftTitle } rightTitle = { rightTitle } />
100
120
</ div >
101
121
< div style = { { flexBasis : "24%" , height : '100%' , display : "flex" , flexDirection : "column" } } >
102
122
< div style = { { textAlign : 'center' , fontWeight : 700 } } > Diff Detail</ div >
0 commit comments