瀏覽代碼

Other: Change how split button is bound to model.

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

+ 5 - 14
packages/ckeditor5-ui/src/button/splitbuttonview.js

@@ -20,12 +20,12 @@ export default class SplitButtonView extends View {
 	/**
 	 * @inheritDoc
 	 */
-	constructor( locale, startButton ) {
+	constructor( locale ) {
 		super( locale );
 
 		this.children = this.createCollection();
 
-		this.buttonView = startButton || this._createButtonView();
+		this.buttonView = this._createButtonView();
 		this.arrowView = this._createArrowView();
 
 		this.keystrokes = new KeystrokeHandler();
@@ -75,18 +75,6 @@ export default class SplitButtonView extends View {
 		} );
 	}
 
-	swapButton( buttonView ) {
-		// remove from FT
-		this.focusTracker.remove( this.buttonView.element );
-
-		this.children.remove( this.buttonView );
-
-		this.buttonView = buttonView;
-
-		this.children.add( this.buttonView, 0 );
-		this.focusTracker.add( this.buttonView.element );
-	}
-
 	focus() {
 		this.buttonView.focus();
 	}
@@ -101,7 +89,10 @@ export default class SplitButtonView extends View {
 
 	_createArrowView() {
 		const arrowView = new ButtonView();
+
+		// TODO:
 		arrowView.icon = 'abc';
+
 		arrowView.extendTemplate( {
 			attributes: {
 				class: 'ck-splitbutton-arrow'

+ 3 - 3
packages/ckeditor5-ui/src/dropdown/createsplitbuttondropdown.js

@@ -16,11 +16,11 @@ import DropdownPanelView from './dropdownpanelview';
  *
  * TODO: docs
  */
-export default function createSplitButtonDropdown( model, locale, startButton ) {
-	const splitButtonView = new SplitButtonView( locale, startButton );
+export default function createSplitButtonDropdown( model, locale ) {
+	const splitButtonView = new SplitButtonView( locale );
 
 	// TODO: keystroke?
-	splitButtonView.bind( 'label', 'isOn', 'isEnabled', 'withText', 'keystroke', 'tooltip' ).to( model );
+	splitButtonView.bind( 'label', 'isOn', 'isEnabled', 'withText', 'keystroke', 'tooltip', 'icon' ).to( model );
 
 	const panelView = new DropdownPanelView( locale );