8
0
Просмотр исходного кода

Cleanup in the documentation and other small details.

Piotrek Koszuliński 9 лет назад
Родитель
Сommit
5793dfe5b1
2 измененных файлов с 14 добавлено и 14 удалено
  1. 9 9
      packages/ckeditor5-link/src/link.js
  2. 5 5
      packages/ckeditor5-link/tests/link.js

+ 9 - 9
packages/ckeditor5-link/src/link.js

@@ -16,6 +16,8 @@ import ButtonView from '../ui/button/buttonview.js';
 import LinkBalloonPanel from './ui/linkballoonpanel.js';
 import LinkBalloonPanelView from './ui/linkballoonpanelview.js';
 
+import { keyCodes } from '../utils/keyboard.js';
+
 /**
  * The link feature. It introduces the Link and Unlink buttons and the <kbd>Ctrl+L</kbd> keystroke.
  *
@@ -115,9 +117,9 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Creates the {@link link.ui.LinkBalloonPanel LinkBalloonPanel} instance,
+	 * Creates the {@link link.ui.LinkBalloonPanel} instance,
 	 * attaches {@link link.LinkBalloonPanelModel} events to the link and unlink commands
-	 * and applies specified for this panel behaviours.
+	 * and applies behaviors specified for this panel.
 	 *
 	 * @private
 	 * @returns {link.ui.LinkBalloonPanel} Link balloon panel instance.
@@ -166,7 +168,7 @@ export default class Link extends Feature {
 		this.listenTo( balloonPanel.view.model, 'change:isVisible', ( evt, propertyName, value ) => {
 			if ( value ) {
 				// Handle close by `Esc`.
-				balloonPanel.view.listenTo( document, 'keydown', this._closePanelOnClick.bind( this ) );
+				balloonPanel.view.listenTo( document, 'keydown', this._closePanelOnEsc.bind( this ) );
 
 				// Handle close by clicking out of the panel.
 				// Note that it is not handled by a `click` event, it is because clicking on link button or directly on link element
@@ -219,8 +221,6 @@ export default class Link extends Feature {
 	 * 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.
 	 *
-	 * Input inside panel will be focused.
-	 *
 	 * @private
 	 * @param {core.view.LinkElement} [parentLink] Target element.
 	 */
@@ -246,7 +246,7 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Hide {@link link#balloonPanel LinkBalloonPanel}.
+	 * Hides {@link link#balloonPanel LinkBalloonPanel}.
 	 *
 	 * @private
 	 * @param {Object} [options={}] Additional options.
@@ -261,7 +261,7 @@ export default class Link extends Feature {
 	}
 
 	/**
-	 * Hide balloon panel on `ESC` key press event and restore editor focus.
+	 * Hides balloon panel on `ESC` key press event and restores editor focus.
 	 *
 	 * **Note**: this method is `@protected` for testing purposes only.
 	 *
@@ -269,8 +269,8 @@ export default class Link extends Feature {
 	 * @param {utils.EventInfo} evt Information about the event.
 	 * @param {KeyboardEvent} domEvt DOM `keydown` event.
 	 */
-	_closePanelOnClick( evt, domEvt ) {
-		if ( domEvt.keyCode == 27 ) {
+	_closePanelOnEsc( evt, domEvt ) {
+		if ( domEvt.keyCode == keyCodes.esc ) {
 			this._hidePanel( { focusEditable: true } );
 		}
 	}

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

@@ -224,7 +224,7 @@ describe( 'Link', () => {
 		describe( 'close listeners', () => {
 			describe( 'keyboard', () => {
 				it( 'should listen keyboard events when is open', () => {
-					const escCloseSpy = testUtils.sinon.spy( linkFeature, '_closePanelOnClick' );
+					const escCloseSpy = testUtils.sinon.spy( linkFeature, '_closePanelOnEsc' );
 
 					balloonPanel.view.model.isVisible = true;
 					document.dispatchEvent( new Event( 'keydown' ) );
@@ -233,7 +233,7 @@ describe( 'Link', () => {
 				} );
 
 				it( 'should not listen keyboard events when is closed', () => {
-					const escCloseSpy = testUtils.sinon.spy( linkFeature, '_closePanelOnClick' );
+					const escCloseSpy = testUtils.sinon.spy( linkFeature, '_closePanelOnEsc' );
 
 					balloonPanel.view.model.isVisible = false;
 					document.dispatchEvent( new Event( 'keydown' ) );
@@ -242,7 +242,7 @@ describe( 'Link', () => {
 				} );
 
 				it( 'should stop listening keyboard events after close', () => {
-					const escCloseSpy = testUtils.sinon.spy( linkFeature, '_closePanelOnClick' );
+					const escCloseSpy = testUtils.sinon.spy( linkFeature, '_closePanelOnEsc' );
 
 					balloonPanel.view.model.isVisible = true;
 					balloonPanel.view.model.isVisible = false;
@@ -425,12 +425,12 @@ describe( 'Link', () => {
 			} );
 		} );
 
-		describe( '_closePanelOnClick', () => {
+		describe( '_closePanelOnEsc', () => {
 			it( 'should hide panel and focus editable on ESC press', () => {
 				const eventInfo = {};
 				const domEvent = { keyCode: 27 };
 
-				linkFeature._closePanelOnClick( eventInfo, domEvent );
+				linkFeature._closePanelOnEsc( eventInfo, domEvent );
 
 				expect( hidePanelSpy.calledOnce ).to.true;
 				expect( focusEditableSpy.calledOnce ).to.true;