mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Rewrite all <br>s in cleanupBRs fn.
Previously, we were just removing <br>s that didn't have siblings on both sides. A better test is whether the containing block has any non-whitespace text content. If it does, the <br> is a line break and we can just split the block. If it doesn't though, we need to leave the <br> as a placeholder, to ensure the block doesn't collapse to 0 height.
This commit is contained in:
parent
ac14985583
commit
0ba91e627d
2 changed files with 17 additions and 17 deletions
File diff suppressed because one or more lines are too long
|
@ -1217,7 +1217,6 @@
|
|||
// Cleanup may have removed it
|
||||
block = br.parentNode;
|
||||
if ( !block ) { continue; }
|
||||
if ( br.nextSibling && br.previousSibling ) {
|
||||
while ( block.isInline() ) {
|
||||
block = block.parentNode;
|
||||
}
|
||||
|
@ -1226,15 +1225,16 @@
|
|||
if ( !block.isBlock() ) {
|
||||
wrapTopLevelInline( block, 'DIV' );
|
||||
}
|
||||
// If in a block we can split, split it instead
|
||||
else if ( tagAfterSplit[ block.nodeName ] ) {
|
||||
// If in a block we can split, split it instead, but only if there
|
||||
// is actual text content in the block. Otherwise, the <br> is a
|
||||
// placeholder to stop the block from collapsing, so we must leave
|
||||
// it.
|
||||
else if ( tagAfterSplit[ block.nodeName ] &&
|
||||
/\S/.test( block.textContent ) ) {
|
||||
splitBlock( block, br.parentNode, br );
|
||||
br.detach();
|
||||
}
|
||||
// Otherwise leave the br alone.
|
||||
} else {
|
||||
br.detach();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue