浏览代码

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

Maciej Gołaszewski 7 年之前
父节点
当前提交
11557cdbe3
共有 1 个文件被更改,包括 17 次插入17 次删除
  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: {