Improved image handling in Redactor, disabled image resize
authorAlexander Ebert <ebert@woltlab.com>
Sun, 30 Mar 2014 17:04:52 +0000 (19:04 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 30 Mar 2014 17:04:52 +0000 (19:04 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index 9f639705a9e9aaf61405a68700564eba088c1419..7c9365165e9dfa0eb5ad80a66fee8ba2ad3d87ce 100644 (file)
@@ -181,7 +181,7 @@ RedactorPlugins.wbbcode = {
                html = html.replace(/<img [^>]*?class="smiley" alt="([^"]+?)".*?>/gi, '$1'); // chrome, ie
                
                // [img]
-               html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1 style="float: (left|right)".*?>/gi, "[img='$2',$3][/img]");
+               html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1 style="float: (left|right)[^"]*".*?>/gi, "[img='$2',$3][/img]");
                html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1.*?>/gi, '[img]$2[/img]');
                
                // [quote]
index 67e166d1d92905dbf143dc22d9402fff1c03fa31..cc1678d9366d7de0015a0fb25a38808088c253cd 100644 (file)
@@ -50,6 +50,11 @@ RedactorPlugins.wmonkeypatch = {
                        $mpModalInit.call(self, title, content, width, callback);
                };
                
+               var $mpImageResizeControls = this.imageResizeControls;
+               this.imageResizeControls = function(image) {
+                       return $mpImageResizeControls.call(self, image).hide();
+               };
+               
                this.setOption('modalOpenedCallback', $.proxy(this.modalOpenedCallback, this));
                
                this.modalTemplatesInit();
@@ -114,12 +119,43 @@ RedactorPlugins.wmonkeypatch = {
                                        + '<dt><label for="redactor_file_link">' + this.opts.curLang.image_web_link + '</label></dt>'
                                        + '<dd><input type="text" name="redactor_file_link" id="redactor_file_link" class="long"  /></dd>'
                                + '</dl>'
+                               + '<dl>'
+                                       + '<dt><label for="redactor_form_image_align">' + this.opts.curLang.image_position + '</label></dt>'
+                                       + '<dd>'
+                                               + '<select id="redactor_form_image_align">'
+                                                       + '<option value="none">' + this.opts.curLang.none + '</option>'
+                                                       + '<option value="left">' + this.opts.curLang.left + '</option>'
+                                                       + '<option value="right">' + this.opts.curLang.right + '</option>'
+                                               + '</select>'
+                                       + '</dd>'
+                               + '</dl>'
                        + '</fieldset>'
                        + '<div class="formSubmit">'
                                + '<button id="redactor_upload_btn">' + this.opts.curLang.insert + '</button>'
                        + '</div>'
                );
                
+               this.setOption('modal_image_edit', this.getOption('modal_image').replace(
+                       '<button id="redactor_upload_btn">' + this.opts.curLang.insert + '</button>',
+                       '<button id="redactorSaveBtn">' + this.opts.curLang.save + '</button>'
+               ));
+               
+               this.setOption('modal_link',
+                       '<fieldset>'
+                               + '<dl>'
+                                       + '<dt><label for="redactor_link_url">URL</label></dt>'
+                                       + '<dd><input type="text" id="redactor_link_url" class="long" /></dd>'
+                               + '</dl>'
+                               + '<dl>'
+                                       + '<dt><label for="redactor_link_url_text">' + this.opts.curLang.text + '</label></dt>'
+                                       + '<dd><input type="text" id="redactor_link_url_text" class="long" /></dd>'
+                               + '</dl>'
+                       + '</fieldset>'
+                       + '<div class="formSubmit">'
+                               + '<button id="redactor_insert_link_btn">' + this.opts.curLang.insert + '</button>'
+                       + '</div>'
+               );
+               
                this.setOption('modal_table',
                        '<fieldset>'
                                + '<dl>'
@@ -148,42 +184,13 @@ RedactorPlugins.wmonkeypatch = {
                                        + '</div>'
                                + '</form>'
                        + '</section>',
-
-                       modal_image_edit: String()
-                       + '<section id="redactor-modal-image-edit">'
-                               + '<label>' + this.opts.curLang.title + '</label>'
-                               + '<input type="text" id="redactor_file_alt" class="redactor_input" />'
-                               + '<label>' + this.opts.curLang.link + '</label>'
-                               + '<input type="text" id="redactor_file_link" class="redactor_input" />'
-                               + '<label><input type="checkbox" id="redactor_link_blank"> ' + this.opts.curLang.link_new_tab + '</label>'
-                               + '<label>' + this.opts.curLang.image_position + '</label>'
-                               + '<select id="redactor_form_image_align">'
-                                       + '<option value="none">' + this.opts.curLang.none + '</option>'
-                                       + '<option value="left">' + this.opts.curLang.left + '</option>'
-                                       + '<option value="center">' + this.opts.curLang.center + '</option>'
-                                       + '<option value="right">' + this.opts.curLang.right + '</option>'
-                               + '</select>'
-                       + '</section>'
-                       + '<footer>'
-                               + '<button id="redactor_image_delete_btn" class="redactor_modal_btn redactor_modal_delete_btn">' + this.opts.curLang._delete + '</button>'
-                               + '<button class="redactor_modal_btn redactor_btn_modal_close">' + this.opts.curLang.cancel + '</button>'
-                               + '<button id="redactorSaveBtn" class="redactor_modal_btn redactor_modal_action_btn">' + this.opts.curLang.save + '</button>'
-                       + '</footer>',
-
+                       // img edit
+                       
                        // img
 
-                       modal_link: String()
-                       + '<section id="redactor-modal-link-insert">'
-                               + '<label>URL</label>'
-                               + '<input type="text" class="redactor_input" id="redactor_link_url" />'
-                               + '<label>' + this.opts.curLang.text + '</label>'
-                               + '<input type="text" class="redactor_input" id="redactor_link_url_text" />'
-                               + '<label><input type="checkbox" id="redactor_link_blank"> ' + this.opts.curLang.link_new_tab + '</label>'
-                       + '</section>'
-                       + '<footer>'
-                               + '<button class="redactor_modal_btn redactor_btn_modal_close">' + this.opts.curLang.cancel + '</button>'
-                               + '<button id="redactor_insert_link_btn" class="redactor_modal_btn redactor_modal_action_btn">' + this.opts.curLang.insert + '</button>'
-                       + '</footer>',
+                       // link
+                       
+                       // table
                        
                        modal_video: String()
                        + '<section id="redactor-modal-video-insert">'
@@ -274,5 +281,5 @@ RedactorPlugins.wmonkeypatch = {
                        callback.call(this, node);
 
                }, this ) );
-       },
+       }
 }
\ No newline at end of file