Closed DZGoldman closed 7 years ago
Not sure if that explanation was clear: essentially, these two lines in modifyBlocks
are the problem:
frag = extractContentsOfRange( range, root, root );
// 4. Modify tree of fragment and reinsert.
this.insertNodeInRange( range, modify.call( this, frag ) );
extractContentsOfRange
handles the case where all contents get extracted (leaving the editor empty) by putting in an empty <div></div>
, but then insertNodeInRange
does what its name promises it will, leaving us with a superfluous empty div
this is the cause of 1 +2 here: https://github.com/natejenkins/socialApp/issues/3229
When
extractContentsOfRange
is called here - if the range includes all of the contents of the editor, an unwanted default empty div gets created. (extractContentsOfRange calls fixCursor calls createDefaultBlock); it's unwanted because a new node is about to be inserted, so the editor doesn't need to be treated as empty. Not sure what the best place to fix this is - would ideally not have to pass down some options hash or completely refactor this flow.