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

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

Szymon Cofalik 8 лет назад
Родитель
Сommit
b5a6ca52fb
2 измененных файлов с 9 добавлено и 1 удалено
  1. 1 1
      packages/ckeditor5-list/src/converters.js
  2. 8 0
      packages/ckeditor5-list/tests/listengine.js

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

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

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

@@ -3257,6 +3257,14 @@ describe( 'ListEngine', () => {
 				'<paragraph>B</paragraph>'
 				'<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', () => {
 	describe( 'other', () => {