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:
parent
a8fcd55cf4
commit
8d764f6638
3 changed files with 17 additions and 1 deletions
|
@ -1264,6 +1264,14 @@ var afterDelete = function ( self, range ) {
|
||||||
// Move cursor into text node
|
// Move cursor into text node
|
||||||
moveRangeBoundariesDownTree( range );
|
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._ensureBottomLine();
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range, true );
|
self._updatePath( range, true );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -127,6 +127,14 @@ var afterDelete = function ( self, range ) {
|
||||||
// Move cursor into text node
|
// Move cursor into text node
|
||||||
moveRangeBoundariesDownTree( range );
|
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._ensureBottomLine();
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range, true );
|
self._updatePath( range, true );
|
||||||
|
|
Loading…
Reference in a new issue