@@ -40,12 +40,13 @@ var DiffArea = React.createClass({
40
40
var newState = { } ;
41
41
42
42
// Text changed ?
43
- var contentChanged = this . state . rightState . getCurrentContent ( ) !== rightState . getCurrentContent ( ) ;
43
+ var contentChanged = this . state . rightState . getCurrentContent ( )
44
+ !== rightState . getCurrentContent ( ) ;
44
45
45
46
// Update diffs
46
47
if ( contentChanged ) {
47
- var right = rightState . getCurrentContent ( ) . getPlainText ( ) ;
48
48
var left = this . props . left ;
49
+ var right = rightState . getCurrentContent ( ) . getPlainText ( ) ;
49
50
50
51
var diffs = computeDiff ( left , right ) ;
51
52
@@ -58,6 +59,7 @@ var DiffArea = React.createClass({
58
59
} ) ;
59
60
} else {
60
61
// Just update the EditorState
62
+ newState . leftState = this . state . leftState ;
61
63
newState . rightState = rightState ;
62
64
}
63
65
@@ -68,8 +70,8 @@ var DiffArea = React.createClass({
68
70
return < div className = 'diffarea' >
69
71
< div className = 'left' >
70
72
< Draft . Editor
71
- readOnly = { true }
72
73
editorState = { this . state . leftState }
74
+ readOnly = { true }
73
75
/>
74
76
</ div >
75
77
< div className = 'right' >
@@ -96,14 +98,8 @@ function editorStateFromText(text, decorator) {
96
98
return Draft . EditorState . createWithContent ( content , decorator ) ;
97
99
}
98
100
99
- // Check for changes
100
- function contentStateHasChanged ( oldEditorState , newEditorState ) {
101
- return ( ! oldEditorState || ! newEditorState )
102
- || oldEditorState . getCurrentContent ( ) !== newEditorState . getCurrentContent ( ) ;
103
- }
104
-
105
101
function computeDiff ( txt1 , txt2 ) {
106
- var diffs = DMP . diff_main ( left , right ) ;
102
+ var diffs = DMP . diff_main ( txt1 , txt2 ) ;
107
103
// Simplify diffs a bit to make it human readable (but non optimal)
108
104
DMP . diff_cleanupSemantic ( diffs ) ;
109
105
return diffs ;
@@ -112,10 +108,10 @@ function computeDiff(txt1, txt2) {
112
108
// Decorators
113
109
114
110
var InsertedSpan = function ( props ) {
115
- return < span { ...props } style = { { backgroundColor : '#eaffea' } } > { props . children } </ span > ;
111
+ return < span { ...props } className = "inserted" > { props . children } </ span > ;
116
112
} ;
117
113
var RemovedSpan = function ( props ) {
118
- return < span { ...props } style = { { backgroundColor : '#ffecec' } } > { props . children } </ span > ;
114
+ return < span { ...props } className = "removed" > { props . children } </ span > ;
119
115
} ;
120
116
121
117
/**
0 commit comments