Skip to content

Commit

Permalink
Merge pull request #224 from WordPress/add/tinymce-single/quote-2
Browse files Browse the repository at this point in the history
Remove blockquote should remove entire blockquote
  • Loading branch information
ellatrix authored Mar 9, 2017
2 parents aedd3d5 + 56ada58 commit 040ba31
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
11 changes: 11 additions & 0 deletions tinymce-single/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@
getSelectedBlock: function() {
return wp.blocks.getSelectedBlocks()[0];
},
selectBlock: function( block ) {
var editor = window.tinyMCE.activeEditor;
var brs = block.getElementsByTagName( 'BR' );

// Has placeholder for text.
if ( brs.length ) {
editor.selection.setCursorLocation( brs[0].parentNode, 0 );
} else {
editor.selection.select( block );
}
},
extendBlock: function( settings ) {
var extendId = settings.extends;
var id = settings.namespace + ':' + settings.name;
Expand Down
15 changes: 14 additions & 1 deletion tinymce-single/blocks/elements/blockquote/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ window.wp.blocks.registerBlock( {
classes: 'remove-formatting',
icon: 'gridicons-quote',
onClick: function( block, editor ) {
editor.formatter.remove( 'blockquote' );
var footer = block.querySelector( 'footer' );
var firstChild = block.firstChild;

if ( footer ) {
block.removeChild( footer );
}

while ( block.firstChild ) {
block.parentNode.insertBefore( block.firstChild, block );
}

block.parentNode.removeChild( block );

window.wp.blocks.selectBlock( firstChild );
}
},
{
Expand Down
9 changes: 1 addition & 8 deletions tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,7 @@
block.parentNode.replaceChild( content, block );
}

var brs = content.getElementsByTagName( 'BR' );

// Has placeholder for text.
if ( brs.length ) {
editor.selection.setCursorLocation( brs[0].parentNode, 0 );
} else {
editor.selection.select( content );
}
window.wp.blocks.selectBlock( content );

setTimeout( showBlockUI )
}
Expand Down

0 comments on commit 040ba31

Please sign in to comment.