mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Use helper fn to get start block in paste handler.
Neater and deals with the edge cases.
This commit is contained in:
parent
597024eecb
commit
c0e33843fb
3 changed files with 7 additions and 15 deletions
|
@ -2646,18 +2646,14 @@ proto._onPaste = function ( event ) {
|
|||
startOffset = range.startOffset,
|
||||
endContainer = range.endContainer,
|
||||
endOffset = range.endOffset,
|
||||
startBlock = startContainer.nodeType === TEXT_NODE ?
|
||||
startContainer : startContainer.childNodes[ startOffset ];
|
||||
startBlock = getStartBlockOfRange( range );
|
||||
|
||||
// We need to position the pasteArea in the visible portion of the screen
|
||||
// to stop the browser auto-scrolling.
|
||||
while ( isInline( startBlock ) ) {
|
||||
startBlock = startBlock.parentNode;
|
||||
}
|
||||
|
||||
var pasteArea = this.createElement( 'DIV', {
|
||||
style: 'position: absolute; overflow: hidden; top:' +
|
||||
( body.scrollTop + startBlock.getBoundingClientRect().top ) +
|
||||
( body.scrollTop +
|
||||
( startBlock ? startBlock.getBoundingClientRect().top : 0 ) ) +
|
||||
'px; left: 0; width: 1px; height: 1px;'
|
||||
});
|
||||
body.appendChild( pasteArea );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1529,18 +1529,14 @@ proto._onPaste = function ( event ) {
|
|||
startOffset = range.startOffset,
|
||||
endContainer = range.endContainer,
|
||||
endOffset = range.endOffset,
|
||||
startBlock = startContainer.nodeType === TEXT_NODE ?
|
||||
startContainer : startContainer.childNodes[ startOffset ];
|
||||
startBlock = getStartBlockOfRange( range );
|
||||
|
||||
// We need to position the pasteArea in the visible portion of the screen
|
||||
// to stop the browser auto-scrolling.
|
||||
while ( isInline( startBlock ) ) {
|
||||
startBlock = startBlock.parentNode;
|
||||
}
|
||||
|
||||
var pasteArea = this.createElement( 'DIV', {
|
||||
style: 'position: absolute; overflow: hidden; top:' +
|
||||
( body.scrollTop + startBlock.getBoundingClientRect().top ) +
|
||||
( body.scrollTop +
|
||||
( startBlock ? startBlock.getBoundingClientRect().top : 0 ) ) +
|
||||
'px; left: 0; width: 1px; height: 1px;'
|
||||
});
|
||||
body.appendChild( pasteArea );
|
||||
|
|
Loading…
Reference in a new issue