diff --git a/src/heading.js b/src/heading.js index b1d708b..1d5009a 100644 --- a/src/heading.js +++ b/src/heading.js @@ -41,14 +41,19 @@ export default class Heading extends Plugin { let defaultOption; for ( let option of options ) { - // Add the option to the collection. - dropdownItems.add( new Model( { + const command = editor.commands.get( option.modelElement ); + const itemModel = new Model( { commandName: option.modelElement, label: option.title, class: option.class - } ) ); + } ); + + itemModel.bind( 'isActive' ).to( command, 'value' ); + + // Add the option to the collection. + dropdownItems.add( itemModel ); - commands.push( editor.commands.get( option.modelElement ) ); + commands.push( command ); if ( !defaultOption && option.modelElement == 'paragraph' ) { defaultOption = option; diff --git a/tests/heading.js b/tests/heading.js index 792fc27..7e0c4c9 100644 --- a/tests/heading.js +++ b/tests/heading.js @@ -210,6 +210,19 @@ describe( 'Heading', () => { 'ck-heading_heading3' ] ); } ); + + it( 'reflects the #value of the commands', () => { + const listView = dropdown.listView; + + editor.commands.get( 'heading2' ).value = true; + + expect( listView.items.map( item => item.isActive ) ).to.deep.equal( [ + false, + false, + true, + false + ] ); + } ); } ); } ); } );