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

Commit 39ba14b

Browse files
authored
Merge pull request #60 from ckeditor/t/26
Feature: Active heading is marked in the drop-down list. Closes #26.
2 parents 0365333 + b4a1736 commit 39ba14b

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/heading.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@ export default class Heading extends Plugin {
4141
let defaultOption;
4242

4343
for ( let option of options ) {
44-
// Add the option to the collection.
45-
dropdownItems.add( new Model( {
44+
const command = editor.commands.get( option.modelElement );
45+
const itemModel = new Model( {
4646
commandName: option.modelElement,
4747
label: option.title,
4848
class: option.class
49-
} ) );
49+
} );
50+
51+
itemModel.bind( 'isActive' ).to( command, 'value' );
52+
53+
// Add the option to the collection.
54+
dropdownItems.add( itemModel );
5055

51-
commands.push( editor.commands.get( option.modelElement ) );
56+
commands.push( command );
5257

5358
if ( !defaultOption && option.modelElement == 'paragraph' ) {
5459
defaultOption = option;

tests/heading.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ describe( 'Heading', () => {
210210
'ck-heading_heading3'
211211
] );
212212
} );
213+
214+
it( 'reflects the #value of the commands', () => {
215+
const listView = dropdown.listView;
216+
217+
editor.commands.get( 'heading2' ).value = true;
218+
219+
expect( listView.items.map( item => item.isActive ) ).to.deep.equal( [
220+
false,
221+
false,
222+
true,
223+
false
224+
] );
225+
} );
213226
} );
214227
} );
215228
} );

0 commit comments

Comments
 (0)