From c6d217e6848c5b4bb81ddf8bb71619f15c1ec274 Mon Sep 17 00:00:00 2001 From: Paul Nicholls Date: Tue, 26 Mar 2013 12:19:58 +1300 Subject: [PATCH 216/216] Prevent drag-drop of images into TinyMCE The standard behaviour of TinyMCE is to embed dropped images using data-URIs, which is not desired behaviour. Ideally, it should upload it to the Moodle filesystem and trigger the Moodle image plugin, but as a first step, this disables the data-URI embedding. --- .../tinymce/plugins/moodleimage/tinymce/editor_plugin.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/editor/tinymce/plugins/moodleimage/tinymce/editor_plugin.js b/lib/editor/tinymce/plugins/moodleimage/tinymce/editor_plugin.js index 42121cf..45e50c3 100644 --- a/lib/editor/tinymce/plugins/moodleimage/tinymce/editor_plugin.js +++ b/lib/editor/tinymce/plugins/moodleimage/tinymce/editor_plugin.js @@ -32,6 +32,18 @@ title : 'advimage.image_desc', cmd : 'mceMoodleImage' }); + ed.onInit.add(function() { + ed.dom.bind(ed.getWin(), ['dragenter', 'dragover', 'draggesture', 'drag', 'drop'], function(e) { + // Cancel drop event if it's an image file being dragged in + if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length) { + e.preventDefault(); + e.stopPropagation(); + var alertpanel = new M.core.alert({title:'Please upload your image', message:'Please upload your image using the
"Insert/edit Image" icon ().', lightbox:true}); + Y.Node.one('#id_yuialertconfirm-' + alertpanel.COUNT).focus(); + return false; + } + }); + }); }, getInfo : function() { -- 1.8.0.msysgit.0