瀏覽代碼

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

Maciej Gołaszewski 8 年之前
父節點
當前提交
9502b6c21c

+ 9 - 11
packages/ckeditor5-font/src/fontfamily/fontfamilyui.js

@@ -52,20 +52,18 @@ export default class FontFamilyUI extends Plugin {
 			dropdownItems.add( itemModel );
 		}
 
-		// Create dropdown model.
-		const dropdownModel = new Model( {
-			icon: fontFamilyIcon,
-			withText: false,
-			tooltip: t( 'Font Family' )
-		} );
-
-		dropdownModel.bind( 'isEnabled' ).to( command, 'isEnabled' );
-
 		// Register UI component.
 		editor.ui.componentFactory.add( 'fontFamily', locale => {
-			const dropdownView = createDropdown( dropdownModel, locale );
+			const dropdownView = createDropdown( locale );
+			addListViewToDropdown( dropdownView, dropdownItems );
+
+			dropdownView.set( {
+				icon: fontFamilyIcon,
+				withText: false,
+				tooltip: t( 'Font Family' )
+			} );
 
-			addListViewToDropdown( dropdownView, dropdownItems, dropdownModel, locale );
+			dropdownView.bind( 'isEnabled' ).to( command, 'isEnabled' );
 
 			dropdownView.extendTemplate( {
 				attributes: {

+ 10 - 11
packages/ckeditor5-font/src/fontsize/fontsizeui.js

@@ -57,20 +57,19 @@ export default class FontSizeUI extends Plugin {
 			dropdownItems.add( itemModel );
 		}
 
-		// Create dropdown model.
-		const dropdownModel = new Model( {
-			icon: fontSizeIcon,
-			withText: false,
-			tooltip: t( 'Font Size' )
-		} );
-
-		dropdownModel.bind( 'isEnabled' ).to( command, 'isEnabled' );
-
 		// Register UI component.
 		editor.ui.componentFactory.add( 'fontSize', locale => {
-			const dropdownView = createDropdown( dropdownModel, locale );
+			const dropdownView = createDropdown( locale );
+			addListViewToDropdown( dropdownView, dropdownItems );
+
+			// Create dropdown model.
+			dropdownView.set( {
+				icon: fontSizeIcon,
+				withText: false,
+				tooltip: t( 'Font Size' )
+			} );
 
-			addListViewToDropdown( dropdownView, dropdownItems, dropdownModel, locale );
+			dropdownView.bind( 'isEnabled' ).to( command, 'isEnabled' );
 
 			dropdownView.extendTemplate( {
 				attributes: {