浏览代码

Use "imageInsert" command.

Maciej Gołaszewski 7 年之前
父节点
当前提交
09a084c9c5
共有 1 个文件被更改,包括 1 次插入21 次删除
  1. 1 21
      packages/ckeditor5-ckfinder/src/ckfindercommand.js

+ 1 - 21
packages/ckeditor5-ckfinder/src/ckfindercommand.js

@@ -13,8 +13,6 @@ import Command from '@ckeditor/ckeditor5-core/src/command';
 import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
-import { findOptimalInsertionPosition } from '@ckeditor/ckeditor5-widget/src/utils';
-
 /**
  * The CKFinder command. It is used by the {@link module:ckfinder/ckfinderediting~CKFinderEditing ckfinder editng feature}
  * to open a CKFinder file browser to insert an image or a link to a file into content.
@@ -142,23 +140,5 @@ function insertImages( editor, urls ) {
 		return;
 	}
 
-	const model = editor.model;
-
-	// The first image will be inserted according to image inserting algorithm. Next one after the previous one.
-	let insertAt = findOptimalInsertionPosition( model.document.selection, model );
-
-	model.change( writer => {
-		for ( const url of urls ) {
-			const imageElement = writer.createElement( 'image', { src: url } );
-
-			// Insert image & update the selection.
-			model.insertContent( imageElement, insertAt );
-
-			// Inserting an image might've failed due to schema regulations.
-			if ( imageElement.parent ) {
-				writer.setSelection( imageElement, 'on' );
-				insertAt = writer.createPositionAfter( imageElement );
-			}
-		}
-	} );
+	editor.execute( 'imageInsert', { sources: urls } );
 }