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 90ff64e85a0f794aa73ccf2399884b7dcaa1c0a9..4f46db25bda73e95ce8377da3b27b2fa789a246e 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 @@ -4509,7 +4509,12 @@ export class OdooEditor extends EventTarget { if (files.length && !clipboardElem.querySelector('table')) { this.addImagesFiles(files).then(html => this._applyCommand('insert', this._prepareClipboardData(html))); } else { - this._applyCommand('insert', clipboardElem); + if (closestElement(sel.anchorNode, 'a')) { + this._applyCommand('insert', clipboardElem.textContent); + } + else { + this._applyCommand('insert', clipboardElem); + } } } else { const text = ev.clipboardData.getData('text/plain'); diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js index 87e4f3be46aeb7353e68696a30668c2f06c86cec..710307aa2b87869cbb014220561195ee2bdbd7b7 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js @@ -1546,6 +1546,15 @@ describe('Paste', () => { contentAfter: `<p><a href="${url}">${url}</a> abc <a href="${videoUrl}">${videoUrl}</a> def <a href="${imgUrl}">${imgUrl}</a>[]</p>`, }); }); + it('should paste plain text inside non empty link', async () => { + await testEditor(BasicEditor, { + contentBefore: '<p><a href="#">a[]b</a></p>', + stepFunction: async editor => { + await pasteHtml(editor, '<span>123</span>'); + }, + contentAfter: '<p><a href="#">a123[]b</a></p>', + }); + }); }); describe('range not collapsed', async () => { it('should paste and transform an URL in a p', async () => {