From d114665df37951cfe28529388717b36fb762209f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 6 Jan 2017 11:58:13 +0100 Subject: [PATCH] Strip `data-title` in HTML view This is a dynamic property used for visual purposes only and is computed on-the-fly when editing the other `data`-attributes. --- .../js/3rdParty/redactor2/plugins/WoltLabSource.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js index 66ffc4f6a1..bd57c711b7 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSource.js @@ -3,6 +3,8 @@ $.Redactor.prototype.WoltLabSource = function() { return { init: function () { + var id = this.$element[0].id; + var fixQuotes = function(container) { // fix empty quotes suffering from a superfluous

elBySelAll('woltlab-quote', container, function(quote) { @@ -24,6 +26,14 @@ $.Redactor.prototype.WoltLabSource = function() { }); }; + var stripIntermediateCode = function(div) { + elBySelAll('pre, woltlab-quote, woltlab-spoiler', div, function (element) { + element.removeAttribute('data-title'); + }); + + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor2', 'source_' + stripIntermediateCode + '_' + id, { div: div }); + }; + function stripIcons(div) { elBySelAll('.icon, .fa', div, function (element) { var classNames = element.className.split(' '); @@ -88,13 +98,14 @@ $.Redactor.prototype.WoltLabSource = function() { var div = elCreate('div'); div.innerHTML = textarea.value; fixQuotes(div); + stripIntermediateCode(div); textarea.value = this.WoltLabSource.format(div.innerHTML); textarea.selectionStart = textarea.selectionEnd = textarea.value.length; }).bind(this); - WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'validate_' + this.$element[0].id, (function (data) { + WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'validate_' + id, (function (data) { if (textarea.clientHeight) { data.api.throwError(this.$element[0], WCF.Language.get('wcf.editor.source.error.active')); data.valid = false; -- 2.20.1