Bladeren bron

Changed: Bind dropdown behavior to `DropdownView` instead of `Model`.

Maciej Gołaszewski 7 jaren geleden
bovenliggende
commit
11557cdbe3
1 gewijzigde bestanden met toevoegingen van 17 en 17 verwijderingen
  1. 17 17
      packages/ckeditor5-heading/src/heading.js

+ 17 - 17
packages/ckeditor5-heading/src/heading.js

@@ -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: {