This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments