mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-18 04:32:28 -05:00
parent
27b1532ca6
commit
c29a8c639b
3 changed files with 22 additions and 52 deletions
|
@ -3010,7 +3010,7 @@ var cleanupBRs = function ( root ) {
|
||||||
var brs = root.querySelectorAll( 'BR' ),
|
var brs = root.querySelectorAll( 'BR' ),
|
||||||
brBreaksLine = [],
|
brBreaksLine = [],
|
||||||
l = brs.length,
|
l = brs.length,
|
||||||
i, br, block;
|
i, br, parent;
|
||||||
|
|
||||||
// Must calculate whether the <br> breaks a line first, because if we
|
// Must calculate whether the <br> breaks a line first, because if we
|
||||||
// have two <br>s next to each other, after the first one is converted
|
// have two <br>s next to each other, after the first one is converted
|
||||||
|
@ -3023,31 +3023,16 @@ var cleanupBRs = function ( root ) {
|
||||||
while ( l-- ) {
|
while ( l-- ) {
|
||||||
br = brs[l];
|
br = brs[l];
|
||||||
// Cleanup may have removed it
|
// Cleanup may have removed it
|
||||||
block = br.parentNode;
|
parent = br.parentNode;
|
||||||
if ( !block ) { continue; }
|
if ( !parent ) { continue; }
|
||||||
while ( isInline( block ) ) {
|
|
||||||
block = block.parentNode;
|
|
||||||
}
|
|
||||||
// If this is not inside a block, replace it by wrapping
|
|
||||||
// inlines in a <div>.
|
|
||||||
if ( !isBlock( block ) ) {
|
|
||||||
fixContainer( block );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// If it doesn't break a line, just remove it; it's not doing
|
// If it doesn't break a line, just remove it; it's not doing
|
||||||
// anything useful. We'll add it back later if required by the
|
// anything useful. We'll add it back later if required by the
|
||||||
// browser. If it breaks a line, split the block or leave it as
|
// browser. If it breaks a line, wrap the content in div tags
|
||||||
// appropriate.
|
// and replace the brs.
|
||||||
if ( brBreaksLine[l] ) {
|
if ( !brBreaksLine[l] ) {
|
||||||
// If in a <div>, split, but anywhere else we might change
|
|
||||||
// the formatting too much (e.g. <li> -> to two list items!)
|
|
||||||
// so just play it safe and leave it.
|
|
||||||
if ( block.nodeName !== 'DIV' ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
split( br.parentNode, br, block.parentNode );
|
|
||||||
}
|
|
||||||
detach( br );
|
detach( br );
|
||||||
|
} else if ( !isInline( parent ) ) {
|
||||||
|
fixContainer( parent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1552,7 +1552,7 @@ var cleanupBRs = function ( root ) {
|
||||||
var brs = root.querySelectorAll( 'BR' ),
|
var brs = root.querySelectorAll( 'BR' ),
|
||||||
brBreaksLine = [],
|
brBreaksLine = [],
|
||||||
l = brs.length,
|
l = brs.length,
|
||||||
i, br, block;
|
i, br, parent;
|
||||||
|
|
||||||
// Must calculate whether the <br> breaks a line first, because if we
|
// Must calculate whether the <br> breaks a line first, because if we
|
||||||
// have two <br>s next to each other, after the first one is converted
|
// have two <br>s next to each other, after the first one is converted
|
||||||
|
@ -1565,31 +1565,16 @@ var cleanupBRs = function ( root ) {
|
||||||
while ( l-- ) {
|
while ( l-- ) {
|
||||||
br = brs[l];
|
br = brs[l];
|
||||||
// Cleanup may have removed it
|
// Cleanup may have removed it
|
||||||
block = br.parentNode;
|
parent = br.parentNode;
|
||||||
if ( !block ) { continue; }
|
if ( !parent ) { continue; }
|
||||||
while ( isInline( block ) ) {
|
|
||||||
block = block.parentNode;
|
|
||||||
}
|
|
||||||
// If this is not inside a block, replace it by wrapping
|
|
||||||
// inlines in a <div>.
|
|
||||||
if ( !isBlock( block ) ) {
|
|
||||||
fixContainer( block );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// If it doesn't break a line, just remove it; it's not doing
|
// If it doesn't break a line, just remove it; it's not doing
|
||||||
// anything useful. We'll add it back later if required by the
|
// anything useful. We'll add it back later if required by the
|
||||||
// browser. If it breaks a line, split the block or leave it as
|
// browser. If it breaks a line, wrap the content in div tags
|
||||||
// appropriate.
|
// and replace the brs.
|
||||||
if ( brBreaksLine[l] ) {
|
if ( !brBreaksLine[l] ) {
|
||||||
// If in a <div>, split, but anywhere else we might change
|
|
||||||
// the formatting too much (e.g. <li> -> to two list items!)
|
|
||||||
// so just play it safe and leave it.
|
|
||||||
if ( block.nodeName !== 'DIV' ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
split( br.parentNode, br, block.parentNode );
|
|
||||||
}
|
|
||||||
detach( br );
|
detach( br );
|
||||||
|
} else if ( !isInline( parent ) ) {
|
||||||
|
fixContainer( parent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue