mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Fix invalid caching of selection nodes in paste handler.
Fixes error thrown when pasting text twice in succession (or more generally, when pasting it into non-normalised text nodes).
This commit is contained in:
parent
8f83ef32c3
commit
5b8e348232
4 changed files with 22 additions and 12 deletions
|
@ -692,6 +692,7 @@ var insertNodeInRange = function ( range, node ) {
|
|||
} else {
|
||||
startContainer.insertBefore( node, children[ startOffset ] );
|
||||
}
|
||||
|
||||
if ( startContainer === endContainer ) {
|
||||
endOffset += children.length - childCount;
|
||||
}
|
||||
|
@ -2598,16 +2599,20 @@ proto._onPaste = function ( event ) {
|
|||
var self = this,
|
||||
body = this._body,
|
||||
range = this.getSelection(),
|
||||
startContainer = range.startContainer,
|
||||
startOffset = range.startOffset,
|
||||
endContainer = range.endContainer,
|
||||
endOffset = range.endOffset,
|
||||
startBlock = getStartBlockOfRange( range );
|
||||
startContainer, startOffset, endContainer, endOffset, startBlock;
|
||||
|
||||
// Record undo checkpoint
|
||||
self._recordUndoState( range );
|
||||
self._getRangeAndRemoveBookmark( range );
|
||||
|
||||
// Note current selection. We must do this AFTER recording the undo
|
||||
// checkpoint, as this modifies the DOM.
|
||||
startContainer = range.startContainer;
|
||||
startOffset = range.startOffset;
|
||||
endContainer = range.endContainer;
|
||||
endOffset = range.endOffset;
|
||||
startBlock = getStartBlockOfRange( range );
|
||||
|
||||
// We need to position the pasteArea in the visible portion of the screen
|
||||
// to stop the browser auto-scrolling.
|
||||
var pasteArea = this.createElement( 'DIV', {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1525,16 +1525,20 @@ proto._onPaste = function ( event ) {
|
|||
var self = this,
|
||||
body = this._body,
|
||||
range = this.getSelection(),
|
||||
startContainer = range.startContainer,
|
||||
startOffset = range.startOffset,
|
||||
endContainer = range.endContainer,
|
||||
endOffset = range.endOffset,
|
||||
startBlock = getStartBlockOfRange( range );
|
||||
startContainer, startOffset, endContainer, endOffset, startBlock;
|
||||
|
||||
// Record undo checkpoint
|
||||
self._recordUndoState( range );
|
||||
self._getRangeAndRemoveBookmark( range );
|
||||
|
||||
// Note current selection. We must do this AFTER recording the undo
|
||||
// checkpoint, as this modifies the DOM.
|
||||
startContainer = range.startContainer;
|
||||
startOffset = range.startOffset;
|
||||
endContainer = range.endContainer;
|
||||
endOffset = range.endOffset;
|
||||
startBlock = getStartBlockOfRange( range );
|
||||
|
||||
// We need to position the pasteArea in the visible portion of the screen
|
||||
// to stop the browser auto-scrolling.
|
||||
var pasteArea = this.createElement( 'DIV', {
|
||||
|
|
|
@ -108,6 +108,7 @@ var insertNodeInRange = function ( range, node ) {
|
|||
} else {
|
||||
startContainer.insertBefore( node, children[ startOffset ] );
|
||||
}
|
||||
|
||||
if ( startContainer === endContainer ) {
|
||||
endOffset += children.length - childCount;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue