[FIX] web_editor, mass_mailing: better transcode alignment inheritance

Browsers' default alignement of <td/> is 'inherit'. Some mail clients do
not set this value properly though and even if it is explicitely set,
they do not compute the final value well.

As a fix, this commit forces the 'inherit' value on <td/> and computes
the real alignment for 'inherit' values when transcoding.

opw-813688
This commit is contained in:
qsm-odoo
2018-02-13 13:37:50 +01:00
parent 1a7f3c7335
commit 32bdadad13
2 changed files with 19 additions and 0 deletions
@@ -46,6 +46,11 @@
background-color: @o_mm_def_color_alpha;
}
td {
// Default browser style but needed so that alignment works on some mail
// clients (see transcoder)
text-align: inherit;
}
// ===== Layout =====
.o_layout {
@@ -131,6 +131,20 @@ var getMatchedCSSRules = function (a) {
delete style['text-decoration-style'];
}
// text-align inheritance does not seem to get past <td> elements on some
// mail clients
if (style['text-align'] === 'inherit') {
var $el = $(a).parent();
do {
var align = $el.css('text-align');
if (_.indexOf(['left', 'right', 'center', 'justify'], align) >= 0) {
style['text-align'] = align;
break;
}
$el = $el.parent();
} while (!$el.is('html'));
}
return style;
};