From a377708436bbd5e5bc71c76ce3af1f680c211116 Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Mon, 7 Nov 2022 13:03:23 +0000 Subject: [PATCH] [FIX] web_editor: fix pasting youtube videos from the editor Before this commit, following this flow in the Website Builder: - Enter edit mode, - Drop a snippet with text, - Paste a youtube video link, - Click on the "Embed Youtube Video" option of the powerbox, => There is a traceback. This is coming from the bad function calls in the Wysiwyg to create a video node. When [1] reworked the MediaDialog in owl, a first implementation was done exporting some utils (saveVideos, videoSpecificMediaClasses). But this implementation was not kept and later changed to use static methods and properties on the VideoSelector class (createElements and mediaSpecificClasses). Unfortunately, the outdated util methods used in the Wysiwyg were not changed, and it was breaking the youtube video instertions. This commit changes the Wysiwyg to use the existing VideoSelector.createElements and VideoSelector.mediaSpecificClasses static method and property to fix this flow. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-2687506 closes odoo/odoo#105475 X-original-commit: 4923c20c29170407d43908f983f2a168241f4817 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Younn Olivier (yol) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index f455251c3c6..1e9e686894f 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -3,7 +3,7 @@ odoo.define('web_editor.wysiwyg', function (require) { const { ComponentWrapper } = require('web.OwlCompatibility'); const { MediaDialogWrapper } = require('@web_editor/components/media_dialog/media_dialog'); -const { saveVideos, videoSpecificClasses } = require('@web_editor/components/media_dialog/video_selector'); +const { VideoSelector } = require('@web_editor/components/media_dialog/video_selector'); const dom = require('web.dom'); const core = require('web.core'); const { browser } = require('@web/core/browser/browser'); @@ -150,8 +150,8 @@ const Wysiwyg = Widget.extend({ route: '/web_editor/video_url/data', params: { video_url: url }, }); - const [savedVideo] = saveVideos([{src}]); - savedVideo.classList.add(...videoSpecificClasses); + const [savedVideo] = VideoSelector.createElements([{src}]); + savedVideo.classList.add(...VideoSelector.mediaSpecificClasses); return savedVideo; };