diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-02-15 10:58:08 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-02-15 10:58:08 +0100 |
| commit | a277b585072c63aab1daf9573914aa722627ae0e (patch) | |
| tree | 7c32d39632fa14b1229c42154fd48a727cc7b8ae /addons/web_editor/static/src/js/editor/transcoder.js | |
| parent | c69d00157ed2162b873a07a9f317016f109f802a (diff) | |
| parent | 259686ba78d7883b450fd014c5be8fa6622f77f3 (diff) | |
[MERGE] forward port branch 11.0 up to 259686ba78d
Diffstat (limited to 'addons/web_editor/static/src/js/editor/transcoder.js')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/transcoder.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/addons/web_editor/static/src/js/editor/transcoder.js b/addons/web_editor/static/src/js/editor/transcoder.js index 54bbc803645..d17f703d89e 100644 --- a/addons/web_editor/static/src/js/editor/transcoder.js +++ b/addons/web_editor/static/src/js/editor/transcoder.js @@ -18,18 +18,12 @@ function getMatchedCSSRules(a) { var sheets = document.styleSheets; for (i = sheets.length-1 ; i >= 0 ; i--) { var rules; - if (sheets[i].hasOwnProperty('rules')) { - rules = sheets[i].rules; - } else { - // try...catch because Firefox not able to enumerate - // document.styleSheets[].cssRules[] for cross-domain sheets. - try { - rules = sheets[i].cssRules; - } catch (e) { - console.warn("Can't read the css rules of: " + sheets[i].href, e); - continue; - } - rules = sheets[i].cssRules; + // try...catch because browser may not able to enumerate rules for cross-domain sheets + try { + rules = sheets[i].rules || sheets[i].cssRules; + } catch (e) { + console.warn("Can't read the css rules of: " + sheets[i].href, e); + continue; } if (rules) { for (r = rules.length-1; r >= 0; r--) { @@ -143,6 +137,20 @@ function getMatchedCSSRules(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; } |
