[FIX] web_editor: properly copy editor content
When copying some list items in the editor and pasting it back into it, we lost their parent list, leading to paragraphs being pasted rather than a list. This restores the list. task-3050150 closes odoo/odoo#105386 X-original-commit: 2333d8470df2fac80247e6f39d740a29f1eeb561 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -3192,7 +3192,14 @@ export class OdooEditor extends EventTarget {
|
||||
clipboardEvent.preventDefault();
|
||||
const selection = this.document.getSelection();
|
||||
const range = selection.getRangeAt(0);
|
||||
const rangeContent = range.cloneContents();
|
||||
let rangeContent = range.cloneContents();
|
||||
|
||||
// Repair the copied range.
|
||||
if (rangeContent.firstChild.nodeName === 'LI') {
|
||||
const list = range.commonAncestorContainer.cloneNode();
|
||||
list.replaceChildren(...rangeContent.childNodes);
|
||||
rangeContent = list;
|
||||
}
|
||||
|
||||
const dataHtmlElement = document.createElement('data');
|
||||
dataHtmlElement.append(rangeContent);
|
||||
|
||||
Reference in New Issue
Block a user