From f314cf0bb3dd715773e5ab1a5fcacd42bd3bd7fd Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 17 Jan 2018 18:45:35 +0100 Subject: [PATCH] [FIX] web_editor: `deleteContents` when no selection Changing the `deleteContents` method of the editor is tricky. This commit however dares to add a behavior: if the range does not represent a selection but only the cursor position and is then asked to delete its content... it should not do anything as nothing is selected. --- addons/web_editor/static/src/js/summernote.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 8385a79fb39..9760ef8c2a2 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -917,6 +917,10 @@ range.WrappedRange.prototype.isOnImg = function () { return nb === 1 && image; }; range.WrappedRange.prototype.deleteContents = function (towrite) { + if (this.sc === this.ec && this.so === this.eo) { + return this; + } + var prevBP = dom.removeBetween(this.sc, this.so, this.ec, this.eo, towrite); $(dom.node(prevBP.sc)).trigger("click"); // trigger click to disable and reanable editor and image handler