#12619 closed Bug (fixed)
[Chrome] Drop image to the empty document does not work properly.
Reported by: | Piotr Jasiun | Owned by: | Artur Delura |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.5.0 Beta |
Component: | General | Version: | |
Keywords: | Cc: |
Description
Drop image to the empty document does not work properly. Needs fix.
Change History (16)
comment:1 Changed 10 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 10 years ago by
Owner: | set to Artur Delura |
---|---|
Status: | confirmed → assigned |
comment:4 Changed 10 years ago by
Lets try with iframe document, or iframe itself, or contents element. There should be some way. Configuration is not an option in this case. I have even no idea how such option should be called so user will understand what does it do.
comment:5 Changed 10 years ago by
Definitely agree with PJ. The inner document is ours and we can do whatever we want with it. The editor container is ours too. But the outer space no.
But I don't understand why did you actually want to touch the outer document. The issue is that dropping into empty inner document does not work. So the only thing I imagine we need to do is to start listening on the inner document instead of on the body.
comment:6 Changed 10 years ago by
I agree with you guys. I somehow overlooked fact that document cover whole area which we need to D&D.
comment:7 Changed 10 years ago by
Okay, so to prevent reloading page on empty document we have to listen to dragover
event in our document and prevent default browser behaviour. This will also prevent browser from displaying cursor which let user know where exactly image will be dropped.
To restore this behaviour, we have to set caret position artfically in our document. To do this we can use methods like Document.caretPositionFromPoint()
or Document.caretRangeFromPoint
, but as we know it's very unstable.
Question is whether we want to go this way.
comment:8 Changed 10 years ago by
We have getRangeAtDropPossition
method: https://github.com/ckeditor/ckeditor-dev/blob/major/plugins/clipboard/plugin.js#L1632-L1772.
But the problem is about dropping below the document and only on Chrome (I hope), so you could use caretRangeFromPoint
https://github.com/ckeditor/ckeditor-dev/blob/major/plugins/clipboard/plugin.js#L1651-L1653 with the real x
posiotion and y
on the bottom of body.
comment:9 Changed 10 years ago by
Okay, I worked out simplest solution:
If dragover
target is HTML element then we prevent default browser behaviour.
if ( evt.data.$.target.tagName === 'HTML' ) { evt.data.preventDefault(); }
comment:10 Changed 10 years ago by
Even simpler - evt.data.getTarget().is( 'html' )
.
But knowing IEs check first if evt.data.getTarget()
returns something and that it's an element. IEs tended to return whatever they like (including null).
comment:11 Changed 10 years ago by
Status: | assigned → review |
---|
Changes in branch:t/12619b. I'm not sure about manual tests which I've written.
comment:12 Changed 10 years ago by
Status: | review → review_failed |
---|
Use server mock instead of real CKFinder for manual tests like these tests do. Also you could move manual test to the uploadwidget
plugin since this is about uploading.
comment:13 Changed 10 years ago by
Status: | review_failed → assigned |
---|
comment:15 Changed 10 years ago by
Status: | assigned → review |
---|
comment:16 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | review → closed |
That's nice that you managed to fix this in such a simple way. Closed with git:68bc88a.
To allow drop on empty document we are forced to listen to
dragover
event onCKEDITOR.document
and prevent default browser behaviour when fired. Since issue seems quite easy to fix, there is an issue that we are interferencing DOM element which is not an CKEDTIOR property.I think this shouldn't be a default behaviour. We should add an option config, which will let user decide whether he or she want us to prevent default browser behaviour.