0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Fix copying when not inside valid doc structure

This commit is contained in:
Neil Jenkins 2016-12-09 10:42:18 +11:00
parent 30dc11fd3c
commit 2c7f7b907c
3 changed files with 5 additions and 5 deletions

View file

@ -897,7 +897,7 @@ var deleteContentsOfRange = function ( range, root ) {
fixCursor( root, root ); fixCursor( root, root );
range.selectNodeContents( root.firstChild ); range.selectNodeContents( root.firstChild );
} else { } else {
range.collapse( false ); range.collapse( range.endContainer === root ? true : false );
} }
return frag; return frag;
}; };
@ -2185,7 +2185,7 @@ var onCopy = function ( event ) {
range = range.cloneRange(); range = range.cloneRange();
startBlock = getStartBlockOfRange( range, root ); startBlock = getStartBlockOfRange( range, root );
endBlock = getEndBlockOfRange( range, root ); endBlock = getEndBlockOfRange( range, root );
copyRoot = ( startBlock === endBlock ) ? startBlock : root; copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
moveRangeBoundariesDownTree( range ); moveRangeBoundariesDownTree( range );
moveRangeBoundariesUpTree( range, copyRoot ); moveRangeBoundariesUpTree( range, copyRoot );
contents = range.cloneContents(); contents = range.cloneContents();

File diff suppressed because one or more lines are too long

View file

@ -59,7 +59,7 @@ var onCopy = function ( event ) {
range = range.cloneRange(); range = range.cloneRange();
startBlock = getStartBlockOfRange( range, root ); startBlock = getStartBlockOfRange( range, root );
endBlock = getEndBlockOfRange( range, root ); endBlock = getEndBlockOfRange( range, root );
copyRoot = ( startBlock === endBlock ) ? startBlock : root; copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
moveRangeBoundariesDownTree( range ); moveRangeBoundariesDownTree( range );
moveRangeBoundariesUpTree( range, copyRoot ); moveRangeBoundariesUpTree( range, copyRoot );
contents = range.cloneContents(); contents = range.cloneContents();