Preventing drag&drop of images
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jul 2013 15:40:17 +0000 (17:40 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 29 Jul 2013 15:40:17 +0000 (17:40 +0200)
wcfsetup/install/files/js/3rdParty/ckeditor/plugins/wbbcode/plugin.js

index 384b12a4b0e98f0de507bdfec5d0e2adfe722a80..780a8dc1a0a018391c26b68a4424699e6b62694c 100644 (file)
@@ -13,6 +13,7 @@
                 * Fixes issues with pasted html.
                 */
                event.editor.on('paste', function(ev) {
+                       console.debug("currentValue = " + ev.data.dataValue);
                        if (ev.data.type == 'html') {
                                var $value = ev.data.dataValue;
                                
                                
                                // convert lists into new lines
                                $value = $value.replace(/<\/li>/gi, "\n");
-                               
+                               console.debug($value);
                                // remove html tags
                                $value = $value.replace(/<[^>]+>/g, '');
                                
                                // fix multiple new lines
                                $value = $value.replace(/\n{3,}/gi,"\n\n");
                                
+                               window.dtdesign = $value;
+                               
                                ev.data.dataValue = $value;
                                
                                $pasted = true;
                        }
                }, null, null, 9);
                
+               // prevent drag and drop of images in Firefox
+               event.editor.document.on('drop', function(ev) {
+                       if (ev.data.$.dataTransfer) {
+                               var $html = ev.data.$.dataTransfer.getData('text/html');
+                               if (/<img src="data:image\/[a-zA-Z0-9]+;base64/.exec($html)) {
+                                       ev.data.preventDefault(true);
+                               }
+                       }
+               });
+               
                event.editor.on('insertText', function(ev) {
                        $insertedText = ev.data;
                }, null, null, 1);
@@ -76,7 +89,7 @@
                }
                
                // place button outside of <body> to prevent it being removed once deleting content
-               $('<button accesskey="s" />').hide().appendTo($(event.editor.document.$).find('html'));
+               $('<button accesskey="s" />').hide().appendTo($(event.editor.container.$).find('.cke_wysiwyg_div'));
                
        }
        
         * Converts html to bbcodes.
         */
        var toDataFormat = function(html, fixForBody) {
+               console.debug("toDataFormat");
                if (html == '<br>' || html == '<p><br></p>') {
                        return "";
                }