From e87a3b8d4fab999d4e683ccec5045ecf74140b32 Mon Sep 17 00:00:00 2001 From: vishal padhiyar Date: Fri, 2 Sep 2022 05:51:27 +0000 Subject: [PATCH] [FIX] web_editor: copy paste link keeps the old url Before this commit: When we try to copy paste link into another link then url of the old link does not change and only lable change. After this commit: Now when we try to copy paste link into another link then the url of the link changes with the label. Task-2768541 closes odoo/odoo#105966 X-original-commit: ea1e410f4174d235609181bdba692a98e7381396 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/odoo-editor/src/OdooEditor.js | 2 +- .../js/editor/odoo-editor/test/spec/copyPaste.test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 59a812fd8d7..3012f2cd79b 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 @@ -1803,7 +1803,7 @@ export class OdooEditor extends EventTarget { // If the end container was fully selected, extractContents may have // emptied it without removing it. Ensure it's gone. const isRemovableInvisible = (node, noBlocks = true) => - !isVisible(node, noBlocks) && !isUnremovable(node) && node.nodeName !== 'A'; + !isVisible(node, noBlocks) && !isUnremovable(node); const endIsStart = end === start; while (end && isRemovableInvisible(end, false) && !end.contains(range.endContainer)) { const parent = end.parentNode; 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 d00c4d0f2da..569e4ac4512 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 @@ -1285,6 +1285,15 @@ describe('Copy and paste', () => { contentAfter: '

aboom[].comd

', }); }); + it('should paste and transform URL over the existing url', async () => { + await testEditor(BasicEditor, { + contentBefore: '

ab[http://www.xyz.com]cd

', + stepFunction: async editor => { + await pasteText(editor, 'https://www.xyz.xdc '); + }, + contentAfter: '

abhttps://www.xyz.xdc []cd

', + }); + }); }); describe('range not collapsed', async () => { it('should paste and transform an URL in a p', async () => {