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

Improved command's test and documentation.

Piotrek Koszuliński 8 лет назад
Родитель
Сommit
ede6dcc1f2

+ 3 - 1
packages/ckeditor5-upload/src/imageuploadcommand.js

@@ -26,7 +26,9 @@ export default class ImageUploadCommand extends Command {
 	 * @param {Object} options Options for executed command.
 	 * @param {File} options.file Image file to upload.
 	 * @param {module:engine/model/position~Position} [options.insertAt] Position at which the image should be inserted.
-	 * If the position won't be specified the image will be inserted next to the selection.
+	 * If the position is not specified the image will be inserted into the current selection.
+	 * Note: You can use the {@link module:upload/utils~findOptimalInsertionPosition} function to calculate
+	 * (e.g. based on the current selection) a position which is more optimal from UX perspective.
 	 * @param {module:engine/model/batch~Batch} [options.batch] Batch to collect all the change steps.
 	 * New batch will be created if this option is not set.
 	 */

+ 3 - 3
packages/ckeditor5-upload/tests/imageuploadcommand.js

@@ -39,15 +39,15 @@ describe( 'ImageUploadCommand', () => {
 	} );
 
 	describe( 'execute()', () => {
-		it( 'should insert image at selection position', () => {
+		it( 'should insert image at selection position (includes deleting selected content)', () => {
 			const file = createNativeFileMock();
-			setModelData( doc, '<paragraph>f[]oo</paragraph>' );
+			setModelData( doc, '<paragraph>f[o]o</paragraph>' );
 
 			command.execute( { file } );
 
 			const id = fileRepository.getLoader( file ).id;
 			expect( getModelData( doc ) )
-				.to.equal( `<paragraph>f</paragraph>[<image uploadId="${ id }"></image>]<paragraph>oo</paragraph>` );
+				.to.equal( `<paragraph>f</paragraph>[<image uploadId="${ id }"></image>]<paragraph>o</paragraph>` );
 		} );
 
 		it( 'should insert directly at specified position (options.insertAt)', () => {