Преглед на файлове

Code style: Switched to ESLint.

Kamil Piechaczek преди 8 години
родител
ревизия
9f4fb40506

+ 4 - 4
packages/ckeditor5-paragraph/src/paragraph.js

@@ -238,7 +238,7 @@ function isParagraphable( node, context, schema, insideParagraphLikeElement ) {
 
 	// Node is paragraphable if it is inside paragraph like element, or...
 	// It is not allowed at this context...
-	if ( !insideParagraphLikeElement && schema.check( { name: name, inside: context } ) ) {
+	if ( !insideParagraphLikeElement && schema.check( { name, inside: context } ) ) {
 		return false;
 	}
 
@@ -248,7 +248,7 @@ function isParagraphable( node, context, schema, insideParagraphLikeElement ) {
 	}
 
 	// And a node would be allowed in this paragraph...
-	if ( !schema.check( { name: name, inside: context.concat( 'paragraph' ) } ) ) {
+	if ( !schema.check( { name, inside: context.concat( 'paragraph' ) } ) ) {
 		return false;
 	}
 
@@ -259,7 +259,7 @@ function isParagraphable( node, context, schema, insideParagraphLikeElement ) {
 const rootsToFix = new Map();
 
 function findEmptyRoots( doc, batch ) {
-	for ( let rootName of doc.getRootNames() ) {
+	for ( const rootName of doc.getRootNames() ) {
 		const root = doc.getRoot( rootName );
 
 		if ( root.isEmpty ) {
@@ -274,7 +274,7 @@ function findEmptyRoots( doc, batch ) {
 
 // Fixes all empty roots.
 function autoparagraphEmptyRoots() {
-	for ( let [ root, batch ] of rootsToFix ) {
+	for ( const [ root, batch ] of rootsToFix ) {
 		// Only empty roots are in `rootsToFix`. Even if root got content during `changesDone` event (because of, for example
 		// other feature), this will fire `findEmptyRoots` and remove that root from `rootsToFix`. So we are guaranteed
 		// to have only empty roots here.

+ 1 - 1
packages/ckeditor5-paragraph/src/paragraphcommand.js

@@ -60,7 +60,7 @@ export default class ParagraphCommand extends Command {
 			const batch = options.batch || document.batch();
 			const blocks = ( options.selection || document.selection ).getSelectedBlocks();
 
-			for ( let block of blocks ) {
+			for ( const block of blocks ) {
 				if ( !block.is( 'paragraph' ) ) {
 					batch.rename( block, 'paragraph' );
 				}

+ 14 - 26
packages/ckeditor5-paragraph/tests/paragraph-intergration.js

@@ -17,9 +17,7 @@ import { parse as parseView } from '@ckeditor/ckeditor5-engine/src/dev-utils/vie
 describe( 'Paragraph feature – integration', () => {
 	describe( 'with clipboard', () => {
 		it( 'pastes h1+h2+p as p+p+p when heading feature is not present', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, Clipboard ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, Clipboard ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -31,15 +29,15 @@ describe( 'Paragraph feature – integration', () => {
 						content: parseView( '<h1>foo</h1><h2>bar</h2><p>bom</p>' )
 					} );
 
-					expect( getModelData( doc ) ).to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph><paragraph>bom[]</paragraph>' );
+					expect( getModelData( doc ) ).to.equal(
+						'<paragraph>foo</paragraph><paragraph>bar</paragraph><paragraph>bom[]</paragraph>'
+					);
 				} );
 		} );
 
 		// Explainer: the heading feature is configured to handle h2-h4 elements, so h1 has no handler.
 		it( 'pastes h1+h2+p as p+h2+p when heading feature is present', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, Clipboard, HeadingEngine ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, Clipboard, HeadingEngine ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -51,14 +49,14 @@ describe( 'Paragraph feature – integration', () => {
 						content: parseView( '<h1>foo</h1><h2>bar</h2><p>bom</p>' )
 					} );
 
-					expect( getModelData( doc ) ).to.equal( '<paragraph>foo</paragraph><heading1>bar</heading1><paragraph>bom[]</paragraph>' );
+					expect( getModelData( doc ) ).to.equal(
+						'<paragraph>foo</paragraph><heading1>bar</heading1><paragraph>bom[]</paragraph>'
+					);
 				} );
 		} );
 
 		it( 'pastes ul>li+li as p+p when list feature is not present', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, Clipboard ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, Clipboard ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -77,9 +75,7 @@ describe( 'Paragraph feature – integration', () => {
 		// Check whether the paragraph feature doesn't breaking pasting such content by trying to
 		// handle the li element.
 		it( 'pastes ul>li>h2+h3+p as h2+h3+p when heading feature is present', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, Clipboard, HeadingEngine ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, Clipboard, HeadingEngine ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -101,9 +97,7 @@ describe( 'Paragraph feature – integration', () => {
 
 		// See 'should convert ul>li>ul>li+li (in clipboard holder)' in clipboard.js.
 		it( 'pastes ul>li>ul>li+li', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, Clipboard ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, Clipboard ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -125,9 +119,7 @@ describe( 'Paragraph feature – integration', () => {
 
 		// See 'should convert ul>li>p,text (in clipboard holder)' in clipboard.js.
 		it( 'pastes ul>li>p,text', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, Clipboard ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, Clipboard ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -149,9 +141,7 @@ describe( 'Paragraph feature – integration', () => {
 
 	describe( 'with undo', () => {
 		it( 'fixing empty roots should be transparent to undo', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, UndoEngine ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, UndoEngine ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;
@@ -183,9 +173,7 @@ describe( 'Paragraph feature – integration', () => {
 		} );
 
 		it( 'fixing empty roots should be transparent to undo - multiple roots', () => {
-			return VirtualTestEditor.create( {
-					plugins: [ Paragraph, UndoEngine ]
-				} )
+			return VirtualTestEditor.create( { plugins: [ Paragraph, UndoEngine ] } )
 				.then( newEditor => {
 					const editor = newEditor;
 					const doc = editor.document;

+ 1 - 3
packages/ckeditor5-paragraph/tests/paragraph.js

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

+ 4 - 2
packages/ckeditor5-paragraph/tests/paragraphcommand.js

@@ -13,7 +13,7 @@ describe( 'ParagraphCommand', () => {
 	let editor, document, command, root, schema;
 
 	beforeEach( () => {
-		return ModelTestEditor.create().then( ( newEditor ) => {
+		return ModelTestEditor.create().then( newEditor => {
 			editor = newEditor;
 			document = editor.document;
 			schema = document.schema;
@@ -133,7 +133,9 @@ describe( 'ParagraphCommand', () => {
 				selection.addRange( Range.createFromParentsAndOffsets( secondTolastHeading, 0, lastHeading, 0 ) );
 
 				command._doExecute( { selection } );
-				expect( getData( document ) ).to.equal( '<heading1>foo[]bar</heading1><paragraph>baz</paragraph><paragraph>qux</paragraph>' );
+				expect( getData( document ) ).to.equal(
+					'<heading1>foo[]bar</heading1><paragraph>baz</paragraph><paragraph>qux</paragraph>'
+				);
 			} );
 		} );