From 7eb528ee1fc2984385b2dc4fbe147d7619e5be7a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 7 Jul 2014 20:48:35 +0000 Subject: [PATCH] Instead of replacing a dropped image with an error image, we'll remove it, and pass the image to the first et2_file widget with a drop target. That's not ideal, but it should work for us in most cases until CKEditor fully supports drag and drop. (Firefox only) --- etemplate/js/et2_widget_htmlarea.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_widget_htmlarea.js b/etemplate/js/et2_widget_htmlarea.js index 57aab079d3..553233687f 100644 --- a/etemplate/js/et2_widget_htmlarea.js +++ b/etemplate/js/et2_widget_htmlarea.js @@ -168,19 +168,32 @@ var et2_htmlarea = et2_inputWidget.extend( // when dragging, so we replace dropped images with error icon. var replaceImgText = function(html) { var ret = html.replace( /]*src="(data:.*;base64,.*?)"[^>]*>/gi, function( img, src ){ - return img.replace(src,egw.image('error')); - }); + return ''; + }); return ret; } - var chkImg = function() { + var chkImg = function(e) { // don't execute code if the editor is readOnly if (editor.readOnly) return; + // Remove the image from the text setTimeout( function() { editor.document.$.body.innerHTML = replaceImgText(editor.document.$.body.innerHTML); },200); + + // Try to pass the image into the first et2_file that will accept it + if(e.data.$.dataTransfer) + { + self.getRoot().iterateOver(function(widget) { + if(widget.options.drop_target) + { + widget.set_value(e.data.$.dataTransfer.files,e.data.$); + return; + } + },e.data.$,et2_file); + } }; editor.on( 'contentDom', function() {