Remove empty paragraph after quote insert into empty editor
authorAlexander Ebert <ebert@woltlab.com>
Tue, 30 Aug 2016 10:28:25 +0000 (12:28 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 30 Aug 2016 10:28:30 +0000 (12:28 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js

index f28d1c5eee37f871cf9144e2a5ffb97dcd0f17f7..53e3e6d7d28f0261918d611c3d15935f73754a15 100644 (file)
@@ -15,8 +15,14 @@ $.Redactor.prototype.WoltLabInsert = function() {
                                /** @var Element */
                                var block = this.selection.block();
                                
+                               var isEmptyEditor = (this.$editor[0].innerHTML.replace(/<\/?p>/g, '').replace(/<br>/g, '').replace(/\u200B/g, '').trim() === '');
+                               
                                mpHtml.call(this, html, data);
                                
+                               if (isEmptyEditor) {
+                                       block = this.$editor[0].firstElementChild;
+                               }
+                               
                                if (block && block.nodeName === 'P' && block.nextElementSibling) {
                                        var removeBlock = false;
                                        if (block.childElementCount === 0 && block.textContent.replace(/\u200B/g, '').trim() === '') {