Skip to content

Commit

Permalink
Don't add undo level for backspace fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Mar 14, 2017
1 parent 678a1f5 commit 94e87cd
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,16 @@
if ( event.keyCode === tinymce.util.VK.BACKSPACE ) {
var block = getSelectedBlock();

console.log(block, block.textContent)

if ( ! block.textContent ) {
removeBlock( block );
var p = editor.$( '<p><br></p>' );

editor.$( block ).before( p );
editor.selection.setCursorLocation( p[0], 0 );
editor.$( block ).remove();
}
}
} );

function removeBlock( block ) {
var $blocks = editor.$( block || getSelectedBlock() );
var p = editor.$( '<p><br></p>' );

editor.undoManager.transact( function() {
$blocks.first().before( p );
editor.selection.setCursorLocation( p[0], 0 );
$blocks.remove();
} );
}

// Attach block UI.

editor.on( 'preinit', function() {
Expand Down Expand Up @@ -257,6 +248,17 @@
}
});

function removeBlock() {
var $blocks = editor.$( getSelectedBlock() );
var p = editor.$( '<p><br></p>' );

editor.undoManager.transact( function() {
$blocks.first().before( p );
editor.selection.setCursorLocation( p[0], 0 );
$blocks.remove();
} );
}

function moveBlockUp() {
$blocks = editor.$( getSelectedBlocks() );
$first = $blocks.first();
Expand Down

0 comments on commit 94e87cd

Please sign in to comment.