From f2c38d517b0a191c12f5e20ff83905b4a0dd057f Mon Sep 17 00:00:00 2001 From: Goaman Date: Mon, 7 Oct 2019 13:50:44 +0000 Subject: [PATCH] [FIX] web_editor: link from the web editor Before this commit, the feature for selecting a link and then clicking on the "link" button or hitting the CTRL+K was partially broken. The method "commonAncestor" was not returing the expected value. This commit add a check in the method "showLinkDialog" to prevent this error to happen. closes odoo/odoo#38103 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/editor/rte.summernote.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 95ce86572ae..d8338fd622d 100644 --- a/addons/web_editor/static/src/js/editor/rte.summernote.js +++ b/addons/web_editor/static/src/js/editor/rte.summernote.js @@ -452,8 +452,11 @@ eventHandler.modules.linkDialog.showLinkDialog = function ($editable, $dialog, l $editable.data('range').select(); $editable.data('NoteHistory').recordUndo(); - var link = linkInfo.range.commonAncestor().closest('a'); - linkInfo.className = link && link.className; + var commonAncestor = linkInfo.range.commonAncestor(); + if (commonAncestor && commonAncestor.closest) { + var link = commonAncestor.closest('a'); + linkInfo.className = link && link.className; + } var def = new $.Deferred(); core.bus.trigger('link_dialog_demand', {