From: Alexander Ebert Date: Mon, 23 Jan 2017 12:57:33 +0000 (+0100) Subject: Recognizing bold font-weights on paste X-Git-Tag: 3.0.2~69 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8f2e1e454d80030d6b37282c722dd28919f9211a;p=GitHub%2FWoltLab%2FWCF.git Recognizing bold font-weights on paste --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js index 0e5472396a..4678855fab 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabClean.js @@ -129,7 +129,7 @@ $.Redactor.prototype.WoltLabClean = function() { var div = elCreate('div'); div.innerHTML = html.replace(/@@@WOLTLAB-P-ALIGN-(?:left|right|center|justify)@@@/g, ''); - var element, elements = elBySelAll('[style]', div), property, removeStyles; + var element, elements = elBySelAll('[style]', div), property, removeStyles, strong, styleValue; for (var i = 0, length = elements.length; i < length; i++) { element = elements[i]; @@ -139,6 +139,21 @@ $.Redactor.prototype.WoltLabClean = function() { //noinspection JSUnresolvedVariable if (this.opts.woltlab.allowedInlineStyles.indexOf(property) === -1) { + if (property === 'font-weight') { + styleValue = element.style.getPropertyValue(property); + if (styleValue === 'bold' || styleValue === 'bolder') { + styleValue = 600; + } + + styleValue = ~~styleValue; + if (styleValue > 500) { + // treat anything above 500 as bold + strong = elCreate('strong'); + element.parentNode.insertBefore(strong, element); + strong.appendChild(element); + } + } + removeStyles.push(property); } }