Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #60 from ckeditor/t/26
Browse files Browse the repository at this point in the history
Feature: Active heading is marked in the drop-down list. Closes #26.
  • Loading branch information
szymonkups authored Mar 13, 2017
2 parents 0365333 + b4a1736 commit 39ba14b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions tests/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
] );
} );
} );
} );
} );

0 comments on commit 39ba14b

Please sign in to comment.