mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Don't try to merge table cell into block on paste
This commit is contained in:
parent
c5be1b79dc
commit
033370ebee
3 changed files with 16 additions and 10 deletions
|
@ -912,7 +912,7 @@ var deleteContentsOfRange = function ( range, root ) {
|
||||||
// After method, range will be around inserted content
|
// After method, range will be around inserted content
|
||||||
var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
var node, block, blockContentsAfterSplit, stopPoint, container, offset;
|
var node, block, blockContentsAfterSplit, stopPoint, container, offset;
|
||||||
var nodeAfterSplit, nodeBeforeSplit, tempRange;
|
var firstBlockInFrag, nodeAfterSplit, nodeBeforeSplit, tempRange;
|
||||||
|
|
||||||
// Fixup content: ensure no top-level inline, and add cursor fix elements.
|
// Fixup content: ensure no top-level inline, and add cursor fix elements.
|
||||||
fixContainer( frag, root );
|
fixContainer( frag, root );
|
||||||
|
@ -936,8 +936,11 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
// Merge the contents of the first block in the frag with the focused block.
|
// Merge the contents of the first block in the frag with the focused block.
|
||||||
// If there are contents in the block after the focus point, collect this
|
// If there are contents in the block after the focus point, collect this
|
||||||
// up to insert in the last block later
|
// up to insert in the last block later
|
||||||
block = getStartBlockOfRange( range );
|
block = getStartBlockOfRange( range, root );
|
||||||
if ( block ) {
|
firstBlockInFrag = getNextBlock( frag, frag );
|
||||||
|
if ( block && firstBlockInFrag &&
|
||||||
|
// Don't merge table cell into block
|
||||||
|
!getNearest( firstBlockInFrag, frag, 'TABLE' ) ) {
|
||||||
moveRangeBoundariesUpTree( range, block, block, root );
|
moveRangeBoundariesUpTree( range, block, block, root );
|
||||||
range.collapse( true ); // collapse to start
|
range.collapse( true ); // collapse to start
|
||||||
container = range.endContainer;
|
container = range.endContainer;
|
||||||
|
@ -961,7 +964,7 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// And merge the first block in.
|
// And merge the first block in.
|
||||||
mergeWithBlock( container, getNextBlock( frag, frag ), range, root );
|
mergeWithBlock( container, firstBlockInFrag, range, root );
|
||||||
|
|
||||||
// And where we will insert
|
// And where we will insert
|
||||||
offset = indexOf.call( container.parentNode.childNodes, container ) + 1;
|
offset = indexOf.call( container.parentNode.childNodes, container ) + 1;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -180,7 +180,7 @@ var deleteContentsOfRange = function ( range, root ) {
|
||||||
// After method, range will be around inserted content
|
// After method, range will be around inserted content
|
||||||
var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
var node, block, blockContentsAfterSplit, stopPoint, container, offset;
|
var node, block, blockContentsAfterSplit, stopPoint, container, offset;
|
||||||
var nodeAfterSplit, nodeBeforeSplit, tempRange;
|
var firstBlockInFrag, nodeAfterSplit, nodeBeforeSplit, tempRange;
|
||||||
|
|
||||||
// Fixup content: ensure no top-level inline, and add cursor fix elements.
|
// Fixup content: ensure no top-level inline, and add cursor fix elements.
|
||||||
fixContainer( frag, root );
|
fixContainer( frag, root );
|
||||||
|
@ -204,8 +204,11 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
// Merge the contents of the first block in the frag with the focused block.
|
// Merge the contents of the first block in the frag with the focused block.
|
||||||
// If there are contents in the block after the focus point, collect this
|
// If there are contents in the block after the focus point, collect this
|
||||||
// up to insert in the last block later
|
// up to insert in the last block later
|
||||||
block = getStartBlockOfRange( range );
|
block = getStartBlockOfRange( range, root );
|
||||||
if ( block ) {
|
firstBlockInFrag = getNextBlock( frag, frag );
|
||||||
|
if ( block && firstBlockInFrag &&
|
||||||
|
// Don't merge table cell into block
|
||||||
|
!getNearest( firstBlockInFrag, frag, 'TABLE' ) ) {
|
||||||
moveRangeBoundariesUpTree( range, block, block, root );
|
moveRangeBoundariesUpTree( range, block, block, root );
|
||||||
range.collapse( true ); // collapse to start
|
range.collapse( true ); // collapse to start
|
||||||
container = range.endContainer;
|
container = range.endContainer;
|
||||||
|
@ -229,7 +232,7 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// And merge the first block in.
|
// And merge the first block in.
|
||||||
mergeWithBlock( container, getNextBlock( frag, frag ), range, root );
|
mergeWithBlock( container, firstBlockInFrag, range, root );
|
||||||
|
|
||||||
// And where we will insert
|
// And where we will insert
|
||||||
offset = indexOf.call( container.parentNode.childNodes, container ) + 1;
|
offset = indexOf.call( container.parentNode.childNodes, container ) + 1;
|
||||||
|
|
Loading…
Reference in a new issue