diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-07-22 10:05:49 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-07-22 10:05:49 +0000 |
| commit | aadc4a9f0be4a17ab3f25c48ac26feabf9aaab9a (patch) | |
| tree | 3b9dd52a473cc11d3a211c19ae62e8416ef6ef70 /addons/web_editor/static/src | |
| parent | 1ebec12dc0f5b2a431a52b89909a949529e0b6ad (diff) | |
| parent | fe4caecb59dd9a4456bbf40563a842ca7e318307 (diff) | |
[MERGE] Forward port of saas-12.3 to saas-12.4 up to fe4caecb59d
closes odoo/odoo#35059
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
3 files changed, 31 insertions, 6 deletions
diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js b/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js index 1738e6e7b48..d65c91aa682 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js @@ -1071,14 +1071,18 @@ var HelperPlugin = AbstractPlugin.extend({ If this error appears, the carret is moved to the beginning of the focused node.*/ console.error(e); - console.error('Informations for debugging', [ + var log = [ ['textContent', textContent], ['trimmed', trimmed], ['cleanContents', cleanContents], - ['start', range.sc.outerHTML || range.sc.textContent, range.so], - ['end', range.ec.outerHTML || range.ec.textContent, range.eo], - ['parent', range.sc.parentNode && range.sc.parentNode.outerHTML], - ]); + ]; + if (range) { + log.push( + ['start', range.sc.outerHTML || range.sc.textContent, range.so], + ['end', range.ec.outerHTML || range.ec.textContent, range.eo], + ['parent', range.sc.parentNode && range.sc.parentNode.outerHTML]); + } + console.error('Informations for debugging', log); } this.context.invoke('editor.saveRange'); }, diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js index 9014b367fee..5337661fa76 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/text.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/text.js @@ -106,7 +106,8 @@ var TextPlugin = AbstractPlugin.extend({ * @returns {Node[]} */ prepareClipboardData: function (clipboardData) { - var $clipboardData = this._removeIllegalClipboardElements($(clipboardData)); + var $html = $('<wrapper>' + clipboardData + '</wrapper>').contents(); + var $clipboardData = this._removeIllegalClipboardElements($html); var $all = $clipboardData.find('*').addBack(); $all.filter('table').addClass('table table-bordered'); diff --git a/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js b/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js index c4ee569ae88..a091a9eed90 100644 --- a/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js +++ b/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js @@ -253,6 +253,26 @@ $.fn.extend({ if (this.length) { Wysiwyg.setRangeFromNode(this[0]); var range = $.summernote.range.create(); + + try { + range.so; + } catch (e) { + /* Under certain unknown conditions, the range cannot be + applied and triggered an error. In order to allow the user to + keep editing, we need to prevent the dialog from showing, hence + the use of `console.error`. + If this error appears, the carret is moved to the beginning + of the focused node.*/ + console.error(e); + console.error('Informations for debugging', [ + ['elements', this], + ['outerHTML', this[0].outerHTML], + ['textContent', this[0].textContent], + ['html', this.html()], + ['previous selection', this.end().html()], + ]); + } + if (!range.sc.tagName && range.so === 0 && range.sc.textContent[range.so] === '\u200B') { range.so += 1; } |
