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

Check if image was inserted before trying to create selection on it.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
befca5ac87
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      packages/ckeditor5-ckfinder/src/ckfindercommand.js

+ 5 - 3
packages/ckeditor5-ckfinder/src/ckfindercommand.js

@@ -141,10 +141,12 @@ function insertImages( editor, urls ) {
 
 			// Insert image & update the selection.
 			model.insertContent( imageElement, insertAt );
-			writer.setSelection( imageElement, 'on' );
 
-			// Insert subsequent image after the previous one.
-			insertAt = writer.createPositionAfter( imageElement );
+			// Inserting an image might've failed due to schema regulations.
+			if ( imageElement.parent ) {
+				writer.setSelection( imageElement, 'on' );
+				insertAt = writer.createPositionAfter( imageElement );
+			}
 		}
 	} );
 }