diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-14 11:51:18 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-14 11:51:18 +0200 |
| commit | 5274a620374d394cc977319cdbde6da89a7bca0c (patch) | |
| tree | 1f3181eefcc73fcb56ced47266755fae0a8c4d27 /addons/web_editor/static/src | |
| parent | 1813f42dbcca4779fb6e07a9b65e863f0d513dcc (diff) | |
| parent | 7b1362ac557b2fb12fd16240786ee0375b29272c (diff) | |
[MERGE] forward port branch 10.0 up to 7b1362ac557
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/backend.js | 2 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/summernote.js | 8 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/transcoder.js | 32 |
3 files changed, 34 insertions, 8 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index 964ececa06b..1c5feb7a7d4 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -146,7 +146,7 @@ var FieldTextHtmlSimple = widget.extend({ this.$content.html(this.text_to_html(value)); if (this.get("effective_readonly")) { this.resize(); - } else { + } else if (this.options['style-inline']) { transcoder.style_to_class(this.$content); } if (this.$content.is(document.activeElement)) { diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 435c5d7fa78..bae44f1998c 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -2003,7 +2003,13 @@ eventHandler.modules.toolbar.button.updateRecentColor = function (elBtn, sEvent, }; $(document).on('click keyup', function () { - var $popover = $((range.create()||{}).sc).closest('[contenteditable]'); + var current_range = {}; + try { + current_range = range.create() || {}; + } catch (e) { + // if range is on Restricted element ignore error + } + var $popover = $(current_range.sc).closest('[contenteditable]'); var popover_history = ($popover.data()||{}).NoteHistory; if(!popover_history || popover_history == history) return; var editor = $popover.parent('.note-editor'); diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js index a5cf20575d4..aff3b3210f6 100644 --- a/addons/web_editor/static/src/js/transcoder.js +++ b/addons/web_editor/static/src/js/transcoder.js @@ -182,14 +182,34 @@ var img_to_font = function ($editable) { }); }; +/* + * Utility function to apply function over descendants elements + * + * This is needed until the following issue of jQuery is solved: + * https://github.com./jquery/sizzle/issues/403 + * + * @param {Element} node The root Element node + * @param {Function} func The function applied over descendants + */ +var applyOverDescendants = function (node, func) { + node = node.firstChild; + while (node) { + if (node.nodeType === 1) { + func(node); + applyOverDescendants(node, func); + } + node = node.nextSibling; + } +}; + // convert class into inline style to send by mail var class_to_style = function ($editable) { if (!rulesCache.length) { getMatchedCSSRules($editable[0]); } - $editable.find('*').each(function () { - var $target = $(this); - var css = getMatchedCSSRules(this); + applyOverDescendants($editable[0], function (node) { + var $target = $(node); + var css = getMatchedCSSRules(node); var style = $target.attr("style") || ""; _.each(css, function (v,k) { if (!(new RegExp('(^|;)\s*' + k).test(style))) { @@ -209,9 +229,9 @@ var style_to_class = function ($editable) { var $c = $('<span/>').appendTo("body"); - $editable.find('*').each(function () { - var $target = $(this); - var css = getMatchedCSSRules(this); + applyOverDescendants($editable[0], function (node) { + var $target = $(node); + var css = getMatchedCSSRules(node); var style = ""; _.each(css, function (v,k) { if (!(new RegExp('(^|;)\s*' + k).test(style))) { |
