diff --git a/src/imageuploadcommand.js b/src/imageuploadcommand.js index 72f4d08..aaee691 100644 --- a/src/imageuploadcommand.js +++ b/src/imageuploadcommand.js @@ -10,7 +10,7 @@ import ModelPosition from '@ckeditor/ckeditor5-engine/src/model/position'; import ModelSelection from '@ckeditor/ckeditor5-engine/src/model/selection'; import FileRepository from './filerepository'; import { isImageType } from './utils'; -import Command from '@ckeditor/ckeditor5-core/src/command/command'; +import Command from '@ckeditor/ckeditor5-core/src/command'; /** * @module upload/imageuploadcommand @@ -19,19 +19,19 @@ import Command from '@ckeditor/ckeditor5-core/src/command/command'; /** * Image upload command. * - * @extends module:core/command/command~Command + * @extends module:core/command~Command */ export default class ImageUploadCommand extends Command { /** - * Executes command. + * Executes the command. * - * @protected + * @fires execute * @param {Object} options Options for executed command. * @param {File} options.file Image file to upload. * @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. */ - _doExecute( options ) { + execute( options ) { const editor = this.editor; const doc = editor.document; const batch = options.batch || doc.batch(); diff --git a/src/imageuploadengine.js b/src/imageuploadengine.js index fc671f2..856b099 100644 --- a/src/imageuploadengine.js +++ b/src/imageuploadengine.js @@ -41,7 +41,7 @@ export default class ImageUploadEngine extends Plugin { schema.requireAttributes( 'image', [ 'uploadId' ] ); // Register imageUpload command. - editor.commands.set( 'imageUpload', new ImageUploadCommand( editor ) ); + editor.commands.add( 'imageUpload', new ImageUploadCommand( editor ) ); // Execute imageUpload command when image is dropped or pasted. editor.editing.view.on( 'clipboardInput', ( evt, data ) => { diff --git a/tests/imageuploadcommand.js b/tests/imageuploadcommand.js index 02c5fda..31b1e86 100644 --- a/tests/imageuploadcommand.js +++ b/tests/imageuploadcommand.js @@ -37,12 +37,12 @@ describe( 'ImageUploadCommand', () => { } ); } ); - describe( '_doExecute', () => { + describe( 'execute()', () => { it( 'should insert image', () => { const file = createNativeFileMock(); setModelData( document, '[]foo' ); - command._doExecute( { file } ); + command.execute( { file } ); const id = fileRepository.getLoader( file ).id; expect( getModelData( document ) ).to.equal( `[]foo` ); @@ -52,7 +52,7 @@ describe( 'ImageUploadCommand', () => { const file = createNativeFileMock(); setModelData( document, 'foo[]' ); - command._doExecute( { file } ); + command.execute( { file } ); const id = fileRepository.getLoader( file ).id; expect( getModelData( document ) ).to.equal( `foo[]` ); @@ -62,7 +62,7 @@ describe( 'ImageUploadCommand', () => { const file = createNativeFileMock(); setModelData( document, 'f{}oo' ); - command._doExecute( { file } ); + command.execute( { file } ); const id = fileRepository.getLoader( file ).id; expect( getModelData( document ) ).to.equal( `[]foo` ); @@ -72,7 +72,7 @@ describe( 'ImageUploadCommand', () => { const file = createNativeFileMock(); setModelData( document, '[]' ); - command._doExecute( { file } ); + command.execute( { file } ); const id = fileRepository.getLoader( file ).id; expect( getModelData( document ) ).to.equal( `[]` ); @@ -88,7 +88,7 @@ describe( 'ImageUploadCommand', () => { setModelData( document, '[]' ); - command._doExecute( { file } ); + command.execute( { file } ); expect( getModelData( document ) ).to.equal( '[]' ); } ); @@ -97,7 +97,7 @@ describe( 'ImageUploadCommand', () => { const file = createNativeFileMock(); file.type = 'audio/mpeg3'; setModelData( document, 'foo[]' ); - command._doExecute( { file } ); + command.execute( { file } ); expect( getModelData( document ) ).to.equal( 'foo[]' ); } ); @@ -109,7 +109,7 @@ describe( 'ImageUploadCommand', () => { setModelData( document, '[]foo' ); - command._doExecute( { batch, file } ); + command.execute( { batch, file } ); const id = fileRepository.getLoader( file ).id; expect( getModelData( document ) ).to.equal( `[]foo` );