diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-02-08 16:43:44 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-02-08 16:43:44 +0100 |
| commit | 1b5ecbb04710b3880b98f78935f73bc92098a5da (patch) | |
| tree | d95b0c5a3621bafc38e589f585ee6222360decbf /addons/web_editor/static/src/js/summernote.js | |
| parent | 84b0ec4da361adab9a4fa1943491fc4c745c762a (diff) | |
| parent | ce51ad7e69dbc1415eaf5f2ae846bbe89a37f69b (diff) | |
[MERGE] forward port branch 9.0 up to ce51ad7e69d
Diffstat (limited to 'addons/web_editor/static/src/js/summernote.js')
| -rw-r--r-- | addons/web_editor/static/src/js/summernote.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 8166d77201e..2678ba955af 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -953,15 +953,21 @@ range.WrappedRange.prototype.deleteContents = function (towrite) { return this; } - var prevBP = dom.removeBetween(this.sc, this.so, this.ec, this.eo, towrite); + var r; + var image = this.isOnImg(); + if (image) { + // If the range matches/is in an image, then the image is to be removed + // and the cursor moved to its previous position + var parentNode = image.parentNode; + var index = _.indexOf(parentNode.childNodes, image); + parentNode.removeChild(image); + r = new range.WrappedRange(parentNode, index, parentNode, index); + } else { + r = 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 - return new range.WrappedRange( - prevBP.sc, - prevBP.so, - prevBP.ec, - prevBP.eo - ); + $(dom.node(r.sc)).trigger("click"); // trigger click to disable and reanable editor and image handler + return new range.WrappedRange(r.sc, r.so, r.ec, r.eo); }; range.WrappedRange.prototype.clean = function (mergeFilter, all) { var node = dom.node(this.sc === this.ec ? this.sc : this.commonAncestor()); @@ -1310,7 +1316,7 @@ function summernote_keydown_clean (field) { function remove_table_content(r) { var ancestor = r.commonAncestor(); - var nodes = dom.listBetween(r.sc, r.ec); + var nodes = dom.listBetween(r.sc, r.ec, r.so, r.eo); if (dom.isText(r.sc)) { r.sc.textContent = r.sc.textContent.slice(0, r.so); } |
