diff options
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; } |
