|
|
@@ -70,28 +70,28 @@ export default class Heading extends Plugin {
|
|
|
commands.push( command );
|
|
|
}
|
|
|
|
|
|
- // Create dropdown model.
|
|
|
- const dropdownModel = new Model( {
|
|
|
- withText: true,
|
|
|
- tooltip: dropdownTooltip
|
|
|
- } );
|
|
|
+ // Register UI component.
|
|
|
+ editor.ui.componentFactory.add( 'headings', locale => {
|
|
|
+ const dropdownView = createDropdown( locale );
|
|
|
|
|
|
- bindOneToMany( dropdownModel, 'isEnabled', commands, 'isEnabled', ( ...areEnabled ) => {
|
|
|
- return areEnabled.some( isEnabled => isEnabled );
|
|
|
- } );
|
|
|
+ dropdownView.set( {
|
|
|
+ isOn: false,
|
|
|
+ withText: true,
|
|
|
+ tooltip: dropdownTooltip
|
|
|
+ } );
|
|
|
|
|
|
- bindOneToMany( dropdownModel, 'label', commands, 'value', ( ...areActive ) => {
|
|
|
- const index = areActive.findIndex( value => value );
|
|
|
+ addListViewToDropdown( dropdownView, dropdownItems );
|
|
|
|
|
|
- // If none of the commands is active, display default title.
|
|
|
- return options[ index ] ? options[ index ].title : defaultTitle;
|
|
|
- } );
|
|
|
+ bindOneToMany( dropdownView, 'isEnabled', commands, 'isEnabled', ( ...areEnabled ) => {
|
|
|
+ return areEnabled.some( isEnabled => isEnabled );
|
|
|
+ } );
|
|
|
|
|
|
- // Register UI component.
|
|
|
- editor.ui.componentFactory.add( 'headings', locale => {
|
|
|
- const dropdownView = createDropdown( dropdownModel, locale );
|
|
|
+ bindOneToMany( dropdownView, 'label', commands, 'value', ( ...areActive ) => {
|
|
|
+ const index = areActive.findIndex( value => value );
|
|
|
|
|
|
- addListViewToDropdown( dropdownView, dropdownItems, dropdownModel, locale );
|
|
|
+ // If none of the commands is active, display default title.
|
|
|
+ return options[ index ] ? options[ index ].title : defaultTitle;
|
|
|
+ } );
|
|
|
|
|
|
dropdownView.extendTemplate( {
|
|
|
attributes: {
|