mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Fix pasting multiple lines into a blockquote.
Pasting is hard to get right in the general case, not least because the browsers give so little control over the process, leaving you to resort to crappy hacks. But we can special case the pasting to a blockquote case fairly easily, and I can't see any particular regression it should cause. Fixes #59.
This commit is contained in:
parent
62e2f5aa95
commit
73ca65edb5
3 changed files with 16 additions and 10 deletions
|
@ -776,11 +776,14 @@ var insertTreeFragmentIntoRange = function ( range, frag ) {
|
||||||
insertNodeInRange( range, frag );
|
insertNodeInRange( range, frag );
|
||||||
range.collapse( false );
|
range.collapse( false );
|
||||||
}
|
}
|
||||||
// Otherwise, split up to body, insert inline before and after split
|
// Otherwise, split up to blockquote (if a parent) or body, insert inline
|
||||||
// and insert block in between split, then merge containers.
|
// before and after split and insert block in between split, then merge
|
||||||
|
// containers.
|
||||||
else {
|
else {
|
||||||
var nodeAfterSplit = split( range.startContainer, range.startOffset,
|
var splitPoint = range.startContainer,
|
||||||
range.startContainer.ownerDocument.body ),
|
nodeAfterSplit = split( splitPoint, range.startOffset,
|
||||||
|
getNearest( splitPoint.parentNode, 'BLOCKQUOTE' ) ||
|
||||||
|
splitPoint.ownerDocument.body ),
|
||||||
nodeBeforeSplit = nodeAfterSplit.previousSibling,
|
nodeBeforeSplit = nodeAfterSplit.previousSibling,
|
||||||
startContainer = nodeBeforeSplit,
|
startContainer = nodeBeforeSplit,
|
||||||
startOffset = startContainer.childNodes.length,
|
startOffset = startContainer.childNodes.length,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -192,11 +192,14 @@ var insertTreeFragmentIntoRange = function ( range, frag ) {
|
||||||
insertNodeInRange( range, frag );
|
insertNodeInRange( range, frag );
|
||||||
range.collapse( false );
|
range.collapse( false );
|
||||||
}
|
}
|
||||||
// Otherwise, split up to body, insert inline before and after split
|
// Otherwise, split up to blockquote (if a parent) or body, insert inline
|
||||||
// and insert block in between split, then merge containers.
|
// before and after split and insert block in between split, then merge
|
||||||
|
// containers.
|
||||||
else {
|
else {
|
||||||
var nodeAfterSplit = split( range.startContainer, range.startOffset,
|
var splitPoint = range.startContainer,
|
||||||
range.startContainer.ownerDocument.body ),
|
nodeAfterSplit = split( splitPoint, range.startOffset,
|
||||||
|
getNearest( splitPoint.parentNode, 'BLOCKQUOTE' ) ||
|
||||||
|
splitPoint.ownerDocument.body ),
|
||||||
nodeBeforeSplit = nodeAfterSplit.previousSibling,
|
nodeBeforeSplit = nodeAfterSplit.previousSibling,
|
||||||
startContainer = nodeBeforeSplit,
|
startContainer = nodeBeforeSplit,
|
||||||
startOffset = startContainer.childNodes.length,
|
startOffset = startContainer.childNodes.length,
|
||||||
|
|
Loading…
Reference in a new issue