[FIX] web_editor: fix line merge on color change
Before this commit: When using shift+enter to move to a new line, now applying bold, italics, underline, etc and then trying to add a color to both lines would result in lines merging. After this commit: Now when the both lines are bold and then applying a color to both the lines would no longer merge. closes odoo/odoo#119701 Task: 3269922 X-original-commit: 0473dbd0090dd7b2fb1ff59a83a38df941303681 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -567,7 +567,7 @@ export const editorCommands = {
|
||||
font = [];
|
||||
}
|
||||
} else if ((node.nodeType === Node.TEXT_NODE && !isWhitespace(node))
|
||||
|| node.nodeName === "BR"
|
||||
|| (node.nodeName === 'BR' && isEmptyBlock(node.parentNode))
|
||||
|| (node.nodeType === Node.ELEMENT_NODE &&
|
||||
['inline', 'inline-block'].includes(getComputedStyle(node).display) &&
|
||||
!isWhitespace(node.textContent) &&
|
||||
|
||||
@@ -61,4 +61,20 @@ describe('applyColor', () => {
|
||||
contentAfter: '<p>[</p><p></p><p>]</p>',
|
||||
});
|
||||
});
|
||||
it('should not merge line on background color change', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<p><strong>[abcd</strong><br><strong>efghi]</strong></p>',
|
||||
stepFunction: setColor('rgb(255, 0, 0)', 'backgroundColor'),
|
||||
contentAfter: '<p><strong><font style="background-color: rgb(255, 0, 0);">[abcd</font></strong><br>' +
|
||||
'<strong><font style="background-color: rgb(255, 0, 0);">efghi]</font></strong></p>',
|
||||
});
|
||||
});
|
||||
it('should not merge line on color change', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<p><strong>[abcd</strong><br><strong>efghi]</strong></p>',
|
||||
stepFunction: setColor('rgb(255, 0, 0)', 'color'),
|
||||
contentAfter: '<p><strong><font style="color: rgb(255, 0, 0);">[abcd</font></strong><br>' +
|
||||
'<strong><font style="color: rgb(255, 0, 0);">efghi]</font></strong></p>',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user