[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) <dmo@odoo.com>
This commit is contained in:
committed by
Hiral Bhavsar
parent
2774e276ac
commit
e87a3b8d4f
@@ -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;
|
||||
|
||||
@@ -1285,6 +1285,15 @@ describe('Copy and paste', () => {
|
||||
contentAfter: '<p>a<a href="https://boom.com">boom[].com</a>d</p>',
|
||||
});
|
||||
});
|
||||
it('should paste and transform URL over the existing url', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<p>ab[<a href="http://www.xyz.com">http://www.xyz.com</a>]cd</p>',
|
||||
stepFunction: async editor => {
|
||||
await pasteText(editor, 'https://www.xyz.xdc ');
|
||||
},
|
||||
contentAfter: '<p>ab<a href="https://www.xyz.xdc">https://www.xyz.xdc</a> []cd</p>',
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('range not collapsed', async () => {
|
||||
it('should paste and transform an URL in a p', async () => {
|
||||
|
||||
Reference in New Issue
Block a user