From c4ddf55880b7aa83580aa8ab312ba71f093a7587 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 11 Jun 2018 15:26:16 +0200 Subject: [FIX] web_editor: link don't duplicate child text If we applied a link eg. on: ``` hello world ``` The system actually gets the "label": hello worldworld because there is 3 nodes: text node: hello element node: `world` text node: world Also since "hello worldworld" is different than "hello world", instead of just keeping existing nodes and adding the link, the system would replace the selected range by: `hello worldworld' instead of: `hello world` This commit ignores element nodes when creating a new link, since when getting the label of the link from the selection, only the text nodes insides the element nodes have any interest. There was a second issue because if we had: ``` world! ``` and tried to put a link over "world!", the code would decide: "world" is inside a link so we will just update that link. Thus we would get: ``` world!! ``` instead of: ``` world! ``` opw-1848351 closes #25187 --- addons/web_editor/static/src/js/widgets.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index f23e196997a..b7e21996e45 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -1025,6 +1025,8 @@ var LinkDialog = Dialog.extend({ if (dom.ancestor(nodes[i], dom.isImg)) { this.data.images.push(dom.ancestor(nodes[i], dom.isImg)); text += '[IMG]'; + } else if (!is_link && nodes[i].nodeType === 1) { + // just use text nodes from listBetween } else if (!is_link && i===0) { text += nodes[i].textContent.slice(so, Infinity); } else if (!is_link && i===nodes.length-1) { -- cgit v1.2.3 From 50418c481182cb414792da32f2a0529503e59f9c Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 13 Jun 2018 17:04:34 +0200 Subject: [FIX] web_editor: properly save media dialog without any image When saving the media dialog without any selected image, a crash occurred. Now, it properly closes the dialog. opw-1858614 --- addons/web_editor/static/src/js/widgets.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index b7e21996e45..675c5c60598 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -326,8 +326,7 @@ var ImageDialog = Widget.extend({ var img = this.images[0]; if (!img) { - var id = this.$(".existing-attachments [data-src]:first").data('id'); - img = _.find(this.images, function (img) { return img.id === id;}); + return this.media; } if (!img.is_document) { -- cgit v1.2.3