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

Commit 4f533be

Browse files
authored
Merge pull request #51 from ckeditor/t/32
Fix: An image dropped on another image will not redirect the browser to the file's path. Closes #32.
2 parents d8d61f3 + eca7a6b commit 4f533be

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/imageuploadengine.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export default class ImageUploadEngine extends Plugin {
6464
}
6565
} );
6666

67+
// Prevents from browser redirecting to drag-end-dropped image.
68+
editor.editing.view.on( 'dragover', ( evt, data ) => {
69+
data.preventDefault();
70+
} );
71+
6772
doc.on( 'change', ( evt, type, data ) => {
6873
// Listen on document changes and:
6974
// * start upload process when image with `uploadId` attribute is inserted,

tests/imageuploadengine.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,14 @@ describe( 'ImageUploadEngine', () => {
359359

360360
nativeReaderMock.mockSuccess( base64Sample );
361361
} );
362+
363+
it( 'should prevent from browser redirecting when an image is dropped on another image', () => {
364+
const spy = testUtils.sinon.spy();
365+
366+
editor.editing.view.fire( 'dragover', {
367+
preventDefault: spy
368+
} );
369+
370+
expect( spy.calledOnce ).to.equal( true );
371+
} );
362372
} );

tests/manual/imageupload.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
1. Press "Upload progress" button couple times to simulate upload process.
66
1. After uploading is complete your image should be replaced with sample image from server.
77

8+
On the occasionn – when you drop an image on another image in the editor,
9+
your browser [**should not** redirect to the image](https://github.com/ckeditor/ckeditor5-upload/issues/32).
10+
811
Repeat all the steps with:
912
* dropping multiple images,
1013
* using toolbar button to add one and multiple images,

0 commit comments

Comments
 (0)