From 94e87cd2b6cab23806b80015e969018064c99e5c Mon Sep 17 00:00:00 2001 From: iseulde Date: Tue, 14 Mar 2017 12:43:04 +0100 Subject: [PATCH] Don't add undo level for backspace fix --- tinymce-single/tinymce/block.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tinymce-single/tinymce/block.js b/tinymce-single/tinymce/block.js index d7084fceb0e1f..a9ebcd2ab0b1d 100644 --- a/tinymce-single/tinymce/block.js +++ b/tinymce-single/tinymce/block.js @@ -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.$( '


' ); + + editor.$( block ).before( p ); + editor.selection.setCursorLocation( p[0], 0 ); + editor.$( block ).remove(); } } } ); - function removeBlock( block ) { - var $blocks = editor.$( block || getSelectedBlock() ); - var p = editor.$( '


' ); - - editor.undoManager.transact( function() { - $blocks.first().before( p ); - editor.selection.setCursorLocation( p[0], 0 ); - $blocks.remove(); - } ); - } - // Attach block UI. editor.on( 'preinit', function() { @@ -257,6 +248,17 @@ } }); + function removeBlock() { + var $blocks = editor.$( getSelectedBlock() ); + var p = editor.$( '


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