diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-02-14 16:34:13 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-02-14 16:34:13 +0100 |
| commit | d24bdbde81be971be27e39ef7a2e1a1b2371074e (patch) | |
| tree | 5c1cc64cf0fadcf1879ef10f233a3793c47b6bfb /addons/web_editor/static/src/js | |
| parent | 33e7c8d60c58c98d2f679b66abae5af7ef224726 (diff) | |
| parent | 9d0de6111471860bc541058be351df4abb8ea167 (diff) | |
[MERGE] forward port branch saas-14 up to 9d0de611147
Diffstat (limited to 'addons/web_editor/static/src/js')
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 4 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/transcoder.js | 31 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/widgets.js | 16 |
3 files changed, 29 insertions, 22 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index e5d184117f4..f68bf8756bb 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -1010,7 +1010,9 @@ data.Editor = Class.extend({ this.$target.after($clone); this.buildingBlock.call_for_all_snippets($clone, function (editor, $snippet) { for (var i in editor.styles) { - editor.styles[i].on_clone($snippet); + editor.styles[i].on_clone($snippet, { + isCurrent: ($snippet.is($clone)), + }); } }); return false; diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js index 265ca5ab3f0..a5cf20575d4 100644 --- a/addons/web_editor/static/src/js/transcoder.js +++ b/addons/web_editor/static/src/js/transcoder.js @@ -9,17 +9,12 @@ var getMatchedCSSRules = function (a) { var sheets = document.styleSheets; for(var 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 stylesheets. - 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(var r = rules.length-1; r >= 0; r--) { @@ -131,6 +126,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; }; diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index d08f70e2aea..64772e319af 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -539,16 +539,12 @@ var getCssSelectors = function (filter) { var sheets = document.styleSheets; for(var i = 0; i < sheets.length; i++) { var rules; - if (sheets[i].rules) { - rules = sheets[i].rules; - } else { - //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets. - try { - rules = sheets[i].cssRules; - } catch(e) { - console.warn("Can't read the css rules of: " + sheets[i].href, e); - continue; - } + // try...catch because browser may not able to enumerate rules for cross-domain stylesheets + 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(var r = 0; r < rules.length; r++) { |
