Unfortunately it seems that drag and drop is broken in ckeditor version 4.5.1
On Chrome:
Uncaught TypeError: Cannot read property 'type' of null
CKEDITOR.dom.range.setStart @ ckeditor.js?nqyh4s:153
CKEDITOR.dom.range.setStartBefore @ ckeditor.js?nqyh4s:154
CKEDITOR.dom.range.setStartAt @ ckeditor.js?nqyh4s:155
CKEDITOR.dom.range.moveToPosition @ ckeditor.js?nqyh4s:152
k.getRange @ ckeditor.js?nqyh4s:1071
(anonymous function) @ plugin.js?t=F62B:512
j @ ckeditor.js?nqyh4s:10
CKEDITOR.event.CKEDITOR.event.fire @ ckeditor.js?nqyh4s:12
CKEDITOR.dom.domObject.a @ ckeditor.js?nqyh4s:47
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | fix-compatibility-4-5-2525450-11.patch | 1.6 KB | gifad |
| #3 | fix-compatibility-4-5-2525450-3.patch | 2.29 KB | nagy.balint |
Comments
Comment #1
nagy.balint commentedHmm if I remove the
if (editableHasContent && !CKEDITOR.tools.isEmpty(liner.visible)) {part and I let it go with the else branch, then I get a normal image inserted and a working widget.So it seems both an issue with the getRange function and also maybe a preventdefault issue somewhere.
The getRange issue only happens when trying to insert it at the beginning of the editor.
Comment #2
nagy.balint commentedTested it on firefox, there it works fine visually, no double addition and insert works, however it also throws the
TypeError: startNode is null range.js:1850:0
Comment #3
nagy.balint commentedI have managed to make a workaround.
Tested on IE9, Firefox 38, Chrome 43, both ckeditor 4.5.1 and ckeditor 4.4.6
It seems that the only way to prevent the new clipboard plugin to double insert (one widget and one simple markup) is to return false from the paste event. Of course that paste event is only active during a dnd drag so in other situations the paste event should still work.
I used return false because preventPropagation and preventDefault did not seem to be available in that context.
The other issue with the error on the finder.getRange seems to be a race condition, cause when I debugged in browser sometimes it worked sometimes it did not, so used a setTimeout and it started to work, just needed to put a setTimeout to the dragend event callback as well as that will be called even on the drop case as well, and it should not cleanup the liner before the drop has a chance to act after the delay.
Of course using timeout can be problematic if the user's computer is too slow, and would require different timings.
The workaround seems to be working for me, but more testing is required.
I think at least a workaround should be committed in this case soon, as maybe I just could not find it, but if you would like to build a custom widget enabled version of ckeditor you can only do that with the latest version.
If anyone has a better idea, let me know :)
Comment #4
gifad commentedTested #3 with fresh Firefox 39, and Safari, in iframe and divarea modes : works fine, thanks nagy.balint !
and yes, the "normal" cut/copy/paste operations are still alive...
Comment #5
nagy.balint commentedWe can wait a little bit if 4.5.2 fixes anything.
Also we can think whether we can somehow avoid the setTimeout calls.
Otherwise this or some improvement on this should be committed before the next release.
Comment #6
gifad commentedplease have a look at ckeditor sample code
this is very similar to scald library...
interesting comment :
// Note: All pasted and dropped content is handled in one event - editor#paste.Is CKEditor 4.5+ an option for scald 1.5 ?
Comment #7
nagy.balint commented@gifad for paste i think we are fine, as with the patch the paste event will
return false;when the drag from the library is in progress. After the dragging the cleanup code will remove the paste event callback.And so anything that is not dragged from the library should still work with the new 4.5 behavior in theory.
And we can continue to handle drag from the library as we did in the past and for older ckeditor versions.
My only concern was about the setTimeouts that i had to introduce for the finder.getRange js error, which seemed to be a race condition. And could not find an explanation in any doc.
Otherwise yes, for the next release we have to include support for 4.5 because otherwise it would be complicated to get a widget ready build, as we would need to host an older version, or find some alternative way of constructing the ckeditor package, and users would not be able to just construct it on the ckeditor website, as that would give them 4.5.1.
Comment #8
nagy.balint commentedAlso users will likely require 4.5.x because of Microsoft Edge support.
Comment #9
gifad commenteddndck4/plugin.js #537 :
see eventsbuffers doc
Comment #10
gifad commentednot fully tested, but this may be an approach...
Comment #11
gifad commentedgiven more tests : ok
fixed : remove debug logging
Comment #12
nagy.balint commentedI will test it tomorrow, thanks :)
Comment #14
nagy.balint commentedTested on ckeditor 4.4.6 on IE 9, Firefox 38, Chrome 43.
Tested on ckeditor 4.5.1 on IE 9, Firefox 38, Chrome 43.
Committed thanks!