diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index ff1adb58410..8eb7d4104b5 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -4786,7 +4786,7 @@ export class OdooEditor extends EventTarget { if (splitAroundUrl.length === 3 && !splitAroundUrl[0] && !splitAroundUrl[2]) { // Pasted content is a single URL. const url = /^https?:\/\//i.test(text) ? text : 'http://' + text; - const youtubeUrl = this.options.allowCommandVideo &&YOUTUBE_URL_GET_VIDEO_ID.exec(url); + const youtubeUrl = this.options.allowCommandVideo && YOUTUBE_URL_GET_VIDEO_ID.exec(url); const urlFileExtention = url.split('.').pop(); const isImageUrl = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp'].includes(urlFileExtention.toLowerCase()); // A url cannot be transformed inside an existing link. @@ -4844,11 +4844,11 @@ export class OdooEditor extends EventTarget { name: this.options._t('Embed Youtube Video'), description: this.options._t('Embed the youtube video in the document.'), fontawesome: 'fa-youtube-play', - callback: () => { + callback: async () => { revertTextInsertion(); let videoElement; if (this.options.getYoutubeVideoElement) { - videoElement = this.options.getYoutubeVideoElement(youtubeUrl[0]); + videoElement = await this.options.getYoutubeVideoElement(youtubeUrl[0]); } else { videoElement = document.createElement('iframe'); videoElement.setAttribute('width', '560'); diff --git a/addons/web_editor/static/tests/html_field_tests.js b/addons/web_editor/static/tests/html_field_tests.js index b01c66d8940..e977aba44ef 100644 --- a/addons/web_editor/static/tests/html_field_tests.js +++ b/addons/web_editor/static/tests/html_field_tests.js @@ -841,4 +841,59 @@ QUnit.module("WebEditor.HtmlField", ({ beforeEach }) => { assert.equal(editor.editable.children[0].children[1].innerHTML.trim(), '
a
a
https://www.youtube.com/watch?v=qxb74CMR748