From ed3a213b045b3f3c3eff3d68d775b24ff4e0aad3 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Tue, 20 Jun 2023 11:25:47 +0000 Subject: [PATCH] [FIX] web_editor: properly convert svg shapes When converting inline svg shapes to images, we checked if the source ended with ".svg", which is not enough, as it can include query parameters (eg, .svg?color=red). We now simply check if it includes ".svg" instead. We also need to make sure we didn't make a clone of the image in an mso before converting it, as the source wouldn't get converted in the mso. closes odoo/odoo#125839 X-original-commit: 3e9fa219ce612875aa034d95080f9cca1f972d27 Signed-off-by: David Monjoie (dmo) --- .../web_editor/static/src/js/backend/convert_inline.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index dc03658f4a9..d2f8c0a38c5 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -697,6 +697,11 @@ async function toInline($editable, cssRules, $iframe) { for (const imgTop of editable.querySelectorAll('.card-img-top')) { imgTop.style.setProperty('height', _getHeight(imgTop) + 'px'); } + + attachmentThumbnailToLinkImg($editable); + fontToImg($editable); + await svgToPng($editable); + // Fix img-fluid for Outlook. for (const image of editable.querySelectorAll('img.img-fluid')) { const width = _getWidth(image); @@ -708,9 +713,6 @@ async function toInline($editable, cssRules, $iframe) { _hideForOutlook(image); } - attachmentThumbnailToLinkImg($editable); - fontToImg($editable); - await svgToPng($editable); classToStyle($editable, cssRules); bootstrapToTable(editable); cardToTable(editable); @@ -1202,7 +1204,7 @@ function normalizeRem($editable, rootFontSize=16) { * @param {JQuery} $editable */ async function svgToPng($editable) { - for (const svg of $editable.find('img[src$=".svg"]')) { + for (const svg of $editable.find('img[src*=".svg"]')) { // Make sure the svg is loaded before we convert it. await new Promise(resolve => { svg.onload = () => resolve();