0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Fix Chrome may replace <div> with <br> if you delete all content.

Fixes #108.
This commit is contained in:
Neil Jenkins 2015-07-13 06:39:07 -07:00
parent a8fcd55cf4
commit 8d764f6638
3 changed files with 17 additions and 1 deletions

View file

@ -1264,6 +1264,14 @@ var afterDelete = function ( self, range ) {
// Move cursor into text node
moveRangeBoundariesDownTree( range );
}
// If you delete the last character in the sole <div> in Chrome,
// it removes the div and replaces it with just a <br> inside the
// body. Detach the <br>; the _ensureBottomLine call will insert a new
// block.
if ( node.nodeName === 'BODY' &&
( node = node.firstChild ) && node.nodeName === 'BR' ) {
detach( node );
}
self._ensureBottomLine();
self.setSelection( range );
self._updatePath( range, true );

File diff suppressed because one or more lines are too long

View file

@ -127,6 +127,14 @@ var afterDelete = function ( self, range ) {
// Move cursor into text node
moveRangeBoundariesDownTree( range );
}
// If you delete the last character in the sole <div> in Chrome,
// it removes the div and replaces it with just a <br> inside the
// body. Detach the <br>; the _ensureBottomLine call will insert a new
// block.
if ( node.nodeName === 'BODY' &&
( node = node.firstChild ) && node.nodeName === 'BR' ) {
detach( node );
}
self._ensureBottomLine();
self.setSelection( range );
self._updatePath( range, true );