mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Fix deleting selection across block boundary.
This commit is contained in:
parent
a46dc2ef02
commit
54b428aaa6
3 changed files with 11 additions and 17 deletions
|
@ -745,6 +745,11 @@ var deleteContentsOfRange = function ( range ) {
|
|||
// Remove selected range
|
||||
extractContentsOfRange( range );
|
||||
|
||||
// Move boundaries back down tree so that they are inside the blocks.
|
||||
// If we don't do this, the range may be collapsed to a point between
|
||||
// two blocks, so get(Start|End)BlockOfRange will return null.
|
||||
moveRangeBoundariesDownTree( range );
|
||||
|
||||
// If we split into two different blocks, merge the blocks.
|
||||
var startBlock = getStartBlockOfRange( range ),
|
||||
endBlock = getEndBlockOfRange( range );
|
||||
|
@ -764,14 +769,6 @@ var deleteContentsOfRange = function ( range ) {
|
|||
fixCursor( body );
|
||||
range.selectNodeContents( body.firstChild );
|
||||
}
|
||||
|
||||
// Ensure valid range (must have only block or inline containers)
|
||||
var isCollapsed = range.collapsed;
|
||||
moveRangeBoundariesDownTree( range );
|
||||
if ( isCollapsed ) {
|
||||
// Collapse
|
||||
range.collapse( true );
|
||||
}
|
||||
};
|
||||
|
||||
// ---
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -159,6 +159,11 @@ var deleteContentsOfRange = function ( range ) {
|
|||
// Remove selected range
|
||||
extractContentsOfRange( range );
|
||||
|
||||
// Move boundaries back down tree so that they are inside the blocks.
|
||||
// If we don't do this, the range may be collapsed to a point between
|
||||
// two blocks, so get(Start|End)BlockOfRange will return null.
|
||||
moveRangeBoundariesDownTree( range );
|
||||
|
||||
// If we split into two different blocks, merge the blocks.
|
||||
var startBlock = getStartBlockOfRange( range ),
|
||||
endBlock = getEndBlockOfRange( range );
|
||||
|
@ -178,14 +183,6 @@ var deleteContentsOfRange = function ( range ) {
|
|||
fixCursor( body );
|
||||
range.selectNodeContents( body.firstChild );
|
||||
}
|
||||
|
||||
// Ensure valid range (must have only block or inline containers)
|
||||
var isCollapsed = range.collapsed;
|
||||
moveRangeBoundariesDownTree( range );
|
||||
if ( isCollapsed ) {
|
||||
// Collapse
|
||||
range.collapse( true );
|
||||
}
|
||||
};
|
||||
|
||||
// ---
|
||||
|
|
Loading…
Reference in a new issue