summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/rte.summernote.js
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2017-03-27 17:51:03 +0200
committerNicolas Lempereur <nle@odoo.com>2017-03-29 16:35:39 +0200
commit105243afa6008abe9176348baafb8de2ce7b2d9c (patch)
treeedb3c780c2dd58ea921dd37606d12c0b1934a11a /addons/web_editor/static/src/js/rte.summernote.js
parent1b5dcf29f58b5c6623fa01dd0fd5c6ebad09f0d8 (diff)
[FIX] web_editor: fix select and modify video
There was an issue when selecting a video tag: - a tag inside the video tag would be selected instead of the video tag so video could not be removed or modified (modifying it would add a video or image inside the video itself and so on). - the selection was not conveyed to the editor so it would be lost consequently due to some code who restored it to what was saved on the editor. This fix solves this by changing how the video tag was selected and saving the selected range on the editor. opw-724701
Diffstat (limited to 'addons/web_editor/static/src/js/rte.summernote.js')
-rw-r--r--addons/web_editor/static/src/js/rte.summernote.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js
index 869ece9cf58..df8aae48055 100644
--- a/addons/web_editor/static/src/js/rte.summernote.js
+++ b/addons/web_editor/static/src/js/rte.summernote.js
@@ -267,7 +267,15 @@ eventHandler.modules.popover.update = function ($popover, oStyle, isAirMode) {
$imagePopover.find('.o_image_alt').text( (alt || "").replace(/&quot;/g, '"') ).parent().toggle(oStyle.image.tagName === "IMG");
$imagePopover.show();
- range.createFromNode(dom.firstChild(oStyle.image)).select();
+ // for video tag (non-void) we select the range over the tag,
+ // for other media types we get the first descendant leaf element
+ var target_node = oStyle.image;
+ if (!oStyle.image.className.match(/(^|\s)media_iframe_video(\s|$)/i)) {
+ target_node = dom.firstChild(target_node);
+ }
+ range.createFromNode(target_node).select();
+ // save range on the editor so it is not lost if restored
+ eventHandler.modules.editor.saveRange(dom.makeLayoutInfo(target_node).editable());
} else {
$(".note-control-selection").hide();
}