From 3c89439a16c41d553322893761a35592b73a5338 Mon Sep 17 00:00:00 2001 From: vishal padhiyar Date: Thu, 14 Sep 2023 17:17:39 +0530 Subject: [PATCH] [FIX] web_editor: calling openMediaDialog on replace media Before this commit: In mass mailing, Selecting image and click on replace media you get picture middle of the screen. After this commit: Now, clicking on replace would open media dialog and replace picture. task-3506590 closes odoo/odoo#137920 X-original-commit: 7e0b8af005e818c9283b332fb140aeaeaf028275 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/editor/snippets.options.js | 5 ++--- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 2f624638c73..660902f7052 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -5463,9 +5463,8 @@ registry.ReplaceMedia = SnippetOptionWidget.extend({ * @see this.selectClass for parameters */ async replaceMedia() { - // TODO for now, this simulates a double click on the media, - // to be refactored when the new editor is merged - this.$target.dblclick(); + // open mediaDialog and replace the media. + await this.options.wysiwyg.openMediaDialog({ node:this.$target[0] }); }, /** * Makes the image a clickable link by wrapping it in an . diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 04da6065b56..813acbe5572 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1512,7 +1512,7 @@ export class Wysiwyg extends Component { // selection when the modal is closed. const restoreSelection = preserveCursor(this.odooEditor.document); - const $editable = $(OdooEditorLib.closestElement(range.startContainer, '.o_editable') || this.odooEditor.editable); + const $editable = $(OdooEditorLib.closestElement(params.node || range.startContainer, '.o_editable') || this.odooEditor.editable); const model = $editable.data('oe-model'); const field = $editable.data('oe-field'); const type = $editable.data('oe-type');