mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Remove uneditable container entirely on delete/backspace
If you backspace/delete to remove an uneditable block, we should be checking if it's part of a larger uneditable container and if so removing the whole thing.
This commit is contained in:
parent
374d067ef3
commit
e1e8ec78cb
3 changed files with 27 additions and 5 deletions
|
@ -1380,6 +1380,17 @@ var afterDelete = function ( self, range ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var detachUneditableNode = function ( node, root ) {
|
||||||
|
var parent;
|
||||||
|
while (( parent = node.parentNode )) {
|
||||||
|
if ( parent === root || parent.isContentEditable ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
node = parent;
|
||||||
|
}
|
||||||
|
detach( node );
|
||||||
|
};
|
||||||
|
|
||||||
var handleEnter = function ( self, shiftKey, range ) {
|
var handleEnter = function ( self, shiftKey, range ) {
|
||||||
var root = self._root;
|
var root = self._root;
|
||||||
var block, parent, node, offset, nodeAfterSplit;
|
var block, parent, node, offset, nodeAfterSplit;
|
||||||
|
@ -1593,7 +1604,7 @@ var keyHandlers = {
|
||||||
if ( previous ) {
|
if ( previous ) {
|
||||||
// If not editable, just delete whole block.
|
// If not editable, just delete whole block.
|
||||||
if ( !previous.isContentEditable ) {
|
if ( !previous.isContentEditable ) {
|
||||||
detach( previous );
|
detachUneditableNode( previous, root );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise merge.
|
// Otherwise merge.
|
||||||
|
@ -1660,7 +1671,7 @@ var keyHandlers = {
|
||||||
if ( next ) {
|
if ( next ) {
|
||||||
// If not editable, just delete whole block.
|
// If not editable, just delete whole block.
|
||||||
if ( !next.isContentEditable ) {
|
if ( !next.isContentEditable ) {
|
||||||
detach( next );
|
detachUneditableNode( next, root );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise merge.
|
// Otherwise merge.
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -139,6 +139,17 @@ var afterDelete = function ( self, range ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var detachUneditableNode = function ( node, root ) {
|
||||||
|
var parent;
|
||||||
|
while (( parent = node.parentNode )) {
|
||||||
|
if ( parent === root || parent.isContentEditable ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
node = parent;
|
||||||
|
}
|
||||||
|
detach( node );
|
||||||
|
};
|
||||||
|
|
||||||
var handleEnter = function ( self, shiftKey, range ) {
|
var handleEnter = function ( self, shiftKey, range ) {
|
||||||
var root = self._root;
|
var root = self._root;
|
||||||
var block, parent, node, offset, nodeAfterSplit;
|
var block, parent, node, offset, nodeAfterSplit;
|
||||||
|
@ -352,7 +363,7 @@ var keyHandlers = {
|
||||||
if ( previous ) {
|
if ( previous ) {
|
||||||
// If not editable, just delete whole block.
|
// If not editable, just delete whole block.
|
||||||
if ( !previous.isContentEditable ) {
|
if ( !previous.isContentEditable ) {
|
||||||
detach( previous );
|
detachUneditableNode( previous, root );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise merge.
|
// Otherwise merge.
|
||||||
|
@ -419,7 +430,7 @@ var keyHandlers = {
|
||||||
if ( next ) {
|
if ( next ) {
|
||||||
// If not editable, just delete whole block.
|
// If not editable, just delete whole block.
|
||||||
if ( !next.isContentEditable ) {
|
if ( !next.isContentEditable ) {
|
||||||
detach( next );
|
detachUneditableNode( next, root );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise merge.
|
// Otherwise merge.
|
||||||
|
|
Loading…
Reference in a new issue