From c3e08e7a7baab1035c3d5c48d668cc02a232e1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Tue, 27 Apr 2021 09:59:46 +0000 Subject: [PATCH] [FIX] web_editor: add support for a.btn-link in emails templates closes odoo/odoo#69922 X-original-commit: 7062ad7495d4ecd7e8a1a89419375c74411c1752 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/widgets/link.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js index 4565001970b..bc685e4d5a7 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js @@ -77,8 +77,6 @@ const Link = Widget.extend({ } $node = $node.parent(); } - this.data.className = this.data.iniClassName.replace(/(^|\s+)btn(-[a-z0-9_-]*)?/gi, ' '); - const textLink = this.$link[0] || this.data.range.cloneContents(); const [encodedText, images] = this._encodeNodeToText(textLink); this.data.originalText = this._decodeText(encodedText, images); @@ -116,7 +114,7 @@ const Link = Widget.extend({ } active = subActive; } else { - active = !this.data.iniClassName || !this.data.iniClassName.includes('btn-'); + active = !this.data.iniClassName || this.data.iniClassName.includes('btn-link') || !this.data.iniClassName.includes('btn-'); } this._setSelectOption($option, active); } @@ -144,6 +142,11 @@ const Link = Widget.extend({ * @param {object} data */ applyLinkToDom: function (data) { + // Some mass mailing template use instead of just a simple . + // And we need to keep the classes because the a.btn.btn-link have some special css rules. + if (!data.classes.includes('btn') && this.data.iniClassName.includes("btn-link")) { + data.classes += " btn btn-link"; + } const attrs = Object.assign({}, this.data.oldAttributes, { href: data.url, target: data.isNewWindow ? '_blank' : '',