Przeglądaj źródła

Refactored docs.

Oskar Wrobel 9 lat temu
rodzic
commit
ea2bbb6e28

+ 14 - 15
packages/ckeditor5-link/src/link.js

@@ -19,7 +19,7 @@ import LinkBalloonPanelView from './ui/linkballoonpanelview.js';
 /**
  * The link feature. It introduces the Link and Unlink buttons and the <kbd>Ctrl+L</kbd> keystroke.
  *
- * It uses the {@link basic-styles.LinkEngine link engine feature}.
+ * It uses the {@link link.LinkEngine link engine feature}.
  *
  * @memberOf link
  * @extends core.Feature
@@ -36,13 +36,12 @@ export default class Link extends Feature {
 	 * @inheritDoc
 	 */
 	init() {
-		// Register document click observer.
 		this.editor.editing.view.addObserver( ClickObserver );
 
 		/**
 		 * Link balloon panel component.
 		 *
-		 * @member {link.LinkBalloonPanel}
+		 * @member {link.ui.LinkBalloonPanel}
 		 */
 		this.balloonPanel = this._createBalloonPanel();
 
@@ -52,8 +51,8 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Create toolbar link button. Click on button will show
-	 * {@link link.LinkBalloonPanel LinkBalloonPanel} attached to the selection.
+	 * Creates toolbar link button. Click on button will show
+	 * {@link link.ui.LinkBalloonPanel LinkBalloonPanel} attached to the selection.
 	 *
 	 * @private
 	 */
@@ -89,7 +88,7 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Create toolbar unlink button. Click on button will unlink selected link.
+	 * Creates toolbar unlink button. Click on button will unlink selected link.
 	 *
 	 * @private
 	 */
@@ -123,7 +122,7 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Create {@link link.LinkBalloonPanel LinkBalloonPanel} instance
+	 * Creates {@link link.ui.LinkBalloonPanel LinkBalloonPanel} instance
 	 * and attach link command to LinkBalloonPanelModel#execute event.
 	 *
 	 *	                       +------------------------------------+
@@ -159,7 +158,7 @@ export default class Link extends Feature {
 	 *	                            |                   +----+ |
 	 *	                            +--------------------------+
 	 * @private
-	 * @returns {link.LinkBalloonPanel} Link balloon panel instance.
+	 * @returns {link.ui.LinkBalloonPanel} Link balloon panel instance.
 	 */
 	_createBalloonPanel() {
 		const editor = this.editor;
@@ -177,16 +176,16 @@ export default class Link extends Feature {
 		// Create Balloon panel instance.
 		const balloonPanel = new LinkBalloonPanel( panelModel, new LinkBalloonPanelView( editor.locale ) );
 
-		// Observe `LinkBalloonPanelMode#execute` event from within the model of the panel,
+		// Observe `LinkBalloonPanelMode#executeLink` event from within the model of the panel,
 		// which means that the `Save` button has been clicked.
-		this.listenTo( panelModel, 'execute', () => {
+		this.listenTo( panelModel, 'executeLink', () => {
 			editor.execute( 'link', balloonPanel.urlInput.value );
 			balloonPanel.view.hide();
 		} );
 
-		// Observe `LinkBalloonPanelMode#execute-unlink` event from within the model of the panel,
+		// Observe `LinkBalloonPanelMode#executeUnlink` event from within the model of the panel,
 		// which means that the `Unlink` button has been clicked.
-		this.listenTo( panelModel, 'execute-unlink', () => {
+		this.listenTo( panelModel, 'executeUnlink', () => {
 			editor.execute( 'unlink' );
 			balloonPanel.view.hide();
 		} );
@@ -209,8 +208,8 @@ export default class Link extends Feature {
 			}
 		} );
 
-		// Handle `Ctrl+l` keystroke and show panel.
-		editor.keystrokes.set( 'CTRL+l', () => this._attachPanelToElement() );
+		// Handle `Ctrl+L` keystroke and show panel.
+		editor.keystrokes.set( 'CTRL+L', () => this._attachPanelToElement() );
 
 		// Append panel element to body.
 		editor.ui.add( 'body', balloonPanel );
@@ -219,7 +218,7 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Show {@link link#balloonPanel LinkBalloonPanel} and attach to target element.
+	 * Shows {@link link#balloonPanel LinkBalloonPanel} and attach to target element.
 	 * If selection is collapsed and is placed inside link element, then panel will be attached
 	 * to whole link element, otherwise will be attached to the selection.
 	 *

+ 33 - 15
packages/ckeditor5-link/src/ui/linkballoonpanel.js

@@ -25,14 +25,14 @@ import InputTextView from '../../ui/inputtext/inputtextview.js';
  *		// An instance of LinkBalloonPanel.
  *		new LinkBalloonPanel( model, new LinkBalloonPanelView() );
  *
- * See {@link link.LinkBalloonPanelView}.
+ * See {@link link.ui.LinkBalloonPanelView}.
  *
- * @memberOf link
+ * @memberOf link.ui
  * @extends ui.balloonPanel.BalloonPanel
  */
 export default class LinkBalloonPanel extends BalloonPanel {
 	/**
-	 * Creates an instance of {@link link.LinkBalloonPanel} class.
+	 * Creates an instance of {@link link.ui.LinkBalloonPanel} class.
 	 *
 	 * @param {link.balloonPanel.LinkBalloonPanelModel} model Model of this link balloon panel.
 	 * @param {ui.View} view View of this link balloon panel.
@@ -44,7 +44,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 	}
 
 	/**
-	 * Initialize {@link ui.form.Form Form} component with input and buttons.
+	 * Initializes {@link ui.form.Form Form} component with input and buttons.
 	 *
 	 * @private
 	 * @returns {ui.form.Form} Form component.
@@ -52,33 +52,33 @@ export default class LinkBalloonPanel extends BalloonPanel {
 	_createForm() {
 		const formModel = new Model();
 
-		formModel.delegate( 'execute' ).to( this.model );
+		formModel.on( 'execute', () => this.model.fire( 'executeLink' ) );
 
 		/**
 		 * Instance of {@link ui.form.Form Form} component.
 		 *
-		 * @member {ui.form.Form} link.LinkBalloonPanel#form
+		 * @member {ui.form.Form} link.ui.LinkBalloonPanel#form
 		 */
 		this.form = new LinkForm( formModel, new LinkFormView( this.locale ) );
 
 		/**
 		 * Button component for submitting form.
 		 *
-		 * @member {ui.button.Button} link.LinkBalloonPanel#saveButton
+		 * @member {ui.button.Button} link.ui.LinkBalloonPanel#saveButton
 		 */
 		this.saveButton = this._createSaveButton();
 
 		/**
 		 * Button component for canceling form.
 		 *
-		 * @member {ui.button.Button} link.LinkBalloonPanel#cancelButton
+		 * @member {ui.button.Button} link.ui.LinkBalloonPanel#cancelButton
 		 */
 		this.cancelButton = this._createCancelButton();
 
 		/**
 		 * Button component for unlinking.
 		 *
-		 * @member {ui.button.Button} link.LinkBalloonPanel#unlinkButton
+		 * @member {ui.button.Button} link.ui.LinkBalloonPanel#unlinkButton
 		 */
 		this.unlinkButton = this._createUnlinkButton();
 
@@ -94,7 +94,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 	}
 
 	/**
-	 * Initialize {@link ui.input.LabeledInput LabeledInput} for providing `href` value.
+	 * Initializes {@link ui.input.LabeledInput LabeledInput} for providing `href` value.
 	 *
 	 * @private
 	 * @returns {ui.input.LabeledInput} Labeled input component.
@@ -111,7 +111,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 		/**
 		 * Input component for providing `href` value.
 		 *
-		 * @member {ui.input.LabeledInput} link.LinkBalloonPanel#urlInput
+		 * @member {ui.input.LabeledInput} link.ui.LinkBalloonPanel#urlInput
 		 */
 		this.urlInput = new LabeledInput( model, new LabeledInputView( this.locale ), inputText );
 
@@ -119,7 +119,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 	}
 
 	/**
-	 * Initialize {@link ui.button.Button Button} for submitting form.
+	 * Initializes {@link ui.button.Button Button} for submitting form.
 	 *
 	 * @private
 	 * @returns {ui.button.Button} Save button component.
@@ -142,7 +142,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 	}
 
 	/**
-	 * Initialize {@link ui.button.Button Button} for canceling form.
+	 * Initializes {@link ui.button.Button Button} for canceling form.
 	 *
 	 * @private
 	 * @returns {ui.button.Button} Cancel button component.
@@ -162,7 +162,7 @@ export default class LinkBalloonPanel extends BalloonPanel {
 	}
 
 	/**
-	 * Initialize {@link ui.button.Button Button} for unlinking command.
+	 * Initializes {@link ui.button.Button Button} for unlinking command.
 	 *
 	 * @private
 	 * @returns {ui.button.Button} Unlink button component.
@@ -176,10 +176,28 @@ export default class LinkBalloonPanel extends BalloonPanel {
 			icon: 'unlink'
 		} );
 
-		unlinkModel.on( 'execute', () => this.model.fire( 'execute-unlink' ) );
+		unlinkModel.on( 'execute', () => this.model.fire( 'executeUnlink' ) );
 
 		const button = new Button( unlinkModel, new ButtonView( this.locale ) );
 
 		return button;
 	}
 }
+
+/**
+ * The LinkBalloonPanel component {@link ui.Model model} interface.
+ *
+ * @interface link.ui.LinkBalloonPanelModel
+ */
+
+/**
+ * Fired when the LinkForm is submit.
+ *
+ * @event link.ui.LinkBalloonPanelModel#executeLink
+ */
+
+/**
+ * Fired when the Unlink button is executed.
+ *
+ * @event link.ui.LinkBalloonPanelModel#executeUnlink
+ */

+ 2 - 2
packages/ckeditor5-link/src/ui/linkballoonpanelview.js

@@ -9,9 +9,9 @@ import BalloonPanelView from '../../ui/balloonpanel/balloonpanelview.js';
 /**
  * The link balloon panel view class.
  *
- * See {@link link.LinkBalloonPanel}.
+ * See {@link link.ui.LinkBalloonPanel}.
  *
- * @memberOf link
+ * @memberOf link.ui
  * @extends ui.balloonPanel.BalloonPanelView
  */
 export default class LinkBalloonPanelView extends BalloonPanelView {

+ 4 - 4
packages/ckeditor5-link/src/ui/linkform.js

@@ -10,16 +10,16 @@ import Form from '../../ui/form/form.js';
  *
  *		new LinkForm( new Model(), new LinkFormView() );
  *
- * See {@link link.LinkFormView}.
+ * See {@link link.ui.LinkFormView}.
  *
- * @memberOf link
+ * @memberOf link.ui
  * @extends ui.form.Form
  */
 export default class LinkForm extends Form {
 	/**
-	 * Creates an instance of {@link link.LinkForm} class.
+	 * Creates an instance of {@link link.ui.LinkForm} class.
 	 *
-	 * @param {link.LinkFormModel} model Model of this link form.
+	 * @param {link.ui.LinkFormModel} model Model of this link form.
 	 * @param {ui.View} view View of this link form.
 	 */
 	constructor( model, view ) {

+ 2 - 2
packages/ckeditor5-link/src/ui/linkformview.js

@@ -9,9 +9,9 @@ import FormView from '../../ui/form/formview.js';
 /**
  * The link form view controller class.
  *
- * See {@link link.LinkForm}.
+ * See {@link link.ui.LinkForm}.
  *
- * @memberOf link
+ * @memberOf link.ui
  * @extends ui.form.FormView
  */
 export default class LinkFormView extends FormView {

+ 7 - 7
packages/ckeditor5-link/tests/link.js

@@ -166,11 +166,11 @@ describe( 'Link', () => {
 			expect( model.url ).to.equal( 'http://cksource.com' );
 		} );
 
-		it( 'should execute link command on balloonPanel#model execute event', () => {
+		it( 'should execute link command on balloonPanel#model executeLink event', () => {
 			const executeSpy = testUtils.sinon.spy( editor, 'execute' );
 
 			balloonPanel.model.url = 'http://cksource.com';
-			balloonPanel.model.fire( 'execute' );
+			balloonPanel.model.fire( 'executeLink' );
 
 			expect( executeSpy.calledOnce ).to.true;
 			expect( executeSpy.calledWithExactly( 'link', 'http://cksource.com' ) ).to.true;
@@ -179,24 +179,24 @@ describe( 'Link', () => {
 		it( 'should hide balloon panel on balloonPanel#model execute event', () => {
 			const hideSpy = testUtils.sinon.spy( balloonPanel.view, 'hide' );
 
-			balloonPanel.model.fire( 'execute' );
+			balloonPanel.model.fire( 'executeLink' );
 
 			expect( hideSpy.calledOnce ).to.true;
 		} );
 
-		it( 'should execute unlink command on balloonPanel#model execute-unlink event', () => {
+		it( 'should execute unlink command on balloonPanel#model executeUnlink event', () => {
 			const executeSpy = testUtils.sinon.spy( editor, 'execute' );
 
-			balloonPanel.model.fire( 'execute-unlink' );
+			balloonPanel.model.fire( 'executeUnlink' );
 
 			expect( executeSpy.calledOnce ).to.true;
 			expect( executeSpy.calledWithExactly( 'unlink' ) ).to.true;
 		} );
 
-		it( 'should hide balloon panel on balloonPanel#model execute-unlink event', () => {
+		it( 'should hide balloon panel on balloonPanel#model executeUnlink event', () => {
 			const hideSpy = testUtils.sinon.spy( balloonPanel.view, 'hide' );
 
-			balloonPanel.model.fire( 'execute-unlink' );
+			balloonPanel.model.fire( 'executeUnlink' );
 
 			expect( hideSpy.calledOnce ).to.true;
 		} );

+ 6 - 6
packages/ckeditor5-link/tests/ui/linkballoonpanel.js

@@ -44,10 +44,10 @@ describe( 'LinkBalloonPanel', () => {
 					expect( linkBalloonPanel.collections.get( 'content' ).get( 0 ) ).to.deep.equal( linkBalloonPanel.form );
 				} );
 
-				it( 'should delegate form.model#execute to the model', () => {
+				it( 'should fire model#executeLink event on form.model#execute event', () => {
 					const executeSpy = sinon.spy();
 
-					model.on( 'execute', executeSpy );
+					model.on( 'executeLink', executeSpy );
 
 					linkBalloonPanel.form.model.fire( 'execute' );
 
@@ -82,10 +82,10 @@ describe( 'LinkBalloonPanel', () => {
 					expect( linkBalloonPanel.form.collections.get( 'actions' ).get( 0 ) ).to.deep.equal( linkBalloonPanel.saveButton );
 				} );
 
-				it( 'should fire model#execute event on DOM click event', ( done ) => {
+				it( 'should fire model#executeLink event on DOM click event', ( done ) => {
 					const executeSpy = sinon.spy();
 
-					model.on( 'execute', executeSpy );
+					model.on( 'executeLink', executeSpy );
 
 					linkBalloonPanel.init().then( () => {
 						linkBalloonPanel.saveButton.view.element.click();
@@ -127,10 +127,10 @@ describe( 'LinkBalloonPanel', () => {
 					expect( linkBalloonPanel.form.collections.get( 'actions' ).get( 2 ) ).to.deep.equal( linkBalloonPanel.unlinkButton );
 				} );
 
-				it( 'should fire model#execute-unlink event on unlinkButton.model#execute event', () => {
+				it( 'should fire model#executeUnlink event on unlinkButton.model#execute event', () => {
 					const executeUnlinkSpy = sinon.spy();
 
-					model.on( 'execute-unlink', executeUnlinkSpy );
+					model.on( 'executeUnlink', executeUnlinkSpy );
 
 					linkBalloonPanel.unlinkButton.model.fire( 'execute' );