[FIX] web_editor: return all inserted nodes on insert
The `insert` command was not returning all inserted nodes. Part-of: odoo/odoo#137064
This commit is contained in:
@@ -233,12 +233,14 @@ export const editorCommands = {
|
||||
reference = child;
|
||||
}
|
||||
}
|
||||
const lastInsertedNodes = [...containerLastChild.childNodes];
|
||||
if (containerLastChild.hasChildNodes()) {
|
||||
const toInsert = [...containerLastChild.childNodes]; // Prevent mutation
|
||||
_insertAt(currentNode, [...toInsert], insertBefore);
|
||||
currentNode = insertBefore ? toInsert[0] : currentNode;
|
||||
lastChildNode = toInsert[toInsert.length - 1];
|
||||
}
|
||||
const firstInsertedNodes = [...containerFirstChild.childNodes];
|
||||
if (containerFirstChild.hasChildNodes()) {
|
||||
const toInsert = [...containerFirstChild.childNodes]; // Prevent mutation
|
||||
_insertAt(currentNode, [...toInsert], insertBefore);
|
||||
@@ -310,7 +312,7 @@ export const editorCommands = {
|
||||
newRange.setStart(lastPosition[0], lastPosition[1]);
|
||||
newRange.setEnd(lastPosition[0], lastPosition[1]);
|
||||
selection.addRange(newRange);
|
||||
return insertedNodes;
|
||||
return [...firstInsertedNodes, ...insertedNodes, ...lastInsertedNodes];
|
||||
},
|
||||
insertFontAwesome: (editor, faClass = 'fa fa-star') => {
|
||||
const insertedNode = editorCommands.insert(editor, document.createElement('i'))[0];
|
||||
|
||||
Reference in New Issue
Block a user