0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Merge adjacent containers on delete/backspace.

If you delete the line separating two containers (e.g. a blockquote), the
containers are merged.
This commit is contained in:
Neil Jenkins 2011-11-17 18:36:58 +11:00
parent f4c5a85379
commit a8e6e5b391

View file

@ -1273,6 +1273,15 @@
// Must not be at the very beginning of the text area. // Must not be at the very beginning of the text area.
if ( previous ) { if ( previous ) {
previous.mergeWithBlock( current, range ); 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 ); setSelection( range );
} }
// If at very beginning of text area, allow backspace // If at very beginning of text area, allow backspace
@ -1309,6 +1318,15 @@
// Must not be at the very end of the text area. // Must not be at the very end of the text area.
if ( next ) { if ( next ) {
current.mergeWithBlock( next, range ); 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 ); setSelection( range );
updatePath( 0, true ); updatePath( 0, true );
} }