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:
parent
f4c5a85379
commit
a8e6e5b391
1 changed files with 18 additions and 0 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue