Fixed image handling
authorAlexander Ebert <ebert@woltlab.com>
Mon, 1 Aug 2016 09:37:43 +0000 (11:37 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 1 Aug 2016 09:37:54 +0000 (11:37 +0200)
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/acp/templates/wysiwyg.tpl
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabUtils.js [new file with mode: 0644]

index e7bb151a13dac2ca4f56f758437d79a81e3bf7c9..5a3e8a03ef4580ae53828a96b3c2fd9682b99954 100644 (file)
@@ -37,7 +37,8 @@
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}',
-                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSpoiler.js?v={@LAST_UPDATE_TIME}'
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSpoiler.js?v={@LAST_UPDATE_TIME}',
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabUtils.js?v={@LAST_UPDATE_TIME}'
                {else}
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/redactor.min.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/combined.min.js?v={@LAST_UPDATE_TIME}'
                                        'WoltLabQuote',
                                        'WoltLabSize',
                                        'WoltLabSmiley',
-                                       'WoltLabSpoiler'
+                                       'WoltLabSpoiler',
+                                       'WoltLabUtils'
                                ],
                                toolbarFixed: false,
                                woltlab: {
index e7bb151a13dac2ca4f56f758437d79a81e3bf7c9..5a3e8a03ef4580ae53828a96b3c2fd9682b99954 100644 (file)
@@ -37,7 +37,8 @@
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}',
-                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSpoiler.js?v={@LAST_UPDATE_TIME}'
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSpoiler.js?v={@LAST_UPDATE_TIME}',
+                       '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabUtils.js?v={@LAST_UPDATE_TIME}'
                {else}
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/redactor.min.js?v={@LAST_UPDATE_TIME}',
                        '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/combined.min.js?v={@LAST_UPDATE_TIME}'
                                        'WoltLabQuote',
                                        'WoltLabSize',
                                        'WoltLabSmiley',
-                                       'WoltLabSpoiler'
+                                       'WoltLabSpoiler',
+                                       'WoltLabUtils'
                                ],
                                toolbarFixed: false,
                                woltlab: {
diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabUtils.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabUtils.js
new file mode 100644 (file)
index 0000000..539cf4b
--- /dev/null
@@ -0,0 +1,17 @@
+$.Redactor.prototype.WoltLabUtils = function() {
+       "use strict";
+       
+       return {
+               init: function() {
+                       var mpReplaceToTag = this.utils.replaceToTag;
+                       this.utils.replaceToTag = (function (node, tag) {
+                               if (tag === 'figure') {
+                                       // prevent <p> wrapping an <img> being replaced
+                                       return node;
+                               }
+                               
+                               return mpReplaceToTag.call(this, node, tag);
+                       }).bind(this);
+               }
+       };
+};