Skip to content

Commit

Permalink
Preventing page reload when droping on non editable elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
adelura authored and Reinmar committed May 29, 2015
1 parent fe4de43 commit bfdd042
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions plugins/clipboard/plugin.js
Expand Up @@ -1341,6 +1341,20 @@
// Cancel native drop.
evt.data.preventDefault();

var target = evt.data.getTarget();

var readOnly;
if ( target.is && target.is( 'html' ) ) {
readOnly = false;
} else {
readOnly = target.isReadOnly();
}

// Do nothing if drop on non editable element (#13015).
if ( readOnly ) {
return;
}

// Getting drop position is one of the most complex part.
var dropRange = clipboard.getRangeAtDropPosition( evt, editor ),
dragRange = clipboard.dragRange;
Expand Down
7 changes: 6 additions & 1 deletion plugins/widget/plugin.js
@@ -1,4 +1,4 @@
/**
/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
Expand Down Expand Up @@ -3044,6 +3044,11 @@
widget.wrapper.append( container );
}

// Preventing page reload (#13015).
widget.wrapper.on( 'dragover', function( evt ) {
evt.data.preventDefault();
}, widget );

widget.wrapper.on( 'mouseenter', widget.updateDragHandlerPosition, widget );
setTimeout( function() {
widget.on( 'data', widget.updateDragHandlerPosition, widget );
Expand Down

0 comments on commit bfdd042

Please sign in to comment.