Jelajahi Sumber

Fixed: Indent fixer callback should not crash editor when "empty content" is inserted.

Szymon Cofalik 8 tahun lalu
induk
melakukan
b5a6ca52fb

+ 1 - 1
packages/ckeditor5-list/src/converters.js

@@ -738,7 +738,7 @@ export function modelIndentPasteFixer( evt, [ content, selection ] ) {
 	// would create incorrect model.
 	let item = content.is( 'documentFragment' ) ? content.getChild( 0 ) : content;
 
-	if ( item.is( 'listItem' ) ) {
+	if ( item && item.is( 'listItem' ) ) {
 		// Get a reference list item. Inserted list items will be fixed according to that item.
 		const pos = selection.getFirstPosition();
 		let refItem = null;

+ 8 - 0
packages/ckeditor5-list/tests/listengine.js

@@ -3257,6 +3257,14 @@ describe( 'ListEngine', () => {
 				'<paragraph>B</paragraph>'
 			);
 		} );
+
+		it( 'should not crash when "empty content" is inserted', () => {
+			setModelData( modelDoc, '<paragraph>[]</paragraph>' );
+
+			expect( () => {
+				editor.data.insertContent( new ModelDocumentFragment(), modelDoc.selection );
+			} ).not.to.throw();
+		} );
 	} );
 
 	describe( 'other', () => {