Skip to content

Commit

Permalink
Ensure current focused node is eligible for control
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Mar 2, 2017
1 parent 7049fd7 commit a3bdbec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tinymce-single/tinymce/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

// Global controls

function isNodeEligibleForControl( node, name ) {
var block;

if ( ! node ) {
return false;
}

block = wp.blocks.getBlockSettingsByElement( node );
return block && _.includes( block.controls, name );
}

_.forEach( wp.blocks.getControls(), function( control, name ) {
var settings = {
icon: control.icon
Expand All @@ -27,7 +38,9 @@
var button = this;

editor.on( 'nodechange', function() {
button.active( control.isActive( element ) );
if ( isNodeEligibleForControl( element, name ) ) {
button.active( control.isActive( element ) );
}
} );
};
}
Expand Down

0 comments on commit a3bdbec

Please sign in to comment.