Ticket #802 (closed enhancement: inactive)
Add a config option to disable dragging into an HTMLArea
| Reported by: | jcsalem | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.97 |
| Component: | Plugins | Version: | |
| Severity: | minor | Keywords: | |
| Cc: |
Description
Dragging content, especially images, into the HTMLArea's iframe can be problematic. In the case of images, the image will appear in the iframe but when the HTMLArea is submitted the image will not be uploaded to the server. Only the link (which, for example, may be just a link to an image on the user's local machine) is saved.
To work around this, I want to disable dragging into the iframe. The code below implements this and would be nice to have as an HTMLArea config option.
Finally, I think the ideal thing would be to add an ondrop handler to actually parse the the image/code being dragged and do the appropriate thing (e.g., automatically upload the image). However, this doesn't seem to be possible as the HTML/image content being dragged is not accessible. [On IE, look at the dataTransfer.getData method which only returns URLs and text data. If you're dragging an image or HTML you're out of luck.]
Anyway, here is the code I'm using to stop the dragging:
if (HTMLArea.is_ie)
{
// IE
HTMLArea._addEvent(editor._doc.body,"dragenter", function() {return false;});
}
else
{
// Firefox
HTMLArea._addEvent(editor._doc, "dragover", function(ev) {HTMLArea._stopEvent(ev); return false;});
HTMLArea._addEvent(editor._textArea,"dragover", function(ev) {HTMLArea._stopEvent(ev); return false;});
}
}
