Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #51 from ckeditor/t/32
Browse files Browse the repository at this point in the history
Fix: An image dropped on another image will not redirect the browser to the file's path. Closes #32.
  • Loading branch information
szymonkups authored Aug 28, 2017
2 parents d8d61f3 + eca7a6b commit 4f533be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/imageuploadengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export default class ImageUploadEngine extends Plugin {
}
} );

// Prevents from browser redirecting to drag-end-dropped image.
editor.editing.view.on( 'dragover', ( evt, data ) => {
data.preventDefault();
} );

doc.on( 'change', ( evt, type, data ) => {
// Listen on document changes and:
// * start upload process when image with `uploadId` attribute is inserted,
Expand Down
10 changes: 10 additions & 0 deletions tests/imageuploadengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,14 @@ describe( 'ImageUploadEngine', () => {

nativeReaderMock.mockSuccess( base64Sample );
} );

it( 'should prevent from browser redirecting when an image is dropped on another image', () => {
const spy = testUtils.sinon.spy();

editor.editing.view.fire( 'dragover', {
preventDefault: spy
} );

expect( spy.calledOnce ).to.equal( true );
} );
} );
3 changes: 3 additions & 0 deletions tests/manual/imageupload.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
1. Press "Upload progress" button couple times to simulate upload process.
1. After uploading is complete your image should be replaced with sample image from server.

On the occasionn – when you drop an image on another image in the editor,
your browser [**should not** redirect to the image](https://github.com/ckeditor/ckeditor5-upload/issues/32).

Repeat all the steps with:
* dropping multiple images,
* using toolbar button to add one and multiple images,
Expand Down

0 comments on commit 4f533be

Please sign in to comment.