[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) <dmo@odoo.com>
This commit is contained in:
Antoine Guenet
2023-06-21 11:50:13 +02:00
parent 7d70122ac6
commit ed3a213b04
@@ -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();