8
0
Эх сурвалжийг харах

Code style: Switched to ESLint.

Kamil Piechaczek 8 жил өмнө
parent
commit
0a69f62da4

+ 10 - 11
packages/ckeditor5-link/src/link.js

@@ -126,7 +126,7 @@ export default class Link extends Plugin {
 		// Handle `Ctrl+K` keystroke and show the panel.
 		editor.keystrokes.set( 'CTRL+K', () => this._showPanel( true ) );
 
-		editor.ui.componentFactory.add( 'link', ( locale ) => {
+		editor.ui.componentFactory.add( 'link', locale => {
 			const button = new ButtonView( locale );
 
 			button.isEnabled = true;
@@ -156,7 +156,7 @@ export default class Link extends Plugin {
 		const t = editor.t;
 		const unlinkCommand = editor.commands.get( 'unlink' );
 
-		editor.ui.componentFactory.add( 'unlink', ( locale ) => {
+		editor.ui.componentFactory.add( 'unlink', locale => {
 			const button = new ButtonView( locale );
 
 			button.isEnabled = false;
@@ -283,13 +283,13 @@ export default class Link extends Plugin {
 			return Promise.resolve();
 		} else {
 			return this._balloon.add( {
-					view: this.formView,
-					position: this._getBalloonPositionData()
-				} ).then( () => {
-					if ( focusInput ) {
-						this.formView.urlInputView.select();
-					}
-				} );
+				view: this.formView,
+				position: this._getBalloonPositionData()
+			} ).then( () => {
+				if ( focusInput ) {
+					this.formView.urlInputView.select();
+				}
+			} );
 		}
 	}
 
@@ -332,8 +332,7 @@ export default class Link extends Plugin {
 
 		const target = targetLink ?
 			// When selection is inside link element, then attach panel to this element.
-			viewDocument.domConverter.getCorrespondingDomElement( targetLink )
-			:
+			viewDocument.domConverter.getCorrespondingDomElement( targetLink ) :
 			// Otherwise attach panel to the selection.
 			viewDocument.domConverter.viewRangeToDom( viewDocument.selection.getFirstRange() );
 

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

@@ -59,10 +59,10 @@ export default class LinkCommand extends Command {
 	 * 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 module:engine/model/text~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 not inside text with `linkHref` attribute, then
+	 * new {@link module:engine/model/text~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 inside text with `linkHref` attribute, the attribute value will be updated.
 	 *
@@ -106,7 +106,7 @@ export default class LinkCommand extends Command {
 				// omitting nodes where `linkHref` attribute is disallowed.
 				const ranges = getSchemaValidRanges( 'linkHref', selection.getRanges(), document.schema );
 
-				for ( let range of ranges ) {
+				for ( const range of ranges ) {
 					batch.setAttribute( range, 'linkHref', href );
 				}
 			}

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

@@ -36,12 +36,12 @@ export default class LinkEngine extends Plugin {
 		// Build converter from model to view for data and editing pipelines.
 		buildModelConverter().for( data.modelToView, editing.modelToView )
 			.fromAttribute( 'linkHref' )
-			.toElement( ( linkHref ) => new LinkElement( 'a', { href: linkHref } ) );
+			.toElement( linkHref => new LinkElement( 'a', { href: linkHref } ) );
 
 		// Build converter from view to model for data pipeline.
 		buildViewConverter().for( data.viewToModel )
 			.fromElement( 'a' )
-			.toAttribute( ( viewElement ) => ( {
+			.toAttribute( viewElement => ( {
 				key: 'linkHref',
 				value: viewElement.getAttribute( 'href' )
 			} ) );

+ 1 - 1
packages/ckeditor5-link/src/unlinkcommand.js

@@ -48,7 +48,7 @@ export default class UnlinkCommand extends Command {
 			const batch = document.batch();
 
 			// Remove `linkHref` attribute from specified ranges.
-			for ( let range of rangesToUnlink ) {
+			for ( const range of rangesToUnlink ) {
 				batch.removeAttribute( range, 'linkHref' );
 			}
 		} );

+ 12 - 8
packages/ckeditor5-link/tests/link.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals document */
+/* globals document, Event */
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
@@ -162,7 +162,8 @@ describe( 'Link', () => {
 				} );
 		} );
 
-		it( 'should not focus the #formView when called with a `true` parameter while the balloon is opened but link form is not visible', () => {
+		it( 'should not focus the #formView when called with a `true` parameter while the balloon is opened but link ' +
+			'form is not visible', () => {
 			const spy = testUtils.sinon.spy( formView.urlInputView, 'select' );
 			const viewMock = {
 				ready: true,
@@ -248,7 +249,7 @@ describe( 'Link', () => {
 					} );
 			} );
 
-			//https://github.com/ckeditor/ckeditor5-link/issues/113
+			// https://github.com/ckeditor/ckeditor5-link/issues/113
 			it( 'updates the position of the panel – editing a link, then the selection remains in the link upon #render', () => {
 				const viewDocument = editor.editing.view;
 
@@ -270,7 +271,7 @@ describe( 'Link', () => {
 					} );
 			} );
 
-			//https://github.com/ckeditor/ckeditor5-link/issues/113
+			// https://github.com/ckeditor/ckeditor5-link/issues/113
 			it( 'updates the position of the panel – creating a new link, then the selection moved upon #render', () => {
 				const viewDocument = editor.editing.view;
 
@@ -295,7 +296,7 @@ describe( 'Link', () => {
 					} );
 			} );
 
-			//https://github.com/ckeditor/ckeditor5-link/issues/113
+			// https://github.com/ckeditor/ckeditor5-link/issues/113
 			it( 'hides of the panel – editing a link, then the selection moved out of the link upon #render', () => {
 				const viewDocument = editor.editing.view;
 
@@ -318,11 +319,14 @@ describe( 'Link', () => {
 					} );
 			} );
 
-			//https://github.com/ckeditor/ckeditor5-link/issues/113
+			// https://github.com/ckeditor/ckeditor5-link/issues/113
 			it( 'hides of the panel – editing a link, then the selection moved to another link upon #render', () => {
 				const viewDocument = editor.editing.view;
 
-				setModelData( editor.document, '<paragraph><$text linkHref="url">f[]oo</$text>bar<$text linkHref="url">b[]az</$text></paragraph>' );
+				setModelData(
+					editor.document,
+					'<paragraph><$text linkHref="url">f[]oo</$text>bar<$text linkHref="url">b[]az</$text></paragraph>'
+				);
 
 				return linkFeature._showPanel()
 					.then( () => {
@@ -341,7 +345,7 @@ describe( 'Link', () => {
 					} );
 			} );
 
-			//https://github.com/ckeditor/ckeditor5-link/issues/113
+			// https://github.com/ckeditor/ckeditor5-link/issues/113
 			it( 'hides the panel – editing a link, then the selection expands upon #render', () => {
 				const viewDocument = editor.editing.view;
 

+ 4 - 3
packages/ckeditor5-link/tests/linkcommand.js

@@ -34,13 +34,13 @@ describe( 'LinkCommand', () => {
 	describe( 'value', () => {
 		describe( 'collapsed selection', () => {
 			it( 'should be equal attribute value when selection is placed inside element with `linkHref` attribute', () => {
-				setData( document, `<$text linkHref="url">foo[]bar</$text>` );
+				setData( document, '<$text linkHref="url">foo[]bar</$text>' );
 
 				expect( command.value ).to.equal( 'url' );
 			} );
 
 			it( 'should be undefined when selection is placed inside element without `linkHref` attribute', () => {
-				setData( document, `<$text bold="true">foo[]bar</$text>` );
+				setData( document, '<$text bold="true">foo[]bar</$text>' );
 
 				expect( command.value ).to.undefined;
 			} );
@@ -130,7 +130,8 @@ describe( 'LinkCommand', () => {
 				expect( command.value ).to.equal( 'url' );
 			} );
 
-			it( 'should overwrite `linkHref` attribute of selected text only, when selection end inside text with `linkHref` attribute', () => {
+			it( 'should overwrite `linkHref` attribute of selected text only, when selection end inside text with `linkHref` ' +
+				'attribute', () => {
 				setData( document, 'f[o<$text linkHref="other url">ob]a</$text>r' );
 
 				expect( command.value ).to.undefined;

+ 1 - 3
packages/ckeditor5-link/tests/linkengine.js

@@ -17,9 +17,7 @@ describe( 'LinkEngine', () => {
 	let editor, doc;
 
 	beforeEach( () => {
-		return VirtualTestEditor.create( {
-				plugins: [ Paragraph, LinkEngine ]
-			} )
+		return VirtualTestEditor.create( { plugins: [ Paragraph, LinkEngine ] } )
 			.then( newEditor => {
 				editor = newEditor;
 

+ 4 - 4
packages/ckeditor5-link/tests/manual/tickets/113/1.js

@@ -44,7 +44,7 @@ ClassicEditor.create( document.querySelector( '#editor-delete' ), {
 .catch( err => console.error( err.stack ) );
 
 function wait( delay ) {
-	return new Promise( ( resolve ) => {
+	return new Promise( resolve => {
 		setTimeout( () => resolve(), delay );
 	} );
 }
@@ -54,7 +54,7 @@ function startExternalInsert( editor ) {
 	const bath = document.batch( 'transparent' );
 
 	function type( path, text ) {
-		return new Promise( ( resolve ) => {
+		return new Promise( resolve => {
 			let position = new Position( document.getRoot(), path );
 			let index = 0;
 
@@ -64,7 +64,7 @@ function startExternalInsert( editor ) {
 						bath.insert( position, new Text( text[ index ] ) );
 						position = position.getShiftedBy( 1 );
 
-						let nextLetter = text[ ++index ];
+						const nextLetter = text[ ++index ];
 
 						if ( nextLetter ) {
 							typing( nextLetter );
@@ -91,7 +91,7 @@ function startExternalInsert( editor ) {
 	}
 
 	wait( 3000 )
-		.then( () => type( [ 0, 36 ], `This specification defines the 5th major revision of the core language of the World Wide Web. ` ) )
+		.then( () => type( [ 0, 36 ], 'This specification defines the 5th major revision of the core language of the World Wide Web. ' ) )
 		.then( () => insertNewLine( [ 0 ] ) )
 		.then( () => type( [ 0, 0 ], 'a' ) )
 		.then( () => insertNewLine( [ 1 ] ) )

+ 3 - 1
packages/ckeditor5-link/tests/ui/linkformview.js

@@ -3,6 +3,8 @@
  * For licensing, see LICENSE.md.
  */
 
+/* globals Event */
+
 import LinkFormView from '../../src/ui/linkformview';
 import View from '@ckeditor/ckeditor5-ui/src/view';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
@@ -18,7 +20,7 @@ describe( 'LinkFormView', () => {
 	let view;
 
 	beforeEach( () => {
-		view = new LinkFormView( { t: ( val ) => val } );
+		view = new LinkFormView( { t: val => val } );
 
 		return view.init();
 	} );

+ 2 - 3
packages/ckeditor5-link/tests/unlinkcommand.js

@@ -91,9 +91,8 @@ describe( 'UnlinkCommand', () => {
 				expect( getData( document ) ).to.equal( 'foo[]bar' );
 			} );
 
-			it(
-				'should remove `linkHref` attribute from selection siblings with the same attribute value and do not modify other attributes',
-			() => {
+			it( 'should remove `linkHref` attribute from selection siblings with the same attribute value and do not modify ' +
+				'other attributes', () => {
 				setData(
 					document,
 					'<$text linkHref="other url">fo</$text>' +