Przeglądaj źródła

Minor code refactoring and documentation fixes.

Aleksander Nowodzinski 9 lat temu
rodzic
commit
442413b304

+ 13 - 12
packages/ckeditor5-link/src/link.js

@@ -41,7 +41,7 @@ export default class Link extends Feature {
 		/**
 		 * Link balloon panel component.
 		 *
-		 * @member {link.ui.LinkBalloonPanel}
+		 * @member {link.LinkBalloonPanel} link.Link#balloonPanel
 		 */
 		this.balloonPanel = this._createBalloonPanel();
 
@@ -51,8 +51,8 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Creates toolbar link button. Click on button will show
-	 * {@link link.ui.LinkBalloonPanel LinkBalloonPanel} attached to the selection.
+	 * Creates a toolbar link button. Clicking this button will show
+	 * {@link link.Link#balloonPanel} attached to the selection.
 	 *
 	 * @private
 	 */
@@ -71,10 +71,10 @@ export default class Link extends Feature {
 			keystroke: 'CTRL+L'
 		} );
 
-		// Bind button model to command.
+		// Bind button model to the command.
 		linkButtonModel.bind( 'isEnabled' ).to( linkCommand, 'isEnabled' );
 
-		// Show Balloon Panel on button click only when editor is focused.
+		// Show the panel on button click only when editor is focused.
 		this.listenTo( linkButtonModel, 'execute', () => {
 			if ( !viewDocument.isFocused ) {
 				return;
@@ -88,7 +88,8 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Creates toolbar unlink button. Click on button will unlink selected link.
+	 * Create a toolbar unlink button. Clicking this button will unlink
+	 * the selected link.
 	 *
 	 * @private
 	 */
@@ -97,7 +98,7 @@ export default class Link extends Feature {
 		const t = editor.t;
 		const unlinkCommand = editor.commands.get( 'unlink' );
 
-		// Create button model.
+		// Create the button model.
 		const unlinkButtonModel = new Model( {
 			isEnabled: false,
 			isOn: false,
@@ -105,10 +106,10 @@ export default class Link extends Feature {
 			icon: 'unlink'
 		} );
 
-		// Bind button model to command.
+		// Bind button model to the command.
 		unlinkButtonModel.bind( 'isEnabled' ).to( unlinkCommand, 'hasValue' );
 
-		// Execute unlink command and hide panel if is open.
+		// Execute unlink command and hide panel, if open.
 		this.listenTo( unlinkButtonModel, 'execute', () => {
 			editor.execute( 'unlink' );
 
@@ -122,8 +123,8 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Creates {@link link.ui.LinkBalloonPanel LinkBalloonPanel} instance
-	 * and attach link command to LinkBalloonPanelModel#execute event.
+	 * Creates the {@link link.LinkBalloonPanel LinkBalloonPanel} instance
+	 * and attaches link command to {@link link.LinkBalloonPanelModel#execute} event.
 	 *
 	 *	                       +------------------------------------+
 	 *	                       | <a href="http://foo.com">[foo]</a> |
@@ -173,7 +174,7 @@ export default class Link extends Feature {
 		// Bind panel model to command.
 		panelModel.bind( 'url' ).to( linkCommand, 'value' );
 
-		// Create Balloon panel instance.
+		// Create the balloon panel instance.
 		const balloonPanel = new LinkBalloonPanel( panelModel, new LinkBalloonPanelView( editor.locale ) );
 
 		// Observe `LinkBalloonPanelMode#executeLink` event from within the model of the panel,

+ 7 - 7
packages/ckeditor5-link/src/linkcommand.js

@@ -25,7 +25,7 @@ export default class LinkCommand extends Command {
 		super( editor );
 
 		/**
-		 * Currently selected linkHref attribute value.
+		 * Currently selected `linkHref` attribute value.
 		 *
 		 * @observable
 		 * @member {Boolean} core.command.ToggleAttributeCommand#value
@@ -52,14 +52,14 @@ export default class LinkCommand extends Command {
 	/**
 	 * Executes the command.
 	 *
-	 * When selection is non-collapsed then `linkHref` attribute will be applied to nodes inside selection, but only to
-	 * this nodes where `linkHref` attribute is allowed (disallowed nodes will be omitted).
+	 * When selection is non-collapsed, then `linkHref` attribute will be applied to nodes inside selection, but only to
+	 * those nodes where `linkHref` attribute is allowed (disallowed nodes will be omitted).
 	 *
-	 * When selection is collapsed and is not inside text with `linkHref` attribute then new {@link engine.model.Text Text node} with
-	 * `linkHref` attribute will be inserted in place of caret, but only if such an element is allowed in this place. _data of inserted
-	 * text will be equal to `href` parameter. Selection will be updated to wrap just inserted text node.
+	 * When selection is collapsed and is not inside text with `linkHref` attribute, then new {@link engine.model.Text Text node} with
+	 * `linkHref` attribute will be inserted in place of caret, but only if such an element is allowed in this place. `_data` of
+	 * the inserted text will equal `href` parameter. Selection will be updated to wrap just inserted text node.
 	 *
-	 * When selection is collapsed and is inside text with `linkHref` attribute then attribute value will be updated.
+	 * When selection is collapsed and inside text with `linkHref` attribute, the attribute value will be updated.
 	 *
 	 * @protected
 	 * @param {String} href Link destination.

+ 3 - 2
packages/ckeditor5-link/src/linkelement.js

@@ -6,8 +6,9 @@
 import AttributeElement from '../engine/view/attributeelement.js';
 
 /**
- * This class is to identify that specified {@link engine.view.Node} is a {@link link.LinkElement} instance.
- * E.g. There could be a situation when different features will create nodes with the same names, and we need to identify them.
+ * This class is to mark specific {@link engine.view.Node} as {@link link.LinkElement}.
+ * E.g. There could be a situation when different features will create nodes with the same names,
+ * and hence they must be identified somehow.
  *
  * @memberOf link
  * @extends engine.view.AttributeElement

+ 7 - 6
packages/ckeditor5-link/src/ui/linkballoonpanel.js

@@ -185,19 +185,20 @@ export default class LinkBalloonPanel extends BalloonPanel {
 }
 
 /**
- * The LinkBalloonPanel component {@link ui.Model model} interface.
+ * The link balloon panel component {@link ui.Model} interface.
  *
- * @interface link.ui.LinkBalloonPanelModel
+ * @interface link.LinkBalloonPanelModel
  */
 
 /**
- * Fired when the LinkForm is submit.
+ * URL of the link displayed in the panel.
  *
- * @event link.ui.LinkBalloonPanelModel#executeLink
+ * @observable
+ * @member {String} link.LinkBalloonPanelModel#url
  */
 
 /**
- * Fired when the Unlink button is executed.
+ * Fired when "OK" action has been executed by the user in the panel.
  *
- * @event link.ui.LinkBalloonPanelModel#executeUnlink
+ * @event link.LinkBalloonPanelModel#execute
  */

+ 3 - 4
packages/ckeditor5-link/src/unlinkcommand.js

@@ -25,7 +25,7 @@ export default class UnlinkCommand extends Command {
 		 * the command's attribute set. For range selection it means that all nodes inside have the attribute applied.
 		 *
 		 * @observable
-		 * @member {Boolean} core.command.ToggleAttributeCommand#hasValue
+		 * @member {Boolean} link.UnlinkCommand#hasValue
 		 */
 		this.set( 'hasValue', undefined );
 
@@ -37,9 +37,8 @@ export default class UnlinkCommand extends Command {
 	/**
 	 * Executes the command.
 	 *
-	 * When selection is collapsed then remove `linkHref` attribute from each stick node with the same `linkHref` attribute value.
-	 *
-	 * When selection is non-collapsed then remove `linkHref` from each node in selected ranges.
+	 * When the selection is collapsed, removes `linkHref` attribute from each node with the same `linkHref` attribute value.
+	 * When the selection is non-collapsed, removes `linkHref` from each node in selected ranges.
 	 *
 	 * @protected
 	 */