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

Wrap LI contents when merging.

This commit is contained in:
Neil Jenkins 2014-05-23 15:26:47 +10:00
parent ca5c08e4d0
commit 46706db889
3 changed files with 26 additions and 6 deletions

View file

@ -507,14 +507,24 @@ function mergeWithBlock ( block, next, range ) {
function mergeContainers ( node ) {
var prev = node.previousSibling,
first = node.firstChild,
isListItem = ( node.nodeName === 'LI' );
isListItem = ( node.nodeName === 'LI' ),
block;
// Do not merge LIs, unless it only contains a UL
if ( isListItem && ( !first || !/^[OU]L$/.test( first.nodeName ) ) ) {
return;
}
if ( prev && areAlike( prev, node ) && isContainer( prev ) ) {
if ( prev && areAlike( prev, node ) ) {
if ( !isContainer( prev ) ) {
if ( isListItem ) {
block = prev.ownerDocument.createElement( 'div' );
block.appendChild( empty( prev ) );
prev.appendChild( block );
} else {
return;
}
}
detach( node );
prev.appendChild( empty( node ) );
if ( first ) {

File diff suppressed because one or more lines are too long

View file

@ -365,14 +365,24 @@ function mergeWithBlock ( block, next, range ) {
function mergeContainers ( node ) {
var prev = node.previousSibling,
first = node.firstChild,
isListItem = ( node.nodeName === 'LI' );
isListItem = ( node.nodeName === 'LI' ),
block;
// Do not merge LIs, unless it only contains a UL
if ( isListItem && ( !first || !/^[OU]L$/.test( first.nodeName ) ) ) {
return;
}
if ( prev && areAlike( prev, node ) && isContainer( prev ) ) {
if ( prev && areAlike( prev, node ) ) {
if ( !isContainer( prev ) ) {
if ( isListItem ) {
block = prev.ownerDocument.createElement( 'div' );
block.appendChild( empty( prev ) );
prev.appendChild( block );
} else {
return;
}
}
detach( node );
prev.appendChild( empty( node ) );
if ( first ) {