From 9913939d77e164ccd7ffc0fa84a59f2fb6920ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sun, 28 Jun 2015 16:33:50 +0200 Subject: [PATCH 1/4] Focusing editor breaks 'defaultRange' because previous selection is restored. --- plugins/clipboard/plugin.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/clipboard/plugin.js b/plugins/clipboard/plugin.js index 53d50ec0be1..7879cc7d639 100644 --- a/plugins/clipboard/plugin.js +++ b/plugins/clipboard/plugin.js @@ -1724,11 +1724,6 @@ * @returns {CKEDITOR.dom.range} range at drop position. */ getRangeAtDropPosition: function( dropEvt, editor ) { - // If we drop content from the external source we need to call focus on IE. - if ( CKEDITOR.env.ie ) { - editor.focus(); - } - var $evt = dropEvt.data.$, x = $evt.clientX, y = $evt.clientY, @@ -1759,6 +1754,9 @@ } // IE 8 and all IEs if !defaultRange. else if ( document.body.createTextRange ) { + // To use this method we need a focus (which may be somewhere else in case of external drop). + editor.focus(); + $range = editor.document.getBody().$.createTextRange(); try { var sucess = false; From 381149dadb1767f6d8d1389258185581401d0ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sun, 28 Jun 2015 16:53:30 +0200 Subject: [PATCH 2/4] ExteTests: nded manual test description. --- tests/plugins/clipboard/manual/draganddrop.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/plugins/clipboard/manual/draganddrop.md b/tests/plugins/clipboard/manual/draganddrop.md index 226d290f393..daf7eb13c96 100644 --- a/tests/plugins/clipboard/manual/draganddrop.md +++ b/tests/plugins/clipboard/manual/draganddrop.md @@ -7,7 +7,9 @@ Expected behavior: ------------------ - * proper drop position, + * proper drop position (**IMPORTANT**): + * check this carefully, + * make sure to try more than once ([#13472](http://dev.ckeditor.com/ticket/13472)), * in the internal and cross editor D&D: dragged content should be removed, * no content lost (e.g. ids of anchors), * paste event should be fired, From 94713b48a74330c28f90e66d21eef9b50b02ba6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sun, 28 Jun 2015 17:15:59 +0200 Subject: [PATCH 3/4] Editable must has focus, otherwise use the backup mechanism, because selection inside fake sel container may be returned. --- plugins/clipboard/plugin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/clipboard/plugin.js b/plugins/clipboard/plugin.js index 7879cc7d639..f81de8e130f 100644 --- a/plugins/clipboard/plugin.js +++ b/plugins/clipboard/plugin.js @@ -1747,12 +1747,14 @@ range.collapse( true ); } // IEs 9+. - else if ( CKEDITOR.env.ie && CKEDITOR.env.version > 8 && defaultRange ) { + // We check if editable is focused to make sure that it's an internal DnD. External DnD must use the second + // mechanism because of http://dev.ckeditor.com/ticket/13472#comment:6. + else if ( CKEDITOR.env.ie && CKEDITOR.env.version > 8 && defaultRange && editor.editable().hasFocus ) { // On IE 9+ range by default is where we expected it. // defaultRange may be undefined if dragover was canceled (file drop). return defaultRange; } - // IE 8 and all IEs if !defaultRange. + // IE 8 and all IEs if !defaultRange or external DnD. else if ( document.body.createTextRange ) { // To use this method we need a focus (which may be somewhere else in case of external drop). editor.focus(); From 64255c9610d86462ee7a4052e4e7664beb913b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Sun, 28 Jun 2015 18:37:07 +0200 Subject: [PATCH 4/4] Tests: More options to dnd. --- tests/plugins/clipboard/manual/draganddrop.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/plugins/clipboard/manual/draganddrop.html b/tests/plugins/clipboard/manual/draganddrop.html index 9020b8c6f3a..b95556c2f82 100644 --- a/tests/plugins/clipboard/manual/draganddrop.html +++ b/tests/plugins/clipboard/manual/draganddrop.html @@ -13,7 +13,7 @@

Helpers (hide/show)

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. In commodo vulputate tempor. Sed <b>at elit</b> vel ligula mollis aliquet a ac odio. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. CKEditor logo In commodo vulputate tempor. Sed <b>at elit</b> vel ligula mollis aliquet a ac odio.
 Aenean cursus egestas ipsum.