From: Alexander Ebert Date: Thu, 25 Aug 2016 09:52:41 +0000 (+0200) Subject: Fixed empty paragraphs after paste X-Git-Tag: 3.0.0_Beta_1~512 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=712cba98a028043aa329e89bba918519caeacfef;p=GitHub%2FWoltLab%2FWCF.git Fixed empty paragraphs after paste --- diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index 4abf9700cb..c26711b263 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -21,6 +21,7 @@ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabEvent.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabImage.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInlineCode.js?v={@LAST_UPDATE_TIME}', + '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabInsert.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabKeydown.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabLink.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}', @@ -171,6 +172,7 @@ 'WoltLabEvent', 'WoltLabImage', 'WoltLabInlineCode', + 'WoltLabInsert', 'WoltLabLink', 'WoltLabModal', 'WoltLabPaste', diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js new file mode 100644 index 0000000000..2a220a5051 --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabInsert.js @@ -0,0 +1,24 @@ +$.Redactor.prototype.WoltLabInsert = function() { + "use strict"; + + return { + init: function () { + var mpHtml = this.insert.html; + this.insert.html = (function (html, data) { + this.placeholder.hide(); + this.core.editor().focus(); + + /** @var Element */ + var block = this.selection.block(); + + mpHtml.call(this, html, data); + + if (block && block.nodeName === 'P' && block.nextElementSibling && !block.childElementCount && block.textContent.replace(/\u200B/g, '').trim() === '') { + // inserting HTML tends to cause new paragraphs inserted + // rather than using the current, empty one + elRemove(block); + } + }).bind(this); + } + }; +};