Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove blockquote should remove entire blockquote #224

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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