[FIX] web_editor: unexpected copy paste behaviour of link
Current behaviour before commit: -When pasting copied content from editor inside link inserts text with HTML content, in result the pasted content seems isolated from the link. e.g. <a href="#">te[]st</a> + pasting <h1>123</h1> <=> <a href="#">te<h1>123</h1>st</a> Desired behaviour after commit: -Now only text content is pasted which makes pasted content as a part of the link. e.g. <a href="#">te[]st</a> + pasting <h1>123</h1> <=> <a href="#">te123st</a> closes odoo/odoo#134516 X-original-commit: 1cc3354b88658620c15fa18427b8725b6215337d Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -4638,7 +4638,12 @@ export class OdooEditor extends EventTarget {
|
||||
}
|
||||
});
|
||||
} 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');
|
||||
|
||||
@@ -1548,6 +1548,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 () => {
|
||||
|
||||
Reference in New Issue
Block a user