From 8f2e1e454d80030d6b37282c722dd28919f9211a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 23 Jan 2017 13:57:33 +0100 Subject: [PATCH] Recognizing bold font-weights on paste --- .../3rdParty/redactor2/plugins/WoltLabClean.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); } } -- 2.20.1