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

Do not add an empty default block below content by default, or when changing block formatting

This commit is contained in:
Courtney Spurgeon 2015-10-07 20:07:51 -07:00
parent 9461368a5c
commit 3be0004cfd

View file

@ -759,7 +759,17 @@ var extractContentsOfRange = function ( range, common ) {
range.setStart( startContainer, startOffset );
range.collapse( true );
fixCursor( common );
// Socrata Edit:
// When there is a single block-level element in the editor and it's format is
// modified (Ex: changing a paragraph to a blockquote)
// - It is removed
// - This function is run
// - The newly formatted block is added
// This leads to an empty node being inserted by fixCursor while the body is
// empty. Instead, only run fixCursor if there are children in `common`
if ( common.childElementCount > 0 ) {
fixCursor( common );
}
return frag;
};
@ -3389,8 +3399,12 @@ var decreaseListLevel = function ( frag ) {
proto._ensureBottomLine = function () {
var body = this._body,
last = body.lastElementChild;
if ( !last ||
last.nodeName !== this._config.blockTag || !isBlock( last ) ) {
// Socrata Edit:
// This used to insert an extra block unless the last element was the same
// as the default block. Now it only adds if there is no block level last
// element.
if ( !last || !isBlock( last ) ) {
body.appendChild( this.createDefaultBlock() );
}
};