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 4a3289150b2..9adf0d6aee9 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 @@ -4378,18 +4378,25 @@ export class OdooEditor extends EventTarget { if (fragment.hasChildNodes()) { this._applyCommand('insert', fragment); } - } else if (files.length && targetSupportsHtmlContent) { - this.addImagesFiles(files).then(html => { - const imageNodes = this._applyCommand('insert', this._prepareClipboardData(html)); - if (imageNodes && this.options.dropImageAsAttachment) { - // Mark images as having to be saved as attachments. - for (const imageNode of imageNodes) { - imageNode.classList.add('o_b64_image_to_save'); + } else if ((files.length || clipboardHtml) && targetSupportsHtmlContent) { + const clipboardElem = this._prepareClipboardData(clipboardHtml); + // When copy pasting a table from the outside, a picture of the + // table can be included in the clipboard as an image file. In that + // particular case the html table is given a higher priority than + // the clipboard picture. + if (files.length && !clipboardElem.querySelector('table')) { + this.addImagesFiles(files).then(html => { + const imageNodes = this._applyCommand('insert', this._prepareClipboardData(html)); + if (imageNodes && this.options.dropImageAsAttachment) { + // Mark images as having to be saved as attachments. + for (const imageNode of imageNodes) { + imageNode.classList.add('o_b64_image_to_save'); + } } - } - }); - } else if (clipboardHtml && targetSupportsHtmlContent) { - this._applyCommand('insert', this._prepareClipboardData(clipboardHtml)); + }); + } else { + this._applyCommand('insert', clipboardElem); + } } else { const text = ev.clipboardData.getData('text/plain'); const selectionIsInsideALink = !!closestElement(sel.anchorNode, 'a');