diff options
| author | Samuel Degueldre <sad@odoo.com> | 2020-12-11 08:15:27 +0000 |
|---|---|---|
| committer | Samuel Degueldre <sad@odoo.com> | 2020-12-15 10:20:42 +0000 |
| commit | c891eb46d304fae9cb444cffb7c0df578cf09638 (patch) | |
| tree | d3c4499cb23a64dd2e04a645a4d8c4cc517b49ab /addons/web_editor/static/src/js/editor | |
| parent | 49f3ee8ab4912c52f5e60b9392c5805272923064 (diff) | |
[FIX] web_editor: fix crash on chrome (cannot read editable of null)
This crash is caused by some of our integration code with summernote.
When clicking on a button of the toolbar, we attempt to create a range
from the current selection so that we can show the image toolbar if the
selection contains an image, but there was no check to see whether the
current selection was actually inside of the editable part of the page.
This causes issues later when we attempt to generate layoutInfo for the
image, as it will look for the editable area that contains the image and
fail.
This commit fixes that by making sure that the current selection is
inside of the editable area before adding it to the styleInfo.
opw-2376794
closes odoo/odoo#63373
X-original-commit: b26c57b4ab269ca7ad3ba3fc2b4a7f4d60d995e8
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/web_editor/static/src/js/editor')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/summernote.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/editor/summernote.js b/addons/web_editor/static/src/js/editor/summernote.js index f1145c8d8c1..290918a9563 100644 --- a/addons/web_editor/static/src/js/editor/summernote.js +++ b/addons/web_editor/static/src/js/editor/summernote.js @@ -2077,8 +2077,9 @@ eventHandler.modules.editor.currentStyle = function (target) { if (!styleInfo.image || !dom.isEditable(styleInfo.image)) { styleInfo.image = undefined; var r = range.create(); - if (r) + if (r && r.isOnEditable()) { styleInfo.image = r.isOnImg(); + } } // Fix when the target is a link: the text-align buttons state should // indicate the alignment of the link in the parent, not the text inside |
