Replace `<br>` inside dynamically converted code elements
authorAlexander Ebert <ebert@woltlab.com>
Tue, 5 Nov 2019 15:16:29 +0000 (16:16 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 5 Nov 2019 15:16:29 +0000 (16:16 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabBlock.js

index 15b206078ad6687ff6b2a106508c82c7339cec4b..8055e388059ff34727e758e896c59c2840c2cc14 100644 (file)
@@ -168,6 +168,14 @@ $.Redactor.prototype.WoltLabBlock = function() {
                                                elRemove(block);
                                        }
                                }
+
+                               // Convert any `<br>` inside `<pre>` with a plain newline character.
+                               if (firstBlock) {
+                                       elBySelAll('br', firstBlock, function(br) {
+                                               br.parentNode.insertBefore(document.createTextNode('\n'), br);
+                                               elRemove(br);
+                                       });
+                               }
                                
                                return $(firstBlock);
                        }).bind(this);