Skip to content

Commit 20cc11b

Browse files
committed
Merge branch 't/13184c'
2 parents 16dc2e0 + 77e9b6e commit 20cc11b

File tree

7 files changed

+87
-39
lines changed

7 files changed

+87
-39
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Fixed Issues:
1717
* [#11616](http://dev.ckeditor.com/ticket/11616): [Chrome] Fixed: Resizing the editor while it is not displayed breaks the editable. Fixed also [#9160](http://dev.ckeditor.com/ticket/9160) and [#9715](http://dev.ckeditor.com/ticket/9715).
1818
* [#13397](http://dev.ckeditor.com/ticket/13397): Fixed: Drag&drop a widget inside its nested widget crashes the editor.
1919
* [#13420](http://dev.ckeditor.com/ticket/13420): Fixed: The [Auto Embed](http://ckeditor.com/addon/autoembed) plugin ignores encoded characters in URL parameters.
20+
* [#13184](http://dev.ckeditor.com/ticket/13184): Fixed: Web page reloaded after drop on editor UI.
2021

2122
## CKEditor 4.5.1
2223

plugins/clipboard/plugin.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,11 @@
12521252
return data;
12531253
}
12541254

1255+
function preventDefaultSetDropEffectToNone( evt ) {
1256+
evt.data.preventDefault();
1257+
evt.data.$.dataTransfer.dropEffect = 'none';
1258+
}
1259+
12551260
function initDragDrop( editor ) {
12561261
var clipboard = CKEDITOR.plugins.clipboard;
12571262

@@ -1263,14 +1268,9 @@
12631268

12641269
// -------------- DRAGOVER TOP & BOTTOM --------------
12651270

1266-
function preventDefaultSetDropEffectToNone( evt ) {
1267-
evt.data.preventDefault();
1268-
evt.data.$.dataTransfer.dropEffect = 'none';
1269-
}
1270-
12711271
// Not allowing dragging on toolbar and bottom (#12613).
1272-
top && top.on( 'dragover', preventDefaultSetDropEffectToNone );
1273-
bottom && bottom.on( 'dragover', preventDefaultSetDropEffectToNone );
1272+
clipboard.preventDefaultDropOnElement( top );
1273+
clipboard.preventDefaultDropOnElement( bottom );
12741274

12751275
// -------------- DRAGSTART --------------
12761276
// Listed on dragstart to mark internal and cross-editor drag & drop
@@ -1995,6 +1995,16 @@
19951995
} else {
19961996
return new this.dataTransfer( null, sourceEditor );
19971997
}
1998+
},
1999+
2000+
/**
2001+
* Prevents dropping on the specified element.
2002+
*
2003+
* @since 4.5
2004+
* @param {CKEDITOR.dom.element} element The element on which dropping should be disabled.
2005+
*/
2006+
preventDefaultDropOnElement: function( element ) {
2007+
element && element.on( 'dragover', preventDefaultSetDropEffectToNone );
19982008
}
19992009
};
20002010

plugins/dialog/plugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ CKEDITOR.DIALOG_STATE_BUSY = 2;
177177
title = body.getChild( 0 ),
178178
close = body.getChild( 1 );
179179

180+
// Don't allow dragging on dialog (#13184).
181+
editor.plugins.clipboard && CKEDITOR.plugins.clipboard.preventDefaultDropOnElement( body );
182+
180183
// IFrame shim for dialog that masks activeX in IE. (#7619)
181184
if ( CKEDITOR.env.ie && !CKEDITOR.env.quirks ) {
182185
var src = 'javascript:void(function(){' + encodeURIComponent( 'document.open();(' + CKEDITOR.tools.fixDomain + ')();document.close();' ) + '}())', // jshint ignore:line

plugins/notification/plugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ function Notification( editor, options ) {
125125
}
126126

127127
this.element = this._createElement();
128+
129+
// Don't allow dragging on notification (#13184).
130+
editor.plugins.clipboard && CKEDITOR.plugins.clipboard.preventDefaultDropOnElement( this.element );
128131
}
129132

130133
/**

tests/plugins/clipboard/drop.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,30 @@ var testsForMultipleEditor = {
11021102
dropTarget.fire( 'drop', evt );
11031103

11041104
assert.isFalse( dropSpy.called );
1105+
},
1106+
1107+
'test preventDefaultDropOnElement': function() {
1108+
var editor = this.editors.divarea,
1109+
bot = this.editorBots[ editor.name ],
1110+
spy = sinon.spy(),
1111+
data = {
1112+
preventDefault: spy,
1113+
$: {
1114+
dataTransfer: {}
1115+
}
1116+
};
1117+
1118+
bot.setHtmlWithSelection( '<div><p>foo</p></div>' );
1119+
editor.resetUndo();
1120+
1121+
var element = editor.editable().findOne( 'p' );
1122+
1123+
CKEDITOR.plugins.clipboard.preventDefaultDropOnElement( element );
1124+
1125+
element.fire( 'dragover', data );
1126+
1127+
assert.isTrue( spy.called, 'preventDefault called.' );
1128+
assert.areEqual( 'none', data.$.dataTransfer.dropEffect, 'dropEffect reset to \'none\'' );
11051129
}
11061130
};
11071131

tests/plugins/uploadwidget/manual/droponnotallowedparts.html

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,42 @@
22
File uploading is not supported on Internet Explorer 9 and below.
33
</div>
44

5-
<textarea id="editor1">
6-
The true&lt;br/&gt;
7-
mark of maturity&lt;br/&gt;
8-
is when&lt;br/&gt;
9-
somebody hurts&lt;br/&gt;
10-
</textarea>
11-
<div id="editor2" contenteditable="true" >
12-
you and you try<br/>
13-
to understand<br/>
14-
their situation<br/>
15-
</div>
16-
<textarea id="editor3">
17-
instead of trying&lt;br/&gt;
18-
to hurt them&lt;br/&gt;
19-
back&lt;br/&gt;
20-
</textarea>
5+
<h2>Classic instance</h2>
6+
<textarea id="editor1">x</textarea>
7+
8+
<h2>Inline instance</h2>
9+
<div id="editor2" contenteditable="true" >y</div>
10+
11+
<h2>Div Editing Area</h2>
12+
<textarea id="editor3">z</textarea>
13+
14+
<hr/>
15+
<input onclick="showNotifications();" type="button" value="Show notification" />
2116

2217
<script>
23-
CKEDITOR.replace( 'editor1', {
24-
imageUploadUrl: 'http://sub.ckeditor.dev/',
25-
extraPlugins: 'elementspath'
26-
} );
18+
var editors = [
19+
CKEDITOR.replace( 'editor1', {
20+
imageUploadUrl: 'http://sub.ckeditor.dev/',
21+
extraPlugins: 'elementspath'
22+
} ),
2723

28-
CKEDITOR.inline( 'editor2', {
29-
imageUploadUrl: 'http://sub.ckeditor.dev/'
30-
} );
24+
CKEDITOR.inline( 'editor2', {
25+
imageUploadUrl: 'http://sub.ckeditor.dev/'
26+
} ),
3127

32-
CKEDITOR.replace( 'editor3', {
33-
imageUploadUrl: 'http://sub.ckeditor.dev/',
34-
extraPlugins: 'divarea'
35-
} );
28+
CKEDITOR.replace( 'editor3', {
29+
imageUploadUrl: 'http://sub.ckeditor.dev/',
30+
extraPlugins: 'divarea'
31+
} )
32+
];
3633

3734
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 10 ) {
3835
document.getElementById( 'ignore' ).style.display = 'block';
3936
}
37+
38+
function showNotifications() {
39+
for ( var i = editors.length; i--; ) {
40+
editors[ i ].showNotification( 'Drag an image here.', 'warning' );
41+
}
42+
}
4043
</script>

tests/plugins/uploadwidget/manual/droponnotallowedparts.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
@bender-ckeditor-plugins: wysiwygarea, image2, uploadimage, toolbar, floatingspace
44
@bender-include: _helpers/xhr.js
55

6-
1. Drag and drop some image into not allowed elements (toolbar, bottom).
6+
1. Drag an image from the hard drive and drop it on disallowed UI elements:
7+
* toolbar (both static and floating),
8+
* bottom space,
9+
* dialog,
10+
* notification (use button to display).
711

8-
**Expected result:** There should be visible an no drop cursor on that elements (expect IE).
12+
**Expected:**
13+
* **Page shouldn't be reloaded!**
14+
* The `no–drop` cursor is visible (except IE)
915

10-
**Unexpected result:** Page shouldn't be reloaded.
11-
12-
**Note:** This test use upload mock which will show you *Lena* instead of the real uploaded image.
16+
**Note:** This test uses upload mock, which means it shows a dummy image.

0 commit comments

Comments
 (0)