From a8e6e5b391e053272532f20634d91b65c9dab7d3 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Thu, 17 Nov 2011 18:36:58 +1100 Subject: [PATCH] Merge adjacent containers on delete/backspace. If you delete the line separating two containers (e.g. a blockquote), the containers are merged. --- source/Editor.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/Editor.js b/source/Editor.js index 09790bb..b9c5b41 100644 --- a/source/Editor.js +++ b/source/Editor.js @@ -1273,6 +1273,15 @@ // Must not be at the very beginning of the text area. if ( previous ) { previous.mergeWithBlock( current, range ); + // If deleted line between containers, merge newly adjacent + // containers. + current = previous.parentNode; + while ( current && !current.nextSibling ) { + current = current.parentNode; + } + if ( current && ( current = current.nextSibling ) ) { + current.mergeContainers(); + } setSelection( range ); } // If at very beginning of text area, allow backspace @@ -1309,6 +1318,15 @@ // Must not be at the very end of the text area. if ( next ) { current.mergeWithBlock( next, range ); + // If deleted line between containers, merge newly adjacent + // containers. + next = current.parentNode; + while ( next && !next.nextSibling ) { + next = next.parentNode; + } + if ( next && ( next = next.nextSibling ) ) { + next.mergeContainers(); + } setSelection( range ); updatePath( 0, true ); }