[FIX] web_editor: remove non-connected nodes in applyColor command
Before this commit, the `applyColor` command returned non-connected nodes (nodes with no parent) in some not well-defined situations, leading to a Warning when `selection.addRange()` was called by `_processAndApplyColor` with such non-connected node as argument. This commit properly removes such non-connected nodes from the array returned by `applyColor`. closes odoo/odoo#117166 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -588,13 +588,15 @@ export const editorCommands = {
|
||||
return font;
|
||||
});
|
||||
// Color the selected <font>s and remove uncolored fonts.
|
||||
for (const font of new Set(fonts)) {
|
||||
const fontsSet = new Set(fonts);
|
||||
for (const font of fontsSet) {
|
||||
colorElement(font, color, mode);
|
||||
if (!hasColor(font, mode) && !font.hasAttribute('style')) {
|
||||
for (const child of [...font.childNodes]) {
|
||||
font.parentNode.insertBefore(child, font);
|
||||
}
|
||||
font.parentNode.removeChild(font);
|
||||
fontsSet.delete(font);
|
||||
}
|
||||
}
|
||||
restoreCursor();
|
||||
@@ -606,7 +608,7 @@ export const editorCommands = {
|
||||
newSelection.removeAllRanges();
|
||||
newSelection.addRange(range);
|
||||
}
|
||||
return [...fonts, ...coloredTds];
|
||||
return [...fontsSet, ...coloredTds];
|
||||
},
|
||||
// Table
|
||||
insertTable: (editor, { rowNumber = 2, colNumber = 2 } = {}) => {
|
||||
|
||||
Reference in New Issue
Block a user