mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 23:40:35 -05:00
Squire: Fix possible error when deleting range
This commit is contained in:
parent
d9122222b2
commit
66c0b20702
4 changed files with 11 additions and 3 deletions
|
@ -361,6 +361,10 @@ function fixCursor ( node, root ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( node.nodeType === TEXT_NODE ) {
|
||||||
|
return originalNode;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isInline( node ) ) {
|
if ( isInline( node ) ) {
|
||||||
child = node.firstChild;
|
child = node.firstChild;
|
||||||
while ( cantFocusEmptyTextNodes && child &&
|
while ( cantFocusEmptyTextNodes && child &&
|
||||||
|
@ -806,8 +810,8 @@ var deleteContentsOfRange = function ( range, root ) {
|
||||||
moveRangeBoundariesDownTree( range );
|
moveRangeBoundariesDownTree( range );
|
||||||
|
|
||||||
// If we split into two different blocks, merge the blocks.
|
// If we split into two different blocks, merge the blocks.
|
||||||
if ( needsMerge ) {
|
|
||||||
startBlock = getStartBlockOfRange( range, root );
|
startBlock = getStartBlockOfRange( range, root );
|
||||||
|
if ( needsMerge ) {
|
||||||
endBlock = getEndBlockOfRange( range, root );
|
endBlock = getEndBlockOfRange( range, root );
|
||||||
if ( startBlock && endBlock && startBlock !== endBlock ) {
|
if ( startBlock && endBlock && startBlock !== endBlock ) {
|
||||||
mergeWithBlock( startBlock, endBlock, range );
|
mergeWithBlock( startBlock, endBlock, range );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -190,6 +190,10 @@ function fixCursor ( node, root ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( node.nodeType === TEXT_NODE ) {
|
||||||
|
return originalNode;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isInline( node ) ) {
|
if ( isInline( node ) ) {
|
||||||
child = node.firstChild;
|
child = node.firstChild;
|
||||||
while ( cantFocusEmptyTextNodes && child &&
|
while ( cantFocusEmptyTextNodes && child &&
|
||||||
|
|
|
@ -153,8 +153,8 @@ var deleteContentsOfRange = function ( range, root ) {
|
||||||
moveRangeBoundariesDownTree( range );
|
moveRangeBoundariesDownTree( range );
|
||||||
|
|
||||||
// If we split into two different blocks, merge the blocks.
|
// If we split into two different blocks, merge the blocks.
|
||||||
if ( needsMerge ) {
|
|
||||||
startBlock = getStartBlockOfRange( range, root );
|
startBlock = getStartBlockOfRange( range, root );
|
||||||
|
if ( needsMerge ) {
|
||||||
endBlock = getEndBlockOfRange( range, root );
|
endBlock = getEndBlockOfRange( range, root );
|
||||||
if ( startBlock && endBlock && startBlock !== endBlock ) {
|
if ( startBlock && endBlock && startBlock !== endBlock ) {
|
||||||
mergeWithBlock( startBlock, endBlock, range );
|
mergeWithBlock( startBlock, endBlock, range );
|
||||||
|
|
Loading…
Reference in a new issue