From 3be0004cfd15a535c80d9e97c57b76b15f618cbf Mon Sep 17 00:00:00 2001 From: Courtney Spurgeon Date: Wed, 7 Oct 2015 20:07:51 -0700 Subject: [PATCH] Do not add an empty default block below content by default, or when changing block formatting --- build/squire-raw.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/build/squire-raw.js b/build/squire-raw.js index 913c781..5d3bc0a 100644 --- a/build/squire-raw.js +++ b/build/squire-raw.js @@ -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() ); } };