@@ -50,9 +50,14 @@ export default class EditableComponent extends Component {
50
50
51
51
updateContent ( ) {
52
52
// This could not be called on each content change, it used to change the cursor position
53
- const bookmark = this . editor . selection . getBookmark ( 2 , true ) ;
53
+ let bookmark ;
54
+ if ( this . props . focusConfig ) {
55
+ bookmark = this . editor . selection . getBookmark ( 2 , true ) ;
56
+ }
54
57
this . editor . setContent ( this . props . content ) ;
55
- this . editor . selection . moveToBookmark ( bookmark ) ;
58
+ if ( this . props . focusConfig ) {
59
+ this . editor . selection . moveToBookmark ( bookmark ) ;
60
+ }
56
61
}
57
62
58
63
executeCommand = ( ...args ) => {
@@ -70,9 +75,7 @@ export default class EditableComponent extends Component {
70
75
this . focus ( ) ;
71
76
}
72
77
73
- // We should be able to compare content instead
74
- // But I came up with externalChange due the moving cursor bugs when spitting/merging content
75
- if ( this . props . externalChange !== prevProps . externalChange ) {
78
+ if ( this . props . content !== prevProps . content ) {
76
79
this . updateContent ( ) ;
77
80
}
78
81
}
@@ -143,6 +146,7 @@ export default class EditableComponent extends Component {
143
146
const after = getHtml ( childNodes . slice ( splitIndex ) ) ;
144
147
const hasAfter = ! ! childNodes . slice ( splitIndex )
145
148
. reduce ( ( memo , node ) => memo + node . textContent , '' ) ;
149
+ this . editor . setContent ( this . props . content ) ;
146
150
if ( before ) {
147
151
this . props . splitValue ( before , hasAfter ? after : '' ) ;
148
152
}
@@ -202,7 +206,7 @@ export default class EditableComponent extends Component {
202
206
this . editor = editor ;
203
207
204
208
editor . on ( 'init' , this . onInit ) ;
205
- editor . on ( 'change focusout undo redo' , this . onChange ) ;
209
+ editor . on ( 'focusout undo redo' , this . onChange ) ;
206
210
editor . on ( 'keydown' , this . onKeyDown ) ;
207
211
editor . on ( 'paste' , this . onPaste ) ;
208
212
editor . on ( 'nodechange' , this . syncToolbar ) ;
0 commit comments