Sfoglia il codice sorgente

Fixed defaultBlockName parameter name in EnterCommand._doExecute().

Szymon Kupś 9 anni fa
parent
commit
6650857463

+ 1 - 1
packages/ckeditor5-enter/src/entercommand.js

@@ -21,7 +21,7 @@ export default class EnterCommand extends Command {
 		const doc = this.editor.document;
 
 		doc.enqueueChanges( () => {
-			enterBlock( doc.batch(), doc.selection, { defaultBlock: 'paragraph' } );
+			enterBlock( doc.batch(), doc.selection, { defaultBlockName: 'paragraph' } );
 		} );
 	}
 }

+ 11 - 2
packages/ckeditor5-enter/tests/entercommand.js

@@ -9,7 +9,7 @@ import ModelTestEditor from '/tests/ckeditor5/_utils/modeltesteditor.js';
 import { default as EnterCommand, enterBlock } from '/ckeditor5/enter/entercommand.js';
 import { getData, setData } from '/tests/engine/_utils/model.js';
 
-let editor, doc;
+let editor, doc, schema;
 
 beforeEach( () => {
 	return ModelTestEditor.create()
@@ -20,7 +20,7 @@ beforeEach( () => {
 			const command = new EnterCommand( editor );
 			editor.commands.set( 'enter', command );
 
-			const schema = doc.schema;
+			schema = doc.schema;
 
 			// Note: We could use real names like 'paragraph', but that would make test patterns too long.
 			// Plus, this is actually a good test that the algorithm can be used for any model.
@@ -41,6 +41,15 @@ describe( 'EnterCommand', () => {
 		expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<p>foo</p><p></p>' );
 		expect( spy.calledOnce ).to.be.true;
 	} );
+
+	it( 'uses paragraph as default block', () => {
+		schema.registerItem( 'paragraph', '$block' );
+		setData( doc, '<p>foo<selection /></p>' );
+
+		editor.execute( 'enter' );
+
+		expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<p>foo</p><paragraph></paragraph>' );
+	} );
 } );
 
 describe( 'enterBlock', () => {