diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js index fb86f92b25a..f97a97b8b46 100644 --- a/addons/web_editor/static/src/js/editor/rte.js +++ b/addons/web_editor/static/src/js/editor/rte.js @@ -569,7 +569,7 @@ var RTEWidget = Widget.extend({ var $target = $(ev.target); var $editable = $target.closest('.o_editable'); - if (!$editable.length) { + if (!$editable.length || $.summernote.core.dom.isContentEditableFalse($target)) { return; } @@ -604,8 +604,7 @@ var RTEWidget = Widget.extend({ }, 150); // setTimeout to remove flickering when change to editable zone (re-create an editor) this.$last = null; } - if ($editable.length && (!this.$last || this.$last[0] !== $editable[0]) && - ($target.closest('[contenteditable]').attr('contenteditable') || '').toLowerCase() !== 'false') { + if ($editable.length && (!this.$last || this.$last[0] !== $editable[0])) { $editable.summernote(this._getConfig($editable)); $editable.data('NoteHistory', history); diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js index 01b83530e48..141fb6ea229 100644 --- a/addons/web_editor/static/src/js/editor/rte.summernote.js +++ b/addons/web_editor/static/src/js/editor/rte.summernote.js @@ -771,7 +771,7 @@ eventHandler.attach = function (oLayoutInfo, options) { }); } oLayoutInfo.editable().on('mousedown', function (e) { - if (dom.isImg(e.target)) { + if (dom.isImg(e.target) && dom.isContentEditable(e.target)) { range.createFromNode(e.target).select(); } }); @@ -836,7 +836,12 @@ eventHandler.attach = function (oLayoutInfo, options) { var show_tooltip = true; oLayoutInfo.editor().on("dblclick", selector, function (e) { - if ($(e.target).closest(".note-toolbar").length) return; // prevent icon edition of top bar for default summernote + var $target = $(e.target); + if (!dom.isContentEditable($target)) { + // Prevent edition of non editable parts + return; + } + show_tooltip = false; callback(); e.stopImmediatePropagation(); @@ -844,7 +849,11 @@ eventHandler.attach = function (oLayoutInfo, options) { oLayoutInfo.editor().on("click", selector, function (e) { var $target = $(e.target); - if ($target.closest(".note-toolbar").length) return; // prevent icon edition of top bar for default summernote + if (!dom.isContentEditable($target)) { + // Prevent edition of non editable parts + return; + } + show_tooltip = true; setTimeout(function () { if (!show_tooltip) return; diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js index 4860931ea6b..f054eca48eb 100644 --- a/addons/web_editor/static/src/js/editor/summernote.js +++ b/addons/web_editor/static/src/js/editor/summernote.js @@ -649,7 +649,10 @@ dom.isNotBreakable = function (node) { return !dom.isText(node) && !dom.isBR(dom.firstChild(node)) && dom.isVoid(dom.firstChild(node)); }; dom.isContentEditable = function (node) { - return $(node).closest('[contenteditable]').is('[contenteditable="true"]'); + return $(node).closest('[contenteditable]').prop('contenteditable') === 'true'; +}; +dom.isContentEditableFalse = function (node) { + return $(node).closest('[contenteditable]').prop('contenteditable') === 'false'; }; dom.isFont = function (node) { var nodeName = node && node.nodeName.toUpperCase();