Skip to content

Commit

Permalink
Pad empty elements in case the browser deletes them on backspace
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 14, 2017
1 parent c38fb24 commit 9abc4b8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@
.attr( 'data-wp-block-selected', null );
} );

editor.on( 'keyup', function( event ) {
if ( event.keyCode === tinymce.util.VK.BACKSPACE ) {
var $empty = editor.$( editor.selection.getNode() ).find( ':empty' );

$empty.append( '<br>' );

if ( $empty.length ) {
editor.selection.setCursorLocation( $empty[0], 0 );
}
}
} );

// Attach block UI.

editor.on( 'preinit', function() {
Expand Down

0 comments on commit 9abc4b8

Please sign in to comment.