Sfoglia il codice sorgente

Minor refactoring.

Aleksander Nowodzinski 9 anni fa
parent
commit
3666fee9c9

+ 4 - 2
packages/ckeditor5-link/src/link.js

@@ -70,7 +70,7 @@ export default class Link extends Feature {
 		// Create panel model.
 		const balloonPanelModel = new Model( {
 			maxWidth: 300,
-			url: 'foo'
+			url: 'http://example.com'
 		} );
 
 		// this.listenTo( balloonPanelModel, 'change:url', ( ...args ) => {
@@ -97,10 +97,12 @@ export default class Link extends Feature {
 					editableViewElement
 				);
 			}
+
+			this.balloonPanel.urlInput.view.focus();
 		}, this );
 
+		// TODO: It's a lame FocusManager.
 		editingView.on( 'blur', ( evt, domEvtData ) => {
-			// TODO: Lame FocusManager.
 			if ( domEvtData.domEvent.relatedTarget === this.balloonPanel.urlInput ) {
 				domEvtData.domEvent.preventDefault();
 			} else {

+ 4 - 0
packages/ckeditor5-link/src/ui/inputtextview.js

@@ -36,4 +36,8 @@ export default class InputTextView extends View {
 			}
 		} );
 	}
+
+	focus() {
+		this.element.focus();
+	}
 }

+ 24 - 18
packages/ckeditor5-link/src/ui/linkballoonpanel.js

@@ -30,33 +30,28 @@ export default class LinkBalloonPanel extends BalloonPanel {
 
 		const contentCollection = this.collections.get( 'content' );
 
-		/**
-		 * TODO
-		 *
-		 * @member {} todo
-		 */
-		this.labeledInput = this._createLabeledInput();
-
-		/**
-		 * TODO
-		 *
-		 * @member {} todo
-		 */
-		this.urlInput = this.labeledInput.input;
-
-		contentCollection.add( this.labeledInput );
+		contentCollection.add( this._createLabeledInput() );
 		contentCollection.add( this._createButtons() );
 	}
 
 	_createLabeledInput() {
 		const t = this.view.t;
-		const labeledInputModel = new Model( {
+		const model = new Model( {
 			label: t( 'Link URL' )
 		} );
 
-		labeledInputModel.bind( 'value' ).to( this.model, 'url' );
+		model.bind( 'value' ).to( this.model, 'url' );
+
+		const labeledInput = new LabeledInput( model, new LabeledInputView( this.locale ) );
 
-		return new LabeledInput( labeledInputModel, new LabeledInputView( this.locale ) );
+		/**
+		 * TODO
+		 *
+		 * @member {} todo
+		 */
+		this.urlInput = labeledInput.input;
+
+		return labeledInput;
 	}
 
 	_createButtons() {
@@ -64,7 +59,18 @@ export default class LinkBalloonPanel extends BalloonPanel {
 			alignRight: true
 		} ), new BoxView( this.locale ) );
 
+		/**
+		 * TODO
+		 *
+		 * @member {} todo
+		 */
 		this.saveButton = this._createSaveButton();
+
+		/**
+		 * TODO
+		 *
+		 * @member {} todo
+		 */
 		this.cancelButton = this._createCancelButton();
 
 		box.add( 'content', this.cancelButton );